Skip to content
This repository has been archived by the owner on May 15, 2021. It is now read-only.

Compile error on Raspbian #29

Open
buzzy opened this issue Apr 21, 2019 · 27 comments
Open

Compile error on Raspbian #29

buzzy opened this issue Apr 21, 2019 · 27 comments

Comments

@buzzy
Copy link

buzzy commented Apr 21, 2019

I have changed the Makefile to build for RPI. Still I get error that "armv71" dir does not exist.
Adding "ARCH=arm" in front of the build command fixed this error, but introduces another compile error.

DKMS make.log for rtl8821CU-5.2.5.3 for kernel 4.14.98-v7+ (armv7l)
Sun 21 Apr 19:57:20 BST 2019
make ARCH=armv7l CROSS_COMPILE= -C /lib/modules/4.14.98-v7+/build M=/var/lib/dkms/rtl8821CU/5.2.5.3/build modules
make[1]: Entering directory '/usr/src/linux-headers-4.14.98-v7+'
Makefile:646: arch/armv7l/Makefile: No such file or directory
make[1]: *** No rule to make target 'arch/armv7l/Makefile'. Stop.
make[1]: Leaving directory '/usr/src/linux-headers-4.14.98-v7+'
Makefile:1923: recipe for target 'modules' failed
make: *** [modules] Error 2

DKMS make.log for rtl8821CU-5.2.5.3 for kernel 4.14.98-v7+ (armv7l)
Sun 21 Apr 19:59:56 BST 2019
make ARCH=arm CROSS_COMPILE= -C /lib/modules/4.14.98-v7+/build M=/var/lib/dkms/rtl8821CU/5.2.5.3/build modules
make[1]: Entering directory '/usr/src/linux-headers-4.14.98-v7+'
CC [M] /var/lib/dkms/rtl8821CU/5.2.5.3/build/core/rtw_cmd.o
gcc: error: -mfloat-abi=soft and -mfloat-abi=hard may not be used together
scripts/Makefile.build:326: recipe for target '/var/lib/dkms/rtl8821CU/5.2.5.3/build/core/rtw_cmd.o' failed
make[2]: *** [/var/lib/dkms/rtl8821CU/5.2.5.3/build/core/rtw_cmd.o] Error 1
Makefile:1535: recipe for target 'module/var/lib/dkms/rtl8821CU/5.2.5.3/build' failed
make[1]: *** [module/var/lib/dkms/rtl8821CU/5.2.5.3/build] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.14.98-v7+'
Makefile:1923: recipe for target 'modules' failed
make: *** [modules] Error 2

@buzzy
Copy link
Author

buzzy commented Apr 21, 2019

I tried commenting out the "mfloat-abi=hard" in the Makefile. Ran "make clean" and tried compiling again. Same error.

@buzzy
Copy link
Author

buzzy commented Apr 21, 2019

root@raspberrypi:/opt/rtl8821CU# uname -a
Linux raspberrypi 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l GNU/Linux

@buzzy
Copy link
Author

buzzy commented Apr 22, 2019

Got it working by doing a manual "make" and "make install". Seems the dkms-part is broken.

@saulable
Copy link

Can you please explain how got it working with the manual install?

I'm getting gcc: error: unrecognized command line option '-mgeneral-regs-only'

@buzzy
Copy link
Author

buzzy commented Apr 29, 2019

I did not do anything special. Just ran "make" instead of compiling through dkms.

@marki2239
Copy link

hi im having the same problem and manual sudo make doesnt work.. Any suggestions?

@sanjuruk
Copy link

I get the same error

gcc: error: -mfloat-abi=soft and -mfloat-abi=hard may not be used together

My environment: Orange Pi Zero, Kernal 4.19.62-sunxi, Ubuntu 18.04.3 boinic

I tried commenting out the "mfloat-abi=hard" in the Makefile. Ran "make clean" and tried compiling again. Same error.

I find the same error too.

I run just "make" too. But the problem persists.

@sanjuruk
Copy link

I managed to solve the compilation issue.
Please refer the following fork I created. You can use the below forked repository to compile without "gcc: error: -mfloat-abi=soft and -mfloat-abi=hard may not be used together" error.

https://github.com/sunzone93/rtl8821CU

All the best!

@shivan
Copy link

shivan commented Nov 12, 2019

@sunzone93 was this on rpi3b?
I'm trying your version on rpi3b... but still some errors.
First in line 1924 there were spaces instead of tabs

@sanjuruk
Copy link

@shivan thanks for the check. I fixed the spaces.
I tested this on Orange Pi Zero. Haven't tested on rpi3b yet.
I will update you soon after testing on rpi3b

@shivan
Copy link

shivan commented Mar 19, 2020

@sunzone93 would be great to have this working, as I already tried several other sources, with bad luck :-(

@sanjuruk
Copy link

sanjuruk commented Mar 23, 2020

Hi @shivan I managed to compile the library for RPi3b with following steps.

  1. install kernel headers
sudo apt install raspberrypi-kernel-headers
  1. Fork the git library
git clone https://github.com/sunzone93/rtl8821CU.git
  1. Use following commands in source the directory (cd rtl8821CU)
make
sudo make install
sudo modprobe 8821cu

*Don't update the Makefile for CONFIG_PLATFORM_ARM_RPI3 = y. Keep the default options. When this option is enabled (error: unrecognized command line option ‘-mgeneral-regs-only’) gcc error occurs. You may follow this.

  1. Check whether the driver is installed properly
ls /lib/modules/$(uname -r)/kernel/drivers/net/wireless

Make sure 8821cu.ko file present on that directory

I updated my repository to fix several bugs. So you may re-clone my repo again!

Please let me know how it goes~

@shivan
Copy link

shivan commented Mar 26, 2020

Hi,

thanks for your update. Now I get this:

pi@rover:~/white $ sudo apt install raspberrypi-kernel-headers
Reading package lists... Done
Building dependency tree
Reading state information... Done
raspberrypi-kernel-headers is already the newest version (1.20200212-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
pi@rover:~/white $ git clone https://github.com/whitebatman2/rtl8821CU.git
Cloning into 'rtl8821CU'...
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 666 (delta 0), reused 0 (delta 0), pack-reused 665
Receiving objects: 100% (666/666), 3.31 MiB | 2.10 MiB/s, done.
Resolving deltas: 100% (246/246), done.
pi@rover:~/white $ cd rtl8821CU/
pi@rover:~/white/rtl8821CU $ ls
clean  core  dkms.conf  hal  ifcfg-wlan0  include  Kconfig  LICENSE  Makefile  os_dep  platform  README.md  rtl8821c.mk  runwpa  wlan0dhcp
pi@rover:~/white/rtl8821CU $ make
make ARCH=armv7l CROSS_COMPILE= -C /lib/modules/4.19.93-v7+/build M=/home/pi/white/rtl8821CU  modules
make[1]: *** /lib/modules/4.19.93-v7+/build: No such file or directory.  Stop.
make: *** [Makefile:1923: modules] Error 2
pi@rover:~/white/rtl8821CU $

What's the problem now? looks like it is missing some libraries?

@sanjuruk
Copy link

@shivan please clone my fork and test.

git clone https://github.com/sunzone93/rtl8821CU.git

@shivan
Copy link

shivan commented Mar 26, 2020

@sunzone93 oops, sorry.

Ok, used your fork.

pi@rover:~/white $ git clone https://github.com/sunzone93/rtl8821CU.git
Cloning into 'rtl8821CU'...
remote: Enumerating objects: 36, done.
remote: Counting objects: 100% (36/36), done.
remote: Compressing objects: 100% (34/34), done.
remote: Total 687 (delta 19), reused 3 (delta 2), pack-reused 651
Receiving objects: 100% (687/687), 3.35 MiB | 2.46 MiB/s, done.
Resolving deltas: 100% (257/257), done.
pi@rover:~/white $ cd rtl8821CU/
pi@rover:~/white/rtl8821CU $ ls
clean  core  dkms.conf  hal  ifcfg-wlan0  include  Kconfig  LICENSE  Makefile  os_dep  platform  README.md  rtl8821c.mk  runwpa  wlan0dhcp
pi@rover:~/white/rtl8821CU $ make
sudo cp /lib/modules/4.19.93-v7+/build/arch/arm/Makefile /lib/modules/4.19.93-v7+/build/arch/arm/Makefile.202003260645
cp: cannot stat '/lib/modules/4.19.93-v7+/build/arch/arm/Makefile': No such file or directory
make: *** [Makefile:1923: modules] Error 1
pi@rover:~/white/rtl8821CU $

But not better. Why is it missing that directory. Solution in the web is mostly to install raspberrypi-kernel-headers. Which is already installed.

@sanjuruk
Copy link

@shivan may be follow this and see? I will take a look into it over this weekend.

@sanjuruk
Copy link

can you try to compile as the superuser (after sudo su)? or try with sudo make ?
I am not in a proper environment to test rn.

@sanjuruk
Copy link

if you can, also test after changing Makefile line 1923 with sudo cp '/lib/modules/$(KVER)/build/arch/arm/Makefile' /lib/modules/$(KVER)/build/arch/arm/Makefile.$(shell date +%Y%m%d%H%M)
ref: 1, 2

@shivan
Copy link

shivan commented Mar 26, 2020

mhm something interesting...

/lib/modules/4.19.97-v7+

exists.

but uname -r returns
4.19.93-v7+

so my modules are newer than the running kernel?

I'll reboot...

@shivan
Copy link

shivan commented Mar 26, 2020

wohoo reboot... now "make" is doing something :)

(I removed the folders which were created by getting kernel sources from that other link)

my lession for today:
always do a reboot after "apt-get update;apt-get upgrade;apt-get dist-upgrade" ...


and the driver is now present...

ls /lib/modules/$(uname -r)/kernel/drivers/net/wireless
...
8821cu.ko 
...

time to test the adapter again :)

Next update:

after calling

sudo usb_modeswitch -KW -v 0bda -p 1a2b

my adapter now switched to network device mode and yeeha:

There it is:

pi@rover:~/white/rtl8821CU $ lsusb
Bus 001 Device 006: ID 0bda:c811 Realtek Semiconductor Corp.

There it is connected:

pi@rover:~/white/rtl8821CU $ iwconfig

wlan1     IEEE 802.11AC  ESSID:"XXXX"  Nickname:"<WIFI@REALTEK>"
          Mode:Managed  Frequency:5.24 GHz  Access Point: B4:FB:E4:CF:6C:XX
          Bit Rate:200 Mb/s   Sensitivity:0/0
          Retry:off   RTS thr:off   Fragment thr:off
          Power Management:off
          Link Quality=67/100  Signal level=42/100  Noise level=0/100
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

GREAT! MANY THANKS!!

so your description here was the solution
#29 (comment)

@ZhipengRobot
Copy link

Hi @shivan I managed to compile the library for RPi3b with following steps.

  1. install kernel headers
sudo apt install raspberrypi-kernel-headers
  1. Fork the git library
git clone https://github.com/sunzone93/rtl8821CU.git
  1. Use following commands in source the directory (cd rtl8821CU)
make
sudo make install
sudo modprobe 8821cu

*Don't update the Makefile for CONFIG_PLATFORM_ARM_RPI3 = y. Keep the default options. When this option is enabled (error: unrecognized command line option ‘-mgeneral-regs-only’) gcc error occurs. You may follow this.

  1. Check whether the driver is installed properly
ls /lib/modules/$(uname -r)/kernel/drivers/net/wireless

Make sure 8821cu.ko file present on that directory

I updated my repository to fix several bugs. So you may re-clone my repo again!

Please let me know how it goes~

