【ESP32】 OTA upgrade brief introduction and Flash partition introduction

1. ESP32 OTA and Flash partition

Insert image description here

The partition table divides 3 application partitions: all three partitions are of type, but have different functions. app

  • factoryPartition: Factory Application
  • ota_0Partition: Save data during OTA upgrade
  • ota_1Partition: 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 otadatathe partition is empty, the factory program will be executed, that is, factorythe partition's firmware will be executed.

If otadatathe partition is not empty otadata, determine which OTApartition to load the image file from.

Insert image description here

2. Brief description of the upgrade process

Suppose a firmware upgrade is stored in ota_0the partition

After the embedded device downloads the firmware from the cloud, it will otadatawrite a mark in the partition (such as ota_0loading from the zone),

When the device is powered on again, it will first read otadatathe partition's tag and then ota_0load the firmware program from the area.

When ota_0the 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;otadataESP_OTA_IMG_VALIDota_0

If ota_0there 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_1the partition or factorypartition

3. What should I do if the power is interrupted during the upgrade process?

Insert image description here

Guess you like

Origin blog.csdn.net/qq_39217004/article/details/133173845