Bare metal runtime
Definition
A bare metal runtime is a lightweight software execution environment that executes directly on hardware without the mediation of a full operating system. In contrast to hosted environments that rely on a rich OS kernel with process isolation, virtualization, and security services, a bare-metal runtime supplies only the minimal infrastructure — basic system call interfaces, exception handlers, and device abstractions — needed to run application code on a target processor.
Role on constrained microcontrollers and SoCs
On ultra-low-power (ULP) microcontroller units (MCUs) and other resource-constrained SoCs, a full operating system is often impractical or impossible to deploy. These devices typically combine:
- Small on-chip main memories (commonly <1 MB),
- Microcontroller-class CPUs, and
- The absence of hardware virtualization or security features.
Because of these constraints, such platforms only support simple bare-metal runtimes rather than a Linux- or RTOS-class software stack. The runtime must be compact enough to fit in limited memory and must not depend on features (MMU-mediated isolation, supervisor/user separation, etc.) that the hardware does not provide. As a result, bare-metal runtimes on these targets are commonly used to host single workloads — for example, an ML inference loop, a DSP kernel, or a control task — that run to completion without preemption by an OS scheduler.
Nexus-AM: a reference implementation
Nexus-AM is a prominent example of a bare-metal runtime environment used in computer architecture research. It is described as:
- A bare metal runtime test generation environment,
- Light-weight and easy to use,
- Implementing basic system call interfaces and exception handlers,
- Supporting multiple ISAs and configurations.
In the XiangShan verification flow, Nexus-AM serves as the standard program loader and runtime for test workloads such as CoreMark. The build flow compiles workloads (e.g., make ARCH=riscv64-xs to produce coremark-riscv64-xs.bin/.elf) against the AM API, and the resulting binaries can be executed directly on the simulated hardware (via NEMU or the XiangShan RTL emulator) without requiring an OS image.
Typical use cases
Bare-metal runtimes such as Nexus-AM are used for:
- Functional verification — running real programs (CoreMark, micro-benchmarks, ML kernels) on an RTL or simulated processor to validate ISA-level correctness via co-simulation (e.g., Difftest against a reference simulator such as NEMU).
- Performance characterization — collecting execution traces and IPC metrics on isolated workloads without OS-induced noise.
- Bring-up and debug — providing a minimal, deterministic environment with full visibility into architectural state, which can be combined with snapshot tools (e.g., LightSSS) and structured waveform databases (e.g., ChiselDB).
- Embedded deployment on ULP MCUs that lack the resources for an OS, where the runtime, drivers, and application are statically linked into a single image.
Relationship to other layers
A bare-metal runtime occupies the middle of the software stack on a constrained device, sitting between raw hardware and the application:
Application workload
│
Bare-metal runtime (system calls, exception/interrupt handlers, device I/O stubs)
│
Hardware (CPU, memory, peripherals)
It contrasts with a hosted environment, where the application sits above an OS kernel that provides richer abstractions (processes, virtual memory, file systems, networking). On larger SoCs — such as heterogeneous RISC-V platforms that pair an application-class RV64 host core with an RV32 accelerator cluster — the host core may run Linux while the accelerator cluster executes its tasks under a bare-metal runtime, with the host and accelerator runtimes coexisting safely.
See also
- Nexus-AM — a concrete bare-metal runtime environment used in the XiangShan / NEMU ecosystem.
- NEMU — an instruction-set simulator frequently paired with a bare-metal runtime for verification.
- Difftest — ISA co-simulation framework that compares DUT and reference states while running bare-metal workloads.
- RISC-V — the ISA family on which many bare-metal runtime examples, including Nexus-AM's RISC-V configurations, are built.