Compile Linux Headers for Wireguard

Hello,

I’m trying to make Wireguard to work on Banana PI R2.

I’ve compiled the Linux kernel with the appropriate kernel modules (https://www.wireguard.com/install/#kernel-requirements) using @frank-w build tool.

However, when installing the wireguard I get the following message: Building for 4.14.69-bpi-r2-main, 4.15.0-34-generic and 4.4.70-BPI-R2-Kernel Module build for kernel 4.14.69-bpi-r2-main was skipped since the kernel headers for this kernel does not seem to be installed.

And my question is how can I get the headers on the kernel? I’ve tried a few variants while compiling, but none seems to work.

try to clone my github-repo to your r2 and create a link in /lib/modules/$(uname -r)/source to the git-folder

Thanks. Gonna try it now.

So, I had to create a symlink to build too instead of just source so that wireguard would stop throwing that error while installing (from the message before) .

But now, I got the following:

ERROR (dkms apport): kernel package linux-headers-4.14.69-bpi-r2-main is not supported
Error! Bad return status for module build on kernel: 4.14.69-bpi-r2-main (armv7l)
Consult /var/lib/dkms/wireguard/0.0.20180910/build/make.log for more information.

The contents for that file are attached.wireguard.log (2.6 KB)

Any help is appreciate

  ERROR: Kernel configuration is invalid.
         include/generated/autoconf.h or include/config/auto.conf are missing.
         Run 'make oldconfig && make prepare' on kernel src to fix it.

Try to run build.sh importconfig before running wireguard-buildscript

else it seems your symlink is wrong or not used.

Yep. I just rebuild the kernel to make sure all wireguard modules needed were added and they are.

I also rechecked the symlinks and they seem OK:

 lrwxrwxrwx  1 root root    19 Sep 18 03:01 build -> /stuff/BPI-R2-4.14/
 lrwxrwxrwx  1 root root    19 Sep 18 03:01 source -> /stuff/BPI-R2-4.14/

Note that I’m not compiling the kernel on the BPI-R2. Could that be the reason for be failing?

Note that I’m not compiling the kernel on the BPI-R2. Could that be the reason for be failing?

Yeah, after compiling everything on the BPI and then creating the symlink, Wireguard was able to install without error. However, it is still failing (not loading anything) and I’m still investigating…

That’s the only error I’m seeing for now.

root@bpi-iot-ros-ai:/stuff/BPI-R2-4.14# ip link add dev wg0 type wireguard
RTNETLINK answers: Operation not supported

Any help is appreciated.

anything in dmesg/syslog?

On dmesg as well on syslog:

[ 347.425411] wireguard: version magic '4.14.70-bpi-r2-main SMP mod_unload ARMv7 p2v8 ’ should be '4.14.69-bpi-r2-main SMP mod_unload ARMv7 p2v8 ’

So, somewhere it is saying 4.14.70???

Because your code is already 4.14.70,but compiled kernel still 4.14.69

You can get running kernel with “uname -r” and source-version in source-folder via “make kernelversion”

Yeah, I noticed that after posting the reply and fixed that.

However, I’m still getting

root@bpi-iot-ros-ai:/home/pi# ip link add dev wg0 type wireguard
RTNETLINK answers: Operation not supported

But now nothing on logs. So, any new ideas is appreciated =)

EDIT: I have to reinstall rebuild wireguard. I will come with the results in a few minutes

You are the genius @frank-w!

After reinstalling wireguard, it worked!!!

Hopefully @sinovoip is paying you enough for being that awesome!

I don’t get payed for it. I’ve got one of my 2 r2 boards for free and maybe an r64/mt7615-module. Most things i do is to get my r2 running as well as i can and simply share my work.

1 Like

I’m currently trying to achieve the same with the Debian Buster Kernel 5.10 image ([BPI-R64] debian buster with new bootchain and linux 5.10) on a BPI-R64.

Installing wireguard-dkms from the backports fails due to missing kernel headers:

Loading new wireguard-1.0.20210219 DKMS files...
It is likely that 5.10.0-bpi-r64-main belongs to a chroot's host
Building for 5.10.0-0.bpo.8-cloud-arm64 and 5.10.0-bpi-r64-main
Module build for kernel 5.10.0-0.bpo.8-cloud-arm64 was skipped since the
kernel headers for this kernel does not seem to be installed.
Module build for kernel 5.10.0-bpi-r64-main was skipped since the
kernel headers for this kernel does not seem to be installed.

I tried to create the sym link to the github repo (https://github.com/frank-w/BPI-R64-ATF)

/lib/modules/5.10.0-bpi-r64-main/source -> /root/BPI-R64-ATF

but this does not change the outcome. Is there anything else I can do?

You have to link kernel-repo (bpi-r2-4.14), change branch and go back to your version via git, change config (build.conf) to r64

Or search the deb-package matching r64 and your version from github releases

I guess you need to update kernel before as 5.10.0 is the first final and we are at 5.10.66 now (my repo is at 5.10.64)

Wireguard dkms is only needed with linux <5.6. With 5.6+ it is included in linux source.

I have it added to r2,but not r64 yet. Basicly you need only add CONFIG_WIREGUARD=m and compile/install new kernel.

Added wireguard to r64 defconfig

You can update kernel from github releases

E.g. this: https://github.com/frank-w/BPI-R2-4.14/releases/tag/CI-BUILD-5.10-main-5.10.64-2021-09-17_0745

Make sure backup old kernel uImage and updating uEnv.txt to your new kernel file.

Hi Frank,

Thanks for the reply. Works like a charm!

Cheers, also Frank

have you used pre-compiled kernel from github oder self-compile?

I’ve cloned the BPI-R2-4.14 repo, switched to the 5.10-main branch with the CONFIG_WIREGUARD=m setting, switched to board=bpi-r64 in the build.config and compiled it.