【ESP32】 OTA upgrade brief introduction and Flash partition introduction
1. ESP32 OTA and Flash partition
The partition table divides 3 application partitions: all three partitions are of type, but have different functions. app
factory
Partition: Factory Applicationota_0
Partition: Save data during OTA upgradeota_1
Partition: Save data during OTA upgrade
When the device starts, it will query otadata data to determine which OTA application partition the program should be loaded from.
If otadata
the partition is empty, the factory program will be executed, that is, factory
the partition's firmware will be executed.
If otadata
the partition is not empty otadata
, determine which OTA
partition to load the image file from.
2. Brief description of the upgrade process
Suppose a firmware upgrade is stored in ota_0
the partition
After the embedded device downloads the firmware from the cloud, it will otadata
write a mark in the partition (such as ota_0
loading from the zone),
When the device is powered on again, it will first read otadata
the partition's tag and then ota_0
load the firmware program from the area.
When ota_0
the firmware in the partition starts correctly, the function will be called to write esp_ota_mark_app_valid_cancel_rollback()
to the partition , marking the firmware of this partition as correct, so that every subsequent startup will be from the partition shelf;otadata
ESP_OTA_IMG_VALID
ota_0
If ota_0
there is an error when the partition is started for the first time, the firmware in this area will be marked as having a problem, and it will be loaded from ota_1
the partition or factory
partition