The Update That Cannot Brick the Device
The Update That Cannot Brick the Device: OTA Firmware With Rollback
An over-the-air firmware update can either extend the life of an embedded product or brick an entire fleet in the field. The difference is not the transport, it is the architecture: A/B partitions so the old firmware is never touched until the new one proves itself, signing and secure boot so the image is yours and unmodified, trial-then-confirm so a bad build reverts automatically, and a staged rollout with a kill switch. The safety costs one extra flash slot, 512 kB on a 2 MB chip, and its payoff is that a bad build costs one reboot instead of one scrapped unit, one truck roll, and one lost customer.
First, a simple picture
A spare key, cut before you lock the door.
A person who changes the lock on their house does not throw away the old key first. They cut the new key, test it in the lock, and only then throw the old one away, because if the new key does not work, the old one is the way back in. A person who throws the old key away before testing the new one is not locked out by bad luck. They are locked out by design.
OTA, over-the-air, firmware update is the feature that lets you fix a bug, add a feature, or patch a security hole in devices you will never touch again. It is also the feature that can render every deployed unit useless if a write is interrupted, a hash is wrong, or a rollback is unreachable. The core design question is not "how do I transfer the image" but "how do I guarantee that at every instant, including the instant the power fails, there is at least one complete, bootable image on the device." The spare key is the old firmware. The update must never throw it away before the new one proves itself.
What OTA really is
Firmware is the software that runs directly on the product's microcontroller, the code that reads the sensors, runs the model, drives the radio, and decides when to sleep. An image is the firmware as a file: the compiled code, plus a header that says what it is, which hardware it fits, and which version it is. An OTA update is the delivery of a new image to a device in the field, over whatever radio the device has, and the replacement of the old image with the new one, without anyone touching the device.
The update has four phases, and the design has to make each one fail safe. Transport: the firmware package must arrive at the device intact, authenticated, and resistant to interruptions. Verification: before even touching the flash, the device must make sure the image received is legitimate, not corrupted, and compatible with the hardware.
Atomic write: the update must be applied such that an interrupt at any point does not leave the device in an inconsistent state. Post-boot validation: only after verifying that the new firmware works correctly must the system consider the update complete. A failure at any phase leaves the old firmware running, and that is the point.
The old firmware is the spare key.
A/B partitions
The single most important architectural decision is dual-slot (A/B) partitioning. The device keeps two firmware slots. It runs from A, downloads and writes the update to B while A keeps running, then flips the boot pointer to B on the next reboot. The switch is atomic, a single flag the bootloader reads, so there is no window where the device is half-updated.
The alternative is single-slot: the new firmware directly overwrites the active one. It is simple to implement, and it is catastrophic in the event of an outage. If the writing stops halfway, a power cut, a dropped connection, a corrupted packet, the device no longer has working firmware.
The only path to recovery is physical access: a person, a cable, and a truck. The single-slot scheme is cheaper in flash, but it is only safe if the bootloader can receive the whole image into a staging area before erasing the application, and on a constrained device, that staging area is usually the flash you do not have.
The flash arithmetic is the whole argument. In the dual-slot scheme the flash is divided into a bootloader region (never updated, or updated only through a very careful separate procedure), slot A, slot B, and a small metadata area. The rule is: slot_size ≥ image_size + header, and total_flash ≥ bootloader + 2·slot_size + metadata + (config, calibration, logs).
Example Labs is a made-up company we use for worked examples.
The active image is never modified during an update, so a power failure at any point leaves a bootable system. The demo below works the numbers for the Example Labs hub: the safety costs exactly one extra slot.
And then there is trial-then-confirm, the step that makes the A/B scheme actually work. When B first boots it is marked "trial." The application must actively confirm it is healthy, network up, sensors reading, watchdog happy, within a few boots.
If it does not confirm, because it crash-loops or hangs, the bootloader automatically reverts to A. The magic is that the confirmation is the application's job, not the bootloader's: the new firmware has to prove itself, in the field, on the real hardware, before the device commits to it. The state machine is: idle → download → verify → apply → reboot → confirm (or rollback).
Signing, secure boot, and the counter that stops the past coming back
Before a device flashes anything, it must prove the image is genuinely yours and unmodified. That means signing every image with a private key held in your build system, and verifying the signature on-device against a public key baked into read-only storage, typically ECDSA P-256 or RSA-2048. The image is signed in the factory; the device checks the signature before it trusts a single byte.
Layer that under secure boot, where each stage verifies the next: immutable ROM verifies the bootloader, the bootloader verifies the application, an unbroken chain of trust from silicon to your code. And add an anti-rollback counter: a monotonic version number, stored in OTP fuses or protected flash, that the device refuses to go below, so an attacker cannot push an old, vulnerable-but-validly-signed image to reopen a patched hole. The counter is the part founders forget: signing proves the image is yours; the counter proves the past cannot come back.
Two more disciplines, both cheap and both skipped. Delta updates: send only the binary difference between the current and target versions, tools like bsdiff or detools generate the patch, which often shrinks the payload by 60–90%. Staged rollouts: a sane ladder starts at a canary of 1%, a small, monitored cohort, watching confirm rates and crash telemetry, and the critical capability is the kill switch: the moment confirm rates dip or crash reports spike, you stop the rollout before the bad build spreads.
Devices already on the new version that failed will have auto-reverted thanks to A/B; devices not yet updated simply never get the bad image. And the download itself must be resumable, track byte offsets and continue rather than restarting a 2 MB fetch over a flaky link, because devices lose connectivity mid-download constantly.
Four phases of a safe update; a failure at any phase leaves the old firmware running
| Phase | Requirement |
|---|---|
| 1. Transport | Intact, authenticated, resumable from a byte offset |
| 2. Verify | Signature and hash checked before anything is written |
| 3. Atomic write | One flag flips the boot pointer; the device is never half-updated |
| 4. Validate | Trial boot and health check, then confirm or roll back automatically |
When OTA loses
OTA loses on two things, and the honest article names both.
The radio. The update has to travel over whatever radio the device has, and some radios cannot carry it. LoRa's data rate is measured in hundreds of bits per second, not megabits, and one guide states it plainly: forget firmware OTA updates over LoRa. The demo below runs the numbers for BLE and Wi-Fi; the radio choice is pipeline #2's subject, and the choice that makes OTA possible is the choice that gives the device a radio with enough throughput to carry a 512 kB image in seconds, not hours.
The flash. A/B partitioning costs a full extra slot. On a device with 2 MB of flash and a 512 kB image, that is affordable, the demo shows 892 kB spare. On a device with 256 kB of flash and a 200 kB image, it is not: two slots plus a bootloader do not fit, and the honest answer is a bigger chip, a smaller image, or a single-slot scheme with a staging area and a recovery path that is tested, not assumed. The flash is the budget, and the budget decides the architecture, which is Article #6's lesson, applied to firmware instead of power.
DEMO
This product is made up. Call it the Example Labs field sensor hub again: the fence-post unit from Articles #6, #7, and #9, the weather sensor, the event camera, the battery, the enclosure, now with a firmware update to receive. The hub runs on an STM32H7: 512 kB of SRAM, 2 MB of flash (the chip from Article #9's CLRO paper).
The firmware image is 512 kB. The fleet is 1,000 units in the field. The demo's arithmetic is the article's own, verified before writing, on the published figures cited above; the hub and its fleet are the worked example, not a measured product.
Step 1, The flash map. The flash is 2,048 kB. The map is: bootloader 64 kB + slot A 512 kB + slot B 512 kB + metadata 4 kB + config, calibration, and logs 64 kB = 1,156 kB used, 892 kB spare. The A/B scheme costs exactly one extra slot, 512 kB, and the hub can afford it. A single-slot scheme would need only 644 kB, but the 512 kB it saves is the spare key.
Step 2, The download. The update travels over BLE, at a practical 200 kbps. The full image is 512 kB, 4,096 kilobits, so the download takes 20.5 seconds. The delta is 51.2 kB, 90% smaller, so it takes 2.1 seconds. Over Wi-Fi, at a practical 5 Mbps, the full image takes 0.82 seconds. And the energy: the full image is 2,621 BLE packets of 200 bytes, at about 30 µJ per packet (Article #6's radio figure), 78.6 mJ, which is 0.003% of the CR2032's 2,484 joules. The download is not the risk. The write is.
Step 3, The bad build. The new firmware has a bug: it crash-loops on boot. In the A/B scheme, the hub writes the image to slot B, verifies the signature and the hash, flips the boot pointer, and reboots into B, marked "trial." B crash-loops. It never confirms. The bootloader reverts to slot A. The hub is down for one reboot, not bricked, not a truck roll, not a scrapped unit. In the single-slot scheme, the same bad build overwrites the running image, the device has no working firmware, and the only recovery is physical access, one scrapped unit, one truck roll, and one lost customer, times however many units took the update before the kill switch was pulled.
Step 4, The rollout. The update goes to a 1% canary first, 10 units of the 1,000. The confirm rate dips; the crash telemetry spikes; the kill switch stops the rollout. Ten units revert automatically. Nine hundred and ninety never get the bad image. The fix ships as the next version, with the anti-rollback counter incremented, so no device can be pushed back to the bad build, and the version number only ever moves forward.
The decision test
Four questions. They sort the updates that cannot brick the device from the ones that can:
- Is there a second slot, A/B partitioning, so the active image is never modified during an update, and a power failure at any point leaves a bootable system? No, the update overwrites the running image, and the only recovery is physical access. Yes, the spare key is always there, and the flash budget proves it.
- Is every image signed, verified before it is flashed, and chained through secure boot, with an anti-rollback counter the device refuses to go below? No, the device trusts whatever it receives, and an old, vulnerable image is a valid image. Yes, the image is yours, unmodified, and the past cannot come back.
- Is there trial-then-confirm, the new image must prove it is healthy within a few boots, or the bootloader reverts automatically? No, the device commits to the new image the moment it boots, and a crash-loop is a brick. Yes, the new firmware has to earn its place, in the field, on the real hardware.
- Is there a staged rollout, a 1% canary, confirm rates and crash telemetry watched, and a kill switch that stops the bad build before it spreads? No, the update goes to the whole fleet at once, and the bad build spreads faster than anyone can stop it. Yes, ten units take the risk, and nine hundred and ninety never see the bad image.
If the answers are yes, yes, yes, yes, the update cannot brick the device, and the review is a final check, not a rescue. If any answer is no, the job is an OTA/firmware-architecture review, and the honest thing is to do it before the first update ships, not after the first fleet is bricked. And if the answer to question 1 is "we don't have the flash for two slots", the problem is not the update.
The problem is that the chip was chosen before the update was designed, and the review starts by admitting that the flash budget decides the architecture.
"But our update works", and two more fair doubts
"But our update works." It works until the power fails mid-write, or the download corrupts a packet, or the new build crash-loops on hardware your test bench does not have. "Works" is not the test. The test is what happens when it fails, and the answer has to be "the old firmware keeps running," not "a person drives to the field with a cable." The four phases are the test, and the test is run on the real hardware, with the power pulled at the worst moment, not the best.
"A/B partitioning wastes flash." It costs one extra slot, 512 kB on a 2 MB chip, in the demo, and the flash it costs is the cheapest insurance in the whole product. The alternative is not free. The alternative is a fleet that can be bricked by a power cut, and a truck roll for every unit it happens to. The flash is the price. The brick is the cost.
"We can just recall the devices." You can, and the recall is the confession that the update was designed to fail. A recall is a truck roll, a scrapped unit, and a lost customer, times the fleet. The A/B scheme is the recall you never have to do, because the bad build reverts itself before anyone notices. The update that cannot brick the device is not a feature. It is the difference between a product and a prototype.
Sources
- Silicon Logix, "Secure OTA Firmware Updates with Rollback: A/B Partitions, Bootloader Strategy and Lifecycle"
What we used
An OTA update can either extend the life of a product or brick an entire fleet; the difference is the architecture, not the transport; four phases (transport, verification, atomic write, post-boot validation); single-slot overwrites the active image and a power cut mid-write leaves no working firmware; dual-slot always maintains two full slots, writes to the inactive one, verifies, then instructs the bootloader to boot from it; fallback is automatic
- Michael Samuel Naeem, "Reliable OTA Firmware Updates for IoT" (July 2026)
What we used
A/B partitions are non-negotiable; the switch is atomic, a single flag; trial-then-confirm (the application must confirm health, network up, sensors reading, watchdog happy, within a few boots, or the bootloader reverts); signing with a private key in the build system, public key in read-only storage; secure boot chain (ROM verifies bootloader, bootloader verifies app); anti-rollback monotonic counter; delta updates shrink the payload by 90% or more; staged rollout ladder starting at a 1% canary, with a kill switch; downloads must be resumable via byte offsets
- EmbeddedInterviewLab, "OTA updates and rollback"
What we used
State machine idle → download → verify → apply → reboot → confirm (or rollback); A/B costs 2× firmware size, rollback is instant (swap back), old slot intact; delta updates via bsdiff/detools reduce transfer size 60–90%; signature verification ECDSA P-256 or RSA-2048, public key in bootloader or OTP fuses; anti-rollback counter in OTP fuses or protected flash; power-fail safety keeps the old confirmed image available while the candidate is staged and trial-booted
- InnovChip, "Firmware OTA Update Design Guide"
What we used
The core design question is guaranteeing at every instant there is at least one complete, bootable image on the device; dual-slot layout (bootloader + slot A + slot B + metadata); slot_size ≥ image_size + header; total_flash ≥ bootloader + 2·slot_size + metadata + (config, calibration, logs); the bootloader must be small, simple, and correct; verify integrity before jumping, never run a half-written image; the application cannot erase its own slot, the bootloader owns the erase/write of the inactive slot; worked example of a 512 kB dual-slot update with resume