Skip to content
casxi-labPublic

About

The krepi operating system: a Rust microkernel for AArch64 on Raspberry Pi 5, with formal verification in Lean 4

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

krepi

krepi

krepi is the operating system of casξ, a portable workstation for mathematics, science and programming built on the Raspberry Pi 5. The name comes from κρηπίς, the stepped platform that a temple stands on.

krepi is a microkernel written in Rust for AArch64. The kernel runs at EL1 and keeps only the mechanisms that need privilege: memory protection, scheduling, communication between processes and interrupt delivery. Device drivers, file systems, program loaders and system policy run as ordinary processes at EL0, each in its own address space, and receive only the authority that the system grants them. Formal verification of the kernel is a primary goal of the project: kernel code is to be written against independent specifications and proved in Lean 4.

Status

The repository holds this README, the krepi logo, the contribution rules, the target architecture, the documentation conventions, empty proof registries, a commit-message hook and the build tooling: a pinned Rust toolchain, the kernel and user-space Cargo workspaces and the repository checks. The kernel workspace holds an empty ABI crate, the AArch64 processor primitives with the cold entry of an image, the exception vectors of EL1 and the cache and TLB maintenance of the executing CPU, and the QEMU virt board support with its PL011 serial console, its exception record, its default image, which boots on QEMU virt into EL1, writes its boot records and echoes its serial input, and test images that take exceptions at EL1 and report them and that exercise the cache and TLB maintenance; the user-space workspace holds an empty SDK crate. A host tooling crate for tests holds an ELF reader, report values, a serial port transport, a serial link, the serial capture behind cargo xtask serial-capture, the QEMU runner behind cargo xtask qemu, the QEMU boot suite behind cargo xtask qemu-boot and the parsers of serial records, and a test image that the checks boot with the runner. The kernel code and most of the tools are ported from the prototype, with their porting records. The proof tools are pinned by a manifest, a reviewed Aeneas patch and the recipe of a container image that CI builds and publishes (formal verification); no proof exists yet. Continuous integration runs the repository checks and the QEMU boot suite on every pull request to main and on every push to main.

The required host checks run from the repository root and need the tools that toolchains.toml lists for the host (testing):

cargo xtask check

Their formal step runs the test vectors in the pinned proof-tool image and needs a linux-aarch64 host with Docker and that image. On another host, record the step as not run and run its first part, the inventory check of the proof targets, on its own; CI runs the whole step:

cargo xtask check --skip-formal
cargo xtask formal check

The QEMU boot suite builds the default image and the test images, boots the default image three times and each test image once on QEMU virt; the default image can also be built in kernel/ and run with the QEMU runner, which records its serial output until the timeout:

cargo xtask qemu-boot
cd kernel
cargo build --locked --release --target aarch64-unknown-none-softfloat -p krepi-qemu-virt --bin krepi-qemu-virt
cd ..
cargo xtask qemu --timeout 5 kernel/target/aarch64-unknown-none-softfloat/release/krepi-qemu-virt

An earlier prototype of the system is kept read-only and is not public. It is the source for porting: boot code, board support, drivers, services and tests are taken from it module by module, as porting describes. A capability of the prototype becomes a capability of krepi only after it has been ported, tested and, where required, proved again in this repository.

Hardware

  • Raspberry Pi 5. The target board (BCM2712 with four Cortex-A76 cores).
  • QEMU virt with Cortex-A76. Generic mechanisms are validated here first. QEMU virt is a generic ARM64 machine with its own addresses, interrupt routing and boot conditions; a result on QEMU says nothing about the Pi 5.

krepi is designed around one system image per supported board that serves every product function. Product functions are never split into build-time variants of the image that exclude each other.

What krepi is for

krepi is the platform that the casξ applications run on: the computer algebra system, graphing, compound documents, Python programming and local Lean proof checking. The long-term target is a complete application platform with:

  • Rust std, C and C++ standard libraries, and the full Go standard library with its runtime;
  • POSIX and GNU interfaces, a general-purpose shell, dynamic linking with shared libraries and dlopen, and networking with TLS;
  • Linux system-call and binary compatibility for unmodified Linux programs;
  • the full CPython ecosystem, including the standard library, package installation and native extensions;
  • Lean and Lake, compiling and checking proofs on the device;
  • desktop application frameworks;
  • parallel execution on all four cores, with the controls of the device staying responsive under full load.

The kernel stays no_std. Compatibility layers and frameworks are user-space services and libraries.

On the verification side the target is a reproducible argument of functional correctness and security for a declared configuration of the privileged kernel, covering the Rust code, the necessary assembly and architecture paths, concurrency and the delivered binary. Every claim names its configuration and the trusted items it still relies on. See formal verification.

First release

The first release is planned to:

  • boot on QEMU virt and on the Raspberry Pi 5 straight into a resident root process, without waiting for serial input;
  • start the file, block, stream and UART services as separate EL0 processes;
  • run the casξ CAS calculator, built from a pinned commit of the CAS library, as a job over the serial console, with the same output bytes on a development host, on QEMU and on the Pi 5, and with a budget, cancellation, forced stop and reclamation of its resources;
  • run small Rust std, C and C++ programs built with the krepi SDK;
  • ship a default image without diagnostic commands or fault probes;
  • check proofs of the kernel object core, capabilities, IPC and waits, system-call dispatch and loader validation in CI, and publish a declaration of what is proved and which items are trusted.

None of this works yet.

Related repositories

Repository Role
casxi-lab/kalyx The CAS library
casxi-lab/kosmo The user interface and graphical shell

The CAS library runs on krepi as an ordinary user program; the UI runs on top of the system services. Neither is part of the kernel.

Documentation

Document Contents
Architecture Target design: protection domains, the resident root, objects and capabilities, IPC, scheduling, memory, multicore, devices
Security model Target design: threat model, security properties, rules for internal choices, observable outputs, permitted nondeterminism, integrity of loading, exec, packages and updates
Formal verification How proofs, specifications and registries are organized
Formal upgrade How the proof tools are upgraded, proofs repaired and canary verdicts triaged
Subject domains The complete target scope of the system, by subject
Feature index What the system provides
Documentation conventions Feature documents, domain and component documents
Testing Test layout, environments and evidence
Porting How code is taken from the prototype tree
SMP design rules How code classifies its state and shares it between CPUs
Provable Rust subset The constructs and design rules of the code that proofs are to cover
Contributing Rules for changes, commits and evidence

License

krepi is released under the MIT License. Copyright (c) 2026 The casξ Authors; see AUTHORS.

About

The krepi operating system: a Rust microkernel for AArch64 on Raspberry Pi 5, with formal verification in Lean 4

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages