Cross compiling Raspberry Pi prempt RT kernel

I would like to try a PREMPT_RT kernel on my Raspberry Pi. The download from emlid is no longer available. So, I thought about trying to cross-compile one from this source:

I have never compiled a linux kernel before. I have three options:

  1. do it on the Pi (seems slow)
  2. use my Ubuntu desktop (should be fine)
  3. use my Mac laptop (easiest for me maybe)

Any recommendations on how I should proceed? How do I get up and running with as little pain as possible?




You can download RT_PREEMPT image here.

Ryan, if you still would like to compile the kernel yourself cross-compiling on Ubuntu would be the easiest option. Instructions are provided in README.MD in the repository.

The download link for the image is broken.

I think I successfully built the kernel on my Ubuntu machine. The only real issue is that it is running 64 bit Ubuntu 14.04LTS and I had to get the CROSS_COMPILE pointing to the right executables.

The RPi boots of the SD card and I see PREMPT RT in uname -a. My only concern is that I am seeing this at boot up:

[ 6.206975] pcm512x 1-004d: Failed to reset device: -5
[ 6.224200] pcm512x: probe of 1-004d failed with error -5
[ 6.242909] pcm512x 1-004c: Failed to reset device: -5
[ 6.261353] pcm512x: probe of 1-004c failed with error -5

Is that important?

I can run the cyclictest and generate a histogram with a max latency of 96 micro seconds. That is cool. The only problem is that my regular kernel had a maximum of 120 micro seconds, so I am not seeing as much improvement as I was hoping for.

No, the pcm512x error is not important, it’s not rt-related.

Sorry for the broken link in the docs, it’ll be updated.

The results in microseconds may vary depending on how you run tests (number of cycles, priority, other parameters), but rt preempt kernel is noticeably better in terms of max latency. Here’s one of the test histograms of default kernel vs rt kernel:

Just updated the broken link, sorry for the inconvenience.

I am not able to boot from the supplied image. The RPi green LED gives one somewhat long flash and then nothing else happens and nothing prints to the screen. I am using a macbook air to flash the card using the command:

sudo dd bs=1m if=Emlid-Raspbian-RT-FEB-2015.img of=/dev/rdisk1

This command leads to fine results with the default raspbian image and a backup image I created of my other card (just wheezy with other packages installed).

Can it also be built on a mac OS X or just on Ubuntu?

@Al_B in theory it is possible to compile Linux kernels on Mac, but practically there are a lot of troubles with it, better stick to Linux.

What do the instructions mean with “merge if necessary”? Does it mean “overwrite if necessary”?

The instructions also only ask to copy a few files so does this mean that the SD card already contains a previous RT image? Otherwise, if the SD card is empty, what about the /overlays directory?

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.

lib should have a separate subfolder for the compiled version, so usually it shouldn’t overwrite anything, just a subfolder.

Why isn’t there a /lib folder in the original image download from the emlid website?

There is. But when you compile your custom kernel you need to compile and copy modules for it as well (that are in the lib folder).

But why I don’t see the /lib folder listed when I install the Emlid image in the SD card?

You’re looking at FAT partition with the kernel and device tree blobs. Root file system (including the lib folder) is located on another EXT partition.