Sophon
A Raspberry Pi OS Kernel in Rust
Install / Use
/learn @wenyuzhao/SophonREADME
Sophon - A Raspberry Pi Kernel in Rust
An experimental modular-kernel written in Rust.
The name "Sophon" comes from the novel The Three-Body Problem.
Getting Started
Preparation
- Install rustup.
qemu-system-aarch64(optionallygdb-multiarchorlldbfor debugging).- For debugging: LLVM tools (
lldb,llvm-objcopyandllvm-objdump) - VSCode setup: install the rust-analyzer extension.
Run on QEMU
$ cargo dev run
Run on a Raspberry Pi 4B
Prepare UEFI and bootable USB (once)
- Prepare a USB drive with UEFI firmware.
- Plug the usb to your Raspberry Pi and connect to a HDMI monitor (or using UART0).
- Start Raspberry Pi and goto UEFI settings menu.
- Navigate to
Device Manager→Raspberry Pi Configuration→Advanced Settingsand enableACPI + Device tree
Install kernel
cd boot/uefimake deploy boot=/path/to/your/usb/directory- Plug the usb to your Raspberry Pi and connect a serial cable to UART0 ports properly.
- Use
screento connect to the serial device- e.g.
screen /dev/tty.usbserial 115200.
- e.g.
- Start Raspberry Pi
Design
The current plan is:
Make the kernel as simple and small as possible. Instead of following the micro-kernel approach that puts each kernel component as a isolated user process, Sophon tries to treat the components as kernel modules. This is expected to have higher performance than micro-kernels due to the absence of context switches and message passing overheads.
TODO
Boot
- [x] Make the kernel boot on AArch64 QEMU (UEFI)
- [x] Make the kernel boot on a real Raspberry Pi 4B (UEFI)
- [x] Setup EL1 virtual memory
- [x] Load kernel as relocatable ELF
- [x] Start kernel at Exception Level 1
- [ ] UEFI Network boot
- [ ] U-boot support
Kernel
- [x] Initialize drivers based on a device tree
- [x] Basic interrupt handler support
- [x] Kernel heap allocation
- [x] Timer interrupts
- [x] Scheduling / Context switch
- [x] Syscalls support
- [x]
Logsyscall (output to UART, for user process debugging) - [x] Kernel Modules
- [x] Module-defined syscalls (Module calls)
- [x] VFS module and Root-FS
- [ ] Memory management module;
mmapandmunmapsyscalls - [ ] File system modules like fat32
- [x] Process management module
- [x] Process and multi-threading
- [x] Driver interface based on modules
- [ ] SMP support
User Space
- [ ] Properly trap and handle Stack-overflow exception
- [x] Launch init process in privileged mode
- [x] Launch init process in user mode
- [x] TTY
- [ ] Update/release ref-counted pages after process exit
- [ ] Port gcc/libc/rustc
Architectures
- [x] AArch64
- [ ] X86_64
- [ ] X86
- [ ] ARMv6-M (RTOS)
Others
- [x] Unit / integration tests
- [x] Continuous integration (based on GitHub Actions)
References
- Raspberry Pi Bare Bones Rust - OSDev
- Mailbox Property Interface
- Bare Metal Raspberry Pi 3 Tutorials
- Bare Metal Raspberry Pi 3 Tutorials (Rust)
- Raspberry Pi Hardware Documents
- Learning OS dev using Linux kernel & Raspberry Pi
- ARM Quad-A7 Documentation (for timer configuration)
- Circle - A C++ bare metal programming env for RPi
- PanicOS - A simple x86 operating system with graphical user space
Related Skills
node-connect
343.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
90.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
343.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
