Raspberry Pi real-time kernel SD image

RT-TestsLinux kernel has configuration options that affect it’s real-time capabilities. Default Raspbian kernel is compiled with CONFIG_PREEMPT option that allows all kernel code outside of spinlock-protected regions and interrupt handlers to be preempted by higher priority kernel threads. Real-time patch from Ingo Molnar adds CONFIG_PREEMPT_RT option that allows nearly all of the kernel code to be preempted, except for a few raw spinlock critical regions.

 

The histogram shows latency comparison between the default Raspbian kernel and the kernel with real-time patch.

We’ve used cyclictest program to obtain data with the following parameters:

cyclictest -l10000000 -m -n -a0 -t1 -p99 -i400 -h400 -q 

 

Latencies for default Raspbian kernel (PREEMPT) in uS: Min: 00014 Avg: 00028 Max: 01247

Latency results for PREEMPT_RT patched kernel in uS: Min: 00012  Avg: 00027 Max: 00077

 

The most important characteristic here is the max latency which indicates the longest time it might take your Raspberry Pi to respond to an event. As it can be observed PREEMPT_RT kernel provides much lower latency thus making it more suitable for usage in time-sensitive embedded systems. It is important to remember that to make full use of real time capabilities of the kernel it is necessary to do proper prioritizing.

 

You can compile PREEMPT_RT real time kernel for Raspberry Pi by yourself or you can download modified Raspbian SD card image that we prepared. The list of changes includes:

  • Added RT_PREEMPT kernel 3.10.25-rt23 (/boot/kernel-rt.img)
  • Copied kernel source patched with rt-patch in /usr/src/linux-3.10.25-rt23
  • Updated packages (2014-May-04)
  • Enabled SPI
  • Enabled I2C
  • Increased I2C speed to 400KHz
  • Installed I2C-tools
  • Installed rpi-serial-console (https://github.com/lurch/rpi-serial-console)
  • Installed socat
  • Performed localepurge
  • Removed wolfram-engine (to reinstall type “sudo apt-get install wolfram-engine“)

Download links: