Skip to content

zrthxn/pios

Repository files navigation

pios kernel

A barebones operating system kernel which should (at the very least) be able to give you a terminal and file handling on a Armv8 (AArch64) based SBC. For this, I'm using the Raspberry Pi 3b+.

Why? Just for fun. I like being this close to hardware and its a huge challenge programming with Rust without a standard library and writing safe code.

Goals

I want this to be able to

  • Run on real hardware
  • Connect to serial UART via USB
  • Be loaded dynamically for dev
  • Keep track of time
  • Display some text on a monitor
  • Take text input via keyboard
  • Run some binaries by giving unix like commands
  • Basic handling of files

Development

I'm using cross-compiling support provided by rustc to build this on a x86_64 system and then run it on a ARM AArch64 device (BCM2837).

Setup

Dockerization for build tools was not set up for this because it was not a priority right now. I do have a script that can sort of do the required setup.

  1. Install build tools (aarch64-gcc toolchain) from Arm website
    chmod +x ./setup.sh
    sudo ./setup.sh
  2. Install Make. I assume you'll know how to do this on your system.
  3. Install Rust and cargo nightly. Also install the aarch64-unknown-none-softfloat target
    rustup +nightly target add aarch64-unknown-none-softfloat

If there are problems, Rust will tell you what to do.

Building and running

If you have a RPi3 then this can be tested on that. Load the contents of the loader directory onto a partition in your microSD card called boot. Be sure to use this exact name. Then connect to USB serial via a breakout board to pins 14 and 15, details here.

Then run

make push

Alternatively, If you have QEMU then this can be tested on that for now. Just run

make qemu

Acknowledgements

A huge thanks to Andre Richter for providing this excellent tutorial series which is the foundation of this little project. Thanks to the teams at Rust Embedded and Tock who build some great libraries for this use. Also a GIANT thanks to Jake Sandler for his excellent tutorial blog where he documents so many things which are just nowhere else on the internet