This README describes necessary steps to build and install RT_PREEMPT Linux kernel for the Raspberry Pi board. RT Kernel is a part of the ROS2 real-time system setup.
git clone https://github.com/ros-realtime/linux-real-time-kernel-builder
cd linux-real-time-kernel-builder./download.shThis script will:
- Find the latest raspi kernel release for your specified version
- Download the kernel buildinfo package (contains the kernel config)
- Download the appropriate RT patch
- Clone the kernel source from Launchpad
Optional: Specify kernel version and RT patch:
./download.sh 6.8.0 6.8.2-rt11docker build -t rtwg-image .sudo docker run -it -v "$PWD/linux_build":/linux_build rtwg-image bashInside the container:
cd /linux_build/linux-raspi
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LOCALVERSION=-raspi -j $(nproc) bindeb-pkgThe build produces .deb packages in /linux_build/:
ls -la /linux_build/*.debCopy them to your host:
# From another terminal on the host
docker cp <container_id>:/linux_build/*.deb .Or directly to your Raspberry Pi:
scp /linux_build/*.deb user@<raspberry_pi_ip>:/home/user/linux-real-time-kernel-builder/
├── download.sh # Downloads kernel source, RT patch, and config locally
├── Dockerfile # Docker build configuration
├── .config-fragment # RT kernel configuration options
├── getpatch.sh # Helper script to find matching RT patches
└── downloads/ # Created by download.sh
├── linux-raspi/ # Kernel source
├── patch-*.patch # RT patch
├── config-* # Kernel config
├── uname_r # Kernel release version
└── rt_patch # RT patch version
The RT kernel is configured with options from .config-fragment:
CONFIG_PREEMPT_RT=y- Full RT preemptionCONFIG_NO_HZ_FULL=y- Full tickless operationCONFIG_HZ_1000=y- 1000Hz timer frequencyCONFIG_HIGH_RES_TIMERS=y- High resolution timersCONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y- Performance CPU governor
-
Copy the
.debpackages to your Raspberry Pi -
Install the packages:
sudo dpkg -i linux-image-*.deb linux-headers-*.deb- Reboot:
sudo reboot- Verify the RT kernel is running:
uname -a
# Should show PREEMPT_RT in the outputThe Launchpad git server can be unreliable. The script will retry 3 times automatically. If it still fails:
- Try again later
- Use a VPN or different network
- Clone manually:
git clone --filter=blob:none -b master --single-branch \
https://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux-raspi/+git/noble \
downloads/linux-raspiThe RT patch version must be close to the kernel version. If you see patch failures:
- Check available RT patches at https://cdn.kernel.org/pub/linux/kernel/projects/rt/
- Specify a compatible RT patch version:
./download.sh 6.8.0 6.8.2-rt11Make sure you've run ./download.sh first and all files exist in downloads/.
Pre-built RT kernel packages are available from GitHub Actions:
- Go to the
Actionstab - Find
Build stableworkflow - Download the artifacts from the latest successful run
See LICENSE file.