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

Strange,

I wonder why it is broken now everywhere…

maybe check if all firmware files are present. Or any change in kernel was breaking it

Okay, clean Debian 10 image, installed bluez and kernel 5.4.150. Was able to bring hci0 up and configure it, as specified in your bluetooth wifi.

Went back to kernel 5.4.58 and was able to bring up the hci0 interface, as specified in your bluetooth wifi.

Tried 4.19.20 and was able to bring up the hci0 interface, as specified in your bluetooth wifi. I lost the ability to SSH into the machine, so I had to pull the SD card in order to change to kernel 5.15.

Tried 5.15.11 and was NOT able to bring up the hci0 interface. Here is the result:

root@bpi-r2:~# wifi.sh
wifidev does not exist...create it...
loading wifi driver module
13: ap0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 02:08:22:14:d1:fc brd ff:ff:ff:ff:ff:ff
Done, all good, ready to lauch hostapd
set IP
restart dnsmasq...
root@bpi-r2:~# hciconfig -a
hci0:	Type: Primary  Bus: SDIO
	BD Address: 00:00:46:85:90:01  ACL MTU: 1021:4  SCO MTU: 184:1
	DOWN 
	RX bytes:539 acl:0 sco:0 events:25 errors:0
	TX bytes:363 acl:0 sco:0 commands:25 errors:0
	Features: 0xbf 0x3e 0x8d 0xfe 0xdb 0xff 0x5b 0x87
	Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
	Link policy: RSWITCH SNIFF 
	Link mode: SLAVE ACCEPT 

root@bpi-r2:~# hciconfig hci0 lm master
root@bpi-r2:~# hciconfig -a
hci0:	Type: Primary  Bus: SDIO
	BD Address: 00:00:46:85:90:01  ACL MTU: 1021:4  SCO MTU: 184:1
	DOWN 
	RX bytes:539 acl:0 sco:0 events:25 errors:0
	TX bytes:363 acl:0 sco:0 commands:25 errors:0
	Features: 0xbf 0x3e 0x8d 0xfe 0xdb 0xff 0x5b 0x87
	Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
	Link policy: RSWITCH SNIFF 
	Link mode: MASTER 

root@bpi-r2:~# hciconfig hci0 up
Can't init device hci0: Invalid request code (56)

root@bpi-r2:~# dmesg | grep hci0
[  115.334281] debugfs: File 'dut_mode' in directory 'hci0' already present!

So it appears to be something wrong with my custom image. which is disappointing… I guess (at the very minimum) it’s time to rebuild the damn thing…

I’ll try setting the MTK_BT_DEBUG flag to 1 on kernel 5.15, recompile and see what happens…

EDIT: Finished recompiling 5.15-main and installed it. Does any of this help?

[    9.457942] Run /sbin/init as init process
[   10.863577] systemd[1]: Condition check resulted in Arbitrary Executable File Formats File System Automount Point being skipped.
[   12.857220] lima 13040000.gpu: bus rate = 500500000
[   18.611757] [WMT-DETECT][I]wmt_detect_open:open major 154 minor 0 (pid 335)
[   28.551657] [MTK-WIFI] WIFI_write: WIFI_write A
[   29.757190] DEBUG: Passed wlanNetRegister 2264 devname:mt6625_%d
[   29.787692] [MTK-WIFI] register_set_p2p_mode_handler: (pid 338) register set p2p mode handler 37657082
[   32.516657] mtk_bt_hci_notify event(3)=HCI_NOTIFY_VOICE_SETTING
[   39.570749] vcamaf: disabling
[   57.704196] debugfs: File 'dut_mode' in directory 'hci0' already present!
[   57.770053] hci_reassembly: this workaround is applied for mediatek BT
[   57.795081] mtk_bt_hci_flush: todo

So for lts,only 5.15 is affected. Could you try 5.11-main - 5.14-main?

Debug seems to do no change. Need to add manual debugs later

Compiled 5.10.88 because that is the last version I tried and couldn’t bring bluetooth up before adding to this thread. Tried to bring up hci0. Got this:

root@bpiwrt:~# wifi.sh
wifidev does not exist...create it...
loading wifi driver module
13: ap0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 02:08:22:64:2c:fc brd ff:ff:ff:ff:ff:ff
Done, all good, ready to lauch hostapd
set IP
restart dnsmasq...
Failed to restart dnsmasq.service: Unit dnsmasq.service is masked.
root@bpiwrt:~# hciconfig -a
hci0:	Type: Primary  Bus: SDIO
	BD Address: 00:00:46:85:90:01  ACL MTU: 1021:4  SCO MTU: 184:1
	DOWN 
	RX bytes:539 acl:0 sco:0 events:25 errors:0
	TX bytes:363 acl:0 sco:0 commands:25 errors:0
	Features: 0xbf 0x3e 0x8d 0xfe 0xdb 0xff 0x5b 0x87
	Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
	Link policy: RSWITCH SNIFF 
	Link mode: SLAVE ACCEPT 

root@bpiwrt:~# hciconfig hci0 lm master
root@bpiwrt:~# hciconfig hci0 up
Can't init device hci0: Invalid request code (56)
root@bpiwrt:~# 

Btw, my dnsmasq.service is masked because I’m using pihole…

Going to try 5.9-main next.

So 5.10+ is not working,but 5.4 is ok,right?

Then you could try 5.5-5.9

Correct, branch 5.10-main does not work. Branches 5.9-main, 5.8-main and 5.7-main also fail to bring up interface hci0 with the same message. However, branch 5.6-main works to bring interface hci0 up.

1 Like

So there is any change between 5.6 and 5.7 which breaks it.

it is not in drivers/misc/mediatek…

