# chipsalliance/caliptra-mcu-sw architecture

> Architecture diagram of the GitHub repository chipsalliance/caliptra-mcu-sw, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chipsalliance/caliptra-mcu-sw
- Repository: https://github.com/chipsalliance/caliptra-mcu-sw

## Overview

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`](https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/registers) (Registers), [`xtask`](https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/xtask) (Xtask), [`common`](https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/common) (Common Protocols), [`rom`](https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/rom) (ROM)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_firmware["Firmware"]
  node_rom["ROM<br/>boot firmware"]
  node_romtime["Romtime<br/>boot shared"]
  node_runtime_kernel["Runtime Kernel<br/>tock kernel"]
  node_runtime_userspace["Runtime Apps<br/>tock userspace"]
  node_runtime_api["Runtime APIs<br/>userspace libs"]
end

subgraph group_shared["Shared"]
  node_common_proto["Common Protocols<br/>shared codecs"]
  node_common_config["Config & Images<br/>build artifacts"]
  node_provisioning["Provisioning<br/>fuse tooling"]
end

subgraph group_host["Host & Emulator"]
  node_hw_model["HW Model<br/>model abstraction"]
  node_emulator["Emulator<br/>simulation"]
  node_host_tools["Host Tools<br/>cli/bindings"]
  node_ocp_verifier["OCP Verifier<br/>attestation verify"]
  node_integration_tests["Integration Tests<br/>end-to-end tests"]
end

subgraph group_hw["Hardware & Platforms"]
  node_registers_pipeline["Registers<br/>rdl pipeline"]
  node_hw_descriptions["HW Descriptions<br/>rdl sources"]
  node_platform_emulator["Emu Platform<br/>platform entrypoints"]
  node_platform_fpga["FPGA Platform<br/>platform entrypoints"]
end

subgraph group_tooling["Tooling"]
  node_fw_bundler["Firmware Bundler<br/>packaging"]
  node_xtask["Xtask<br/>orchestration"]
end

node_rom -->|"uses"| node_romtime
node_rom -->|"reads"| node_common_config
node_rom -->|"uses"| node_common_proto
node_runtime_kernel -->|"coordinates"| node_romtime
node_runtime_kernel -->|"uses"| node_registers_pipeline
node_runtime_userspace -->|"uses"| node_runtime_api
node_runtime_kernel -->|"hosts"| node_runtime_userspace
node_runtime_api -->|"mirrors"| node_common_proto
node_runtime_api -->|"uses"| node_common_config
node_common_proto -->|"binds"| node_registers_pipeline
node_hw_descriptions -->|"feeds"| node_registers_pipeline
node_registers_pipeline -->|"drives"| node_platform_emulator
node_registers_pipeline -->|"drives"| node_platform_fpga
node_platform_emulator -->|"runs on"| node_emulator
node_platform_fpga -->|"integrates"| node_hw_model
node_emulator -->|"implements"| node_hw_model
node_emulator -->|"exercises"| node_common_proto
node_host_tools -->|"uses"| node_common_proto
node_ocp_verifier -->|"verifies"| node_runtime_api
node_integration_tests -->|"drives"| node_emulator
node_integration_tests -->|"targets"| node_platform_fpga
node_fw_bundler -->|"packages"| node_common_config
node_xtask -->|"builds"| node_rom
node_xtask -->|"builds"| node_runtime_userspace
node_xtask -->|"generates"| node_registers_pipeline
node_xtask -->|"packages"| node_fw_bundler
node_xtask -->|"runs"| node_integration_tests

click node_rom "https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/rom"
click node_romtime "https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/romtime"
click node_runtime_kernel "https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/runtime/kernel"
click node_runtime_userspace "https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/runtime/userspace"
click node_runtime_api "https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/runtime/userspace/api"
click node_common_proto "https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/common"
click node_common_config "https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/common/config"
click node_provisioning "https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/provisioning/fuses"
click node_registers_pipeline "https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/registers"
click node_hw_descriptions "https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/hw"
click node_platform_emulator "https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/platforms/emulator"
click node_platform_fpga "https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/platforms/fpga"
click node_hw_model "https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/hw/model"
click node_emulator "https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/emulator"
click node_host_tools "https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/caliptra-util-host"
click node_ocp_verifier "https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/ocp-eat-verifier"
click node_integration_tests "https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/tests/integration"
click node_fw_bundler "https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/firmware-bundler"
click node_xtask "https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/xtask"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_rom,node_romtime,node_runtime_kernel,node_runtime_userspace,node_runtime_api toneBlue
class node_common_proto,node_common_config,node_provisioning toneAmber
class node_hw_model,node_emulator,node_host_tools,node_ocp_verifier,node_integration_tests toneMint
class node_registers_pipeline,node_hw_descriptions,node_platform_emulator,node_platform_fpga toneRose
class node_fw_bundler,node_xtask toneIndigo
```

