Bluetooth and rtk_hciattach

For rtk_hciattach I am using the source code from here :

wifi is working.

When I compile rtk_hciattach from that repo, I get the following :

# rtk_hciattach -n -s 115200 /dev/ttyS4 rtk_h5
Realtek Bluetooth :Realtek Bluetooth init uart with init speed:115200, type:HCI UART H5
Realtek Bluetooth :Realtek hciattach version 3.1.8905594.20200602-140152 

Realtek Bluetooth :Use epoll
Realtek Bluetooth WARN: OP_H5_SYNC Transmission timeout
Realtek Bluetooth WARN: OP_H5_SYNC Transmission timeout
Realtek Bluetooth WARN: OP_H5_SYNC Transmission timeout
Realtek Bluetooth WARN: OP_H5_SYNC Transmission timeout
Realtek Bluetooth WARN: OP_H5_SYNC Transmission timeout
Realtek Bluetooth WARN: OP_H5_SYNC Transmission timeout
Realtek Bluetooth WARN: OP_H5_SYNC Transmission timeout
Realtek Bluetooth WARN: OP_H5_SYNC Transmission timeout
Realtek Bluetooth WARN: OP_H5_SYNC Transmission timeout
Realtek Bluetooth WARN: OP_H5_SYNC Transmission timeout
Realtek Bluetooth WARN: OP_H5_SYNC Transmission timeout
Realtek Bluetooth ERROR: Retransmission exhausts

I see the problem for now, the hci_uart module isn’t built

OK now I have a working hci_uart module.
The same problem persists :

# modprobe hci_uart
# lsmod
Module                  Size  Used by    Tainted: G  
hci_uart               40960  0 

# dmesg
[   60.784351] Bluetooth: HCI UART driver ver 2.2.407c1dd.20200602-140151
[   60.791010] Bluetooth: HCI H4 protocol initialized
[   60.795876] Bluetooth: HCI Realtek H5 protocol initialized
[   60.801439] rtk_btcoex: rtk_btcoex_init: version: 1.2
[   60.806691] rtk_btcoex: create workqueue
[   60.810856] rtk_btcoex: alloc buffers 1792, 2432 for ev and l2

# rtk_hciattach -n -s 115200 /dev/ttyS4 rtk_h5
Realtek Bluetooth :Realtek Bluetooth init uart with init speed:115200, type:HCI UART H5
Realtek Bluetooth :Realtek hciattach version 3.1.8905594.20200602-140152 

Realtek Bluetooth :Use epoll
Realtek Bluetooth WARN: OP_H5_SYNC Transmission timeout
Realtek Bluetooth WARN: OP_H5_SYNC Transmission timeout
Realtek Bluetooth WARN: OP_H5_SYNC Transmission timeout
Realtek Bluetooth WARN: OP_H5_SYNC Transmission timeout
Realtek Bluetooth WARN: OP_H5_SYNC Transmission timeout
Realtek Bluetooth WARN: OP_H5_SYNC Transmission timeout
Realtek Bluetooth WARN: OP_H5_SYNC Transmission timeout
Realtek Bluetooth WARN: OP_H5_SYNC Transmission timeout
Realtek Bluetooth WARN: OP_H5_SYNC Transmission timeout
Realtek Bluetooth WARN: OP_H5_SYNC Transmission timeout
Realtek Bluetooth WARN: OP_H5_SYNC Transmission timeout
Realtek Bluetooth ERROR: Retransmission exhausts

You can refer:

https://wiki.radxa.com/RockpiS/Debian#Bluetooth

Hi Jack,

I am using buildroot : https://github.com/flatmax/buildroot.rk3308

The debian apt package manager doesn’t work in buildroot. Buildroot is a thin and minimal operating system installation based on Linux and busybox.

Can you please link me to the debian distro source codes for the various apt packages ?

thanks
Matt

you can find the source code of the deb package with

apt source package-name

I have switched to using the Radxa kernel. You can see the changes here : https://github.com/flatmax/buildroot.rockchip/commit/af527c257d270097d5d19ffaa3489e0fd2602de9

