BPI-R2 Kernel bluetooth module

Hello,

Which bluetouh module should be include to build the kernel?

+CONFIG_BT=y
+CONFIG_MTK_COMBO_BT=m
+CONFIG_MTK_COMBO_BT_HCI=m

where in the menuconfig i can enable CONFIG_MTK_COMBO_BT?

You can search with / in menuconfig

I have added these options to my defconfig in debug-branch…

simply “./build.sh importconfig”

Else the option is in device drivers - misc devices - mediatek periferals

Thanks. I did remove some un-need driver from your config.

It does not compile

  CC      drivers/misc/mediatek/connectivity/common/conn_soc/core/wmt_core.o
In file included from drivers/misc/mediatek/connectivity/common/conn_soc/core/include/wmt_lib.h:30:0,
                 from drivers/misc/mediatek/connectivity/common/conn_soc/core/wmt_core.c:41:
drivers/misc/mediatek/connectivity/common/conn_soc/linux/include/wmt_idc.h:25:25: fatal error: conn_md_exp.h: No such file or directory
 #include "conn_md_exp.h"
                         ^
compilation terminated.
scripts/Makefile.build:314: recipe for target 'drivers/misc/mediatek/connectivity/common/conn_soc/core/wmt_core.o' failed
make[7]: *** [drivers/misc/mediatek/connectivity/common/conn_soc/core/wmt_core.o] Error 1
scripts/Makefile.build:573: recipe for target 'drivers/misc/mediatek/connectivity/common/conn_soc/core' failed
scripts/Makefile.build:573: recipe for target 'drivers/misc/mediatek/connectivity/common/conn_soc' failed
scripts/Makefile.build:573: recipe for target 'drivers/misc/mediatek/connectivity/common' failed
scripts/Makefile.build:573: recipe for target 'drivers/misc/mediatek/connectivity' failed
scripts/Makefile.build:573: recipe for target 'drivers/misc/mediatek' failed
scripts/Makefile.build:573: recipe for target 'drivers/misc' failed
Makefile:1028: recipe for target 'drivers' failed
make[6]: *** [drivers/misc/mediatek/connectivity/common/conn_soc/core] Error 2
make[5]: *** [drivers/misc/mediatek/connectivity/common/conn_soc] Error 2
make[4]: *** [drivers/misc/mediatek/connectivity/common] Error 2
make[3]: *** [drivers/misc/mediatek/connectivity] Error 2
make[2]: *** [drivers/misc/mediatek] Error 2
make[1]: *** [drivers/misc] Error 2
make: *** [drivers] Error 2

/wmt_idc.h is only loaded if CONFIG_MTK_CONN_LTE_IDC_SUPPORT is set…this is a LTE-Driver and can’t be compiled because of missing android-headers

which drivers do you remove? BTIF is needed for BT and Wifi

some other drivers are listed in Kconfig which are not working too…must be reworked,but first i want to get other things working

ok works, first time if initiate the device it hangs. then the firmware load it and it is fine.

root@bpi-r2:~# hciconfig hci0 up
Can't init device hci0: Input/output error (5)
root@bpi-r2:~# patch name pre-fix:ROMv2_lm_patch
fwVersion:0x8a00
/etc/firmware/ROMv2_lm_patch_1_0_hdr.bin
fw Ver in patch: 0x8a00
read patch info:0x22,0x00,0x06,0x00
gpatchnum = [2]
gdwonseq = [2]
/etc/firmware/ROMv2_lm_patch_1_1_hdr.bin
fw Ver in patch: 0x8a00
read patch info:0x21,0x00,0x0e,0xf0
gdwonseq = [1]
cmd(srh_patch) resp(ok)
^C
root@bpi-r2:~# 
root@bpi-r2:~# hciconfig hci0 up

find device

# hcitool dev
Devices:
	hci0	00:00:46:85:90:01

However the wifi stop working correctly

[  255.198907] [WMT-CTRL][E]wmt_ctrl_rx(263):wmt_dev_rx_timeout: timeout,jiffies(4294962816),timeoutvalue(20000)
[  255.208789] [WMT-CORE][E]wmt_core_rx(346):WMT-CORE: wmt_core_ctrl failed: WMT_CTRL_RX, iRet:-1
[  255.220162] 0x01 0x01 0xe9 0x03 0x02 0x10 0x4f 0x80 0x17 0x00 0x3f 0x80 0x17 0xc3 0x2e 0xb4 0x02 0x01 0x01 0x00 0x00 0x01 0x01 0xe9 0x03 0x02 0xdd 0x3c 0x3e 0x00 0x6c 0x34 0xd5
 0x17 0x2f 0xe0 0x6c 0x02 0x01 0x01 0x00 0x00 0x01 0x01 0xe9 0x03 0x02 0x4c 0x02 0xc1 0x78 0x48 0x00 0x01 0x7c 0x46 0x08 0x11 0x02 0x01 0x01 0x00 0x00 0x01 0x01 0xe9 0x03 0x02 0xd
