您尚未登录。

楼主 # 2023-12-21 14:37:42

542396750@qq.com
会员
注册时间: 2021-03-26
已发帖子: 163
积分: 19.5

v3s使用rtl8723bs蓝牙模块记录

官方给出的步骤是这样的
下载或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

离线

楼主 #1 2023-12-21 14:39:31

542396750@qq.com
会员
注册时间: 2021-03-26
已发帖子: 163
积分: 19.5

Re: v3s使用rtl8723bs蓝牙模块记录

根据自己选择的串口,设备树添加相关的定义

发现代码仓库中代码已失效,找到本站的下载文件rtl8723bs_bt

离线

楼主 #2 2023-12-21 14:40:30

542396750@qq.com
会员
注册时间: 2021-03-26
已发帖子: 163
积分: 19.5

Re: v3s使用rtl8723bs蓝牙模块记录

修改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/

离线

楼主 #3 2023-12-21 14:41:30

542396750@qq.com
会员
注册时间: 2021-03-26
已发帖子: 163
积分: 19.5

Re: v3s使用rtl8723bs蓝牙模块记录

压缩成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

离线

楼主 #4 2023-12-21 14:41:58

542396750@qq.com
会员
注册时间: 2021-03-26
已发帖子: 163
积分: 19.5

Re: v3s使用rtl8723bs蓝牙模块记录

把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

离线

楼主 #5 2023-12-22 11:35:37

542396750@qq.com
会员
注册时间: 2021-03-26
已发帖子: 163
积分: 19.5

Re: v3s使用rtl8723bs蓝牙模块记录

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.

离线

楼主 #6 2023-12-22 11:41:34

542396750@qq.com
会员
注册时间: 2021-03-26
已发帖子: 163
积分: 19.5

Re: v3s使用rtl8723bs蓝牙模块记录

勾上  serial_device_bus之后有了Three-wire UART (H5) protocol support
看来还有依赖没有打开

离线

楼主 #7 2023-12-22 13:22:36

542396750@qq.com
会员
注册时间: 2021-03-26
已发帖子: 163
积分: 19.5

Re: v3s使用rtl8723bs蓝牙模块记录

折腾了还是没出来,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

离线

楼主 #8 2023-12-22 13:22:52

542396750@qq.com
会员
注册时间: 2021-03-26
已发帖子: 163
积分: 19.5

Re: v3s使用rtl8723bs蓝牙模块记录

./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

离线

楼主 #9 2023-12-28 11:40:59

542396750@qq.com
会员
注册时间: 2021-03-26
已发帖子: 163
积分: 19.5

Re: v3s使用rtl8723bs蓝牙模块记录

刚开始勾的bluez 3.x编译,后来改成bluez 5.x,任然没有bluetoothctl,找了好久没找到原因,干脆make clean之后重新make,终于有bluetoothctl了

离线

楼主 #10 2023-12-28 11:43:17

542396750@qq.com
会员
注册时间: 2021-03-26
已发帖子: 163
积分: 19.5

Re: v3s使用rtl8723bs蓝牙模块记录

使用上了bluetoothctl,先启动bluetoothd,再启动bluetoothctl,scan on提示没有可用控制器
几经折腾,使用/usr/libexec/bluetooth/bluetoothd &开启了另外一个bluetoothd,终于可以scan on等操作

离线

楼主 #11 2023-12-28 11:44:13

542396750@qq.com
会员
注册时间: 2021-03-26
已发帖子: 163
积分: 19.5

Re: v3s使用rtl8723bs蓝牙模块记录

目前的问题是pair 和trust之后,connect 设备,连上之后又自动断开了。
不能保持连接。

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn