[BPI-R2] MT7615 Wifi no IR flag

Maybe change this:


1 Like

Oh that I also changed as I thought it may be relevant :slight_smile:, no dice.

Then i guess you need entry-point of module where the params are parsed to get function which sets the countrycode and copy this with fixed country to non-module startcode

That sounds like a really complicated matter, nothing I would be able to do :frowning_face:. Thank you for all the help :slight_smile:.

come a bit further to build cfg80211 as module and supporting r2 internal wifi:

diff --git a/drivers/misc/mediatek/connectivity/Kconfig b/drivers/misc/mediatek/connectivity/Kconfig
index cf31d30c763a..ad1a3e051ea1 100644
--- a/drivers/misc/mediatek/connectivity/Kconfig
+++ b/drivers/misc/mediatek/connectivity/Kconfig
@@ -216,7 +216,7 @@ config MTK_COMBO_BT_HCI
        tristate "MediaTek combo chip Wi-Fi support"
-       depends on MTK_COMBO
+       depends on MTK_COMBO && CFG80211
        select MTK_BTIF
        select WIRELESS_EXT
        select WEXT_PRIV

if now cfg80211 is module, MTK_COMBO_WIFI be built as module…not yet completely because of

drivers/misc/mediatek/connectivity/common/common_detect/drv_init/wlan_drv_init.c:34: undefined reference to `mtk_wcn_wmt_wifi_init'

so i built wlan_drv_init as module too

diff --git a/drivers/misc/mediatek/connectivity/common/common_detect/drv_init/Makefile b/drivers/misc/mediatek/connectivity/common/common_detect/drv_init/Makefile
index fda8ba149107..e7d13fefcf91 100644
--- a/drivers/misc/mediatek/connectivity/common/common_detect/drv_init/Makefile
+++ b/drivers/misc/mediatek/connectivity/common/common_detect/drv_init/Makefile
@@ -16,7 +16,7 @@ endif
        obj-y += bluetooth_drv_init.o
        obj-y += gps_drv_init.o
        obj-y += fm_drv_init.o
-       obj-y += wlan_drv_init.o
+       obj-$(CONFIG_MTK_COMBO_WIFI) += wlan_drv_init.o
        obj-($(CONFIG_MTK_COMBO_ANT)) += ant_drv_init.o

now i hang here:

ERROR: modpost: missing MODULE_LICENSE() in drivers/misc/mediatek/connectivity/common/common_detect/drv_init/wlan_drv_init.o
ERROR: modpost: "sched_setscheduler" [drivers/misc/mediatek/connectivity/wlan/gen2/wlan_gen2.ko] undefined!
ERROR: modpost: "gWmtDetectDbgLvl" [drivers/misc/mediatek/connectivity/common/common_detect/drv_init/wlan_drv_init.ko] undefined!

cause gWmtDetectDbgLvl is declared as external in drivers/misc/mediatek/connectivity/common/common_detect/wmt_detect.h and defined in wmt_detect.c

for sched_setscheduler this seems to be defined in ./kernel/sched/core.c, here just a export is missing (which was removed in 2020)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 98191218d891..b7858e39c118 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6374,6 +6374,7 @@ int sched_setscheduler(struct task_struct *p, int policy,
        return _sched_setscheduler(p, policy, param, true);

for the gWmtDetectDbgLvl (external) and LICENSE:

diff --git a/drivers/misc/mediatek/connectivity/common/common_detect/drv_init/wlan_drv_init.c b/drivers/misc/mediatek/connectivity/common/common_detect/drv_init/wlan_drv_init.c
index 6d7c5751cade..2bc7315ebfb4 100644
--- a/drivers/misc/mediatek/connectivity/common/common_detect/drv_init/wlan_drv_init.c
+++ b/drivers/misc/mediatek/connectivity/common/common_detect/drv_init/wlan_drv_init.c
@@ -20,6 +20,7 @@
 #include "wmt_detect.h"
 #include "wlan_drv_init.h"
+unsigned int gWmtDetectDbgLvl = WMT_DETECT_LOG_INFO;
 int do_wlan_drv_init(int chip_id)
@@ -73,3 +74,5 @@ int do_wlan_drv_init(int chip_id)
        return i_ret;

r2wifi-mod.patch (2,1 KB)

you can try this patch (created on 5.12), i can compile, but have not tested its functionality…

patch -p1 < path/to/patch

in kernel source root

before running wmt commands on r2 make sure all modules have been loaded



mhm, as i thought, change for gWmtDetectDbgLvl breaks builtin-compilation…so i guarded the new definition depended on module-compilation

diff --git a/drivers/misc/mediatek/connectivity/common/common_detect/drv_init/wlan_drv_init.c b/drivers/misc/mediatek/connectivity/common/common_detect/drv_init/wlan_drv_init.c
index 2bc7315ebfb4..86f0cffc841c 100644
--- a/drivers/misc/mediatek/connectivity/common/common_detect/drv_init/wlan_drv_init.c
+++ b/drivers/misc/mediatek/connectivity/common/common_detect/drv_init/wlan_drv_init.c
@@ -20,7 +20,9 @@
 #include "wmt_detect.h"
 #include "wlan_drv_init.h"
 unsigned int gWmtDetectDbgLvl = WMT_DETECT_LOG_INFO;
 int do_wlan_drv_init(int chip_id)

Maybe anybody have an idea how to build 1 module for wifi instead of 4…maybe we can work here with exports too. I guess this is wrong here:

maybe use defined(CONFIG_MTK_COMBO_WIFI_MODULE) here too as it is done for function call

Have not found where MTK_WCN_REMOVE_KERNEL_MODULE is defined,but for BT this is dropped (bt working only as module). CONFIG_MTK_COMBO_WIFI_MODULE not defined anywhere too…so always false

seems like i need to link connectivity/common/conn_soc/linux/pub/wmt_chrdev_wifi.c to connectivity/common/common_detect/drv_init/wlan_drv_init.c to get this working. as the first should be the module and the second is the “core”, this cannot work this way…so we need another way to reduce module-count

in bluetooth-“core” this call is simply disabled :stuck_out_tongue: but this depends driver is always built as module (because it is initialized on module load)

added commits to 5.12-hnat tree…but not yet tested

1 Like

Ok applied the patch (to branch 5.10-main) and everything compiles fine, with “iw reg get” I get my desired output.

Now for the rest: I modprobed the modules you mentioned, modules load but there is output in dmesg.

When loading stp_chrdev_bt:

Apr  5 17:41:27 kernel: [  109.363955] [MTK-BT] BT_init: mtk_stp_BT_chrdev driver(major 192) installed
Apr  5 17:41:27 kernel: [  109.363986] [WMT-STP-EXP][E]mtk_wcn_stp_register_if_rx(223):ERROR! mtk_wcn_stp_if_rx_f cb is null
Apr  5 17:41:27 kernel: [  109.364600] [WMT-STP-EXP][E]mtk_wcn_wmt_func_on(332):ERROR! mtk_wcn_wmt_func_on_f cb is null
Apr  5 17:41:27 kernel: [  109.364613] mtk_bt_hci_open func on failed with 0
Apr  5 17:42:08 kernel: [  149.972826] [WMT-STP-EXP][E]mtk_wcn_wmt_msgcb_reg(384):ERROR! mtk_wcn_wmt_msgcb_reg_f cb is null

Now starting wmt_loader gives the following

Apr  5 17:43:31 kernel: [  232.718444] [WMT-DETECT][I]wmt_detect_open:open major 154 minor 0 (pid 1451)
Apr  5 17:43:31 kernel: [  232.718498] [WMT-DETECT][I]wmt_detect_unlocked_ioctl:cmd (-2147191037),arg(0)
Apr  5 17:43:31 kernel: [  232.718536] [WMT-DETECT][I]wmt_detect_unlocked_ioctl:cmd (1074034433),arg(30243)
Apr  5 17:43:31 kernel: [  232.718544] set current consys chipid (0x7623)
Apr  5 17:43:31 kernel: [  232.718571] [WMT-DETECT][I]wmt_detect_unlocked_ioctl:cmd (-2147191036),arg(30243)
Apr  5 17:43:31 kernel: [  232.718580] [WMT-MOD-INIT][I]do_common_drv_init:start to do common driver init, chipid:0x00007623
Apr  5 17:43:31 kernel: [  232.722019] [WMT-CONF][E]wmt_conf_parse_pair(323):unknown field 'mt6620.defAnt'.
Apr  5 17:43:31 kernel: [  232.722037] [WMT-CONF][E]wmt_conf_parse_pair(323):unknown field 'mt6628.defAnt'.
Apr  5 17:43:31 kernel: [  232.722047] [WMT-CONF][E]wmt_conf_parse_pair(323):unknown field 'mt6630.defAnt'.
Apr  5 17:43:31 kernel: [  232.724606] [WMT-MOD-INIT][I]do_common_drv_init:finish common driver init
Apr  5 17:43:31 kernel: [  232.724623] [WCN-MOD-INIT][E]do_connectivity_driver_init(58):do common driver init failed, ret:-1
Apr  5 17:43:31 kernel: [  232.724631] [WCN-MOD-INIT][E]do_wlan_drv_init(31):Can not find wlan module for chip: 30243 !
Apr  5 17:43:31 kernel: [  232.725058] [WMT-DETECT][I]wmt_detect_close:close major 154 minor 0 (pid 1451)

Going on with “stp_uart_launcher -p /etc/firmware &”

Apr  5 17:44:33 kernel: [  294.468188] [WMT-CORE][E]opfunc_hif_conf(874):WMT-CORE: WMT HIF info added
Apr  5 17:44:33 kernel: [  294.468649] vcn18: mode operation not allowed
Apr  5 17:44:33 kernel: [  294.470513] [WMT-CONSYS-HW][E]mtk_wcn_consys_hw_reg_ctrl(290):Read CONSYS chipId(0xfffff093)
Apr  5 17:44:33 kernel: [  294.570340] [WMT-CONF][E]wmt_conf_parse_pair(323):unknown field 'mt6620.defAnt'.
Apr  5 17:44:33 kernel: [  294.570358] [WMT-CONF][E]wmt_conf_parse_pair(323):unknown field 'mt6628.defAnt'.
Apr  5 17:44:33 kernel: [  294.570367] [WMT-CONF][E]wmt_conf_parse_pair(323):unknown field 'mt6630.defAnt'.
Apr  5 17:44:33 kernel: [  295.149989] [STP] mtk_wcn_stp_psm_enable:[W] STP Not Ready, Dont do Sleep/Wakeup

After all this the device “/dev/wmtWifi” is never created so I can’t do ,obvioulsy, “echo A >/dev/wmtWifi”


wlan_gen2            1548288  0
stp_chrdev_bt          24576  0
wlan_drv_init          16384  0
wmt_chrdev_wifi        20480  2 wlan_gen2,wlan_drv_init
mac80211              749568  0
cfg80211              774144  2 wlan_gen2,mac80211
libarc4                16384  1 mac80211

I’d say this is a good start? :slightly_smiling_face:

Afair bluetooth needs to be loaded after running stp_uart_launcher and wmtloader

Could you try also last patch from 5.12-hnat as it includes wlan_drv_init back to builtin?

Then try running wmt loader and stp_uart_launcher first then load modules

1 Like

I downloaded the branch “5.12-hnat” but I can’t do “./build.sh importconfig” as it gives me an error “please install gcc-aarch64-linux-gnu”.

Trying to manually edit the files in “5.10-main” branch results in:

drivers/misc/mediatek/connectivity/common/common_detect/drv_init/wlan_drv_init.o: In function `.LANCHOR0':
wlan_drv_init.c:(.data+0x0): multiple definition of `gWmtDetectDbgLvl'
drivers/misc/mediatek/connectivity/common/common_detect/wmt_detect.o:wmt_detect.c:(.data+0x4): first defined here
Makefile:1166: recipe for target 'vmlinux' failed
make: *** [vmlinux] Error 1

5.12-hnat is changed to bpi-r64 in build.conf,just comment out the line by adding a # at beginning

1 Like

Got it compiled and have it now on the Pi.

Here are the outputs as I do them:

modprobe mac80211 modprobe cfg80211

“iw reg get” has the desired output!


Apr  5 21:40:00 kernel: [  120.199400] [WMT-DETECT][I]wmt_detect_open:open major 154 minor 0 (pid 1448)
Apr  5 21:40:00 kernel: [  120.199472] [WMT-DETECT][I]wmt_detect_unlocked_ioctl:cmd (-2147191037),arg(0)
Apr  5 21:40:00 kernel: [  120.199513] [WMT-DETECT][I]wmt_detect_unlocked_ioctl:cmd (1074034433),arg(30243)
Apr  5 21:40:00 kernel: [  120.199525] set current consys chipid (0x7623)
Apr  5 21:40:00 kernel: [  120.199551] [WMT-DETECT][I]wmt_detect_unlocked_ioctl:cmd (-2147191036),arg(30243)
Apr  5 21:40:00 kernel: [  120.199563] [WMT-MOD-INIT][I]do_common_drv_init:start to do common driver init, chipid:0x00007623
Apr  5 21:40:00 kernel: [  120.203188] [WMT-CONF][E]wmt_conf_parse_pair(323):unknown field 'mt6620.defAnt'.
Apr  5 21:40:00 kernel: [  120.203217] [WMT-CONF][E]wmt_conf_parse_pair(323):unknown field 'mt6628.defAnt'.
Apr  5 21:40:00 kernel: [  120.203228] [WMT-CONF][E]wmt_conf_parse_pair(323):unknown field 'mt6630.defAnt'.
Apr  5 21:40:00 kernel: [  120.205824] [WMT-MOD-INIT][I]do_common_drv_init:finish common driver init
Apr  5 21:40:00 kernel: [  120.205847] [WCN-MOD-INIT][E]do_connectivity_driver_init(58):do common driver init failed, ret:-1
Apr  5 21:40:00 kernel: [  120.205860] [WLAN-MOD-INIT][I]do_wlan_drv_init:CONFIG_MTK_COMBO_WIFI is not defined
Apr  5 21:40:00 kernel: [  120.206235] [WMT-DETECT][I]wmt_detect_close:close major 154 minor 0 (pid 1448)

stp_uart_launcher -p /etc/firmware &:

Apr  5 21:42:12 kernel: [  251.817813] [WMT-CORE][E]opfunc_hif_conf(874):WMT-CORE: WMT HIF info added
Apr  5 21:42:12 kernel: [  251.818194] vcn18: mode operation not allowed
Apr  5 21:42:12 kernel: [  251.819983] [WMT-CONSYS-HW][E]mtk_wcn_consys_hw_reg_ctrl(290):Read CONSYS chipId(0xfffff093)
Apr  5 21:42:12 kernel: [  251.919991] [WMT-CONF][E]wmt_conf_parse_pair(323):unknown field 'mt6620.defAnt'.
Apr  5 21:42:12 kernel: [  251.920016] [WMT-CONF][E]wmt_conf_parse_pair(323):unknown field 'mt6628.defAnt'.
Apr  5 21:42:12 kernel: [  251.920027] [WMT-CONF][E]wmt_conf_parse_pair(323):unknown field 'mt6630.defAnt'.
Apr  5 21:42:13 kernel: [  252.474378] [STP] mtk_wcn_stp_psm_enable:[W] STP Not Ready, Dont do Sleep/Wakeup

modprobe stp_chrdev_bt:

Apr  5 21:43:44 kernel: [  344.356686] [MTK-BT] BT_init: mtk_stp_BT_chrdev driver(major 192) installed
Apr  5 21:43:45 kernel: [  344.694820] mtk_bt_hci_notify event(3)=HCI_NOTIFY_VOICE_SETTING
Apr  5 21:43:45 kernel: [  344.739772] hci_reassembly: this workaround is applied for mediatek BT
Apr  5 21:43:45 kernel: [  344.758592] mtk_bt_hci_flush: todo

modprobe wmt_chrdev_wifi:

Apr  5 21:44:23 kernel: [  382.562824] [MTK-WIFI] WIFI_init: mtk_wmt_WIFI_chrdev driver(major 155) installed.

modprobe wlan_gen2

echo A > /dev/wmtWifi:

Apr  5 21:46:05 kernel: [  485.079938] [MTK-WIFI] WIFI_open: WIFI_open: major 155 minor 0 (pid 1439)
Apr  5 21:46:05 kernel: [  485.080086] [MTK-WIFI] WIFI_write: WIFI_write A
Apr  5 21:46:05 kernel: [  485.124018] kalFirmwareImageMapping firmware size 225840
Apr  5 21:46:06 kernel: [  486.309670] DEBUG: Passed wlanNetRegister 2264 devname:wlan%d
Apr  5 21:46:06 kernel: [  486.310728] DEBUG: Passed wlanNetRegister 2273 devname:wlan0 (need to be used everywhere "wlan0" is used)
Apr  5 21:46:06 kernel: [  486.310770] [MTK-WIFI] register_set_p2p_mode_handler: (pid 1451) register set p2p mode handler 9f5eac37
Apr  5 21:46:06 kernel: [  486.310884] [MTK-WIFI] WIFI_write: WMT turn on WIFI success!
Apr  5 21:46:06 kernel: [  486.310911] DEBUG: Passed WIFI_write 483 wlan0
Apr  5 21:46:06 kernel: [  486.311129] DEBUG: Passed p2pNetRegister 1111,devname: ap%d
Apr  5 21:46:06 kernel: [  486.312197] [MTK-WIFI] WIFI_write: Set wlan mode 0 --> 1
Apr  5 21:46:06 kernel: [  486.312228] [MTK-WIFI] WIFI_write: WIFI_write
Apr  5 21:46:06 kernel: [  486.312228]
Apr  5 21:46:06 kernel: [  486.312248] [MTK-WIFI] WIFI_write: WIFI_write invalid param
Apr  5 21:46:06 kernel: [  486.312363] [MTK-WIFI] WIFI_close: WIFI_close: major 155 minor 0 (pid 1439)

“wlan0” and “ap0” are now there.

modprobe mt76 modprobe mt7615e

“wlan1” is now also there.

Hostapd works on both.

However doing “echo 0 /dev/wmtWifi” crashes the OS. I guess the driver is rly unstable :laughing:

Last output I got:

Apr  5 21:53:55 kernel: [  922.873786] [MTK-WIFI] WIFI_open: WIFI_open: major 155 minor 0 (pid 1439)
Apr  5 21:53:55 kernel: [  922.873900] [MTK-WIFI] WIFI_write: WIFI_write 0
Apr  5 21:53:55 kernel: [  944.769433] rcu: INFO: rcu_sched detected stalls on CPUs/tasks:
Apr  5 21:53:55 kernel: [  944.769461] rcu:     0-...0: (4 ticks this GP) idle=9b2/1/0x40000000 softirq=2220/2222 fqs=1042
Apr  5 21:53:55 kernel: [  944.769485]  (detected by 3, t=2102 jiffies, g=3061, q=149)
Apr  5 21:53:55 kernel: [  944.769498] Sending NMI from CPU 3 to CPUs 0:

Thank you very much @frank-w :+1:

A small update: The module “stp_chrdev_bt” doesn’t have to be loaded for wifi to work, everything works still even with that module not loaded; Found that out by accident :laughing:

Chrdev_bt is for bluetooth…does this break wifi?

For “crash” (it is rcu-stall,hanging process),do you use any cmdline param like net.ifnames=0 ? Or any other network-manager?

Hostap works on wlan0?

No it does not.

No network manager, I just use ip with my start script to asign ip addresses. :slight_smile:. And no cmdline params like “net.ifname=0”.

I never tried that, as I thought that wouldn’t work from what I gathered from all the random posts, I thought that is why “ap0” exists.

Ah, you have mt7615 and hostapd works on ap0 and device from mt7615…

So we have now the rcu stall (when does this came up)? Maybe because mt7615 (see my patches for getting mt6625 wlan-device).

But it looks like you have the patch (or at least the debug lines) already…

And the crash on “echo 0” right (maybe same)? Any more info on this crash? Based on commit above you can add some debug-lines in the 0-block to trace this down (printks after each functional line like my prinktks)

WIFI_write invalid param

Is also strange,seems like printed some lines above when count is <=0

1 Like

I’m currently using your 5.12-hnat branch kernel, I don’t know what patches you already inserted there, so you would have to tell me :yum:

As to the devices:

mt6625 (internal module) is “wlan0” and “ap0”

mt7615 (PCIe card) is “wlan1”

I have two hostapd instances running one on “ap0” (internal module) and one on “wlan1” (PCIe card).

The stall happens while both cards are active (meaing they coexist in the system) and I want to disable the internal module with “echo 0 > /dev/wmtWifi”. Basically I enter “echo 0 > /dev/wmtWifi” and press ENTER and right after I press ENTER the stall happens. The whole system hangs and I have to RESET the system.

The lines I got are because I have “logread -f” running on another terminal.

I hope I could make myself understood :woozy_face: I’m sorry I’m just bad at this :blush:

5.12-hnat contains the latest patches for mt6625

try adding this to 5.12-hnat:rcu_debug_on_reset.patch (2,5 KB)

i guess the problem is pf_set_p2p_mode (line 374 will be printed last, no 376)…that was the problem i tried to fix with get_netdev(); function. in origin code the netdev was fixed to wlan0 but if you have another wifi-card this may differ, running pf_set_p2p_mode on wrong netdev resulted in hang. so please look if the right netdev is printed in 365. if this is correct and we know the location here, we have to dig deeper…afair rcu-stall results from unreleased lock, but this i had not found (all exits goto “done” where this lock wr_mtx is released correctly, but afair there was a semaphore in pf_set_p2p_mode or later). Maybe it is because of you load mt7615 driver later…imho i use last wifi-device as i guess last is created by this driver

btw. to prevent filesystem-problems you can boot into init-ramdisk

for this you need to add buildroot-initrd and build.sh (+conf for module filter) from 5.10-main (need to be commited because initrd is resetted first in mod2initrd)

git checkout 5.10-main -- build.sh build.conf  utils/buildroot/rootfs_bpi-r2.cpio.gz
git commit -m "build.sh: add initrd"

after building do not install and run “./build.sh mod2initrd” this should run install-choice too and installs kernel with the initrd

1 Like

Ok applied the patch and this time I had to poweroff the device and added my UART debug USB device.

This time I can do “echo 0 > /dev/wmtWifi” and the system just hangs here and there with NO OUTPUT anywhere. Nothing in syslog, dmesg, debug UART, nothing. The only thing that happens is that the terminal where I typed it in is now “soft locked” as in I can’t do “CTRL+C” to do a sigterm.

You have to disable line in wifi.sh which prevents log to console (dmesg -D,printk line)…i guessed you did it because you see the stall message.

If you still do not see anything the hang occours before wifi-write function (or at least before my first printk)…but the print with “WIFI_write: 0” is 2 lines before my first printk…nothing that can hang

Oh I don’t use your “wifi.sh” file I wrote my own :slight_smile: No information is left out here. Alpine uses openRC not systemd so I wrote my own service.

The few debug lines that are now new would be when it initilizes:

Jan  1 00:00:43 kernel: [   29.485992] DEBUG: Passed wlanNetRegister 2264 devname:wlan%d
Jan  1 00:00:43 kernel: [   29.487019] DEBUG: Passed wlanNetRegister 2273 devname:wlan0 (need to be used everywhere "wlan0" is used)


Jan  1 00:00:43 kernel: [   29.487195] DEBUG: Passed WIFI_write 496 wlan0
Jan  1 00:00:43 kernel: [   29.487397] DEBUG: Passed p2pNetRegister 1111,devname: ap%d

Sadly there is really no output after I type “echo 0 > /dev/wmtWifi”

the first 2 were already there in your previous log and there you have posted this:

Apr  5 21:53:55 kernel: [  922.873786] [MTK-WIFI] WIFI_open: WIFI_open: major 155 minor 0 (pid 1439)
Apr  5 21:53:55 kernel: [  922.873900] [MTK-WIFI] WIFI_write: WIFI_write 0 <<< this is already wifi_write function, 2 lines before my first printk
Apr  5 21:53:55 kernel: [  944.769433] rcu: INFO: rcu_sched detected stalls on CPUs/tasks:

i wonder why the “wifi-write: 0” line does not occour now

WIFI_INFO_FUNC("WIFI_write %s\n", local);

can you test without the mt7615-card? or at least do not load the module for now

my wifi.sh does not depend on systemd…it is a basic bash-script :slight_smile:

1 Like

Yes you’re right just wanted to mention that I wrote my own service so it would funtion properly in OpenRC. I really can’t report to you more than what there is, which in this case really is nothing :slightly_frowning_face:

Yes I will test without.