## Components

### Firmware

MCU-side boot and runtime software stack

- [ROM](https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/rom): boot firmware · Immutable boot firmware handling boot, lifecycle, OTP, verification, recovery, and ownership transfer · `rom`
- [Romtime](https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/romtime): boot shared · Shared boot/runtime primitives for status and MCU/SoC coordination · `romtime`
- [Runtime Kernel](https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/runtime/kernel): tock kernel · Privileged board init, drivers, and capsules for hardware access and system services · `runtime/kernel`
- [Runtime Apps](https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/runtime/userspace): tock userspace · Unprivileged service apps implementing SPDM, firmware update, image loading, mailbox, and VDM workflows · `runtime/userspace`
- [Runtime APIs](https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/runtime/userspace/api): userspace libs · 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](https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/common): shared codecs · Reusable wire-format, transport, and protocol helpers shared across domains · `common`
- [Config & Images](https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/common/config): build artifacts · Boot configuration, flash image layout, and provisioning-related data models · `common/config`
- [Provisioning](https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/provisioning/fuses): fuse tooling · Fuse generation and provisioning support artifacts · `provisioning/fuses`

### Host & Emulator

Host tooling, emulator, and validation infrastructure

- [HW Model](https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/hw/model): model abstraction · Common abstraction for emulator and FPGA-backed model behavior in tests · `hw/model`
- [Emulator](https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/emulator): simulation · Hardware substitute modeling peripherals, ROM/runtime execution, and BMC-side flows · `emulator`
- [Host Tools](https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/caliptra-util-host): cli/bindings · Host-side mailbox and MCTP VDM utilities plus C bindings · `caliptra-util-host`
- [OCP Verifier](https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/ocp-eat-verifier): attestation verify · Verifier for OCP EAT and COSE/CORIM attestation artifacts · `ocp-eat-verifier`
- [Integration Tests](https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/tests/integration): end-to-end 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](https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/registers): rdl pipeline · SystemRDL parsing and code generation pipeline producing shared register crates · `registers`
- [HW Descriptions](https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/hw): rdl sources · Top-level hardware register definitions and FPGA support descriptions · `hw`
- [Emu Platform](https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/platforms/emulator): platform entrypoints · Emulator-specific ROM/runtime entry points and board wiring · `platforms/emulator`
- [FPGA Platform](https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/platforms/fpga): platform entrypoints · FPGA-specific ROM/runtime entry points, flash configuration, and board wiring · `platforms/fpga`

### Tooling

Build, packaging, and orchestration

- [Firmware Bundler](https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/firmware-bundler): packaging · Manifest, linker, and image bundling for firmware deployment artifacts · `firmware-bundler`
- [Xtask](https://github.com/chipsalliance/caliptra-mcu-sw/tree/main/xtask): orchestration · Central command layer for builds, generation, docs, emulator runs, and tests · `xtask`

## Connections

- 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
