1# Building and using MCUboot with RIOT 2 3MCUboot began its life as the bootloader for Mynewt. It has since 4acquired the ability to be used as a bootloader for RIOT as well. 5Currently the support is limited to the nrf52dk platform. 6 7## Building the bootloader itself 8 9In this first version, a prebuilt Mynewt binary is downloaded at 10compile time. This binary was compiled to do an integrity check, but 11not a signature check. In order to configure the bootloader for 12signature check it is necessary to re-compile it either with Mynewt 13or Zephyr, following the provided instructions. 14 15In the next version, it is planned to compile MCUboot using RIOT, 16which should be able to boot any of the supported OS images. 17 18## Building applications for the bootloader 19 20A compatible MCUboot image can be compiled by typing: `make mcuboot`. 21 22The only variable which needs to be set is `IMAGE_VERSION` loaded 23with a valid formatted value. The format is `major.minor.patch+other` 24(e.g. `export IMAGE_VERSION= 1.1.1+1`. This variable can be either 25exported in the Makefile or manually, prior to the compilation process. 26 27The goal is to produce an ELF file which is linked to be flashed at a 28`BOOTLOADER_OFFSET` offset rather than the beginning of ROM. MCUboot 29also expects an image padded with some specific headers containing the 30version information, and trailer type-length-value records (TLVs) with 31hash and signing information. This is done through the imgtool.py 32application, which is executed automatically by the RIOT build system. 33 34### Signing the application 35 36The application will be automatically signed with the provided key. 37If no key is provided, a new key will be automatically generated. The 38default key type is RSA-2048. 39 40In order to use your provided key, you need to recompile the bootloader 41using you public key, either in Zephyr or Mynewt by following the 42provided procedure for the selected OS. 43 44### Flashing the application 45 46The application can be flashed by typing: `make flash-mcuboot`. 47This will flash both the bootloader and the application. 48