Embedded and IoT

How do you update firmware without internet?

You carry a signed update to the device over whatever link reaches it, such as Bluetooth from a phone, a serial or USB cable, removable media or a local mesh, and the device checks the signature before installing it. Because the delivery path is not trusted, the protection has to travel with the update itself, along with a rule against installing older versions and a way to fall back to the previous image if the new one fails.

TL;DR

An offline update passes through links nobody can trust, so the device must check a signed manifest with a payload digest and monotonic sequence number itself. The sequence number alone cannot stop a long-offline device accepting an old signed release. Bootloaders should keep the previous image until the new one works, because recovery has to happen locally.

Learning objectives

After reading this article you will be able to:

  • Explain why an offline update must carry its own signed protection
  • List what a firmware manifest should contain when the device cannot reach a server
  • Describe how anti-rollback counters and fallback slots guard against old or bad images

Self-protecting offline firmware updates

Without internet, a firmware image may pass through a technician’s phone, a USB stick or several neighbouring devices before it arrives, and none of those can be trusted to keep it intact. A connected device, by contrast, can fetch an update from a known server over an encrypted connection.

RFC 9019, the IETF architecture for firmware updates on IoT devices, plans for this. It does not assume how images reach devices, and for updates that are broadcast or pass through third parties it says a solution “cannot rely on link-layer, network-layer, or transport-layer security”. The protection is applied to the update itself: a signed description of the image, called a manifest, and the image it describes. The RFC requires the image to be authenticated and integrity protected, and makes confidentiality optional.

RFC 9124, the companion manifest model, puts the stakes plainly: a firmware update “is, by definition, remote code execution”. A device runs whatever its trusted signer approves, and if that signer is compromised, the RFC notes, the possibilities for defence are limited.

Offline firmware delivery paths

RFC 9019 allows the manifest and image to travel as one bundle, which it describes as useful when devices are not connected to the internet and cannot contact a firmware server, including updates by USB stick or short-range radio such as Bluetooth. Common paths:

  • A phone over Bluetooth LE. Zephyr’s device management protocol, SMP, has transports for Bluetooth LE and for UART or serial links. ESP-IDF, Espressif’s framework, describes over-the-air updates as data received while normal firmware runs, for example over Wi-Fi, Bluetooth or Ethernet.
  • A cable or removable media. RFC 9019 describes a recovery image that can rerun the update over serial, USB or Bluetooth when a normal update fails.
  • Across a mesh. The Bluetooth SIG’s Mesh Device Firmware Update feature sends firmware to many nodes with multicast, with parameters to control the cadence and size of messages so the transfer runs in the background, and lets the update be applied on all nodes at a planned time. The Bluetooth SIG notes that an update means transferring a large amount of data to every node, so the problem resembles moving a large file across a mesh.
  • Carried by someone. A phone that picks up an update where there is coverage and hands it over later is a form of data muling.

Bluetooth LE firmware updates

To update firmware over Bluetooth LE, use the update protocol your bootloader supports and the phone library that speaks it. Three paths cover most Bluetooth LE devices:

  • MCUmgr and SMP, on Zephyr and the nRF Connect SDK. Zephyr’s Simple Management Protocol runs over Bluetooth LE through a single GATT characteristic, as well as over serial links. Nordic’s nRF Connect SDK updates firmware this way: the device acts as a GATT server with the SMP service, MCUboot must be its bootloader, and Nordic’s nRF Connect Device Manager app sends the image. Nordic also publishes Android and iOS libraries for SMP over Bluetooth LE, for apps that run the update themselves.
  • Nordic DFU, on the older nRF5 SDK. Devices with nRF5 SDK secure or legacy bootloaders update through Nordic’s separate Android and iOS DFU libraries. Nordic says the Android library cannot update firmware built with the nRF Connect SDK and points to nRF Connect Device Manager instead. For React Native apps, the community package react-native-nordic-dfu runs Nordic DFU on iOS and Android, though it says it is no longer actively maintained and points to a fork.
  • ESP-IDF OTA, on the ESP32. ESP-IDF’s OTA API accepts the image from any transport, Bluetooth included: esp_ota_begin and esp_ota_write write it into the OTA slot that is not running, and esp_ota_set_boot_partition selects it for the next boot. Espressif’s ESP BLE OTA component in esp-iot-solution provides the Bluetooth LE side, checking each packet’s sequence and CRC and acknowledging it.

