Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Bootloader That Safely Updates Device Firmware

Let a fleet of small embedded devices install new application firmware in the field so that every boot starts an authentic image and no power cut, crash or bad release leaves a device unable to start.

Problem statement

For this exercise, assume a company ships about 2 million small connected devices, each built around one microcontroller. A boot loader runs first from a write-protected region of the microcontroller's internal flash and then starts the application, the firmware that does the device's real work.

About four new application versions are released each year.

Design how a device updates its application in the field: from a new signed release being available, through download and install, to the device running the new version, or safely back on the old one. Focus most on the boot loader, which decides which image to start and must keep the device bootable.

For this exercise, assume the running application downloads a new image over the network and writes it into flash that it is not executing from. The boot loader has no network stack, so it can only work with images that are already in flash.

Power can be cut, and the device can reset, at any moment, including in the middle of a flash write. The boot loader itself is never updated in the field. An update server, a content delivery network and a release signing service already exist; you design the device side and its contract with the server.

A device must never start an image that is incomplete, altered, not signed by the vendor, or below the minimum security version it has accepted, and a bad release must not leave devices stuck. Physical attacks on the device, such as probing or glitching, are out of scope.

What to build

  1. Let the running application fetch a new signed version and schedule it, while the device keeps doing its normal work until a short restart.
  2. Start only a complete, vendor-signed image whose security version is not below the minimum the device has accepted.
  3. After a power loss or reset at any moment of a download, install or first boot, come back up running a trusted, working image.
  4. Return to the previous version without human help when a new version does not prove healthy, and let the update server learn each device's outcome.

At scale

  • For this exercise, assume 1 MB of internal flash erased in 8 KB sectors; a sector survives about 10,000 erases, erasing one takes about 30 ms and writing one about 20 ms. The write-protected boot region is 32 KB, the application keeps 80 KB of its own data in flash that must survive updates, RAM is 256 KB, and an application image is at most 448 KB.
  • For this exercise, assume the network link averages about 10 KB/s and drops often, and devices stay in service for 10 years and may boot up to 20 times a day.
  • For this exercise, assume an update may stop the device's normal work for at most about 5 seconds, the application must be running within 1 second of power-on, hashing a full image takes about 50 ms and checking one signature about 200 ms.
  • For this exercise, assume 32 one-time-programmable bits are available to the boot loader as a minimum-security-version counter.