01. Environment Setup for Raspberry Pi OS Development¶
Target Hardware
This tutorial series targets the Raspberry Pi 4 Model B (BCM2711, Cortex-A72, ARMv8-A 64-bit).
Before we start writing code, let's set up the development environment.
Installing the Cross-Compiler¶
Since we're developing on a PC/Mac for the Raspberry Pi's ARM64 architecture, we need a cross-compiler.
Verify the installation:
Installing Build Tools¶
We'll use CMake as our build system:
Setting Up the Project¶
Clone the os-rasp repository (or create your own):
Project Structure¶
Building the Kernel¶
If successful, you'll see:
The output file kernel8.img is what we'll deploy to the Raspberry Pi.
Understanding the Toolchain¶
CMake Toolchain File¶
Located at cmake/aarch64-none-elf.cmake, this file tells CMake how to cross-compile:
- Compiler:
aarch64-linux-gnu-gcc - Target: ARMv8-A (64-bit) Cortex-A72
- Flags:
-ffreestanding(no standard library),-nostdlib(no startup files)
Key Compiler Flags¶
-mcpu=cortex-a72+nosimd: Target the Raspberry Pi 4's CPU-ffreestanding: We're not using a hosted environment-nostdlib: Don't link against the standard C library
Next Steps¶
Now that your environment is ready, we'll dive into the boot process and write our first assembly code!