Rpi 3 and WiFi Dongle

I have my Rpi 3 / Volumio in a nice metal case. That doesn’t play well with the built-in WiFi.

So … how do I get Volumio to use my WiFi dongle (wlan1) rather than wlan0?

(I did see some earlier threds but they weren’t helpful / or maybe I wasn’t understanding, so I could use a better explanation.)

Thanks!

One solution proposed here https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=138610 is to blacklist the drivers.

@jncraig

Which Volumio version are you using?
Recent versions (2.114 and on) has implemented something to try to handle such case by blacklisting drivers by default (with some shortcomings).
Is it a version you are using?

If you are using such version and USB dongle is still on wlan1, can you do the following once connected under SSH?cat /etc/udev/rules.d/75-persistent-net-generator.rules sudo rm /etc/udev/rules.d/75-persistent-net-generator.rulesand report what cat command returned.
Then you may restart your Pi with the dongle pluged-in, and see if your dongle gets to wlan0 (rm command may resolve the problem alone).

Can you please report again the following after reboot (another one must have been created): cat /etc/udev/rules.d/75-persistent-net-generator.rules If rm did not solve the problem, we will then edit the file with some other information…

Thanks for your feedback: this may help improving the workaround.

EDIT: for typo in actual file name

I am using the previous version mainly because the issue installing the Touch Display plugin.

If I get some time over the weekend, I will set up a clean install of the current version (2.118?) and do some testing with your suggestions.

Thanks.

Plugin has been adapted to work now with 2.118, so you may use that version.
Looking forward your feedback.

I have a 2.1.4 with the Touch Display installed. Can I upgrade it? Or would it make more sense to start with a clean install of 2.118?

I did a clean install of 2.118 and installed the Touch Display plugin with zero problems.

About blacklisting the drivers - when I took at look at /etc/modprobe.d/raspi-blacklist.conf, the two lines to blacklist the wifi drivers are there, but it looks like they are loaded anyway.

Is there something else that I need to do?

I have no file named /etc/udev/rules.d/70-persistent-net.rules.

Using a different Pi3 running the current Raspbian/Pixel OS, both the method for blacklisting drivers, or using dtoverlay=pi3-disable-wifi in /boot/config.txt work perfectly.

So, I’m assuming that the older Raspbian version on which Volumio 2 is built do not support either of these methods.

I sure would appreciate it if someone could confirm this?

And, is there a third method?

Yes may probably work for Volumio2 in principle (provided you also add this file to the /boot/overlays folder - unsure Volumio 4.4.9 kernel will support it though): it’s a quite radical method indeed, but worth considering in your specific case.
However, note that eventual DAC config changes may currently alter /boot/config.txt: so any change you make to /boot/config.txt may be wiped if you change DAC settings (not the thing you change everyday though, but good to know…).

The udev rules method may be interesting as it would allow to set wlan0 to the interface of your choice: be it built-in chipset or USB dongle, without tuning off the other one you may want to keep using for other reason.
My earlier question is gated to understanding if any rule may be set for your dongle (search by name, by driver etc) to get that to wlan0 at boot.

Driver unload/load option is possible but would be overruled anyway if any rule is set. Also the way it currently operates may not be optimal

Appreciate your patience in providing the info I asked for, in order to figure-out that rules method or help optimize the driver unload/load method.

Sorry, file name is actually 75-persistent-net-generator.rules
Can you also ls -la /etc/udev/rules.d/ on both Volumio and Raspian images and show what you get (and eventually cat the files whose names are related to net or your dongle brand name?

Well, adding that file results in me having a single wlan connection: wlan0! Thanks!

Raspberry Pi running Volumio (Edimax WiFi dongle)

volumio@volumio:~$ ls -la /etc/udev/rules.d/
total 1
drwxr-xr-x 2 root root 79 Mar 7 14:02 .
drwxr-xr-x 4 root root 61 Jan 15 03:28 …
-rw-r–r-- 1 root root 2 Mar 7 13:59 75-persistent-net-generator.rules
-rw-r–r-- 1 root root 79 Mar 7 14:02 95-ralink.rules

volumio@volumio:/etc/udev/rules.d$ cat 7*

volumio@volumio:/etc/udev/rules.d$ cat 9*
ACTION==“add”, SUBSYSTEM==“net”, ATTR{type}==“1”, KERNEL==“ra*”, NAME=“wlan0”

Raspberry Pi running Raspbian (Pi 3 with internal WiFi)

pi@raspberrypi:~ $ ls -la /etc/udev/rules.d/
total 16
drwxr-xr-x 2 root root 4096 Dec 31 1969 .
drwxr-xr-x 4 root root 4096 Dec 31 1969 …
-rw-r–r-- 1 root root 114 Sep 22 23:52 40-scratch.rules
-rw-r–r-- 1 root root 983 Sep 16 09:33 99-com.rules

Great: that file is missing in default Volumio image as this 4.4.x overlay was introduced after kernel 4.4.9: it is required so that related dtoverlay directive in /boot/config.txt has any effect. It might remain your preferred solution in your (metal :wink: ) case.

Now, could you please try the following on Volumio2 image to help improve more generic cases? sudo sh -c 'echo "ACTION==\"add\", SUBSYSTEM==\"net\", ATTR{type}==\"1\", DRIVERS==\"rtl*\", NAME=\"wlan0\"" > /etc/udev/rules.d/70-persistent-net.rules' and (for now) remove the dtoverlay=pi3-disable-wifi statement in /boot/config.text, and reboot.
You would probably still have your Edimax dongle as wlan0 after boot: can you confirm?
Built-in wifi would probably be in wlan1 now…
Could you then give me (in pastebin maybe) the output of the 3 following commands:udevadm info -a /sys/class/net/wlan0 udevadm info -a /sys/class/net/wlan1 udevadm info -a /sys/class/net/eth0

Finally, if you are not tired with it, can you do (still without dtoverlay=pi3-disable-wifi statement) sudo sh -c 'echo "ACTION==\"add\", SUBSYSTEM==\"net\", SUBSYSTEMS==\"usb\", KERNEL==\"wlan*\", ATTR{type}==\"1\", NAME=\"wlan0\"" > /etc/udev/rules.d/70-persistent-net.rules' and then:

  • reboot with Edimax dongle plugged-in -> Edimax should be on wlan0 (and internal on wlan1) (can check with udevadm info /sys/class/net/wlan0 or 1)
  • reboot without Edimax dongle -> internal should be on wlan0

Thanks for your help and confirmation.

Adding the /etc/udev/rules.d/70-persistent-net.rules and removing the dtoverlay in /boot/config.text does result in the behavior you described.

With the wifi dongle (I was actually using the Canakit dongle) plugged in, the dongle is wlan0 and the internal is wlan1.

After removing the dongle and restarting, the internal wifi is wlan0 and there is no wlan1.

I put the results of the 3 commands into a pastebin named jnc-volumio2.

Finally, after the second version of /etc/udev/rules.d/70-persistent-net.rules, the behavior persists correctly. With the dongle it is wlan0 and the internal is wlan1. Without the dongle, the internal takes over wlan0.

Which of those two cases should I use, or does it matter?

And thanks a bundle for your interest and help. I hope my testing helps to make this a stronger product.

The second one is more generic (not geared towards your specific wifi dongle), so is probably better.
However in your case I would agree dtoverlay=pi3-disable-wifi statement in /boot/config.text probably provides additional benefit of turning off internal wifi chip radio. Anyway, both are not conflicting (you may keep the last rule).

Thanks a lot for your patience and willingness to help and contribute to the community: this seems to validate the approach and we’ll do further tests to see if this can be integrated in original image.

@jncraig, may I ask you yet-another test please if you can?
Still removing the previous dtoverlay directive, could you apply the changes below:

sudo mv /etc/modprobe.d/raspi-blacklist.conf /etc/modprobe.d/raspi-blacklist.old sudo cp /bin/wifistart.sh /bin/wifistart.old sudo nano /bin/wifistart.shand comment all the lines, except the last one. Should be like this in the end:[code]
#sudo /sbin/iw dev wlan0 set power_save off

#!/bin/sh
#sudo /sbin/modprobe brcmfmac
#sudo /sbin/modprobe brcmutil
sudo /sbin/iw dev wlan0 set power_save off[/code]then ctrl-o and ctrl-x to save and quit.
Then reset the last rule from previous post if you removed it.
Finally restart the Pi with your Canakit dongle plugged.

At reboot, is your dongle again in wlan0? (you may check by issuing ifconfig command).

Thanks!

PS: I guess you may be able to easily reverse the proposed changes after that test (just reverse the arguments of each of first 2 commands, to restore original files): let me know if you have any difficulty to come back to original settings.

This is a useful feature to use an external WiFi dongle for those of us using metal cases.
Therefore is it possible to request this to be added as a radio button on the networking page in a future release?

@paulf
Please check the first paragraph of this post: its has a solution for you now.
A PR has been submitted for this feature: maybe it will be included in the near future.

We are discussing here another method, which does not turn off wifi radio, but just prioritizes wifi interfaces favoring external interface over internal.
Testing right now, but not ready for prime-time yet.
If you have some wifi dongle and willing to do a bit of testing, welcome!