{"id":20128904,"url":"https://github.com/wenyuzhao/sophon","last_synced_at":"2025-04-09T15:51:21.605Z","repository":{"id":43519621,"uuid":"218913082","full_name":"wenyuzhao/Sophon","owner":"wenyuzhao","description":"A Raspberry Pi OS Kernel in Rust","archived":false,"fork":false,"pushed_at":"2022-09-11T05:55:41.000Z","size":5454,"stargazers_count":30,"open_issues_count":7,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-02T05:32:12.304Z","etag":null,"topics":["aarch64","arm","armv8","bare-metal","kernel","operating-system","os","osdev","qemu","raspberry-pi","rpi4","rust-lang","uefi"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wenyuzhao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-01T04:26:42.000Z","updated_at":"2024-04-06T15:46:56.000Z","dependencies_parsed_at":"2023-01-18T03:30:31.383Z","dependency_job_id":null,"html_url":"https://github.com/wenyuzhao/Sophon","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenyuzhao%2FSophon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenyuzhao%2FSophon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenyuzhao%2FSophon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenyuzhao%2FSophon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wenyuzhao","download_url":"https://codeload.github.com/wenyuzhao/Sophon/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248063954,"owners_count":21041854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aarch64","arm","armv8","bare-metal","kernel","operating-system","os","osdev","qemu","raspberry-pi","rpi4","rust-lang","uefi"],"created_at":"2024-11-13T20:30:22.631Z","updated_at":"2025-04-09T15:51:21.589Z","avatar_url":"https://github.com/wenyuzhao.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **Sophon** - A Raspberry Pi Kernel in Rust\n\nAn experimental _modular_-kernel written in Rust.\n\nThe name \"Sophon\" comes from the novel [_The Three-Body Problem_](https://en.wikipedia.org/wiki/The_Three-Body_Problem_(novel)).\n\n# Getting Started\n\n## Preparation\n\n\n1. Install [rustup](https://rustup.rs/).\n2. `qemu-system-aarch64` (optionally `gdb-multiarch` or `lldb` for debugging).\n3. For debugging: LLVM tools (`lldb`, `llvm-objcopy` and `llvm-objdump`)\n4. VSCode setup: install the [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=matklad.rust-analyzer) extension.\n\n\n## Run on QEMU\n\n```console\n$ cargo dev run\n```\n\n## Run on a Raspberry Pi 4B\n\n#### Prepare UEFI and bootable USB (once)\n\n1. Prepare a USB drive with [UEFI firmware](https://github.com/pftf/RPi4).\n2. Plug the usb to your Raspberry Pi and connect to a HDMI monitor (or using UART0).\n3. Start Raspberry Pi and goto UEFI settings menu.\n4. Navigate to `Device Manager` → `Raspberry Pi Configuration` → `Advanced Settings` and enable `ACPI + Device tree`\n\n#### Install kernel\n\n1. `cd boot/uefi`\n2. `make deploy boot=/path/to/your/usb/directory`\n3. Plug the usb to your Raspberry Pi and connect a serial cable to UART0 ports properly.\n4. Use `screen` to connect to the serial device\n   - e.g. `screen /dev/tty.usbserial 115200`.\n5. Start Raspberry Pi\n\n# Design\n\n_The current plan is:_\n\nMake 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.\n\n# TODO\n\n### Boot\n\n- [x] Make the kernel boot on AArch64 QEMU (UEFI)\n- [x] Make the kernel boot on a real Raspberry Pi 4B (UEFI)\n- [x] Setup EL1 virtual memory\n- [x] Load kernel as relocatable ELF\n- [x] Start kernel at Exception Level 1\n- [ ] UEFI Network boot\n- [ ] U-boot support\n\n### Kernel\n\n- [x] Initialize drivers based on a device tree\n- [x] Basic interrupt handler support\n- [x] Kernel heap allocation\n- [x] Timer interrupts\n- [x] Scheduling / Context switch\n- [x] Syscalls support\n- [x] `Log` syscall (output to *UART*, for user process debugging)\n- [x] Kernel Modules\n- [x] Module-defined syscalls (_Module calls_)\n- [x] VFS module and Root-FS\n- [ ] Memory management module; `mmap` and `munmap` syscalls\n- [ ] File system modules like fat32\n- [x] Process management module\n- [x] Process and multi-threading\n- [x] Driver interface based on modules\n- [ ] SMP support\n\n### User Space\n\n- [ ] Properly trap and handle Stack-overflow exception\n- [x] Launch init process in privileged mode\n- [x] Launch init process in user mode\n- [x] TTY\n- [ ] Update/release ref-counted pages after process exit\n- [ ] Port gcc/libc/rustc\n\n### Architectures\n\n- [x] AArch64\n- [ ] X86_64\n- [ ] X86\n- [ ] ARMv6-M (RTOS)\n\n### Others\n\n- [x] Unit / integration tests\n- [x] Continuous integration (based on GitHub Actions)\n\n# References\n\n1. [Raspberry Pi Bare Bones Rust - OSDev](https://wiki.osdev.org/Raspberry_Pi_Bare_Bones_Rust)\n2. [Mailbox Property Interface](https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface)\n3. [Bare Metal Raspberry Pi 3 Tutorials](https://github.com/bztsrc/raspi3-tutorial)\n4. [Bare Metal Raspberry Pi 3 Tutorials (Rust)](https://github.com/rust-embedded/rust-raspi3-OS-tutorials)\n5. [Raspberry Pi Hardware Documents](https://github.com/raspberrypi/documentation/tree/master/hardware/raspberrypi)\n6. [Learning OS dev using Linux kernel \u0026 Raspberry Pi](https://github.com/s-matyukevich/raspberry-pi-os)\n7. [ARM Quad-A7 Documentation (for timer configuration)](https://github.com/raspberrypi/documentation/blob/master/hardware/raspberrypi/bcm2836/QA7_rev3.4.pdf)\n8. [Circle - A C++ bare metal programming env for RPi](https://github.com/rsta2/circle)\n9. [PanicOS - A simple x86 operating system with graphical user space](https://github.com/JasonBrave/PanicOS)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwenyuzhao%2Fsophon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwenyuzhao%2Fsophon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwenyuzhao%2Fsophon/lists"}