5 0x0c 0x84 0x0c 0xd5 0x08 0x49 0xfe 0x24 0x23 0x84 0x02 0x01 0x01 0x00 0x00 0x01 0x01 0xe9 0x03 0x02 0x49 0xfe 0x45 0x70 0xec 0x04 0x3a 0x6f 0xa4 0x84 0xdd 0x02 0x01 0x01 0x00 0x
00 0x01 0x01 0xe9 0x03 0x02 0x4e 0x82 0x00 0x0d 0x3c 0x1c 0x07 0x7f 0x84 0x02 0xdd 0x02 0x01 0x01 0x00 0x00 0x01 0x01 0x35 0x00 0x03 0xd4 0xef 0x06 0x00 0x08 0x00 0x00 0x00 0x02 0
x00 0x00 0x02 0x01 0x01 0x00 0x00 0x01 0x07 0x01 0x00 0x04 0x02 0x07 0x01 0x00 0x00 0x01 0x08 
[  255.290518] 0x10 0x00 0x01 0x01 0x00 0x01 0x0c 0x01 0x00 0x80 0x00 0x4d 0x84 0x00 0x02 0x08 0x04 0x00 0x00 0x00 0x00 0x01 0x01 0x08 0x10 0x00 0x01 0x01 0x00 0x01 0x34 0x03 0x00
 0x80 0x00 0x00 0x00 0x00 0x02 0x08 0x04 0x00 0x00 0x00 0x00 0x01 0x01 0x14 0x01 0x00 0x01 0x02 0x14 0x72 0x02 0x00 0x01 0x01 0x11 0x11 0x4a 0x4a 0x49 0x49 0x48 0x48 0x47 0x01 0x1
0 0x02 0x00 0x01 0x00 0x02 0x10 0x01 0x00 0x00 0x01 0x05 0x02 0x00 0x02 0x02 0x02 0x05 0x02 0x00 0x00 0x02 0x01 0x03 0x01 0x00 0x01 0x02 0x03 0x02 0x00 0x00 0x01 0x02 0x03 0x02 0x
00 0x00 0x03 
[  255.290754] drivers/misc/mediatek/connectivity/common/conn_soc/core/wmt_core.c, 348, (0)
[  255.346459] [WMT-CORE][E]opfunc_pwr_sv(1208):wmt_core: read SLEEP_EVT fail(-1) len(0, 6)0x01 0x01 0xe9 0x03 0x02 0x10 0x4f 0x80 0x17 0x00 0x3f 0x80 0x17 0xc3 0x2e 0xb4 0x02 0x0
1 0x01 0x00 0x00 0x01 0x01 0xe9 0x03 0x02 0xdd 0x3c 0x3e 0x00 0x6c 0x34 0xd5 0x17 0x2f 0xe0 0x6c 0x02 0x01 0x01 0x00 0x00 0x01 0x01 0xe9 0x03 0x02 0x4c 0x02 0xc1 0x78 0x48 0x00 0x
01 0x7c 0x46 0x08 0x11 0x02 0x01 0x01 0x00 0x00 0x01 0x01 0xe9 0x03 0x02 0xd5 0x0c 0x84 0x0c 0xd5 0x08 0x49 0xfe 0x24 0x23 0x84 0x02 0x01 0x01 0x00 0x00 0x01 0x01 0xe9 0x03 0x02 0
x49 0xfe 0x45 0x70 0xec 0x04 0x3a 0x6f 0xa4 0x84 0xdd 0x02 0x01 0x01 0x00 0x00 0x01 0x01 0xe9 0x03 0x02 0x4e 0x82 0x00 0x0d 0x3c 0x1c 0x07 0x7f 0x84 0x02 0xdd 0x02 0x01 0x01 0x00 
0x00 0x01 0x01 0x35 0x00 0x03 0xd4 0xef 0x06 0x00 0x08 0x00 0x00 0x00 0x02 0x00 0x00 0x02 0x01 
[  255.419614] 0x01 0x00 0x00 0x01 0x07 0x01 0x00 0x04 0x02 0x07 0x01 0x00 0x00 0x01 0x08 0x10 0x00 0x01 0x01 0x00 0x01 0x0c 0x01 0x00 0x80 0x00 0x4d 0x84 0x00 0x02 0x08 0x04 0x00
 0x00 0x00 0x00 0x01 0x01 0x08 0x10 0x00 0x01 0x01 0x00 0x01 0x34 0x03 0x00 0x80 0x00 0x00 0x00 0x00 0x02 0x08 0x04 0x00 0x00 0x00 0x00 0x01 0x01 0x14 0x01 0x00 0x01 0x02 0x14 0x7
