I was expecting an easy use of my brand new Wifi adapter AWUS036NHA under Debian Stretch but I hit an unexpected bug...
I started with
apt install firmware-atheros
and soon the blue LED on the Alfa device was blinking furiously. So good so far! But when I tried to connect to a Wifi network with Network-Manager the tool was unable to connect. And no matter what I did it failed to connect. This is what I could see in the system logs (dmesg):
[ 217.118991] usb 1-3: USB disconnect, device number 5 [ 219.137772] usb 1-3: new high-speed USB device number 6 using xhci_hcd [ 219.294368] usb 1-3: New USB device found, idVendor=0cf3, idProduct=9271 [ 219.294373] usb 1-3: New USB device strings: Mfr=16, Product=32, SerialNumber=48 [ 219.294376] usb 1-3: Product: UB91C [ 219.294378] usb 1-3: Manufacturer: ATHEROS [ 219.294380] usb 1-3: SerialNumber: 12345 [ 219.295099] usb 1-3: ath9k_htc: Firmware ath9k_htc/htc_9271-1.4.0.fw requested [ 219.295555] usb 1-3: firmware: direct-loading firmware ath9k_htc/htc_9271-1.4.0.fw [ 219.578229] usb 1-3: ath9k_htc: Transferred FW: ath9k_htc/htc_9271-1.4.0.fw, size: 51008 [ 219.829806] ath9k_htc 1-3:1.0: ath9k_htc: HTC initialized with 33 credits [ 220.096217] ath9k_htc 1-3:1.0: ath9k_htc: FW Version: 1.4 [ 220.096221] ath9k_htc 1-3:1.0: FW RMW support: On [ 220.096224] ath: EEPROM regdomain: 0x833a [ 220.096225] ath: EEPROM indicates we should expect a country code [ 220.096227] ath: doing EEPROM country->regdmn map search [ 220.096229] ath: country maps to regdmn code: 0x37 [ 220.096231] ath: Country alpha2 being used: GB [ 220.096232] ath: Regpair used: 0x37 [ 220.101582] ieee80211 phy1: Atheros AR9271 Rev:1 [ 220.115019] ath9k_htc 1-3:1.0 wlx00c0ca9751d9: renamed from wlan1 [ 220.148280] IPv6: ADDRCONF(NETDEV_UP): wlx00c0ca9751d9: link is not ready [ 220.332215] IPv6: ADDRCONF(NETDEV_UP): wlx00c0ca9751d9: link is not ready [ 220.578623] IPv6: ADDRCONF(NETDEV_UP): wlx00c0ca9751d9: link is not ready [ 220.642308] IPv6: ADDRCONF(NETDEV_UP): wlx00c0ca9751d9: link is not ready [ 255.566737] IPv6: ADDRCONF(NETDEV_UP): wlx00c0ca9751d9: link is not ready [ 259.745782] IPv6: ADDRCONF(NETDEV_UP): wlx00c0ca9751d9: link is not ready [ 259.986747] IPv6: ADDRCONF(NETDEV_UP): wlx00c0ca9751d9: link is not ready [ 265.841754] IPv6: ADDRCONF(NETDEV_UP): wlx00c0ca9751d9: link is not ready [ 276.133407] wlx00c0ca9751d9: authenticate with ec:08:6b:33:71:ba [ 276.391552] wlx00c0ca9751d9: send auth to ec:08:6b:33:71:ba (try 1/3) [ 276.394687] wlx00c0ca9751d9: authenticated [ 281.389219] wlx00c0ca9751d9: aborting authentication with ec:08:6b:33:71:ba by local choice (Reason: 3=DEAUTH_LEAVING) [ 282.900769] wlx00c0ca9751d9: authenticate with ec:08:6b:33:71:ba [ 283.164429] wlx00c0ca9751d9: send auth to ec:08:6b:33:71:ba (try 1/3) [ 283.167350] wlx00c0ca9751d9: authenticated
wlx00c0ca9751d9 is the name the system gave to the adapter and I was intrigued with this error line:
aborting authentication with ec:08:6b:33:71:ba by local choice (Reason: 3=DEAUTH_LEAVING)
After looking up on the web, I discovered that other users of Atheros firmware reported issue when the adapter was given a long name...
So I decided to teach udev to give a shorter name to the wifi device, for example wlan1. And by the way it would be easier to remember!
The first step was to detect the attributes seen by udev on the device. The right command to do so is:
udevadm info -a -p /sys/class/net/wlx00c0ca9751d9
Among many other attributes, I spotted quite precise ones:
ATTRS{manufacturer}=="ATHEROS" ATTRS{product}=="UB91C"
Then I opened /etc/udev/rules.d/70-persistent-net.rules and added this line:
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTRS{manufacturer}=="ATHEROS", ATTRS{product}=="UB91C", NAME="wlan1"
After restarting udev with
/etc/init.d/udev restart
I unplugged and then plugged back the Wifi adapter and it was recognized as wlan1. And then the Wifi connection could be established.
Complicated but quite effective fix!