@@ -4,12 +4,15 @@ py-esp32-ulp Documentation
4
4
py-esp32-ulp is an assembler toolchain for the ESP32 ULP (Ultra Low-Power)
5
5
Co-Processor, written in MicroPython.
6
6
7
+ .. contents :: Table of Contents
8
+
7
9
8
10
What is it useful for?
9
11
----------------------
10
12
11
- It can translate small assembly language programs to a loadable/executable
12
- ULP machine code binary, directly on the ESP32 microcontroller.
13
+ py-esp32-ulp can translate small assembly language programs to a
14
+ loadable/executable ULP machine code binary, directly on the ESP32
15
+ microcontroller.
13
16
14
17
This is intended as an alternative approach to assembling such programs using
15
18
the binutils-esp32ulp toolchain from Espressif on a development machine.
@@ -55,30 +58,31 @@ On the ESP32, install using upip:
55
58
On a PC, simply ``git clone `` this repo.
56
59
57
60
58
- Examples
59
- --------
61
+ Getting started
62
+ ---------------
60
63
61
- Quick start
62
- +++++++++++
63
- The quickest way to get started is to try one of the `examples </examples/ >`_.
64
+ On the ESP32
65
+ ++++++++++++
64
66
65
- The simplest example is `counter.py </examples/counter.py >`_. It shows how to
66
- assemble code, load and run the resulting binary and exchange data between the
67
- ULP and the main CPU.
67
+ The simplest example to try on the ESP32 is `counter.py </examples/counter.py >`_.
68
+ It shows how to assemble code, load and run the resulting binary and exchange
69
+ data between the ULP and the main CPU.
68
70
69
71
Run the ``counter.py `` example:
70
72
71
73
1. Install py-esp32-ulp onto the ESP32 as shown above
72
- 2. Upload the `counter.py </examples/counter.py >`_ file to the ESP32
74
+ 2. Upload the `examples/ counter.py </examples/counter.py >`_ file to the ESP32
10000
code>
73
75
3. Run with ``import counter ``
74
76
75
77
You can also try the `blink.py </examples/blink.py >`_ example, which shows how to
76
78
let the ULP blink an LED.
77
79
78
80
Look inside each example for a more detailed description.
79
81
80
- Using on a PC
81
- +++++++++++++
82
+
83
+ On a PC
84
+ +++++++
85
+
82
86
On a PC with the unix port of MicroPython, you can assemble source code as
83
87
follows:
84
88
@@ -88,9 +92,11 @@ follows:
88
92
cd py-esp32-ulp
89
93
micropython -m esp32_ulp path/to/code.S # this results in path/to/code.ulp
90
94
95
+
91
96
More examples
92
97
+++++++++++++
93
- More ULP examples from around the web:
98
+
99
+ Other ULP examples from around the web:
94
100
95
101
* https://github.com/espressif/esp-iot-solution/tree/master/examples/ulp_examples
96
102
* https://github.com/duff2013/ulptool
@@ -100,30 +106,30 @@ More ULP examples from around the web:
100
106
Advanced usage
101
107
--------------
102
108
103
- In real world applications, you might want to separate the assembly stage from
104
- the loading/running stage, to avoid having to assemble the code on every startup.
105
- This can be useful for battery-powered applications, where every second of sleep
109
+ In some applications you might want to separate the assembly stage from the
110
+ loading/running stage, to avoid having to assemble the code on every startup.
111
+ This can be useful in battery-powered applications where every second of sleep
106
112
time matters.
107
113
108
- Splitting the assembly and load stage can be combined with other techniques to
109
- for example implement a caching mechansim for the ULP binary, which automatically
110
- updates the binary every time the assembly source code changes.
114
+ Splitting the assembly and load stage can be combined with other techniques,
115
+ for example to implement a caching mechansim for the ULP binary that
116
+ automatically updates the binary every time the assembly source code changes.
111
117
112
- The ``esp32_ulp.assemble_file `` function stores the assembled and linked binary
113
- into a file with a ``.ulp `` extension, which can later be loaded directly without
114
- assembling the source again.
118
+ The ``esp32_ulp.assemble_file `` function can be used to assemble and link an
119
+ assembly source file into a machine code binary file with a ``.ulp `` extension.
120
+ That file can then be loaded directly without assembling the source again.
115
121
116
- 1. Create/upload an assembly source file and run the following to get a loadable
117
- ULP binary as a ``.ulp `` file:
122
+ 1. Create/upload an assembly source file and run the following to get a
123
+ loadable ULP binary as a ``.ulp `` file:
118
124
119
125
.. code-block :: python
120
126
121
127
import esp32_ulp
122
128
esp32_ulp.assemble_file(' code.S' ) # this results in code.ulp
123
129
124
- 2. The above prints out the offsets of all global symbols/labels. For the next step,
125
- you will need to note down the offset of the label, which represents the entry
126
- point to your code.
130
+ 2. The above prints out the offsets of all global symbols/labels. For the next
131
+ step, you will need to note down the offset of the label, which represents
132
+ the entry point to your code.
127
133
128
134
3. Now load and run the resulting binary as follows:
129
135
@@ -147,9 +153,10 @@ assembling the source again.
147
153
# 2 words * 4 = 8 bytes
148
154
ulp.run(2 * 4 ) # specify the offset of the entry point label
<
57AE
td data-grid-cell-id="diff-8d068e8797e88947c320f79e856c3e16a72b730124a8f9d7031e2c4680dfa534-149-155-0" data-selected="false" role="gridcell" style="background-color:var(--bgColor-default);text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative diff-line-number-neutral left-side">149
155
150
- To update the binary every time the source code changes, you would need a mechanism
151
- to detect that the source code changed. Whenever needed, manually re-running the
152
- ``assemble_file `` function as shown above, would also work.
156
+ To update the binary every time the source code changes, you would need a
157
+ mechanism to detect that the source code changed. This could trigger a re-run
158
+ of the ``assemble_file `` function to update the binary. Manually re-running
159
+ this function as needed would also work.
153
160
154
161
155
162
Preprocessor
0 commit comments