Skip to content
tomkcook edited this page Jul 3, 2012 · 3 revisions

Note Well

Perhaps no-one else would be silly enough to try, but in case you do want to try, you should know that you can't build a Linux Kernel on a case-insensitive filesystem. You will get strange results if you try. That includes mounting a Windows NTFS filesystem onto a Linux system just because your NTFS partition has a lot more free space - which is what I tried.

Building a RasPI Real-Time Kernel

Here are some notes so far on how to build a RT-Preempt kernel for the Raspberry Pi. I'm building in an Ubuntu 12.04 x64 virtual machine. Note that it doesn't work yet!

You need to have the appropriate cross-compiler installed. On Ubuntu, that's:

apt-get install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi

(You don't need the g++ compiler for the kernel, but I want it for Other Things.) Then get the 3.2.20 Raspberry Pi kernel source from bootc's github:

git clone https://github.com/bootc/linux
cd linux
git checkout origin/rpi-3.2.20

This will all take some time. Then get the patch file and apply it:

wget http://www.kernel.org/pub/linux/kernel/projects/rt/3.2/older/patch-3.2.20-rt32.patch.bz2
bunzip2 patch-3.2.20-rt32.patch.bz2
patch -p1 < patch-3.2.20-rt32.patch.bz2

You will need a .config file. I got one by downloading a binary of bootc's kernel, running it on the pi and then copying /proc/config.gz. Once you've got one, copy it to .config in the kernel source. I've chosen to enable a few more options in mine:

  • CONFIG_NFS_FS - enable the NFS filesystem client
  • CONFIG_ROOT_NFS - allow the kernel to mount the root filesystem by NFS
  • CONFIG_IP_PNP_DHCP - allow the kernel to get a boot-time DHCP lease so it can access an NFS mount

As you've probably guessed, this is so that I can mount the root filesystem by NFS.

Then:

make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- INSTALL_MOD_PATH=/export/rpi bzImage modules
sudo make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- INSTALL_MOD_PATH=/export/rpi bzImage modules_install

To install the kernel on the RasPI, copy /export/rpi/lib/modules/* to /lib/modules on the RasPI, and copy arch/arm/boot/bzImage to /boot/kernel.img on the RasPI. Note that you need a recent version of the RasPI firmware to be able to boot this type of kernel image!

The problem so far is that the MMC/SD card is not detected by the kernel and so it can't mount the root filesystem. The idea of mounting the root by NFS is that it will allow the boot to finish so that I can investigate the SD card problems.

Clone this wiki locally