[BPI-R64] mt7622 mac80211 WiFi driver

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
nt                                                                              
   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                                                                            
Environment=DAEMON_CONF=/etc/hostapd/hostapd.conf                                                                                        
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'?
     SURVEY_INFO_TIME_BSS_RX,
     ^~~~~~~~~~~~~~~~~~~~~~~
     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?

Hi,

Does the WiFi driver implements client mode?

I tested it to get internet via Wifi (client mode!) for BPI-R64, but failed.

Is it possible to fix that?

I dont have /dev/rfkill, by the way, maybe that is the root cause. The same command at my computer x86 works (I get connection via Wifi).

root@bpi-r64:~# wpa_supplicant -i wlan0 -c <(wpa_passphrase catbo passphrase)
Successfully initialized wpa_supplicant
rfkill: Cannot open RFKILL control device
wlan0: SME: Trying to authenticate with cc:2d:21:14:60:81 (SSID='catbo' freq=2437 MHz)
nl80211: Failed to open /proc/sys/net/ipv6/conf/wlan0/drop_unicast_in_l2_multicast: No such file or directory
nl80211: Failed to set IPv6 unicast in multicast filter
wlan0: SME: Trying to authenticate with cc:2d:21:14:60:81 (SSID='catbo' freq=2437 MHz)
nl80211: Failed to open /proc/sys/net/ipv6/conf/wlan0/drop_unicast_in_l2_multicast: No such file or directory
nl80211: Failed to set IPv6 unicast in multicast filter
wlan0: SME: Trying to authenticate with cc:2d:21:14:60:81 (SSID='catbo' freq=2437 MHz)
nl80211: Failed to open /proc/sys/net/ipv6/conf/wlan0/drop_unicast_in_l2_multicast: No such file or directory
nl80211: Failed to set IPv6 unicast in multicast filter
wlan0: SME: Trying to authenticate with cc:2d:21:14:60:81 (SSID='catbo' freq=2437 MHz)
wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="catbo" auth_failures=1 duration=10 reason=CONN_FAILED
nl80211: Failed to open /proc/sys/net/ipv6/conf/wlan0/drop_unicast_in_l2_multicast: No such file or directory
nl80211: Failed to set IPv6 unicast in multicast filter
^Cnl80211: Failed to open /proc/sys/net/ipv6/conf/wlan0/drop_unicast_in_l2_multicast: No such file or directory
nl80211: Failed to set IPv6 unicast in multicast filter
nl80211: Failed to open /proc/sys/net/ipv6/conf/wlan0/drop_unicast_in_l2_multicast: No such file or directory
nl80211: Failed to set IPv6 unicast in multicast filter
nl80211: deinit ifname=wlan0 disabled_11b_rates=0
wlan0: CTRL-EVENT-TERMINATING 
root@bpi-r64:~#

dmesg at the same time:

[104448.297511] wlan0: authenticate with cc:2d:21:14:60:81                                                                                                                                         
[104448.349616] wlan0: send auth to cc:2d:21:14:60:81 (try 1/3)                                                                                                                                                    
[104448.361821] wlan0: send auth to cc:2d:21:14:60:81 (try 2/3)                                                                                                                                                    
[104448.373934] wlan0: send auth to cc:2d:21:14:60:81 (try 3/3)                                                                                                                                                    
[104448.386182] wlan0: authentication with cc:2d:21:14:60:81 timed out                                                                                                                                             
[104452.541424] wlan0: authenticate with cc:2d:21:14:60:81                                                                                                                                                         
[104452.593539] wlan0: send auth to cc:2d:21:14:60:81 (try 1/3)                                                                                                                                                    
[104452.605874] wlan0: send auth to cc:2d:21:14:60:81 (try 2/3)                                                                                                                                                    
[104452.617989] wlan0: send auth to cc:2d:21:14:60:81 (try 3/3)                                                                                                                                                    
[104452.630210] wlan0: authentication with cc:2d:21:14:60:81 timed out                                                                                                                                             
[104457.185530] wlan0: authenticate with cc:2d:21:14:60:81                                                                                                                                                         
[104457.237700] wlan0: send auth to cc:2d:21:14:60:81 (try 1/3)                                                                                                                                                    
[104457.249998] wlan0: send auth to cc:2d:21:14:60:81 (try 2/3)                                                                                                                                                    
[104457.262245] wlan0: send auth to cc:2d:21:14:60:81 (try 3/3)                                                                                                                                                    
[104457.274466] wlan0: authentication with cc:2d:21:14:60:81 timed out                                                                                                                                             
[104462.333487] wlan0: authenticate with cc:2d:21:14:60:81                                                                                                                                                         
[104462.385575] wlan0: send auth to cc:2d:21:14:60:81 (try 1/3)                                                                                                                                                    
[104462.397729] wlan0: send auth to cc:2d:21:14:60:81 (try 2/3)                                                                                                                                                    
[104462.410166] wlan0: send auth to cc:2d:21:14:60:81 (try 3/3)                                                                                                                                                    
[104462.422325] wlan0: authentication with cc:2d:21:14:60:81 timed out                                                                                                                                             

i tried using this driver in linux 5.5 to test client-mode (added rfkill in my local repo). but i can’t get wifi working

[    6.430384] mt7622_wmac 18000000.wmac: ASIC revision: 76220010               
[    6.477544] mt7622_wmac 18000000.wmac: Invalid MAC address, using random addr
ess 92:ba:4c:49:e4:af                                                           
[    6.546282] mt7622_wmac 18000000.wmac: MAC addr = 92:ba:4c:49:e4:af          
[    6.560631] mt7622_wmac 18000000.wmac: Failed to get patch semaphore         
[    6.572500] mt7622_wmac: probe of 18000000.wmac failed with error -11        
root@bpi-r64:~#

with 5.4-new (i renamed to 5.4-main) (same filesystem) i get here:

[    5.031844] mt7622_wmac 18000000.wmac: ASIC revision: 76220010               
[    5.054045] mt7622_wmac 18000000.wmac: Invalid MAC address, using random addr
ess 0a:15:88:bd:cb:e9                                                           
[    5.096887] mt7622_wmac 18000000.wmac: MAC addr = 0a:15:88:bd:cb:e9          
[    5.123086] mt7622_wmac 18000000.wmac: N9 Firmware Version: _reserved_, Build
 Time: 20190801210351                                                           
[    5.178647] mt7622_wmac 18000000.wmac: Firmware init done                    
[    5.202432] mt7622_wmac 18000000.wmac: Driver own success

tried recompiling 5.4-main and ran into same problem…looks like module is loaded to fast (but time is 1 sec later than old 5.4-new tree, so something seems blocking)…i unloaded module and loaded it again. after that i got

mt7622_wmac 18000000.wmac: Driver own success

@nagi any idea how to fix this?

@Ilya_Murav_jov with rfkill (and stopping hostapd-service) i get this using your command

root@bpi-r64:~# wpa_supplicant -i wlan0 -c <(wpa_passphrase bssid passphrase)                                                                              
Successfully initialized wpa_supplicant                                         
wlan0: CTRL-EVENT-REGDOM-CHANGE init=BEACON_HINT type=UNKNOWN                   
wlan0: SME: Tryi[  989.854265] wlan0: authenticate with 02:08:22:f6:ef:fb       
ng to authenticate with 02:08:22:f6:ef:fb (SSID='r2_AP0' freq=2472 MHz)         
[  989.892684] wlan0: send auth to 02:08:22:f6:ef:fb (try 1/3)                  
[  989.901065] wlan0: authenticated                                             
wlan0: Trying to associate with 02:08:22:f6:ef:f[  989.910216] wlan0: associate 
with 02:08:22:f6:ef:fb (try 1/3)                                                
b (SSID='r2_AP0' freq=2472 MHz)                                                 
[  989.921388] wlan0: RX AssocResp from 02:08:22:f6:ef:fb (capab=0x431 status=0 
aid=3)                                                                          
[  989.957801] wlan0: associated                                                
wlan0: Associated with 02:08:22:f6:ef:fb                                        
wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0                                 
wlan0: WPA: Key [  990.587491] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link become
s ready                                                                         
negotiation completed with 02:08:22:f6:ef:fb [PTK=CCMP GTK=CCMP]                
wlan0: CTRL-EVENT-CONNECTED - Connection to 02:08:22:f6:ef:fb completed [id=0 id
_str=] 

but it seems i need to run manually dhclient to obtain an ip-address…

so only rfkill is missing (and module_unload)…i add to my 5.4-tree

Felix just merged mt7622 related patches into mt76 github and openwrt trunk. you can try this up-to-date driver, thanks.

https://github.com/openwrt/mt76/commits/master https://github.com/openwrt/openwrt/commit/8216766ad97db2f20e30b6622343d8d473ad9d68

