daBee
Posts: 82
Joined: Fri Mar 06, 2015 8:25 pm
Location: Toronto
Contact: Website

RP4 WiFi Realtek Dongle Installation

Thu Apr 08, 2021 6:18 pm

For some reason I can't get an external WiFi dongle to be recognized. I can only see the onboard wifi solution

Code: Select all

$ iw dev
phy#0
	Interface wlan0
		ifindex 3
		wdev 0x1
		addr dc:a6:32:68:fa:f1
		type managed
		channel 34 (5170 MHz), width: 20 MHz, center1: 5170 MHz
		
$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 0bda:c811 Realtek Semiconductor Corp.			## this is the WiFi dongle
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
I've installed firmware-realtek but that hasn't changed anything.

Found a driver, tried to install it, changed the Makefile for ARM install, but errors:

Code: Select all

 git clone https://github.com/brektrou/rtl8821CU.git
cd rtl8821CU
chmod +x dkms-install.sh
sudo ./dkms-install.sh
Result:

Code: Select all

out to run dkms install steps...
Error! DKMS tree already contains: rtl8821CU-5.4.1
You cannot add the same module/version combo more than once.

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area...
'make' KVER=5.10.17-v7l+.....(bad exit status: 2)
Error! Bad return status for module build on kernel: 5.10.17-v7l+ (armv7l)
Consult /var/lib/dkms/rtl8821CU/5.4.1/build/make.log for more information.

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area...
'make' KVER=5.10.17-v7l+.....(bad exit status: 2)
Error! Bad return status for module build on kernel: 5.10.17-v7l+ (armv7l)
Consult /var/lib/dkms/rtl8821CU/5.4.1/build/make.log for more information.
Finished running dkms install steps.

$ cat /var/lib/dkms/rtl8821CU/5.4.1/build/make.log
DKMS make.log for rtl8821CU-5.4.1 for kernel 5.10.17-v7l+ (armv7l)
Thu 08 Apr 2021 02:14:32 PM EDT
make ARCH=armv7l CROSS_COMPILE= -C /lib/modules/5.10.17-v7l+/build M=/var/lib/dkms/rtl8821CU/5.4.1/build  modules
make[1]: Entering directory '/usr/src/linux-headers-5.10.17-v7l+'
Makefile:681: 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-5.10.17-v7l+'
make: *** [Makefile:2212: modules] Error 2
So can't get past the make. Not sure what to do at this point.

Anybody have any insight? I appreciate any notes.

Cheers

fruitoftheloom
Posts: 26815
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: RP4 WiFi Realtek Dongle Installation

Thu Apr 08, 2021 6:50 pm

.
Removed see next response....
Last edited by fruitoftheloom on Thu Apr 08, 2021 7:49 pm, edited 1 time in total.
The information is out there....you just have to let it in.

My other Linux machines: ChromeBox
https://www.aliexpress.com/item/32966393971.html
& Stone Desktop Intel CoreDuo circa 2010

MrEngman
Posts: 4140
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: RP4 WiFi Realtek Dongle Installation

Thu Apr 08, 2021 7:33 pm

I compile several different out of tree wifi drivers and I am using one of those wifi modules on a Pi4B 8Gb using the 8821cu driver.

I have the drivers available on my web site http://downloads.fars-robotics.net/wifi-drivers and have a script that can download and install the wifi drivers. You can install the script and download and install the driver using commands

Code: Select all

sudo wget http://downloads.fars-robotics.net/wifi-drivers/install-wifi -O /usr/bin/install-wifi
sudo chmod +x /usr/bin/install-wifi
sudo install-wifi
Details on using the script can be seen using command

Code: Select all

sudo install-wifi -h

MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

daBee
Posts: 82
Joined: Fri Mar 06, 2015 8:25 pm
Location: Toronto
Contact: Website

Re: RP4 WiFi Realtek Dongle Installation

Thu Apr 08, 2021 9:54 pm

Now I'm confused. Same person posting? I followed the first instructions and it installed. Nothing came out of it though.

Ah I see what you have done. A master install. This is much better. Might want to include a suggestion for a

Code: Select all

sudo reboot
OK, things look ok, but I was hoping for this unit to be able to monitor:

Code: Select all

$ rfkill list
0: phy0: Wireless LAN
	Soft blocked: no
	Hard blocked: no
1: phy1: Wireless LAN
	Soft blocked: no
	Hard blocked: no
2: hci0: Bluetooth
	Soft blocked: no
	Hard blocked: no

$ iw dev
phy#1
	Interface wlx1cbfcee6a146						# dongle
		ifindex 4
		wdev 0x100000001
		addr 1c:bf:ce:e6:a1:46
		type managed
		txpower 12.00 dBm
phy#0
	Interface wlan0
		ifindex 3
		wdev 0x1
		addr dc:a6:32:68:fa:f1
		type managed
		channel 34 (5170 MHz), width: 20 MHz, center1: 5170 MHz
kismet needs a monitor device. Is this possible?

daBee
Posts: 82
Joined: Fri Mar 06, 2015 8:25 pm
Location: Toronto
Contact: Website

Re: RP4 WiFi Realtek Dongle Installation

Fri Apr 09, 2021 3:11 pm

Apparently monitor mode is disabled by default in Makefile. It seems you've compiled your own, so this needs to be redone.

Code: Select all

## get driver
mkdir -p ~/build
cd ~/build
git clone https://github.com/brektrou/rtl8821CU.git

## set monitor
sudo ip link set wlx1cbfcee6a146 down
sudo iw wlx1cbfcee6a146 set monitor none
sudo ip link set wlx1cbfcee6a146 up

$ iw dev
phy#1
	Interface wlx1cbfcee6a146
		ifindex 4
		wdev 0x100000001
		addr 1c:bf:ce:e6:a1:46
		type monitor
		txpower 12.00 dBm
phy#0
	Interface wlan0
		ifindex 3
		wdev 0x1
		addr dc:a6:32:68:fa:f1
		type managed
		channel 34 (5170 MHz), width: 20 MHz, center1: 5170 MHz

MrEngman
Posts: 4140
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: RP4 WiFi Realtek Dongle Installation

Fri Apr 09, 2021 4:43 pm

In the source I have monitor mode is enabled by default.

In the Makefile I have

Code: Select all

CONFIG_BR_EXT = y
CONFIG_TDLS = n
CONFIG_WIFI_MONITOR = y
CONFIG_MCC_MODE = n
CONFIG_APPEND_VENDOR_IE_ENABLE = n

MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

MrEngman
Posts: 4140
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: RP4 WiFi Realtek Dongle Installation

Fri Apr 09, 2021 5:03 pm

I don't know how monitor mode works but I appear to be able to enable it as follows without making any changes to the driver source.

Before setting monitor mode

Code: Select all

pi@Pi-4B-8GB:~ $ iw dev
phy#1
        Interface wlan1
                ifindex 4
                wdev 0x100000001
                addr 00:e0:32:40:23:5e
                type managed
                txpower 12.00 dBm
phy#0
        Unnamed/non-netdev interface
                wdev 0x2
                addr de:a6:32:ae:8b:91
                type P2P-device
                txpower 31.00 dBm
        Interface wlan0
                ifindex 3
                wdev 0x1
                addr dc:a6:32:ae:8b:91
                ssid MYON3
                type managed
                channel 36 (5180 MHz), width: 40 MHz, center1: 5190 MHz
                txpower 31.00 dBm
and then setting monitor mode

Code: Select all

pi@Pi-4B-8GB:~ $ sudo ip link set wlan1 down
pi@Pi-4B-8GB:~ $ sudo iw wlan1 set monitor none
pi@Pi-4B-8GB:~ $ sudo ip link set wlan1 up
pi@Pi-4B-8GB:~ $ iw dev
phy#1
        Interface wlan1
                ifindex 4
                wdev 0x100000001
                addr 00:e0:32:40:23:5e
                type monitor
                txpower 12.00 dBm
phy#0
        Unnamed/non-netdev interface
                wdev 0x2
                addr de:a6:32:ae:8b:91
                type P2P-device
                txpower 31.00 dBm
        Interface wlan0
                ifindex 3
                wdev 0x1
                addr dc:a6:32:ae:8b:91
                ssid MYON3
                type managed
                channel 36 (5180 MHz), width: 40 MHz, center1: 5190 MHz
                txpower 31.00 dBm
pi@Pi-4B-8GB:~ $
Can you explain how I can check it is working?

MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

daBee
Posts: 82
Joined: Fri Mar 06, 2015 8:25 pm
Location: Toronto
Contact: Website

Re: RP4 WiFi Realtek Dongle Installation

Fri Apr 09, 2021 8:57 pm

Ya your type is still managed. Needs to be either monitor or promiscuous.

Mine was managed until those last 3 commands:

Code: Select all

## set monitor
sudo ip link set wlx1cbfcee6a146 down
sudo iw wlx1cbfcee6a146 set monitor none
sudo ip link set wlx1cbfcee6a146 up
Strange interface name, as well.

Just so that you know, my unit won't respond on eth0 now. So I get to turn off the interface in /etc/network/interfaces and troubleshoot. Second time now, but first after setting to monitor. I'm troubleshooting on the allow-hotplug.

MrEngman
Posts: 4140
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: RP4 WiFi Realtek Dongle Installation

Sat Apr 10, 2021 9:10 am

Before setting monitor mode wlan1 on my Pi it shows managed, but after using commands

Code: Select all

sudo ip link set wlan1 down
sudo iw wlan1 set monitor none
sudo ip link set wlan1 up
it shows wlan1 is set in monitor mode

Code: Select all

iw dev
phy#1
        Interface wlan1
                ifindex 4
                wdev 0x100000001
                addr 00:e0:32:40:23:5e
                type monitor
                txpower 12.00 dBm
phy#0
        Unnamed/non-netdev interface
                wdev 0x2
                addr de:a6:32:ae:8b:91
                type P2P-device
                txpower 31.00 dBm
        Interface wlan0
                ifindex 3
                wdev 0x1
                addr dc:a6:32:ae:8b:91
                ssid MYON3
                type managed
                channel 36 (5180 MHz), width: 40 MHz, center1: 5190 MHz
                txpower 31.00 dBm

MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

MrEngman
Posts: 4140
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: RP4 WiFi Realtek Dongle Installation

Sat Apr 10, 2021 9:28 am

The strange network interface names are predictable names using the MAC addresses of the wifi interfaces as the names.

You can change the names using command

Code: Select all

sudo raspi-config
and then select option

Code: Select all

6 Advanced names
, then select option

Code: Select all

A4 Network Interface Names Enable/disable predictable network i/f names 
and then select NO.

This should change names to wlan0/1.


MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

daBee
Posts: 82
Joined: Fri Mar 06, 2015 8:25 pm
Location: Toronto
Contact: Website

Re: RP4 WiFi Realtek Dongle Installation

Wed Apr 14, 2021 8:46 pm

OK, can't seem to get this to work:

Code: Select all

$ iw dev
phy#1
	Interface wlan1
		ifindex 4
		wdev 0x100000001
		addr 1c:bf:ce:e6:a1:46
		type managed
		txpower 12.00 dBm
phy#0
	Interface wlan0
		ifindex 3
		wdev 0x1
		addr dc:a6:32:68:fa:f1
		type managed
		channel 34 (5170 MHz), width: 20 MHz, center1: 5170 MHz
$ sudo iwconfig wlan1 mode monitor
Error for wireless request "Set Mode" (8B06) :
    SET failed on device wlan1 ; Operation not permitted.
Entered this and rebooted, and the unit wouldn't start up:

Code: Select all

allow-hotplug wlan1
 iface wlan1 inet manual
 pre-up iw phy phy0 interface add mon1 type monitor
 pre-up iw dev wlan1 del
 pre-up ifconfig mon1 up
At this point I don't know what to do. Seems like it's stuck.

MrEngman
Posts: 4140
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: RP4 WiFi Realtek Dongle Installation

Wed Apr 14, 2021 9:17 pm

To turn on monitor mode I use the commands

Code: Select all

sudo ip link set wlan1 down   # turn off wlan1 wifi
sudo iw wlan1 set monitor none   # set monitor mode
sudo ip link set wlan1 up   # turn on wlan1 wifi
as I show in my previous post. If I try and set monitor mode just using command

Code: Select all

sudo iw wlan1 set monitor none
without first stopping wlan1 wifi I also get an error similar to the one you show in your previous post.

So it looks like you need to stop the wifi before setting monitor mode. I am not familiar with the commands you are using to set monitor mode.


MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

daBee
Posts: 82
Joined: Fri Mar 06, 2015 8:25 pm
Location: Toronto
Contact: Website

Re: RP4 WiFi Realtek Dongle Installation

Fri Apr 16, 2021 10:10 am

OK, this is what I have and it's hanging the startup, trying to launch a network interface. When commented out, it starts up fine:

Code: Select all

allow-hotplug wlan1
 iface wlan1 inet manual
 pre-up iw phy phy1 interface add mon1 type monitor
 pre-up iw dev wlan1 del
 pre-up ifconfig mon1 up
Been reading some confusing notes on this /etc/network/interfaces file. From some time back actually. viewtopic.php?t=251021

I need this to be active when I unplug the unit and plug it back in. I can't enter anything as the unit is headless. I'm rebooting and finding wlan1 moving back to managed:

Code: Select all

iface wlan1 inet manual
 pre-up ifconfig wlan1 down
 iw wlan1 set monitor none
 pre-up ifconfig wlan1 up
 post-down ifconfig wlan1 down

MrEngman
Posts: 4140
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: RP4 WiFi Realtek Dongle Installation

Fri Apr 16, 2021 10:44 am

OK, i also see the wlan1 wifi is in managed mode when I reboot.

However I found a way to get it to boot with the wifi in monitor mode. I edited file /etc/rc.local and added to following lines to the end of the file before the line exit 0

Code: Select all

sudo ip link set wlan1 down
iw wlan1 set monitor none
ip link set wlan1 up
Then when I reboot wlan1 wifi is in monitor mode.



MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

daBee
Posts: 82
Joined: Fri Mar 06, 2015 8:25 pm
Location: Toronto
Contact: Website

Re: RP4 WiFi Realtek Dongle Installation

Fri Apr 16, 2021 2:26 pm

Excellent. Looks like it's working. /etc/network/interfaces:

Code: Select all

iface wlan1 inet manual
 pre-up ifconfig wlan1 down
 iw wlan1 set monitor none
 pre-up ifconfig wlan1 up
 post-down ifconfig wlan1 down
/etc/rc.local:

Code: Select all

sudo ip link set wlan1 down
iw wlan1 set monitor none
ip link set wlan1 up

Code: Select all

$ iw dev
phy#1
	Interface wlan1
		ifindex 4
		wdev 0x100000001
		addr 1c:bf:ce:e6:a1:46
		type monitor
		txpower 12.00 dBm
phy#0
	Interface wlan0
		ifindex 3
		wdev 0x1
		addr dc:a6:32:68:fa:f1
		type managed
		channel 34 (5170 MHz), width: 20 MHz, center1: 5170 MHz
Last edited by daBee on Fri Apr 30, 2021 3:46 pm, edited 1 time in total.

daBee
Posts: 82
Joined: Fri Mar 06, 2015 8:25 pm
Location: Toronto
Contact: Website

Re: RP4 WiFi Realtek Dongle Installation

Sat Apr 17, 2021 5:10 am

OK, got things semi-working. The GPS unit, using gpsmon through gpsd, is getting signal, but has no Az or El.:
Screen Shot 2021-04-17 at 1.05.16 AM.png
Screen Shot 2021-04-17 at 1.05.16 AM.png (28.21 KiB) Viewed 365 times
Screen Shot 2021-04-17 at 1.05.08 AM.png
Screen Shot 2021-04-17 at 1.05.08 AM.png (44.08 KiB) Viewed 365 times

daBee
Posts: 82
Joined: Fri Mar 06, 2015 8:25 pm
Location: Toronto
Contact: Website