2 0x02 0x00 0x01 0x01 0x11 0x11 0x4a 0x4a 0x49 0x49 0x48 0x48 0x47 0x01 0x10 0x02 0x00 0x01 0x00 0x02 0x10 0x01 0x00 0x00 0x01 0x05 0x02 0x00 0x02 0x02 0x02 0x05 0x02 0x00 0x00 0x
02 0x01 0x03 0x01 0x00 0x01 0x02 0x03 0x02 0x00 0x00 0x01 0x02 0x03 0x02 0x00 0x00 0x03 
[  255.419874] [WMT-CTRL][E]wmt_ctrl_evt_parser(967):parser wmt evt from BTIF buf fail(0)
[  255.481890] [WMT-CORE][E]wmt_core_ctrl(500):WMT-CORE: wmt_core_ctrl failed: id(29), type(1), value(0) iRet:(-1)
[  255.491932] drivers/misc/mediatek/connectivity/common/conn_soc/core/wmt_core.c, 501, (0)
[  255.499975] [WMT-CTRL][W]wmt_ctrl_evt_err_trg_assert:wmt-ctrl:drv_type(4),reason(33)
[  255.507701] MTK-BTIF[E]mtk_btif_rxd_be_blocked_by_data(2245):there is no sync pkt in BTIF buffer
[  265.011708] [STP] mtk_wcn_stp_wmt_evt_err_trg_assert:[E] evt err trigger assert fail,do chip reset to recovery
[  265.021724] [WMT-LIB][W]wmtd_thread:opid (7) failed, iRet(-1)
[  265.021869] [MTK-WIFI] wifi_reset_start: Turn off p2p/ap mode
[  265.027494] [WMT-CORE][W]wmt_core_dump_func_state:[BE HW RST]status(b:0 f:0 g:0 w:2 lpbk:2 coredump:0 wmt:2 stp:0)
[  265.043528] [WMT-FUNC][W]wmt_func_wifi_off:WMT-FUNC: wmt wlan func on before wlan remove
[  265.051569] [MTK-WIFI] register_set_p2p_mode_handler: (pid 618) register set p2p mode handler   (null)
[  265.451846] [WMT-FUNC][W]wmt_func_wifi_off:WMT-FUNC: wmt call wlan remove ok
[  265.459032] vcn18: mode operation not allowed
[  265.463485] DEBUG: Passed mtk_wcn_consys_hw_reg_ctrl 234 
[  265.468856] vcn18: mode operation not allowed
[  265.473220] DEBUG: Passed mtk_wcn_consys_hw_reg_ctrl 238 
[  265.478585] DEBUG: Passed mtk_wcn_consys_hw_reg_ctrl 241 
[  265.483975] DEBUG: Passed mtk_wcn_consys_hw_reg_ctrl 243 
[  265.489836] DEBUG: Passed mtk_wcn_consys_hw_reg_ctrl 250 
[  265.495545] DEBUG: Passed mtk_wcn_consys_hw_reg_ctrl 277 
[  265.501507] DEBUG: Passed mtk_wcn_consys_hw_reg_ctrl 279 
[  265.506902] DEBUG: Passed mtk_wcn_consys_power_on 193 
[  265.512054] DEBUG: Passed mtk_wcn_consys_power_on 195 
[  265.517205] DEBUG: Passed mtk_wcn_consys_power_on 202 
[  265.522336] DEBUG: Passed mtk_wcn_consys_hw_reg_ctrl 281 
[  265.527718] DEBUG: Passed mtk_wcn_consys_hw_reg_ctrl 286 
[  265.591702] [WMT-CORE][W]opfunc_hw_rst:WMT-CORE: -->[HW RST] ok
[  265.597666] [WMT-CORE][W]wmt_core_dump_func_state:[AF HW RST]status(b:0 f:0 g:0 w:0 lpbk:0 coredump:0 wmt:1 stp:0)
[  265.608175] [WMT-CONF][E]wmt_conf_parse_pair(323):unknown field 'mt6620.defAnt'.
[  265.615569] [WMT-CONF][W]wmt_conf_parse:parse fail (mt6620.defAnt, mt6620_ant_m3.cfg, -1)
[  265.623732] [WMT-CONF][E]wmt_conf_parse_pair(323):unknown field 'mt6628.defAnt'.
[  265.631082] [WMT-CONF][W]wmt_conf_parse:parse fail (mt6628.defAnt, mt6628_ant_m1.cfg, -1)
[  265.639235] [WMT-CONF][E]wmt_conf_parse_pair(323):unknown field 'mt6630.defAnt'.
[  265.646612] [WMT-CONF][W]wmt_conf_parse:parse fail (mt6630.defAnt, mt6630_ant_m1.cfg, -1)
[  265.655135] [STP] _mtk_wcn_stp_send_data:[E] WMT lats close,should not have tx request!
[  265.663135] [WMT-CTRL][W]wmt_ctrl_rx:wmt_ctrl_rx be signaled, but no rx data(2000)

Please try to reproduce the problem (step-by-step) and then try that with kernel 4.4.70, open an issue there…i have only ported it,but did not know much about internals

Thanks, I might give a go with the project_test branch on 4.4.70

i will wait for the dev to be stable prior to i replace my current soekris as a router.

The HW spec looks nice but it is NOT ready for production yet.

gary (or any other) must be able to reproduce this error, to fix it…

First ensure you have the wifi up and running prior to test bluetooth as the BT adapter is bundled with a Wi-Fi card.

The device is detected and running but no LE support. My goal is to connect a BT speaker. Only hci tools are working, no bluetoothctl bluetoothd for some reasons.

Bring up with:

# hciconfig hci0 up

List devices

# hciconfig list
hci0:	Type: Primary  Bus: SDIO
	BD Address: 00:00:46:85:90:01  ACL MTU: 1021:4  SCO MTU: 184:1
	UP RUNNING 
	RX bytes:581 acl:0 sco:0 events:32 errors:0
	TX bytes:418 acl:0 sco:0 commands:31 errors:0

List devices

# hcitool dev
Devices:
	hci0	00:00:46:85:90:01

Details device info

# hciconfig -a hci0
hci0:   Type: Primary  Bus: SDIO
        BD Address: 00:00:46:85:90:01  ACL MTU: 1021:4  SCO MTU: 184:1
        UP RUNNING 
        RX bytes:554 acl:0 sco:0 events:27 errors:0
        TX bytes:386 acl:0 sco:0 commands:27 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 
        Name: 'MTK MT8590 #1'
        Class: 0x001f00
        Service Classes: Unspecified
        Device Class: Invalid Device Class!
        HCI Version: 4.0 (0x6)  Revision: 0x0
        LMP Version: 4.1 (0x7)  Subversion: 0x0
        Manufacturer: MediaTek, Inc. (70)

bluetoothd is afaik part of bluez…have you enabled bluez (maybe separate stack also needed) in kernel too? error-message of bluetoothd?

imho wlan must not be connected but the chip must be started before with wmt-tools (wmt_loader ,stp_uart_lancher)

on which step you hang or is not desired result?

To run bluetoothd you need rfkill in the kernel. I manage to avoid the error, but doesn’t solve the issue.

CONFIG_RFKILL_LEDS=y
CONFIG_RFKILL_INPUT=y
CONFIG_RFKILL_GPIO=y

added that and some other now in main

Did some more test, same OS but with kernel 4.4. LEscan is working but unable to pair or set a connection between BT devices. Something is missing in 4.14 to allow LE scan to work.

bluetoothd is still not working.

# /usr/lib/bluetooth/bluetoothd -n -C
bluetoothd[1106]: Bluetooth daemon 5.43
bluetoothd[1106]: Starting SDP server
bluetoothd[1106]: kernel lacks bnep-protocol support
bluetoothd[1106]: System does not support network plugin
bluetoothd[1106]: Bluetooth management interface 1.10 initialized

LEscan

# hcitool lescan
LE Scan ...
4C:42:31:07:6C:XX (unknown)
4C:42:31:07:6C:XX (unknown)
3C:15:C2:CC:13:XX (unknown)
3C:15:C2:CC:13:XX (unknown)
FC:F1:36:C5:CA:XX (unknown)
5D:74:FF:77:B7:XX (unknown)
5D:74:FF:77:B7:XX (unknown)
AC:BC:32:A9:DA:XX (unknown)
AC:BC:32:A9:DA:XX (unknown)

Try to connect

