$ show mcu-tools/mcuboot
MCUboot is a secure bootloader for 32-bit microcontrollers, providing signed and encrypted firmware upgrade capabilities. The repository contains the core bootloader library (C) with support for multiple RTOS platforms (Zephyr, Mynewt, NuttX, Mbed OS, Espressif, Cypress), a Python image signing and management tool (imgtool), a Rust-based simulator for testing boot scenarios, and vendored cryptographic libraries (TinyCrypt, Mbed TLS subset, fiat-crypto). The system architecture is a library with platform-specific ports: the common boot logic (bootutil) handles image validation, swap algorithms (scratch, move, offset, direct-XIP, RAM-load), encryption, and fault-injection hardening. Each platform provides flash map, logging, watchdog, and boot entry point implementations. The codebase is highly configurable via compile-time flags, supporting multiple signature schemes (RSA, ECDSA, Ed25519), encryption backends, and upgrade modes. It is not a standalone application but a bootloader intended to be integrated into embedded firmware projects.
The LLM identified 5 files worth highlighting for reuse:
Provides a unified ECDSA verification API that abstracts over multiple backend implementations (mbedTLS, TinyCrypt, PSA, CC310, custom). The header defines a struct and inline functions for signature verification, allowing the bootloader to switch crypto libraries without changing callers. Reusable in any embedded C project needing pluggable ECDSA verification.
Implements fault-injection hardening macros (FIH) for critical functions. Supports profiles (OFF, LOW, MEDIUM, HIGH) with techniques like double-variable checks, control flow integrity counters, and random delays. The header-only design makes it trivially reusable in any C codebase where resistance to glitching attacks is required.
Implements a robust TLV (Type-Length-Value) iterator for parsing image metadata. Functions `bootutil_tlv_iter_begin`, `bootutil_tlv_iter_next`, and `bootutil_tlv_iter_find` provide safe traversal of protected and non-protected TLV areas. The pattern is self-contained and can be extracted for any binary TLV format parsing.
A Python CLI tool (imgtool) for generating cryptographic keys, signing firmware images, encrypting payloads, and inspecting image metadata. Supports RSA, ECDSA, Ed25519, X25519, AES-CTR, and various key wrapping schemes. Its modular design (keys subpackage, image module, version handling) makes it reusable as a standalone build tool for any MCUboot-based project.
Rust module that simulates bootloader scenarios with systematic fault injection (random resets, write failures, corrupt images). The `ImagesBuilder` pattern and `run_perm_with_fails` function provide a reusable framework for testing upgrade logic across multiple swap algorithms and configurations. Demonstrates a high-craftsmanship approach to hardware-in-the-loop simulation without hardware.