Atheros AR9271
Topics in this section,
In this section, you are going to learn
How to load atheros wifi linux driver for Atheros AR9271 802.11n USB Wi-Fi Adapter
Features |
|
---|---|
Hardware Interface |
USB 2.0 |
Compatible Devices |
Laptop, Desktop |
Data Link Protocol |
USB |
Data Transfer Rate |
150 Megabits Per Second |
Item Weight |
0.03 Kilograms |
# |
Version |
---|---|
Ubuntu |
Ubuntu 22.04 64 bit |
Linux Kernel |
6.9.0 |
Wifi chip |
Atheros |
Chipset version |
Atheros AR9271 |
Insert the wifi usb adapter to the usb port:
Check the wifi chipset by running the below command
test:~$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 413c:301a Dell Computer Corp. Dell MS116 Optical Mouse
Bus 001 Device 004: ID 0cf3:9271 Qualcomm Atheros Communications AR9271 802.11n
Bus 001 Device 002: ID 0461:0010 Primax Electronics, Ltd HP PR1101U / Primax PMX-KPR1101U Keyboard
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Check the dmesg output by running the below command:
test:~$ sudo dmesg
[15075.422501] usb 1-5: new high-speed USB device number 7 using xhci_hcd
[15075.587285] usb 1-5: New USB device found, idVendor=0cf3, idProduct=9271, bcdDevice= 1.08
[15075.587298] usb 1-5: New USB device strings: Mfr=16, Product=32, SerialNumber=48
[15075.587303] usb 1-5: Product: UB93
[15075.587308] usb 1-5: Manufacturer: ATHEROS
[15075.587311] usb 1-5: SerialNumber: 12345
Stop applications by running the commands below:
test@test-V520-15IKL:~/linux-6.9$ pwd
/home/test/linux-6.9
test:~/linux-6.9$ sudo systemctl stop NetworkManager.service
test:~/linux-6.9$ sudo killall wpa_supplicant hostapd
test:~/linux-6.9$ ps -N | grep -i wpa_supplicant
test:~/linux-6.9$ ps -N | grep -i hostapd
Run lsmod commands:
test:~/linux-6.9$ lsmod | grep -i mac80211
mac80211 1712128 1 ath9k_htc
libarc4 12288 3 lib80211_crypt_tkip,lib80211_crypt_wep,mac80211
cfg80211 1376256 4 ath9k_htc,ath9k_common,ath,mac80211
test:~/linux-6.9$ lsmod | grep -i lib80211
lib80211_crypt_tkip 24576 0
lib80211_crypt_ccmp 16384 0
lib80211_crypt_wep 12288 0
libarc4 12288 3 lib80211_crypt_tkip,lib80211_crypt_wep,mac80211
lib80211 16384 3 lib80211_crypt_tkip,lib80211_crypt_wep,lib80211_crypt_ccmp
test:~/linux-6.9$ lsmod | grep -i ath
ath9k_htc 114688 0
ath9k_common 49152 1 ath9k_htc
ath9k_hw 659456 2 ath9k_htc,ath9k_common
ath 36864 3 ath9k_htc,ath9k_common,ath9k_hw
mac80211 1712128 1 ath9k_htc
cfg80211 1376256 4 ath9k_htc,ath9k_common,ath,mac80211
Now, remove drivers by executing rmmod command as shown below:
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod ath9k_htc
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod ath9k_common
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod ath9k_hw
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod ath
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod mac80211
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod lib80211_crypt_tkip
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod lib80211_crypt_ccmp
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod lib80211_crypt_wep
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod libarc4
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod lib80211
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod cfg80211
Follow steps from the link : <https://c-pointers.com/osp/bare_linux/x86-64/secB.html>
Move to compiled Linux folder as shown below:
$ cd /home/test/linux-6.9
Check current directory:
test@test-V520-15IKL:~/linux-6.9$ pwd
/home/test/linux-6.9
Start compilation for wireless folder:
test@test-V520-15IKL:~/linux-6.9$ sudo make -C . M=net/wireless/
make: Entering directory "/home/test/linux-6.9"
CC [M] net/wireless/core.o
LD [M] net/wireless/cfg80211.o
CC [M] net/wireless/lib80211.o
CC [M] net/wireless/lib80211_crypt_wep.o
CC [M] net/wireless/lib80211_crypt_ccmp.o
CC [M] net/wireless/lib80211_crypt_tkip.o
MODPOST net/wireless/Module.symvers
LD [M] net/wireless/cfg80211.ko
LD [M] net/wireless/lib80211.ko
LD [M] net/wireless/lib80211_crypt_wep.ko
LD [M] net/wireless/lib80211_crypt_ccmp.ko
LD [M] net/wireless/lib80211_crypt_tkip.ko
make: Leaving directory "/home/test/linux-6.9"
Run make command for mac80211 folder:
test@test-V520-15IKL:~/linux-6.9$ sudo make -C . M=net/mac80211
make: Entering directory "/home/test/linux-6.9"
CC [M] net/mac80211/main.o
LD [M] net/mac80211/mac80211.o
MODPOST net/mac80211/Module.symvers
LD [M] net/mac80211/mac80211.ko
make: Leaving directory "/home/test/linux-6.9"
Run make command for ath folder:
test@test-V520-15IKL:~/linux-6.9$ sudo make -C . M=drivers/net/wireless/ath/
make: Entering directory "/home/test/linux-6.9"
MODPOST drivers/net/wireless/ath/Module.symvers
CC [M] drivers/net/wireless/ath/ath5k/ath5k.mod.o
LD [M] drivers/net/wireless/ath/ath5k/ath5k.ko
CC [M] drivers/net/wireless/ath/ath9k/ath9k.mod.o
LD [M] drivers/net/wireless/ath/ath9k/ath9k.ko
CC [M] drivers/net/wireless/ath/ath9k/ath9k_hw.mod.o
LD [M] drivers/net/wireless/ath/ath9k/ath9k_hw.ko
CC [M] drivers/net/wireless/ath/ath9k/ath9k_common.mod.o
LD [M] drivers/net/wireless/ath/ath9k/ath9k_common.ko
CC [M] drivers/net/wireless/ath/ath9k/ath9k_htc.mod.o
LD [M] drivers/net/wireless/ath/ath9k/ath9k_htc.ko
CC [M] drivers/net/wireless/ath/ath9k/ath9k_pci_owl_loader.mod.o
LD [M] drivers/net/wireless/ath/ath9k/ath9k_pci_owl_loader.ko
CC [M] drivers/net/wireless/ath/carl9170/carl9170.mod.o
LD [M] drivers/net/wireless/ath/carl9170/carl9170.ko
CC [M] drivers/net/wireless/ath/ath6kl/ath6kl_core.mod.o
LD [M] drivers/net/wireless/ath/ath6kl/ath6kl_core.ko
CC [M] drivers/net/wireless/ath/ath6kl/ath6kl_sdio.mod.o
LD [M] drivers/net/wireless/ath/ath6kl/ath6kl_sdio.ko
CC [M] drivers/net/wireless/ath/ath6kl/ath6kl_usb.mod.o
LD [M] drivers/net/wireless/ath/ath6kl/ath6kl_usb.ko
CC [M] drivers/net/wireless/ath/ar5523/ar5523.mod.o
LD [M] drivers/net/wireless/ath/ar5523/ar5523.ko
CC [M] drivers/net/wireless/ath/wil6210/wil6210.mod.o
LD [M] drivers/net/wireless/ath/wil6210/wil6210.ko
CC [M] drivers/net/wireless/ath/ath10k/ath10k_core.mod.o
LD [M] drivers/net/wireless/ath/ath10k/ath10k_core.ko
CC [M] drivers/net/wireless/ath/ath10k/ath10k_pci.mod.o
LD [M] drivers/net/wireless/ath/ath10k/ath10k_pci.ko
CC [M] drivers/net/wireless/ath/ath10k/ath10k_sdio.mod.o
LD [M] drivers/net/wireless/ath/ath10k/ath10k_sdio.ko
CC [M] drivers/net/wireless/ath/ath10k/ath10k_usb.mod.o
LD [M] drivers/net/wireless/ath/ath10k/ath10k_usb.ko
CC [M] drivers/net/wireless/ath/wcn36xx/wcn36xx.mod.o
LD [M] drivers/net/wireless/ath/wcn36xx/wcn36xx.ko
CC [M] drivers/net/wireless/ath/ath11k/ath11k.mod.o
LD [M] drivers/net/wireless/ath/ath11k/ath11k.ko
CC [M] drivers/net/wireless/ath/ath11k/ath11k_ahb.mod.o
LD [M] drivers/net/wireless/ath/ath11k/ath11k_ahb.ko
CC [M] drivers/net/wireless/ath/ath11k/ath11k_pci.mod.o
LD [M] drivers/net/wireless/ath/ath11k/ath11k_pci.ko
CC [M] drivers/net/wireless/ath/ath12k/ath12k.mod.o
LD [M] drivers/net/wireless/ath/ath12k/ath12k.ko
CC [M] drivers/net/wireless/ath/ath.mod.o
LD [M] drivers/net/wireless/ath/ath.ko
make: Leaving directory "/home/test/linux-6.9"
Run find command to search for “.ko” files in ./net/wireless directory:
test@test-V520-15IKL:~/linux-6.9$ find ./net/wireless/ -iname "*.ko" -print
./net/wireless/lib80211_crypt_wep.ko
./net/wireless/cfg80211.ko
./net/wireless/lib80211_crypt_ccmp.ko
./net/wireless/lib80211.ko
./net/wireless/lib80211_crypt_tkip.ko
Run find command to search for “.ko” files in ./net/mac80211 directory:
test@test-V520-15IKL:~/linux-6.9$ find ./net/mac80211/ -iname "*.ko" -print
./net/mac80211/mac80211.ko
Run find command to search for “.ko” files in ./drivers/net/wireless/ath directory:
test@test-V520-15IKL:~/linux-6.9$ find ./drivers/net/wireless/ath/ -iname "*.ko" -print
./drivers/net/wireless/ath/ath10k/ath10k_pci.ko
./drivers/net/wireless/ath/ath10k/ath10k_core.ko
./drivers/net/wireless/ath/ath10k/ath10k_sdio.ko
./drivers/net/wireless/ath/ath10k/ath10k_usb.ko
./drivers/net/wireless/ath/ath12k/ath12k.ko
./drivers/net/wireless/ath/wil6210/wil6210.ko
./drivers/net/wireless/ath/ath11k/ath11k.ko
./drivers/net/wireless/ath/ath11k/ath11k_ahb.ko
./drivers/net/wireless/ath/ath11k/ath11k_pci.ko
./drivers/net/wireless/ath/wcn36xx/wcn36xx.ko
./drivers/net/wireless/ath/ath9k/ath9k_hw.ko
./drivers/net/wireless/ath/ath9k/ath9k_htc.ko
./drivers/net/wireless/ath/ath9k/ath9k.ko
./drivers/net/wireless/ath/ath9k/ath9k_pci_owl_loader.ko
./drivers/net/wireless/ath/ath9k/ath9k_common.ko
./drivers/net/wireless/ath/ar5523/ar5523.ko
./drivers/net/wireless/ath/ath6kl/ath6kl_sdio.ko
./drivers/net/wireless/ath/ath6kl/ath6kl_usb.ko
./drivers/net/wireless/ath/ath6kl/ath6kl_core.ko
./drivers/net/wireless/ath/ath.ko
./drivers/net/wireless/ath/ath5k/ath5k.ko
./drivers/net/wireless/ath/carl9170/carl9170.ko
Remove the following .zst files
test@test-V520-15IKL:~/linux-6.9$ find /lib/modules/6.9.0/kernel/net/wireless/ -iname "*.ko.zst*" -print
/lib/modules/6.9.0/kernel/net/wireless/lib80211_crypt_wep.ko.zst
/lib/modules/6.9.0/kernel/net/wireless/lib80211_crypt_ccmp.ko.zst
/lib/modules/6.9.0/kernel/net/wireless/lib80211.ko.zst
/lib/modules/6.9.0/kernel/net/wireless/cfg80211.ko.zst
/lib/modules/6.9.0/kernel/net/wireless/lib80211_crypt_tkip.ko.zst
test@test-V520-15IKL:~/linux-6.9$ find /lib/modules/6.9.0/kernel/net/mac80211/ -iname "*.ko.zst*" -print
/lib/modules/6.9.0/kernel/net/mac80211/mac80211.ko.zst
test@test-V520-15IKL:~/linux-6.9$ find /lib/modules/6.9.0/kernel/drivers/net/wireless/ath/ -iname "*.ko.zst*" -print
/lib/modules/6.9.0/kernel/drivers/net/wireless/ath/ath10k/ath10k_core.ko.zst
/lib/modules/6.9.0/kernel/drivers/net/wireless/ath/ath10k/ath10k_usb.ko.zst
/lib/modules/6.9.0/kernel/drivers/net/wireless/ath/ath10k/ath10k_sdio.ko.zst
/lib/modules/6.9.0/kernel/drivers/net/wireless/ath/ath10k/ath10k_pci.ko.zst
/lib/modules/6.9.0/kernel/drivers/net/wireless/ath/ath12k/ath12k.ko.zst
/lib/modules/6.9.0/kernel/drivers/net/wireless/ath/wil6210/wil6210.ko.zst
/lib/modules/6.9.0/kernel/drivers/net/wireless/ath/ath11k/ath11k.ko.zst
/lib/modules/6.9.0/kernel/drivers/net/wireless/ath/ath11k/ath11k_ahb.ko.zst
/lib/modules/6.9.0/kernel/drivers/net/wireless/ath/ath11k/ath11k_pci.ko.zst
/lib/modules/6.9.0/kernel/drivers/net/wireless/ath/wcn36xx/wcn36xx.ko.zst
/lib/modules/6.9.0/kernel/drivers/net/wireless/ath/ath9k/ath9k.ko.zst
/lib/modules/6.9.0/kernel/drivers/net/wireless/ath/ath9k/ath9k_hw.ko.zst
/lib/modules/6.9.0/kernel/drivers/net/wireless/ath/ath9k/ath9k_pci_owl_loader.ko.zst
/lib/modules/6.9.0/kernel/drivers/net/wireless/ath/ath9k/ath9k_common.ko.zst
/lib/modules/6.9.0/kernel/drivers/net/wireless/ath/ath9k/ath9k_htc.ko.zst
/lib/modules/6.9.0/kernel/drivers/net/wireless/ath/ar5523/ar5523.ko.zst
/lib/modules/6.9.0/kernel/drivers/net/wireless/ath/ath6kl/ath6kl_usb.ko.zst
/lib/modules/6.9.0/kernel/drivers/net/wireless/ath/ath6kl/ath6kl_sdio.ko.zst
/lib/modules/6.9.0/kernel/drivers/net/wireless/ath/ath6kl/ath6kl_core.ko.zst
/lib/modules/6.9.0/kernel/drivers/net/wireless/ath/ath5k/ath5k.ko.zst
/lib/modules/6.9.0/kernel/drivers/net/wireless/ath/carl9170/carl9170.ko.zst
/lib/modules/6.9.0/kernel/drivers/net/wireless/ath/ath.ko.zst
You may restart your system using the command below:
$ reboot
Repeat Step 3
$ cd /home/test/linux-6.9
Repeat Step 5
test@test-V520-15IKL:~/linux-6.9$ sudo dmesg -c
sudo insmod ./net/wireless/cfg80211.ko
sudo insmod ./net/wireless/lib80211.ko
sudo insmod ./lib/crypto/libarc4.ko
sudo insmod ./net/wireless/lib80211_crypt_wep.ko
sudo insmod ./net/wireless/lib80211_crypt_ccmp.ko
sudo insmod ./net/wireless/lib80211_crypt_tkip.ko
sudo insmod ./net/mac80211/mac80211.ko
sudo insmod ./drivers/net/wireless/ath/ath.ko
sudo insmod ./drivers/net/wireless/ath/ath9k/ath9k_hw.ko
sudo insmod ./drivers/net/wireless/ath/ath9k/ath9k_common.ko
sudo insmod ./drivers/net/wireless/ath/ath9k/ath9k_htc.ko
test@test-V520-15IKL:~/linux-6.9$ lsmod
Module Size Used by
ath9k_htc 114688 0
ath9k_common 49152 1 ath9k_htc
ath9k_hw 659456 2 ath9k_htc,ath9k_common
ath 36864 3 ath9k_htc,ath9k_common,ath9k_hw
mac80211 1712128 1 ath9k_htc
lib80211_crypt_tkip 24576 0
lib80211_crypt_ccmp 16384 0
lib80211_crypt_wep 12288 0
libarc4 12288 3 lib80211_crypt_tkip,lib80211_crypt_wep,mac80211
lib80211 16384 3 lib80211_crypt_tkip,lib80211_crypt_wep,lib80211_crypt_ccmp
cfg80211 1376256 4 ath9k_htc,ath9k_common,ath,mac80211
test@test-V520-15IKL:~/linux-6.9$ iwconfig
lo no wireless extensions.
enp1s0 no wireless extensions.
wlxc01c3031bc56 IEEE 802.11 ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=off
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:off
Open below files with vim and add prints in module_init and module_exit fucntions:
test:linux-6.9$ pwd
/home/test/linux-6.9
./net/wireless/lib80211_crypt_wep.c
./net/wireless/lib80211.c
./net/wireless/lib80211_crypt_tkip.c
./net/wireless/lib80211_crypt_ccmp.c
./net/wireless/core.c
./net/mac80211/main.c
./drivers/net/wireless/ath/ath9k/htc_drv_init.c
./drivers/net/wireless/ath/ath9k/common.c
Open nl80211.c file with vim, add prints in all .doit functions in nl80211_small_ops
test:linux-6.9/net/wireless$ vi nl80211.c
static const struct genl_small_ops nl80211_small_ops[] = {
{
.cmd = NL80211_CMD_SET_WIPHY,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = nl80211_set_wiphy,
.flags = GENL_UNS_ADMIN_PERM,
},
{
.cmd = NL80211_CMD_GET_INTERFACE,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = nl80211_get_interface,
.dumpit = nl80211_dump_interface,
/* can be retrieved by unprivileged users */
.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV),
},
{
.cmd = NL80211_CMD_SET_INTERFACE,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = nl80211_set_interface,
.flags = GENL_UNS_ADMIN_PERM,
.internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV |
NL80211_FLAG_NEED_RTNL),
},
Open cfg.c file with vim, add prints in all functions in mac80211_config_ops
test:linux-6.9/net/mac80211$ vi cfg.c
const struct cfg80211_ops mac80211_config_ops = {
.add_virtual_intf = ieee80211_add_iface,
.del_virtual_intf = ieee80211_del_iface,
.change_virtual_intf = ieee80211_change_iface,
.start_p2p_device = ieee80211_start_p2p_device,
.stop_p2p_device = ieee80211_stop_p2p_device,
Open htc_drv_main.c file with vim, add prints in all functions in ath9k_htc_ops
test:linux-6.9/drivers/net/wireless/net/wireless/ath/ath9k$ vi htc_drv_main.c
struct ieee80211_ops ath9k_htc_ops = {
.add_chanctx = ieee80211_emulate_add_chanctx,
.remove_chanctx = ieee80211_emulate_remove_chanctx,
.change_chanctx = ieee80211_emulate_change_chanctx,
.switch_vif_chanctx = ieee80211_emulate_switch_vif_chanctx,
.tx = ath9k_htc_tx,
.wake_tx_queue = ieee80211_handle_wake_tx_queue,
.start = ath9k_htc_start,
.stop = ath9k_htc_stop,
.add_interface = ath9k_htc_add_interface,
.remove_interface = ath9k_htc_remove_interface,
Open iface.c file with vim, add prints in all functions in ieee80211_dataif_ops
test:linux-6.9/net/mac80211$ vi ./iface.c
static const struct net_device_ops ieee80211_dataif_ops = {
.ndo_open = ieee80211_open,
.ndo_stop = ieee80211_stop,
.ndo_uninit = ieee80211_uninit,
.ndo_start_xmit = ieee80211_subif_start_xmit,
.ndo_set_rx_mode = ieee80211_set_multicast_list,
.ndo_set_mac_address = ieee80211_change_mac,
.ndo_get_stats64 = ieee80211_get_stats64,
.ndo_setup_tc = ieee80211_netdev_setup_tc,
};