@@ -17,43 +17,8 @@ This is intended as an alternative approach to assembling such programs using
1717the binutils-esp32ulp toolchain from Espressif on a development machine.
1818
1919
20- Installation
21- ------------
22-
23- On the ESP32, install using upip:
24-
25- ..code-block ::python
26-
27- # ensure the ESP32 is connected to a network with internet connectivity
28- import upip
29- upip.install(' micropython-py-esp32-ulp' )
30-
31- On a PC, simply ``git clone `` this repo.
32-
33-
34- Getting Started
35- ---------------
36-
37- The quickest way to get started is to try one of the `examples <examples/ >`_.
38-
39- The simplest example is `counter.py <examples/counter.py >`_. It shows how to
40- assemble code, load and run the resulting binary and exchange data between the
41- ULP and the main CPU.
42-
43- Run the ``counter.py `` example:
44-
45- 1. Install py-esp32-ulp onto the ESP32 as shown above
46- 2. Upload the `counter.py <examples/counter.py >`_ file to the ESP32
47- 3. Run with ``import counter ``
48-
49- You can also try the `blink.py <examples/blink.py >`_ example, which shows how to
50- let the ULP blink an LED.
51-
52- Look inside each example for a more detailed description.
53-
54-
55- Support
56- -------
20+ Features
21+ --------
5722
5823The following features are supported:
5924
@@ -64,119 +29,45 @@ The following features are supported:
6429* RTC convenience macros (e.g. WRITE_RTC_REG)
6530* many ESP32 ULP code examples found on the web will work unmodified
6631
67- Currently not supported:
68-
69- * assembler macros using ``.macro ``
70- * preprocessor macros using ``#define A(x,y) ... ``
71- * including files using ``#include ``
72- * ESP32-S2 (not binary compatible with the ESP32)
73-
74-
75- Requirements
76- ------------
77-
78- The minimum supported version of MicroPython is v1.12.
79-
80- py-esp32-ulp has been tested on the Unix port of MicroPython and on real ESP32
81- devices with the chip type ESP32D0WDQ6 (revision 1) without SPIRAM.
82-
83-
84- Advanced usage
85- --------------
86-
87- In real world applications, you might want to separate the assembly stage from
88- the loading/running stage, to avoid having to assemble the code on every startup.
89- This can be useful for battery-powered applications, where every second of sleep
90- time matters.
91-
92- Splitting the assembly and load stage can be combined with other techniques to
93- for example implement a caching mechansim for the ULP binary, which automatically
94- updates the binary every time the assembly source code changes.
95-
96- The ``esp32_ulp.assemble_file `` function stores the assembled and linked binary
97- into a file with a ``.ulp `` extension, which can later be loaded directly without
98- assembling the source again.
99-
100- 1. Create/upload an assembly source file and run the following to get a loadable
101- ULP binary as a ``.ulp `` file:
10232
103- ..code-block ::python
33+ Quick start
34+ -----------
10435
105- import esp32_ulp
106- esp32_ulp.assemble_file(' code.S' )# this results in code.ulp
36+ You can get going, run the following directly on the ESP32:
10737
108- 2. The above prints out the offsets of all global symbols/labels. For the next step,
109- you will need to note down the offset of the label, which represents the entry
110- point to your code.
111-
112- 3. Now load and run the resulting binary as follows:
38+ ..code-block ::python
11339
114- ..code-block ::python
40+ # step 1: install py-esp32-ulp
41+ # important: ensure the ESP32 is connected to a network with internet connectivity
42+ import upip
43+ upip.install(' micropython-py-esp32-ulp' )
11544
116- from esp32import ULP
45+ # step 2: run an example
46+ # first, upload examples/counter.py to the ESP32
47+ import counter
11748
118- ulp= ULP()
119- with open (' test.ulp' ,' r' )as f:
120- # load the binary into RTC memory
121- ulp.load_binary(0 , f.read())
49+ The `counter.py </examples/counter.py >`_ example shows how to assemble code, load
50+ and run the resulting binary and exchange data between the ULP and the main CPU.
12251
123- # configure howoften the ULP should wake up
124- ulp.set_wakeup_period( 0 , 500000 ) # 500k usec == 0.5 sec
52+ You can also try the ` blink.py < /examples/blink.py >`_ example, which shows howto
53+ let the ULP blink an LED.
12554
126- # start the ULP
127- # assemble_file printed offsets in number of 32-bit words.
128- # ulp.run() expects an offset in number of bytes.
129- # Thus, multiply the offset to our entry point by 4.
130- # e.g. for an offset of 2:
131- # 2 words * 4 = 8 bytes
132- ulp.run(2 * 4 )# specify the offset of the entry point label
13355
134- To update the binary every time the source code changes, you would need a mechanism
135- to detect that the source code changed. Whenever needed, manually re-running the
136- `` assemble_file `` function as shown above, would also work .
56+ Documentation
57+ -------------
58+ See ` docs/index.rst < /docs/index.rst >`_ .
13759
13860
139- Preprocessor
61+ Requirements
14062------------
14163
142- There is a simple preprocessor that understands just enough to allow assembling
143- ULP source files containing convenience macros such as WRITE_RTC_REG. This is
144- especially useful for assembling ULP examples from Espressif or other ULP code
145- found as part of Arduino/ESP-IDF projects.
146-
147- The preprocessor and how to use it is documented here: `Preprocessor support <docs/preprocess.rst >`_.
148-
149-
150- Testing
151- -------
152-
153- There are unit tests and also compatibility tests that check whether the binary
154- output is identical with what binutils-esp32ulp produces.
155-
156- Consult the Github Actions `workflow definition file <.github/workflows/run_tests.yaml >`_
157- for how to run the different tests.
158-
159-
160- Links
161- -----
162-
163- Espressif documentation:
164-
165- * `ESP32 ULP coprocessor instruction set <https://esp-idf.readthedocs.io/en/latest/api-guides/ulp_instruction_set.html >`_
166- * `ESP32 Technical Reference Manual <https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf >`_
167-
168- GNU Assembler "as" documentation (we try to be compatible for all features that are implemented)
169-
170- * `GNU Assembler manual <https://sourceware.org/binutils/docs/as/index.html >`_
171-
172- More ULP examples:
64+ The minimum supported version of MicroPython is v1.12.
17365
174- * https://github.com/espressif/esp-iot-solution/tree/master/examples/ulp_examples
175- * https://github.com/duff2013/ulptool
176- * https://github.com/joba-1/Blink-ULP/blob/master/main/ulp/
66+ An ESP32 is required to run the ULP machine code binary produced by py-esp32-ulp
67+ (the ESP32-S2 will not work as it is not binary compatible with the ESP32).
17768
17869
17970License
18071-------
18172
182- This project is released under the `MIT License <LICENSE >`_.
73+ This project is released under the `MIT License </ LICENSE >`_.