How to Install Specific Version of Linux Header in a Raspberry Pi
Hi, this post is a follow-up to another post, where I needed a specific version of Linux header.
Read that post here, How to Configure a Raspberry Pi as an OpenFlow Switch: Steps, Issues, and Solutions
If we search for linux headers using the following command:
$ apt search linux-headers
we see, there is nothing less than
5.10+ version. However, I wanted to install version 4.9.
In this post, I will go through the steps to install a specific linux header in a Raspberry Pi.
- Download the source code for the kernel version you want to install. You can find the source code at https://github.com/raspberrypi/linux. You need to select
4.9from the branch and then download zip file.
Extract the source code to the
$ sudo cp linux-rpi-4.9.y-stable.zip /usr/src/ $ cd /usr/src/
$ sudo unzip linux-rpi-4.9.y-stable.zip
- Change to the extracted source code directory
$ cd linux-rpi-4.9.y-stable/
bcmxxxx_deconfigversion, check the
$ ls arch/arm/configs/
$ sudo make bcm2709_defconfig
- Next we need to create
$ sudo make clean $ sudo make mrproper $ sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig $ sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage
After executing the last command we can get a error like
usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x10): multiple definition of 'yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here
we need to edit the
scripts/dtc/dtc-lexer-lex.cfile in that case, find the line ‘YYLTYPE yylloc’ and change it to ‘extern YYLTYPE yylloc’. I found the solution here.
Now, let’s run the command again. This will take a while (hours!). You can do other things in the meantime.
- If the build process completes successfully this time, the
zImagefile should be in the
arch/arm/bootfolder. Copy the “zImage” file to the “/boot” directory on your Raspberry Pi’s SD card.
$ sudo cp arch/arm/boot/zImage /boot
Configure the kernel using the existing configuration file (
$ sudo make oldconfig
- Compile the kernel
$ sudo make -j$(nproc)
This also takes some time.
- Install the kernel modules
$ sudo make modules_install
- Install the kernel
$ sudo make install
- Reboot the system to start using the new kernel.
You can also read my other posts related to
How to Configure a Raspberry Pi as Gateways between two Private Local Area Network using Ethernet Interfaces
How to fix the Ubuntu Black Screen Issue in a Raspberry Pi after Installation
Set Up Headless Kali Linux in a Raspberry Pi 4 without Monitor, Keyboard, and Mouse
ARM Exploitation with Raspberry Pi: Return Back to Program without Crashing
How to Configure a Raspberry Pi as an OpenFlow Switch: Steps, Issues, and Solutions.
Leave a comment