LugalOS is a bare-metal, capability-isolated microkernel operating system built for RISC-V microcontrollers and 64-bit workstations. Inspired by the minimalism of Plan 9 and the interactivity of classic Lisp machines, LugalOS combines hardware-enforced memory domains, copy-always message channels, an exact Computer Algebra System (CAS), on-device C11 compilation (chibicc), a U-mode MicroPython v1.24.1 runtime (mpy), SSH-2/Git clients, and a horizontal tiling window ribbon.
- Capability-Enforced Microkernel Core: Preemptive multitasking with hardware-enforced per-task memory domains--Physical Memory Protection (PMP) on NOMMU microcontrollers, Sv39 page tables on RV64--strictly confining drivers and user programs.
- Driver Tasks Confined to PMP Windows: UART, native USB CDC dual-ACM, SD/SPI block storage, I2C bus controllers, TFT canvas, and TM1638 drivers each run as separate U-mode tasks. A fault in one driver cannot corrupt the kernel or another driver.
-
Dual-Core & 4-Core SMP Acceleration: Runs a shared preemptive scheduler across RP2350 (2x Hazard3), ESP32-P4 (2x RV32), and StarFive VisionFive 2 (4x U74 RV64GC). The chess engine achieves a 1.96x speedup on move generation (
perft) and 1.60x on Lazy SMP alpha-beta search. -
Exact Symbolic Computer Algebra System (CAS): Complete symbolic mathematics in pure Lisp without floating-point instructions: arbitrary-precision bignums, exact rationals
$\mathbb{Q}$ , Gaussian rationals$\mathbb{Q}(i)$ , polynomial factorization, symbolic calculus, and power series. -
MicroPython v1.24.1 (
mpy/python): Isolated U-mode Python runtime using software 32-bit floating-point (-mabi=ilp32/lp64),uasyncio,urequests(TLS 1.3 HTTPS verified against an 82-root CA store),mip, and nativelugal.sensor,lugal.canvas,lugal.ui,machine, andsocketbindings. -
Plan 9 IPC, 9P2000 & SSH-2/Git: Copy-always channels (
chan_t) as the core IPC primitive. Serves and consumes 9P2000 filesystems over USB CDC-ACM, SLIP, TCP, and WebSockets (tools/p9sync.py), plus nativessh,ssh-keygen, andgitover HTTP(S) and SSH. -
On-Device C11 Compilation & Binary Execution: Native
chibiccC11 compiler generates RISC-V ELF binaries directly on the microcontroller or workstation, executed as confined U-mode tasks. -
Zero Floating-Point in Kernel / M-Mode: Boot code enforces
mstatus.FS = 0. Kernel math, sensor scaling, and graphical coordinates use pure fixed-point or exact integer math (with soft-float isolated to U-modempy.elf). -
Zero SRAM Builtin Footprint: Symbols, primitives, and standard library catalogs reside in Flash
.rodatatables sorted for$O(\log N)$ binary search, keeping SRAM free for applications.
| Preset Name | Architecture | SoC / Board | Clock | RAM & Cache | Display & UI | Storage & Net | Role |
|---|---|---|---|---|---|---|---|
visionfive2 |
RV64GC (4x U74) | StarFive VisionFive 2 v1.3B | 1.5 GHz | 8 GiB LPDDR4 (Sv39 MMU) | 1920x1080 HDMI (DC8200) | M.2 NVMe, SDIO1, GbE, xHCI USB 3 | 64-bit Desktop Workstation |
rp2350-terminal |
RV32 Hazard3 | Waveshare RP2350-LCD-7 | 150 MHz | 520 KB SRAM + 8 MB PSRAM | 7" 800x480 RGB LCD, GT911 Touch | SD/SPI, Dual CDC USB | Workstation Terminal |
esp32p4-lcd7b |
RV32 Dual-Core | ESP32-P4-WIFI6-LCD-7B (rev v3.2) | 400 MHz | 768 KB L2MEM + 32 MB PSRAM | 7" 1024x600 MIPI-DSI, GT911 Touch | SDMMC, USB Host, Wi-Fi 6 | High-Perf Ribbon Workstation |
esp32p4-tab5 |
RV32 Dual-Core | M5Stack Tab5 (rev v1.3) | 360-400 MHz | 768 KB L2MEM + 32 MB PSRAM | 5" 720x1280 MIPI-DSI, ST7121 Touch | SDMMC, USB Host, Dual Expander | 5" Portable Tablet / Reader |
esp32p4 |
RV32 Dual-Core | ESP32-P4-NANO (rev v1.3) | 360-400 MHz | 768 KB L2MEM + 32 MB PSRAM | Serial Console (921600 baud) | RMII Ethernet, SDMMC | Microkernel Compute Node |
esp32c6 |
RV32IMAC | Waveshare ESP32-C6-Zero | 160 MHz | 512 KB SRAM, 8 MB Flash | Serial / JTAG Console | 802.11ax Wi-Fi, Flashfs | Low-Power Wireless Node |
rp2350-chess |
RV32 Hazard3 | Raspberry Pi Pico 2 | 150 MHz | 520 KB SRAM | 1.8" ST7735 TFT, TM1638 Keypad | SD/SPI card | Dedicated Chess Computer |
rp2350-clock |
RV32 Hazard3 | Waveshare Pico-Clock-Green | 150 MHz | 520 KB SRAM | SM16106 LED Matrix | DCF77 Radio, RTC | Precision Network Time Node |
rp2350-gateway |
RV32 Hazard3 | Raspberry Pi Pico 2 | 150 MHz | 520 KB SRAM | Serial Console | ENC28J60 Ethernet, USB 9P | Network Gateway Node |
rp2350-wifi |
RV32 Hazard3 | Raspberry Pi Pico 2 W | 150 MHz | 520 KB SRAM | Serial Console | CYW43439 Wi-Fi (802.11n) | Wireless IoT Node |
rv32 |
RV32 NOMMU | QEMU virt machine |
Emulated | 128 MB RAM | VirtIO Console | VirtIO Blk, VirtIO Net | 32-bit Microkernel CI Target |
rv64 |
RV64 Sv39 MMU | QEMU virt machine |
Emulated | 128 MB RAM | VirtIO Console | VirtIO Blk, VirtIO Net | 64-bit Virtual Memory Target |
rv64-smp |
RV64 SMP | QEMU virt (2 harts) |
Emulated | 128 MB RAM | VirtIO Console | VirtIO Blk, VirtIO Net | Multicore SMP CI Target |
This guide takes you from a clean checkout to an interactive LugalOS shell in QEMU or on physical hardware. For detailed configuration and reference material, see the Documentation Portal below.
- Toolchains:
riscv32-unknown-elf-gccorriscv64-unknown-elf-gcc - Build Tools:
cmake,ninja, Python 3.11+ (withuv) - Virtualization:
qemu-system-riscv32,qemu-system-riscv64
# Configure and build the 64-bit virtual memory target
cmake --preset rv64
ninja -C build/rv64
# Run a quick smoke group (e.g. Python, shell, CAS)
python3 tests/quick.py --target rv64 python
# Launch interactive QEMU shell
ninja -C build/rv64 runOnce at the lsh> prompt, try:
lsh> uname
lsh> (simplify '(diff (* x (sin x)) x))
lsh> python -c print(1+2,1/2)
lsh> man shell
# StarFive VisionFive 2 (RV64GC workstation via U-Boot YMODEM / SD)
ninja -C build/visionfive2
./tools/vf2run.py --kernel build/visionfive2 --save-sd --cmd "uname; df"
# Waveshare RP2350 7" Terminal
ninja -C build/rp2350-terminal
picotool load -f build/rp2350-terminal/lugalos.uf2 -x
# Waveshare ESP32-P4 7" Touch Terminal
ninja -C build/esp32p4-lcd7b
python3 tools/p4flash.py --board lcd7b --build build/esp32p4-lcd7b --only boot,os --verify
# M5Stack Tab5 5" Portable Tablet
ninja -C build/esp32p4-tab5
python3 tools/p4flash.py --board tab5 --build build/esp32p4-tab5 --only boot,os --verify+------------------------------------------------------------------------+
| USER SPACE APPLICATIONS |
| lsh (Shell) * Lisp REPL / CAS * e / ed (Editors) * Chess |
| chibicc (C Compiler) * User ELFs (Confined PMP / Sv39 Domains) |
\-----------------------------------+------------------------------------+
| System Calls (Pointer Validation)
+-----------------------------------v------------------------------------+
| ISOLATED U-MODE DRIVER DOMAINS |
| UART0 Console * USB CDC ACM * SD/SPI Storage * I2C RTC |
| ST7735 TFT * TM1638 Keypad * LCD Scanout DMA * Ethernet |
\-----------------------------------+------------------------------------+
| Copy-Always Message Channels
+-----------------------------------v------------------------------------+
| LUGALOS MICROKERNEL CORE |
| Preemptive / Priority Scheduler * Cross-Hart SMP Lock Hand-off (amoswap)|
| Physical Page Allocator (palloc)* Bulk PSRAM Zone * VFS / DevFS |
| Tokenized Dictionary Logger * PMP / Sv39 Hardware Memory Manager |
\------------------------------------------------------------------------+
LugalOS maintains structured documentation under doc/, split between task-oriented user/admin guides and in-depth technical references:
- About LugalOS: Architectural overview, hardware specifications, and system concepts.
- User Manual:
- Shell & Command Environment
- Text Editors: Full-Screen & Line Editors
- Window Ribbon & Terminal System and The Launcher
- LugalOS Chess Computer
- Computer Algebra System (CAS)
- Environmental Sensors & MQTT Telemetry
- Ribbon Reader & Typographic Viewer and Spartan / Gemtext
- SSH-2 & Git Clients
- MicroPython (
mpy/python)
- Administrator Manual:
- System Programmer Manual:
- On-Device C Programming & Syscalls
- Lisp Dialect, Primitives & Scripting
- Python Scripting &
lugal.*API Reference - Microkernel Architecture & Memory Domains
- Scheduler & SMP Multicore Locking and Concurrency
- Tokenized Kernel Logging Macro System
- Confined Driver Framework and UI Framework
- Board Bringup & Porting Guide
- Testing Guide & QA Framework and Making a Release
- Architecture Decision Records (ADRs):
- Context, decisions, and trade-offs behind core design choices.
- Agent & Developer Guide (
AGENTS.md):- Strict rules, coding standards, hardware TTY mappings, and invariants for AI agents.
This project was implemented with the help of AI agents:
- Anthropic Claude Code (mostly Opus 5.5)
- Google Antigravity (mostly Gemini 3.8 Flash, Gemini 4.0 Hydrogen)
- Pi (Qwen3.8 Flash Next)
LugalOS is licensed under the MIT License.
Copyright (c) 2026 Dominik Schloesser and LugalOS Contributors.





