cjj25 / RTS3903N-rsdk-4.8.5-5281

Hours of searching... here it is.
9 stars 2 forks source link

building wireguard #2

Open fkoteam opened 2 years ago

fkoteam commented 2 years ago

Hello, I'm trying to build wireguard ( https://github.com/WireGuard/wireguard-linux ). After installing the toolchain, I'm not able to compile nothing.

(Container) [user@971c421b8cec wireguard-linux-stable]$ sudo make HOSTCC=mips-linux-uclibc-xgcc oldconfig
HOSTCC  scripts/basic/fixdep
/toolchains/sdk/bin/../lib/gcc/mips-linux-uclibc/4.8.5/../../../../mips-linux-uclibc/lib/libgcc_s.so: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
make[1]: *** [scripts/Makefile.host:95: scripts/basic/fixdep] Error 1
make: *** [Makefile:555: scripts_basic] Error 2

Do you have any clue? Do you think is it possible?

Thank you!

fkoteam commented 2 years ago

day 2. next try. installing pacman and following https://www.wireguard.com/compilation/ different error, same result

(Container) [user@d54ac6b2c346 to_build]$ sudo make -C wireguard-linux-compat/src -j$(nproc) KERNELRELEASE=5.16.16-arch1-1
make: Entering directory '/to_build/wireguard-linux-compat/src'
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: gcc (GCC) 11.2.0
  You are using:           mips-linux-uclibc-xgcc (Realtek RSDK-4.8.5p1 Build 2521) 4.8.5 20150209 (prerelease)
  CC [M]  /to_build/wireguard-linux-compat/src/main.o
  CC [M]  /to_build/wireguard-linux-compat/src/noise.o
