[BPI-R64] mt7622 mac80211 WiFi driver

The mac80211 driver of MT7622 built-in WiFi is now available for newer kernel on bpi-r64.

Note that it is only tested on Openwrt trunk with kernel 4.19 currently, you can follow this guide to change the default kernel version.

The following parts will focus on how to build an Openwrt image with mt7622 wifi enabled.

Source code

mt76 driver with mt7622 built-in WiFi supported

Necessary Files

All the following files are attached, please download them first.

  • dts patches: for enabling wmac interface
  • mt76 Makefile: add mt7622 kernel module to menuconfig
  • eeprom binary: write default wifi configs into factory partition

Apply patch

Please apply the patch for mt7622 wifi by copying 1000-mt7622-dts-support-emmc-wifi.patch into the following path:


The patch is used for enabling wmac interface and specifying eMMC partitions.

Config WiFi and eMMC

  1. For basic configs and steps of building bpi-r64, please also refer to this guide.

  2. Replace package/kernel/mt76/Makefile with the attached Makefile.

  3. Type make menuconfig, and the option kmod-mt7622 can be seen at:

    Kernel modules -> Wireless Drivers -> kmod-mt7622
  4. (Optional) Enable the following configs with make kernel_menuconfig, it makes mtd partitions of eMMC work normally.


Note that you can just boot the system via initramfs-kernel.bin, on which the mt7622 wifi also works, but if you want to boot with squashfs-sysupgrade.bin, these configs must be set.

  1. Save and exit

Build image

  1. make -j

  2. copy .bin file to your default folder of tftp server, and boot

    (choose *1. System Load Linux to SDRAM via TFTP.* in uBoot menu)
    (choose *2. System Load Linux Kernel then write to Flash via TFTP.* in uBoot menu)
  3. If you boot and load the mt7622 module correctly, you may find the bootlog shows something wrong during eeprom loading. Please refer to the next section.

Update eeprom

The factory partition of bpi-r64 may be empty in some devices, so we need to manually provide a binary to the partition. Just need to do it once.

  1. Check the mtd partitions (on Openwrt). In this example, the "Factory" partition is on mtd3

    root@OpenWrt:/# cat /proc/mtd
    dev:        size      erasesize  name
    mtd0: 000c0000 00010000 "mbr"
    mtd1: 00080000 00010000 "uboot"
    mtd2: 00080000 00010000 "Config"
    mtd3: 00040000 00010000 "Factory"
    mtd4: 02000000 00010000 "Kernel"
    mtd5: 00270000 00010000 "kernel"
    mtd6: 01d80000 00010000 "rootfs"
    mtd7: 013d0000 00010000 "rootfs_data"
    mtd8: 80000000 00010000 "usrdata"
  2. Write MT7622_EEPROM.bin into the partition /dev/mtd3

    dd if=MT7622_EEPROM.bin of=/dev/mtd3
  3. Reboot, the error related to eeprom should be fixed

Some demos

Related bootlog

mt7622_wmac 18000000.wmac: ASIC revision: 76220010
mt7622_wmac 18000000.wmac: MAC addr = 00:0c:43:26:60:50
mt7622_wmac 18000000.wmac: HW/SW Version: 0x8a108a10, Build Time: 20190801210006a

mt7622_wmac 18000000.wmac: N9 Firmware Version: _reserved_, Build Time: 20190801210351
mt7622_wmac 18000000.wmac: Firmware init done
mt7622_wmac 18000000.wmac: Driver own success
ieee80211 phy0: Selected rate control algorithm 'minstrel_ht'

Test results

Peak: (phy rate = 288.9 Mbps)

1000-mt7622-dts-support-emmc-wifi.patch (3.2 KB)

(Updated)1000-mt7622-dts-support-emmc-wifi.patch (3.3 KB)

Makefile_mt76.txt (7.7 KB)

MT7622_EEPROM.bin (1 KB)



first thank you for your work on the driver.

as i’m not using openwrt, i will try to get it working on debian/ubuntu…

where are the mtd-partitions located? are these depending on partitiontable (sd/emmc)? can the firmware simply be loaded from /lib/firmware/mediatek like other firmware?

as it calls request_firmware, it should also load from /lib/firmware

