[BPI-R2] internal Wifi/BT (MT6625L) - Kernel

there is no image because 4.18 is only rc :slight_smile:

but you can download my debian/ubuntu-image and unpack a 4.18-wlan-kernel to it… had merged wlan yesterday to main-branch…

you can (maybe upgrade to 4.18-rc3 first,) compile it by yourself and install it to sd-card

i have uploaded last version here: https://drive.google.com/open?id=17MoFc3vIuGHDEV5SsCmGegJDr009IXls

bpi-r2_4.18.0-rc1_rc.tar.gz

just backup your existing uImage-File in BPI-BOOT/bananapi/bpi-r2/linux/ and look if kernel-var in uEnv.txt is set to uImage

Thanks Frank.

Where should I copy the WMT_SOC.cfg file to? There is no folder named “system” on my SD card (it is Your ubuntu-18.04-bpi-r2-preview.img … thank You for that too).

The file bpi-r2_4.18.0-rc1_rc.tar.gz does not yet contain the last commit from main-branch?

I compiled this yesterday and this is the last version.

You have to create that folder and imho one in etc. For wmt-files i have a tar-file containing all files and my script (simply unpack to rootfs) on my gdrive: https://drive.google.com/open?id=1MJxfHCpR-ph5YJu-_yMTCH5YG9rL6HHY

create a /etc/hostapd/hostapd_ap0.conf and run wifi.sh

for automatic creation this is simply done: wmt_loader.c:18++

#define WCN_COMBO_LOADER_DEV                "/dev/wmtdetect"
gLoaderFd = open(WCN_COMBO_LOADER_DEV, O_RDWR | O_NOCTTY);
// Get Device ID
chipId = ioctl(gLoaderFd, COMBO_IOCTL_GET_SOC_CHIP_ID, NULL);
// Set Device ID
iRet = ioctl(gLoaderFd, COMBO_IOCTL_SET_CHIP_ID, chipId);
// do module init 
iRet = ioctl(gLoaderFd, COMBO_IOCTL_DO_MODULE_INIT, chipId);

these values are handled here:

drivers/misc/mediatek/connectivity/common/common_detect/wmt_detect.c:83 static long wmt_detect_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)

so we need to place the wmtloader-code in wmt_detect.c instead of waiting for a file-operation

I’m trying to get things working on OpenWrt with 3.14 kernel and those drivers on top and having some problems with that. Either a device cannot connect claiming WPA handshake failed or, sometimes, it can connect but then works only for a couple of minutes, gets disassociated and continues to fail WPA handshakes then. I have custom patches that rename interfaces (to get OpenWrt play better with them) but apart from that it’s effectively @frank-w 's drivers port[1]. Any idea what is going wrong? Errors on hostapd side are pretty vague:

root@abbradarrouter:~# hostapd hostapd-mtkp2p0.conf 
Configuration file: hostapd-mtkp2p0.conf
mtkap0: interface state UNINITIALIZED->COUNTRY_UPDATE
mtkap0: interface state COUNTRY_UPDATE->HT_SCAN
Using interface mtkap0 with hwaddr 02:08:22:00:0b:c6 and ssid "foo"
mtkap0: interface state HT_SCAN->ENABLED
mtkap0: AP-ENABLED 
mtkap0: STA c4:0b:cb:85:b9:3b IEEE 802.11: associated
mtkap0: AP-STA-CONNECTED c4:0b:cb:85:b9:3b
mtkap0: STA c4:0b:cb:85:b9:3b WPA: pairwise key handshake completed (RSN)
mtkap0: STA c4:0b:cb:85:b9:3b IEEE 802.11: disassociated
mtkap0: AP-STA-DISCONNECTED c4:0b:cb:85:b9:3b
mtkap0: STA c4:0b:cb:85:b9:3b IEEE 802.11: associated
mtkap0: STA c4:0b:cb:85:b9:3b IEEE 802.11: disassociated
mtkap0: STA c4:0b:cb:85:b9:3b IEEE 802.11: associated
mtkap0: STA c4:0b:cb:85:b9:3b IEEE 802.11: disassociated
mtkap0: STA c4:0b:cb:85:b9:3b IEEE 802.11: associated
mtkap0: STA c4:0b:cb:85:b9:3b IEEE 802.11: disassociated

