We broke an Over-The-Air update on the ESP32 on purpose
Recorded: Sept. 22, 2026, 3:09 p.m.
| Original | Summarized |
ESP32 firmware update recovery time | Groundrun groundrun.io Platform 20 September 2026 Over-The-Air (OTA) updates are one of the most fundamental mechanisms in any connected product. Thanks to OTAs, we can fix problems even after the product has shipped simply by downloading a new firmware over the air. In fact, most connected products perform an OTA update the first thing they do when they are installed: this ensures they always have all the latest fixes as quickly as possible. Survive the interruption. The device should still be alive after an interrupted OTA update, running the original version of the code. So this we need to test: an update either finishes and applies cleanly, or it gets interrupted. The power goes out mid-download, the device reboots on its own, someone hits reset at the wrong moment. When that happens, the device has to recover on its own and finish the job anyway. New image Sent in the Shown in the Device Applies and A new image starts in the cloud, reaches the device either quietly or through the app, and the device applies it. The tricky part is if the OTA process gets interrupted. In the worst case, a firmware image applied halfway through a write can leave a device unable to boot at all, which is the absolutely worst state that a connected product can end up in. This is typically known as a bricked device: a device that is about as useful as a brick. Completely dead to the world. Before ota_0 ota_1 After a successful update ota_0 ota_1 The two flash partitions the ESP32 uses for an update: the boot pointer marks one active, and a new image lands in the other. We interrupt the update in three ways Software reset. Sends the board's own console a force_reboot command mid-download, closer to a crash somewhere else in the firmware. Each of these methods has the same effect: they stop the OTA partway through writing the new image to the inactive slot. They interrupt before we reach the point where the bootloader would switch the boot pointer, so the device that reboots is still running the old firmware, with the same rollback mechanism ready to walk it through a fresh attempt. They interrupt before we reach the point where the bootloader would switch the boot pointer, so the device that reboots is still running the old firmware, with the same rollback mechanism ready to walk it through a fresh attempt. While the three methods has a similar effect, in that they all interrupt the firmware download, they could potentially break the system in different ways. We want to make sure that our system survives and recovers in every case. Update Software reset Reset-pin toggle Hard power cut Reboots on Second attempt Three ways an update gets interrupted, all converging on the same recovery path. In every trial where the interruption landed, that is exactly what happened. The board came back on the old version, took a second update attempt cleanly, and stayed there. ESP-IDF's own rollback mechanism did the whole job, with nothing on Groundrun's side stepping in, in any of the eighteen trials. Rollback enabledRollback disabled Hard power cut99.6s93.5s 0s 20s 40s 60s 80s 100s 120s 140s 160s 180s 99.6s 93.5s 165.7s 155.3s 157.5s 158.5s Rollback enabled Rollback disabled Mean recovery time by interruption method and rollback setting, across three trials each. Recovery time clustered by how the update was interrupted more than by whether rollback was enabled. A hard power cut recovered fastest, under two minutes either way, because that recovery run is a clean second attempt with no re-provisioning needed. Software reset and the reset-pin toggle took longer, around two and a half minutes, because their recovery run also rejoins Wi-Fi from scratch. 140s 160s 180s 200s 220s 240s 0% 157.5s 183.2s 200.8s 223.2s Mean recovery time against how far into the download the reset-pin toggle fired, from a fixed-point reference (effectively a 0% cut) through 75% of the baseline download. Every one of the nine cut-point trials recovered automatically, the same as the fixed-point comparison above. What changed was how long it took. Recovery at the earliest cut point, 25% into the download, took just over three minutes. By the time the cut landed at 75%, recovery had grown to close to three and three-quarters. The extra recovery time tracks the added delay closely: it's the download's own progress, redone twice, once before the interruption and once again after. The extra recovery time tracks the added delay closely: it's the download's own progress, redone twice, once before the interruption and once again after. Conclusions Groundrun platform overview → More from the blog Automating Wi-Fi setup testing on the ESP32 Platform groundrun.io |
Over-The-Air (OTA) updates represent a fundamental mechanism for connected products, allowing fixes to be deployed remotely. Because OTA updates involve significant changes to the software, the mechanism must possess absolute reliability, ensuring that even under adverse conditions, it can recover gracefully. This reliability necessitates that the system must survive interruptions—such as power loss or unexpected resets—and automatically recover to a known-good state. Therefore, the core requirement is that an update must either complete successfully or revert cleanly, preventing the device from entering an unusable, "bricked" state. This requirement demands that the system survive the interruption and possess the capability to automatically reattempt and complete the update. The experiment conducted by the authors utilized the Groundrun system to rigorously test the resilience of the OTA mechanism on an ESP32-C6 system. The objective was to subject the system to various forms of interruption during the firmware download and verify successful recovery. The researchers simulated three distinct failure modes: performing a software reset mid-download, executing a hardware reset during the update, and cutting the power supply to the entire system during the process. These methods were designed to interrupt the writing of the new image at various stages. The mechanism governing the ESP32's OTA process, implemented via the ESP-IDF, relies on two flash partitions, ota_0 and ota_1, where the boot pointer determines which partition is active and which is inactive for the update. The update downloads to the inactive slot, is verified, and only then the bootloader switches the pointer. A critical safeguard is the CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE feature, which manages the rollback process. If a newly booted image fails self-confirmation, this mechanism automatically reverts the device to the previously running firmware partition, ensuring that the system avoids being left in an indeterminate state. When the update was interrupted using the three failure methods, the system was designed to recover by rebooting into the original firmware, initiating a fresh update attempt, and maintaining that stable version through a second deliberate reset, thereby eliminating any lingering pending verification states. The study confirmed that the ESP-IDF's inherent rollback mechanism successfully handled all interruption scenarios reliably, regardless of whether rollback was explicitly enabled or disabled in testing. The measured recovery times varied based on the interruption method. The hard power cut demonstrated the fastest recovery time, achieving completion in under two minutes across all tested configurations. In contrast, interruptions involving a software reset or a reset-pin toggle resulted in longer recovery times, approximately two and a half minutes, as these methods required the recovered device to re-establish its network connection and re-provision itself. Furthermore, the time taken for recovery was directly correlated with where the interruption occurred during the download; interrupts near the beginning of the download tested faster than those occurring later in the process, demonstrating that the recovery delay reflects the amount of download progress that had to be redone. Overall, the experiment strongly supports the confidence that the OTA mechanism reliably ensures the survival and recovery of firmware updates by autonomously utilizing internal rollback procedures. |