How stmicroelectronics/stm32-mw-mcuboot works
MCUboot is a secure bootloader and firmware-upgrade system for 32-bit MCUs. Its runtime entry point initializes the platform and security counters, then hands boot decisions to the boot utility; flash mapping, image selection/update state, and platform handoff support execution. The repository also includes imgtool for preparing, signing, inspecting, and verifying images. The excerpts establish the entry-point setup, counter updates, flash abstraction, and imgtool command wiring; some runtime calls and unsampled subsystems are not directly shown, so those links are omitted or marked unverified.
Main entry points: main.py imgtool CLI · bl2_main.c BL2 entry · loader.c Boot loader · security_cnt.c Security counters
Components 20
Boot and handoff
- BL2 entry
bl2/ext/mcuboot/bl2_main.c
Image boot utility
- Boot loader
boot/bootutil/src/loader.c - Image validation
boot/bootutil/src/image_validate.c - Image crypto
boot/bootutil/src/image_ec.c - Swap handling
boot/bootutil/src/swap_move.c - Scratch swap
boot/bootutil/src/swap_scratch.c - Boot record
boot/bootutil/src/boot_record.c - Image format
boot/bootutil/include/bootutil/image.h
Platform services
- Flash mapping
bl2/src/flash_map.c - Flash driver
platform/ext/driver/Driver_Flash.h - Security counters
bl2/src/security_cnt.c - NV counter API
platform/include/plat_nv_counters.h - Shared boot data
bl2/src/shared_data.c - Platform handoff
bl2/include/boot_hal.h
Image tooling
- imgtool CLI
scripts/imgtool/main.py - Image builder
scripts/imgtool/image.py - Key operations
scripts/imgtool/keys/ecdsa.py - Image inspection
scripts/imgtool/dumpinfo.py
Other components
- MCU device
- Firmware image
Connections 11
- MCU device → BL2 entry: starts
- BL2 entry → Boot loader: delegates boot
- Boot loader → Security counters: updates counter
boot/bootutil/src/loader.c - Security counters → NV counter API: uses counter API
bl2/src/security_cnt.c - Flash mapping → Flash driver: uses driver
bl2/src/flash_map.c - Shared boot data → Image format: reads image metadata
bl2/src/shared_data.c - BL2 entry → Platform handoff: initializes platform
bl2/ext/mcuboot/bl2_main.c - Firmware image → imgtool CLI: provides image
- imgtool CLI → Image builder: creates image
scripts/imgtool/main.py - imgtool CLI → Key operations: uses keys
scripts/imgtool/main.py - imgtool CLI → Image inspection: dispatches inspect
scripts/imgtool/main.py