To perform OTA updates, the device needs a partition table with at least two app partitions. In this assignment we will select and flash an appropriate partition table.
Assignment steps#
- Check the current partition table.
- Change it to a partition table scheme that supports OTA.
- Check the new partition table.
Check the current partition table#
To check the partition table currently loaded on your module, read it back from flash and convert it to a readable format.
Read the flash and dump the partition table into a
.binfile usingesptool.py:esptool.py -p <YOUR-PORT> read_flash 0x8000 0x1000 partition_table.bin<YOUR-PORT>is the same port you use to flash the device (e.g./dev/tty.usbmodem1131101orCOM25).This creates a
partition_table.binfile containing the raw partition table.Convert the
partition_table.binfile to a readable format usinggen_esp32part.py:python $IDF_PATH/components/partition_table/gen_esp32part.py partition_table.binYou get this output:
Parsing binary partition input... Verifying table... # ESP-IDF Partition Table # Name, Type, SubType, Offset, Size, Flags nvs,data,nvs,0x9000,24K, phy_init,data,phy,0xf000,4K, factory,app,factory,0x10000,1M, coredump,data,coredump,0x110000,64K,This table has a single
factoryapp partition, so it does not support OTA updates.
Change the partition table#
Switch to the default partition table scheme that includes two OTA app partitions, then increase the flash size so both app partitions fit.
Open
menuconfig(> ESP-IDF: SDK Configuration Editor (menuconfig)) and go toPartition Table→Factory app, two OTA definitions.This replaces the single
factoryapp partition with two OTA app partitions (ota_0andota_1) and adds theotadatapartition used to track which one is active.In the same
menuconfigwindow, go toSerial Flasher Config→Flash Size→4MB.Two 1 MB OTA app partitions no longer fit in the default 2 MB flash size, so this step is required for the new partition table to fit.
Check the new partition table#
Repeat the read and convert steps to confirm the partition table changed.
Read the flash again:
esptool.py -p <YOUR-PORT> read_flash 0x8000 0x1000 partition_table.binConvert it to a readable format:
python $IDF_PATH/components/partition_table/gen_esp32part.py partition_table.binYou now get:
Parsing binary partition input... Verifying table... # ESP-IDF Partition Table # Name, Type, SubType, Offset, Size, Flags nvs,data,nvs,0x9000,16K, otadata,data,ota,0xd000,8K, phy_init,data,phy,0xf000,4K, factory,app,factory,0x10000,1M, ota_0,app,ota_0,0x110000,1M, ota_1,app,ota_1,0x210000,1M,The table now includes the
otadatapartition and two app partitions,ota_0andota_1, confirming the switch to an OTA-capable scheme.
You can also check the partition table in code using ESP-IDF APIs. See the partition API example for reference.
Conclusion#
In this assignment, you changed the partition table from Single factory app, no OTA to Factory app, two OTA definitions. Both partition table schemes are default options provided by ESP-IDF. In the next assignment, you will create a custom partition table.
Next step#
Next assignment → Assignment 2.2
