|
1 | 1 | # mp-image-tool-esp32: Working with esp32 firmware files and devices |
2 | 2 |
|
3 | 3 |  |
| 4 | + |
4 | 5 |
|
5 | 6 | Tool for manipulating partition tables and files in MicroPython esp32 firmware |
6 | 7 | image files and device flash storage. |
@@ -157,76 +158,88 @@ To run the tests: `uv run pytest` or `uv run tox`. |
157 | 158 | #### Change the flash size of a firmware file and expand the vfs partition |
158 | 159 |
|
159 | 160 | ```console |
160 | | -$ mp-image-tool-esp32 ESP32_GENERIC-20231005-v1.21.0.bin -f 8M --resize vfs=0 |
161 | | -Opening image file: ESP32_GENERIC-20231005-v1.21.0.bin... |
162 | | -Chip type: esp32 |
163 | | -Flash size: 4MB |
164 | | -Micropython App size: 0x186bb0 bytes (1,562 KB) |
165 | | -Partition table (flash size: 4MB): |
166 | | -# Name Type SubType Offset Size (End) Flags |
167 | | - nvs data nvs 0x9000 0x6000 0xf000 0x0 (24.0 kB) |
168 | | - phy_init data phy 0xf000 0x1000 0x10000 0x0 (4.0 kB) |
169 | | - factory app factory 0x10000 0x1f0000 0x200000 0x0 (1.9 MB) |
170 | | - vfs data fat 0x200000 0x200000 0x400000 0x0 (2.0 MB) |
171 | | -Micropython app fills 78.8% of factory partition (421 kB free) |
172 | | -Resizing vfs partition to 0x600000 bytes. |
173 | | -Writing output file: ESP32_GENERIC-20231005-v1.21.0-8MB-vfs=0.bin... |
174 | | -Partition table (flash size: 8MB): |
175 | | -# Name Type SubType Offset Size (End) Flags |
176 | | - nvs data nvs 0x9000 0x6000 0xf000 0x0 (24.0 kB) |
177 | | - phy_init data phy 0xf000 0x1000 0x10000 0x0 (4.0 kB) |
178 | | - factory app factory 0x10000 0x1f0000 0x200000 0x0 (1.9 MB) |
179 | | - vfs data fat 0x200000 0x600000 0x800000 0x0 (6.0 MB) |
180 | | -Micropython app fills 78.8% of factory partition (421 kB free) |
| 161 | +❯ mp-image-tool-esp32 ESP32_GENERIC-20240602-v1.23.0.bin -f 8M --resize vfs=0 |
| 162 | +Running mp-image-tool-esp32 v0.0.13 (Python 3.12.6). |
| 163 | +Opening tests/data/ESP32_GENERIC-20240602-v1.23.0.bin... |
| 164 | +Found esp32 firmware file (4MB flash). |
| 165 | + Partition table (flash size: 4MB): |
| 166 | +╭──────────┬──────┬─────────┬──────────┬──────────┬──────────┬───────┬───────────╮ |
| 167 | +│ Name │ Type │ SubType │ Offset │ Size │ End │ Flags │ │ |
| 168 | +├──────────┼──────┼─────────┼──────────┼──────────┼──────────┼───────┼───────────┤ |
| 169 | +│ nvs │ data │ nvs │ 0x9000 │ 0x6000 │ 0xf000 │ 0x0 │ (24.0 kB) │ |
| 170 | +│ phy_init │ data │ phy │ 0xf000 │ 0x1000 │ 0x10000 │ 0x0 │ (4.0 kB) │ |
| 171 | +│ factory │ app │ factory │ 0x10000 │ 0x1f0000 │ 0x200000 │ 0x0 │ (1.9 MB) │ |
| 172 | +│ vfs │ data │ fat │ 0x200000 │ 0x200000 │ 0x400000 │ 0x0 │ (2.0 MB) │ |
| 173 | +╰──────────┴──────┴─────────┴──────────┴──────────┴──────────┴───────┴───────────╯ |
| 174 | +Micropython app fills 82.3% of factory partition (350 kB free) |
| 175 | + Partition table (flash size: 8MB): |
| 176 | +╭──────────┬──────┬─────────┬──────────┬──────────┬──────────┬───────┬───────────╮ |
| 177 | +│ Name │ Type │ SubType │ Offset │ Size │ End │ Flags │ │ |
| 178 | +├──────────┼──────┼─────────┼──────────┼──────────┼──────────┼───────┼───────────┤ |
| 179 | +│ nvs │ data │ nvs │ 0x9000 │ 0x6000 │ 0xf000 │ 0x0 │ (24.0 kB) │ |
| 180 | +│ phy_init │ data │ phy │ 0xf000 │ 0x1000 │ 0x10000 │ 0x0 │ (4.0 kB) │ |
| 181 | +│ factory │ app │ factory │ 0x10000 │ 0x1f0000 │ 0x200000 │ 0x0 │ (1.9 MB) │ |
| 182 | +│ vfs │ data │ fat │ 0x200000 │ 0x600000 │ 0x800000 │ 0x0 │ (6.0 MB) │ |
| 183 | +╰──────────┴──────┴─────────┴──────────┴──────────┴──────────┴───────┴───────────╯ |
| 184 | +Micropython app fills 82.3% of factory partition (350 kB free) |
| 185 | +Writing to esp32 firmware file: ESP32_GENERIC-20240602-v1.23.0-8MB-resize=vfs.bin... |
| 186 | +Writing partition table... |
| 187 | +Updating flash size (8MB) in bootloader header... |
181 | 188 | ``` |
182 | 189 |
|
183 | 190 | #### Change the flash size of firmware on a device and write an OTA partition table |
184 | 191 |
|
185 | 192 | ```console |
186 | | -$ mp-image-tool-esp32 u0 -f 8M --table ota |
187 | | -Opening esp32 device at: /dev/ttyUSB0... |
188 | | -Warning: End of last partition (0x400000) < flash size (0x800000). |
189 | | -Chip type: esp32 |
190 | | -Flash size: 8MB |
191 | | -Partition table (flash size: 8MB): |
192 | | -# Name Type SubType Offset Size (End) Flags |
193 | | - nvs data nvs 0x9000 0x6000 0xf000 0x0 (24.0 kB) |
194 | | - phy_init data phy 0xf000 0x1000 0x10000 0x0 (4.0 kB) |
195 | | - factory app factory 0x10000 0x1f0000 0x200000 0x0 (1.9 MB) |
196 | | - vfs data fat 0x200000 0x200000 0x400000 0x0 (2.0 MB) |
197 | | -Warning: End of last partition (0x400000) < flash size (0x800000). |
198 | | -Writing new table to flash storage at /dev/ttyUSB0... |
199 | | -Partition table (flash size: 8MB): |
200 | | -# Name Type SubType Offset Size (End) Flags |
201 | | - nvs data nvs 0x9000 0x5000 0xe000 0x0 (20.0 kB) |
202 | | - otadata data ota 0xe000 0x2000 0x10000 0x0 (8.0 kB) |
203 | | - ota_0 app ota_0 0x10000 0x200000 0x210000 0x0 (2.0 MB) |
204 | | - ota_1 app ota_1 0x210000 0x200000 0x410000 0x0 (2.0 MB) |
205 | | - vfs data fat 0x410000 0x3f0000 0x800000 0x0 (3.9 MB) |
206 | | -Setting flash_size in bootloader to 8.0MB... |
| 193 | +❯ mp-image-tool-esp32 u0 -f 8M --table ota |
| 194 | +Running mp-image-tool-esp32 v0.0.13 (Python 3.12.6). |
| 195 | +Opening /dev/ttyUSB0... |
| 196 | +Detected flash size (8MB) is different from firmware bootloader (4MB). |
| 197 | +Found esp32 device (4MB flash). |
| 198 | + Partition table (flash size: 4MB): |
| 199 | +╭──────────┬──────┬─────────┬──────────┬──────────┬──────────┬───────┬───────────╮ |
| 200 | +│ Name │ Type │ SubType │ Offset │ Size │ End │ Flags │ │ |
| 201 | +├──────────┼──────┼─────────┼──────────┼──────────┼──────────┼───────┼───────────┤ |
| 202 | +│ nvs │ data │ nvs │ 0x9000 │ 0x6000 │ 0xf000 │ 0x0 │ (24.0 kB) │ |
| 203 | +│ phy_init │ data │ phy │ 0xf000 │ 0x1000 │ 0x10000 │ 0x0 │ (4.0 kB) │ |
| 204 | +│ factory │ app │ factory │ 0x10000 │ 0x1f0000 │ 0x200000 │ 0x0 │ (1.9 MB) │ |
| 205 | +│ vfs │ data │ fat │ 0x200000 │ 0x200000 │ 0x400000 │ 0x0 │ (2.0 MB) │ |
| 206 | +╰──────────┴──────┴─────────┴──────────┴──────────┴──────────┴───────┴───────────╯ |
| 207 | + Partition table (flash size: 8MB): |
| 208 | +╭─────────┬──────┬─────────┬──────────┬──────────┬──────────┬───────┬───────────╮ |
| 209 | +│ Name │ Type │ SubType │ Offset │ Size │ End │ Flags │ │ |
| 210 | +├─────────┼──────┼─────────┼──────────┼──────────┼──────────┼───────┼───────────┤ |
| 211 | +│ nvs │ data │ nvs │ 0x9000 │ 0x5000 │ 0xe000 │ 0x0 │ (20.0 kB) │ |
| 212 | +│ otadata │ data │ ota │ 0xe000 │ 0x2000 │ 0x10000 │ 0x0 │ (8.0 kB) │ |
| 213 | +│ ota_0 │ app │ ota_0 │ 0x10000 │ 0x200000 │ 0x210000 │ 0x0 │ (2.0 MB) │ |
| 214 | +│ ota_1 │ app │ ota_1 │ 0x210000 │ 0x200000 │ 0x410000 │ 0x0 │ (2.0 MB) │ |
| 215 | +│ vfs │ data │ fat │ 0x410000 │ 0x3f0000 │ 0x800000 │ 0x0 │ (3.9 MB) │ |
| 216 | +╰─────────┴──────┴─────────┴──────────┴──────────┴──────────┴───────┴───────────╯ |
| 217 | +Writing partition table... |
| 218 | +Updating flash size (8MB) in bootloader header... |
207 | 219 | Erasing data partition: nvs... |
208 | 220 | Erasing data partition: otadata... |
209 | | -Warning: app partition 'ota_1' does not contain app image. |
210 | | -Erasing data partition: vfs... |
211 | 221 | ``` |
212 | 222 |
|
213 | 223 | #### Perform an OTA firmware update |
214 | 224 |
|
215 | 225 | ```console |
216 | | -$ mp-image-tool-esp32 u0 --ota-update ESP32_GENERIC-20231005-v1.21.0.app-bin |
217 | | -Opening esp32 device: /dev/ttyUSB0... |
218 | | -Chip type: esp32 |
219 | | -Flash size: 8MB |
220 | | -Partition table (flash size: 8MB): |
221 | | -# Name Type SubType Offset Size (End) Flags |
222 | | - nvs data nvs 0x9000 0x5000 0xe000 0x0 (20.0 kB) |
223 | | - otadata data ota 0xe000 0x2000 0x10000 0x0 (8.0 kB) |
224 | | - ota_0 app ota_0 0x10000 0x200000 0x210000 0x0 (2.0 MB) |
225 | | - ota_1 app ota_1 0x210000 0x200000 0x410000 0x0 (2.0 MB) |
226 | | - vfs data fat 0x410000 0x3f0000 0x800000 0x0 (3.9 MB) |
227 | | -Performing OTA firmware upgrade from 'ESP32_GENERIC-20231005-v1.21.0-8MB-OTA.app-bin'... |
| 226 | +❯ mp-image-tool-esp32 u0 --ota-update ESP32_GENERIC-20240602-v1.23.0.app-bin |
| 227 | +Running mp-image-tool-esp32 v0.0.13 (Python 3.12.6). |
| 228 | +Opening /dev/ttyUSB0... |
| 229 | +Found esp32 device (8MB flash). |
| 230 | + Partition table (flash size: 8MB): |
| 231 | +╭─────────┬──────┬─────────┬──────────┬──────────┬──────────┬───────┬───────────╮ |
| 232 | +│ Name │ Type │ SubType │ Offset │ Size │ End │ Flags │ │ |
| 233 | +├─────────┼──────┼─────────┼──────────┼──────────┼──────────┼───────┼───────────┤ |
| 234 | +│ nvs │ data │ nvs │ 0x9000 │ 0x5000 │ 0xe000 │ 0x0 │ (20.0 kB) │ |
| 235 | +│ otadata │ data │ ota │ 0xe000 │ 0x2000 │ 0x10000 │ 0x0 │ (8.0 kB) │ |
| 236 | +│ ota_0 │ app │ ota_0 │ 0x10000 │ 0x200000 │ 0x210000 │ 0x0 │ (2.0 MB) │ |
| 237 | +│ ota_1 │ app │ ota_1 │ 0x210000 │ 0x200000 │ 0x410000 │ 0x0 │ (2.0 MB) │ |
| 238 | +│ vfs │ data │ fat │ 0x410000 │ 0x3f0000 │ 0x800000 │ 0x0 │ (3.9 MB) │ |
| 239 | +╰─────────┴──────┴─────────┴──────────┴──────────┴──────────┴───────┴───────────╯ |
| 240 | +Performing OTA firmware upgrade from 'ESP32_GENERIC-20240602-v1.23.0.app-bin'... |
228 | 241 | Writing firmware to OTA partition ota_1... |
229 | | -Updating otadata partition... |
| 242 | +⠼ Write Flash ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0% 0:00:21 -0.5/1.7 MB 103.0 kB/s |
230 | 243 | ``` |
231 | 244 |
|
232 | 245 | ## Filesystem Operations |
|
0 commit comments