./mt7622/mt7622.h:29:#define MT7622_FIRMWARE_N9		"mediatek/mt7622_n9.bin"
./mt7622/mt7622.h:30:#define MT7622_ROM_PATCH		"mediatek/mt7622_rom_patch.bin"

./mt7622/mcu.c:366:	ret = request_firmware(&fw, MT7622_ROM_PATCH, dev->mt76.dev);
./mt7622/mcu.c:466:	ret = request_firmware(&fw, MT7622_FIRMWARE_N9, dev->mt76.dev);

only filename differs from your version…i did not found right files in firmware-repo


maybe there is another source? from bootlog i guess its the basicly the mt7622_n9.bin maybe with modifications

seems like 4.19 mainline-kernel needs many Patches for cfg80211/mac80211/netlink :frowning: is there any Patchlist applied to openwrt, which i can use?

Hi, I recommend you give it a taste :smile:, and you can also compare the performance after porting.

The bootlog of Openwrt shows the addresses of each partition on eMMc:

Creating 6 MTD partitions on "eMMC":
0x000000000000-0x0000000c0000 : "mbr"
0x0000000c0000-0x000000140000 : "uboot"
0x000000140000-0x0000001c0000 : "Config"
0x0000001c0000-0x000000200000 : "Factory"
0x000000200000-0x000002200000 : "Kernel"
0x000002200000-0x000082200000 : "usrdata"

Since this driver hasn’t upstream yet, the firmware can’t be found in that repo. The existed mt7622pr2h.bin is for bluetooth.

I’ve put the firmware for wifi in my repo, link here.

Openwrt uses the backport version of cfg80211/mac80211, which can be retrieved here.

Also, some patches can be found at:

1 Like


are the mtd memory-only partitions or written to emmc? on second case i need to check if anything else is affected (preloader,head0,head1,atf,uboot,…,existing partitions BPI-BOOT/BPI-ROOT)

thank you for the firmware-files…i will try this instead :slight_smile: since it is the linux way :wink:

for the mac/cfg80211 patches, second link i found no related to this before…first one i’m searching the patches needed…have not seen the ones i got from patchwork

IEEE80211_KEY_FLAG_GENERATE_MMIE => https://patchwork.kernel.org/patch/11045085/

needs IEEE80211_KEY_FLAG_NO_AUTO_TX for applying => https://patchwork.kernel.org/patch/10860335/

“NLA_POLICY_MAX(NLA_U32, NUM_NL80211_KEYTYPES - 1)” needs this: https://patchwork.kernel.org/patch/10623157/

nl80211_ftm_responder_policy this needs this https://patchwork.kernel.org/patch/10608889/

NL80211_EXT_FEATURE_CAN_REPLACE_PTK0 => https://patchwork.kernel.org/patch/11179155/

last cannot be applied due to missing rtw88 driver…

