Skip to main content
Topic: How do I use the USB Wireless (Wi-Fi) Adapter (ath9k)? (Read 2747 times) previous topic - next topic
0 Members and 3 Guests are viewing this topic.

How do I use the USB Wireless (Wi-Fi) Adapter (ath9k)?

Hello everyone.
Please tell me how to use the USB Wireless (Wi-Fi) Adapter correctly if I already have a network card in my laptop? When I try to turn on the USB Wireless (Wi-Fi) Adapter, do I see that two interfaces are enabled? Here are my steps:

I also wanted to see if there was a conflict between connman + connman-gtk and the USB Wireless (Wi-Fi) Adapter

I didn't find the ath9k drivers separately in the repository, but I realized they were included in the kernel.
I loaded the kernel module with the command and checked:

Code: [Select]
$ sudo modprobe ath9k
 
$ sudo modprobe -v ath9k
 
$ sudo  lsmod | grep ath

Next, I inserted the USB Wireless (Wi-Fi) Adapter and checked:
 
Code: [Select]
$ sudo dmesg | grep usb

Next, I checked the name of the USB Wireless (Wi-Fi) Adapter interface (I have it "wlan1")
 
Code: [Select]
$ ip -c a

Next, I activated the network interface "wlan1"
 
Code: [Select]
$ sudo ip link set wlan1  up

but received a message:
 
Code: [Select]
RTNETLINK answers: Operation not possible due to RF-kill

Okay, I checked if blocking the network interface with the command:
 
Code: [Select]
 $ rfkill list all 
 
phy2: Wareless LAN
 
Soft blocked: yes
Hard blocked: no

Unlock with the command:
 
Code: [Select]
 $ rfkill unblock 3   # the number 3 is my phy2 it appears when you press TAB

Let's check again:
 
Code: [Select]
$ rfkill list all
 
phy2: Wareless LAN
 
Soft blocked: no
Hard blocked: no

I try to activate the interface again:
 
Code: [Select]
$ sudo ip link set wlan1  up 
 
$ sudo ifconfig wlan1 up

 Nothing happens??
 
Okay, I'm trying to act wpa_supplicant command:
 
Code: [Select]
$ sudo rc-service wpa_supplicant start

I see an error that says there is no wpa_supplicant.conf file. Okay,
 
I've created a file like this:
 
Code: [Select]
$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel 

network={
ssid="YourWiFiNetworkName"        
psk="YourWiFiPassword"             
        key_mgmt=WPA-PSK
        proto=RSN
 
}

Code: [Select]
$ sudo chmod 600 /etc/wpa_supplicant/wpa_supplicant.conf

 
I try to activate the interface again:
 
Code: [Select]
 $ sudo rc-service wpa_supplicant start

I see that rfkill is blocking the interface...
 

Re: How do I use the USB Wireless (Wi-Fi) Adapter (ath9k)?

Reply #1
If you have network manager installed, regardless of whether it is doing anything or in use at all, it will block operations in the terminal. At least that was always the case in the past but I haven't checked recently. Possibly other GUI managers would interfere too. Also wpa_supplicant was broken in an update and still hasn't been fixed, once you get that far you may need to use these old versions:
wpa_supplicant-2:2.10-8-x86_64.pkg.tar.zst
iproute2-6.9.0-2-x86_64.pkg.tar.zst
The current versions only connect if you are close to the router because they fail to switch to high power while searching for a connection - it was a deliberate change in wpa_supplicant to avoid interference but it doesn't work if you really need that, and they usually only release new versions every couple of years. Once the connection is established the power level is set as high as required by the card and router communicating.
I have physical wifi switches and BIOS settings which can disable wifi, that could also be worth a look.
There's some useful troubleshooting info on the Arch wiki:
https://wiki.archlinux.org/title/Network_configuration/Wireless

Re: How do I use the USB Wireless (Wi-Fi) Adapter (ath9k)?

Reply #2
If it's not a secret, what adapter are you using? Usually USB adapters use ath9k_htc instead of ath9k. Both families are completely open source, but I don't know if ath9k_htc is included in the kernel like ath9k or if I need to install a separate package.