i see no mt7622 driver in master/mt7622-branch

It looks like it’s part of 7615…

Is it compatible with my current dts-node? still wondering why root and some others (mt76x0,76x2,7603) do not have a Kconfig file…and still the problem with trace.o (trace.h not found)

after fixing this, i get this on 5.4 with this driver:

drivers/net/wireless/mediatek/mt76_new/mac80211.c: In function 'mt76_phy_init':
drivers/net/wireless/mediatek/mt76_new/mac80211.c:286:31: error: 'NL80211_EXT_FEATURE_AQL' undeclared (first use in this function); did you mean 'NL80211_EXT_FEATURE_TXQS'?
  wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_AQL);
                               ^~~~~~~~~~~~~~~~~~~~~~~
                               NL80211_EXT_FEATURE_TXQS
drivers/net/wireless/mediatek/mt76_new/mac80211.c:286:31: note: each undeclared identifier is reported only once for each function it appears in
drivers/net/wireless/mediatek/mt76_new/mac80211.c: In function 'mt76_airtime_report':
drivers/net/wireless/mediatek/mt76_new/mac80211.c:760:12: error: implicit declaration of function 'ieee80211_calc_rx_airtime'; did you mean 'ieee80211_check_tim'? [-Werror=implicit-function-declaration]
  airtime = ieee80211_calc_rx_airtime(dev->hw, &info, len);
            ^~~~~~~~~~~~~~~~~~~~~~~~~
            ieee80211_check_tim

for first i need this commit: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/include/uapi/linux/nl80211.h?id=911bde0fe5ccd7e55760be9d6dcc67a8850fcc12 => i cannot apply without conflicts in 5/6 files (include/uapi/linux/nl80211.h,net/mac80211/debugfs_sta.c,net/mac80211/main.c,net/mac80211/sta_info.c,net/mac80211/tx.c). except the debugfs-file i have solved them…but this one is tricky (and many changes overlapping)

for second https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/include/net/mac80211.h?id=db3e1c40cf2f973fbdd52ae0b59a9472b1c04f4a

after fixing them…there are many new errors…so new driver not usable for me (at least in 5.4)

net/mac80211/main.c: In function 'ieee80211_alloc_hw_nm':
net/mac80211/main.c:673:7: error: 'struct ieee80211_local' has no member named 'aql_threshold'
  local->aql_threshold = IEEE80211_AQL_THRESHOLD;
       ^~
net/mac80211/main.c:673:25: error: 'IEEE80211_AQL_THRESHOLD' undeclared (first use in this function); did you mean 'IEEE80211_MAX_RTS_THRESHOLD'?
  local->aql_threshold = IEEE80211_AQL_THRESHOLD;
                         ^~~~~~~~~~~~~~~~~~~~~~~
                         IEEE80211_MAX_RTS_THRESHOLD
net/mac80211/main.c:673:25: note: each undeclared identifier is reported only once for each function it appears in
net/mac80211/main.c:674:19: error: 'struct ieee80211_local' has no member named 'aql_total_pending_airtime'
  atomic_set(&local->aql_total_pending_airtime, 0);
                   ^~
scripts/Makefile.build:265: recipe for target 'net/mac80211/main.o' failed
make[2]: *** [net/mac80211/main.o] Error 1
make[2]: *** Waiting for unfinished jobs....
  CC [M]  net/wireless/sysfs.o
net/mac80211/sta_info.c: In function 'ieee80211_sta_update_pending_airtime':
net/mac80211/sta_info.c:1908:25: error: 'struct airtime_info' has no member named 'aql_tx_pending'
        &sta->airtime[ac].aql_tx_pending);
                         ^
net/mac80211/sta_info.c:1910:32: error: 'struct ieee80211_local' has no member named 'aql_total_pending_airtime'
   atomic_add(tx_airtime, &local->aql_total_pending_airtime);
                                ^~
net/mac80211/sta_info.c:1916:30: error: 'struct airtime_info' has no member named 'aql_tx_pending'
             &sta->airtime[ac].aql_tx_pending);
                              ^
net/mac80211/sta_info.c:1920:36: error: 'struct airtime_info' has no member named 'aql_tx_pending'
    atomic_cmpxchg(&sta->airtime[ac].aql_tx_pending,
                                    ^
net/mac80211/sta_info.c:1925:18: error: 'struct ieee80211_local' has no member named 'aql_total_pending_airtime'
            &local->aql_total_pending_airtime);
                  ^~
