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

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!

could you try if this fixes the issue?

diff --git a/drivers/misc/mediatek/connectivity/common/conn_soc/linux/pub/stp_chrdev_bt.c b/drivers/misc/mediatek/connectivity/common/conn_soc/linux/pub/stp_chrdev_bt.c
index 5a85f68b092f..2347183c874a 100644
--- a/drivers/misc/mediatek/connectivity/common/conn_soc/linux/pub/stp_chrdev_bt.c
+++ b/drivers/misc/mediatek/connectivity/common/conn_soc/linux/pub/stp_chrdev_bt.c
@@ -473,6 +473,8 @@ int mtk_bt_hci_init(void)
        mtk_hci.hdev->notify = mtk_bt_hci_notify;
        SET_HCIDEV_DEV(mtk_hci.hdev, stpbt_dev);
 
+       set_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &mtk_hci.hdev->quirks);
+
         hci_set_drvdata(mtk_hci.hdev, &mtk_hci);       
 
        mtk_wcn_stp_register_if_rx(mtk_bt_hci_receive);

Made that change in 5.15-main and recompiled. It does fix the issue! Thank you!

2 Likes

Also tested on 5.16 - hci0 brings up successfully. Not yet any other tests.

1 Like

Compiling 5.7-main and 5.8-main gives me these errors:

from drivers/misc/mediatek/connectivity/common/conn_soc/linux/pub/stp_chrdev_bt.c:16:
drivers/misc/mediatek/connectivity/common/conn_soc/linux/pub/stp_chrdev_bt.c: In function 'mtk_bt_hci_init':
drivers/misc/mediatek/connectivity/common/conn_soc/linux/pub/stp_chrdev_bt.c:476:10: error: 'HCI_QUIRK_BROKEN_ERR_DATA_REPORTING' undeclared (first use in this function); did you mean 'HCI_OP_READ_DEF_ERR_DATA_REPORTING'?
  set_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &mtk_hci.hdev->quirks);
          ^
./arch/arm/include/asm/bitops.h:183:42: note: in definition of macro 'ATOMIC_BITOP'
 #define ATOMIC_BITOP(name,nr,p)  _##name(nr,p)
                                          ^~
drivers/misc/mediatek/connectivity/common/conn_soc/linux/pub/stp_chrdev_bt.c:476:2: note: in expansion of macro 'set_bit'
  set_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &mtk_hci.hdev->quirks);
  ^~~~~~~
drivers/misc/mediatek/connectivity/common/conn_soc/linux/pub/stp_chrdev_bt.c:476:10: note: each undeclared identifier is reported only once for each function it appears in
  set_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &mtk_hci.hdev->quirks);
          ^
./arch/arm/include/asm/bitops.h:183:42: note: in definition of macro 'ATOMIC_BITOP'
 #define ATOMIC_BITOP(name,nr,p)  _##name(nr,p)
                                          ^~
drivers/misc/mediatek/connectivity/common/conn_soc/linux/pub/stp_chrdev_bt.c:476:2: note: in expansion of macro 'set_bit'
  set_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &mtk_hci.hdev->quirks);
  ^~~~~~~
scripts/Makefile.build:266: recipe for target 'drivers/misc/mediatek/connectivity/common/conn_soc/linux/pub/stp_chrdev_bt.o' failed
scripts/Makefile.build:488: recipe for target 'drivers/misc/mediatek/connectivity/common/conn_soc/linux/pub' failed
make[8]: *** [drivers/misc/mediatek/connectivity/common/conn_soc/linux/pub/stp_chrdev_bt.o] Error 1

5.9-main and 5.10-main compiles correctly and each is able to bring up the hci0 interface.

EDIT #1: I just pulled the latest version of the kernel. Let me try 5.7-main and 5.8-main again…

EDIT #2: 5.7-main and 5.8-main are still unable to compile for me.

mhm, this quirk and code for skipping the data_reporting was added in 5.7.16/5.8.2

thx for testing

i’ll update these 2 branches, edit: done

Pulled lastest 5.7-main and attempted to compile. No dice.

i can compile 5.7-main and module is built

frank@frank-G5-U20:/media/data_nvme/git/kernel/BPI-R2-4.14 (5.7-main) [1M26U]
$ find ../build/ -iname '*stp*.ko'
../build/drivers/misc/mediatek/connectivity/common/conn_soc/linux/pub/stp_chrdev_bt.ko

which error did you get? but i guess your code is not same as on github, maybe you need a make clean/mrproper

Pull changes to the repository again. Dunno what you did, but both branches 5.7-main and 5.8-main compile successfully now! Thank you again!

My last change was 1 hour ago in these 2 branches :slight_smile: that was the push after the updates

https://github.com/frank-w/BPI-R2-4.14/branches