Repolode
sypstraw

sypstraw/rpi4-osdev

A step-by-step tutorial for writing a bare metal operating system that runs directly on the Raspberry Pi 4.

Stars
3,777
Forks
283
Open issues
0
Last commit
2 months ago

What is it?

This is a tutorial project for building a bare metal operating system on the Raspberry Pi 4. Bare metal means the code runs directly on the hardware without an existing OS underneath, so the author walks through the low-level steps a system normally handles at boot: starting the CPU, driving the display, and talking to attached hardware.

The guide covers the setup needed before writing code: a Raspberry Pi 4 with HDMI output, a micro-SD card booted with Raspbian to verify the hardware, and a cross-compiler for the Arm Cortex-A72 processor. It documents building with Arm's GCC toolchain on Linux or WSL, and with Clang/LLVM on macOS, as well as building directly on the Pi.

The tutorial is organized into parts, starting with bootstrapping, and is released under CC0 public-domain dedication. It credits code collated from and inspired by Zoltan Baldaszti's Raspberry Pi 3 bare metal tutorials.

Key features

  • 01Walks through booting and running custom code on Raspberry Pi 4 hardware.
  • 02Covers cross-compiling for the Arm Cortex-A72 with Arm GCC or Clang/LLVM.
  • 03Explains the setup steps, including preparing the SD card and serial debugging.
  • 04Organized as sequential parts, beginning with bootstrapping.
  • 05Released under CC0, so the material can be reused freely.

Use cases

  • Learning how computers boot and how an OS talks to hardware without relying on an existing OS.
  • Getting started with ARM64 bare metal programming on a Raspberry Pi.
  • Using the tutorial as a base for a custom hobby kernel on Raspberry Pi 4.

Quick start

  1. 1

    Install GNU make on Ubuntu/WSL

    sudo apt install make
  2. 2

    Install LLVM with Homebrew on macOS

    brew install llvm
  3. 3

    Download and unpack Arm's AArch64 ELF bare-metal gcc cross-compiler from the Arm GNU toolchain page

  4. 4

    Read the tutorial and continue to part1-bootstrapping

Things to know

  • Requires an RPi4 and extra hardware such as a serial TTL cable.
  • Tutorial targets Raspberry Pi 4 only and is not a general-purpose OS.

In collections

Topics

FAQ

What is rpi4-osdev?
A step-by-step tutorial for writing a bare metal operating system that runs directly on the Raspberry Pi 4. This is a tutorial project for building a bare metal operating system on the Raspberry Pi 4. Bare metal means the code runs directly on the hardware without an existing OS underneath, so the author walks through the low-level steps a system normally handles at boot: starting the CPU, driving the display, and talking to attached hardware.
Is rpi4-osdev free to use? What license does it have?
rpi4-osdev is open source under the CC0-1.0 license. Check the license terms before using it in commercial products.
Is rpi4-osdev still maintained?
Updated within 6 months. The last commit to rpi4-osdev was on Sep 3, 2026.
What can I use rpi4-osdev for?
Learning how computers boot and how an OS talks to hardware without relying on an existing OS. Getting started with ARM64 bare metal programming on a Raspberry Pi. Using the tutorial as a base for a custom hobby kernel on Raspberry Pi 4.
How do I install rpi4-osdev?
Install GNU make on Ubuntu/WSL: sudo apt install make Install LLVM with Homebrew on macOS: brew install llvm Download and unpack Arm's AArch64 ELF bare-metal gcc cross-compiler from the Arm GNU toolchain page Read the tutorial and continue to part1-bootstrapping
Where can I get rpi4-osdev?
The source code and installation instructions are on GitHub: https://github.com/sypstraw/rpi4-osdev

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects