How firmware is updated after shipment. Partition tables start on board one.
Update and testOTA updateESP32 family
Official path: examples/system/ota/native_ota_example
01 Overview
Native OTA is the standard remote update solution in ESP-IDF: the device pulls a new image from the network, writes it to a spare partition, and switches the boot partition to complete the update.
It solves the maintenance problem for deployed devices: no disassembly, no return to factory, just fix bugs, add features, or change configuration over the air.
Typical use cases include smart home devices, industrial sensors, and data loggers that run for long periods and are hard to access physically.
It is not suitable for boards that cannot stay online reliably, nor for applications requiring real-time performance—the update process involves a brief reboot.
OTA is not a later plugin; it is a partition decision that must be made from the first board.
02 Hardware
Flash size: Must accommodate two OTA slots (each ~1.5MB) plus factory and NVS partitions; 4MB is a comfortable start.
Partition table: Must be defined before production, including factory, ota_0, ota_1, nvs, and aligned addresses.
Power stability: Power loss during update can corrupt partitions; rely on partition design and brown-out detection (e.g., external voltage monitor).
Antenna and RF: Ensure Wi-Fi antenna matching and sufficient signal strength to avoid download failures.
Connectors: Reserve UART or JTAG for debugging and recovery mode.
Reset circuit: Ensure a reliable reset button for entering download mode.
Layout notes: Keep power traces wide to avoid voltage drops during high-current update operations.
03 Software flow
1. Configure the partition table with two OTA slots and a factory partition.
2. Initialize NVS to store the current boot partition and rollback counters.
3. Connect to Wi-Fi and obtain an IP address.
4. Download the new firmware over HTTPS to the idle OTA partition, verifying signature and hash.
5. Set the boot partition to the new image using esp_ota_set_boot_partition().
6. Reboot the device to boot from the new partition.
7. After boot, verify the firmware runs correctly; if it fails, roll back to the old partition.
04 Core points
OTA is a partition decision, not a later plugin. Partition tables must be fixed during hardware design.
Signature verification is mandatory. For public internet updates, use HTTPS and signing to prevent man-in-the-middle attacks.
Define rollback strategy. On failure, automatically roll back to the old version to avoid bricking.
Do not copy OTA flows from other chips. ESP-IDF OTA APIs have specific requirements like partition alignment and erase operations.