# hcitool leinfo FC:F1:36:C5:CA:C4
Requesting information ...
Could not create connection: Input/output error
root@bpi-r2:~# hcitool leinfo 3C:15:C2:CC:13:B3
Requesting information ...
Could not create connection: Input/output error
root@bpi-r2:~# hcitool leinfo 5D:74:FF:77:B7:CC
Requesting information ...
Could not create connection: Input/output error
root@bpi-r2:~# hcitool leinfo AC:BC:32:A9:DA:C6
Requesting information ...
Could not create connection: Input/output error
root@bpi-r2:~# hcitool leinfo 5B:90:D3:2F:12:BB
Requesting information ...
Could not create connection: Input/output error

which OS do you use? which device? pin-protected? BT-version? bluez-utils (which version) installed?

does it work with 4.4+ubuntu?

BT-Speaker may needs some from the audio/multimedia-stack (internal audio-chip maybe), please first try a “simple” BT-device line mouse/keyboard to test if BT itself is working, the complexer devices like audio/multimedia

maybe passkey-problem: https://debianforum.de/forum/viewtopic.php?p=671148#p671148 (compile passkey-agent and use it to set PINcode)

For all my test i use the same system, eg: Debian stech.

There is nothing related to a BT-Speaker yet as it is pure BT scan and connection. It should be able to list all BT devices available.

# dpkg -l | grep blue
ii  bluetooth                     5.43-2+deb9u1                all          Bluetooth support
ii  bluez                         5.43-2+deb9u1                armhf        Bluetooth tools and daemons
ii  bluez-obexd                   5.43-2+deb9u1                armhf        bluez obex daemon
ii  bluez-tools                   0.2.0~20140808-5+b2          armhf        Set of tools to manage Bluetooth devices for linux

On kernel 4.4, BT init

[  175.326050] [WMT-CORE][W]wmt_core_dump_func_state:[AF FUNC ON]status(b:2 f:0 g:0 w:2 lpbk:2 coredump:0 wmt:2 stp:0)
[  175.341375] [WMT-EXP][W]mtk_wcn_wmt_func_ctrl:OPID(3) type(0) ok
[  175.378610] mtk_bt_hci_notify event(3)=HCI_NOTIFY_VOICE_SETTING
[  175.419856] hci_reassembly: this workaround is applied for mediatek BT

On kernel 4.14, BT init

[ 1690.935593] [WMT-CORE][W]wmt_core_dump_func_state:[AF FUNC ON]status(b:2 f:0 g:0 w:2 lpbk:2 coredump:0 wmt:2 stp:0)
[ 1690.946039] [WMT-EXP][W]mtk_wcn_wmt_func_ctrl:OPID(3) type(0) ok
[ 1690.982828] mtk_bt_hci_notify event(3)=HCI_NOTIFY_VOICE_SETTING
[ 1690.992145] [WMT-CTRL][W]wmt_ctrl_rx:wmt_ctrl_rx be signaled, but no rx data(2000)
[ 1691.025211] hci_reassembly: this workaround is applied for mediatek BT

On 4.14 the additional line:

[ 1690.992145] [WMT-CTRL][W]wmt_ctrl_rx:wmt_ctrl_rx be signaled, but no rx data(2000)

you can connect your speaker with 4.4.70?

then we must search the localtion of that error…i’m currently not at home so i can’t search the source-tree

error seems to be here: https://github.com/frank-w/BPI-R2-4.14/blob/8c3ec0a9f038d0089a28ee306fea1efdb41ad810/drivers/misc/mediatek/connectivity/common/conn_soc/core/wmt_ctrl.c#L274

obj-$(CONFIG_MTK_COMBO_BT_HCI) += bt/

seems to be missing in drivers/misc/mediatek/connectivity/Makefile

i assume that there are coming compile-errors, i had not ported something in the BT-Driver, merged after wifi was working

mhm…the bt-folder is removed also in 4.4.70…strange…

@garywang have you an idea what is missing?

created branch debug_bt…but currently i’ve found no difference to 4.4

there are WMT_DBG_FUNC, but i don’t know how to show that messages…

@xbgmsharp can you add printk() in that file in that function to see more whats going on?

i assume that the read from BT is failing…function mtk_wcn_stp_receive_data is in file /drivers/misc/mediatek/connectivity/common/conn_soc/include/stp_exp.h and drivers/misc/mediatek/connectivity/common/common_detect/wmt_stp_exp.c

The reason why I removed BT folder is that I implemented BT support in linux-mt/drivers/misc/mediatek/connectivity/common/conn_soc/linux/pub/stp_chrdev_bt.c.