I tried sunzone93's solution on raspi CM3, it works!
Thank you very much!

@AverageMaker
Copy link

I seem to get near the end of sunzone's method and I get an error saying that it can't locate the 8821cu.ko file. Anyone else had this or know the fix?

@sanjuruk
Copy link

I seem to get near the end of sunzone's method and I get an error saying that it can't locate the 8821cu.ko file. Anyone else had this or know the fix?

@AverageMaker please share your test environment

@AverageMaker
Copy link

AverageMaker commented Aug 14, 2020

I'm using a Raspberry Pi 3B+ with a clean (new) copy of the latest Raspberry Pi OS installed from a new NOOBS image (3.4.0). I'll need to check kernel versions when I get home. Nothing else is attached apart from keyboard and mouse. Using this RTL8811cu adapter: https://thepihut.com/products/raspberry-pi-dual-band-5ghz-2-4ghz-usb-wifi-adapter-with-antenna

@AverageMaker
Copy link

I seem to get near the end of sunzone's method and I get an error saying that it can't locate the 8821cu.ko file. Anyone else had this or know the fix?

@AverageMaker please share your test environment

Also noticed that this is likely to do with the latest (20th Aug) Raspberry Pi OS version shipping with Linux kernel 5.4.51, whereas previously this was on 4.19.118. Since that kernel change the driver no longer works.,

I'm no expert on drivers and kernels - is this something that can easily be resolved? Do we need to wait for Realtek to release an updated driver or can we tweak the current driver to work with the newer Linux kernel?

@sanjuruk
Copy link

Yes. Currently the driver doesn't support the new kernel.
I will try to port it in my free time.

@sp1d3rino
Copy link

I have changed the Makefile to build for RPI. Still I get error that "armv71" dir does not exist.
Adding "ARCH=arm" in front of the build command fixed this error, but introduces another compile error.

DKMS make.log for rtl8821CU-5.2.5.3 for kernel 4.14.98-v7+ (armv7l)
Sun 21 Apr 19:57:20 BST 2019
make ARCH=armv7l CROSS_COMPILE= -C /lib/modules/4.14.98-v7+/build M=/var/lib/dkms/rtl8821CU/5.2.5.3/build modules
make[1]: Entering directory '/usr/src/linux-headers-4.14.98-v7+'
Makefile:646: arch/armv7l/Makefile: No such file or directory
make[1]: *** No rule to make target 'arch/armv7l/Makefile'. Stop.
make[1]: Leaving directory '/usr/src/linux-headers-4.14.98-v7+'
Makefile:1923: recipe for target 'modules' failed
make: *** [modules] Error 2

DKMS make.log for rtl8821CU-5.2.5.3 for kernel 4.14.98-v7+ (armv7l)
Sun 21 Apr 19:59:56 BST 2019
make ARCH=arm CROSS_COMPILE= -C /lib/modules/4.14.98-v7+/build M=/var/lib/dkms/rtl8821CU/5.2.5.3/build modules
make[1]: Entering directory '/usr/src/linux-headers-4.14.98-v7+'
CC [M] /var/lib/dkms/rtl8821CU/5.2.5.3/build/core/rtw_cmd.o
gcc: error: -mfloat-abi=soft and -mfloat-abi=hard may not be used together
scripts/Makefile.build:326: recipe for target '/var/lib/dkms/rtl8821CU/5.2.5.3/build/core/rtw_cmd.o' failed
make[2]: *** [/var/lib/dkms/rtl8821CU/5.2.5.3/build/core/rtw_cmd.o] Error 1
Makefile:1535: recipe for target 'module/var/lib/dkms/rtl8821CU/5.2.5.3/build' failed
make[1]: *** [module/var/lib/dkms/rtl8821CU/5.2.5.3/build] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.14.98-v7+'
Makefile:1923: recipe for target 'modules' failed
make: *** [modules] Error 2

  1. vi Makefile
  2. search for -mfloat-abi field and change hard to soft
  3. save & restart make

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants