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 ~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.
-
Load Raspberry Pi 5 defaults:
make bcm2712_defconfig
-
Open menuconfig:
make menuconfig
-
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
-
Disable debugging and power-saving governors to reduce jitter.
Compile natively on Raspberry Pi 5:
make prepare
make CFLAGS='-O3 -march=native' -j6 Image.gz modules dtbs
sudo make -j6 modules_installRecommendation: Use 1.5 × number of CPU cores for -j (Pi 5 has 4 cores → -j6).
sudo mkdir /boot/firmware/NTP
sudo mkdir /boot/firmware/NTP/overlays-NTPsudo 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.imgEdit /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.
sudo reboot nowAfter reboot, check:
uname -aExpected output:
Linux raspberrypi 6.15.0-rc7-v8-16k-NTP+ #1 SMP PREEMPT_RT ...