Useful links for RT patching the kernel:
- https://wiki.linuxfoundation.org/realtime/documentation/start
- https://www.raspberrypi.com/documentation/computers/linux_kernel.html
Tested on kernel 6.1.77 and Raspberry OS Bookworm (link to exact version).
The linux/ contains a submodule with the kernel code already patched (even if it's quite easy to do yourself). You can pull the contents by cloning with --recurse-submodules --shallow-submodules (second option is there to avoid pulling the full kernel repo, which is big).
IMPORTANT: Configure full real-time capabilities with menu_config before compilation.
Cross compile the kernel following the indications in the second link.
After having built the kernel:
- Run the packing script from this directory:
./pack.sh. - Copy the installation archive via ssh:
scp .\rt-install.tar.gz <dest>:. - Ssh into your Raspberry Pi:
ssh <dest> - Backup your current kernel image:
sudo cp /boot/firmware/kernel8.img /boot/firmware/kernel8-$(date +"%Y%m%d_%H%M%S").img - Unpack the files
tar -xvf rt-install.tar.gz - Copy the nel kernel files:
sudo cp -r rt-install/* / - Append
dwc_otg.fiq_enable=0 dwc_otg.fiq_fsm_enable=0to/boot/firmware/cmdline.txt(see https://wiki.linuxfoundation.org/realtime/documentation/known_limitations) - Reboot:
sudo reboot
All in one script to run on ste RPi (DANGER!):
sudo cp /boot/firmware/kernel8.img /boot/firmware/kernel8-$(date +"%Y%m%d_%H%M%S").img && \
tar -xvf rt-install.tar.gz && sudo cp -r rt-install/* / && \
sudo sed -i 's/$/ dwc_otg.fiq_enable=0 dwc_otg.fiq_fsm_enable=0/' /boot/firmware/cmdline.txt