IMPORTANT: You should no longer be using my kernels. The official kernels shipped with Raspbian now include versions of my I2C and SPI drivers and are much newer. I am also no longer involved in Raspberry Pi development. The rest of the page is being kept for historical reasons only.
As I have been posting so often about kernels for the Raspberry Pi I thought I had best create a central page on my blog that people can link to and always get the latest version.
Table of Contents
Latest 3.2 Kernel (NO LONGER AVAILABLE)
You shouldn’t be using 3.2 any longer. Please use more up to date kernels. See the note at the top of the page.
Note that the source is still available on GitHub if you really want to use it, but you’ll have to build your own kernels.
Recent change history:
- 3.2.23 r1
- Imported 3.2.22 and 3.2.23 kernel patches; enabled some more modules by request; imported some extra patches from the official kernel; compiled with Linaro GCC 2012.04 (thanks to crosstool-ng); fixed a minor sched_clock warning that looked nastier than it was.
- 3.2.21 r2
- Applied GPIO interrupts patch and some other patches from the official Raspberry Pi kernel; enabled DVB (oops, sorry, this was meant to be there before) and some further V4L modules; added DRBD module.
- 3.2.21 r1
- Imported 3.2.21 kernel patch; imported some extra patches from the official kernel including for the ALSA audio driver.
- 3.2.20 r1
- Imported 3.2.20 kernel patch; imported latest SDHCI performance tweaks; enabled easycap driver.
- 3.2.19 r3
- Added a bunch of wireless drivers from the kernel’s staging directory, including r8712u.
- 3.2.19 r2
- Added a bunch of GSPCA webcam drivers. (not publicly released)
- 3.2.19 r1
- Imported 3.2.19 kernel patch; reverted a bad SDHCI patch that has been causing issues; added a bunch of USB webcam drivers. (not publicly released)
How to install
First, make sure you have got recent firmware on your SD card. The firmware that comes with the official images is not recent enough. You can get the latest firmware from the Raspberry Pi Foundation GitHub, or see the post about Hexxeh’s easy updater tool. The firmware update is safe and painless and cannot brick your Pi.
Download the package to your Raspberry Pi and run the following commands as root:
dpkg -i linux-image-3.2.23-rpi1+_1_armel.deb cp /boot/vmlinuz-3.2.23-rpi1+ /boot/kernel.img
Then reboot. You should be all set.
Note that you should change the version numbers in the above commands to reflect the version of the .deb file you downloaded. Also, if you’re using my own Debian Wheezy based image, you’ll want to put the kernel at /mnt/boot/kernel.img instead.
Using SPI or I2C
The kernel above includes my SPI and I2C drivers for Raspberry Pi.
The SPI driver exposes two device files (/dev/spidev-0.0 and /dev/spidev-0.1), one for each cable select line (CE0 and CE1 on RPi). Look in the /usr/include/linux/spi/spidev.h header for how to drive this properly. There are also Python bindings available and I’m sure there are others available for other languages too. If you want to bind a kernel SPI device driver to an SPI chipselect line, you’ll have to edit the source and build your own kernel. Sorry, but that’s how it works in 3.2.
The I2C driver creates a Linux I2C bus just as any other I2C bus driver would. To use it from userspace you’ll want to load the i2c-dev module and play with /dev/i2c-0. If you want to use kernel I2C device drivers you can bind them from userspace without a rebuild, e.g.:
echo tmp102 0x48 > /sys/class/i2c-adapter/i2c-0/new_device echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device
One of the reasons I’m really pushing at a 3.2 kernel for the base image of the Raspberry Pi (until we get the architecture code rewritten for a mainline merge, another effort I’m part of) is that 3.1 is no longer an actively supported branch of the kernel and has some nasty security issues, whereas 3.2 is actively supported as it is the basis of Ubuntu 12.04 LTS (Precise Pangolin) and will be the kernel used in Debian Wheezy as well.
If a module isn’t included
If there is a kernel module you would like to use but isn’t included in the above download, let me know. If it’s in the mainline 3.2 kernel and builds cleanly, I’d be more than happy to included it in a future build of my kernel. Just let me know in the comments below or by email.
Building your own modules
If a module isn’t part of the standard kernel tree or you can’t wait for me to build a new image, you may be tempted to build your own modules and use them with the package above. Don’t. It won’t work. You won’t have the same compiler as me and the resulting files will most likely not even load into the kernel. You’ll need to rebuild the entire kernel with the same compiler for this to work.
Rebuilding the kernel from source
I won’t write a big “kernel building for Raspberry Pi” how-to as plenty of folks have done something similar. I will, however, point to my post on how to build a cross compiler that works for the Raspberry Pi.
If you’re curious about how I build the Debian package, look into a package called kernel-package within which you will find make-kpkg. Note that if you’re wanting to do this on Debian Wheezy you need a modified version of kernel-package available in my apt repository (with source).