A simple hobby operating system for the Raspberry Pi 4 Model B which is based on the Broadcom BCM2711, a quad-core ARM Cortex-A72 (ARMv8) 64-bit System on Chip (SoC). This work-in-progress is meant to help me learn OS and Linux kernel/driver development.
My goals are to develop a simple operating system capable of the following functions:
- A simple Bash-like interface.
- A file system.
- Symmetric Multi-Processing utilizing all 4 ARM cores.
- Internet connectivity via the ethernet connector on the RPi.
- Basic web server functionality.
- A very much simplified Linux-like kernel.
I am using GitHub Actions to trigger builds when a change is pushed to the remote. However, I am also able to build locally. Instructions for obtaining the toolchain, installing it, and building with make
are included below.
My dev machine is x86_64 running Ubuntu Linux. The target is the ARM Cortex-A72 chip on the Rasberry Pi 4. Thus, the cross-compiler I am using (aarch64-none-elf
) is included in a toolchain by ARM which can be found here.
sudo apt update
sudo apt -y upgrade
sudo apt install curl
ARM_TOOLCHAIN_VERSION=$(curl -s https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads | grep -Po '<h4>Version \K.+(?=</h4>)')
curl -Lo aarch64-none-elf.tar.xz "https://developer.arm.com/-/media/Files/downloads/gnu/${ARM_TOOLCHAIN_VERSION}/binrel/arm-gnu-toolchain-${ARM_TOOLCHAIN_VERSION}-x86_64-aarch64-none-elf.tar.xz"
sudo mkdir /opt/gcc-arm
sudo tar xf aarch64-none-elf.tar.xz --strip-components=1 -C /opt/gcc-arm
echo 'export PATH=$PATH:/opt/gcc-arm/bin' | sudo tee -a /etc/profile.d/aarch64-none-elf.sh
Alternatively, I have seen others use a GNU-based cross-compiler developed and maintained by Ubuntu Core Developers, but I have not tried it.
sudo apt-get update
sudo apt-get install gcc-aarch64-linux-gnu
To build, run the following commands inside the root of the project.
source /etc/profile
make
The following resources were used to various capacities:
-
Tutorial by Sergey Matyukevich. He uses a Raspberry Pi 3 Model B (with BCM2837 SoC) but does a great job at comparing to how things are implemented in Linux.
-
Two tutorials by Rocky Pulley: one on writing a bare-metal OS for the Raspberry Pi, which extends Sergey's work, and one on OS dev using the Linux kernel.
-
Tutorial by Adam Greenwood-Byrne. Adam extends Sergey's work to the Raspberry Pi 4.
-
OSDev.org has a lot of content related to OS development including a section on writing a bare-metal OS for the Rasbperry Pi.
-
The Write your own Operating System YouTube channel.
-
I always recommend Miro Samek's embeded systems programming course to anyone interested in embedded development.
-
Andre Leiradella describes RPi stubs and the ARM boot protocol.
-
ANother RPi3 bare-metal OS tutorial by Zoltan Baldaszti.