mips-linux-uclibc-xgcc: error: unrecognized argument in option '-mtune=generic'
mips-linux-uclibc-xgcc: note: valid arguments to '-mtune=' are: 10000 1004kc 1004kf 1004kf1_1 1004kf2_1 10k 12000 12k 14000 14k 16000 16k 2000 20kc 24kc 24kec 24kef 24kef1_1 24kef2_1 24kefx 24kex 24kf 24kf1_1 24kf2_1 24kfx 24kx 2k 3000 3081 34kc 34kf 34kf1_1 34kf2_1 34kfx 34kn 34kx 3900 3k 4000 4081 4100 4111 4120 4130 4180 4181 4281 4300 4400 4600 4650 4700 4k 4kc 4kec 4kem 4kep 4km 4kp 4ksc 4ksd 5000 5181 5280 5281 5400 5500 5k 5kc 5kf 6000 6k 7000 74kc 74kf 74kf1_1 74kf2_1 74kf3_2 74kfx 74kx 7k 8000 8k 9000 9k from-abi loongson2e loongson2f loongson3a m4k mips1 mips2 mips3 mips32 mips32r2 mips4 mips64 mips64r2 native octeon octeon+ octeon2 orion r10000 r1004kc r1004kf r1004kf1_1 r1004kf2_1 r10k r12000 r12k r14000 r14k r16000 r16k r2000 r20kc r24kc r24kec r24kef r24kef1_1 r24kef2_1 r24kefx r24kex r24kf r24kf1_1 r24kf2_1 r24kfx r24kx r2k r3000 r34kc r34kf r34kf1_1 r34kf2_1 r34kfx r34kn r34kx r3900 r3k r4000 r4100 r4111 r4120 r4130 r4300 r4400 r4600 r4650 r4700 r4k r4kc r4kec r4kem r4kep r4km r4kp r4ksc r4ksd r5000 r5400 r5500 r5k r5kc r5kf r6000 r6k r7000 r74kc r74kf r74kf1_1 r74kf2_1 r74kf3_2 r74kfx r74kx r7k r8000 r8k r9000 r9k rm7000 rm7k rm9000 rm9k sb1 sb1a sr71000 sr71k vr4100 vr4111 vr4120 vr4130 vr4300 vr5000 vr5400 vr5500 vr5k xlp xlr
mips-linux-uclibc-xgcc: error: unrecognized command line option '-mno-sse'
mips-linux-uclibc-xgcc: error: unrecognized command line option '-mno-mmx'
mips-linux-uclibc-xgcc: error: unrecognized command line option '-mno-sse2'
mips-linux-uclibc-xgcc: error: unrecognized command line option '-mno-3dnow'
mips-linux-uclibc-xgcc: error: unrecognized command line option '-mno-avx'
mips-linux-uclibc-xgcc: error: unrecognized command line option '-m64'
mips-linux-uclibc-xgcc: error: unrecognized command line option '-mno-80387'
mips-linux-uclibc-xgcc: error: unrecognized command line option '-mno-red-zone'
mips-linux-uclibc-xgcc: error: unrecognized command line option '-mcmodel=kernel'
mips-linux-uclibc-xgcc: error: unrecognized command line option '-fstack-protector-strong'
mips-linux-uclibc-xgcc: error: unrecognized command line option '-Wimplicit-fallthrough=5'
mips-linux-uclibc-xgcc: error: unrecognized command line option '-mrecord-mcount'
make[2]: *** [scripts/Makefile.build:287: /to_build/wireguard-linux-compat/src/main.o] Error 1
make[2]: *** Waiting for unfinished jobs....
mips-linux-uclibc-xgcc: error: unrecognized argument in option '-mtune=generic'
mips-linux-uclibc-xgcc: note: valid arguments to '-mtune=' are: 10000 1004kc 1004kf 1004kf1_1 1004kf2_1 10k 12000 12k 14000 14k 16000 16k 2000 20kc 24kc 24kec 24kef 24kef1_1 24kef2_1 24kefx 24kex 24kf 24kf1_1 24kf2_1 24kfx 24kx 2k 3000 3081 34kc 34kf 34kf1_1 34kf2_1 34kfx 34kn 34kx 3900 3k 4000 4081 4100 4111 4120 4130 4180 4181 4281 4300 4400 4600 4650 4700 4k 4kc 4kec 4kem 4kep 4km 4kp 4ksc 4ksd 5000 5181 5280 5281 5400 5500 5k 5kc 5kf 6000 6k 7000 74kc 74kf 74kf1_1 74kf2_1 74kf3_2 74kfx 74kx 7k 8000 8k 9000 9k from-abi loongson2e loongson2f loongson3a m4k mips1 mips2 mips3 mips32 mips32r2 mips4 mips64 mips64r2 native octeon octeon+ octeon2 orion r10000 r1004kc r1004kf r1004kf1_1 r1004kf2_1 r10k r12000 r12k r14000 r14k r16000 r16k r2000 r20kc r24kc r24kec r24kef r24kef1_1 r24kef2_1 r24kefx r24kex r24kf r24kf1_1 r24kf2_1 r24kfx r24kx r2k r3000 r34kc r34kf r34kf1_1 r34kf2_1 r34kfx r34kn r34kx r3900 r3k r4000 r4100 r4111 r4120 r4130 r4300 r4400 r4600 r4650 r4700 r4k r4kc r4kec r4kem r4kep r4km r4kp r4ksc r4ksd r5000 r5400 r5500 r5k r5kc r5kf r6000 r6k r7000 r74kc r74kf r74kf1_1 r74kf2_1 r74kf3_2 r74kfx r74kx r7k r8000 r8k r9000 r9k rm7000 rm7k rm9000 rm9k sb1 sb1a sr71000 sr71k vr4100 vr4111 vr4120 vr4130 vr4300 vr5000 vr5400 vr5500 vr5k xlp xlr
mips-linux-uclibc-xgcc: error: unrecognized command line option '-mno-sse'
mips-linux-uclibc-xgcc: error: unrecognized command line option '-mno-mmx'
mips-linux-uclibc-xgcc: error: unrecognized command line option '-mno-sse2'
mips-linux-uclibc-xgcc: error: unrecognized command line option '-mno-3dnow'
mips-linux-uclibc-xgcc: error: unrecognized command line option '-mno-avx'
mips-linux-uclibc-xgcc: error: unrecognized command line option '-m64'
mips-linux-uclibc-xgcc: error: unrecognized command line option '-mno-80387'
mips-linux-uclibc-xgcc: error: unrecognized command line option '-mno-red-zone'
mips-linux-uclibc-xgcc: error: unrecognized command line option '-mcmodel=kernel'
mips-linux-uclibc-xgcc: error: unrecognized command line option '-fstack-protector-strong'
mips-linux-uclibc-xgcc: error: unrecognized command line option '-Wimplicit-fallthrough=5'
mips-linux-uclibc-xgcc: error: unrecognized command line option '-mrecord-mcount'
make[2]: *** [scripts/Makefile.build:287: /to_build/wireguard-linux-compat/src/noise.o] Error 1
make[1]: *** [Makefile:1846: /to_build/wireguard-linux-compat/src] Error 2
make: *** [Makefile:26: module] Error 2
make: Leaving directory '/to_build/wireguard-linux-compat/src'
fkoteam commented 2 years ago

