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
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).
Is it possible to add the ability for more than 2 SPI devices. I require the use of 3 and was hoping to use an GPIO pin for the 3rd device CS pin.
Also will the python usage example at http://www.brianhensley.net/2012/02/python-controlling-spi-bus-on.html work with the Hardware SPI in your kernel.
I followed the instructions to install the kernel, but when installing it throws the following errors:
Hmm. There is a symbolic link /lib/modules/3.2.23-rpi1+/build
However, I can not read it: No such file or directory
Therefore, I am deleting /lib/modules/3.2.23-rpi1+/build
Hmm. The package shipped with a symbolic link /lib/modules/3.2.23-rpi1+/source
However, I can not read the target: No such file or directory
Therefore, I am deleting /lib/modules/3.2.23-rpi1+/source
And then, when I reboot it won’t! I copy the old kernel back (I made sure to take a backup first!) it works a treat. Any ideas on this one?
Im my case (after forced update) got similar warnings, but restart in in my case OK. Also startx OK. But when opening MIdori or taskmanager, system holds totally. If using only terminals on X,Â seems to be happy and stable
– “uname – a” reports 3.2.xx kernel version
– H/W latest (10.8.)
– “apt update” and “apt upgrade” did not help (done just in case)
First of all thanks for publishing you work to the community 🙂
I’m currently in the process of building a custom Rpi kernel to address an issue with an external hard-drive.
Maybe you could integrate this patch in you build? https://lkml.org/lkml/2011/11/22/666
Pingback: Raspberry Pi I2C How-To ã‚¬ã‚¤ãƒ‰ by @azarashi55 | GVC : Global Versatile Controller
It would great to be able to use USBIP from here:
I tried to compile with 3.1.9 kernel but it was impossible because of source missing issues.
I would be grateful if you could add the modules related to usbip to your kernels.
Thanks in advance.
I’d like to second that, I got my raspberry pi 10 days ago and try to get usbip running since… it is frustrating and I don’t know whart I’m doing wrong 🙁
Is it possible to add the sc16is7x2 serial driver (It’s a spi->2x uart IC).
Yes, but you wouldn’t be able to use it without recompiling the kernel anyway.
Thanks, recompiling shouldn’t be a problem.
I’m trying to install bootc via apt – but I get the error that /usr/bin/lsb_release is missing. I’m using Linux raspberrypi 3.1.9+ #1 PREEMPT Mon Jul 16 00:23:24 PDT 2012 armv6l GNU/Linux and
Aug 5 2012 16:23:39
Copyright (c) 2012 Broadcom
version 329495 (release)
Sorry I missed that the latest raspberrypi release 2012-07-15-wheezy-raspbian is armhf. So, I tried the dpkg –force-architecture as mentioned below – unfortunately, this bricked my rpi – let’s start again.
ist it ok to install this kernel with dpkg –force-architecture (otherwise it won’t install)
on the newest Raspbian distribution with ‘armhf’ Kernel?
I forced kernel change and now X freezes after opening e.g. task manager. If I open only terminal(s), system keeps running.
Also normal terminal use seem OK
Updated, upgraded just in case, checked that
HW 10.8.2012 revision, 3.2.xx kernel running.
Any ideas what went wrong?
I amhaving exactly the same issue. Whenever midori tries to open a website with an image, e.g. google it freezes X and I need to powercycle.
Just as a short notice for all of you using i2c or spi:
On the newest Raspian release the modules
are blacklisted in /etc/modprobe.d/raspi-blacklist.conf by default.
Took me half a day to find out…
Many thanks….was wondering why it wasn’t working!
Newbe alert !!
How does the blacklisting effect it – what installation/instruction changes are required?
Hi, I check out your kernel source, via git clone -b rpi-3.2.23 https://github.com/bootc/linux.git
and cp arch/arm/configs/bcmrpi_defconfig as my config file
run make command, the Image file created, but there is no any .ko file?
MODPOST show 0 modules….
what’s wrong am i?
Thank you very much!!
my crosschains tool worked, a hello_world.c can be compiled and run corretly in raspberry board
CC [M] drivers/usb/storage/initializers.o
CC [M] drivers/watchdog/bcm2708_wdog.o
LD [M] drivers/usb/host/dwc_otg/dwc_otg.o
CC [M] drivers/usb/storage/sierra_ms.o
CC [M] drivers/usb/storage/option_ms.o
CC [M] drivers/usb/storage/usual-tables.o
LD [M] drivers/usb/storage/usb-storage.o
Building modules, stage 2.
MODPOST 0 modules
Kernel: arch/arm/boot/Image is ready
Kernel: arch/arm/boot/zImage is ready
You build the modules? For example
make ARCH=arm modules_install INSTALL_MOD_PATH=/tmp/modules
Pingback: Wii Nunchuk + Raspberry Pi = ChukBerry |
Hi Chris, nice work!
i have (maybe a stupid) question: What is the rationale to have your kernel besides the “official rpi kernel”?
First, thanks for your work, it was very easy to get my hardware clock running!
Unfortunately, I have trobble using the Raspberry as a rs 232 logger. I get frequently errors like
ttyAMA0: 1 input overrun(s)
It happens only if I use the GPIO pins with a MAX3232 chip for 232, if I use an USB adapter I have no problems. Unfortunately, I cannot lower the baud rate (56700), so how can I fix that?
Would you like to add iSCSI support in the future kernels ?
It will help ones who want to use a pi as a iSCSI target host.
Pingback: neophob.com » Raspberry Pi: Enable the SPI device
I just upgraded to
Linux raspberrypi 3.2.27+ #24 PREEMPT Sun Aug 19 21:28:36 BST 2012 armv6l GNU/Linux
but I am not able to load rtc-ds1307.ko !!!
pi@raspberrypi ~ $ sudo insmod /lib/modules/3.2.23-rpi1+/kernel/drivers/rtc/rtc-ds1307.ko -f
Error: could not insert module /lib/modules/3.2.23-rpi1+/kernel/drivers/rtc/rtc-ds1307.ko: Invalid module format
Who can give a good advice?
Thank you, hgs
You’re trying to load a 3.2.23 module into a 3.2.27 kernel. That won’t work.
I thought something like this, but how can I compile a right module version? Sorry, I am a newbie!
I solved the problem myself.
There is a excelent instruction how to recompile the kernel given by nidO (http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=7306).
So I managed to build a 3.2.27 kernel and the 3.2.27 module rtc-ds1307.ko
Pingback: Enable I2C on your Rasberry Pi | Shady Goings On
I am trying to write short chunks of data (192 bytes) to the SPI repeatedly
I am using Python, my code goes this way:
spi = os.open(“/dev/spidev0.0”, os.O_RDWR)
The SPI clock is set to 2Mbit. Sometimes it throws timeout.
spidev spi0.0: transfer timed out
I have found in the sources the timeout is set to 150ms
I am not skilled enough to recompile the whole kernel.
Do you think it is possible to release your linux-headers-xxx package so I can try SPI module build with the different timeout?
If not, can you please compile module with the different timeout (say 200ms) for testing purposes?
Thanks and Best regards
Recompiling the kernel isn’t that hard really, but I’m not even sure that will help. At 2 Mbps one byte takes 0.5ÂµS to transfer, so ignoring other sources of delays you are looking at sending 300 Kbit in a single transaction before the timeout is hit – I don’t think you can even do that with the spidev interface. Is your Pi particularly busy when you are doing this? Try sending the data in smaller transactions – e.g. write to your socket then flush the output, then write some more.
Thank you for the hard work you put into the development and for sharing it with us.
I’m trying to build Kismet. It complains about mac80211/nl80211:
configure: WARNING: Missing libnl netlink library will not be able to control mac80211 vaps
libnl detected but no support for mac80211 your kernel is probably too old for mac80211 or nl80211 upgrade your kernel then reinstall the latest netlink to get mac80211 support.
Do you plan on adding nl80211 support to your kernel?
Pingback: » Raspberry Pi odczyt temperatury przez nodejs | Vokiel.com
What about adding the CAN driver family (mcp251x and others) together with the corresponding can protocol handler?
Also a means to “register” spi devices dynamically (without a reboot) would be appreciated (like the ones for I2C via /sys/bus/i2c/devices/i2c-X/new_device)
I’ve been trying to use SPI with 9 bits and have come up against a problem where the driver appears to be limited to 8 bits:
Is there any way that this can be changed to allow 8 – 16 bits as with spidev as using bit bashing is just too slow for it to be usable ??
No, the hardware can only perform 8-bit transfers. Perhaps you could still use spidev but manually shift the buffer along?
I have been thinking of ways to add the extra bit, which is simply a command / data bit that tells the device whether the byte is a command instruction or data.
But I have no experience with c and are using python py-spidev. bit bashing works, but is really slow.
One of the advantages of spidev is that I can sent an array of bytes, rather than byte by byte, that really speeds things up using writebytes([0xFF,0x00]) etc. If I was able to set or clear the DATA line and toggle the CLOCK prior to sending the 8 bits to spidev, then that would effectively add the additional control bit, but that would only work if I send one byte at a time, and that would slow things down tremendously.
I forgot to mention that this document appears to suggest that the SPI device supports up to 32 bits: http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf
Or have I misinterpreted it ??
It can send/receive 8 or 32 bits at a time, but nothing in between. Seems pointless to me as sending 4×8 bits is identical to sending 32 bits.
I believe the 32-bit mode is only mentioned because it is needed when using DMA, because DMA only does 32 Bit transfers, so the SPI device has to handle those correctly (probably it splits the DMA data up into 4 bytes internally).
But DMA mode still does transfer the right amount of data, as you have to configure a byte-count (up to 65535 (or 65536 – not sure which is true) bytes) that gets set to the SPI register when executing DMA (there is also information on SPI dividers that gets passed as well).
But for all practical purposes it is a 8 Bit device only.
There are cases where having transfer sizes other than 8-bits can be useful (or even necessary). This is especially true in cases where the target hardware requires that SS be de-asserted between words. I specifically had a problem with this on loading a DSP from a iMX35 part — and for loading the boot code the DSP defaults to 24-bit words and requires SS to de-assert between words but NOT between bytes in the word.
I would have to look at how the actual GPIO config for the SPI pins works on the BCM SOC in the RPi, but one potential solution if you absolutely HAVE to have 9-bit mode would be to do what we did. Change from using the hardware SPI drivers over to spi-bitbang and then modify spidev.c and spi-bitbang.c to add the 9-bit mode (which is what weI did to add 24-bit mode). The amount of code required is probably not much more than 10-20 lines — but it gets a bit weird in places as neither 9 or 24 bits native variable types exist, so expect to do quite a bit of bit masking and manual word assembly to make things work right.
Thanks, & sorrie for the delay, but I am already bit-bashing 9 bits and it’s way too slow, with a very tight loop, it is taking around 6 seconds to refresh a 130×130 pixel colour (nokia) screen, and that is just too slow to be workable.
The only way this display would be usable would be if I can do it all thru hardware and avoid bit-bashing, or am I misunderstanding what you’re proposing ??
I am really happy for the support that you are giving to many folks out there..
Can you please add the touch screen interface to this kernel.
I am looking for a driver for the “MXT540E”, MXT540E works on I2C and UART interface as PI has both of this hope we can interface the same with PI.
A driver code for the same is available in the below -“https://bitbucket.org/sarcastillo/redpillkernel/src/990eb0053acb/drivers/input/touchscreen/mxt540e.c”
It will be amazing if you can support the I2C interface as I2C is already part of the kernel.
I have the board for the MXT540E it requires SDL,SDA and CHG [indicated change or the event in the touch screen]. If we configure any of the GPIO of the PI as to read status of this [interrupt mode is good] then all things are set.
Chris PLZ do add this to the kernel.
I’d like to get a PCF2123 realtime clock (for SPI bus) working with my pi. I’m using latest raspberrypi 3.2.27+ kernel (pre-compiled from image) and it already includes spi_bcm2708 and rtc_pcf2123 modules. SPI seems to work (/dev entries appear), but loading the rtc driver doesn’t produce any output in dmesg.
You wrote something that it won’t work without recompiling. Can you give me instructions?
Can you please look at http://www.raspberrypi.org/phpBB3/viewtopic.php?f=44&t=19489 and evaluate if you can incorporate into the kernel?
It definitely improves SPI performance and reduces latencies.
Thanks a lot for your job! Using your description “how to build cross compiler” I have managed to build it on I386 box – Debian Squeeze. After some strange compilation errors I have successfully compile the great “Hello, world!” – I was really happy. Now I want to compile kernel for myself – I need module easycap.ko which is for a simple USB grabber – chip and easy to use. Unfortunately opposite of your precise description for building crosstools-ng I do not found detailed information here.
I’m using Debian Wheezy for now 3.2.27+ #244 PREEMPT
How and where can I get sources and configuration for this kernel?
What is the convenient place (such as your suggestion about /opt/cross) to place source tree?
I suppose that after these I can simply run make menuconfig and add my options for compilation. But what should look like the command for build?
Also, for better keeping I plan to use Debian kernel package system. Is there any difference for this against usual Debian procedure?
Would you be so kind explain, or figure out where I can find detailed descriptions for this task?
Thanks in advance!
Thank you for the great contribution!
I’m using your 3.2.23 kernel for everything, but for 1-wire bus I had to switch to Frank Buss’ 3.1.9+. When I try to insert w1-gpio.ko in your kernel I receive:
ERROR: could not insert ‘w1_gpio’: No such device
Could you add support for it?
I have some progress! Thank to you and Raspberry PI collective – I have used instructions for building kernel on ubuntu. The kernel source I’ve got from github.
I was some what confusing which kernel image to use, at last I’ve used uncompressed(?) image about 5 M bytes (size was the clue ).
First what I was mentioned that firmware was less then it was given with image 2012-09-18-wheezy-raspbian.zip.
What I have still do not know how to use debian kernal package system for this situation, I’ve seen several examples on the web but are those was not similar.
Also I have relized, that some task VCHIQka-0:27 blocked several time – kernel complain, even “original” kernel is do it 🙁
If you have some time please explain how to use Debian kernel package make system for this situation.
Thanks for your job and that you share it with us.
I’m looking distribution to Raspberry that allows me to run Oracles Embedded Java (requires soft-float) and Huawei E392 4G Dongle (requires qmi_wwan module). Is this possible with your distribution?
I would like to use my Cinergie DVB-C HTC HDTV stick with my raspberry. This stick is supported by Kernel > 3.5 or using media-build from linuxtv.org. I would be very happy, if you could creat a kernel including em28XX-driver.
Thank you very much.
Are you familiar with the rpi-3.6.y kernel fork over on github? Basically, do you know if it is working (video isn’t an issue for my purposes, I’m strictly needing serial or telnet access to my RPi for use as an embedded controller).
Also, do you know if their is a consolidated patch list that show the differences between the original Broadcom fork and the mainline kernel?
I’ve just spent the last month or so merging Phytec patches and BSP code to get 3.5.x and 3.6.x up and running on a PCM043-like Freescale iMX35 based platform and would like to do the same for my RPi (specifically so I don’t have to maintain different code bases for some of the device driver code I’m working on — without having to have a ton of #ifdef’s in the code).
I’d love it if vloopback modules came with the kernel:
used by the popular motion detection software Motion:
Which seems quite a popular use for the Pi
Keep up the good work!
I’m missing support for USB Printer Support (usblp.ko, mainline) since I’m using my Pi as a File- and Printserver. I recompiled the Kernel with support for now, but would appreciate a precompiled build in a future version.
Thank’s a lot!
I tried to use the I2C driver in Occidentalis v0.2.to control a PCF8591.
I can detect the device on 0x48 and can instantiating the device by echo pcf8591 0x48 > /sys/class/…/new_device. Afterwards I can see the input and output files. If I try to access these files only out0_enable works as expected, but there is alwys full output voltage independent of the conten of out0_output..
A test program written in C (http://sourceforge.net/projects/raspberrypisnip/files/Occidentalis%20v0.2/pcf8591.c) works correct, so I think the hardware is ok.
Do you have any idea what’s wrong?
I am struggling with communicating with a MLX90614 over the i2c bus.
It seems that the implementation of i2c_smbus_read_word_data(…) on the i2c_bcm2708 sends a stop bit after the “command byte” then a start bit and this seems to confuse the sensor. I have digged into the code and came to this function
bcm2708_i2c_master_xfer() in file i2c-bcm2708.c where it seems that after each read/write there is a call to bcm2708_bsc_reset().
Am I right to assume that this is the cause of the stop bit after the “command byte” ?
Is there a way to make the 2 operations part of the same SMbus transaction? to look like:
Hi Every one,
I am new bee to Linux as well as Raspberry Pi.
If I do buy MI0283QT-2 LCD from where I will arrange the driver software or do I need to compile the driver as described in the steps given above.
Anticipating for a quick response.
Pingback: How to:Raspberry Pi(Raspbian”Wheezy”)ç”¨ã«ã‚¯ãƒã‚¹ã‚³ãƒ³ãƒ‘ã‚¤ãƒ«ç’°å¢ƒã‚’æ§‹ç¯‰ã™ã‚‹ | é›»è„³ã‚ã–ã‚‰ã—ã®æ³³ãŽ Raspberry Pi åˆ¥é¤¨
I have a problem with i2c smbus, when i tried to read data it always gives me the same values (and incorrect values). For example I have MMA8452 accelerometer and I tried it with arduino mega, it works properly but whenever we try it on raspberry we failed. I checked the communicaion with a scope, we send the right thing but the answer is wrong.
we used your image, and the latest rasppberry image the result is the same.. What could be our problem??
Hi, could you please enable Display link module or built in in the next update?
Its in device drivers, graphics, framebuffer, display.
I’ve been trying to get the dlink dwa-160 rev. B2 usb-wifi adapter going, and after downloading the kernel sources on the pi and building a module it seems it won’t load. Perhaps you could add support for this device, please?
the following was sufficient to get it going under ubuntu.
I’m a lowly user space kind of guy, and am struggling with strange performance glitches on my synth project, where I appear to get swapped out for hundreds of microseconds at a time, despite my elevated priority, and am interested to try out an RT kernel to see if it will help – I like the Rasbian distribution that comes from the foundation and would like to stick with it.
So – in dumb user space words on one syllable – what do I need to do to simply drop in an RT kernel into the Rasbian distribution?
Hi – is this still alive? – I use common debootstrap with armhf and qemu to set up my basemin system. armel works fine. but where can I get a working kernel for armhf rpi? (i tought rpi-update would fetch the correct kernel.img architecture -> nope 🙂
Thanks for all your work I am trying (to learn and share -> embedded os optimizations) to create a comprehensive guide on minbase install “console-only server” rpi with all optimizations explained by command line (armhf, flashbench/fdisk aligned partitions, elevator=noop, sqashfs/aufs etc/) … so at the a custom (patched) kernel must be compiled. I am just searching for a default armhf kernel for testing purposes.
I wanted to try the linux-image-3.2.23-rpi1+_1_armel.deb.
The link seems to be broken. Can you pl restore access to the deb?
Thanks and Rgds,
I’ve just posted a note at the top of my page stating that you shouldn’t use my kernel any longer. Please use the official Raspbian kernels instead.
is there any build available that includes usblp kernel module?