Skip to content

emlid/linux-rt-rpi

 
 

Repository files navigation

Real-time kernel for Raspberry Pi

This repository holds a fork of Raspberry Pi Linux kernel patched with rt-patch and configured as a fully preemtible kernel. Instructions on compiling, setting up and testing the kernel are provided below.

Cross-compiling the rt kernel on Linux

Download Raspberry Pi tools:

git clone https://github.com/raspberrypi/tools.git

Download kernel sources and switch to rt branch:

git clone -b rpi-3.18.9-rt5 https://github.com/emlid/linux-rt-rpi.git
cd linux-rt-rpi

Export the following variables to specify cross-compilation options:

export ARCH=arm 
export CROSS_COMPILE=~/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-

If you compile on a x64-machine you need to change the last export to

export CROSS_COMPILE=~/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-

For Raspberry Pi:

make bcmrpi_rt_defconfig

For Raspberry Pi 2:

make bcm2709_rt_defconfig

Optional: make changes to the config

make menuconfig

Compile the kernel:

make -j5

Install modules, will result in "lib" folder with modules and firmware:

mkdir kernel-rt
INSTALL_MOD_PATH=kernel-rt make modules_install

Setting up an SD card with the compiled rt kernel

Copy kernel:

For Raspberry Pi:

Copy arch/arm/boot/Image to /boot/kernel.img on SD card.
Copy arch/arm/boot/dts/bcm2708-rpi-b.dtb to /boot/bcm2708-rpi-b.dtb on SD card
Copy arch/arm/boot/dts/bcm2708-rpi-b-plus.dtb to /boot/bcm2708-rpi-b-plus.dtb on SD card
Copy (merge if necessary) kernel-rt/lib to / on SD card.

For Raspberry Pi 2:

Copy arch/arm/boot/Image to /boot/kernel7.img on SD card.
Copy arch/arm/boot/dts/bcm2709-rpi-2-b.dtb to /boot/bcm2709-rpi-2-b.dtb on SD card
Copy (merge if necessary) kernel-rt/lib to / on SD card.

Now you can insert an SD card into your Raspberry Pi and check if it boots. If something is wrong it is recommended to observe serial console.

Testing real-time capabilites using cyclictest utility

Installing cyclictest utility on Raspberry Pi:

git clone git://git.kernel.org/pub/scm/linux/kernel/git/clrkwllms/rt-tests.git 
cd rt-tests
make all
cp ./cyclictest /usr/bin/
cd ~

Testing real-time:

sudo cyclictest -l1000000 -m -n -a0 -t1 -p99 -i400 -h400 -q

About

Real-time preemptible kernel for Raspberry Pi

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 96.6%
  • Assembly 2.0%
  • C++ 0.7%
  • Objective-C 0.3%
  • Makefile 0.3%
  • Perl 0.1%