My hostapd configuration is pretty much barebones:

driver=nl80211
logger_syslog=127
logger_syslog_level=2
logger_stdout=127
logger_stdout_level=2
country_code=CN
hw_mode=g
channel=8
interface=mtkap0
wpa_passphrase=12345678
auth_algs=1
wpa=2
rsn_pairwise=CCMP
ssid=foo
bridge=br-lan
wpa_key_mgmt=WPA-PSK

1: https://github.com/frank-w/BPI-R2-4.14/commit/e6b369a5ade19206db433b46d0102ae000b87e99

Have you tried a higher debug-level? Some users experiencing problems with missing entropy from random-number-generator. Try install haveng

I’ve built a full-featured hostapd which has a debug log[1]. It’s as if at some point the chip stops sending and receiving messages. Notice that the first (successful) connection when during key exchange there are EAPOL_RX events and the next ones when there are no such events at all and key exchange timeouts.

I’ve tried installing haveged and also looked at diff between my and yours dts-es – there were some changes which I ported but it made no difference. If you have the radio working, can you show me your dmesg from the moment when you run wmt_loader till you have connection for some time?

1: https://gist.github.com/abbradar/b876c4358ae419940c37b9e8281a4edd

It will take a week because i’m away from home. But after that i can send you the log if you send me changed settings (loglevel,changes in binary)

Nah, that’s not going to help after all – I thought the problem is in Cannot find pinctrl defaulterror but I managed to solve it and nothing has changed.

Does anyone have a stable connection (by that I mean that fast.com running some time doesn’t kill the AP)? If so, on what kernel and did you make any tweaks to hostapd.conf or something else? I’m trying to get results with the official LEDE image now to see what’s different.

I’ve tested more and it turns out it works normally on official LEDE image. It’s also broken without my custom changes to connectivity driver meaning that possible reasons are:

  • I’ve forgot to take some change from @frank-w’s tree;
  • It doesn’t work on 4.14 at all.

Unfortunately I can’t just test @frank-w’s kernel because it’s not trivial to make OpenWrt run on it.

@frank-w @garywang how is combo chip connected to the CPU? I think which .dts changes may be relevant; I didn’t yet port fixes for SDIO for example. Could that be relevant?

In my mutiple tries to port (4.14, 4.16, 4.17, 4.18) i got no ap0 device if i forgot anything in dts(i).

Wifi-chip (mt6626l) is connected via btif (similar to uart). If this node is wrong (different compatible or clock) kernel crashes. If main-node is disabled you get timeout on echo A.

the problem looks more like wpasupplicant or similar is running (or just installed). Try to remove that if you found it

@abbradar how do you solve “Cannot find pinctrl default”-Error? I looked in hostapd-log on my router and found no eapol timeouts

Index: linux-4.14.53/drivers/misc/mediatek/connectivity/common/conn_soc/mt7623/mtk_wcn_consys_hw.c
===================================================================
--- linux-4.14.53.orig/drivers/misc/mediatek/connectivity/common/conn_soc/mt7623/mtk_wcn_consys_hw.c
+++ linux-4.14.53/drivers/misc/mediatek/connectivity/common/conn_soc/mt7623/mtk_wcn_consys_hw.c
@@ -116,7 +116,7 @@ static INT32 mtk_wmt_probe(struct platfo
 		WMT_PLAT_ERR_FUNC("Wmt cannot find pinctrl!\n");
 		goto set_pin_exit;
 	}
