Adding BTF Support to Raspberry Pi 4 and 5 Kernels
LiME requires a Linux kernel with BTF (BPF Type Format) information enabled. This guide focuses specifically on enabling BTF support when compiling a kernel for Raspberry Pi 4 and 5.
Overview
For complete kernel compilation instructions, please refer to the official documentation:
Raspberry Pi Linux Kernel Documentation
Follow that guide for setting up your build environment, obtaining the kernel source, and general compilation steps. This page only covers the additional steps needed for BTF support.
We recommend using Linux kernel 6.12 or newer, which includes mainline PREEMPT_RT support for real-time applications. To use kernel 6.12 specifically, clone the rpi-6.12.y
branch:
git clone --depth=1 --branch rpi-6.12.y https://github.com/raspberrypi/linux
cd linux
Enabling BTF Support
After running either make bcm2711_defconfig
(for Pi 4) or make bcm2712_defconfig
(for Pi 5) as described in the official documentation, you need to modify the kernel configuration:
- Enable DEBUG_INFO_BTF - After the defconfig step, modify the
.config
file:
# Option 1: Use menuconfig or nconfig (recommended)
make nconfig
# Navigate to: Kernel hacking → Compile-time checks and compiler options → Generate BTF typeinfo
# Enable "Generate BTF typeinfo"
# Option 2: Edit .config directly
sed -i 's/# CONFIG_DEBUG_INFO_BTF is not set/CONFIG_DEBUG_INFO_BTF=y/' .config
# Verify the change
grep CONFIG_DEBUG_INFO_BTF .config
# Should output: CONFIG_DEBUG_INFO_BTF=y
- Continue with the standard build process as described in the official Raspberry Pi documentation.
Verifying BTF Support
After booting your Raspberry Pi with the new kernel, verify that BTF support is enabled:
# Check for BTF-related symbols
cat /proc/kallsyms | grep btf
# Or verify with bpftool (if installed):
# If successful, this will create a vmlinux.h file with BTF type information
sudo bpftool btf dump file /sys/kernel/btf/vmlinux format c > ./vmlinux.h
If BTF is correctly enabled, you'll see BTF-related symbols or information in the output.
Next Steps
With BTF support enabled in your kernel, you can now install LiME and use it to analyze your real-time applications.