Whichever path you use, the phone is only the courier. The device still checks the signature before it boots the new image, and the bootloader keeps the old image until the new one proves it works.

Firmware manifest contents for offline devices

RFC 9124 lists the information a manifest carries. These elements matter most when the device cannot check with a server:

  • Signature. The foundation of all the manifest’s security properties.
  • Payload digest. Ties the manifest to one exact image.
  • Vendor ID and class ID. Let the same manifest reach many devices without the wrong kind of device accepting it.
  • Monotonic sequence number. Required, must never wrap around, and stops anyone reinstalling an older update against the vendor’s policy.
  • Expiration time. Optional, and only useful where the device has a secure source of time.

Firmware rollback trap on offline devices

The rollback trap is a threat specific to disconnected devices, named in RFC 9124: an attacker hands a device that has been offline for a long time an old but validly signed update that is newer than what it runs but older than the latest, carrying a known vulnerability. Such a device runs old firmware and does not know newer releases exist. The sequence number check passes, because the device has never seen anything newer. The RFC says the right mitigation depends on where the threat comes from; against a network attacker, showing an expiration date and asking a user to confirm can help.

Some bootloaders anchor the version rule in hardware. MCUboot’s hardware-based downgrade prevention compares an image’s security counter with a value stored in a non-volatile, trusted part of the device. ESP-IDF’s anti-rollback refuses an application whose security version is lower than the one programmed into the chip’s eFuse. The bootloader also needs a trust anchor store holding the key it verifies against, RFC 9019 notes, and a secure element is one way to protect keys on a device someone can open.

Failed firmware install recovery

Bootloaders keep the old image until the new one proves itself. RFC 9019 says devices must not fail when a disruption such as a power failure occurs during an update, and bootloaders handle this as follows:

  • MCUboot keeps a primary and a secondary slot. In a test swap it boots the new image, and unless that image marks itself as good, it swaps back on the next reset, so a device that crashes on bad firmware returns to the working version.
  • ESP-IDF needs at least two OTA app slots. With app rollback enabled, a new application must confirm it works on first boot or the bootloader returns to the previous one. Its documentation recommends running the self-test quickly, so a power loss during it does not trigger a rollback.

NIST SP 800-193 frames the same goals for platform firmware as protection against unauthorised changes, detection of changes that occur, and recovery. For a device with no network, recovery has to work locally, because nobody can push a fix to a device that cannot boot.

Frequently asked questions

Does the update need to be encrypted?

Not necessarily. RFC 9019 requires authentication and integrity protection of firmware images but makes confidentiality optional. Encrypting the image makes reverse engineering harder, and it means the bootloader needs a decryption key and a way to manage it.

Can a phone act as the update server?

Yes. A phone app can carry the image and push it over Bluetooth LE, for example using the MCUmgr protocol that Zephyr supports over Bluetooth LE and serial links. The phone is only a courier; the device should still verify the signature itself.

What is a firmware manifest?

A manifest is a signed description of a firmware image. RFC 9124 lists what it carries, including a signature, a payload digest that ties it to one exact image, vendor and class IDs, a monotonic sequence number, and an optional expiration time.

How do you stop a device installing older firmware?

The manifest carries a monotonic sequence number that stops anyone reinstalling an older update against the vendor's policy. Some bootloaders anchor the rule in hardware, such as MCUboot's security counter and ESP-IDF's eFuse-based anti-rollback.

What happens if power fails during a firmware update?

RFC 9019 says devices must not fail when that happens. Bootloaders such as MCUboot and ESP-IDF keep the old image in a second slot and go back to it unless the new image confirms it works.

Can firmware updates be sent across a Bluetooth mesh?

Yes. The Bluetooth SIG's Mesh Device Firmware Update feature sends firmware to many nodes with multicast, runs the transfer in the background, and lets the update be applied on all nodes at a planned time.

Sources

Build it with Offline Protocol

The Offline Protocol embedded docs list what firmware must supply to a constrained leaf, including atomic durable storage that protects cryptographic state across power loss, and ask you to qualify restart behaviour on the selected part. Both matter when an update reboots the device.

Read the Rust and constrained devices docs