How to build a 6GHz WiFi client with a Raspberry Pi and Netgear A8000
Tags: linux, raspberrypi, wifi6e, 6ghz
Published: 2023-06-26 08:16:53

The use of 6GHz WiFi band has been approved in Japan since September 2022.
This article ([Japanese](https://qiita.com/wataniguchi/items/e61130686f3f3e97bde0)) provides detailed instructions to build a 6GHz WiFi client there, using a Raspberry Pi and a Netgear A8000.
It is most likely that these instructions are applicable in any country where the use of 6GHz is allowed.  However, it is not tested outside of Japan.
Instructions to build a 6GHz Access Point is covered by separate articles [How to build a 6GHz WiFi Router Mode AP with a Raspberry Pi and Netgear A8000](https://dev.to/wataniguchi/how-to-build-a-6ghz-wifi-router-mode-ap-with-a-raspberry-pi-and-netgear-a8000-31om) and [How to build a 6GHz WiFi Bridge Mode AP with a Raspberry Pi and Netgear A8000](https://dev.to/wataniguchi/how-to-build-a-6ghz-wifi-bridge-mode-ap-with-a-raspberry-pi-and-netgear-a8000-2ojc).

# Task Summary

- Force the standard mt7921u driver to recognize A8000
- Refresh Linux Wireless Regulatory Database to reflect the addition of 6GHz band WiFi
- Renew MediaTek WiFi firmware
- Upgrade WPA Supplicant to v2.10

# Prerequisites and Assumptions

- Raspberry Pi OS version is Bullseye, i.e., kernel 6.1
- Interface name for the onboard WiFi is wlan0 while that for A8000 is wlan1
- Instructions described in this article are for Japan

# Force the standard mt7921u driver to recognize A8000

Create a new file `/etc/udev/rules.d/90-usb-0846:9060-mt7921u.rules` as below, following the instructions about A8000 on [this page](https://github.com/morrownr/USB-WiFi/blob/main/home/USB_WiFi_Adapters_that_are_supported_with_Linux_in-kernel_drivers.md).

```
ACTION=="add", \
	SUBSYSTEM=="usb", \
	ENV{ID_VENDOR_ID}=="0846", \
	ENV{ID_MODEL_ID}=="9060", \
	RUN+="/usr/sbin/modprobe mt7921u", \
	RUN+="/bin/sh -c 'echo 0846 9060 > /sys/bus/usb/drivers/mt7921u/new_id'"
```

This enables A8000 to be automatically recognized at boot for the use of existing WiFi bands.


# Refresh Linux Wireless Regulatory Database to reflect the addition of 6GHz band WiFi

You can see that the use of 6GHz WiFi in Japan has not yet been reflected to the Bullseye's regulatory database by the command `iw reg get`.  The timestamp of `wireless-regdb` package, April 2022, explains why.  It is before the approval that took place in September of the year.

```
~ $ iw reg get
global
country JP: DFS-JP
	(2402 - 2482 @ 40), (N/A, 20), (N/A)
	(2474 - 2494 @ 20), (N/A, 20), (N/A), NO-OFDM
	(4910 - 4990 @ 40), (N/A, 23), (N/A)
	(5170 - 5250 @ 80), (N/A, 20), (N/A), AUTO-BW
	(5250 - 5330 @ 80), (N/A, 20), (0 ms), DFS, AUTO-BW
	(5490 - 5710 @ 160), (N/A, 23), (0 ms), DFS
	(57000 - 66000 @ 2160), (N/A, 10), (N/A)
~ $ apt list --installed | grep regdb
wireless-regdb/stable,now 2022.04.08-2~deb11u1 all [installed]
```

Obtain the newest distribution file from [the distribution site](https://mirrors.edge.kernel.org/pub/software/network/wireless-regdb/) and copy its binary database file to `/lib/crda`.

```
xzcat wireless-regdb-2023.05.03.tar.xz | tar -xvf -
cd wireless-regdb-2023.05.03/
sudo mv /lib/crda/regulatory.bin /lib/crda/regulatory.bin.orig
sudo cp regulatory.bin /lib/crda
```

Make sure the new band gets included by the command `iw reg get` after reboot.

```
~ $ iw reg get
global
country JP: DFS-JP
	(2402 - 2482 @ 40), (N/A, 20), (N/A)
	(2474 - 2494 @ 20), (N/A, 20), (N/A), NO-OFDM
	(4910 - 4990 @ 40), (N/A, 23), (N/A)
	(5170 - 5250 @ 80), (N/A, 20), (N/A), AUTO-BW
	(5250 - 5330 @ 80), (N/A, 20), (0 ms), DFS, AUTO-BW
	(5490 - 5730 @ 160), (N/A, 23), (0 ms), DFS
	(5925 - 6425 @ 160), (N/A, 23), (N/A), NO-OUTDOOR
	(57000 - 66000 @ 2160), (N/A, 10), (N/A)
```

# Renew MediaTek WiFi firmware

Bullseye comes with a version of MediaTek WiFi firmware, which is no longer the newest.  You can renew the firmware, following the instructions on [this page](https://github.com/morrownr/USB-WiFi/blob/main/home/How_to_Install_Firmware_for_Mediatek_based_USB_WiFi_adapters.md).
The original version is found to be `____010000-20220908211021` by the command `ethtool -i wlan1`.

```
~ $ ethtool -i wlan1
driver: mt7921u
version: 6.1.21-v8+
firmware-version: ____010000-20220908211021
expansion-rom-version: 
bus-info: 1-1.4:1.0
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: no
supports-priv-flags: no
```

Download files for MT7921 chipset from [MediaTek firmware for Linux distribution site](https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/mediatek) and copy them to `/lib/firmware/mediatek`.
```
sudo mv /lib/firmware/mediatek/WIFI_MT7961_patch_mcu_1_2_hdr.bin /lib/firmware/mediatek/WIFI_MT7961_patch_mcu_1_2_hdr.bin.orig
sudo mv /lib/firmware/mediatek/WIFI_RAM_CODE_MT7961_1.bin /lib/firmware/mediatek/WIFI_RAM_CODE_MT7961_1.bin.orig
sudo cp WIFI_MT7961_patch_mcu_1_2_hdr.bin /lib/firmware/mediatek
sudo cp WIFI_RAM_CODE_MT7961_1.bin /lib/firmware/mediatek
```

The refreshed version is found to be `____010000-20230526130958` by the command `ethtool -i wlan1`.

```
~ $ ethtool -i wlan1
driver: mt7921u
version: 6.1.21-v8+
firmware-version: ____010000-20230526130958
expansion-rom-version: 
bus-info: 1-1.4:1.0
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: no
supports-priv-flags: no
```

# Upgrade WPA Supplicant to v2.10

You have to upgrade WPA Supplicant to v2.10 as [there are some WiFi 6E functionalities not ready on v2.9](https://medium.com/@barry_wu.me/how-to-connect-wi-fi-6e-ap-over-the-6-ghz-band-with-ubuntu-21-04-2a0b4f071ac2).  Since hostapd is also have to be upgraded to v2.10 for AP, let's download `hostap_2_10.tar.gz` package that incorporate both WPA Supplicant and hostapd from [its distribution site](https://w1.fi/cgit/hostap/).
```
tar -xzvf hostap_2_10.tar.gz
cd hostap_2_10/wpa_supplicant
cp defconfig .config
make
sudo mv /usr/sbin/wpa_supplicant /usr/sbin/wpa_supplicant_2_9
sudo cp wpa_supplicant /usr/sbin
sudo mv /usr/sbin/wpa_cli /usr/sbin/wpa_cli_2_9
sudo cp wpa_cli /usr/sbin
```

# Direct wlan1/A8000 to connect to a different network

Change WPA supplicant configuration such that wlan0/onboard WiFi and wlan1/A8000 to connect to different networks.
```
cd /etc/wpa_supplicant
sudo mv wpa_supplicant.conf wpa_supplicant-wlan0.conf
```

Create a new file `wpa_supplicant-wlan1.conf` as below.  Do not forget to change `ssid=` and `sae_password=` appropriately.
```
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
pmf=2
sae_pwe=1

network={
	scan_ssid=1
	ssid="foo-ax"
	key_mgmt=SAE
	proto=RSN
	ieee80211w=2
	sae_password="foobar"
	pairwise=CCMP
	group=CCMP
}
```
You can optionally disable the use of wlan0/onboard WiFi by `sudo iwconfig wlan0 txpower off`.

# Done

See if you are on 6GHz by `iwconfig`.
```
~ $ iwconfig
lo        no wireless extensions.

wlan0     IEEE 802.11  ESSID:off/any  
          Mode:Managed  Access Point: Not-Associated   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:on
          
wlan1     IEEE 802.11  ESSID:"foo-ax"  
          Mode:Managed  Frequency:6.235 GHz  Access Point: 94:18:65:xx:xx:xx   
          Bit Rate=286.7 Mb/s   Tx-Power=3 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:on
          Link Quality=70/70  Signal level=-31 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0
```