mpbecker / QNAP_TS231P2_wireguard

How to build the wireguard kernel module for the QNAP TS231P2 NAS
13 stars 2 forks source link

request for compiled wireguard Kenelmodul #1

Open gamer123 opened 3 years ago

gamer123 commented 3 years ago

@mpbecker I have a TS-231P actually everything is more or less the same Kernel is 4.2.8

[~] # uname -r 4.2.8

[~] # cat /proc/version 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 Tue Apr 6 05:28:48 CST 2021

-getting access via ssh and press Q to get the normal consol

Until Cross compile the kernel it is no problem.

But then you make this files directly on qnap and here the problems starts

Do you may have a video guide how you do it?

because a lot of persons would like to use wireguard on qnap but qnap has a toooo old kernel and also the userspace implemantions are very slow and not as it should be.

Thanks

mujuli

mpbecker commented 3 years ago

Since the self build kernel modules get deleted during a OS update of the QNAP, I decided to do the whole wireguard stuff on another system like Raspberry Pi. Therefore unfortunately I do not have any further guidance on how to run wireguard on QNAP NAS - I just wanted to share my knowledge regarding the cross compiling.

gamer123 commented 3 years ago

@mpbecker

Thanks for your response :) actually i got run with gcc 7.X.X and i also got the wireguard.ko file .. but with the wrong gcc version

for me biggest problem is left how can i use only the toolchain? or which linux distro have you used for building it ? when i set CROSS_COMPILER= to my toolchain path the result is always: arm-linux-gnueabihf-gcc file not found.

when i use CROSS_COMPILER=arm-linux-gnueabihf-gcc it use the system path and the newer gcc and then it works .. but when i ceck the version gcc-v is allways the system version.

may you can help me out ?

ok but kernel change not really often (still fu*** old ) .. for me it is better to run it on qnap because i have two ;) so i update only once a year ;)

gamer123 commented 3 years ago

arm-linux-gnueabihf-gcc -v gcc version 7.5.0 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)

make

ubuntu@DESKTOP-AQ53H2J:~/kern$ make make: home/ubuntu/gl/bin/arm-linux-gnueabihf-gcc: Command not found CHK include/config/kernel.release CHK include/generated/uapi/linux/version.h CHK include/generated/utsrelease.h make[1]: 'include/generated/mach-types.h' is up to date. CC kernel/bounds.s /bin/sh: 1: home/ubuntu/gl/bin/arm-linux-gnueabihf-gcc: not found Kbuild:44: recipe for target 'kernel/bounds.s' failed make[1]: [kernel/bounds.s] Error 127 Makefile:992: recipe for target 'prepare0' failed make: [prepare0] Error 2

Path to toolchain is /home/ubuntu/gl/bin

and the file is in there !!

gamer123 commented 3 years ago

ah and do you know what happens when i use my compiled file with 7xxx . i think it kills the kernel or ?

mpbecker commented 3 years ago

You have to set the path to your toolchain including the compiler prefix:

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)

gamer123 commented 3 years ago

hi thanks again,

may can you tell me which linux distro and which version you have used ? and have you used a 32 bit or 64bit system ?

after a while i modified it directly in the makefile .. but here again on a nice an clean ubuntu18.04 x 64

One question appears by useing .config

make ARCH=arm CROSS_COMPILE=home/ubuntu/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/arm-linux-gnueabihf- oldconfig scripts/kconfig/conf --oldconfig Kconfig *

an then this:

make ARCH=arm CROSS_COMPILE=home/ubuntu/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/arm-linux-gnueabihf- make: home/ubuntu/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/arm-linux-gnueabihf-gcc: Command not found scripts/kconfig/conf --silentoldconfig Kconfig make: home/ubuntu/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/arm-linux-gnueabihf-gcc: Command not found CHK include/config/kernel.release UPD include/config/kernel.release WRAP arch/arm/include/generated/asm/bitsperlong.h WRAP arch/arm/include/generated/asm/cputime.h WRAP arch/arm/include/generated/asm/current.h WRAP arch/arm/include/generated/asm/emergency-restart.h WRAP arch/arm/include/generated/asm/errno.h WRAP arch/arm/include/generated/asm/exec.h WRAP arch/arm/include/generated/asm/ioctl.h WRAP arch/arm/include/generated/asm/ipcbuf.h WRAP arch/arm/include/generated/asm/irq_regs.h WRAP arch/arm/include/generated/asm/kdebug.h WRAP arch/arm/include/generated/asm/local.h WRAP arch/arm/include/generated/asm/local64.h WRAP arch/arm/include/generated/asm/mcs_spinlock.h WRAP arch/arm/include/generated/asm/mm-arch-hooks.h WRAP arch/arm/include/generated/asm/msgbuf.h WRAP arch/arm/include/generated/asm/param.h WRAP arch/arm/include/generated/asm/parport.h WRAP arch/arm/include/generated/asm/poll.h WRAP arch/arm/include/generated/asm/preempt.h WRAP arch/arm/include/generated/asm/resource.h WRAP arch/arm/include/generated/asm/rwsem.h WRAP arch/arm/include/generated/asm/seccomp.h WRAP arch/arm/include/generated/asm/sections.h WRAP arch/arm/include/generated/asm/segment.h WRAP arch/arm/include/generated/asm/sembuf.h WRAP arch/arm/include/generated/asm/serial.h WRAP arch/arm/include/generated/asm/shmbuf.h WRAP arch/arm/include/generated/asm/siginfo.h WRAP arch/arm/include/generated/asm/simd.h WRAP arch/arm/include/generated/asm/sizes.h WRAP arch/arm/include/generated/asm/socket.h WRAP arch/arm/include/generated/asm/sockios.h WRAP arch/arm/include/generated/asm/termbits.h WRAP arch/arm/include/generated/asm/termios.h WRAP arch/arm/include/generated/asm/timex.h WRAP arch/arm/include/generated/asm/trace_clock.h WRAP arch/arm/include/generated/asm/unaligned.h CHK include/generated/uapi/linux/version.h UPD include/generated/uapi/linux/version.h CHK include/generated/utsrelease.h UPD include/generated/utsrelease.h HOSTCC scripts/basic/bin2c Generating include/generated/mach-types.h CC kernel/bounds.s /bin/sh: 1: home/ubuntu/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/arm-linux-gnueabihf-gcc: not found Kbuild:44: recipe for target 'kernel/bounds.s' failed make[1]: [kernel/bounds.s] Error 127 Makefile:992: recipe for target 'prepare0' failed make: [prepare0] Error 2

when i do a /home instead of home i get this syntax error "(" unexpected

ubuntu@DESKTOP-AQ53H2J:~/linux-4.2.8$ make ARCH=arm CROSS_COMPILE=/home/ubuntu/gcc-linaro-arm-linux-gnueabihf-4.8-2013.1 0_linux/bin/arm-linux-gnueabihf- /home/ubuntu/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/arm-linux-gnueabihf-gcc: 1: /home/ubuntu/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/arm-linux-gnueabihf-gcc: Syntax error: "(" unexpected CHK include/config/kernel.release CHK include/generated/uapi/linux/version.h CHK include/generated/utsrelease.h make[1]: 'include/generated/mach-types.h' is up to date. CC kernel/bounds.s /bin/sh: 1: /home/ubuntu/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/arm-linux-gnueabihf-gcc: Exec format error Kbuild:44: recipe for target 'kernel/bounds.s' failed make[1]: [kernel/bounds.s] Error 2 Makefile:992: recipe for target 'prepare0' failed make: [prepare0] Error 2

I also tried this :

export CROSS_COMPILE=arm-linux-gnueabihf- export PATH=/home/ubuntu/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/:$PATH, export ARCH=arm

and then make

i get in this case some // in path appear .. dont know why ..

ubuntu@DESKTOP-AQ53H2J:~/linux-4.2.8$ make /home/ubuntu/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin//arm-linux-gnueabihf-gcc: 1: /home/ubuntu/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin//arm-linux-gnueabihf-gcc: Syntax error: "(" unexpected CHK include/config/kernel.release CHK include/generated/uapi/linux/version.h CHK include/generated/utsrelease.h make[1]: 'include/generated/mach-types.h' is up to date. CC kernel/bounds.s arm-linux-gnueabihf-gcc: error trying to exec 'cc1': execvp: No such file or directory Kbuild:44: recipe for target 'kernel/bounds.s' failed make[1]: [kernel/bounds.s] Error 1 Makefile:992: recipe for target 'prepare0' failed make: [prepare0] Error 2