net/mac80211/sta_info.c:1930:24: error: 'struct ieee80211_local' has no member named 'aql_total_pending_airtime'
   atomic_cmpxchg(&local->aql_total_pending_airtime,
                        ^~
scripts/Makefile.build:265: recipe for target 'net/mac80211/sta_info.o' failed

any chance to fix only the mt7622 semaphore issue? as far as i see it checks status and this failes…maybe a sleep/delay may help?

For kernel 5.5

I’m not sure what’s going on in kernel 5.5, but I’ve got the same error at getting patch semaphore before, which is due to power-domain not enabled.

This may need to be verified, have you noticed any change on this part?

For kernel 5.4 and latest mt76

  1. For the AQL flag, you can try some of these patches, which backport the AQL support to 5.4

  2. For the latest mt7622_wmac dts node, please refer this patch. Also, mt7622/mt7615e share the same module mt7615e.ko

  3. For the problem you need to “unload and load” the module once, does it happen only on using wpa_supplicant or also on hostapd?

I’ve cherry-picked your patches from my older 5.4 branch (where i do not get this error). I guess some recent changes in 5.4 breaking it…

My node contains power-domain

I’m still on 5.4, Or do you mean it is switched on anywhere else/later? Where is powerdomain switched on? It is working on unload/load,so i guess it’s a timing issue.

Currently i do not want to use backport patches because it makes it difficulter applying updates. I only wanted to try newer driver version to compare.

unload/load is independ from hostapd/wpa-supplicant (which depends on wlan-device exists). It is needed to get drivers probe working (patch semaphore) to create the wlan-device.

I’m not familiar with the power domain part, may need some time to dig it out.

For the patches, please apply this series and this patch you applied before, to see if it works on your kernel 5.4.

[v11,0/4] Add Airtime Queue Limits (AQL) to mac80211
[v11,1/4] mac80211: Add new sta_info getter by sta/vif addrs
[v11,2/4] mac80211: Import airtime calculation code from mt76
[v11,3/4] mac80211: Implement Airtime-based Queue Limit (AQL)
[v11,4/4] mac80211: Use Airtime-based Queue Limits (AQL) on packet dequeue

it’s not enough…

./include/net/mac80211.h:1067:6: error: 'struct ieee80211_tx_info' has no member named 'tx_time_est'
  info->tx_time_est = min_t(u16, tx_time_est, 4095) >> 2;

but i want to know why your current version is failing some times on the Patch semaphore…was working on 5.4-r64-rc (5.4.0-rc1), but not on 5.4.12

I has same problem with semaphore, and found out after some time that modules conflict - if rfkill module is loaded earlier than mt7622 then error arise. So I made softdep and the error has gone:

sa@bpi-r64:~$ cat /etc/modprobe.d/wifi.conf 
#blacklist rfkill
softdep rfkill pre: mt7622
sa@bpi-r64:~$ cat /etc/modprobe.d/wifi.conf 
#blacklist rfkill
softdep rfkill pre: mt7622
sa@bpi-r64:~$ dmesg | grep mt7622
[    0.000000] Kernel command line: board=bpi-r64 console=ttyS0,115200n1 earlyprintk root=/dev/mmcblk1p2 rootfstype=ext4 rootwait service=linux debug=7 initcall_debug=0 androidboot.hardware=mt7622 swiotlb=512
[    1.232638] rtc_mt7622 10212800.rtc: registered as rtc0
[    6.134757] rtc_mt7622 10212800.rtc: setting system clock to 2020-02-09T21:51:14 UTC (1581285074)
[   11.082558] mt7622_wmac 18000000.wmac: ASIC revision: 76220010
[   11.089035] mt7622_wmac 18000000.wmac: Invalid MAC address, using random address 7a:d8:70:2d:ea:3d
[   11.098779] mt7622_wmac 18000000.wmac: MAC addr = 7a:d8:70:2d:ea:3d
[   11.121530] mt7622_wmac 18000000.wmac: HW/SW Version: 0x8a108a10, Build Time: 20190801210006a
[   11.159501] mt7622_wmac 18000000.wmac: N9 Firmware Version: _reserved_, Build Time: 20190801210351
[   11.216096] mt7622_wmac 18000000.wmac: Firmware init done
[   11.238435] mt7622_wmac 18000000.wmac: Driver own success
1 Like

thank you, works for me too

softdep rfkill pre: mt7622

sorry for delay…made some tests with uboot and ethernet-driver on this board so tested this too