$ git diff 5.6-main..5.7-main -- drivers/misc/mediatek

is empty, so no change there, so anything else breaks it

diff --git a/arch/arm/configs/mt7623n_evb_fwu_defconfig b/arch/arm/configs/mt7623n_evb_fwu_defconfig
index b512869a9ba0..0f2bdd3d6376 100644
--- a/arch/arm/configs/mt7623n_evb_fwu_defconfig
+++ b/arch/arm/configs/mt7623n_evb_fwu_defconfig
@@ -430,7 +430,7 @@ CONFIG_CFG80211=y
 
 #internal wlan (not working yet)
 # CONFIG_MTK_CONN_LTE_IDC_SUPPORT is not set
-CONFIG_MTK_COMBO=y
+#CONFIG_MTK_COMBO=y

could you try reenabling it? but without i wifi should also not work and it does…comparing with 5.10-main this change is not there…i’m not sure why this is in 5.7-main but later i made a change to automaticly set the MTK_PLATFORM (this should lead to compile-errors if i made a mistake), maybe this breaks BT

-CONFIG_MTK_PLATFORM="mt7623"
+#CONFIG_MTK_PLATFORM="mt7623"

Okay, in .config,I tried commenting out:

CONFIG_MTK_PLATFORM="mt7623"

and the repo refused to build until I ran ./build.sh config, then exited. Then during compilation, it produced compile-errors.

Next attempt was after commenting out CONFIG_MTK_COMBO=y and recompiling. Compile was successful, however, after installing the kernel and rebooting, running wifi.sh just hangs. CTRL-C’ed, then checked /var/log/wmtloader.log. I saw these line:

init combo device
Can't open device node(/dev/wmtdetect) count(1)
Can't open device node(/dev/wmtdetect) count(2)
Can't open device node(/dev/wmtdetect) count(3)
...(counts between 3 and 329 happen here)...
Can't open device node(/dev/wmtdetect) count(329)
Can't open device node(

Hope this helps…

Try removing # in arch/arm/configs/mt7623n_evb_fwu_defconfig,save and build.sh importconfig again

Did that, then recompiled. No change…

Hold on, which branch am I supposed to do this in? 5.7?

just make sure that

CONFIG_MTK_PLATFORM="mt7623"

and

CONFIG_MTK_COMBO=y

in your config

Of all the branches I’ve compiled today, 5.6-main and 5.7-main are the only branches that contains CONFIG_MTK_PLATFORM=“mt7623”. The others contain CONFIG_MTK_PLATFORM="". All branches contain CONFIG_MTK_COMBO=y.

mhm, tried setting it in 5.10, does not work, no default controller available, but dmesg seems clear so far

[   78.199221] [MTK-BT] BT_init: mtk_stp_BT_chrdev driver(major 192) installed
[   78.347261] mtk_bt_hci_notify event(3)=HCI_NOTIFY_VOICE_SETTING
[   78.378220] hci_reassembly: this workaround is applied for mediatek BT
[   78.391438] mtk_bt_hci_flush: todo

also in the logs i see no error, seems handling bluetooth devices has changed…currently i have no idea how to debug, as there is not real error except the

root@bpi-r2:~# hciconfig hci0 lm master
root@bpi-r2:~# hciconfig hci0 up
Can't init device hci0: Invalid request code (56)

there is a bunch of changes in bluetooth core, have not found out which breaks

git log --oneline v5.6..v5.7 -- net/bluetooth/
git diff v5.6..v5.7 -- net/bluetooth/

i guess we need anybody which has more knowledge about BT

maybe @DeadMeat @LeXa2 @asac @BitMaster @dfiloni @abbradar who helped me in past with the BT/wifi

have not found where the errormessage is generated, but 56 is the errorcode for EBADRQC

include/uapi/asm-generic/errno.h:37:#define	EBADRQC		56	/* Invalid request code */

i guess it is thrown somewhere in bluetooth-core, found no return in drivers/misc/mediatek

$ grep -Rni 'EBADRQC' net/bluetooth/
net/bluetooth/lib.c:52:		return EBADRQC;

but for more we need to add debug

Hi, all.

As I got the problem is with BT? Is there any branch where it’s working?

I know 5.4-main as well as 5.6-main can bring up the hci0 interface. 5.7-main, 5.8-main, 5.9-main, 5.10-main, and 5.15-main cannot bring up the interface. I haven’t tested any other branches.

Yes it’s with BT. Seems to be broken betwee 5.6-main (working) and 5.7-main (not working).

BT module needs to be loaded after wmt-tools run.

wifi.sh
modprobe stp_bt_chrdev
hciconfig hci0 lm master
hciconfig hci0 up

In 5.7 i changed defconfig to no more include

**CONFIG_MTK_PLATFORM=“mt7623”**
**CONFIG_MTK_COMBO=y**

These you should add/enable again first,but in 5.10 it does not solve. First one should be generated by makefile without the config option and second one should be set.

Hi all.

@dougiefresh Can you pls try to bring the hci0 interface up on any working kernel while running btmon (run btmon in one console and then run hciconfig hci0 up in another)?

And then share the log.

I got the next on 5.16 (non-working): btmon.log (28.1 КБ)

Thank You!

1 Like

I compiled 5.6-main and ran it while bringing up hci0 and scanned for my phone. Hope this is helpful… Did you want me to try 5.15? Or for the purposes of this discussion, does that not quality as a “working kernel”?

btmon_5.6.log (17.2 KB)

1 Like

thanks for the log, alex have an idea where the problem can be, it is a new codeblock in BT core and needs a flag in driver to skip it.

no need to try later kernel at the moment as we know 5.7+ is broken

Yay! You’re welcome!