The happy path of an OTA update fits in three lines: download, write, reboot. The engineering is not in the happy path. It is in the places where that path gets cut. For a device that is already in the field the real question is this: at exactly which moment of the flow does a power cut leave the device unrecoverable? This article treats OTA as a failure tree instead of a feature list: which interruptions an A/B layout closes, which ones it does not, and where the atomic switch point has to sit. Tool choice is a separate discussion. What follows are design decisions that do not depend on the tool.

In short

  • Cut the update flow along the time axis and ask "what if power goes now?" at each point. Only one step can produce an undefined state: writing the switch record. A good design reduces that step to a single atomic write.
  • An OTA update has three signature gates and their order matters: the bundle signature before a single byte is written, the payload digest while the data streams, and verification at run time with a signed FIT image and dm-verity.
  • Rollback and anti-rollback pull in opposite directions. Rollback is allowed only inside the trial window and only to the previous slot. The monotonic counter moves only after the health confirmation, on a later normal boot.
  • "It booted" is not "it works". A/B rollback only helps if a product-specific health gate decides whether the update becomes permanent.
  • A/B protects what is updated. The bootloader, the device tree and the fuse state are shared and need their own plan.

The film and the work behind it

Our 60-second film Power Cut at 63% plays this failure tree out on one device. A new image rolls out to the controllers of a wind farm during a storm, and unit #0417 loses power 63% into the write. With a single copy of the system the unit ends at "Site visit required". With an A/B layout it boots from the untouched slot, tries again, and commits only after the health check has passed. In another scene an unsigned image is rejected at the door, before anything is written.

The wind farm, the fleet, unit #0417, the storm and the 63% are an example scenario. They do not describe an incident that happened and they do not describe a customer. The boot log lines on screen are representative; they are not the literal output of one particular bootloader. No update product is named in the film and none is ranked here. This article contains no measurements of ours.

The film closes on a date, 11 December 2027, the day the EU Cyber Resilience Act fully applies. The Act asks for the things this article is about: vulnerabilities have to be addressable through security updates (Annex I, Part I(2)(c)), the manufacturer needs a mechanism to distribute updates securely (Part II(7)), and security updates have to reach users without delay and free of charge (Part II(8)), for a support period of at least five years unless the product is expected to be in use for less (Article 13(8)). An update path that can leave a unit unbootable makes every one of those harder to keep. The full list of obligations is in the Cyber Resilience Act for embedded Linux devices. This article is not legal advice.

The failure tree: what happens depending on where the interruption lands

Cutting an update flow along the time axis and asking "what if power goes now?" at each point lays out the whole design.

Moment of the interruption State of the device Recovery path
While the manifest downloads Nothing has changed Start again
While the payload is written to the passive slot Active slot intact, passive slot half written Rewrite the passive slot
Write finished, switch record not yet written Active slot intact Repeat the write or the switch
While the switch record is written Depends on the design; can be undefined Redundant record plus checksum
During the first boot from the new slot New slot is suspect Boot counter returns to the old slot
During the health check New slot boots but is unhealthy No confirmation, fall back
After the confirmation New slot is permanent Going back is now a new update job

The table reads one way: only one row can produce an undefined state. The job of a good OTA design is to reduce that row to a single atomic write. Every other step has to be either repeatable or reversible. The firmware update architecture the IETF wrote for embedded devices (RFC 9019) states the same principle: the installation flow itself has to survive interruption, because interruption is a normal operating condition, not an exception.

Where does the atomic switch point sit?

"Atomic" here is not a philosophical adjective. It is a concrete guarantee from the storage medium: after a power cut the record is either entirely in its old state or entirely in its new one, with nothing in between. The mechanisms used in practice are few.

  • U-Boot redundant environment (CONFIG_ENV_OFFSET_REDUND). Two copies of the environment are kept; each has its own CRC and a flag byte that says which one is valid. U-Boot writes the passive copy, then flips the flag. If the write is interrupted, the old copy is still valid.
  • eMMC boot area selection. The PART_CONFIG register in EXT_CSD, defined by JEDEC JESD84-B51, decides with a single register write which boot area (boot0/boot1) the device starts from. This is the standard way to make the bootloader A/B.
  • GPT partition attribute bits (priority / tries remaining / successful). There is a hidden trap here: the primary copy of the GPT is at the start of the disk and the backup copy is at the end. By definition that is two separate writes, so the tool needs a read order that tolerates a mismatch between the two copies.
  • Boot entry file name counter. systemd's automatic boot assessment decrements a tries-left counter embedded in the file name of the boot entry by renaming the file on every boot; systemd-bless-boot marks success.

The most common design mistake here is to split the switch into two separate writes: first change the active slot, then reset the boot counter. If power goes between the two, the device tries to start from the new slot, but its counter is already at the limit, so it either falls back at once or enters a boot loop. The right way is to write all variables that belong to the switch in one operation:

# Write to the passive slot: repeatable, reversible, not critical
dd if=rootfs.ext4 of=/dev/mmcblk0p3 bs=1M conv=fsync status=none

# dd returning is NOT durability: flush the block layer and the device cache
blockdev --flushbufs /dev/mmcblk0p3
sync

# Read back what was written and compare it with the digest in the manifest
IMG_BYTES=$(stat -c %s rootfs.ext4)
head -c "$IMG_BYTES" /dev/mmcblk0p3 | sha256sum -

# ATOMIC SWITCH: all variables in a single environment write
cat > /run/ota-switch.env <<'EOF'
boot_slot b
bootcount 0
upgrade_available 1
EOF
fw_setenv -s /run/ota-switch.env

fw_setenv -s reads all name-value pairs from a script file and writes the environment once. Together with a redundant environment configuration this closes the only undefined-state risk in the flow. Policy values such as bootlimit should be fixed when the image is built, not written at update time: every extra variable the updater touches widens the atomic window.

Signature verification order: what, when, against what

OTA has no single signature check. There are three gates that complement each other, and their order defines what they mean.

First gate: the bundle signature, before a single byte is written. RAUC checks the detached CMS signature next to the squashfs bundle before installation starts. In SWUpdate, sw-description has to be the first entry of the cpio archive; with CONFIG_SIGNED_IMAGES enabled, the signature check happens before the handlers run. This ordering is not a coincidence. It is what makes streaming installation safe.

Second gate: the payload digest, while the data flows. The sha256 = "@rootfs.ext4.gz" field in sw-description is a digest that comes from inside the signed manifest. Hashing the payload while it streams, instead of downloading it to disk and verifying it afterwards, removes the need for extra download space, but only if the digest comes from the signed manifest.

Third gate: at run time. A signed FIT image and a root filesystem protected with dm-verity work against silent corruption after installation and against offline modification. The root hash produced with veritysetup is carried in the signed kernel command line.

Three mistakes are common:

  • Verifying after the switch. A check done after switching to the new slot finds the error when you already depend on the fallback path. Verification ends before the switch.
  • Installing what is re-read from disk instead of what was verified. Hashing the downloaded file and then installing by reading the same file again is a classic TOCTOU gap. The installation has to be fed from the very stream that was hashed.
  • Not verifying the verifier. If the component that checks the signature can be replaced, there is no chain. That is why the OTA signature is the last link of a chain that starts at a hardware root, such as HAB on NXP i.MX. It is not the first link.

There is also a silent time bomb. On a device with no RTC, or with a clock that cannot be trusted, verification logic that looks at the expiry date of the signing certificate makes the whole fleet impossible to update on the same day. This is why the manifest information model in RFC 9124 treats freshness and version checking separately: measure staleness with a monotonic version number, not with the calendar.

Partial download: identity is not a byte count

On an intermittent cellular link it is normal for a download to stop halfway, and it is normal to resume it with HTTP Range. The trap is what the decision to resume is based on. A client that resumes on byte length alone will join two different builds into one file if the bundle on the server changed in the meantime. In the good case the digest does not match and the bundle is rejected. In the bad case, if the manifest does not cover every byte, nobody notices.

The rule is simple: the identity of the bundle (the bundle digest or the ETag given by the server) is stored next to the partial download, compared before resuming, and if it does not match, the download starts again. The second rule: the free-space check happens before the passive slot is touched. An updater that learns in the middle of installation that the disk is full leaves a half-written slot behind.

Power loss: write order and storage realities

A write call that returns does not mean the data is durable. The order is: write, flush the block layer, flush the device cache, read back and compare, and only then write the switch record. JESD84-B51 defines a cache flush command for eMMC; the driver calls it on the sync path, but a writer that uses O_DIRECT has to trigger it itself.

NAND-based media add a second reality: if power goes during programming, the block being written at that moment can be corrupted. This explains why the switch record has to be kept as two copies plus a checksum, and also why the record should not sit in the same erase block as data that is rewritten often. If you use raw NAND, UBI's volume update marker (UBI_IOCVOLUP) does the same job: an interrupted update leaves the volume marked as unusable, and half-written data is not mounted silently.

