🛠 Secure boot et TrustZone-M sur RP2350 : signer son firmware sans se faire avoir

RP2350 (generic / RP2350-based boards) · avance · Schéma : IMG-rp2350-generic-avance-1-rp2350-secure-boot-trustzone.svg — puce RP2350 avec bloc boot ROM vérifiant une signature ECDSA secp256k1, mémoire OTP avec empreinte de clé publique et compteur anti-recul, domaines Secure/Non-Secure séparés par la SAU, cœurs RISC-V barrés (désactivés par le secure boot)

Objectives

The RP2350 is Raspberry Pi's first "mainstream" chip with a real security stack: extended system Arm TrustZone-M (peripherals, GPIO, and individual DMA channels assignable to Secure/Non-Secure domains, 8 SAU regions + 8+8 MPU regions per core), signed boot (SHA-256 + ECDSA secp256k1, public key fingerprint in 8 KB OTP, anti-rollback counter), encryption keys in OTP, hardware SHA-256 accelerator, TRNG, Redundancy Coprocessor (RCP), and glitch detector against fault injection (RP2350 datasheet, §10, §3.6.3, §12.12–12.13). This tutorial covers understanding the chain of trust, its two major trade-offs, and the order of operations — because OTP is irreversible.

Hardware

The Chain of Trust

  1. Immutable Boot ROM: on each reset, it reads a signature descriptor in flash; if secure boot is disabled (default state), it boots anything — this is what makes drag-and-drop UF2 possible.
  2. Key fingerprint in OTP: enabling secure boot = burning your public key fingerprint into OTP. Any image not signed with the corresponding private key is rejected. There is no "off" switch for OTP: a lost key = no more firmware possible on the chip.
  3. Anti-rollback: the OTP counter prevents reverting to older versions (downgrade protection) — plan your versioning policy BEFORE burning.
  4. TrustZone-M: SAU/MPU partitioning per core, and especially system granularity — you can put the USB controller in Non-Secure and your key in Secure. Beware of errata E3 on RP2350A (QFN-60): GPIO_NSMASK0 applies Non-Secure permissions from PADS to the wrong pins (the mapping ignores the QFN-60 pad remap, datasheet Appendix D.1.1) — re-read the errata before designing a Secure/Non-Secure partitioning on an RP2350A.

The Two Trade-offs to Know

Expected Verification

On the test board: signed image boots, image modified by one byte is rejected (status LED or bootrom return code signals this).

Common Mistakes

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials