Home

Awesome

Caliptra MCU firmware and software

Building

Install rustup to manage your Rust toolchain:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

(You may need to open a new shell or source $HOME/.cargo/env.)

Do a full clone of the repository

git clone --recursive https://github.com/chipsalliance/caliptra-mcu-sw.git

Now you should be able to run all checks and builds:

cargo xtask precheckin

Commands such as cargo b and cargo t will also work, but won't execute the extra tests and RISC-V firmware builds.

Documentation

Directory structure

Runtime layout

The runtime (or "firmware") uses Tock as the kernel. Any RISC-V code that needs to run in M-mode, e.g., low-level drivers, should run in the Tock board or a capsule loaded by the board.

In Tock, the "board" is the code that runs that does all of the hardware initialization and starts the Tock kernel. The Tock board is essentially a custom a kernel for each SoC.

The applications are higher-level RISC-V code that only interact with the rest of the world through Tock system calls. For instance, an app might be responsible for running a PLDM flow and uses a Tock capsule to interact with the MCTP stack to communicate with the rest of the SoC.

The Tock kernel allows us to run multiple applications at the same time.

Each app and board will be buildable through xtask, which will produce ELF, TAB, or raw binaries, as needed.

runtime/ directory layout

Policies

#!/bin/sh
cargo xtask precheckin

Generating Registers from RDL files

You can run the registers RDL to Rust autogenerator as an xtask:

cargo xtask registers-autogen

By default, this generates Rust register files from the pre-defined RDL files contained in the hw/ directory.

If you only want to check the output, you can use --check.

cargo xtask registers-autogen --check

Quickly checking new RDL files

For testing and quick development, can also run additional RDL files directly with the command-line flags. For example, if you want to use the RDL device.rdl (which defines a type devtype) and mount it to the memory location 0x90000000, you can do so with:

cargo xtask registers-autogen --files device.rdl --addrmap devtype@0x90000000

The Autogenerated Root Bus

The register autogenerator generates several pieces of code for each peripheral (corresponding to an RDL instance present in the addrmap):

Development

When implementing a new emulator peripheral and firmware driver, the workflow will typically be: