rustBoot Partitions
rustBoot has 2 distinct partitioning schemes, depending on the type of the underlying system.
- micro-controller partitions: uses the concept of
swappable flash partitionsto update micro-controller firmware.This usually means bare-metal firmware but it is also applicable to
RTOS(s). - linux system partitions: uses a single fat32 partition to host the
rustBoot-bootloaderand (boot/update) fit-images. This method uses arustBoot-statefile to determine which image is to be booted.
Micro-controller Partitions:
Note:
BOOT,UPDATEandSWAPpartitions need NOT be consecutively laid out in flash memory. The above diagram only serves as a visual aid.
rustBoot requires an mcu's non-volatile memory (or flash storage) to be divided into (at-least) 4 non-overlapping memory regions (i.e. partitions).
rustBoot: contains the bootloader. This usually starts ataddress 0x0in flash-memory.BOOT:contains boot firmware.rustBootalways boots from this partition address.UPDATE:contains update firmware i.e. downloaded update firmware is placed in this partition.SWAP:is an empty partition that is used to swap contents ofBOOTandUPDATE, one sector at a time.
All 3 partition boundaries must be aligned to a physical sector as rustBoot erases all flash sectors prior to storing a new firmware image, and swaps the contents of the two partitions, one sector at a time.
To ensure that a partition's sector alignments are maintained, the following points must be considered:
BOOT and UPDATEpartition must be of the same size.SWAPpartitionmust be larger than or equal to the largest sectorin eitherBOOTorUPDATEpartition.
MCU flash memory is partitioned as follows:
- rustBoot partition starts at
address 0x0in flash memory. It should be at least 32KB in size. BOOTpartition starts at a pre-defined address -BOOT_PARTITION_ADDRESSUPDATEpartition starts at a pre-defined address -UPDATE_PARTITION_ADDRESS- both partitions must be of the same size, defined by
PARTITION_SIZE
- both partitions must be of the same size, defined by
SWAPpartition starts at a predefined address -SWAP_PARTITION_ADDRESS- swap-space size is defined by
SECTOR_SIZEand must be larger than the largest sector in eitherBOOTorUPDATEpartition.
- swap-space size is defined by
BOOT, UPDATE, SWAP addresses and SECTOR_SIZE, PARTITION_SIZE values can be set via source files - constants.rs.
MCU defaults:
- By default, public keys used for firmware validation are embedded in
rustBoot-firmwareduring a factory image-burn. However, rustBoot also supports the option to retrieve them from secure-hardware (ex: crypto-elements).- The
BOOTpartition is the only partition from which we can boot a firmware image. The firmware image must be linked so that its entry-point is at address256 + BOOT_PARTITION_ADDRESS.BOOTfirmware is responsible for downloading a new firmware image via a secure channel and installing it in theUPDATEpartition.- To trigger an update, the
BOOTfirmware updates thestatus byteof theUPDATEpartition and performs a reboot. This will allow the bootloader toswap the contentsofBOOTpartition with that of theUPDATEpartition.
Linux system partitions:
To boot into a linux system, rustBoot includes support for the fat32 file-system.
Boot-storage media must contain a fat32 partition
- of at least 150 MiB to accommodate the bootloader, boot + update fit-images and other vendor-specific boot files and
- to add rustBoot support for your board, you can either implement the
BlockDevicetrait for your board's boot-storage mediacontrolleror simply use an existing implementation from the repo.
Note: rustBoot comes with batteries-included. It provides
rustyimplementations for basic peripherals such as flash, uart, crypto, gpio (out of the box) along with the necessary arch-specific initialization routines.
- for example: the rustBoot implementation for
rpi4includes bare-metal drivers for the on-board emmc controller, gpio and uart peripherals.