OTA updates and fleet management
How over-the-air updates stay safe on microcontrollers and gateways (two slots, rollback, signing, anti-rollback, recovery) and how to roll a release out to a fleet in stages and watch it land.
Overview
An over-the-air (OTA) update replaces a device’s firmware through its own network link. It is the only way to fix a bug or a security flaw in a device that is already on a wall, in a field or in a customer’s home. It is also the fastest way to break every device you have shipped at once. This hub is for makers adding their first update path and for product teams planning how a release reaches thousands of devices without losing any of them.
On one device, the goal is that an interrupted or bad update never leaves the device unable to boot. That is a matter of flash layout and bootloader logic. Across a fleet, the goal is to release to a few devices first and stop before a problem spreads. That is a matter of process and telemetry.
Key ideas
Two slots and a small boot record
The standard layout keeps two application slots. The running image stays in one while the new image is written to the other. A small record tells the bootloader which slot to start. In ESP-IDF v6.1.1 a safe OTA scheme needs at least ota_0, ota_1 and an OTA data partition (otadata) of two flash sectors (0x2000 bytes), which holds the boot selection and the image state. The partition table allows up to 16 OTA slots, and app partitions must start on 64 KB boundaries. The built-in “factory app, two OTA definitions” table gives three 1 MB app partitions. MCUboot uses the same idea under different names: a primary slot that runs and a secondary slot that receives the candidate.
Linux gateways follow the same pattern at a larger scale. SWUpdate calls it double copy and notes the cost: each copy gets less than half the storage. Its alternative, single copy, boots a small rescue system to rewrite the main one, which saves space but gives no fallback to the old version without a second update.
The new image has to prove itself
Writing the new image safely is half the job. The other half is deciding whether it works. With CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE set, ESP-IDF boots a fresh image once in a pending-verify state. The application runs its own checks and then calls esp_ota_mark_app_valid_cancel_rollback(). If a reset happens first, the image is marked aborted and the bootloader returns to the previous one. The documentation advises running the self-test as quickly as possible, because a power cut during a slow test also triggers a rollback. MCUboot’s equivalent is the test swap: the candidate runs, and unless it sets its image_ok flag it is reverted on the next boot. A permanent swap skips that safety net.
A useful self-test reaches the server that delivers updates, because an image that boots but cannot fetch a fix is the worst outcome.
Signing and anti-rollback are different jobs
A signature proves who built the image. MCUboot checks RSA2048-PSS, RSA3072-PSS, ECDSA (elliptic-curve digital signature algorithm) or Ed25519 signatures. ESP-IDF can check signed updates even without hardware secure boot (CONFIG_SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT). A signature does not stop someone installing an older, correctly signed image that still has a known flaw. That is the job of anti-rollback. ESP-IDF compares the image’s secure version with a value burned into eFuse (one-time programmable fuse bits). On the ESP32-C5 that field is 9 bits, so the documentation says the secure version can be raised only 9 times in the chip’s life, and factory or test partitions cannot be used with it. Raise it only for security fixes. MCUboot offers a software version check (overwrite mode only) or a hardware security counter.
Plan the recovery path
Two slots do not help if the bootloader itself is damaged. On the ESP32-C5, ESP-IDF v6.1.1 describes a recovery bootloader: if the primary bootloader at 0x2000 fails to load, the ROM starts a second copy from an offset stored in eFuse. It is not flashed by default, and writing 0xFFF to that eFuse disables the feature for good. A factory-reset GPIO (general-purpose input/output) held for 5 seconds by default can erase chosen data partitions and boot the factory image. Decide both before the first unit ships.
Roll out in stages and stop automatically
A staged roll-out sends a release to a small share of devices, waits, then widens. Mender’s documentation shows phases such as 80% and 20%. AWS IoT Jobs offers exponential rates (its example starts at 50 devices per minute and doubles), abort rules triggered when a threshold percentage of devices fail, and up to 10 retries per device. Whatever service you use, write the abort rule before the release, not during the incident.
Monitoring closes the loop
A roll-out is only safe if you can see failures. ESP-IDF can save a core dump in ELF (Executable and Linkable Format) to a flash partition after a crash, for decoding with idf.py coredump-info. Fleet services such as Memfault collect crashes and metrics and tie them to release cohorts. The useful signal is the crash and reboot rate of the new version against the old one over the same period.
For makers
Start with the ESP-IDF two-slot table and rollback enabled. Make the self-test connect to your broker and only then confirm the image. Keep a USB cable route for recovery. Leave anti-rollback and eFuse settings alone until you understand that they are permanent.
For product teams
Sign every image, and keep signing keys off build machines. Decide the anti-rollback policy, recovery bootloader and factory-reset behaviour before production, because they live in eFuse. Release to a canary group, define abort thresholds in advance, and compare crash rates per version. Budget flash for two full images plus growth.
Where to start
Flash and monitor a board first: /learn/beginner/03-toolchains-and-first-flash/. An update needs a network path and a server, so work through /learn/beginner/06-wifi-and-your-first-request/ and /learn/beginner/07-mqtt-basics/, which gives you a channel to announce a new version. An intermediate lesson on OTA with rollback is planned. Signing keys and secure boot are covered in /topics/iot-security/, and project structure in /topics/embedded-firmware/.
Tools and platforms
Versions and features as of 28 November 2026, from each project’s own documentation.
| Job | Tool | What it gives you | Source |
|---|---|---|---|
| A/B updates on an Espressif chip | ESP-IDF OTA, v6.1.1 | Up to 16 OTA slots, pending-verify rollback, eFuse anti-rollback | ESP-IDF OTA |
| Bootloader for Zephyr and other 32-bit MCU projects | MCUboot 2.5.1 | Overwrite, swap, direct-XIP (execute in place) and RAM-load modes, signed images, test and confirm | MCUboot design |
| Loading images over Bluetooth LE or UART | Zephyr MCUmgr (Simple Management Protocol) | Transports include Bluetooth LE, UART, shell and UDP. Image upgrades go through MCUboot | Zephyr MCUmgr |
| Image-based updates on a Linux gateway | SWUpdate 2026.05, RAUC | Single or double copy (SWUpdate). Mandatory bundle signing and mark-good/mark-bad (RAUC) | SWUpdate, RAUC |
| Phased deployment to a fleet | Mender, AWS IoT Jobs | Phases (Mender). Exponential rates, abort thresholds, retries (AWS) | Mender, AWS IoT Jobs |
| Crash data from devices | ESP-IDF core dump, Memfault | ELF dump to flash or UART (ESP-IDF). Fleet crash, metric and cohort tracking (Memfault) | ESP-IDF core dump, Memfault |
Common mistakes
- Confirming the image at the top of
app_main(), before anything has been tested. Rollback then never fires. - A self-test so slow that a normal power cut rolls a good image back.
- Raising the anti-rollback secure version on every release and running out of eFuse bits.
- Shipping with no recovery route for the bootloader, or with a factory image nobody has tested for years.
- Signing keys stored next to the build scripts, or shared between products.
- Releasing to the whole fleet at once, with no abort rule and no per-version crash rate.
- A partition table with no headroom, so the first large feature no longer fits in a slot.
Going deeper
- Espressif, Over The Air Updates (OTA) and Bootloader, ESP-IDF v6.1.1 for ESP32-C5. Pick your chip in the documentation menu.
- MCUboot, Bootloader design, the reference for slots, swap types and the image trailer.
- Zephyr Project, MCUmgr.
- SWUpdate, overview of update strategies, and RAUC, basics, for Linux gateways.
- AWS, How job configurations work, on rollout rates and abort rules.