Error while compiling rtlwifi drivers for OpenWrt on Fedora

Hi,

I'm trying to compile drivers from:


(from that repository: github.com/lwfinger/rtlwifi_new.git)

not for Ubuntu but for OpenWRT instead (I'm compiling on Fedora 31).

I followed more or less the instructions from
https://telecnatron.com/articles/Cross-Compiling-For-OpenWRT-On-Linux/index.html and
(http removed because of 2 links limit)
botdream.com/blog/2013/11/24/setup-openwrt-cross-compile-environment/

I don't know much about compiling etc. and I got stuck with that error.

[james7bondo@localhost rtlwifi_new]$ make
make -C /lib/modules/5.3.16-300.fc31.x86_64/build M=/home/james7bondo/External/Programming/OpenWrt_Driver/rtlwifi_new modules
make[1]: Entering directory '/usr/src/kernels/5.3.16-300.fc31.x86_64'
  CC [M]  /home/james7bondo/External/Programming/OpenWrt_Driver/rtlwifi_new/btcoexist/halbtc8192e2ant.o
mipsel-openwrt-linux-gcc: error: unrecognized argument in option '-mtune=generic'
mipsel-openwrt-linux-gcc: 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 34kc 34kf 34kf1_1 34kf2_1 34kfx 34kn 34kx 3900 3k 4000 4100 4111 4120 4130 4300 4400 4600 4650 4700 4k 4kc 4kec 4kem 4kep 4km 4kp 4ksc 4ksd 5000 5400 5500 5900 5k 5kc 5kf 6000 6k 7000 74kc 74kf 74kf1_1 74kf2_1 74kf3_2 74kfx 74kx 7k 8000 8k 9000 9k from-abi i6400 interaptiv loongson2e loongson2f loongson3a m14k m14kc m14ke m14kec m4k m5100 m5101 mips1 mips2 mips3 mips32 mips32r2 mips32r3 mips32r5 mips32r6 mips4 mips64 mips64r2 mips64r3 mips64r5 mips64r6 native octeon octeon+ octeon2 octeon3 orion p5600 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 r5900 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
mipsel-openwrt-linux-gcc: error: unrecognized command line option '-mno-sse'; did you mean '-fno-dse'?
mipsel-openwrt-linux-gcc: error: unrecognized command line option '-mno-mmx'; did you mean '-mno-mdmx'?
mipsel-openwrt-linux-gcc: error: unrecognized command line option '-mno-sse2'; did you mean '-fno-dse'?
mipsel-openwrt-linux-gcc: error: unrecognized command line option '-mno-3dnow'; did you mean '-mno-dsp'?
mipsel-openwrt-linux-gcc: error: unrecognized command line option '-mno-avx'; did you mean '-mno-eva'?
mipsel-openwrt-linux-gcc: error: unrecognized command line option '-m64'
mipsel-openwrt-linux-gcc: error: unrecognized command line option '-mno-80387'
mipsel-openwrt-linux-gcc: error: unrecognized command line option '-mno-fp-ret-in-387'
mipsel-openwrt-linux-gcc: error: unrecognized command line option '-mpreferred-stack-boundary=3'
mipsel-openwrt-linux-gcc: error: unrecognized command line option '-mskip-rax-setup'
mipsel-openwrt-linux-gcc: error: unrecognized command line option '-mno-red-zone'; did you mean '-fno-regmove'?
mipsel-openwrt-linux-gcc: error: unrecognized command line option '-mcmodel=kernel'
mipsel-openwrt-linux-gcc: error: unrecognized command line option '-mindirect-branch=thunk-extern'
mipsel-openwrt-linux-gcc: error: unrecognized command line option '-mindirect-branch-register'
mipsel-openwrt-linux-gcc: error: unrecognized command line option '-mrecord-mcount'; did you mean '-frecord-marker=4'?
mipsel-openwrt-linux-gcc: error: unrecognized command line option '-mfentry'; did you mean '--entry'?
make[3]: *** [scripts/Makefile.build:281: /home/james7bondo/External/Programming/OpenWrt_Driver/rtlwifi_new/btcoexist/halbtc8192e2ant.o] Error 1
make[2]: *** [scripts/Makefile.build:497: /home/james7bondo/External/Programming/OpenWrt_Driver/rtlwifi_new/btcoexist] Error 2
make[1]: *** [Makefile:1630: _module_/home/james7bondo/External/Programming/OpenWrt_Driver/rtlwifi_new] Error 2
make[1]: Leaving directory '/usr/src/kernels/5.3.16-300.fc31.x86_64'
make: *** [Makefile:58: all] Error 2

The command mips-openwrt-linux-gcc from the website doesn't work, I use mipsel-openwrt-linux-gcc instead. I don't know whether that makes any difference.

In the Makefile I changed the line CC = gcc for CC = mipsel-openwrt-linux-gcc

I would be grateful for any help. I don't whether the Makefile has to be edited or I should change something about the compiler.

I do it because I want to plug TL-WN722N into TL-WR902AC.

You're in way over your head. MIPS and MIPSEL are different architectures. Secondly, you're dealing with Realtek wireless drivers which are hit and miss. Thirdly, you say you're compiling for OpenWrt but you're compiling against what looks like your Linux distribution's running kernel.

You don't seem to be using the buildroot, with a bit of luck it has (shoddy) drivers available.

My advice: get something that is supported (ath9k based).

1 Like

Thank you for the answer. I know it is a bit too hard for me but I learned that sometimes it is good to do a too hard things instead of starting with the simplest ones.

I give it the last try :slight_smile:

I checked architecture on that website: https://openwrt.org/toh/hwdata/tp-link/tp-link_tl-wr902ac_v3
Now I know it is: mipsel_24kc

Apart from having Target System set for 'MediaTek Ralink MIPS' and Subtarget for 'MT76x8 based boards' in OpenWrt Configuration (make menuconfig), I set Target Profile for 'TP-Link TL-WR902AC v3'
so I hope it is now okay. In 'staging_dir' directory that mips directory is not present now after I compiled it again from the scratch.

I've read bad thinks about Realthek drivers but it doesn't have to be very stable (I compiled it on Mint and it worked quite okey). If I do not succeed I will eventually that buy ath9k based one but I hope that maybe with some little help from you I could make it work.

I tried using: make CC=mipsel-openwrt-linux-musl-gcc LD=mipsel-openwrt-linux-musl-ld
which I found when looking for info about that buildroot you wrote about.

I found it on that page: https://openwrt.org/docs/guide-developer/crosscompile

* Pass the *host* and *build* to the build system of the package to trigger cross-compile

* For GNU configure, use `--build=architecture-unknown-linux-gnu --host=architecture-openwrt-linux-uclibc` (for example: `./configure --build=x86_64-unknown-linux-gnu  –host=mips-openwrt-linux-uclibc` )

  * Run `./config.guess` to get the `--build=` option.

  * Check the output and ensure that `'checking whether we are cross compiling… yes` ' is yes.
* For GNU make, override the `CC` and `LD` environment variables (usually not needed if GNU configure was used)

  * `make CC=architecture-openwrt-linux-uclibc-gcc` `LD=architecture-openwrt-linux-uclibc-ld`

I could do nothing about that ./configure, as far as I understand, it should be some file in the driver package? I couldn't find any.

Nevertheless, I run that config.guess file so I know I should put x86_64-pc-linux-gnu there.

It has to do something with 'binutils' directory in 'toolchain'? I guess all that things should be compiled, although in that directory are just those files: Makefile, Config.version, Config.in and Patches dir.

It is compiled somewhere else? and I should maybe just put some folder to the PATH?

I would be grateful if you could point me again in some direction because I am afraid that I don't know myself where I should start trying to fix it

I tried compiling beta linux drivers from TP-Link website. The error is quite similar. Just for the record.


[james7bondo@localhost rtl8188EUS_linux_v5.2.2.4_25483.20171222]$ make CC=mipsel-openwrt-linux-musl-gcc LD=mipsel-openwrt-linux-musl-ld
make ARCH=x86_64 CROSS_COMPILE= -C /lib/modules/5.3.16-300.fc31.x86_64/build M=/home/james7bondo/External/Programming/rtl8188EUS_linux_v5.2.2.4_25483.20171222  modules
make[1]: Entering directory '/usr/src/kernels/5.3.16-300.fc31.x86_64'
  CC [M]  /home/james7bondo/External/Programming/rtl8188EUS_linux_v5.2.2.4_25483.20171222/core/rtw_cmd.o
mipsel-openwrt-linux-musl-gcc: error: unrecognized command line option '-mno-sse'; did you mean '-fno-dse'?
mipsel-openwrt-linux-musl-gcc: error: unrecognized command line option '-mno-mmx'; did you mean '-mno-mdmx'?
mipsel-openwrt-linux-musl-gcc: error: unrecognized command line option '-mno-sse2'; did you mean '-fno-dse'?
mipsel-openwrt-linux-musl-gcc: error: unrecognized command line option '-mno-3dnow'; did you mean '-mno-dsp'?
mipsel-openwrt-linux-musl-gcc: error: unrecognized command line option '-m64'
mipsel-openwrt-linux-musl-gcc: error: unrecognized command line option '-mno-red-zone'; did you mean '-fno-regmove'?
mipsel-openwrt-linux-musl-gcc: error: unrecognized command line option '-mcmodel=kernel'
make[2]: *** [scripts/Makefile.build:281: /home/james7bondo/External/Programming/rtl8188EUS_linux_v5.2.2.4_25483.20171222/core/rtw_cmd.o] Error 1
make[1]: *** [Makefile:1630: _module_/home/james7bondo/External/Programming/rtl8188EUS_linux_v5.2.2.4_25483.20171222] Error 2
make[1]: Leaving directory '/usr/src/kernels/5.3.16-300.fc31.x86_64'
make: *** [Makefile:1911: modules] Error 2

And that rtlwifi after compiling that OpenWrt tools again:

[james7bondo@localhost rtlwifi_new]$ make CC=mipsel-openwrt-linux-musl-gcc LD=mipsel-openwrt-linux-musl-ld
make -C /lib/modules/5.3.16-300.fc31.x86_64/build M=/home/james7bondo/External/Programming/OpenWrt_Driver/rtlwifi_new modules
make[1]: Entering directory '/usr/src/kernels/5.3.16-300.fc31.x86_64'
  CC [M]  /home/james7bondo/External/Programming/OpenWrt_Driver/rtlwifi_new/btcoexist/halbtc8192e2ant.o
mipsel-openwrt-linux-musl-gcc: error: unrecognized command line option '-mno-sse'; did you mean '-fno-dse'?
mipsel-openwrt-linux-musl-gcc: error: unrecognized command line option '-mno-mmx'; did you mean '-mno-mdmx'?
mipsel-openwrt-linux-musl-gcc: error: unrecognized command line option '-mno-sse2'; did you mean '-fno-dse'?
mipsel-openwrt-linux-musl-gcc: error: unrecognized command line option '-mno-3dnow'; did you mean '-mno-dsp'?
mipsel-openwrt-linux-musl-gcc: error: unrecognized command line option '-m64'
mipsel-openwrt-linux-musl-gcc: error: unrecognized command line option '-mno-red-zone'; did you mean '-fno-regmove'?
mipsel-openwrt-linux-musl-gcc: error: unrecognized command line option '-mcmodel=kernel'
make[3]: *** [scripts/Makefile.build:281: /home/james7bondo/External/Programming/OpenWrt_Driver/rtlwifi_new/btcoexist/halbtc8192e2ant.o] Error 1
make[2]: *** [scripts/Makefile.build:497: /home/james7bondo/External/Programming/OpenWrt_Driver/rtlwifi_new/btcoexist] Error 2
make[1]: *** [Makefile:1630: _module_/home/james7bondo/External/Programming/OpenWrt_Driver/rtlwifi_new] Error 2
make[1]: Leaving directory '/usr/src/kernels/5.3.16-300.fc31.x86_64'
make: *** [Makefile:58: all] Error 2

Glad to see you're making progress.

Config.in is a 'precursor' so to speak for configure. OpenWrt uses standard Linux build system tools (make, autoconf, ...) but it's best to check the documentation Realtek provides for the drivers, to see what commands you should be feeding to the OpenWrt toolchain. It helps to look at other out of tree drivers like e.g. mt76 (particularly its Makefile) to see how it's done in the buildroot.

My first recommendation would be to check of there aren't any deprecated OpenWrt packages for the driver you're trying to build. Others probably have done some of the legwork already.

Check also this topic: 8188eu drivers

1 Like

Thanks again :slight_smile: I've seen that topic 8188eu drivers. Unfortunately, it didn't work.
I see it is in fact going to be demanding to do for me. Nevertheless, once I have a bit of time, I will probably try to do it. Although, taking into consideration the amount of time, buying ath9k will be much cheaper :stuck_out_tongue: Sadly, I will probably try untill I succeed unless the number of "wasted" days without effect is going to be too great. :smiley: I will inform on my progress.

But, do I understand/guess correctly - I will have to presumably compile some additional packages to the toolchain and then modify the Makefile of the driver package?

The toolchain is usable as-is if you already compiled an image for your device. The driver source code just needs to be prepped to compile along with OpenWrt, against its kernel headers etc.

1 Like