[BPI-R64] mt7622 mac80211 WiFi driver

I am testing wifi now and found out that ping from bpi-r64 to connected device (my phone) is too long - several times > 1 second:

    sa@bananapir64:~$ ping 172.30.1.143
    PING 172.30.1.143 (172.30.1.143) 56(84) bytes of data.
    64 bytes from 172.30.1.143: icmp_seq=1 ttl=64 time=1210 ms
    64 bytes from 172.30.1.143: icmp_seq=2 ttl=64 time=201 ms
    64 bytes from 172.30.1.143: icmp_seq=3 ttl=64 time=1356 ms
    64 bytes from 172.30.1.143: icmp_seq=4 ttl=64 time=341 ms
    64 bytes from 172.30.1.143: icmp_seq=5 ttl=64 time=774 ms
    64 bytes from 172.30.1.143: icmp_seq=6 ttl=64 time=6.10 ms
    64 bytes from 172.30.1.143: icmp_seq=7 ttl=64 time=193 ms
    64 bytes from 172.30.1.143: icmp_seq=8 ttl=64 time=1354 ms
    64 bytes from 172.30.1.143: icmp_seq=9 ttl=64 time=335 ms
    64 bytes from 172.30.1.143: icmp_seq=10 ttl=64 time=769 ms
    64 bytes from 172.30.1.143: icmp_seq=11 ttl=64 time=6.46 ms
    64 bytes from 172.30.1.143: icmp_seq=12 ttl=64 time=199 ms
    64 bytes from 172.30.1.143: icmp_seq=13 ttl=64 time=1349 ms
    64 bytes from 172.30.1.143: icmp_seq=14 ttl=64 time=329 ms
    64 bytes from 172.30.1.143: icmp_seq=15 ttl=64 time=763 ms
    64 bytes from 172.30.1.143: icmp_seq=16 ttl=64 time=73.6 ms
    ^C
    --- 172.30.1.143 ping statistics ---
    16 packets transmitted, 16 received, 0% packet loss, time 91ms
    rtt min/avg/max/mdev = 6.096/578.547/1355.555/489.164 ms, pipe 2

My hostapd.conf:

sa@bananapir64:~$ sed -E 's/^(wpa_passphrase|ssid)=(.*)/\1=***/g' /etc/hostapd/hostapd.conf
ctrl_interface=/var/run/hostapd
#ctrl_interface_group=0 # These 2 are just parameters so that the hostap daemon runs.

interface=wlan0
#interface=ap0
driver=nl80211

ssid=***

#2.4G
hw_mode=g
channel=1
#wmm_enabled=1

#5G-Support
#country_code=DE
#ieee80211n=1
#ieee80211d=1
#hw_mode=a
#channel=48

#security
#wpa=2
#wpa_passphrase=12345678
#wpa_key_mgmt=WPA-PSK
#wpa_pairwise=TKIP CCMP
#ignore_broadcast_ssid=0
auth_algs=1
#rsn_pairwise=CCMP

#macaddr_acl=0
#accept_mac_file=/etc/hostapd/acl_accept
#deny_mac_file=/etc/hostapd/acl_deny

# https://wiki.gentoo.org/wiki/Hostapd
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
wpa_passphrase=***

It seems not fine. I have antenna connected to WF0 and phone 1 meter away.

Wifi analyzer shows -59dbm

Is it possible to reduce e.g. to 0.3 sec?

do you running with bridge or standalone/routing? can you test ping-time in standalone-mode (pinging wlan0-ip from client)?

-59dBm sounds like bad quality for 1m distance, have you checked all connections?

Yes, I run it standalone, without bridge:

$ ip addr show wlan0
10: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 7a:9b:e6:8b:bf:08 brd ff:ff:ff:ff:ff:ff
    inet 172.30.1.129/25 brd 172.30.1.255 scope global wlan0
       valid_lft forever preferred_lft forever

Hmm, from my notebook to wlan0 address ping is ok:

$ ping 172.30.1.129
PING 172.30.1.129 (172.30.1.129) 56(84) bytes of data.
64 bytes from 172.30.1.129: icmp_seq=1 ttl=64 time=2.59 ms
64 bytes from 172.30.1.129: icmp_seq=2 ttl=64 time=3.39 ms
64 bytes from 172.30.1.129: icmp_seq=3 ttl=64 time=4.22 ms
64 bytes from 172.30.1.129: icmp_seq=4 ttl=64 time=21.3 ms
64 bytes from 172.30.1.129: icmp_seq=5 ttl=64 time=3.39 ms
64 bytes from 172.30.1.129: icmp_seq=6 ttl=64 time=6.27 ms
64 bytes from 172.30.1.129: icmp_seq=7 ttl=64 time=3.50 ms

But backward, from wlan0 address to wifi-client, e.g. my notebook, is not good:

sa@bananapir64:~$ ping 172.30.1.144
PING 172.30.1.144 (172.30.1.144) 56(84) bytes of data.
64 bytes from 172.30.1.144: icmp_seq=1 ttl=64 time=3.08 ms
64 bytes from 172.30.1.144: icmp_seq=2 ttl=64 time=169 ms
64 bytes from 172.30.1.144: icmp_seq=3 ttl=64 time=622 ms
64 bytes from 172.30.1.144: icmp_seq=4 ttl=64 time=3.10 ms
64 bytes from 172.30.1.144: icmp_seq=5 ttl=64 time=623 ms
64 bytes from 172.30.1.144: icmp_seq=6 ttl=64 time=6.68 ms
64 bytes from 172.30.1.144: icmp_seq=7 ttl=64 time=106 ms
64 bytes from 172.30.1.144: icmp_seq=8 ttl=64 time=1076 ms
64 bytes from 172.30.1.144: icmp_seq=9 ttl=64 time=72.7 ms
64 bytes from 172.30.1.144: icmp_seq=10 ttl=64 time=606 ms
64 bytes from 172.30.1.144: icmp_seq=11 ttl=64 time=200 ms
64 bytes from 172.30.1.144: icmp_seq=12 ttl=64 time=393 ms

Btw, iperf is showing max 30 Mbits/sec.

iperf -s -u -i 1
iperf -c 172.30.1.129 -u -b 1m -l 1300 -t 100

# 1mbit/s
[  3] local 172.30.1.129 port 5001 connected with 172.30.1.144 port 46101
[ ID] Interval       Transfer     Bandwidth        Jitter   Lost/Total Datagrams
[  3]  0.0- 1.0 sec   123 KBytes  1.01 Mbits/sec   0.078 ms    0/   97 (0%)
[  3]  1.0- 2.0 sec   123 KBytes  1.01 Mbits/sec   0.253 ms    0/   97 (0%)
[  3]  2.0- 3.0 sec   122 KBytes   998 Kbits/sec   0.096 ms    0/   96 (0%)
[  3]  3.0- 4.0 sec   122 KBytes   998 Kbits/sec   0.134 ms    0/   96 (0%)
[  3]  4.0- 5.0 sec   122 KBytes   998 Kbits/sec   0.303 ms    0/   96 (0%)
[  3]  5.0- 6.0 sec   122 KBytes   998 Kbits/sec   0.182 ms    0/   96 (0%)
[  3]  6.0- 7.0 sec   122 KBytes   998 Kbits/sec   0.044 ms    0/   96 (0%)

# 10mbit/s
[  4] local 172.30.1.129 port 5001 connected with 172.30.1.144 port 56346
[  4]  0.0- 1.0 sec  1.20 MBytes  10.1 Mbits/sec   0.308 ms    0/  971 (0%)
[  4]  1.0- 2.0 sec  1.19 MBytes  10.0 Mbits/sec   0.038 ms    0/  962 (0%)
[  4]  2.0- 3.0 sec  1.19 MBytes  9.99 Mbits/sec   0.058 ms    0/  961 (0%)
[  4]  3.0- 4.0 sec  1.19 MBytes  10.0 Mbits/sec   0.052 ms    0/  962 (0%)
[  4]  4.0- 5.0 sec  1.19 MBytes  9.99 Mbits/sec   0.210 ms    0/  961 (0%)
[  4]  5.0- 6.0 sec  1.19 MBytes  10.0 Mbits/sec   0.033 ms    0/  962 (0%)
[  4]  6.0- 7.0 sec  1.19 MBytes  9.99 Mbits/sec   0.050 ms    0/  961 (0%)
[  4]  7.0- 8.0 sec  1.19 MBytes  10.0 Mbits/sec   0.045 ms    0/  962 (0%)
[  4]  8.0- 9.0 sec  1.19 MBytes  9.99 Mbits/sec   0.180 ms    0/  961 (0%)

# 30mbit/s
[  3] local 172.30.1.129 port 5001 connected with 172.30.1.144 port 33150
[ ID] Interval       Transfer     Bandwidth        Jitter   Lost/Total Datagrams
[  3]  0.0- 1.0 sec  3.61 MBytes  30.3 Mbits/sec   0.075 ms    0/ 2909 (0%)
[  3]  1.0- 2.0 sec  3.57 MBytes  29.9 Mbits/sec   0.053 ms    0/ 2879 (0%)
[  3]  2.0- 3.0 sec  3.58 MBytes  30.0 Mbits/sec   0.106 ms    0/ 2887 (0%)
[  3]  3.0- 4.0 sec  3.48 MBytes  29.2 Mbits/sec   0.504 ms    0/ 2803 (0%)
[  3]  4.0- 5.0 sec  3.50 MBytes  29.4 Mbits/sec   0.704 ms    0/ 2826 (0%)
[  3]  5.0- 6.0 sec  3.56 MBytes  29.9 Mbits/sec   0.825 ms    0/ 2871 (0%)
[  3]  6.0- 7.0 sec  3.48 MBytes  29.2 Mbits/sec   0.564 ms    0/ 2809 (0%)
[  3]  7.0- 8.0 sec  3.61 MBytes  30.3 Mbits/sec   0.709 ms    0/ 2911 (0%)
[  3]  8.0- 9.0 sec  3.58 MBytes  30.0 Mbits/sec   0.371 ms    0/ 2887 (0%)
[  3]  0.0- 9.8 sec  34.9 MBytes  29.8 Mbits/sec   1.221 ms    0/28159 (0%)

About connections, I just do it this way:

Pingtime is time for both directions (round trip time). Initial send of icmp echo request and receive of corresponding echo reply.

Are you sure you have no disturbing effects (walls between r64 and client,overlapping wifi,…)?

I understand it. Nevertheless, there is quite a difference if I ping from r64 and to r64 o_O

Are you sure you have no disturbing effects (walls between r64 and client,overlapping wifi,…)?

Nope, you can see at the picture the antenna itself and the part of my notebook.

Did you update WiFi RF calibration data into flash?(dd if=MT7622_EEPROM.bin of=/dev/mtd3)

Can i use calibrationdata if i have no mtd (debian/ubuntu)?

Can i use calibrationdata if i have no mtd (debian/ubuntu)?

This mt76 driver loads eeprom kinda tricky (look at eeprom.c). First, there is parameter in wmac node:

mediatek,mtd-eeprom = <(reference) (offset)>;

where (reference) - reference to partition definiton, (offset) - offset in it.

Driver looks for mtd-eeprom parameter, follow to partition reference, take label of it and then uses mtd subsystem to load content by partiton label. So, actually, only label is needed from device tree.

Next, you can simulate mtd by using block2mtd driver, which makes mtd devices from common block devices (like emmc/sd). Also there is cmdline parser which can make mtd partitioning. You can enable both driver and parser:

CONFIG_MTD_BLOCK2MTD=y
CONFIG_MTD_CMDLINE_PARTS=y

Next, we need to create virtual mtd device and made fake partition for mt76 in dts, example from OpenWRT build for eMMC:

bootargs = "earlycon=uart8250,mmio32,0x11002000 console=ttyS0,115200n1 swiotlb=512 block2mtd.block2mtd=/dev/mmcblk0,65536,eMMC,5 mtdparts=eMMC:768k(mbr),512k(uboot),512k(uboot-env),256k(factory),-(firmware)"
&mmc0 {
        ....
        /* Fake card and partition, just for taking name "factory" */
	emmc@0 {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "mmc-card";
		reg = <0>;

		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;

			factory: partition@1c0000 {
				label = "factory";
				/* no need actually, just for sure */
				reg = <0x01c0000 0x00040000>;
			};
		};
	};
};
/* EEPROM location */
&wmac {
	mediatek,mtd-eeprom = <&factory 0x0000>;
	status = "okay";
};