day 3 (not true, same day, several hours later). Installing pacman+go. Trying to compile go version ( https://github.com/WireGuard/wireguard-go ). With version compiled with sudo make GOARCH=mipsle I get

fatal error: float64nan
runtime: panic before malloc heap initialized

runtime stack:
Illegal instruction (core dumped)

It's the "best error" I get (I tried all mips versions in the GOARCH param). Then I try another version with sudo make GOARCH=mipsle GOMIPS=softfloat And nothing... I get Illegal instruction (core dumped)

I have no more ideas

cjj25 commented 2 years ago

I can't really investigate these errors right now, but it might be worth looking into buildroot and integrating the SDK/toolchain into that.

It appears the errors you're receiving on the initial build are from an incorrectly configured kbuild, if you try to build the fixdep outside the make build system, it compiles fine (fixdep src, not Wireguard).

fkoteam commented 2 years ago

my knowledge is poor. I haven't be able to install buildroot in the docker (it seems arch distribution and I have not found some dependencies). i've compiled wireguard tools but it's not enough to make work the client on the cam (error "Unable to modify interface: Protocol not supported" ).

Finally I compiled openvpn. It executes on cam (but I have not configured yet).
Here are the binaries compiled to cam (remove .log extension):

I don't know if openVPN will work, but I want wireguard :P

cjj25 commented 2 years ago

I can see why you want to use Wireguard, it's far superior when it comes to speed.

I'm not sure if I can really help as I don't have time to compile this with my current projects.

However, there is usually two ways of using Wireguard: 1. stand-alone and 2. with the kernel module.

Depending on how you've compiled the tools, it might be wanting to see the kernel module?

Try add an interface with something like ip link add dev wg0 type wireguard

Notice the type 'wireguard', does it give the same error?

fkoteam commented 2 years ago

I really appreciate your comments. I've spent hours with no success and it's great to have feedback. I expect installing wireguard could be possible someday, but I'm not sure. To execute the ip command you need:

  1. busybox (you've compiled for me in this project!)
  2. some libraries, because executing "busybox ip" on cam returns "can't load library 'libresolv.so.0". You can download this library from bellow (remove .log) or from this comment. And probably you'll have to create a symbolic link.
  3. The wireguard kernel compiled. In theory this is possible, wireguard-linux-compat supports kernel >= 3.1.0 and it is the exactly the kernel's cam. But this project has not configure option to cross compile. I tried with buildroot and crosstool-ng unsuccessfuly, but I think this toolchain have to be the way. I've also tried with wireguard-go version. But go attaches some parameters incompatible with gcc version included in the toolchain, so I compiled go sources changing "march=mips32" to "march=5281" and removing "mno-odd-spreg". After compiling go, I've compiled "wireguard-go" with several go parameters (CGO_ENABLED=1/0, -ldflags='-extldflags=-static', GOARCH=mips/mipsle, etc.). All the generated binares fails on cam with "line 1: syntax error: unexpected "("" or "Illegal instruction (core dumped)".

libresolv.a.log libresolv-0.9.33.so.log

PS- executing openvpn also fails (" ERROR: Cannot open TUN/TAP dev /dev/net/tun: No such file or directory (errno=2)"). TUN is not present in the kernel. Maybe I should try compiling 3.1.0 kernel, but I think I have no more energy.