2018-01-23 01:02:46 +08:00
|
|
|
# Building and using MCUboot with RIOT
|
2017-07-20 05:00:27 +08:00
|
|
|
|
2018-01-23 01:02:46 +08:00
|
|
|
MCUboot began its life as the bootloader for Mynewt. It has since
|
2017-07-20 05:00:27 +08:00
|
|
|
acquired the ability to be used as a bootloader for RIOT as well.
|
|
|
|
Currently the support is limited to the nrf52dk platform.
|
|
|
|
|
2018-01-23 01:02:46 +08:00
|
|
|
## Building the bootloader itself
|
2017-07-20 05:00:27 +08:00
|
|
|
|
|
|
|
In this first version, a prebuilt Mynewt binary is downloaded at
|
|
|
|
compile time. This binary was compiled to do an integrity check, but
|
|
|
|
not a signature check. In order to configure the bootloader for
|
|
|
|
signature check it is necessary to re-compile it either with Mynewt
|
|
|
|
or Zephyr, following the provided instructions.
|
|
|
|
|
2018-01-23 01:02:46 +08:00
|
|
|
In the next version, it is planned to compile MCUboot using RIOT,
|
2017-07-20 05:00:27 +08:00
|
|
|
which should be able to boot any of the supported OS images.
|
|
|
|
|
2021-11-03 20:19:22 +08:00
|
|
|
## Building applications for the bootloader
|
2017-07-20 05:00:27 +08:00
|
|
|
|
2018-01-23 01:02:46 +08:00
|
|
|
A compatible MCUboot image can be compiled by typing: `make mcuboot`.
|
2017-07-20 05:00:27 +08:00
|
|
|
|
2018-01-23 01:02:46 +08:00
|
|
|
The only variable which needs to be set is `IMAGE_VERSION` loaded
|
|
|
|
with a valid formatted value. The format is `major.minor.patch+other`
|
|
|
|
(e.g. `export IMAGE_VERSION= 1.1.1+1`. This variable can be either
|
2017-07-20 05:00:27 +08:00
|
|
|
exported in the Makefile or manually, prior to the compilation process.
|
|
|
|
|
|
|
|
The goal is to produce an ELF file which is linked to be flashed at a
|
2018-01-23 01:02:46 +08:00
|
|
|
`BOOTLOADER_OFFSET` offset rather than the beginning of ROM. MCUboot
|
2017-07-20 05:00:27 +08:00
|
|
|
also expects an image padded with some specific headers containing the
|
|
|
|
version information, and trailer type-length-value records (TLVs) with
|
|
|
|
hash and signing information. This is done through the imgtool.py
|
|
|
|
application, which is executed automatically by the RIOT build system.
|
|
|
|
|
2018-01-23 01:02:46 +08:00
|
|
|
### Signing the application
|
2017-07-20 05:00:27 +08:00
|
|
|
|
|
|
|
The application will be automatically signed with the provided key.
|
|
|
|
If no key is provided, a new key will be automatically generated. The
|
|
|
|
default key type is RSA-2048.
|
|
|
|
|
|
|
|
In order to use your provided key, you need to recompile the bootloader
|
|
|
|
using you public key, either in Zephyr or Mynewt by following the
|
|
|
|
provided procedure for the selected OS.
|
|
|
|
|
2018-01-23 01:02:46 +08:00
|
|
|
### Flashing the application
|
|
|
|
|
|
|
|
The application can be flashed by typing: `make flash-mcuboot`.
|
2017-07-20 05:00:27 +08:00
|
|
|
This will flash both the bootloader and the application.
|