官方给出的步骤是这样的
下载或clone下面的源码,编译
https://github.com/NextThingCo/rtl8723bs_bt
首先在dts里使能UART:
sun8i-v3s.dtsi:
uart0_pins_a: uart0@0 { pins = "PB8", "PB9";function = "uart0";bias-pull-up; };
uart1_pins_a: uart1@0 { pins = "PE21", "PE22";function = "uart1";bias-pull-up; };
uart2_pins_a: uart2@0 { pins = "PB0", "PB1";function = "uart2";bias-pull-up; };
sun8i-v3s-licheepi-zero.dts:
&uart0 { pinctrl-0 = <&uart0_pins_a>;pinctrl-names = "default";status = "okay"; };
&uart1 { pinctrl-0 = <&uart1_pins_a>;pinctrl-names = "default";status = "okay"; };
&uart2 { pinctrl-0 = <&uart2_pins_a>;pinctrl-names = "default";status = "okay"; };
再在内核里使能蓝牙功能:
[]Networking support->Bluetooth subsystem support
[]Networking support->Bluetooth subsystem support->Bluetooth device->
HC UART driver->Three-wire UART (H5) protocol support
最后就可以在终端里开启蓝牙,扫描使用设备了:
./start_bt.sh ttyS2
hciconfig -a
hciconfig hci0 up
hcitool scan
离线
根据自己选择的串口,设备树添加相关的定义
发现代码仓库中代码已失效,找到本站的下载文件rtl8723bs_bt
离线
修改makefile
#CC := cc
CC = /home/obm/123/zero/buildroot-2017.08.1/output/host/bin/arm-linux-gnueabihf-gcc
#PREFIX :=
PREFIX =/opt/btstack
make clean
make
# ./rtk_hciattach
hciattach - HCI UART driver initialization utility
Usage:
hciattach [-n] [-p] [-b] [-r] [-t timeout] [-s initial_speed] <tty> <type | id> [speed] [flow|noflow] [bdaddr]
hciattach -l
make install
mkdir -p /opt/btstack/lib/firmware/rtl_bt
mkdir -p /opt/btstack/sbin
cp -p rtlbt_* /opt/btstack/lib/firmware/rtl_bt/.
cp -p rtk_hciattach /opt/btstack/sbin/
cp -p bt_reset /opt/btstack/sbin/
离线
压缩成zip,拷贝到板子上unzip
执行:
sudo ./rtk_hciattach -n -s 115200 /dev/ttyS1 rtk_h5
./rtk_hciattach -n -s 115200 /dev/ttyS1 rtk_h5有反应
Realtek Bluetooth init uart with init speed:115200, final_speed:115200, type:HCI UART H5
Realtek Bluetooth :Realtek hciattach version 2.5
Realtek Bluetooth :3-wire sync pattern resend : 1, len: 8
Realtek Bluetooth :3-wire sync pattern resend : 2, len: 8
Realtek Bluetooth :3-wire sync pattern resend : 3, len: 8
Realtek Bluetooth :Get SYNC Resp Pkt
Realtek Bluetooth :Get SYNC pkt-active mode
Realtek Bluetooth :3-wire config pattern resend : 1 , len: 10
Realtek Bluetooth :Get CONFG pkt-active mode
Realtek Bluetooth :Get CONFG resp pkt-active mode
Realtek Bluetooth :H5 init finished
Realtek Bluetooth ERROR: can't access bt config file:/lib/firmware/rtl_bt/rtlbt_config, errno:2
Realtek Bluetooth ERROR: Get Config file error, just use efuse settings
Realtek Bluetooth ERROR: Can't access firmware, errno:2
Realtek Bluetooth ERROR: Get BT firmware error
Can't initialize device: No such file or directory
离线
把opt里面的两个文件放到lib/firmware/rtl_bt/
Realtek Bluetooth :3-wire sync pattern resend : 2, len: 8
Realtek Bluetooth :3-wire sync pattern resend : 3, len: 8
Realtek Bluetooth :Get SYNC Resp Pkt
Realtek Bluetooth :Get SYNC pkt-active mode
Realtek Bluetooth :3-wire config pattern resend : 1 , len: 10
Realtek Bluetooth :Get CONFG pkt-active mode
Realtek Bluetooth :Get CONFG resp pkt-active mode
Realtek Bluetooth :H5 init finished
Realtek Bluetooth :config offset(f4),length(8)
Realtek Bluetooth :config baud rate to :4928002, hwflowcontrol:5f, 1
Realtek Bluetooth :config offset(27),length(1)
Realtek Bluetooth :config offset(fe),length(1)
Realtek Bluetooth :config offset(15b),length(4)
Realtek Bluetooth :config offset(1e3),length(1)
Realtek Bluetooth :Get config baud rate from config file:4928002
Realtek Bluetooth :Load FW OK
Realtek Bluetooth :RTK send HCI_VENDOR_READ_RTK_ROM_VERISION_Command
Realtek Bluetooth :Received reliable seqno 0 from card
Realtek Bluetooth :receive hci command complete event with command:1001
Realtek Bluetooth :Read RTK LMP version with Status:0
Realtek Bluetooth :gLmpVersion = 0x8723
Realtek Bluetooth :RTK send HCI_VENDOR_READ_RTK_ROM_VERISION_Command
Realtek Bluetooth :Received reliable seqno 1 from card
Realtek Bluetooth :receive hci command complete event with command:fc6d
。。。。。
Realtek Bluetooth :Received reliable seqno 7 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 100
Realtek Bluetooth :Init Process finished
Can’t set device: Protocol not supported
Can’t initialize device: Protocol not supported
离线
linux5.2配置选项并没有
[ ※] Realtek Three-wire UART (H5) protocol support
# ./opt/btstack/sbin/rtk_hciattach -n -s 115200 /dev/ttyS1 rtk_h4
Realtek Bluetooth init uart with init speed:115200, final_speed:115200, type:HCI UART H4
Realtek Bluetooth :Realtek hciattach version 2.5
Realtek Bluetooth :config offset(f4),length(8)
Realtek Bluetooth :config baud rate to :4928002, hwflowcontrol:5f, 1
Realtek Bluetooth :config offset(27),length(1)
Realtek Bluetooth :config offset(fe),length(1)
Realtek Bluetooth :config offset(15b),length(4)
Realtek Bluetooth :config offset(1e3),length(1)
Realtek Bluetooth :Get config baud rate from config file:4928002
Realtek Bluetooth :Load FW OK
Realtek Bluetooth ERROR: Check signature error!
Realtek Bluetooth :baudrate in change speed command: 0x2 0x80 0x92 0x4
Realtek Bluetooth :H4 Change uart Baudrate after write
Initialization timed out.
离线
勾上 serial_device_bus之后有了Three-wire UART (H5) protocol support
看来还有依赖没有打开
离线
折腾了还是没出来,Realtek Three-wire UART (H5) protocol support,先不管了,勾上这个Three-wire UART (H5) protocol support后试试先
果然没有报H5 协议的错误
Realtek Bluetooth :Received reliable seqno 7 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 100
Realtek Bluetooth :Init Process finished
Realtek Bluetooth post process
Device setup complete
离线
./rtk_hciattach -n -s 115200 ttyS1 rtk_h5 > hciattach.txt &
# hciconfig hci0 up
# hcitool scan
Scanning ...
# [ 110.084263] random: crng init done
[ 110.087706] random: 2 urandom warning(s) missed due to ratelimiting
# hcitool scan
Scanning ...
A4:50:46:85:59:01 1152469795鐨凪I 8 SE
可以扫到我的手机蓝牙,接上天线,扫描出
A4:50:46:85:59:01 1152469795鐨凪I 8 SE
9C:BC:F0:05:B2:89 2522395158鐨凴edmi Note 9 4G
34:B9:8D:08:DA:87 2606742277鐨凴edmi Note 9 4G
离线
刚开始勾的bluez 3.x编译,后来改成bluez 5.x,任然没有bluetoothctl,找了好久没找到原因,干脆make clean之后重新make,终于有bluetoothctl了
离线
使用上了bluetoothctl,先启动bluetoothd,再启动bluetoothctl,scan on提示没有可用控制器
几经折腾,使用/usr/libexec/bluetooth/bluetoothd &开启了另外一个bluetoothd,终于可以scan on等操作
离线
目前的问题是pair 和trust之后,connect 设备,连上之后又自动断开了。
不能保持连接。
离线