Skip to content

Latest commit

 

History

History
121 lines (80 loc) · 2.37 KB

File metadata and controls

121 lines (80 loc) · 2.37 KB

Kernel Build Process

1. Preparing the Environment

On a fresh Raspberry Pi OS install, run:

sudo apt update && sudo apt upgrade -y
sudo apt install git bc bison flex libssl-dev make -y
sudo apt install libncurses5-dev -y
sudo apt install raspberrypi-kernel-headers -y

mkdir ~/kernel && cd ~

2. Cloning the Kernel Source

Clone the official Raspberry Pi Linux repository:

git clone --depth 1 --branch rpi-6.15.y https://github.com/raspberrypi/linux
cd linux

✅ Starting with kernel 6.12, PREEMPT_RT is integrated for ARM64 — no external patches needed.


3. Kernel Configuration

  1. Load Raspberry Pi 5 defaults:

    make bcm2712_defconfig
  2. Open menuconfig:

    make menuconfig
  3. Enable the following key options:

    • General Setup → Preemption Model → Fully Preemptible Kernel (Real-Time)
    • Processor type and features → Timer frequency → 1000 Hz
    • CPU Frequency Default Governor → performance
    • Full dynticks system (CONFIG_NO_HZ_FULL=y)
    • NTP/PPS client GPIO support
  4. Disable debugging and power-saving governors to reduce jitter.


4. Building the Kernel

Compile natively on Raspberry Pi 5:

make prepare
make CFLAGS='-O3 -march=native' -j6 Image.gz modules dtbs
sudo make -j6 modules_install

Recommendation: Use 1.5 × number of CPU cores for -j (Pi 5 has 4 cores → -j6).


5. Deploying the Kernel

Step 1: Create RT kernel boot directories

sudo mkdir /boot/firmware/NTP
sudo mkdir /boot/firmware/NTP/overlays-NTP

Step 2: Copy kernel & device trees

sudo cp arch/arm64/boot/dts/broadcom/*.dtb /boot/firmware/NTP/
sudo cp arch/arm64/boot/dts/overlays/*.dtb* /boot/firmware/NTP/overlays-NTP/
sudo cp arch/arm64/boot/dts/overlays/README /boot/firmware/NTP/overlays-NTP/
sudo cp arch/arm64/boot/Image.gz /boot/firmware/kernel_2712-NTP.img

Step 3: Update boot configuration

Edit /boot/firmware/config.txt and add:

os_prefix=NTP/
overlay_prefix=overlays-NTP/
kernel=/kernel_2712-NTP.img

⚠️ This ensures the stock kernel remains intact for recovery.

Step 4: Reboot

sudo reboot now

6. Verifying the Kernel

After reboot, check:

uname -a

Expected output:

Linux raspberrypi 6.15.0-rc7-v8-16k-NTP+ #1 SMP PREEMPT_RT ...