System Details
- Resin OS 2.15.1+rev2 (production)
- Raspberry Pi 3
- Microservice Application
- Supervisor version 7.16.6
- WiFi Adapter: TL-WN722N | 150Mbps High Gain Wireless USB Adapter | TP-Link
Problem
We are using a Raspberry Pi 3 and a USB WiFi adapter to connect our devices to the internet as well as to some internal networks. Here is an interface breakdown:
wlan0 (internal to the RPI3): hosts a hotspot
wlan1 (WiFi adapter): connects to the internet
eth0 (internal to the RPI3): connects to an internal network
We use a Docker Compose solution. When one of our processes starts up, the first thing it does is create the hotspot on wlan0. The hotspot is tied to wlan0 via the connection configuration (see below). The process will enter a loop of starting the hotspot if it detects the hotspot failed to activate. This is why in one of the network manager logs below you will see a lot of activation attempts for the hotspot. When the USB WiFi adapter is not plugged in, everything works as expected. However, when the WiFi adapter is plugged in before boot, we get into situations where wlan0 becomes “unusable”.
Meaning of unusable:
- When using nmcli to attach a connection to it “nmcli c u hotspot”
-
Error: Connection activation failed: No suitable device found for this connection.
-
- It shows up as “disconnected” via “nmcli d”
- When I issue “nmcli d c” to “connect” the wlan0 interface:
-
Error: Failed to add/activate new connection: A ‘wireless’ setting is required if no AP path was given.
- If there is another connection available beside the hotspot, it will choose the other connection and not the hotspot. It works fine in this context.
-
- The logs keep showing this error only when I reproduce the problem - otherwise this doesn’t show:
-
device (wlan0): set-hw-addr: new MAC address C2:33:52:A8:5A:C8 not successfully set (scanning)
-
If the WiFi adapter is plugged in after the RPI3 boots, things work fine. This is only a problem if the WiFi adapter is plugged in when the RPI3 boots.
We’ve been using this solution for months and never noticed any issues. Based on my debugging, I think these are the important factors to consider:
- The WiFi adapter being plugged in at device boot seems to somehow cause this problem. This is the only way I’ve been able to reproduce the issue.
- The issue seems specific to wlan0 and the hotspot connection. In the error state, other connections work on wlan0 - only the hotspot fails.
I’m looking for any insight into this problem. We want things to work the way we have them now and want to avoid changing which interface we attach our connections to if possible. I may attempt to set an autoconnect priority as well as define a set number of retries on the hotspot connection, but based on my debugging I don’t have faith that those changes will get to the root of the problem.
If I can provide any more details, please let me know.
Relevant Data / Logs
Hotspot Configuration
hotspotConnection := map[string]dbus.Variant{
"id": dbus.MakeVariant("hotspot"),
"uuid": dbus.MakeVariant('some_uuid'),
"type": dbus.MakeVariant("802-11-wireless"),
"autoconnect": dbus.MakeVariant(true),
"interface-name": dbus.MakeVariant("wlan0"),
}
hotspotWifi := map[string]dbus.Variant{
"band": dbus.MakeVariant("bg"),
"mode": dbus.MakeVariant("ap"),
"ssid": dbus.MakeVariant([]byte("some_ssid")),
}
hotspotWifiSecurity := map[string]dbus.Variant{
"key-mgmt": dbus.MakeVariant("wpa-psk"),
"psk": dbus.MakeVariant("some_psk"),
}
hotspotIPV4 := map[string]dbus.Variant{
"method": dbus.MakeVariant("shared"),
"address-data": dbus.MakeVariant([]map[string]dbus.Variant{
{
"address": dbus.MakeVariant(settings.ip),
"prefix": dbus.MakeVariant(settings.ipPrefix),
},
}),
}
hotspotIPV6 := map[string]dbus.Variant{
"method": dbus.MakeVariant("auto"),
}
return networkmanager.ConnectionConfiguration{
"connection": hotspotConnection,
"802-11-wireless": hotspotWifi,
"802-11-wireless-security": hotspotWifiSecurity,
"ipv4": hotspotIPV4,
"ipv6": hotspotIPV6,
}
journalctl -u NetworkManager Logs
These were a bit annoying to grab off the device. Hopefully they help.
nmoutput-boot (2).log (30.0 KB)
nmoutput (2).log (614.4 KB)
Misc Logs
error dmesg | grep wlan0
root@eeed17e:~# dmesg | grep wlan0
[ 9.223128] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 9.825740] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 9.932582] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 11.569888] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 12.925996] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 357.116488] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 672.113766] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
success dmesg | grep wlan0
[ 9.471633] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 9.514793] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 10.039566] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 10.382145] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 11.442040] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 12.320801] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[ 36.724186] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 37.315847] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 37.643061] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
working ifconfig dump of wlan0
root@9885f88:~# ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr B8:27:EB:44:AE:69
inet addr:10.0.0.1 Bcast:10.0.0.255 Mask:255.255.255.0
inet6 addr: fe80::e6c:fd74:3c42:626f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:7 overruns:0 frame:0
TX packets:140 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:24067 (23.5 KiB)
error state wlan0
wlan0 Link encap:Ethernet HWaddr 50:3E:AA:31:61:4C
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
driver
root@eeed17e:~# readlink /sys/class/net/wlan0/device/driver
../../../../../../../../bus/sdio/drivers/brcmfmac