Architecture
openprot is a no_std Rust firmware project for Platform Root-of-Trust
devices, organized as a Bazel module so that HAL traits, OS-abstraction
traits, OS-agnostic services, and target-specific glue can stay decoupled.
Repository layout
openprot/
├── MODULE.bazel # Bazel module + crate_universe extensions
├── workflows.json # Pigweed workflow groups (./pw …)
├── BUILD.bazel # Top-level Bazel package
├── openprot/ # Main application crate (lib.rs + main.rs)
├── hal/
│ ├── async/ # Async HAL trait crates
│ ├── blocking/ # Blocking HAL trait crates
│ └── nb/ # Non-blocking (nb) HAL trait crates
├── platform/
│ ├── traits/ # OS-abstraction traits
│ └── impls/ # Concrete impls per host environment
├── services/
│ ├── storage/ # OS-agnostic services on top of HAL + platform
│ └── telemetry/
├── target/
│ ├── earlgrey/ # OpenTitan Earl Grey target
│ └── veer/ # Caliptra VeeR-EL2 target (pw_kernel-based)
├── third_party/
│ ├── pigweed/ # Pigweed integration
│ └── caliptra/ # caliptra-sw / caliptra-mcu-sw integration
├── presubmit/ # Python presubmit scripts
└── docs/ # mdbook sources (this site)
The intent of the split is that anything touching hardware registers goes
through a hal/ trait, anything touching the host OS goes through a
platform/traits/ trait, and reusable logic lives in services/. Targets
under target/ provide the silicon-specific glue (linker scripts, ePMP
setup, console wiring, register definitions) without leaking those details
into the rest of the tree.
Build system
The build is driven by Bazel via Pigweed's workflow launcher; there is no Cargo workspace. The relevant pieces:
MODULE.bazeldeclares Bazel module dependencies (bazel_skylib,pigweed,platforms,rules_rust,rules_rust_mdbook,rules_python, pluscaliptra_depsanduregvia overrides).git_overridepins Pigweed to a specific upstream commit (MODULE.bazel:23-27), keeping the kernel/build/log/status/toolchain pieces reproducible.pw_rust.toolchainregisters Pigweed's managed Rust toolchains (MODULE.bazel:35-37); host C/C++ toolchains and therv32imcRISC-V C/C++ toolchain are registered viaregister_toolchains(MODULE.bazel:39-44).- Three
crate_universeworkspaces govern Rust crate dependencies:@rust_crates— cross-platform crates declared inthird_party/crates_io/Cargo.toml.@rust_caliptra_crates— embedded Caliptra crates (rv32imc, no std/alloc).@rust_caliptra_crates_host— Caliptra host tools (need std).
./pwisbazelisk run //:pw -- "$@"and dispatches to the named groups inworkflows.json(presubmit,default,ci,upstream_pigweed).
See usage.md for the everyday command surface and workflows.json for the
authoritative workflow definitions.
Pigweed integration
The veer target builds on Pigweed's microkernel and runtime crates:
@pigweed//pw_kernel— the microkernel running ontarget/veer/. Provides scheduling, IPC channels, interrupt objects, userspace isolation, and the#[entry]/#[process_entry]macros. System images are described declaratively insystem.json5files (seetarget/veer/for examples) and assembled by Pigweed'ssystem_image()macro.@pigweed//pw_log/rust:pw_log— structured logging used throughout userspace and target code.@pigweed//pw_status/rust:pw_status—Result<T, pw_status::Error>is the syscall and IPC return type.@pigweed//pw_toolchain/riscv_clang:riscv_clang_cc_toolchain_rv32imc— RISC-V C/C++ toolchain used by the veer target's mixed-language build.
For a concrete cross-process example, see design/pw-kernel-ipc.md and
target/veer/ipc/.
Targets
Each silicon/SoC target lives under target/<name>/ and provides its own
linker script, entry point, defs.bzl helpers, register definitions, and
test/runner tooling.
target/earlgrey/— OpenTitan Earl Grey. Verilator-driven tests are gated behind theverilatortag and only run via theearlgrey_verilator_testsbuild (seeworkflows.json).target/veer/— Caliptra VeeR-EL2. Built onpw_kerneland exercised on the Caliptra emulator viatarget/veer/tooling/caliptra_runner.bzl.
When adding a new target, prefer the target/<name>/defs.bzl helpers over
hand-rolled rust_binary rules, and always set target_compatible_with = TARGET_COMPATIBLE_WITH so wildcard host builds skip target-only crates.
Third-party integration
third_party/pigweed/— local Pigweed integration including avisibility.patch.third_party/caliptra/— integration withcaliptra-swandcaliptra-mcu-sw. Version bumps go throughuprev.py, which writes bothversions.bzl(commit pins) and the CaliptraCargo.lockfiles.third_party/crates_io/— pinned crates.io dependencies for the main workspace;third_party/caliptra/crates_io/{embedded,host}/for the two Caliptra crate hubs.
Where to read next
coding-style.md— formatter configs and Rust conventions.contributing.mdanddevelopment-process.md— review and merge process.design/— focused notes on individual subsystems (e.g. pw_kernel IPC).