-	mt6625_spi_default = pinctrl_lookup_state(mt6625_spi_pinctrl, "consys_pins_default");
+	mt6625_spi_default = pinctrl_lookup_state(mt6625_spi_pinctrl, PINCTRL STATE DEFAULT);
 	if (IS_ERR(mt6625_spi_default)) {
 		ret = PTR_ERR(mt6625_spi_default);
 		WMT_PLAT_ERR_FUNC("Wmt Cannot find pinctrl default!\n");

From my very limited understanding on newer kernels when there’s only one pinctrl state entry it’s placed under PINCTRL STATE DEFAULT. Anyway this doesn’t change anything, and I’m not even sure that’s needed – I think it’s done automatically by the kernel when there’s only one entry. Notice that this is all half-assumptions! Just to be sure earlier I listed all state entries in that place – only default is there.

1 Like

Do I get it correctly that you actively use WLAN and it works okay for you? Hm, then I guess it’s me not backporting something after all…

I had kernel 4.14.34 running for 70 days without problems…now running 4.14.52 for 11 days

I basicly want to remove that error :slight_smile:

have done logs before, but only stdout (stp-uart-launcher is empty):

wmtloader.log (133 Bytes) dmesg.log (43,4 KB)

and the interesting (with modified mac-adresses) hostapd_ap0.log: hostapd_ap0.tar.xz (21,8 KB)

the logfiles (hostapd.log) is from the last 11 days, so it shows many entries…i have not figured out yet, how to add timestamp while redirecting, so it’s the plain output of “hostapd -dd”

After some more experiments: it turns out even an image built from official Banana Pi repository[1] has this bug. @frank-w can you confirm that downloading a file at ~15-20mbps for several minutes works for you? Do you use any kind of rate limiting as suggested by official Getting Started guide (quote below)? If you don’t have this problem, can you share your hostapd.conf?

  1. If your Ap is not stable, please limit the speed, here I limit download speed as 8Mbit/s, upload as 4Mbit/s

    tc qdisc add dev ap0 root handle 1: htb default 11 tc class add dev ap0 parent 1:1 classid 1:2 htb rate 8Mbit ceil 4Mbit prio 2

More experiments: I’ve enabled debug mode in wifi drivers. Problems start when those lines appear in dmesg:

Wed Jul 11 04:23:59 2018 kern.debug kernel: [  571.536808] p2pHardStartXmit:(TX INFO)netif_stop_subqueue for p2p0, Queue len: 256
Wed Jul 11 04:23:59 2018 kern.debug kernel: [  571.551218] statsInfoEnvDisplay:(RX INFO)<stats> OTHER (9425) (0) (44) (0)
Wed Jul 11 04:23:59 2018 kern.debug kernel: [  571.588142] kalSendCompleteAndAwakeQueue:(TX INFO)netif_wake_subqueue for bss: 1. Queue len: 128
Wed Jul 11 04:23:59 2018 kern.debug kernel: [  571.638894] p2pHardStartXmit:(TX INFO)netif_stop_subqueue for p2p0, Queue len: 256
Wed Jul 11 04:23:59 2018 kern.debug kernel: [  571.676083] kalSendCompleteAndAwakeQueue:(TX INFO)netif_wake_subqueue for bss: 1. Queue len: 128
Wed Jul 11 04:23:59 2018 kern.debug kernel: [  571.795011] p2pHardStartXmit:(TX INFO)netif_stop_subqueue for p2p0, Queue len: 256
Wed Jul 11 04:24:00 2018 kern.debug kernel: [  571.832179] kalSendCompleteAndAwakeQueue:(TX INFO)netif_wake_subqueue for bss: 1. Queue len: 128
Wed Jul 11 04:24:00 2018 kern.debug kernel: [  572.390999] kalBoostCpu:(SW4 WARN)enter weak kalBoostCpu, core_num:2
Wed Jul 11 04:24:01 2018 kern.debug kernel: [  573.028974] p2pHardStartXmit:(TX INFO)netif_stop_subqueue for p2p0, Queue len: 256
Wed Jul 11 04:24:01 2018 kern.debug kernel: [  573.430983] kalBoostCpu:(SW4 WARN)enter weak kalBoostCpu, core_num:0
Wed Jul 11 04:24:01 2018 kern.debug kernel: [  573.529356] kalPerMonStart:(SW4 INFO)perf monitor started
Wed Jul 11 04:24:19 2018 kern.debug kernel: [  591.106956] saaFsmRunEventRxDeauth:(SAA INFO)Rx Deauth frame from BSSID=[ 02:08:22:82:a7:03 ].
Wed Jul 11 04:24:19 2018 kern.debug kernel: [  591.115637] p2pFsmRunEventRxDeauthentication:(P2P INFO)GO RX Deauth Reason: 3

You can see deauth in the end caused by problems. Any ideas?

1: https://github.com/garywangcn/bpi-r2_lede/commits/bpi-r2-on-lede-v1

I have only dsl with 12mbit down…but i have downloaded larger files which take more than 30 minutes or downloaded files with near 1gb from pi directly without disconnects

My hostapd.conf (changed wpa-pass):

#ctrl_interface=/var/run/hostapd
#ctrl_interface_group=0 # These 2 are just parameters so that the hostap daemon runs.
 
#interface=wlan1
interface=ap0
driver=nl80211
 
ssid=r2_AP0
 
hw_mode=g
channel=1
#macaddr_acl=0
auth_algs=1
#ignore_broadcast_ssid=0
wpa=2
wmm_enabled=1
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
[07:31] frank@bpi-r2-e:~$

I have no ratelimit or traffic-shaping on ap0

Interesting… maybe I have a hardware problem then. I’ve tested my new setup for some time and it seems to work without any problems. If you are interested I have several patches atop Mediatek drivers which fix building them as a module, redo phy creation so that it happens only along with dev and rename interfaces and phys so that they don’t conflict with other devices. Patches are in my openwrt tree + https://github.com/abbradar/mt6625l-wlan-gen2

I’ve also updated my openwrt pull request - wifi should be working out of the box now there.

2 Likes

Have you added my changes to make it compatible for 4.14 and 4.16/4.18?

Have you removed bluetooth/gps/fm?

Have driver autoload (without wmt-tools) and how to switch between client/ap-mode?

it seems that you have changed folder structure…i have 2 folders on top

Have you depencies (watchdog,genl,…) and dts(i) changes also in your repo?

How to integrate to kernel-tree (only add entry in makefile/kconfig)? Then i can try your modified driver on my r2

Btw. Have you tried with my 4.14 version? and what does “PINCTRL STATE DEFAULT” mean in above patch? i can’t believe this compiles…or are there underscores instead of spaces (PINCTRL_STATE_DEFAULT exists)?

  1. You mean changes for the connectivity driver? I did some for new cfg80211 but nothing more, possibly more changes are required for 4.16+.
  2. Nope, I left them as is. The reason why I split the wifi module into a separate repository is because OpenWrt has its own out-of-tree mac80211 module with updates from later kernels and all wireless drivers are supposed to be compiled as an out-of-tree packages against it. It’s the reason why I fixed its compilation as a module too. I imagine Bluetooth can be compiled in as usual.
  3. I didn’t implement client mode switch yet, that will need more work. I didn’t avoid wmt-tools, instead I implemented an OpenWrt service which does all the initialization. You can see what it does here.
  4. Same reasons as in (2)-- I changed it a bit so that it can be compiled out-of-tree.
  5. What’s genI? I did port watchdog changes as an OpenWrt kernel patch – basically it’s a commit from your tree.
  6. OpenWrt compiles it by itself as a module. I’d suggest you extract my patches from this repo and apply them to drivers/misc/mediatek/connectivity/wlan/gen2 subdirectory.
  7. Nope, my goal was to upstream this support to OpenWrt and this required making patches to the current OpenWrt mediatek kernel, honoring their out-of-tree mac80211 module etc.
  8. Ah, yes, sorry! The truth is that I already lost the patch when you asked it so I quickly redid it from memory and made an error. You are right, it should have been PINCTRL_STATE_DEFAULT instead.

changes in include/uapi/linux/genetlink.h / include/net/genetlink.h …ok, there are part from the full patch (0232-merge-mt6625l-wifi-driver.patch) but i havn’t seen them in you separated driver

what about the dts(i)-changes?

can i easily include you code into my tree for testing? which patch should i include? i only one big patch for the full driver…maybe i can use your separated driver…

i see you use the wmt-tools too…i hoped you kick them :slight_smile:

  1. The separated one includes only changes in drivers/misc/mediatek/connectivity/wlan/gen2. Basically if you want my changes you need both to take patches from https://github.com/abbradar/openwrt/tree/bpi-upstream/target/linux/mediatek/patches-4.14 and then apply changes from the separated driver to its directory in your kernel tree.
  2. Those are done as patches for the kernel too.
  3. Yeah, I tried to mess around but sadly no dice.

The reason I split changes between the kernel and the driver is because of how OpenWrt does things. I can get them all together in one kernel tree later, so that it becomes easier to work. If you are interested I can take a look at Monday.