if i apply first patch manually (ignoring the missing BIT9 value) i get undeclared IEEE80211_HW_TX_STATUS_NO_AMPDU_LEN (https://patchwork.kernel.org/patch/10767013/) which depends on string “MMPDUs on station interfaces” i don’t find any Patch on Patchwork…

i guess it’s easier to integrate in 5.4…seems 5.4 does not need any additional Patches :slight_smile: only some small fixes…

driver compiles without any issues…i guess i need only dts-changes now and then can test

btw. i suggest renaming the CONFIG-Symbol as MT7622 is not only a wifi-symbol and may collide with some other symbol…maybe something like MT7622_WIFI or similar

[   11.592573] mt7622_wmac 18000000.wmac: ASIC revision: 76220010                                                                          
[   11.599222] mt7622_wmac 18000000.wmac: Invalid MAC address, using random address 22:03:c9:0f:1b:84                                      
[   11.608243] mt7622_wmac 18000000.wmac: MAC addr = 22:03:c9:0f:1b:84                                                                     
[   11.633005] mt7622_wmac 18000000.wmac: N9 Firmware Version: _reserved_, Build Time: 20190801210351                                      
[   11.664384] Bluetooth: hci0: Device setup in 331942 usecs                                                                               
[   11.708029] mt7622_wmac 18000000.wmac: Firmware init done                                                                               
[   11.733544] mt7622_wmac 18000000.wmac: Driver own success 

4: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000                                                     
    link/ether 22:03:c9:0f:1b:84 brd ff:ff:ff:ff:ff:ff

root@bpi-r64:~# uname -a                                                                                                                   
Linux bpi-r64 5.4.0-rc1-r64 #15 SMP PREEMPT Fri Nov 22 16:04:17 CET 2019 aarch64 GNU/Linux

but hostapd gives me this:

nl80211: Set mode ifindex 4 iftype 3 (AP)                                                                                                  
nl80211: Setup AP(wlan0) - device_ap_sme=0 use_monitor=0                                                                                   
nl80211: Subscribe to mgmt frames with AP handle 0x5560da2380                                                                              
nl80211: Register frame type=0xb0 (WLAN_FC_STYPE_AUTH) nl_handle=0x5560da2380 match=                                                       
nl80211: Register frame command failed (type=176): ret=-114 (Operation already in progress)                                                
nl80211: Register frame match - hexdump(len=0): [NULL]                                                                                     
nl80211: Could not configure driver mode                                                                                                   
nl80211: deinit ifname=wlan0 disabled_11b_rates=0                                                                                          
nl80211: Remove monitor interface: refcount=0                                                                                              
nl80211: Remove beacon (ifindex=4)                                                                                                         
netlink: Operstate: ifindex=4 linkmode=0 (kernel-control), operstate=6 (IF_OPER_UP)                                                        
nl80211 driver initialization failed.


#ctrl_interface_group=0 # These 2 are just parameters so that the hostap daemon$




starting like this:

ip addr add dev wlan0
hostapd -dd /etc/hostapd/hostapd.conf

Yes, current Openwrt trunk uses backport-5.4

Thanks, I will rename it in the future update.

Was your network-manager enabled or disabled when you ran hostapd?

I guess you mean nm from gnome systems…as i have headless minimal buster image,i have no such installed…only systemd-networkd

Does ap-mode work in your system? Same config?

AFAIK, the error "nl80211: Could not configure driver mode" is usually caused by the confict between hostapd and nm…

Yes, I use uci command or Luci GUI to directly enable the ap mode. Both of them seem to dynamically generate hostapd config, but I’m not familiar with it yet.

1 Like

it looks anything started hostapd before (directly after install)…i booted again and looked via “ps ax” and saw a hostapd process…killed it, started my again, and i got AP enabled :slight_smile:

looks like it is now started by systemd…

root@bpi-r64:~# systemctl status hostapd -l                                     
hostapd.service - Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authe
   Loaded: loaded (/lib/systemd/system/hostapd.service; enabled; vendor preset: 
   Active: inactive (dead) since Fri 2019-11-22 17:40:52 UTC; 7min ago          
  Process: 239 ExecStart=/usr/sbin/hostapd -B -P /run/hostapd.pid -B $DAEMON_OPT
 Main PID: 250 (code=exited, status=0/SUCCESS)

root@bpi-r64:~# grep CONF /lib/systemd/system/hostapd.service                                                                            
ExecStart=/usr/sbin/hostapd -B -P /run/hostapd.pid -B $DAEMON_OPTS ${DAEMON_CONF}                                                        

but it uses same config, i’ve created :wink:

since i have not yet an antenna connected i don’t see the AP on my phone…but i see some frame events running through the log

1 Like

Good day! in my opinion there is not enough line in the makefile CONFIG_PACKAGE_kmod-mt7622 ? images for the test … https://drive.google.com/drive/folders/1ihHQ3Ab6pq3X24qtA3rm020VpCFW8WQc?usp=sharing Wi-Fi for some reason is trying to start at 5 GHz …

I have problem to build that mt7622 wifi driver.

/home/ubuntu/omr/bpi-r64/source/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2019-11-20-8103cf96/mt7615/pci.c: In function 'mt7615_pci_probe':
/home/ubuntu/omr/bpi-r64/source/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2019-11-20-8103cf96/mt7615/pci.c:78:5: error: 'SURVEY_INFO_TIME_BSS_RX' undeclared (first use in this function); did you mean 'SURVEY_INFO_TIME_RX'?
/home/ubuntu/omr/bpi-r64/source/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2019-11-20-8103cf96/mt7615/pci.c:78:5: note: each undeclared identifier is reported only once for each function it appears in
scripts/Makefile.build:303: recipe for target '/home/ubuntu/omr/bpi-r64/source/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2019-11-20-8103cf96/mt7615/pci.o' failed
make[6]: *** [/home/ubuntu/omr/bpi-r64/source/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2019-11-20-8103cf96/mt7615/pci.o] Error 1
scripts/Makefile.build:544: recipe for target '/home/ubuntu/omr/bpi-r64/source/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2019-11-20-8103cf96/mt7615' failed
make[5]: *** [/home/ubuntu/omr/bpi-r64/source/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2019-11-20-8103cf96/mt7615] Error 2
Makefile:1517: recipe for target '_module_/home/ubuntu/omr/bpi-r64/source/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2019-11-20-8103cf96' failed
make[4]: *** [_module_/home/ubuntu/omr/bpi-r64/source/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2019-11-20-8103cf96] Error 2
make[4]: Leaving directory '/home/ubuntu/omr/bpi-r64/source/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-4.19.72'
Makefile:278: recipe for target '/home/ubuntu/omr/bpi-r64/source/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2019-11-20-8103cf96/.built' failed
make[3]: *** [/home/ubuntu/omr/bpi-r64/source/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2019-11-20-8103cf96/.built] Error 2
make[3]: Leaving directory '/home/ubuntu/omr/bpi-r64/source/package/kernel/mt76'
time: package/kernel/mt76/compile#7.72#1.56#12.11
package/Makefile:111: recipe for target 'package/kernel/mt76/compile' failed
make[2]: *** [package/kernel/mt76/compile] Error 2
make[2]: Leaving directory '/home/ubuntu/omr/bpi-r64/source'
package/Makefile:107: recipe for target '/home/ubuntu/omr/bpi-r64/source/staging_dir/target-aarch64_cortex-a53_musl/stamp/.package_compile' failed
make[1]: *** [/home/ubuntu/omr/bpi-r64/source/staging_dir/target-aarch64_cortex-a53_musl/stamp/.package_compile] Error 2
make[1]: Leaving directory '/home/ubuntu/omr/bpi-r64/source'
/home/ubuntu/omr/bpi-r64/source/include/toplevel.mk:216: recipe for target 'world' failed
make: *** [world] Error 2

which codebase do you use? you have to use very recent version of openwrt because you need 5.4 backport patches…thats why i did not get it compiled on 4.19…5.4 seems to work…got some antennas/cables last days but have not found yet time to connect and test if ap accept connections…only see that wifi-device is created and i can start hostapd on it

I use openmptcprouter, and the openwrt git checkout from: https://github.com/openwrt/openwrt “713561a10b6e9a7100a860651b700207223c09ef”

ok, i do not know openwrt very well…i guess the version you use have not latest backports (this commit has date 3 Months ago…5.4-rc1 is ~ 10 weeks old)

you can try adding this Patch: https://patchwork.ozlabs.org/patch/1175702/ this adds the SURVEY_INFO_TIME_BSS_RX you miss

btw. i had successfully connect to r64 using this driver in debian (after connecting a antenna to one of the 4 wifi-ports)…only a quick test (5.4-r64-main/pcie)

Yes, I have success build mt7622 module with latest openwrt source code. The latest openwrt use 4.19.86 kernel. I will try to build openwrt latest source into omr. Thank you!

@nagi, mt7622 wifi speed up to 288mbps? I have build openwrt (4.19.86 kernel) with your mt7622 module, and the wifi speed only upload 44mbps, download 68mbps. And mt7622 wifi only support 2.4G, not support 5.8G.

@bourne_hlm, thanks for the test.

which kind of client did you use?

288 Mbps is the theoretical phy rate, on 4 streams with MCS31 In my field trial test using cable, the best result I got is around 21X Mbps.

If I use my mobile, which has 2 streams with MCS15 (phy rate = 144), I usually get 70-90 Mbps on DL.

Yes, mt7622 doesn’t have 5G band.

I use my iPhone7Plus, using iperf3 to do speed test. Do you know how many streams iphone7plus have?