How to update your Raspberry Pi Kernel and install Kernel Headers

Updating your Raspberry Pi to the latest kernel and installing the appropriate kernel headers gives you access to pre-release features. This tutorial will guide you through using rpi-update to update the kernel and rpi-source to install kernel headers.

Prerequisites
  • A Raspberry Pi running Raspberry Pi OS.
  • An internet connection.
  • Basic knowledge of using the terminal.

Step 1: Update Your System

Before proceeding with the kernel update, make sure your system is up to date. Open the terminal and execute the following commands:

sudo apt update
sudo apt full-upgrade

Step 2: Install rpi-update

rpi-update is a tool that fetches the latest experimental kernel available for the Raspberry Pi. This kernel is not thoroughly tested, so use it at your own risk, especially in production environments.

To install rpi-update, run:

sudo apt install rpi-update


Step 3: Update the Kernel

Now that rpi-update is installed, you can update the kernel. This will download and install the latest firmware and kernel. Execute the following command:

sudo rpi-update


Note: After updating the kernel, it's a good idea to reboot your Raspberry Pi to ensure that it uses the new kernel.

sudo reboot

Step 4: Install rpi-source to Fetch Kernel Headers

Kernel headers are needed if you plan to build modules or drivers. rpi-source is a tool that helps in fetching the source corresponding to the installed kernel.

Install rpi-source using the following commands:

sudo apt install git bc bison flex libssl-dev make libncurses5-dev
sudo wget https://raw.githubusercontent.com/jgartrel/rpi-source/master/rpi-source -O /usr/bin/rpi-source
sudo chmod +x /usr/bin/rpi-source
rpi-source --tag-update


Step 5: fetch the Kernel Headers

After installing rpi-source, run it to download and prepare the kernel headers:

rpi-source --default-config

This command fetches the kernel source and ensures that the kernel headers are correctly aligned with your currently running kernel.

Conclusion

You now have the latest kernel and the corresponding headers installed on your Raspberry Pi. This setup is ideal for developing hardware drivers, experimenting with new kernel features, or simply staying up-to-date with Raspberry Pi developments.

Back to blog