MCUboot is a secure bootloader for 32-bits microcontrollers.
- Secure firmware verification using cryptographic signatures
- Support for multiple image upgrade strategies
- NuMicro microcontroller (Supported Platform)
- Toolchain:
CMake,NinjaandArm Compiler 6/GCC - Flashing Tool:
PyOCD
Cloning all submodules recursively may impact performance and consume significant disk space. It is recommended to selectively clone only the submodules needed.
- Cloning necessary submodules
git submodule update --init -- lib/ext/mcubootlib/mcuboot
git submodule update --init -- lib/ext/mbedtlslib/mbedtls
- Clone the corresponding BSP based on your board model. For example, with M460:
git submodule update --init -- bl2/platform/m460/bsplib/bsp
It is recommended to use CMake Presets to handle CMake configuration. Using M460 as an example:
mkdir build
cp CMakeUserPresets.json.sample CMakeUserPresets.json
cmake --preset m460 --fresh
For example, to configure M55M1 with:
- ARM Compiler
- Build type: RELWITHDEBINFO
- EC-P256 image signature verification
Add a new section in CMakeUserPresets.json:
{
"name": "m55-relwithdbg",
"inherits": "common",
"cacheVariables": {
"CMAKE_BUILD_TYPE":"RELWITHDEBINFO",
"CMAKE_TOOLCHAIN_FILE": "toolchain/armclang.cmake",
"CMAKE_SYSTEM_PROCESSOR": "cortex-m55",
"PLATFORM_NAME": "m55m1",
"MCUBOOT_SIG_TYPE": "ecdsa-p256"
}
}
And make sure you specify the correct preset during configuration:
cmake --preset m55-relwithdbg --fresh
cmake --build build/m460 --clean-first
pyocd load -t m467hjhae build/m460/bin/bl2.bin
The bootloader behavior can be customized using CMake variables. CMake variables can be configured directly via command line arguments or specified within CMakeUserPresets.json.
Change the algorithm used for signature validation:
-DMCUBOOT_SIG_TYPE=EC
-DMCUBOOT_SIG_LEN=256
Enable more verbose logging:
-DMCUBOOT_LOG_LEVEL=DEBUG
Change upgrade strategies:
-DMCUBOOT_UPGRADE_STRATEGY=DIRECT_XIP
Check available configuration options in mcuboot_default_config.cmake.
Warning
The SPI flash driver is currently supported on M460 only.
-DSECONDARY_SLOT_IN_SPI_FLASH=ON
The SPI flash uses the standard SPI interface by default. To enable the SPIM interface instead, configure as follows:
-DSPI_DRIVER=SPIM
To enable the QSPI interface instead, configure as follows:
-DSPI_DRIVER=QSPI
The flash layout file configures image slot parameters, such as the address or the size of secondary slot. For M460, this sets the primary slot to 64 KiB starting at 0x30000:
// bl2/platform/m460/partition/region_defs.h
#define FLASH_AREA_0_OFFSET (0x30000)
#define FLASH_AREA_0_SIZE (0x10000)| Device | Core |
|---|---|
| M2354 | Cortex-M23 |
| M480 | Cortex-M4 |
| M55M1 | Cortex-M55 |
| M261 | Cortex-M23 |
| M460 | Cortex-M4 |
| M2L31 | Cortex-M23 |
| M3331 | Cortex-M33 |
| M3351 | Cortex-M33 |
| M2351 | Cortex-M23 |
To work with MCUBoot, the repository MCUBoot-Compatible-Template provides template firmware code for validating MCUBoot firmware upgrade strategies. Users can reference the template and customize the provided code according to their needs. By programming the images to the flash address of primary and secondary slot, MCUBoot will jump to the correct image based on the chosen strategy.
CMake Tools provides a convenient interface for working with CMake-based project in VS Code. For more details, see the CMake Tools documentation
Please check out keys.md.
Please check out layout.md
- Implement the ARM flash driver interface (Driver_Flash.c)
- ARM_Flash_GetCapabilities
- ARM_Flash_Initialize
- ARM_Flash_Uninitialize
- ARM_Flash_PowerControl
- ARM_Flash_ReadData
- ARM_Flash_ProgramData
- ARM_Flash_EraseSector
- ARM_Flash_GetStatus
- ARM_Flash_GetInfo
- Configure flash layout (
region_defs.h)
Refer to existing implementations as reference examples.
Please check out spi.md