I am trying to setup the bluetooth, not sure if the hci device is meant to show now ?

Here is a sample of my console :

[    2.362276] Bluetooth: RFCOMM TTY layer initialized
[    2.362296] Bluetooth: RFCOMM socket layer initialized
[    2.362332] Bluetooth: RFCOMM ver 1.11
[    2.362354] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[    2.362364] Bluetooth: HIDP socket layer initialized
[    2.362377] 8021q: 802.1Q VLAN Support v1.8
[    2.362425] [WLAN_RFKILL]: Enter rfkill_wlan_init
[    2.363028] [WLAN_RFKILL]: Enter rfkill_wlan_probe
[    2.363049] [WLAN_RFKILL]: wlan_platdata_parse_dt: wifi_chip_type = rtl8723ds

[    2.363053] [WLAN_RFKILL]: wlan_platdata_parse_dt: enable wifi power control.

[    2.363057] [WLAN_RFKILL]: wlan_platdata_parse_dt: wifi power controled by gp
io.
[    2.363066] of_get_named_gpiod_flags: can't parse 'WIFI,poweren_gpio' propert
y of node '/wireless-wlan[0]'
[    2.363072] of_get_named_gpiod_flags: can't parse 'WIFI,vbat_gpio' property o
f node '/wireless-wlan[0]'
[    2.363078] of_get_named_gpiod_flags: can't parse 'WIFI,reset_gpio' property 
of node '/wireless-wlan[0]'
[    2.363108] of_get_named_gpiod_flags: parsed 'WIFI,host_wake_irq' property of
 node '/wireless-wlan[0]' - status (0)
[    2.363113] [WLAN_RFKILL]: wlan_platdata_parse_dt: get property: WIFI,host_wa
ke_irq = 0, flags = 0.
[    2.363172] [WLAN_RFKILL]: rfkill_wlan_probe: init gpio
[    2.363179] [WLAN_RFKILL]: Exit rfkill_wlan_probe
[    2.363258] [BT_RFKILL]: Enter rfkill_rk_init
[    2.363680] of_get_named_gpiod_flags: parsed 'uart_rts_gpios' property of nod
e '/wireless-bluetooth[0]' - status (0)
[    2.363685] [BT_RFKILL]: bluetooth_platdata_parse_dt: get property: uart_rts_
gpios = 135.
[    2.363702] of_get_named_gpiod_flags: parsed 'BT,power_gpio' property of node
 '/wireless-bluetooth[0]' - status (0)
[    2.363708] [BT_RFKILL]: bluetooth_platdata_parse_dt: get property: BT,power_
gpio = 139.
[    2.363714] of_get_named_gpiod_flags: can't parse 'BT,reset_gpio' property of
 node '/wireless-bluetooth[0]'
[    2.363720] of_get_named_gpiod_flags: can't parse 'BT,wake_gpio' property of 
node '/wireless-bluetooth[0]'
[    2.363734] of_get_named_gpiod_flags: parsed 'BT,wake_host_irq' property of n
ode '/wireless-bluetooth[0]' - status (0)
[    2.363740] [BT_RFKILL]: bluetooth_platdata_parse_dt: get property: BT,wake_h
ost_irq = 140.
[    2.363749] [BT_RFKILL]: bluetooth_platdata_parse_dt: clk_get failed!!!.
[    2.363820] [BT_RFKILL]: Request irq for bt wakeup host
[    2.363879] [BT_RFKILL]: ** disable irq
[    2.364074] [BT_RFKILL]: bt_default device registered.

Hi, please show all the log provided by sudo dmesg. I want to see if you miss something.

Also, you can trouble shooting like this.

1.Put rtl8723d_config and rtl8723d_fw in directory /lib/firmware/rtlbt.

2.Install module hci_uart.ko

3.Load rtl8723ds BT firmware

/usr/sbin/rfkill block bluetooth
sleep 2
/usr/sbin/rfkill unblock bluetooth
sleep 2
/usr/bin/rtk_hciattach -n -s 115200 /dev/ttyS4 rtk_h5 &

4.Check BT device

hciconfig -a