How do rollback and anti-rollback live in the same system?

The two requirements conflict directly. Rollback saves you from a broken update. Anti-rollback protects you from an attacker who reinstalls an old version that is properly signed but has a known vulnerability. Both are needed, and the way to have both is to place them on different time scales.

Rollback is allowed only inside the trial window and only to the previous slot. Anti-rollback is built on a monotonic counter in hardware: SRK revocation in the i.MX family, the NV counter in ARM Trusted Firmware, the lowest supported version reported through ESRT on the UEFI side. These counters are one-way doors: once advanced, they cannot be taken back.

A hard rule follows: never advance the monotonic counter on the boot in which the switch happens. If the counter is burned and the health check then fails, the device can go neither forward nor back, and recovery needs a service technician. The right order is: switch, health confirmation, and then on the next normal boot advance the counter, only for versions that really close a vulnerability.

The same conflict has a data side that should not be forgotten. If the new version changed the schema in the data partition, the old version you fall back to cannot read that data. For the rollback path to really work, the on-disk schema has to stay readable at least one version back.

Health confirmation with a watchdog: "it booted" and "it works" are not the same

Rollback in an A/B layout is useful only because the device falls back unless someone says "this update is good". Defining who that "someone" is, is the most often skipped part of OTA design. Three layers are needed and each one catches different failures.

The hardware watchdog (/dev/watchdog0, WDIOC_SETTIMEOUT, WDIOC_KEEPALIVE) is the only layer that recovers from a completely locked kernel. The systemd layer catches hangs at the service level. The application gate is specific to the product: is the field data path up, is the sensor streaming, can the server be reached?

# /etc/systemd/system/ota-health-gate.service
[Unit]
Description=OTA health gate and commit
After=network-online.target spikedge-app.service
Requires=spikedge-app.service

[Service]
Type=oneshot
RemainAfterExit=yes
# Product-specific check: data path, sensor stream, backend reachability
ExecStart=/usr/bin/ota-health-check
# If the check passed, make the update permanent; if not, the commit never
# runs and the bootloader returns to the old slot on the next boot
ExecStart=/usr/bin/rauc status mark-good booted

[Install]
WantedBy=multi-user.target
# /etc/systemd/system.conf.d/watchdog.conf
[Manager]
RuntimeWatchdogSec=default
RebootWatchdogSec=default

On the service side, an application that uses Type=notify and WatchdogSec= has to send its sd_notify(0, "WATCHDOG=1") call from the actual work loop. A heartbeat sent from a separate timer thread continues even when the application hangs, and turns the watchdog into decoration.

Where it goes wrong

  1. The bootloader stays outside the A/B scheme. A/B protects what is updated; it does not protect what is not. The bootloader, the device tree and the fuse state are shared. On eMMC, switching the bootloader between boot0 and boot1 with PART_CONFIG closes this gap. If you do not close it, the bootloader becomes the one unrecoverable component of the fleet.
  2. The rollback path has never been run. If CI only runs the successful update, the fallback path is untested code. In every release, at least one scenario should be failed on purpose at the health check, and the device should be seen returning to the old slot.
  3. The health gate only looks at multi-user.target. A device whose network configuration is broken and whose application crashes, but which still reached the systemd target, passes this check and the broken update becomes permanent.
  4. The watchdog is closed silently by magic close. If the character V is written to the /dev/watchdog device before it is closed, the watchdog is disabled. When a crashing updater closes its file descriptor cleanly, the protection goes with it. CONFIG_WATCHDOG_NOWAYOUT closes this door; the price is that the watchdog can never be stopped again. And because the driver allows a single open, decide once whether systemd or the application owns the watchdog.
  5. OTA state shares the environment area with the application. If the boot counter sits in an area that the application also writes with fw_setenv, an unrelated write resets the counter and rollback is not triggered.
  6. The device chooses the moment of the reboot. A device that restarts on its own decision inside a moving machine is a safety problem, not an update problem. Separate installation from activation: the write can happen at any time, while the switch is tied to operator approval or to a defined standstill window. The regulations that describe software update processes in automotive (UNECE R156, ISO 24089) insist on the same distinction.
  7. The campaign goes to the whole fleet at once. Without a staged rollout and a stop criterion defined in advance, an error that would have shown up in the first wave has already reached the whole fleet.

A/B or single partition plus recovery image?

Criterion A/B (two root filesystems) Single partition + recovery image
Flash cost Twice the rootfs space Rootfs + a small recovery image
Device during the write Runs normally Drops into the recovery image, service stops
Tolerance to interruption Built in: the active slot is not touched Depends on the robustness of the recovery image
Health of the recovery path Used on every update Rarely used, decays silently
Updating the recovery image No such concept It has no recovery path of its own
Network dependency None Usually present

The real weakness of the recovery image model is not storage. It is decay from lack of use: an image that has not been run for years is tried for the first time on the day it is needed. If you choose this model, really boot the recovery image at regular intervals, preferably once before each campaign. If the rootfs is too large to fit two copies, shrinking the rootfs before adding the second copy is often the cheaper engineering job; building a BSP to fit the need with Yocto aims at exactly that.

Decision criteria

Answer these six questions in order before the design starts. Each one locks the next.

  1. Does the flash budget carry two rootfs copies? If yes, A/B. If not, try shrinking the rootfs first; a recovery image is the second choice and has to be booted regularly.
  2. Is the switch a single atomic write? If not, the design is not finished. Redundant environment, PART_CONFIG or attribute bits: whichever it is, the number of writes has to be one.
  3. Can you write the health gate? If you cannot define "the device works" in the language of the product, A/B rollback is decoration. Define the gate, then back it with a watchdog layer.
  4. Does the rollback path run in CI? If it does not, that path does not exist. A deliberately failing update scenario should be part of your release acceptance criteria.
  5. Is there a risk of physical access to the device? If yes, the signature chain has to start at the bootloader; the OTA signature alone is not enough. The key rotation plan also has to be made today.
  6. Do you need to forbid going back permanently? Advance the monotonic counter only for versions that really close a vulnerability, and only on the boot after the confirmation.

All six can and should be answered before the first board arrives. Once the product is in the field, each of them is learned at the price of a service call. If you want an independent look at an existing update design before it goes to production, our secure boot and OTA lifecycle capability and our embedded architecture audit look at exactly these layers.

What this article cannot tell you

This article contains no measurement of ours: no update duration, no failure rate, no count of recovered units. The film scenario is an example, as stated above. Several things depend on your hardware and product and have to be settled there:

  • Storage behaviour under power loss. How an eMMC or NAND part behaves when power goes during a write differs from part to part. The write order above lowers the risk. It does not replace cutting power on your own board, many times, at arbitrary moments.
  • Names and paths. The device path (/dev/mmcblk0p3), the variable names (boot_slot, bootcount, upgrade_available) and the unit names in the snippets are examples. Bootloader, kernel and update framework documentation is versioned; option names and device paths always have to be checked against the documentation of the version you use.
  • Tool choice. We do not compare RAUC, SWUpdate, Mender or any other framework here, and we do not claim that one of them is better.
  • Legal classification. Which obligations of the Cyber Resilience Act apply to your product, and how, is not something this article decides.

Frequently asked questions

What happens if power is lost during an OTA update?

It depends on where in the flow the cut lands. In an A/B layout the active slot is not touched while the new image is written, so a power cut during the download or the write only means the passive slot is written again. The one step that can leave an undefined state is writing the switch record, which is why it should be a single atomic write backed by a redundant, checksummed record.

What is an A/B update on an embedded Linux device?

In an A/B update the device keeps two copies of the root filesystem, called slots. The update is written to the passive slot while the system keeps running from the active one, and the bootloader then starts the new slot on trial. If the system does not confirm that it is healthy, the boot counter runs out and the bootloader returns to the previous slot.

What is the difference between rollback and anti-rollback?

Rollback returns the device to the previous slot when a new update turns out to be broken. Anti-rollback stops an attacker from reinstalling an older, correctly signed version with a known vulnerability, and it is built on a monotonic hardware counter that cannot be taken back. The two can live together if rollback is limited to the trial window and the counter is advanced only after the health confirmation, on a later normal boot.

When should an OTA update be marked as good?

An OTA update should be marked as good only after a product-specific health check has passed, not when the system merely reaches a boot target. The check should cover what "working" means for the product, for example the field data path, the sensor stream and the connection to the backend. Until that confirmation is given, the bootloader has to be able to fall back to the old slot.

A/B or a single partition with a recovery image?

A/B costs twice the rootfs space, but the device keeps running during the write and the recovery path is exercised on every update. A single partition with a recovery image saves flash, but the device is out of service while it updates, and the recovery image is rarely run, so it can decay without anyone noticing. If two copies do not fit, try shrinking the rootfs first.

Sources

Accessed: 19 November 2026 for the Cyber Resilience Act sources. The technical sources were accessed on 5 September 2026, for the Turkish original of this article.