Zephyr Hands-on: Adding MCUboot Support to FRDM-KE15Z
Secure Boot Enablement and Validation for Kinetis Using Zephyr Sysbuild
Objective: Extend the existing Zephyr support for FRDM-KE15Z with the Flash partition and SRAM configuration required by MCUboot, and verify the complete build, flash, and boot process.
1. Background
With the implementation of the EU Cyber Resilience Act (CRA), software security and vulnerability management are becoming increasingly important for embedded products. For products that need firmware updates to address security vulnerabilities, having a reliable and verifiable software update mechanism is essential.
The CRA does not require products to use a specific bootloader. However, it emphasizes cybersecurity by design, vulnerability handling throughout the product support period, and the delivery of necessary security updates. Therefore, adding secure firmware update capabilities to existing MCU-based products is becoming an increasingly common requirement in real-world projects.
MCUboot is an open-source secure bootloader with well-established integration in Zephyr. This makes it a practical option for implementing secure firmware update capabilities. In this article, we use the NXP FRDM-KE15Z as an example to demonstrate how to add MCUboot support to an existing Zephyr board.
2. Why Zephyr + MCUboot?
For earlier Kinetis MCUs, traditional solutions commonly rely on a ROM bootloader or secondary bootloader. These solutions typically focus on firmware download and programming, for example, downloading firmware to the MCU through a serial interface using blhost.
When the requirement expands to secure firmware updates, additional considerations are introduced, including:
Image signing
Image verification
Primary and secondary image slots
Image management during firmware updates
If MCUboot is ported completely from scratch, additional work is also required for MCU support, Flash drivers, linker scripts, and board-specific adaptation.
Using Zephyr simplifies this process because:
Zephyr already integrates MCUboot and can build both MCUboot and the application through Sysbuild.
FRDM-KE15Z is already supported upstream by Zephyr with the board target frdm_ke15z.
Basic MCU, Flash, UART, and board-level support is already available. Only the memory layout and configuration required by MCUboot need to be added.
Therefore, this is not a full MCUboot port from scratch. Instead, it is a relatively small board-level adaptation based on the existing Zephyr board support.
3. Adding MCUboot Support to FRDM-KE15Z
By default, the FRDM-KE15Z Devicetree does not define the Flash partitions required by MCUboot.
At minimum, MCUboot requires the following regions in Zephyr:
boot_partition : stores MCUboot
slot0_partition : primary image
slot1_partition : secondary image
3.1 Specify the Application Code Partition
Modify boards/nxp/frdm_ke15z/frdm_ke15z.dts.
Add zephyr,code-partition to the chosen node and map the application to slot0_partition:
chosen {
zephyr,sram = &sram_all;
zephyr,flash = &flash0;
zephyr,code-partition = &slot0_partition;
zephyr,console = &lpuart1;
zephyr,shell-uart = &lpuart1;
zephyr,crc = &crc;
};
3.2 Reorganize the 256 KB Flash
The Flash partitions are configured as follows:
&flash0 {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x00000000 DT_SIZE_K(44)>;
};
slot0_partition: partition@b000 {
label = "image-0";
reg = <0x0000b000 DT_SIZE_K(100)>;
};
slot1_partition: partition@24000 {
label = "image-1";
reg = <0x00024000 DT_SIZE_K(100)>;
};
storage_partition: partition@3d000 {
label = "storage";
reg = <0x0003d000 DT_SIZE_K(12)>;
};
};
};
The Flash layout used in this test is:
Region
Start Address
Size
Purpose
boot_partition
0x00000000
44 KB
MCUboot
slot0_partition
0x0000B000
100 KB
Primary Image
slot1_partition
0x00024000
100 KB
Secondary Image
storage_partition
0x0003D000
12 KB
Storage
The four regions use the complete 256 KB Flash while maintaining 2 KB Flash sector alignment.
3.3 Combine SRAML and SRAMU
After configuring the Flash partitions, MCUboot reports insufficient RAM during the linking stage.
The MKE15Z256 provides 32 KB SRAM, but the original Device tree divides it into:
SRAML: 0x1FFFE000, 8 KB SRAMU: 0x20000000, 24 KB
By default, zephyr,sram points only to the 24 KB SRAMU region.
Because these two SRAM regions are contiguous in the address space, they are combined into a single 32 KB SRAM region for this test:
/delete-node/ &sram_l;
/delete-node/ &sram_u;
/ {
sram_all: memory@1fffe000 {
compatible = "mmio-sram";
reg = <0x1fffe000 DT_SIZE_K(32)>;
};
};
Then update zephyr,sram in the chosen node:
zephyr,sram = &sram_all;
4. Building MCUboot + Application
For validation, the standard Zephyr hello_world sample is used as the test application.
With Sysbuild, MCUboot and the application can be built together using:
west build -p always -b frdm_ke15z --sysbuild samples/hello_world -- \
-DSB_CONFIG_BOOTLOADER_MCUBOOT=y
"SB_CONFIG_BOOTLOADER_MCUBOOT=y" enables MCUboot as part of the Sysbuild configuration.
During the build process, the following output appears:
image.py: sign the payload
This indicates that the application image has been signed for MCUboot.
Figure 1. MCUboot and hello_world build successfully
5. Flashing and Runtime Verification
After the build completes, simply run:
west flash
Sysbuild manages the MCUboot and application build domains, and flashing is performed using the default LinkServer runner for FRDM-KE15Z.
Figure 2. west flash log
After flashing, reset the board and monitor the serial output at 115200 baud.
MCUboot reports:
chainload address offset: 0xb000
It then jumps to the first image slot. 0xB000 is exactly the start address of slot0_partition.
The application subsequently prints: Hello World!
This confirms that MCUboot successfully boots and chainloads the signed application image from the primary slot.
Figure 3. Serial output showing MCUboot booting the signed hello_world application
6. Conclusion
For Kinetis MCUs without an existing MCUboot example, porting MCUboot completely from scratch can require considerable low-level adaptation.
However, for devices that are already supported by Zephyr, the existing MCU, Flash, and board support can be reused. The remaining work can then focus mainly on the Flash and SRAM configuration required by MCUboot.
In this article, MCUboot support was successfully added to FRDM-KE15Z, including:
MCUboot Flash partition configuration
SRAM layout adjustment
Building MCUboot and the application together using Sysbuild
Application image signing
Flashing with "west flash"
Booting MCUboot and successfully chainloading the signed application
This experiment focuses on basic MCUboot integration, image building, and the boot flow. For a production implementation, additional security considerations are required, including signing key management, firmware update transport, image confirmation and rollback policies, and the overall secure update process.
References
Cyber Resilience Act (CRA): Requirements, Deadlines & Penalties
Zephyr: FRDM-KE15Z Board Documentation
Zephyr: Sysbuild
Zephyr: MCUboot with Sysbuild Sample
MCUboot: Building and Using MCUboot with Zephyr
Zephyr GitHub: FRDM-KE15Z Board Sources
View full article