Realtek TP-Link TL-WN722N
Topics in this section,
In this section, you are going to learn
How to load Realtek wifi linux driver for Realtek TP-Link TL-WN722N USB WiFi Adapter
Features |
|
---|---|
Hardware Interface |
USB 2.0 |
Compatible Devices |
Laptop, Desktop |
Data Link Protocol |
USB, IEEE 802.11n |
Data Transfer Rate |
150 Megabits Per Second |
Item Weight |
0.4 Pounds |
# |
Version |
---|---|
Ubuntu |
Ubuntu 22.04 64 bit |
Linux kernel |
6.9.0 |
Wifi chip |
Realtek |
Chipset version |
TP-Link TL-WN722N v2/v3 [Realtek RTL8188EUS] |
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 004: ID 413c:301a Dell Computer Corp. Dell MS116 Optical Mouse
Bus 001 Device 025: ID 2357:010c TP-Link TL-WN722N v2/v3 [Realtek RTL8188EUS]
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
[346980.529317] usb 1-5: new high-speed USB device number 25 using xhci_hcd
[346980.677736] usb 1-5: New USB device found, idVendor=2357, idProduct=010c, bcdDevice= 0.00
[346980.677749] usb 1-5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[346980.677755] usb 1-5: Product: 802.11n NIC
[346980.677759] usb 1-5: Manufacturer: Realtek
[346980.677763] usb 1-5: SerialNumber: 00E04C0001
[346980.680279] usb 1-5: This Realtek USB WiFi dongle (0x2357:0x010c) is untested!
[346980.680291] usb 1-5: Please report results to Jes.Sorensen@gmail.com
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 wifi
rtlwifi 139264 14 rtl_pci,rtl8188ee,rtl8821ae,rtl8192c_common,rtl_usb,rtl8192cu,rtl8723be,btcoexist,rtl8723ae,rtl8192ee,rtl8192de,rtl8192se,rtl8192ce,rtl8723_common
mac80211 1691648 12 rtl_pci,rtl8188ee,rtl8821ae,rtl_usb,rtl8192cu,rtl8723be,rtl8723ae,rtlwifi,rtl8192ee,rtl8xxxu,rtl8192se,rtl8192ce
cfg80211 1318912 3 rtlwifi,mac80211,rtl8xxxu
test:~/linux-6.9$ lsmod | grep -i mac80211
mac80211 1691648 12 rtl_pci,rtl8188ee,rtl8821ae,rtl_usb,rtl8192cu,rtl8723be,rtl8723ae,rtlwifi,rtl8192ee,rtl8xxxu,rtl8192se,rtl8192ce
cfg80211 1318912 3 rtlwifi,mac80211,rtl8xxxu
libarc4 12288 3 lib80211_crypt_tkip,lib80211_crypt_wep,mac80211
test:~/linux-6.9$ lsmod | grep -i lib80211
lib80211_crypt_tkip 24576 0
lib80211_crypt_ccmp 16384 0
lib80211_crypt_wep 12288 0
lib80211 16384 3 lib80211_crypt_tkip,lib80211_crypt_wep,lib80211_crypt_ccmp
libarc4 12288 3 lib80211_crypt_tkip,lib80211_crypt_wep,mac80211
Now, remove drivers by executing rmmod command as shown below:
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod rtl8xxxu
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod rtl8723be
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod rtl8723ae
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod rtl8192ee
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod rtl8821ae
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod rtl8723-common
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod btcoexist
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod rtl8188ee
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod rtl8192de
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod rtl8192se
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod rtl8192cu
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod rtl8192ce
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod rtl8192c-common
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod rtl_usb
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod rtl_pci
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod rtlwifi
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 lib80211
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod cfg80211
test@test-V520-15IKL:~/linux-6.9$ sudo rmmod libarc4
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 rtlwifi folder:
test@test-V520-15IKL:~/linux-6.9$ sudo make -C . M=drivers/net/wireless/realtek/rtl8xxxu/
make: Entering directory "/home/test/linux-6.9"
CC [M] drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.o
CC [M] drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.o
CC [M] drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.o
CC [M] drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.o
CC [M] drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.o
CC [M] drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.o
CC [M] drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.o
CC [M] drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8710b.o
CC [M] drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192f.o
LD [M] drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.o
MODPOST drivers/net/wireless/realtek/rtl8xxxu/Module.symvers
CC [M] drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.mod.o
LD [M] drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.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/realtek/rtl8xxxu/ directory:
test@test-V520-15IKL:~/linux-6.9$ find ./drivers/net/wireless/realtek/rtl8xxxu/ -iname "*.ko" -print
./drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.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/realtek/rtl8xxxu/ -iname "*.ko.zst*" -print
/lib/modules/6.9.0/kernel/drivers/net/wireless/realtek/rtlwifi/rtl8xxxu.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/realtek/rtlwifi/rtlwifi.ko
sudo insmod ./drivers/net/wireless/realtek/rtlwifi/rtl_pci.ko
sudo insmod ./drivers/net/wireless/realtek/rtlwifi/rtl_usb.ko
sudo insmod ./drivers/net/wireless/realtek/rtlwifi/rtl8192c/rtl8192c-common.ko
sudo insmod ./drivers/net/wireless/realtek/rtlwifi/rtl8192ce/rtl8192ce.ko
sudo insmod ./drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rtl8192cu.ko
sudo insmod ./drivers/net/wireless/realtek/rtlwifi/rtl8192se/rtl8192se.ko
sudo insmod ./drivers/net/wireless/realtek/rtlwifi/rtl8192de/rtl8192de.ko
sudo insmod ./drivers/net/wireless/realtek/rtlwifi/rtl8188ee/rtl8188ee.ko
sudo insmod ./drivers/net/wireless/realtek/rtlwifi/btcoexist/btcoexist.ko
sudo insmod ./drivers/net/wireless/realtek/rtlwifi/rtl8723com/rtl8723-common.ko
sudo insmod ./drivers/net/wireless/realtek/rtlwifi/rtl8821ae/rtl8821ae.ko
sudo insmod ./drivers/net/wireless/realtek/rtlwifi/rtl8192ee/rtl8192ee.ko
sudo insmod ./drivers/net/wireless/realtek/rtlwifi/rtl8723ae/rtl8723ae.ko
sudo insmod ./drivers/net/wireless/realtek/rtlwifi/rtl8723be/rtl8723be.ko
sudo insmod ./drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.ko
test@test-V520-15IKL:~/linux-6.9$ lsmod
Module Size Used by
rtl8xxxu 286720 0
rtl8723be 167936 0
rtl8723ae 159744 0
rtl8192ee 180224 0
rtl8821ae 352256 0
rtl8723_common 28672 2 rtl8723be,rtl8723ae
btcoexist 278528 4 rtl8821ae,rtl8723be,rtl8723ae,rtl8192ee
rtl8188ee 176128 0
rtl8192de 196608 0
rtl8192se 126976 0
rtl8192cu 110592 0
rtl8192ce 102400 0
rtl8192c_common 90112 2 rtl8192cu,rtl8192ce
rtl_usb 20480 1 rtl8192cu
rtl_pci 40960 8 rtl8188ee,rtl8821ae,rtl8723be,rtl8723ae,rtl8192ee,rtl8192de,rtl8192se,rtl8192ce
rtlwifi 139264 14 rtl_pci,rtl8188ee,rtl8821ae,rtl8192c_common,rtl_usb,rtl8192cu,rtl8723be,btcoexist,rtl8723ae,rtl8192ee,rtl8192de,rtl8192se,rtl8192ce,rtl8723_common
mac80211 1691648 12 rtl_pci,rtl8188ee,rtl8821ae,rtl_usb,rtl8192cu,rtl8723be,rtl8723ae,rtlwifi,rtl8192ee,rtl8xxxu,rtl8192se,rtl8192ce
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 1318912 3 rtlwifi,mac80211,rtl8xxx
test@test-V520-15IKL:~/linux-6.9$ iwconfig
lo no wireless extensions.
enp1s0 no wireless extensions.
wlx503eaa8c24ae IEEE 802.11 ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=off
Retry short limit:7 RTS thr=2347 B Fragment thr:off
Power Management:on
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/realtek/rtlwifi/base.c
./drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
./drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.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 rtl8xxxu_core.c file with vim, add prints in all functions in rtl8xxxu_ops
test:linux-6.9/drivers/net/wireless/realtek/rtl8xxxu$ vi rtl8xxxu_core.c
static const struct ieee80211_ops rtl8xxxu_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 = rtl8xxxu_tx,
.wake_tx_queue = ieee80211_handle_wake_tx_queue,
.add_interface = rtl8xxxu_add_interface,
.remove_interface = rtl8xxxu_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,
};