Re: How do I use the USB Wireless (Wi-Fi) Adapter (ath9k)?

Reply #3
Dell M4500, this is a non-standard internal PCI card as all the OE options I tried had problems in Linux:
Qualcomm Atheros AR9287 Wireless Network Adapter (PCI-Express)
Kernel driver in use: ath9k

Dell E7470, again an internal PCI card:
Intel Corporation Wireless 8260 (rev 3a)
Kernel driver in use: iwlwifi

I have used the M4500 with a PCMCIA card plugged in too, but then I only enable one device or the other, and never tried both together:
Network controller: Ralink corp. RT2760 Wireless 802.11n 1T/2R
Kernel driver in use: rt2800pci

Re: How do I use the USB Wireless (Wi-Fi) Adapter (ath9k)?

Reply #4
I use this one  https://libre.thinkpenguin.com/gnu-linux/penguin-wireless-n-usb-adapter-gnu-linux-tpe-n150usb
(Chipset AR9271 )


The problem is that when I activate wpa_supplicant, I have two network cards working, but I only want the USB Wireless (Wi-Fi) Adapter to work.

I'll try your recommendation with older versions of wpa_supplicant.

Re: How do I use the USB Wireless (Wi-Fi) Adapter (ath9k)?

Reply #5
Ok, it uses ath9k_htc. Any new messages in dmesg when unlocking and raising the interface?

Re: How do I use the USB Wireless (Wi-Fi) Adapter (ath9k)?

Reply #6
When I have 2 wifi adapters I just bring up the one I want, and if I want to swap then I turn it off and start the other, something like this:
Code: [Select]
On script:
#!/bin/bash
ip link set wlan0 up
sleep 1 && wpa_supplicant -B -P /run/somename.pid  -i wlan0 -D nl80211,wext \
-c /somedir/wpa_supplicant.conf
sleep 1 && dhclient -v -cf /somedir/dhclient.conf wlan0
#sleep 1 && dhcpcd -4 -t 0 -K wlan0 # you could use dhcpcd instead, doesn't need a conf file

Off script:
#!/bin/bash
dhclient -x wlan0
wpa_cli -i wlan0 -p /run/wpa_supplicant terminate
ip link set wlan0 down
rm -f /run/wpa_supplicant/wlan0


wpa_supplicant.conf:

ctrl_interface=/run/wpa_supplicant
ctrl_interface_group=wheel
network={
proto=RSN WPA
psk="whatever"
ssid=whatever or bssid=whatever

dhclient.conf can be empty unless you have some config to add. Perhaps the problem is something is switching on the one you are not using, and that's interfering, could be connman. Look at the Arch wiki and check which interfaces are "up." You might not need the sleeps but sometimes they help avoid race conditions.

Re: How do I use the USB Wireless (Wi-Fi) Adapter (ath9k)?

Reply #7
Thank you very much for your answer and desire to help. Your script will not work, since the first command from it does not work,
Code: [Select]
 
$ ip link set wlan1 up
I wrote about this above. I insert the USB Wireless (Wi-Fi) Adapter into the PC. I see the new wlan1 interface Next, I try to raise it and it doesn't work, I fully described above. I have one network card built into my PC, but I only want to use the USB Wireless (Wi-Fi) Adapter How do I download wpa_supplicant-openrc 20210505-1 in pkg.tar.zst format?

I want to try this version of wpa_supplicant-openrc

Re: How do I use the USB Wireless (Wi-Fi) Adapter (ath9k)?

Reply #8
What if I block the built-in adapter and enable usb? Install the required version via pacman -U from the artix package archive (https://archive.artixlinux.org/):
Code: [Select]
pacman -U https://archive.artixlinux.org/packages/w/wpa_supplicant-openrc/wpa_supplicant-openrc-20210505-1-any.pkg.tar.zst

 

Re: How do I use the USB Wireless (Wi-Fi) Adapter (ath9k)?

Reply #9
That isn't the first thing you should run, first you have to turn off the other card, wlan0 (if it's called that) and check it stays down - it might be getting restarted by something like connman. You might need to disable connman or uninstall the package entirely - you can always put it back with pacman -U from the cache so long as you make sure it's in there first, possibly copy the package to another location so it won't get accidentally cleaned up during system maintenance.
You can see what cards are found by the system and up or down, connected or not like this:
Code: [Select]
iw dev
ip link
ip route
That version of wpa_supplicant won't work on it's own, you have to downgrade iproute2 from the package archive too.

Re: How do I use the USB Wireless (Wi-Fi) Adapter (ath9k)?

Reply #10
What if I block the built-in adapter and enable usb? Install the required version via pacman -U from the artix package archive (https://archive.artixlinux.org/):
Code: [Select]
pacman -U https://archive.artixlinux.org/packages/w/wpa_supplicant-openrc/wpa_supplicant-openrc-20210505-1-any.pkg.tar.zst

Thank you very much for the link.

Re: How do I use the USB Wireless (Wi-Fi) Adapter (ath9k)?

Reply #11
That isn't the first thing you should run, first you have to turn off the other card, wlan0 (if it's called that) and check it stays down - it might be getting restarted by something like connman. You might need to disable connman or uninstall the package entirely - you can always put it back with pacman -U from the cache so long as you make sure it's in there first, possibly copy the package to another location so it won't get accidentally cleaned up during system maintenance.
You can see what cards are found by the system and up or down, connected or not like this:
Code: [Select]
iw dev
ip link
ip route
That version of wpa_supplicant won't work on it's own, you have to downgrade iproute2 from the package archive too.

This is exactly what happens as you wrote, wlan0 is a built-in network card, it works with connman-openrc and connman-gtk and a conflict occurs when wlan0 does not work wlan1 (USB Wireless (Wi-Fi) Adapter) I thought the same as you deleted connman, but then decided to write here, thought maybe there is another solution.



Re: How do I use the USB Wireless (Wi-Fi) Adapter (ath9k)?

Reply #12
You mean when wlan0 is "down" wlan1 works OK? That's good if that is the case, now you have established that, if you are happy with using Connman then you should be able to disable wlan0 by blacklisting it like this in /etc/connman/main.conf (as I'm not using Connman I haven't tested this though) :
https://unix.stackexchange.com/questions/798919/connman-permanently-disable-built-in-wifi-interface
It seems Connman is mainly designed for systems with just one wifi interface and requires manual configuration rather than having a button or menu option to switch between two, as the project intends to be lightweight and simple.
Or you could try some other means of managing your wifi connections and configure that as appropriate.

Re: How do I use the USB Wireless (Wi-Fi) Adapter (ath9k)?

Reply #13
Not exactly, when I use connman-gtk, i.e. I enable wlan0 (PC network interface) then everything works fine, but when I insert the
USB Wireless (Wi-Fi) Adapter (wlan1) it doesn't work.
I think you are right that connman is causing problems, since apparently it can work with two network interfaces at the same time. In general, it all looks old)) I want to use a USB Wireless (Wi-Fi) Adapter, I have to insert a USB Wireless (Wi-Fi) Adapter and everything should work, but in reality it is not...

Re: How do I use the USB Wireless (Wi-Fi) Adapter (ath9k)?

Reply #14
From the link I posted:

"You can prevent connman from configuring a network interface at all, by adding it to the comma-separated NetworkInterfaceBlacklist= list in the [General] section of /etc/connman/main.conf"

I am not using connman to test this, and you might need to alter the name or remove the spaces around the = sign, but it looks like you simply add a line to /etc/connman/main.conf like this:
Code: [Select]
NetworkInterfaceBlacklist = wlan0
Then reboot and connman should use wlan1 instead, you might need to have the USB adapter plugged in before you start the computer because hotplugging later may not work. Even if wlan1 doesn't work it should stop wlan0 from working, which you can check.

If it doesn't work, change that line and reboot again.