How coreboot/arm-trusted-firmware works
Project type and purpose
• This is not an application or web service but a reference firmware implementation (Trusted Firmware-A) for Arm A-Profile processors. It provides the secure-world boot stages and runtime services (EL3 Secure Monitor, secure payloads, PSCI, SMC/SCMI/SDEI interfaces) needed to bootstrap both secure and non-secure software on Armv8-A/Armv7-A systems.
Key architectural areas (derived from file tree and README)
• Boot stages (bl1, bl2, bl2u, bl31, bl32)
• Common libraries and utilities (common, lib, libfdt, zlib, compiler-rt)
• Hardware abstraction (drivers/)
• Platform integration (plat/)
• Secure services framework (services/, including PSCI, SPMD, SCMI, SDEI, TBBR)
• Tools and packaging utilities (tools/, fiptool, encrypt_fw, tlc)
• Documentation (docs/)
Main components and layers
A. Hardware and Boot ROM
• On-chip ROM / BootROM
• SoC peripherals (GIC, timers, memory controller)
B. BL1 – Initial Boot Loader
• Minimal SRAM code that sets up CPU and loads BL2 from storage
C. BL2 – Secondary Boot Loader
• Platform-agnostic image loading
• Authentication (TBBR/COT)
• Passes control to BL31
D. BL31 – EL3 Secure Monitor
• Implements SMCCC, PSCI, SCMI, SDEI interfaces
• Manages world switches (secure ↔ non-secure)
• Provides runtime services via “services/” modules
E. BL32 – Secure Payload(s)
• Optional Trusted OS or simple service (SP_MIN, TSP, OPTEE, TLKD, Trusty)
• Runs at EL1 in secure world
F. BL33 – Non-secure Payload
• Secondary bootloader or OS (e.g., UEFI, Linux) loaded via PSCI/smccc
G. Common Libraries and Drivers
• Driver framework (drivers/) behind unified IO and platform drivers
• lib/ and common/ for context management, memory management, crypto, FDT handling
H. Platform Adaptation Layer
• plat/ contains code for each SoC/Board (clock init, topology, platform_def.h, FDT fixups)
I. External Tools
• FIP creation (tools/fiptool), encryption (tools/encrypt_fw), certificate creation
Relationships and dataflow
• BootROM → BL1 → BL2 → BL31 → {BL32, BL33}
• BL31 exports SMC gateway (SMC invocations) to BL32 and BL33
• PSCI calls from non-secure OS → forwarded by BL31 to platform power drivers
• SCMI messages from EL3 → drivers in BL31 → devices
• SDEI interrupts handled in BL31 → delivered to registered handlers in BL32
• Drivers in BL31/BL1 use common libfdt to parse device-tree (fdts/)
• Platform code in plat/<vendor>/<board> is called from each stage for board-specific init
Architectural patterns and principles
• Layered boot stages isolate responsibilities and privileges
• Modular services in BL31 (services/) implement standardized Arm interfaces
• Portable hardware abstraction via drivers/ + common/ + include/
• Platform-specific overrides in plat/ allow reuse of core code
• Build system (Makefile, make_helpers/) orchestrates multicore, multi-stage builds