Share
This article is part of a three-part series on fail-safe firmware upgrades.
Part 1: Fail-Safe Firmware Upgrades: Failure Model, Requirements and Design Objectives (you are here)
Part 2: Fail-Safe Firmware Upgrades: Architecture, Components and Responsibilities
Part 3: Fail-Safe Firmware Upgrades: Failure Analysis, Limitations and Mitigations
Part 1 of 3. A power loss, storage fault or defective image during an in-field upgrade must never leave a device unbootable. This part defines the failure model, the system requirements and the design objectives for a multi-stage boot chain.
An in-field firmware upgrade rewrites boot-critical code in place, on the storage the device boots from, and the new image has never executed on that unit. A power loss, a failed flash write or a defective image in that window can leave no bootable image, which turns a routine update into a costly on-site reflash or a return (RMA).
This series describes a fail-safe upgrade mechanism for a multi-stage boot chain. Part 1 defines the problem, the requirements and the design objectives. Part 2 describes the architecture of the proposed solution. Part 3 analyzes its failure points, residual limitations and mitigations.
The mechanism was developed for a client that provides mission-critical communication infrastructure, deployed in remote locations that are costly to service. The cost of a failed upgrade is very high for that client, so the architecture keeps a fallback image installed on the device at all times. A deployed device carries two release slots (A/B) and a golden image. The golden image is factory-tested and supports a restricted feature set, enough to reinstall a release image.
The same architecture supports a cost-optimized configuration for consumer electronics, where flash storage capacity affects the bill of materials. That configuration drops the second release slot and keeps one bootable release image plus the golden image. A failed upgrade is recovered by the golden image, which retries the previous version. Part 2 describes both configurations.
The boot chain has four stages: a boot ROM or small loader, a primary boot loader (PBL), a secondary boot loader (SBL) and the operating system. Each stage verifies and starts the next. The upgrade application runs in the OS on a live device and can replace the PBL, SBL and OS images.
Three constraints shape the design:
Goal: the device always ends up running a known-good image, using the smallest and most predictable mechanism available.
The scope is accidental faults. Protection against deliberate tampering is out of scope for this release.
| Failure | Example |
|---|---|
| Power loss | Supply drop or brownout during an image write or a metadata update |
| Storage fault | A write that does not take effect, or a block that reads back incorrectly |
| Bad image | A corrupt, incomplete or defective image |
| Boot failure | A new image that hangs, resets repeatedly or never signals success |
| Corrupted state | Damage to the record that selects the image to boot |
| Total loss | No release image is bootable |
The design defines more than a dozen numbered requirements. These eight drive the architecture.
Out of scope for this release: malicious images, rejection of older versions (anti-downgrade), manual rollback and update of the golden image. Each is recorded as a future item.
The objectives below were the criteria for resolving design trade-offs.
| Objective | Meaning |
|---|---|
| Fall back to the last stable version | Any failure during an upgrade leaves the previous version running, never a partial image |
| Minimal boot-time logic | The decision code runs earliest, with the least support and no field debug access, so each branch is a risk |
| Atomic state transitions | A power loss at any point resolves to the state before or after a change, never between |
| Ordered writes over locking | Where two updates must go together, choose a write order in which every intermediate state is safe |
| Hardware assistance | A watchdog converts a hang into a reset; registers retained across warm resets carry boot state |
| Testable failure paths | Every failure mode can be injected on a bench. The test plan has more than forty cases |
The requirements and objectives imply redundant image slots, a persistent record of the trial in progress, a bounded retry policy, an independent recovery image and a hardware watchdog. The engineering problem is arranging these so that no single interruption yields an unbootable device.
Part 2 describes that arrangement and follows one upgrade from start to finish.
Bluehatsoft has implemented this design on several hardware platforms and has worked with SoC design companies to build the supporting hardware aids into their SoCs. Bluehatsoft is available for consulting on the subject, covering design, architecture and implementation. An implementation that includes secure boot is also available and will be covered in a future article series.
Get in touch with us or email us at contact(at-the-rate)bluehatsoft(dot)com.