Re: RP4 WiFi Realtek Dongle Installation

Sun Apr 18, 2021 5:09 pm

Fixed with a GPS configuration and moving closer to the window...not sure what did it.

MrEngman
Posts: 4140
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: RP4 WiFi Realtek Dongle Installation

Sun Apr 18, 2021 6:09 pm

OK, makes sense. I remember seeing various posts that recommend using a Pi with GPS outdoors because of GPS signal loss if used indoors.


MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

daBee
Posts: 82
Joined: Fri Mar 06, 2015 8:25 pm
Location: Toronto
Contact: Website

Re: RP4 WiFi Realtek Dongle Installation

Mon Apr 19, 2021 12:58 am

Thing is, I use a GPS indoors for the past 10 years or more. I also changed something by asking it not to return confusing messages. But all of a sudden all data appeared. Heh.

daBee
Posts: 82
Joined: Fri Mar 06, 2015 8:25 pm
Location: Toronto
Contact: Website

Re: RP4 WiFi Realtek Dongle Installation

Wed Apr 28, 2021 6:05 pm

OK, more problems.

First, eth0 stopped working. I was told that /etc/network/interfaces should be replaced with /etc/dhcpcd.conf should be used. So I shoved the interface directives over there and she worked fine.

Now I am starting kismet and I'm getting no recognition from the WiFi dongle monitor. Should I put the wlan1 directives in that same file?

Code: Select all

iface wlan1 inet manual
 pre-up ifconfig wlan1 down
 iw wlan1 set monitor none
 pre-up ifconfig wlan1 up
 post-down ifconfig wlan1 down
I just got it going with your last directives:

Code: Select all

sudo ip link set wlan1 down
sudo iw wlan1 set monitor none
sudo ip link set wlan1 up
Let's see if she sticks.

Update: wlan1 goes back to managed instead of monitor. I looked at /etc/rc.local and it had the proper entry:

Code: Select all

## wlan1 stuff for monitoring
sudo ip link set wlan1 down
sudo iw wlan1 set monitor none
sudo ip link set wlan1 up
Not sure why it's not sticking. Any idea?

Code: Select all

$ iw dev
phy#1
	Interface wlan1
		ifindex 4
		wdev 0x100000001
		addr 1c:bf:ce:e6:a1:46
		type managed
		txpower 12.00 dBm
phy#0
	Unnamed/non-netdev interface
		wdev 0x2
		addr de:a6:32:68:fa:f1
		type P2P-device
		txpower 31.00 dBm
	Interface wlan0
		ifindex 3
		wdev 0x1
		addr dc:a6:32:68:fa:f1
		type managed
		channel 34 (5170 MHz), width: 20 MHz, center1: 5170 MHz
		txpower 31.00 dBm

daBee
Posts: 82
Joined: Fri Mar 06, 2015 8:25 pm
Location: Toronto
Contact: Website

Re: RP4 WiFi Realtek Dongle Installation

Fri Apr 30, 2021 3:51 pm

Ya it's not working anymore. /etc/network/interfaces was replaced with /etc/dhcpcd.conf as per previous post: 16 Apr 2021, 10:26

On reboot:

Code: Select all

$ iw dev
phy#1
	Interface wlan1
		ifindex 4
		wdev 0x100000001
		addr 1c:bf:ce:e6:a1:46
		type managed
		txpower 12.00 dBm
phy#0
	Unnamed/non-netdev interface
		wdev 0x2
		addr de:a6:32:68:fa:f1
		type P2P-device
		txpower 31.00 dBm
	Interface wlan0
		ifindex 3
		wdev 0x1
		addr dc:a6:32:68:fa:f1
		type managed
		channel 34 (5170 MHz), width: 20 MHz, center1: 5170 MHz
		txpower 31.00 dBm
Not sure why it switched back to managed. Any idea why it has done that?

Update: This is the proper entry. if and iw are similar but not functionally the same:

Code: Select all

sudo ip link set wlan1 down
sudo iw dev wlan1 set type monitor
sudo ip link set wlan1 up

Return to “Troubleshooting”