RTL8761b的驱动适配
说明
RTL8761b 是USB接口的蓝牙,支持5.1,5.0 版本。
驱动适配
送的包装里面有个光盘,把光盘里面的文件,看下发现有Linux的驱动和相关指导。
我上传gitee:
https://gitee.com/qaq-cmd/Drivers-outside-the-kernel
根据 Realtek_Linux_Bluetooth_Porting_Guide.pdf 文档。
解压 20210819_LINUX_BT_DRIVER.tgz ,里面有 usb/bluetooth_usb_driver/ ,把这个文件夹下的c ,h文件都放到内核,写Kconfig,和Makefile 文件即可。
然后编译。
内核patch:bt/rtl8761b
https://gitee.com/qaq-cmd/Drivers-outside-the-kernel
光盘文件里面有个可以把5.0设置为5.1版本的patch我没有打,就用5.0就可以了,有需求的可以试下。
蓝牙测试
typc转USB母口,连接如下:

# 放置fw文件到 /lib/firmware/rtl_bt/
# ls /lib/firmware/rtl_bt/
rtl8761b_config.bin rtl8761b_fw.bin
# 加载编译出来的驱动
insmod btintel.ko
insmod btrtl.ko
insmod btusb.ko
# 启动蓝牙
hciconfig hci0 up
# 查看节点是否产生
hciconfig -a
#进入蓝牙配对模式 这个版本可以tab补全
bluetoothctl
[bluetooth] power on
[bluetooth] agent on
[bluetooth] pairable on
[bluetooth] devices (查看蓝牙是否有之前的设备配对)
[bluetooth] remove 0C:D6:BD:4C:A7:55(如果有将它移除)
[bluetooth] devices(再次查看蓝牙是否有之前的设备配对)
[bluetooth] scan on (开启扫描,会有很多设备刷屏比较乱)
[bluetooth] trust 0C:D6:BD:4C:A7:55 (信任这个设备,该设备为我测试手机)
[bluetooth] pair 0C:D6:BD:4C:A7:55 (配对该设备)
[agent] Confirm passkey 318051 (yes/no): yes (选择yes 配对)
[bluetooth] quit
# 发送接收文件测试
cd /usr/test
# 创建测试文件
echo "123" > /usr/test/test.txt
# 配置环境变量
eval `dbus-launch --sh-syntax`
# 设置obexd进入后台
/usr/libexec/bluetooth/obexd -r /usr/test -a &
#进入[obex]#交互模式
obexctl
[obex] connect 0C:D6:BD:4C:A7:55 (连接手机)
[0C:D6:BD:4C:A7:55] send /usr/test/test.txt (发送/usr/test/目录下的 test.txt 文件)
[0C:D6:BD:4C:A7:55] quit
#让开发板能被其他蓝牙设备识别,自动接收文件,接收到的文件在/usr/test 目录下
hciconfig hci0 piscan
板子发送:

然后手机上查看接收的文件内容。
手机相册选个照片,找到配对的蓝牙,蓝牙发送即可,板子接收:

root@tusk:~# hciconfig -a
hci0: Type: Primary Bus: USB
BD Address: 00:E0:4C:23:99:87 ACL MTU: 1021:6 SCO MTU: 255:12
DOWN
RX bytes:1401 acl:0 sco:0 events:143 errors:0
TX bytes:26427 acl:0 sco:0 commands:143 errors:0
Features: 0xff 0xff 0xff 0xfa 0xdb 0xbf 0x7b 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH HOLD SNIFF PARK
Link mode: SLAVE ACCEPT
root@tusk:~# hciconfig hci0 up
root@tusk:~# hciconfig -a
hci0: Type: Primary Bus: USB
BD Address: 00:E0:4C:23:99:87 ACL MTU: 1021:6 SCO MTU: 255:12
UP RUNNING
RX bytes:2090 acl:0 sco:0 events:187 errors:0
TX bytes:27166 acl:0 sco:0 commands:187 errors:0
Features: 0xff 0xff 0xff 0xfa 0xdb 0xbf 0x7b 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH HOLD SNIFF PARK
Link mode: SLAVE ACCEPT
Name: 'imx8mpevk'
Class: 0x200000
Service Classes: Audio
Device Class: Miscellaneous,
HCI Version: 5.1 (0xa) Revision: 0x9a8
LMP Version: 5.1 (0xa) Subversion: 0xc6b1
Manufacturer: Realtek Semiconductor Corporation (93)
本文来自博客园,作者:杨旭0324,转载请注明原文链接:https://www.cnblogs.com/allalonewithyou/p/19273546,个人邮箱:yaonie4444@foxmail.com

浙公网安备 33010602011771号