How chipsalliance/caliptra-mcu-sw works
This repository is a workspace for Caliptra MCU firmware, emulator support, host-side utilities, and protocol libraries. The architecture is split around two execution domains: the MCU-side firmware stack, and the host/emulator/test infrastructure that drives and validates it.
1. Core firmware split: ROM vs runtime
- rom/ contains the immutable boot firmware that handles cold boot, warm boot, lifecycle, OTP, image verification, recovery, and device ownership transfer.
- runtime/ contains the mutable firmware environment that runs after boot and provides higher-level services.
- romtime/ holds shared boot/runtime primitives used by both sides, such as boot status and MCU/SoC coordination.
2. Runtime is a Tock-based two-layer system
- The runtime follows a Tock-style architecture: a kernel layer plus U-mode apps.
- runtime/kernel/ contains board-level initialization and low-level drivers/capsules for devices like DOE, flash, I3C, MCU mailbox, MCTP, and system services.
- runtime/userspace/apps/ contains service applications such as SPDM, firmware update, image loading, mailbox handling, and VDM handling.
- The boundary is important: hardware access and privileged operations live in the kernel/capsules; protocol logic and workflows live in userspace apps.
3. Protocol and service planes
- The major external-facing protocols are SPDM, PLDM, MCTP VDM, mailbox commands, and MCU mailbox commands.
- These protocols are implemented in reusable libraries under runtime/userspace/api/, common/, and caliptra-util-host/.
- Data flows typically move from transport binding → protocol decode/encode → command handler/state machine → firmware or hardware operation.
4. Shared protocol libraries
- common/mctp-vdm, common/pldm, and related crates define message codecs, protocol structures, and transport helpers shared across firmware, emulator, and host tools.
- runtime/userspace/api/spdm-lib, pldm-lib, mctp-vdm-lib, and mcu-mbox-lib mirror those protocol stacks for the firmware runtime side.
- This separation keeps wire-format handling reusable while allowing different execution environments.
5. Emulator as a hardware substitute
- emulator/ models the MCU, Caliptra subsystem, and attached peripherals so the ROM/runtime stack can run without real hardware.
- emulator/periph/ provides emulated peripherals such as flash, OTP, I3C, DOE mailbox, lifecycle controller, and MCU mailbox.
- emulator/app/ is the main executable and includes test scenarios, GDB support, ELF loading, and mailbox/transport behavior.
- emulator/bmc/ and its PLDM components simulate the BMC-side firmware-update path.
6. Hardware model abstraction and platform support
- hw/model/ provides a common abstraction layer for running different platform models in tests.
- platforms/emulator/ and platforms/fpga/ supply platform-specific ROM/runtime entry points, board wiring, flash configuration, and device-specific drivers.
- This boundary makes the same ROM/runtime logic portable across emulator and FPGA targets.
7. Register generation and hardware-description pipeline
- hw/*.rdl and registers/ form the register-definition pipeline.
- registers/systemrdl, registers/systemrdl-new, registers/generator, and the registers/generated-* crates turn RDL/SystemRDL into Rust register definitions and emulator traits.
- The generated code feeds both firmware drivers and emulator peripheral emulation, so register layout is a shared contract across the stack.
8. Common configuration, flash, and provisioning artifacts
- common/config, common/flash-image, provisioning/fuses, and firmware-bundler/ manage boot-time image layout, flash metadata, fuse generation, and packaging.
- These crates define the data produced at build/provision time and consumed by ROM boot logic and emulator/image-loading paths.
9. Host-side utilities and external interfaces
- caliptra-util-host/ exposes host APIs and CLI tools for mailbox and MCTP VDM interactions, including C bindings for integration with non-Rust environments.
- ocp-eat-verifier/ verifies attestation artifacts such as OCP EAT tokens and COSE/CORIM structures.
- These crates sit outside the firmware boundary but are part of the end-to-end attestation and command ecosystem.
10. Testing architecture
- tests/ contains end-to-end integration tests that exercise ROM boot, runtime services, mailbox, MCTP, PLDM firmware update, I3C, lifecycle transitions, and attestation flows.
- runtime/.../tests and emulator/.../tests provide lower-level component and protocol tests.
- The test suite is designed around the emulator as the main execution harness, with some paths targeting FPGA-specific behavior.
11. Build and orchestration tooling
- xtask/ is the central orchestration layer for builds, formatting, register generation, docs, emulator runs, and test execution.
- The repository policy is to route the main workflows through cargo xtask, which is significant because it is the integration point for building firmware, generating artifacts, and running validation.
12. Boundary summary for diagramming
- At the bottom are hardware descriptions and register definitions.
- Above that are generated register crates, platform boards, and low-level drivers.
- ROM owns boot and security-critical transitions.
- Runtime owns services and protocol handling through Tock kernel/app layers.
- Emulator, host tools, and integration tests surround the firmware to simulate peripherals, inject traffic, and validate behavior.
Main entry points: registers Registers · xtask Xtask · common Common Protocols · rom ROM
Components 19
Firmware
MCU-side boot and runtime software stack
- ROM · Immutable boot firmware handling boot, lifecycle, OTP, verification, recovery, and ownership transfer
rom - Romtime · Shared boot/runtime primitives for status and MCU/SoC coordination
romtime - Runtime Kernel · Privileged board init, drivers, and capsules for hardware access and system services
runtime/kernel - Runtime Apps · Unprivileged service apps implementing SPDM, firmware update, image loading, mailbox, and VDM workflows
runtime/userspace - Runtime APIs · Firmware-side protocol and service libraries shared by runtime apps
runtime/userspace/api
Shared
Libraries and artifacts reused across firmware, host, and emulator
- Common Protocols · Reusable wire-format, transport, and protocol helpers shared across domains
common - Config & Images · Boot configuration, flash image layout, and provisioning-related data models
common/config - Provisioning · Fuse generation and provisioning support artifacts
provisioning/fuses
Host & Emulator
Host tooling, emulator, and validation infrastructure
- HW Model · Common abstraction for emulator and FPGA-backed model behavior in tests
hw/model - Emulator · Hardware substitute modeling peripherals, ROM/runtime execution, and BMC-side flows
emulator - Host Tools · Host-side mailbox and MCTP VDM utilities plus C bindings
caliptra-util-host - OCP Verifier · Verifier for OCP EAT and COSE/CORIM attestation artifacts
ocp-eat-verifier - Integration Tests · Cross-domain tests exercising ROM, runtime, emulator, protocols, and platform behavior
tests/integration
Hardware & Platforms
Register sources, models, and platform-specific entry points
- Registers · SystemRDL parsing and code generation pipeline producing shared register crates
registers - HW Descriptions · Top-level hardware register definitions and FPGA support descriptions
hw - Emu Platform · Emulator-specific ROM/runtime entry points and board wiring
platforms/emulator - FPGA Platform · FPGA-specific ROM/runtime entry points, flash configuration, and board wiring
platforms/fpga
Tooling
Build, packaging, and orchestration
- Firmware Bundler · Manifest, linker, and image bundling for firmware deployment artifacts
firmware-bundler - Xtask · Central command layer for builds, generation, docs, emulator runs, and tests
xtask
Connections 27
- ROM → Romtime: uses · Boot code consumes shared boot/runtime primitives
- ROM → Config & Images: reads · Boot logic depends on image and flash configuration data
- ROM → Common Protocols: uses · ROM shares transport/protocol definitions where needed
- Runtime Kernel → Romtime: coordinates · Kernel participates in boot and SoC coordination
- Runtime Kernel → Registers: uses · Drivers and capsules rely on generated register definitions
- Runtime Apps → Runtime APIs: uses · Apps build on firmware-side protocol/service libraries
- Runtime Kernel → Runtime Apps: hosts · Kernel provides the privileged boundary for userspace apps
- Runtime APIs → Common Protocols: mirrors · Firmware-side APIs mirror shared protocol and transport stacks
- Runtime APIs → Config & Images: uses · Runtime services consume shared boot and flash configuration
- Common Protocols → Registers: binds · Protocol implementations align to generated register and device contracts
- HW Descriptions → Registers: feeds · RDL/SystemRDL sources generate register crates and traits
- Registers → Emu Platform: drives · Generated emulator-side register traits back peripheral modeling
- Registers → FPGA Platform: drives · Generated firmware-side register definitions support FPGA targets
- Emu Platform → Emulator: runs on · Emulator platform entry points are executed inside the simulator stack
- FPGA Platform → HW Model: integrates · FPGA platform behavior is exercised through shared model abstractions
- Emulator → HW Model: implements · Simulator supplies a model backend for platform-agnostic tests
- Emulator → Common Protocols: exercises · Emulator validates shared protocol flows and transports
- Host Tools → Common Protocols: uses · Host utilities speak the same mailbox and MCTP VDM protocols
- OCP Verifier → Runtime APIs: verifies · Verifier consumes attestation outputs produced by runtime services
- Integration Tests → Emulator: drives · End-to-end tests primarily execute through the emulator harness
- Integration Tests → FPGA Platform: targets · Some tests cover FPGA-specific behavior and entry points
- Firmware Bundler → Config & Images: packages · Bundling uses layout and manifest data for flashable images
- Xtask → ROM: builds · Orchestrated workflows compile the ROM image
- Xtask → Runtime Apps: builds · Orchestrated workflows compile runtime applications
- Xtask → Registers: generates · Xtask runs register generation and related build steps
- Xtask → Firmware Bundler: packages · Xtask drives firmware packaging workflows
- Xtask → Integration Tests: runs · Xtask is the central entry point for validation workflows