Raspberry Pi Kernel

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.

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

Why 3.2?

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.

Please see Issue #2 on the Raspberry Pi kernel tree on GitHub for a fright. Here’s a technical description of the issue, including an exploit (linked from the GitHub issue).

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).

271 thoughts on “Raspberry Pi Kernel

  1. Pingback: Chris's Digital Realm » Yet another new kernel – 3.2.19

  2. Pingback: Chris's Digital Realm » Slightly updated RPi kernel

  3. Pingback: Chris's Digital Realm » Another new RPi kernel (3.2.18)

  4. Pingback: Chris's Digital Realm » Updated Raspberry Pi Kernel

  5. Hi Chris,

    I’m glad you’ve started the Raspberry Pi Kernel 3.2 project page — it’s looks like hard work and (heavy) responsibility. Thanks.

    I’ve a question: will you accept and incorporate little patches for new devices? I’ve a little expansion board with a new NXP PCF8523 I2C RTC that hasn’t got a driver yet, and probably won’t be in upstream for many months. I’ve found a patch on lkml.org which wasn’t accepted yet (due to build errors by moderators), but I’ve updated it to make it work personally. I’ve also tried registering on the I2C device bus and it works at kernel boot phase.

    I can’t afford to replicate/mirror your build system: could your build system accept user-level (normal folks) patches, so that it can go into the Raspberry Pi-flavoured kernel?

  6. Pingback: Chris's Digital Realm » Why I won’t support a 3.1 kernel

  7. Hi Chris,

    Thanks for all your work on this.

    Would it be possible to add support for the BCM20702A0 as described here?:

    http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1026193.html

    Specifically I’m intersted in using this device:

    T: Bus=01 Lev=03 Prnt=04 Port=04 Cnt=02 Dev#= 8 Spd=12 MxCh= 0
    D: Ver= 2.00 Cls=ff(vend.) Sub=01 Prot=01 MxPS=64 #Cfgs= 1
    P: Vendor=0a5c ProdID=21e8 Rev=01.12
    S: Manufacturer=Broadcom Corp
    S: Product=BCM20702A0
    S: SerialNumber=000272D68FDB
    C: #Ifs= 4 Cfg#= 1 Atr=e0 MxPwr=0mA
    I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=01 Prot=01 Driver=(none)
    I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=(none)
    I: If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
    I: If#= 3 Alt= 0 #EPs= 0 Cls=fe(app. ) Sub=01 Prot=01 Driver=(none)

  8. Hi Chris,
    I tried to install your kernel twice already today and every time I do it, my RPi stops booting. And I ave no idea what’s going on, I thought I had done something wrong the first time. But now I’m sure I followed the instructions correctly but my Pi still doesn’t boot.
    It doesn’t do anything, just the pwr light comes on, but nothing else happens. I’m using your wheezy image and copied the kernel.img into the /mnt/boot/ directory.
    Any idea of how to find out, what I’m doing wrong or what the problem it?

    Thanks.

  9. I try to use the I2c device.
    My programs work under “Blackfin/uClinux” and “openrisc/Linux3.2”, but not in the RPI.

    I always use ioctl(file, I2C_RDWR, struct i2c_rdwr_ioctl_data msgset *);

    when I run i2cdetect, it find a device at any address, even though nothing is connected.
    All write commands are successful, and all read commands return the byte 0x00. But nothing is connected.

    • Hmm that’s not right, and I definitely don’t see the same behaviour as you. Are you using my pre-build kernels or one you have built yourself? What build / git revision are you using?

    • I just tried this again with my 3.2.19 r3 kernel. With nothing connected to the i2c header I get:

      raspberrypi bootc # i2cdetect 0
      WARNING! This program can confuse your I2C bus, cause data loss and worse!
      I will probe file /dev/i2c-0.
      I will probe address range 0x03-0x77.
      Continue? [Y/n] 
           0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
      00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
      10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
      20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
      30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
      40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
      50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
      60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
      70: -- -- -- -- -- -- -- --                         
      
  10. I am still getting sd/mmc errors with latest 3.2.19r3.

    I have tried bunch of different SD cards (kingston, sandisk, panasonic with different SD classes, sizes etc.) and found only one working card (Kingston microSDHC 8GB SDC4/8GB). With other cards kernel loads ok, but when init starts loading userspace I get:

    [ 69.111923] mmc0: Timeout waiting for hardware interrupt – cmd12.
    [ 69.126438] mmcblk0: error -110 sending stop command, original cmd response 0x900, card status 0x900
    [ 69.243410] mmc0: final write to SD card still running

    .. endlessly.

    Any ideas?

  11. root@raspberrypi ~ #i2cdetect 0
    WARNING! This program can confuse your I2C bus, cause data loss and worse!
    I will probe file /dev/i2c-0.
    I will probe address range 0x03-0x77.
    Continue? [Y/n]
    0 1 2 3 4 5 6 7 8 9 a b c d e f
    00: 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
    10: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
    20: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
    30: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
    40: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
    50: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
    60: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f
    70: 70 71 72 73 74 75 76 77

    hardware fault?

    I have a clock on SCL0
    I look at it closer tomorrow on a storage oscilloscope

  12. Pingback: Raspberry Pi PCF8563 Real Time Clock (RTC) | SusaNET

  13. Kirsch,
    In the past, I’ve found that if SDA is stuck low (HW fault: solder-bridge to GND or missing/broken pullup), it will give the i2cdetect result you’ve pasted. I hope this helps…

  14. Hi

    I’m also finding that this image causes my rpi to stop working. I’m updating the firmware as follows:

    sudo wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update && sudo chmod +x /usr/bin/rpi-update
    sudo rpi-update
    sudo reboot

    Then installing your kernel:

    wget http://www.bootc.net/raspberrypi/linux-image-3.2.19-rpi1+_3_armel.deb
    sudo dpkg -i linux-image-3.2.19-rpi1+_3_armel.deb
    sudo cp /boot/vmlinuz-3.2.19-rpi1+ /boot/kernel.img
    sudo reboot

    After this the rpi won’t start, only the power light comes on.

    Andy

    • The very latest firmware changes the SDHCI clock speed, and my kernel doesn’t account for that yet. This shouldn’t cause any issues as it just means the clock will be slower than what the kernel thinks, but your problem could be related to this. I’ll try to post a new kernel with the updated SDHCI code this weekend.

  15. I updated the firmware with rpi-update and then installed your kernel.
    After reboot I ran i2cdetect but got error: -bash: i2cdetect: command not found
    What am I doing wrong?

  16. Pingback: build your own basic Raspberry Pi Debian image | Hödlmosers' Hard- and SoftwareCuisine

  17. echo driver 0x48 > /sys/class/i2c-adapter/i2c-0/new_device
    might work fine for lots of i2c things, but not all. Particularly the gpio expanders tend to need some platform data before they’ll register, and of course they give the usual cryptic error message when they fail

  18. Thanks for all your cool work. I tried to run setup-repo.sh using the command you gave on http://apt.bootc.net/ but it says “Sorry, can’t find /usr/bin/lsb_release” (in red, nice touch!) I am basically using the official Debian image from the Raspberry Pi foundation which I downloaded a couple weeks ago and I do not have that file. I will download your Debian package and install it the other way.

  19. Latest version of kernel fixed my problem, thanks
    Andy

  20. Is there a pre-compiled version of omxplayer anywhere that works with this kernel ? The pre-compiled omxplayer that was posted on the pi forum works with the 3.1.9 kernel but not with this one. Unfortunately most of the error messages are hidden behind the video image and scroll away too quickly to read, but they look like kernel error messages.

  21. I can detect my device with:

    pi@raspberrypi:~$ sudo i2cdetect 0
    WARNING! This program can confuse your I2C bus, cause data loss and worse!
    I will probe file /dev/i2c-0.
    I will probe address range 0x03-0x77.
    Continue? [Y/n]
    0 1 2 3 4 5 6 7 8 9 a b c d e f
    00: — — — — — — — — — — — — —
    10: — — — — — — — — — — — — — — — —
    20: 20 — — — — — — — — — — — — — — —
    30: — — — — — — — — — — — — — — — —
    40: — — — — — — — — — — — — — — — —
    50: — — — — — — — — — — — — — — — —
    60: — — — — — — — — — — — — — — — —
    70: — — — — — — — —

    but when I try and use it I get “Input/output error” but there is nothing in /var/log/kern.log

    Any ideas what I’m doing wrong?

  22. Actually my problem might be an issue with my harware, I’ve just connected another i2c device and I can send it data without error.

  23. Hi chris
    hope you can help.

    Im trying to install this program USB Redirector for Linux

    http://www.incentivespro.com/downloads.html

    running latest debian for raspberry

    When tring to install i get the famus kernel error could somebody who knows linux help me so i could install this???
    kernel headers or kernel source not installed.

    i even tried your kernel but still got some errors
    but was asked if i wanted to try anyway so something in your kernel works for me!

    • What famous kernel error is this? I don’t really have enough details to know what’s going on at all. I suspect if it needs a module compiling for your kernel (I bet it will) then you’ll find your version of gcc doesn’t match what was used to build the kernel, and that the kernel headers are missing. In that case you’d need to rebuild your own kernel – on the Raspberry Pi (have fun with that)!

  24. I’ve put this kernel into Arch Arm installation and it doesn’t work. There is only loopback interface and no ethX. Any idea what’s wrong?

    • Sorry, not from the information you’ve given me. Did you use my precompiled kernel or did you build your own? Did you build the right modules and install them on your Pi?

  25. Right. Sorry for not saying that. 🙂 I’ve used your precompiled kernel. I’ve coppied kernel image from ./boot and firmware and modules from ./usr. I assume every RPi is the same so the kernel should work. 😀 It works for my friend but he has Debian on his RPi.

    • Does lsmod show any modules as being loaded at all? Can you modprobe something simple like evdev? Does dmesg tell you anything more about the situation? Does ifconfig -a show your interface under a different number?

  26. Geez, sorry to bug you. Silly me didn’t do depmod. 😡 Anyway thanks. 🙂

  27. Could you please include the modules for socketcan support and the related MCP251x.ko CAN driver in your kernel build?
    I have test hardware ready to verify a CANbus interface on the Raspberry through an MCP2515 CAN-SPI converter with additional level conversion.

    • I’ll happily include the modules in my next build. However I can’t find any reference to this socketcan you mentioned. Also, if it’s an SPI CAN chip then my pre-compiled kernel won’t be much help as you would have to edit the architecture source files to link the driver to the SPI bus – it’s not something you can do in userspace after the fact.

  28. Following on from GrahamC I also have the problem with omxplayer. I even recompiled it! See my other posting on the 3.2.20 thread (from that you can gather that the problem still exists in 3.2.20).

    • I suspect, that it’s something in the config. I had this selfsame problem with the pre-compiled kernel. So I cross-compiled my own from Chris’s source but using the 3.1.9 config from /opt. The omxplayer I had (compiled against 3.1.9+) worked fine after.

      • Interesting. Could you email me your .config (my email is at the bottom of my blog) so I can compare them?

  29. After installing the new kernel (3.2.20 r1 built on 2012-06-17) I can’t access the I2C interface anymore:
    sudo i2cdetect 0
    Error: Could not open file `/dev/i2c-0' or `/dev/i2c/0': No such file or directory

  30. Well I fixed it by running “modprobe i2c-dev” again. Didn’t know I had to do it again after updating the kernel.

  31. Pingback: Building a new kernel for the raspberry pi, including support for i2c, spi and working version of the driver rtl8192cu. at Dominique Gallot's weblog

  32. Hey Chris, sorry to take some of your time again!
    I’m trying to get DVB working, I don’t think the modules are included (I could be wrong, i’m not 100% sure how to tell)

    Anyway, trying to build v4l-dvb using instructions from here http://www.linuxtv.org/wiki/index.php/How_to_Obtain,_Build_and_Install_V4L-DVB_Device_Drivers

    Trying to get kernel-headers installed, when I do “make modules_prepare” I get (after mashing enter, I’m assuming none of the options need changing?):
    arm-unknown-linux-gnueabi-gcc: not found

    I also get the same error when building v4l-dvb:
    /bin/sh: 1: arm-unknown-linux-gnueabi-gcc: not found

    I’ve installed your apt and kernel-package

    Thanks,
    Liam.

    • Sorry, but you won’t be able to build additional modules for the kernel that way because I used a cross compiler – so that compiler isn’t available on the RPi. If you let me know what modules you actually need I can make sure I include them in the next build.

  33. Hi!

    I am wondering if I can use your kernel image 21+ together with armhf of raspberian. on a forum post so. stated that the kernels do not differ. what do you think?
    thank you!
    florian

    • Yes, you should be able to use my kernel without recompiling. You may have to force the installation of the package as the package says it’s for armel instead of armhf but it should definitely work with an armhf userspace.

  34. Hi Chris!

    Is the mceusb module included in this kernel img? If it’s not can you add it? There is so many people using xbmc that while the libcec it’s not compatible it would be nice to use an mceusb remote with lirc.

    Tks!

  35. Hi Chris,
    I’m wanting to interface a mcp2515 CAN controller to my RPi. I’ve tried building a kernel using the standard kernel sources etc and the mcp251x driver builds, but when I try to load it, it can’t find the SPI driver. So after googling around I found your pages and the native SPI Driver support etc.

    Could you please add the mcp251x driver and the slcan driver and any other useful looking CAN Networking related drivers and debugging tools into your next kernel build please?

    I’ve still not figured out where you define which GPIO pin the hardware interrupt from the mcp2515 chip should be connected to yet but you may know about shuch things.

    TIA

  36. Pingback: JavaCV on a Raspberry Pi | Jeremy Nicola

  37. Hi Chris,

    Could you please have a look at getting the drbd module in ?

    • Sorry but LOL, are you serious? DRBD on the Raspberry Pi? But sure, I’ll include it in my next kernel 🙂

  38. :)) Thank you very much – yes I am serious.

    I’m thinking in terms of using LXC and drbd to get all my essential internal services running on low power devices with automatic failover. Stateless or near stateless services like named and dhcpd are easy – services with a lot of state like the incoming mail server need shared filesystems – drbd is the only lightweight solution I know of.

    It’s about resilience not performance 🙂

  39. Hi Chris – any chance the DVB drivers can be enabled in future builds of your kernel? I’m wondering whether my DVB-T2 USB stick (using em28xx-dvb) will work. Appreciate the kernel builds!

      • Hi Chris – yes, but not the DVB drivers.

        CONFIG_VIDEO_EM28XX_DVB=m

        would be required along with

        CONFIG_DVB_CORE=m
        CONFIG_VIDEOBUF_DVB=m
        CONFIG_DVB_MAX_ADAPTERS=8
        CONFIG_DVB_DYNAMIC_MINORS=y
        CONFIG_DVB_CAPTURE_DRIVERS=y
        CONFIG_DVB_USB=m

        and possibly some more DVB options.

  40. Chris, I’ve built the 3.2.21 kernel and can see that SPI module is loaded properly:

    ————————-8 CS=00000000 CDIV=0200
    spi spi0.0: setup mode 0, 8 bits/w, 500000 Hz max –> 0
    bcm2708_spi bcm2708_spi.0: registered child spi0.0
    spi spi0.1: setup: cd 1: 500000 Hz, bpw 8, mode 0x0 -> CS=00000001 CDIV=0200
    spi spi0.1: setup mode 0, 8 bits/w, 500000 Hz max –> 0
    bcm2708_spi bcm2708_spi.0: registered child spi0.1
    bcm2708_spi bcm2708_spi.0: SPI Controller at 0x20204000 (irq 80)
    ————————-8<———————–

    but no /dev/spidev-0.x devices created. Am I missing something?

    Thanks!

  41. You said:-
    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.

    Well it just bricked my Pi. It seems that it does that now. The only solution I have found is the recommendation to delete the start.elf file and rename one of the other files. Sadly this does not work for me either.

    • Sorry, but writing the wrong files to your SD card does not brick your Raspberry Pi. Just write the correct firmware files to your SD card and your Pi will start working again.

  42. Pingback: New Revision of 3.2.21 | Chris's Digital Realm

  43. Chris, would it be possible for you to include the DRBD related drivers in your next version? I am experimenting with HA and it would make it easier for me than trying to get shared storage to work over iscsi or NFS.

    Thanks.

  44. Hi Chris, thanks a lot for enabling the DVB modules! I am closer but it looks like a bunch of tuner modules are still missing.

    CONFIG_MEDIA_TUNER_TDA18271

    is the one I’m after, but there are other CONFIG_MEDIA_TUNER_xxx modules turned off too according to /proc/config.gz.

    I’m not a Debian user by habit, so perhaps I’m doing something wrong; when I did a “dpkg -i” on the new linux-image, I got this error:

    dpkg: error processing linux-image-3.2.21-rpi1+_2_armel.deb (–install):
    unable to make backup link of `./boot/vmlinuz-3.2.21-rpi1+’ before installing new version: Operation not permitted
    dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)

    doing a “dpkg -r” and then a “dpkg -i” worked fine. Thanks a lot! Gareth

Comments are closed.