Today I was trying to build ipt-netflow kernel module on my Raspberry Pi with Raspbian linux. For hours I was stuck with proper system setup to make it ready for compiling additional kernel modules. The problem was with make prepare modules_prepare
command which gives me such error:
1 2 3 4 5 6 7 |
root@raspberrypi:/usr/src/linux-headers-4.9.59+# make prepare modules_prepare CHK include/config/kernel.release CHK include/generated/uapi/linux/version.h CHK include/generated/utsrelease.h make[1]: *** No rule to make target 'arch/arm/tools/gen-mach-types', needed by 'include/generated/mach-types.h'. Stop. arch/arm/Makefile:315: recipe for target 'archprepare' failed make: *** [archprepare] Error 2 |
Google was not very helpful with this problem. Finally, basing on various trops, I got it worked. Uff.. Here is the proper way to setup Raspberry Pi for compiling additional kernel modules:
Install kernel headers and other tools:
1 2 |
apt-get update apt-get install raspberrypi-kernel-headers module-assistant pkg-config libncurses5-dev |
Install rpi-source tool. This downloading full kernel sources, not only kernel headers.
1 2 3 |
wget https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source -O /usr/bin/rpi-source chmod +x /usr/bin/rpi-source /usr/bin/rpi-source -q --tag-update |
Install kernel sources (Lack of this was the cause of problems).
1 |
rpi-source --skip-gcc |
You will see something like that:
1 2 3 4 5 6 7 8 9 |
root@raspberrypi:/home/pi# rpi-source --skip-gcc *** Using: /usr/share/doc/raspberrypi-bootloader/changelog.Debian.gz *** Latest firmware revision: 12e0bf86e08d6067372bc0a45d7e8a10d3113210 *** Linux source commit: 36612d5d7a88672a3e7dd6cb458dbbbca0d75efe *** Kernel source already installed: /root/linux-36612d5d7a88672a3e7dd6cb458dbbbca0d75efe |
I suggest you create a symlink to /usr/src/linux:
1 |
ln -s /root/linux-36612d5d7a88672a3e7dd6cb458dbbbca0d75efe /usr/src/linux |
Copy current kernel config to downloaded kernel sources and make oldconfig:
1 2 3 4 |
modprobe configs cd /usr/src/linux zcat /proc/config.gz > .config make oldconfig |
Run module assistant:
1 |
m-a prepare |
Prepare kernel for modules compilation:
1 |
make prepare modules_prepare |
After this steps I was able to compile third party kernel modules. 🙂
At the end I would like to highly recommend ipt-netflow kernel module – it is very robust solution for sending netflows from linux machines.
1 Comment
thanks, best tutorial ever