Skip to content

A simple operating system for the Raspberry Pi 4 Model B

Notifications You must be signed in to change notification settings

markCwatson/rpi-os

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C/C++ CI

rpi-os

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.

Goals

My goals are to develop a simple operating system capable of the following functions:

  1. A simple Bash-like interface.
  2. A file system.
  3. Symmetric Multi-Processing utilizing all 4 ARM cores.
  4. Internet connectivity via the ethernet connector on the RPi.
  5. Basic web server functionality.
  6. A very much simplified Linux-like kernel.

Building

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.

Installing Toolchain

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 

Invoke Make

To build, run the following commands inside the root of the project.

source /etc/profile

make

References

The following resources were used to various capacities:

  1. 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.

  2. 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.

  3. Tutorial by Adam Greenwood-Byrne. Adam extends Sergey's work to the Raspberry Pi 4.

  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.

  5. ARM's offical documentation.

  6. The ARMv8 architecture ref manual.

  7. BCM2711 documentation.

  8. The Write your own Operating System YouTube channel.

  9. I always recommend Miro Samek's embeded systems programming course to anyone interested in embedded development.

  10. Andre Leiradella describes RPi stubs and the ARM boot protocol.

  11. ANother RPi3 bare-metal OS tutorial by Zoltan Baldaszti.

About

A simple operating system for the Raspberry Pi 4 Model B

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published