For debian, you can create GPT partition somewhere on SD/eMMC card, flash EEPROM to it. For example, 256k EEPROM partition at 204800 sector (100MiB), then dts will looks like

bootargs = "... block2mtd.block2mtd=/dev/mmcblk1,65536,SD,5 mtdparts=SD:100M(boot),256k(factory),-(root)"
&mmc1 {
        ....
        /* Fake card and partition, just for taking name "factory" */
	sd@0 {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "mmc-card";
		reg = <0>;

		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;

			factory: partition@6400000 {
				label = "factory";
				/* no need actually, just for sure */
				reg = <0x06400000 0x00040000>;
			};
		};
	};
};
&wmac {
	mediatek,mtd-eeprom = <&factory 0x0000>;
	status = "okay";
};

However, you should use block2mtd driver (drivers/mtd/devices/block2mtd.c) from OpenWRT tree, because vanilla driver uses auto-generated mtd names with colon, which breaks mtdparts

2 Likes

I had the same problem so hardcoded it into mt76 driver from OpenWRTMT7615e_7622_eeprom_hardcoded.patch (7.9 KB) TX power is working correct now. I did not trace if driver is using it as a real EEPROM but for read only calibration works ok.

I’ve connected 4 antennas to the board, how does the board decides which device uses which antenna?

Doing a speed test gives about 100mbps for each device if ran separately. If I run a speed test on 2 devices at the same time one device gets 40, another one gets 20, which looks like both devices use the same antenna.

Shouldn’t they bot get 100mbps and both use different antennas?

I’m running master openwrt.

[   21.396876] mt7622-wmac 18000000.wmac: HW/SW Version: 0x8a108a10, Build Time: 20190801210006a
[   21.427145] mt7622-wmac 18000000.wmac: N9 Firmware Version: 2.0, Build Time: 20200131180931

i guess currently only one antenna is used…i see a Patch on patchwork which seems to be related to this (but only pinctl), there should be also a driver+dts-change to use these pinctl to use multiple antennas

https://patchwork.kernel.org/patch/11792841/

Interesting find, I guess this only affects mt7622 wmac but not mt7615?

@moore any info on this?

Right,this patch is only for mt7622,but i guess for mt7615 there should be a similar way as mt7622 uses mt7615 core

Hi,

The four antennas on the board are all for MT7622 WiFi, could you explain more that what did you mean about “how does the board decides which device uses which antenna”?

I’ve tested the latest driver, and it can use rate MCS31 (4 antennas).

root@OpenWrt:/# iw phy | grep Antennas
        Available Antennas: TX 0xf RX 0xf
        Configured Antennas: TX 0xf RX 0xf

root@OpenWrt:/# iw dev wlan0 station dump
Station 2c:fd:a1:ce:5e:a9 (on wlan0)
        inactive time:  8 ms
        rx bytes:       12685717
        rx packets:     169384
        tx bytes:       812461366
        tx packets:     271666
        tx retries:     75596
        tx failed:      150
        rx drop misc:   1
        signal:         -43 [-43, -60, -44, -44] dBm
        signal avg:     -43 [-43, -59, -44, -44] dBm
        tx bitrate:     288.9 MBit/s MCS 31 short GI
        tx duration:    41637653 us
        rx bitrate:     288.9 MBit/s MCS 31 short GI
        rx duration:    1901454 us
1 Like

Needs the MCS31 mode enabled? How?

is your latest branch fixed to use 4 antennas?

i don’t know if i need additional patches to enable all 4 antennas…thats why i asked how to enable the mode to check

what he meant is to test the speed directly. If the speed of a single antenna is about 100Mbps, the speed of four antennas is more than 200Mbps.

there are two problems with MT7622 wifi, right? first is 6db, and second is antenna. isn’t it repair on your branch?

6db seems to depend on eeprom which cannot be loaded currently without mtd (my file-aproach was denied to be implemented). Antenna i don’t know how to check/set the mcs31 mode.

i can only fix if i know how to do it :slight_smile: