@@ -86,6 +86,12 @@ Advanced usage
|
86 | 86 |
|
87 | 87 | In real world applications, you might want to separate the assembly stage from
|
88 | 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. |
89 | 95 |
|
90 | 96 | The ``esp32_ulp.assemble_file`` function stores the assembled and linked binary
|
91 | 97 | into a file with a ``.ulp`` extension, which can later be loaded directly without
|
@@ -99,16 +105,6 @@ assembling the source again.
|
99 | 105 | import esp32_ulp
|
100 | 106 | esp32_ulp.assemble_file('code.S') # this results in code.ulp
|
101 | 107 |
|
102 |
| - Alternatively you can assemble the source on a PC with MicroPython, and transfer |
103 |
| -the resulting ULP binary to the ESP32. |
104 |
| - |
105 |
| -.. code-block:: python |
106 |
| -
|
107 |
| -git clone https://.com/ThomasWaldmann/py-esp32-ulp |
108 |
| -cd py-esp32-ulp |
109 |
| -micropython -m esp32_ulp path/to/code.S # this results in path/to/code.ulp |
110 |
| -# now upload path/to/code.ulp to the ESP32 |
111 |
| -
|
112 | 108 | 2. The above prints out the offsets of all global symbols/labels. For the next step,
|
113 | 109 | you will need to note down the offset of the label, which represents the entry
|
114 | 110 | point to your code.
|
@@ -135,6 +131,10 @@ assembling the source again.
|
135 | 131 | # 2 words * 4 = 8 bytes
|
136 | 132 | ulp.run(2*4) # specify the offset of the entry point label
|
137 | 133 |
|
| 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. |
| 137 | + |
138 | 138 |
|
139 | 139 | Preprocessor
|
140 | 140 | ------------
|
|
0 commit comments