samothx
Posts: 3
Joined: Tue Jul 21, 2015 8:27 pm

WLAN Adapters in wrong sequence

Fri Dec 09, 2016 3:19 am

Hi,
I have already put a lot of effort into my PI trying to get the following to work and I sort of succeeded but it needs a manual intervention each time to get it going.
I have set up a Pi 2B with two Wifi adapters. One of the adapters I want to use as access point, the other one to connect to an external wifi. I live on a boat and 220 V is only available at a cost (running the generator or an inverter) so I like the idea of having the Pi provide the accespoint and if available connect my devices to a wifi that is usually available in port. I might also try to set the PI up with a 3G/4G dongle.
Now after a lot of effort I am getting this configuration to work, but after booting the hostapd will not start properly.
Starting it manually with log reveals the following lines:

Code: Select all

nl80211: interface wlan1 in phy phy0
nl80211: Set mode ifindex 5 iftype 3 (AP)
nl80211: Failed to set interface 5 to mode 3: -19 (No such device)
nl80211: Could not configure driver mode

Looks to me like it uses an index to access a device and that index is not available.
Now if I remove both USB adapters and the put them back in (wlan0 first then wlan1) it works.
The adapter I use for the hostapd is a Ralink Technology, Corp. RT2870/RT3070 Wireless Adapter on wlan1
The adapter I use to access the port Wifi is a Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]. I did not get that adapter to work with hostapd.
The edimax seems to be a bit special, when I call iw list I get Information for an adapter Wiphy phy1. Before I had the ralink installed I saw nothing at all, so it seems iw does not even recognise the edimax.
Is there a way of making sure that the adapters are correctly associated with the right interfaces and whatever that index might be that hostapd stumbles over is set correctly ?

aBUGSworstnightmare
Posts: 2014
Joined: Tue Jun 30, 2015 1:35 pm

Re: WLAN Adapters in wrong sequence

Fri Dec 09, 2016 5:50 am

use a whitelist -> refer to here for details on how-to viewtopic.php?f=29&t=55527]

samothx
Posts: 3
Joined: Tue Jul 21, 2015 8:27 pm

Re: WLAN Adapters in wrong sequence

Fri Dec 09, 2016 7:21 am

Tried it and it basically works but one of the interfaces does not get configured as in /etc/network/interface. It just stays unconfigured.

Instead I tried out what I found in

https://wiki.archlinux.org/index.php/Ne ... evice_name

Code: Select all

/etc/udev/rules.d/10-network.rules
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="wifi1"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="wifi0"
I read somewhere that this does not work with hotplugging devices but for now it works for me.
I wonder if there is some sort of timing problem in your solution.. Obviously my file starting with 10 comes earlier than the generated udev rules starting with 70... Would your solution support hotplug if I got it work ?

aBUGSworstnightmare
Posts: 2014
Joined: Tue Jun 30, 2015 1:35 pm

Re: WLAN Adapters in wrong sequence

Fri Dec 09, 2016 8:09 am

It's not 'my solution' but I'm using it as well. If you spend a little more effort in configuring it (starting with a clean image basically, configuring one WiFi after the other) this works bullet proof for me. used the same to re-configure RPi3 Wifi to Wlan1 instead of Wlan0 --> Wlan1 is always there (as long as Wifi is not disabled), wlan0 get's configured when attached (based on it's mac address)

aBUGSworstnightmare
Posts: 2014
Joined: Tue Jun 30, 2015 1:35 pm

Re: WLAN Adapters in wrong sequence

Fri Dec 09, 2016 8:14 am

I.e. like this

[check your wifi devices and take a note of the MAC address assigned to wlan0 (onboard wifi of the
RPi3]
iw dev

[disable on-board wlan]
sudo modprobe -r -v brcmfmac

[add wlan devices to whitelist
viewtopic.php?f=29&t=55527]
sudo nano /lib/udev/rules.d/75-persistent-net-generator.rules

# device name whitelist
KERNEL!="ath*|wlan*[0-9]|msh*|ra*|sta*|ctc*|lcs*|hsi*", \
GOTO="persistent_net_generator_end"


[With this modification a file will be generated '/etc/udev/rules.d/70-persistent-net.rules'
which will be used to associate a wifi MAC address with a particular wifi name e.g. wlan0 or
whatever (verify content of '/etc/udev/rules.d/70-persistent-net.rules' with your noted MAC)
Now power down and add the second/next adapter wlanx (only one at a time!).
After restarting the Pi the second/next adapter should be assigned the permanent name wlan1/wlanx.
Review t.he names assigned by viewing the file '/etc/udev/rules/70-persistent-net.rules' and check
which MAC address is assigned to a particular wifi (adapter)name (also check by 'iw list').

[sample '/etc/udev/rules/70-persistent-net.rules' file]
[check with sudo nano /etc/udev/rules.d/70-persistent-net.rules ]
----------
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# Unknown net device (/devices/platform/soc/3f300000.mmc/mmc_host/mmc1/mmc1:0001/mmc1:0001:1/net/wlan0) (brcmfmac_sdio)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="b8:27:eb:ea:fa:c1", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0"

# USB device 0x:0x (rt2800usb)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="24:05:0f:77:b1:d4", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan1"
----------
This is from my notes; possible that some step is missing since I sometimes tend to skip sertain steps in my 'own docu'

samothx
Posts: 3
Joined: Tue Jul 21, 2015 8:27 pm

Re: WLAN Adapters in wrong sequence

Fri Dec 09, 2016 6:07 pm

Thanks for the input. You might be right that I have to start clean, but you know how it is. So much stuff installed that you needed for some reason, if you start from scratch it takes ages till you back to where you were and have everything going again..
My problem might also have to do with the devices I am using.. I will play around some more, maybe get an extra SD card set up for 'clean' install experiments..

Return to “Troubleshooting”