1

Helo,

I have followed the instructions given at https://www.raspberrypi.org/documentation/linux/kernel/building.md to build a custom kernel. (I have cross-compiled it on an x86 box.) The custom kernel is running perfectly under Raspbian on a RPI 3B+.

The cross-compilation process has not generated a linux-headers-VERSION.deb package.

How do I install the Kernel Headers for this custom kernel? (I need them to compile a kernel loadable module.)

Cheers

1 Answer 1

0
  • The headers should usually be installed using sudo apt install raspberrypi-kernel-headers –y

    You'll see the headers installed at /usr/src

  • If you don't see the headers that correspond to your current kernel source uname -r:

Install dependencies for rpi-source

sudo apt install git bc bison flex libssl-dev

Install your rpi-source

sudo wget https://raw.githubusercontent.com/RPi-Distro/rpi-source/master/rpi-source -O /usr/local/bin/rpi-source && sudo chmod +x /usr/local/bin/rpi-source && /usr/local/bin/rpi-source -q --tag-update

Run

rpi-source

After this you'll see two folders. One of them is a symbolic link to the other named linux-{sha-number to git commit pointing to kernel version}. e.g. linux-1f9874a5435d6c3fd94a2ad00823d85cb59fc0b4

Move this folder to /usr/src/ where kernel headers should be located on your Raspberry Pi and rename it linux:

sudo mv linux-{sha-number} /usr/src/linux

Create symbolic links after removing the ones created by rpi-source in /lib/modules/$(uname -r):

cd /usr/src
sudo ln -s linux linux-headers-$(uname -r)
sudo rm -rf /lib/modules/$(uname -r)/build /lib/modules/$(uname -r)/source
sudo ln -s /usr/src/linux /lib/modules/$(uname -r)/build
sudo ln -s /usr/src/linux /lib/modules/$(uname -r/source

Let me know if this works and if there's a better way of course

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.