MCUBoot Integration
Introduction
This page describes how MCUBoot is integrated in the SDK for AM13E230X and AM13E232X: what it is, how the SDK port is structured, how the two MCUBoot examples cooperate, and how to bring them up on a board.
For the signing flows, key provisioning and the update protocol, see:
Enabling Secure Boot — ROM vs. MCUBoot signing, CCS/CMake configuration, update protocol
Security Overview — device lifecycle (HSFS/HSSE) and key provisioning
CyberShield Toolkit (CST) — the
ti_cstsigning tool
What MCUBoot Does
MCUBoot is a secure bootloader library. At reset it inspects the firmware image slots in flash. Each image carries a header (version, size) and a trailer of TLV (type-length-value) entries that holds the authentication tag. MCUBoot validates every candidate image, selects the newest valid one and hands control to it. An image that is corrupt, unsigned or signed with the wrong key is never executed, so a failed update cannot replace a working image.
The SDK uses a customized MCUBoot with two differences from the upstream defaults:
Feature |
SDK configuration |
|---|---|
Image authentication |
AES-CMAC-128 ( |
Update strategy |
Direct XIP ( |
The key is compiled into the bootloader only to keep the examples self-contained. In a product, the key can be placed in data flash and protected with the GSC, so that it is not stored in the bootloader image itself.
The image trailer holds a single CMAC TLV and no separate hash TLV. The AES-CMAC is computed over the image header and body, so it protects both integrity and authenticity and a plain hash would add nothing.
The firmware is executed directly from flash, so an image can run only at the address it was linked for. The SDK
therefore links every application for the primary slot address, and the entry point is always 0x00010100
(the vector table, placed after the image header at offset 0x100 in the slot). The image in the secondary
slot is linked the same way, so on its own it is not executable at its physical location.
To activate it, the bootloader does not copy the image into the primary slot. It asks the device to swap which
physical flash bank is mapped at address 0x00000000. The secondary slot then appears at the primary slot
address, where the image was linked to run, and the boot manager jumps to the same entry point as before. This
is a swap of the address mapping of the two banks and moves no image data.
Components
Component |
Location |
Role |
|---|---|---|
MCUBoot core ( |
|
Image validation and slot selection |
Device port |
|
Flash map, MCUBoot configuration, slot IDs |
Boot manager example |
|
The bootloader application |
Firmware update example |
|
Application that receives and stages updates |
Host tool |
|
Sends an image over UART |
Linker scripts |
|
Slot placement, |
Signing |
|
Post-build signing with |
Device port
Each device port in source/security/mcuboot/<device>/ contains:
File |
Purpose |
|---|---|
|
Direct XIP, CMAC algorithm and key, image count, maximum sector count |
|
Flash area table (bootloader, primary, secondary) and flash access functions |
|
Flash area IDs and the image-to-slot mapping macros |
|
Adds the port include directories and sources to the |
MCUBOOT_WATCHDOG_FEED() in mcuboot_config.h is intentionally defined empty, so it does nothing. Upstream MCUBoot
calls it inside long flash erase and copy loops so that a watchdog does not reset the device during an overwrite or
swap. Direct XIP never runs those loops, and the boot manager does not enable a watchdog. If you use a watchdog in
the boot manager, or move to a strategy that erases or copies flash, define the macro to service your watchdog.
In Direct XIP mode MCUBoot only reads flash, so flash_area_read() is a direct memory copy and
flash_area_write() and flash_area_erase() are intentionally empty. Writing the update image is done by the
application, not by the bootloader.
The library is enabled per device with set(TI_SDK_INCLUDE_MCUBOOT ON) in
source/device/<device>/cmake/<device>_ti_sdk.cmake, and is selected by an example through the mcuboot entry
in its libraries list.
Flash Layout
Both devices use the same slot layout (two 256 KB banks, 192 KB image slots):
Region |
Address range |
Size |
Bank |
Defined in |
|---|---|---|---|---|
Bootloader |
|
64 KB |
0 |
|
Primary slot |
|
192 KB |
0 |
|
Reserved |
|
64 KB |
1 |
linker script |
Secondary slot |
|
192 KB |
1 |
|
The address and size values in flash_map_backend.h, the memory regions in the signed linker scripts and the
--slot-size passed to the signing tool must stay consistent. Changing the layout requires changing all
three.
The signed MCUBoot image starts with a 32-byte header at the beginning of the primary slot. The vector table
sits at 0x00010100, which is the address the boot manager programs into the vector table offset register.
How the Examples Work Together
Boot manager
mcuboot_boot_manager is the bootloader. It runs from the bootloader region and is the only image the device
ROM boots. On a device in HSSE state it must be signed with ROM signing; on HSFS it can be unsigned. See
Security Overview.
On reset, App_McubootBootManager_Execute() selects an image and hands control to it:
Check for re-entry. The boot manager must run only once per reset. If the system controller has already received INITDONE (
DL_SYSCTL_isINITDONEIssued()returns true), the function asserts and does nothing else.Select an image.
boot_go()validates the primary and secondary slots and reports the winner inboot_rsp. If no valid image is found,LOG_ASSERTstops the boot.Map the selected bank. If the winner is in the secondary slot,
DL_SYSCTL_swapFlashBank()maps that bank at address0x00000000, so the image appears at the primary slot address. For a primary-slot winner nothing needs to be done.Set the vector table.
DL_GSC_setVTOR_NSpoints the vector table at the application entry address.Complete boot.
DL_SYSCTL_issueINITDONE()tells the system controller that boot is complete.
Its SysConfig enables the NONMAIN options needed for this flow (cscExists and flashBankSwap), and on the
LaunchPad it selects the external-crystal clock profile.
Firmware update application
mcuboot_fw_update is an ordinary application signed with MCUBoot signing. It is linked for the primary
slot and runs two activities concurrently so that the effect of an update on real-time behavior is visible:
Activity |
Priority |
Behavior |
|---|---|---|
Timer ISR (every 50 µs) |
0 (highest) |
Toggles the heartbeat LED every 500 ms; drives the status LED from the update state |
UART ISR (UC4, 115200 8N1) |
1 |
Receives 262-byte packets; the RX callback copies the packet and re-arms reception |
The main loop is non-blocking. When the RX callback flags a packet, the main loop passes it to
FwUpdate_ProcessPacket() and sends a 5-byte ACK through an interrupt-driven transmit.
fw_update.c implements the update state machine (Idle, Ready, Downloading, Complete, Error). Data is
accumulated in RAM and written one flash sector at a time. The destination is fixed in app_cfg.h as
APP_FW_UPDATE_BANK_ADDRESS (0x00050000, the secondary slot) and is not sent over the wire. The protocol and
LED behavior are described in Enabling Secure Boot.
The transfer checks only transport integrity (CRC16). Authentication is done later by the boot manager.
Security considerations
The update application is deliberately not a trust boundary. It accepts data from an unauthenticated UART link and writes it to the secondary slot. All security decisions are made by the boot manager when it validates the image at the next reset:
Authentication. An image is accepted only if its AES-CMAC-128 tag, computed with the key in
mcuboot_config.h, is valid. Anything received over UART, whether corrupted, unsigned or signed with another key, is rejected at boot and the current image keeps running. The CRC16 check is not a security mechanism.Version check. The boot manager activates the secondary image only if its version is higher than the running one, which prevents an older (for example vulnerable) signed image from replacing a newer one.
No confidentiality. The image is sent in clear text. Do not place secrets in the firmware image.
Fault injection hardening (FIH). The SDK builds MCUBoot with
MCUBOOT_FIH_PROFILE_MEDIUM, set insource/security/mcuboot/am13e230x/mcuboot_config/mcuboot_config.h. It protects the validation path in the boot manager (bootutil_img_validate()and the functions it calls) against voltage or clock glitches that try to skip a check or flip its result. The medium profile enables:Double variables (
FIH_ENABLE_DOUBLE_VARS): critical values, such as the validation result, are stored as(x, x ^ mask). Both halves are checked, so a single bit flip is detected.Global fail (
FIH_ENABLE_GLOBAL_FAIL): every failure loop branches to one hardened, non-inlinedfih_panic_loop(), so a glitch cannot escape an individual loop.Control flow integrity (
FIH_ENABLE_CFI): a global counter is incremented before and decremented after each protected call (FIH_CALL). Skipping a call, such as the CMAC comparison, leaves the counter wrong and is detected.
Random delays (
FIH_ENABLE_DELAY, theHIGHprofile) are not enabled, because they need an entropy source. FIH does not protect the update application, nor the ROM verification of the boot manager itself.Key handling. CMAC is a symmetric scheme, so anyone who can read the key can create images that the boot manager accepts. The key in
mcuboot_config.his a development key and is compiled into the bootloader for reference only. For a product, use a unique key, keep it out of source control, and store it in data flash protected through the GSC instead of in the bootloader image.Update channel. The UART link has no authentication, so anyone with access to it can overwrite the secondary slot (a denial of service for updates, not for the running image). Disable or restrict the update path in production, and keep the application’s debug port locked according to the device lifecycle described in Security Overview.
End-to-end sequence
Reset
|
Device ROM ---- verifies boot manager (ROM signature, HSSE only)
|
Boot manager -- boot_go(): validate primary + secondary (AES-CMAC-128, version)
| |
| +-- selected image in secondary slot? --> swap flash bank
|
Application ---- runs from 0x00010100; receives a new signed image over UART
| and writes it to the secondary slot (0x00050000)
|
Reset ---------- boot manager runs again, picks the new image if valid and
its version is higher; otherwise the current image keeps booting
A completed transfer does not activate the image. Activation happens at the next reset, and only if the new image is authentic and has a higher version than the one currently running.
Signing
The two examples use different signing types, handled by ti_sdk_sign_executable() after linking:
Image |
Target type |
Header / trailer |
Note |
|---|---|---|---|
Boot manager |
|
128 B / 44 B |
Verified by device ROM |
Application |
|
32 B / 24 B |
Verified by the boot manager |
The post-build step extracts a clean binary from the ELF, signs it, and writes the resulting header and trailer
back into the .header and .trailer sections of the ELF. For MCUBoot signing it also produces the
standalone signed binary (<target>.bin) that is sent to the device during an update.
Signing parameters can be overridden at configure time:
CMake variable |
Default |
Meaning |
|---|---|---|
|
|
Key index used for signing |
|
|
Image version; must be higher than the running image for an update to be activated |
|
empty |
CST session name; empty uses |
|
empty |
Password for the session; required when a session is given |
TI_SDK_SIGN_KEY_INDEX selects one of the four AES-CMAC keys (1-4) held in the CST session used for signing. It
is passed to ti_cst as --key-index and is not mapped to the KEYSTORECTL peripheral. The key index has a
different counterpart for each signing type:
ROM signing (boot manager): the index refers to the key of the same number that was provisioned into OTP (see Security Overview). Key 1 is the initial root of trust, and keys 2 to 4 are for key revision.
MCUBoot signing (application): the index must refer to the same key value as
MCUBOOT_CMAC_KEYinmcuboot_config.h, because the boot manager verifies the image with that compiled-in key. If they differ, the image is rejected at boot.
Note
If ti_cst is not installed, the build completes but skips signing, and the resulting image will not boot.
Install the CyberShield Toolkit first, see CyberShield Toolkit (CST).
The CMAC key in mcuboot_config.h is a development key. Replace it, and sign with a matching key, before
using these examples as the basis of a product, and consider moving it to GSC-protected data flash as described
in the Security considerations section above.
Running the Examples
Prerequisites
Board connected through the on-board debug probe, with a UART connection to the host for UC4
CyberShield Toolkit (
ti_cst) installedPython 3 with
pyserialfor the host toolOn an HSSE device, keys provisioned as described in Security Overview
Build
make all TI_SDK_DEVICE=<device>
The two images needed are:
Image |
CMake target (LaunchPad) |
|---|---|
Boot manager |
|
Application |
|
Program and verify
Program the boot manager at
0x00000000.Program the signed application at
0x00010000.Reset the board. A blinking heartbeat LED shows that the boot manager validated the application and handed over control.
Perform an update
Rebuild the application with a higher version, for example
-DTI_SDK_SIGN_MCUBOOT_IMG_VERSION=2.0, and keep the signed.bin.Send it to the running application:
python mcuboot_fw_update_host.py --file <signed_app>.bin --port <serial port> --baudrate 115200
Wait for the status LED to turn solid, which means the transfer completed and the CRC check passed.
Reset the board. The boot manager authenticates the secondary image, swaps the banks and boots it.
Troubleshooting
Symptom |
Likely cause |
|---|---|
No LED activity after reset |
Application not signed ( |
Status LED fast blink during transfer |
A packet failed its CRC or sequence check, or a flash write failed; send a new START packet to retry |
Transfer completes but the old image keeps booting |
New image version is not higher than the running image, or the image is not authentic |
Boot manager assertion at reset |
Neither slot holds a valid image; reprogram a validly signed image |
List of Supported Devices
Device |
Boards |
|---|---|
AM13E230X |
|
AM13E232X |
|
Other devices are not supported yet. Adding one requires a device port in source/security/mcuboot/<device>/ and
set(TI_SDK_INCLUDE_MCUBOOT ON) in the device CMake file.