How to update the kernel and the firmware for Raspberry PI

Once I have decided to write a kernel-mode application for my Raspberry Pi. I have found some sketches and a makefile. But I’ve got an error: Linux headers are missing. I spent some time solving this problem. Here you will find my solution for this problem.


You will need Internet connection and a terminal window (or PuTTY/WinSCP).
I recommend to use Win32DiskImager to make a backup-file of your OS located on SD card.

If your Raspberry PI uses small SD-card ( < 4GB) you can get the "out of free space" error. Try to delete temporary files and unused downloaded package files (.deb files) in "/var/cache/apt/archives". You can remove these in order to free up space with:

sudo apt-get clean

The official documentation says that there are two steps to upgrading. First, run UPDATE in order to synchronize the database of available software packages and the versions available. Second, run UPGRADE which will cause any packages with newer versions available to be updated. This can take more than an hour!

sudo apt-get update
sudo apt-get upgrade

Doing this regularly will keep your installation up to date and it will be equivalent to the latest released image.

The kernel and firmware are installed as a Debian package. These packages are updated infrequently. If you want to try more recent experimental software, it’s also easy to update to the latest available version using RPI-UPDATE and try the latest firmware. A REBOOT is needed after that. The firmware update is safe and painless.

sudo rpi-update
sudo reboot 

Some earlier releases of Raspbian OS didn’t have rpi-update installed by default. So we should install it:

sudo apt-get install rpi-update

To get the Raspbian metapackage Linux kernel with corresponding linux-headers do the following:

sudo apt-get install linux-image-rpi-rpfv

My version number is 3.12-1, it was updated in 2015. You should find your version number and ensure that the kernel filename is correct. Edit “/boot/config.txt” file and append at the end of this file command to boot new kernel:

initramfs initrd.img-3.12-1-rpi followkernel

Now you can reboot your Raspberry PI to test the new kernel and check it version with

uname -a

At last you can download Linux headers for your new kernel:

sudo apt-get install linux-headers-rpi-rpfv
apt-get install linux-headers-rpi

P.S. Some kernel-builds does not include support for SPI, I2C e.t.c.

Useful commands:

uname -a
find / |grep spi
modprobe spidev
sudo nano /etc/modprobe.d/raspi-blacklist.conf
sudo service ssh start
sudo shutdown -h now

To set the root password:
sudo passwd root

Interesting links:
Raspberry Pi: Enable the SPI device
How to get the Raspbian kernel installed with headers

This entry was posted in Firmware, Unix, Linux, FreeBSD and tagged , , . Bookmark the permalink.

Leave a Reply