This short manual should provide you with the necessary information on how to cross compile the wireguard kernel module for your arm based QNAP NAS. It was tested on a QNAP TS-231P2 with QNAP OS version 4.4.1
Please be aware that you should regularly check for new wireguard releases to keep the module up to date!
uname -r
(possible output: 4.2.8
)cat /proc/version
(possible output: Linux version 4.2.8 (root@U16BuildServer48) (gcc version 4.8.2 20131014 (prerelease) (crosstool-NG linaro-1.13.1-4.8-2013.10 - Linaro GCC 2013.10) ) #2 SMP Fri Feb 14 10:05:10 CST 2020
)crosstool-NG linaro-1.13.1-4.8-2013.10
get the linaro toolchain from https://releases.linaro.org/archive/13.10/components/toolchain/binaries//proc/config.gz
from NAS (e.g. with scp
) and extract it to the extracted kernel folder as .config
PC1
tool to decrypt the encrypted image. For this purpose you can copy the .img file to your NAS (e.g. by using scp
) and decrypt it by running\
PC1 d QNAPNASVERSION4 IMAGE_FILENAME.img /mnt/HDA_ROOT/IMAGE_FILENAME.tgz
\
Please note that you should extract to the disk because the internal storage size is limited and otherwise you could end up with a corrupted file.\
You could also decrypt the encrypted .img file on your host machine by getting the source code for the PC1
tool from https://sites.google.com/site/nliaudat/nas/test2/qnap401t-decryptencryptfirmware and compile it yourself.extract_uImage.sh EXTRACTED_IMAGE_FOLDER/uImage
\
You should end up with a file named initramfs_qnap.cpio.gz
. This file needs to be copied to the kernel source files into the usr
folder.make ARCH=arm CROSS_COMPILE=folder/to/toolchain/your-compiler-prefix- oldconfig
\
(e.g. make ARCH=arm CROSS_COMPILE=folder/to/toolchain/arm-linux-gnueabihf- oldconfig
)\
This will check the provided .config
file for missing entries and ask for your input if there are any missing config entries found. Normally there should be none to some questions asked - normally they can be answered with default values.make ARCH=arm CROSS_COMPILE=folder/to/toolchain/your-compiler-prefix-
Makefile
in src
. Just comment the lines KERNELRELEASE
and KERNELDIR
out.make ARCH=arm CROSS_COMPILE=/ABSOLUTE/PATH/TO/CROSS/COMPILER/your-compiler-prefix- KERNELRELEASE=X.Y.Z KERNELDIR=/ABSOLUTE/PATH/TO/KERNEL/DIR -C src/
\
(e.g. make ARCH=arm CROSS_COMPILE=/home/user/QNAP/gcc-linaro-arm-linux-gnueabihf-4.8-2013.11_linux/bin/arm-linux-gnueabihf- KERNELRELEASE=4.2.8 KERNELDIR=/home/user/QNAP/linux-4.2.8 -C src/
)wireguard.ko
in the src
folder to /lib/modules/X.Y.Z
(e.g. /lib/modules/4.2.8
) on your QNAP NAS and load them by running insmod /lib/modules/X.Y.Z/wireguard.ko