mpbecker commented 3 years ago

Setting the absolute path should work. Maybe the syntax error is in the config file. But you have to figure out yourself. I crosscompiled under 64Bit Ubuntu 18.04.

gamer123 commented 3 years ago

hi thanks again for your answer. This is my last post :) when i get it run i will let you know how i fixed it .

You mean in the extraced kernel .config file from qnap image ? from my point of view it works with gcc 7.6 so i think it must be effected by something else.

have you only used the this ?

gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux.tar.bz2 file or have you used also the sourcefiles too ? gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_src.tar.bz2

ok nearly the last question have you installed some other libaries like "arm build esentials" or some other ? like sudo apt-get install build-essential sudo apt-get install g++-arm-linux-gnueabihf sudo apt-get install gdb-multiarch

or some build support for compile 32 bit systems on a 64 bit system ?

and when i check make file in kernel

CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)

can be overritten by config .. i think kernel .config file or ?

Cross compiling and selecting different set of gcc/bin-utils

---------------------------------------------------------------------------

#

When performing cross compilation for other architectures ARCH shall be set

to the target architecture. (See arch/* for the possibilities).

ARCH can be set during invocation of make:

make ARCH=ia64

Another way is to have ARCH set in the environment.

The default ARCH is the host where make is executed.

CROSS_COMPILE specify the prefix used for all executables used

during compilation. Only gcc and related bin-utils executables

are prefixed with $(CROSS_COMPILE).

CROSS_COMPILE can be set on the command line

make CROSS_COMPILE=ia64-linux-

Alternatively CROSS_COMPILE can be set in the environment.

A third alternative is to store a setting in .config so that plain

"make" in the configured kernel build directory always uses that.

Default value for CROSS_COMPILE is not to prefix executables

Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile

ARCH ?= $(SUBARCH) CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)

gamer123 commented 3 years ago

hey now it is working. got some help and manjaro is much better for building.. and qnap is a pice of sh*** because they still use gcc 4.8.2 when you compile the 4.2.8 kernel you get a warning that this version 4.8.2 and 4.8.3 miscompile the kernel and you have to manually modify the kernel soure and remove this error otherwise gcc do not compile.

ok but now kernel modul is loaded:

[/share/Kernelmodul] # cp -u wireguard.ko /lib/modules/4.2.8 [/share/Kernelmodul] # insmod /lib/modules/4.2.8/wireguard.ko [/share/Kernelmodul] # lsmod Tainted: P wireguard 132922 0 - Live 0x7ee79000

so its working from the first perspectiv, but

i run the wireguard install in a 18:04 LXC container everything looks fine until wg-quicks start (I used this https://github.com/angristan/wireguard-install exit1 must be removed in LXC warning)

See "systemctl status wg-quick@wg0.service" and "journalctl -xe" for details.

if i check this:

sudo systemctl status wg-quick@wg0

[sudo] password for ubuntu:

● wg-quick@wg0.service - WireGuard via wg-quick(8) for wg0

Loaded: loaded (/lib/systemd/system/wg-quick@.service; indirect; vendor preset: enabled)

Active: failed (Result: exit-code) since Tue 2021-05-04 07:55:05 UTC; 38min ago

Docs: man:wg-quick(8)

man:wg(8)

@mpbecker Can you may tell me how you set up wireguard ? In a LXC Container or Docker or nativ directly on qnap ? and have you also had problems to get wg-quick running ?

And do i have to install the Kernel header also?

From my point of view Wireguard needs:

Thanks again

mujuli

mpbecker commented 3 years ago

Since the self build kernel modules get deleted during a OS update of the QNAP, I decided to do the whole wireguard stuff on another system like Raspberry Pi. Therefore unfortunately I do not have any further guidance on how to run wireguard on QNAP NAS - I just wanted to share my knowledge regarding the cross compiling.