ok - I have now included the rtk_hciattach code and the firmware in the buildroot system.
echo 0 > /sys/class/rfkill/rfkill0/state
echo 1 > /sys/class/rfkill/rfkill0/state
modprobe hci_uart
rtk_hciattach -n -s 115200 /dev/ttyS4 rtk_h5 &

The output of rtk_hciattach is lower down. hciconfig -a outputs the following :

# hciconfig -a
hci0:	Type: Primary  Bus: UART
	BD Address: 00:E0:4C:23:99:87  ACL MTU: 1021:8  SCO MTU: 255:12
	DOWN 
	RX bytes:1115 acl:0 sco:0 events:34 errors:0
	TX bytes:938 acl:0 sco:0 commands:34 errors:0
	Features: 0xff 0xff 0xff 0xfe 0xdb 0xfd 0x7b 0x87
	Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
	Link policy: RSWITCH HOLD SNIFF PARK 
	Link mode: SLAVE ACCEPT 

rtk_hciattach outputs tthe following :
# Realtek Bluetooth :Realtek Bluetooth init uart with init speed:115200, type:HCI UART H5
Realtek Bluetooth :Realtek hciattach version 3.1.8905594.20200602-140152

Realtek Bluetooth :Use epoll
Realtek Bluetooth :[SYNC] Get SYNC Resp Pkt
Realtek Bluetooth :[CONFIG] Get SYNC pkt
Realtek Bluetooth :[CONFIG] Get CONFG pkt
Realtek Bluetooth :[CONFIG] Get CONFG resp pkt
Realtek Bluetooth :dic is 1, cfg field 0x14
Realtek Bluetooth :H5 init finished

Realtek Bluetooth :Realtek H5 IC
Realtek Bluetooth :Receive cmd complete event of command: 1001
Realtek Bluetooth :HCI Version 0x08
Realtek Bluetooth :HCI Revision 0x000d
Realtek Bluetooth :LMP Subversion 0x8723
Realtek Bluetooth :Receive cmd complete event of command: fc6d
Realtek Bluetooth :Read ROM version 02
Realtek Bluetooth :LMP Subversion 0x8723
Realtek Bluetooth :EVersion 2
Realtek Bluetooth :IC: RTL8723DS
Realtek Bluetooth :Firmware/config: rtl8723d_fw, rtl8723d_config
Realtek Bluetooth :Couldnt open extra config /opt/rtk_btconfig.txt, No such file or directory
Realtek Bluetooth :Couldnt access customer BT MAC file /opt/bdaddr
Realtek Bluetooth ERROR: Can't access Config file: /lib/firmware/rtlbt/rtl8723d_config, No such file or directory
Realtek Bluetooth ERROR: Read Config file error, use eFuse settings
Realtek Bluetooth :Load FW /lib/firmware/rtlbt/rtl8723d_fw OK, size 52712
Realtek Bluetooth :rtb_get_fw_project_id: opcode 0, len 1, data 9
Realtek Bluetooth :FW version 0xaa7b5645, Patch num 3
Realtek Bluetooth :Chip id 0x0001
Realtek Bluetooth :Chip id 0x0002
Realtek Bluetooth :Chip id 0x0003
Realtek Bluetooth :Patch length 0x8420
Realtek Bluetooth :Start offset 0x00004980
Realtek Bluetooth :Svn version:    20543
Realtek Bluetooth :Coexistence: BTCOEX_20180125-2323

Realtek Bluetooth :FW  exists, Config file not exists
Realtek Bluetooth :Total len 33824 for fwc
Realtek Bluetooth :No baud from Config file, set baudrate: 115200, 0x0252c014
Realtek Bluetooth :end_idx: 134, lp_len: 56, additional pkts: 6

Realtek Bluetooth :Start downloading...
Realtek Bluetooth :Send additional packet 8
Realtek Bluetooth :Send additional packet 9
Realtek Bluetooth :Send additional packet 10
Realtek Bluetooth :Send additional packet 11
Realtek Bluetooth :Send additional packet 12
Realtek Bluetooth :Last packet 141
Realtek Bluetooth :Send last pkt
Realtek Bluetooth :Disable host hw flow control
Realtek Bluetooth :h5_hci_reset: Issue hci reset cmd
Realtek Bluetooth :Receive cmd complete event of command: 0c03
Realtek Bluetooth :Received cc of hci reset cmd
Realtek Bluetooth :Init Process finished
Realtek Bluetooth :Realtek Bluetooth post process
Realtek Bluetooth :Device setup complete

When I try to bring up hci0 I get the following :

# hciconfig hci0 up
Can't init device hci0: Invalid request code (56)

# hciconfig -a
hci0:	Type: Primary  Bus: UART
	BD Address: 00:E0:4C:23:99:87  ACL MTU: 1021:8  SCO MTU: 255:12
	DOWN 
	RX bytes:2238 acl:0 sco:0 events:68 errors:0
	TX bytes:1880 acl:0 sco:0 commands:69 errors:0
	Features: 0xff 0xff 0xff 0xfe 0xdb 0xfd 0x7b 0x87
	Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
	Link policy: RSWITCH HOLD SNIFF PARK 
	Link mode: SLAVE ACCEPT 

Here is the dmesg for all of the above :
# dmesg
[ 152.065319] [BT_RFKILL]: bt shut off power
[ 157.611807] [BT_RFKILL]: rfkill_rk_set_power: set bt wake_host pin output high!
[ 157.689333] [BT_RFKILL]: rfkill_rk_set_power: set bt wake_host pin input!
[ 157.697512] [BT_RFKILL]: ENABLE UART_RTS
[ 157.805384] [BT_RFKILL]: DISABLE UART_RTS
[ 157.810293] [BT_RFKILL]: bt turn on power
[ 173.252048] Bluetooth: HCI UART driver ver 2.2.d448471.20190215-141136
[ 173.259949] Bluetooth: HCI H4 protocol initialized
[ 173.265723] Bluetooth: HCI Realtek H5 protocol initialized
[ 173.272295] rtk_btcoex: rtk_btcoex_init: version: 1.2
[ 173.278403] rtk_btcoex: create workqueue
[ 173.283095] rtk_btcoex: Coex over UDP
[ 173.288047] rtk_btcoex: alloc buffers 1792, 2432 for ev and l2
[ 199.309605] Bluetooth: h5_open
[ 199.313374] Bluetooth: hci_uart_register_dev
[ 199.320925] rtk_btcoex: Open BTCOEX
[ 199.325219] rtk_btcoex: create_udpsocket: connect_port: 30001
[ 199.332203] rtk_btcoex: send msg INVITE_REQ with len:11
[ 199.350504] rtk_btcoex: BTCOEX hci_rev 0xaa7b
[ 199.355782] rtk_btcoex: BTCOEX lmp_subver 0x5645
[ 199.581571] rtk_btcoex: Close BTCOEX
[ 199.585912] rtk_btcoex: release udp socket
[ 199.590905] rtk_btcoex: -x
[ 558.738394] rtk_btcoex: Open BTCOEX
[ 558.742652] rtk_btcoex: create_udpsocket: connect_port: 30001
[ 558.749610] rtk_btcoex: send msg INVITE_REQ with len:11
[ 559.001414] Bluetooth: hu ffffffc019e7b080 retransmitting 1 pkts
[ 559.019747] rtk_btcoex: BTCOEX hci_rev 0xaa7b
[ 559.025036] rtk_btcoex: BTCOEX lmp_subver 0x5645
[ 559.250752] rtk_btcoex: Close BTCOEX
[ 559.255122] rtk_btcoex: release udp socket
[ 559.260095] rtk_btcoex: -x

Is there a git repo with your rtk_hciattach code somewhere ?

Hi, check here. https://github.com/radxa/rkwifibt/tree/master/realtek/rtk_hciattach

Or use these four files. https://github.com/radxa/meta-radxa/tree/zeus/recipes-devtools/rtl-tools/files

ok that works.
I got the firmware config file from that repo and am now using the radxa repo for rtl_hciattach.

# hciconfig 
	UP RUNNING 

Here are the latest buildroot commits relating to this work :

thanks for your help

1 Like