2

I would like to better understand how OTA works on ESP32. I have read the datasheet but I still have some questions about the OTA data partition: it has a size of 0x2000 bytes being 2 sectors of 4K, my question is how are these bytes filled? The bootloader will see such OTA data partition to chose a firmware partition to boot. I can write code to update the firmware in the respective partitions but I don't know how to updatw the bytes in OTA data partition.

I thank you in advance for your help.

Obs: I dont wish to use the OTA functions, for such reason I want to understand it to develop my own routine.

a2800276
  • 3,272
  • 22
  • 33

1 Answers1

1

You don't need to worry about the details of writing the OTA partition data, this is handled by the IDF when you commit the OTA update by calling esp_ota_set_boot_partition() after successfully writing the new firmware to that partition.

If you are interested in what is being written, you can check out the code implementing that function or download the flash comprising the OTA-data partition using esp_tool.py. It's pretty unspectacular and consists of data identifying the partition to boot from, a counter and mostly 00's...

The OTA data is spread across two sectors to allow for cases where an error occurs while writing. The second sector is only updated after the first write is complete. That way the "old" boot sector information is guaranteed to still be intact and the device can recover by rebooting into the old application (whose sector is still intact).

a2800276
  • 3,272
  • 22
  • 33