BuildRoot配置RTL8822CE WIFI&BT模块(BT部分)

发布时间:2024年01月20日

BuildRoot配置RTL8822CE WIFI&BT模块(WIFI部分)-CSDN博客

WIFI部分更新一下:

①、rkwifibt.mk

查看了output/rockchip_rk3399_tinkerboard2/build/的两个目录都有wifi相关的ko(后面make clean之后剩下linux-headers-custom路径的),md5都一样,随便选了一个,拷贝所有ko

zoipuus@ADM5800X:/home/workspace/BuildSpace/RepoProjects/Linux/buildroot$ md5sum output/rockchip_rk3399_tinkerboard2/build/*/drivers/net/wireless/rockchip_wlan/*/*.ko
0a6b7ee3fe2d637725cff8f04f5c4f25  output/rockchip_rk3399_tinkerboard2/build/linux-custom/drivers/net/wireless/rockchip_wlan/rtl8812AU_8821AU_linux/8812au.ko
eb38d81925a693ab33d47bd711515624  output/rockchip_rk3399_tinkerboard2/build/linux-custom/drivers/net/wireless/rockchip_wlan/rtl8814au/8814au.ko
35545c69741d15e728330ec295281361  output/rockchip_rk3399_tinkerboard2/build/linux-custom/drivers/net/wireless/rockchip_wlan/rtl8822ce/8822ce.ko
957baa941cea1254775d2ef9d72372bf  output/rockchip_rk3399_tinkerboard2/build/linux-custom/drivers/net/wireless/rockchip_wlan/rtl8852be/8852be.ko
0a6b7ee3fe2d637725cff8f04f5c4f25  output/rockchip_rk3399_tinkerboard2/build/linux-headers-custom/drivers/net/wireless/rockchip_wlan/rtl8812AU_8821AU_linux/8812au.ko
eb38d81925a693ab33d47bd711515624  output/rockchip_rk3399_tinkerboard2/build/linux-headers-custom/drivers/net/wireless/rockchip_wlan/rtl8814au/8814au.ko
35545c69741d15e728330ec295281361  output/rockchip_rk3399_tinkerboard2/build/linux-headers-custom/drivers/net/wireless/rockchip_wlan/rtl8822ce/8822ce.ko
957baa941cea1254775d2ef9d72372bf  output/rockchip_rk3399_tinkerboard2/build/linux-headers-custom/drivers/net/wireless/rockchip_wlan/rtl8852be/8852be.ko
diff --git a/package/rockchip/rkwifibt/rkwifibt.mk b/package/rockchip/rkwifibt/rkwifibt.mk
index aab7637a..e0bdadb9 100644
--- a/package/rockchip/rkwifibt/rkwifibt.mk
+++ b/package/rockchip/rkwifibt/rkwifibt.mk
@@ -46,7 +46,6 @@ define RKWIFIBT_INSTALL_COMMON
     $(INSTALL) -D -m 0755 $(@D)/wifi_start.sh $(TARGET_DIR)/usr/bin/
     $(INSTALL) -D -m 0755 $(@D)/wifi_ap6xxx_rftest.sh $(TARGET_DIR)/usr/bin/
     $(INSTALL) -D -m 0755 $(@D)/src/rk_wifi_init $(TARGET_DIR)/usr/bin/
-    $(INSTALL) -D -m 0644 $(TOPDIR)/../kernel/drivers/net/wireless/rockchip_wlan/rtl8822ce/*.ko $(TARGET_DIR)/vendor/lib/modules/
     $(SED) 's/WIFI_KO/\/$(FIRMWARE_DIR)\/lib\/modules\/$(BR2_PACKAGE_RKWIFIBT_WIFI_KO)/g' $(@D)/$(SXLOAD_WIFI)
     $(SED) 's/BT_TTY_DEV/\/dev\/$(BT_TTY_DEV)/g' $(@D)/$(SXLOAD_WIFI)
     -$(INSTALL) -D -m 0755 $(@D)/$(SXLOAD_WIFI) $(TARGET_DIR)/etc/init.d/
@@ -85,6 +84,7 @@ define RKWIFIBT_BROADCOM_INSTALL
 endef

 define RKWIFIBT_REALTEK_WIFI_INSTALL
+    $(INSTALL) -D -m 0644 $(@D)/../*/drivers/net/wireless/rockchip_wlan/*/*.ko $(TARGET_DIR)/vendor/lib/modules/
     $(INSTALL) -D -m 0755 $(@D)/bin/$(RKWIFIBT_ARCH)/rtwpriv $(TARGET_DIR)/usr/bin/
     $(INSTALL) -D -m 0755 $(@D)/$(SXLOAD_WIFI) $(TARGET_DIR)/etc/init.d/
 endef

②、移除对应package里面的.stamp_*是可以重新编译的

zoipuus@ADM5800X:/home/workspace/BuildSpace/RepoProjects/Linux$ rm buildroot/output/rockchip_rk3399_tinkerboard2/build/rkwifibt-1.0.0/.stamp_*
zoipuus@ADM5800X:/home/workspace/BuildSpace/RepoProjects/Linux$ ./build.sh buildroot

2024-01-16T11:37:35 >>> rkwifibt 1.0.0 Syncing from source dir /home/workspace/BuildSpace/RepoProjects/Linux/buildroot/../external/rkwifibt
2024-01-16T11:37:35 >>> rkwifibt 1.0.0 Configuring
2024-01-16T11:37:35 >>> rkwifibt 1.0.0 Building

1、kernel配置

2、buildroot配置

2.1、BT_EN配置?

之前配置WIFI时已经知道板卡里面没有.ko文件,所以要查配置看哪里没有设置?

make menuconfig查看BR2_PACKAGE_RKWIFIBT_BT_EN属性为空,rkwifibt.sh无法执行BT相关的文件拷贝

 Symbol: BR2_PACKAGE_RKWIFIBT_BT_EN [=]                                                                                                                   │
  │ Type  : string                                                                                                                                           │
  │   Defined at package/rockchip/rkwifibt/Config.in:182                                                                                                     │
  │   Depends on: BR2_PACKAGE_ROCKCHIP [=y] && BR2_PACKAGE_RKWIFIBT [=y] 

修改Config.in,再make menuconfig查看BR2_PACKAGE_RKWIFIBT_BT_EN属性

diff --git a/package/rockchip/rkwifibt/Config.in b/package/rockchip/rkwifibt/Config.in
index 2adf0f7a..46aa6112 100644
--- a/package/rockchip/rkwifibt/Config.in
+++ b/package/rockchip/rkwifibt/Config.in
@@ -199,6 +199,7 @@ config BR2_PACKAGE_RKWIFIBT_BT_EN
     default "ENABLE" if BR2_PACKAGE_RKWIFIBT_RTL8723CS
     default "ENABLE" if BR2_PACKAGE_RKWIFIBT_RTL8723DS
     default "ENABLE" if BR2_PACKAGE_RKWIFIBT_RTL8821CS
+    default "ENABLE" if BR2_PACKAGE_RKWIFIBT_RTL8822CE
     default "DISABLE" if BR2_PACKAGE_RKWIFIBT_RK912

 endif
 Symbol: BR2_PACKAGE_RKWIFIBT_BT_EN [=ENABLE]                                                                                                             │
  │ Type  : string                                                                                                                                           │
  │   Defined at package/rockchip/rkwifibt/Config.in:182                                                                                                     │
  │   Depends on: BR2_PACKAGE_ROCKCHIP [=y] && BR2_PACKAGE_RKWIFIBT [=y] 

2.2、拷贝rtk_btusb.ko

diff --git a/package/rockchip/rkwifibt/rkwifibt.mk b/package/rockchip/rkwifibt/rkwifibt.mk
index aab7637a..1d721295 100644
--- a/package/rockchip/rkwifibt/rkwifibt.mk
+++ b/package/rockchip/rkwifibt/rkwifibt.mk
@@ -96,6 +96,7 @@ define RKWIFIBT_REALTEK_BT_INSTALL
     -$(INSTALL) -D -m 0644 $(@D)/realtek/$(BR2_PACKAGE_RKWIFIBT_CHIPNAME)/mp_* $(TARGET_DIR)/lib/firmware/rtlbt/
     -$(INSTALL) -D -m 0644 $(@D)/realtek/$(BR2_PACKAGE_RKWIFIBT_CHIPNAME)/mp_* $(TARGET_DIR)/lib/firmware/
     $(INSTALL) -D -m 0755 $(@D)/bt_realtek* $(TARGET_DIR)/usr/bin/
+    $(INSTALL) -D -m 0644 $(@D)/../*/drivers/bluetooth/rtk_btusb.ko $(TARGET_DIR)/usr/lib/modules/rtk_btusb.ko
     $(INSTALL) -D -m 0644 $(@D)/realtek/bluetooth_uart_driver/hci_uart.ko $(TARGET_DIR)/usr/lib/modules/hci_uart.ko
     $(INSTALL) -D -m 0755 $(@D)/bt_load_rtk_firmware $(TARGET_DIR)/usr/bin/
     $(SED) 's/BT_TTY_DEV/\/dev\/$(BT_TTY_DEV)/g' $(TARGET_DIR)/usr/bin/bt_load_rtk_firmware

2.3、bluez-utils配置?

3、处理编译问题

3.1、没有RTL8822CE路径?

2024-01-16T11:15:55 /usr/bin/install: cannot stat '/home/workspace/BuildSpace/RepoProjects/Linux/buildroot/output/rockchip_rk3399_tinkerboard2/build/rkwifibt-1.0.0/realtek/RTL8822CE/*': No such file or directory
2024-01-16T11:15:55 make[1]: *** [package/pkg-generic.mk:313: /home/workspace/BuildSpace/RepoProjects/Linux/buildroot/output/rockchip_rk3399_tinkerboard2/build/rkwifibt-1.0.0/.stamp_target_installed] Error 1
2024-01-16T11:15:55 make: *** [/home/workspace/BuildSpace/RepoProjects/Linux/buildroot/output/rockchip_rk3399_tinkerboard2/Makefile:16: _all] Error 2
Command exited with non-zero status 1
you take 2:24.42 to build builroot
ERROR: Running build_buildroot failed!
ERROR: exit code 1 from line 581:
    /usr/bin/time -f "you take %E to build builroot" $COMMON_DIR/mk-buildroot.sh $BOARD_CONFIG

确实没有RTL8822CE目录,有RTL8822CS

zoipuus@ADM5800X:/home/workspace/BuildSpace/RepoProjects/Linux$ ls -l buildroot/output/rockchip_rk3399_tinkerboard2/build/rkwifibt-1.0.0/realtek/
总计 60
drwxr-xr-x 3 zoipuus zoipuus  4096  1月 16 11:15 bluetooth_uart_driver
-rw-r--r-- 1 zoipuus zoipuus 30632  1月  9 22:09 bluetooth_uart_driver.7z
drwxr-xr-x 2 zoipuus zoipuus  4096  1月  9 22:09 bluetooth_usb_driver
drwxr-xr-x 4 zoipuus zoipuus  4096  1月  9 22:09 demo
drwxr-xr-x 2 zoipuus zoipuus  4096  1月  9 22:09 rtk_hciattach
drwxr-xr-x 2 zoipuus zoipuus  4096  1月  9 22:09 RTL8723DS
drwxr-xr-x 2 zoipuus zoipuus  4096  1月  9 22:09 RTL8821CS
drwxr-xr-x 2 zoipuus zoipuus  4096  1月  9 22:09 RTL8822CS

文件暂时拷贝RTL8822CS的,编译通过,运行

4、加载rtk_btusb.ko失败

手动加载rtk_btusb.ko

[root@rk3399:/]# insmod /usr/lib/modules/rtk_btusb.ko
[  113.943635] rtk_btusb: Realtek Bluetooth USB driver ver 3.1.32e1d0b.20210819-170430
[  113.944823] rtk_btcoex: rtk_btcoex_init: version: 1.2
[  113.945893] rtk_btcoex: create workqueue
[  113.947686] [root@rk3399:/]# rtk_btcoex: alloc buffers 1792, 2432 for ev and l2
[  113.949094] rtk_btusb: btusb_probe intf->cur_altsetting->desc.bInterfaceNumber 0
[  113.950123] rtk_btusb: btusb_probe can_wakeup 1, may wakeup 0
[  113.951240] rtk_btusb: patch_add
[  113.952230] rtk_btusb: auto suspend is disabled
[  113.953196] rtk_btusb: pid = 0x3548
[  113.954158] rtk_btusb: patch_add: Reset gEVersion to 0xff
[  113.955074] rtk_btusb: set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
[  113.956496] rtk_btusb: btusb_probe: done
[  113.956532] rtk_btusb: btusb_open start
[  113.957596] usbcore: registered new interface driver rtk_btusb
[  113.963305] rtk_btusb: btusb_open hdev->promisc ==0
[  113.970062] rtk_btusb: download_patch start
[  113.975814] rtk_btusb: chip type value: 0x73
[  113.983969] rtk_btusb: HCI reset.
[  114.002215] rtk_btusb: read_ver_rsp->lmp_subver = 0x8822
[  114.006274] rtk_btusb: read_ver_rsp->hci_rev = 0xc
[  114.010257] rtk_btusb: patch_entry->lmp_sub = 0x8822
[  114.014345] rtk_btusb: load_firmware start
[  114.018482] rtk_btusb: lmp_version = 0x8822
[  114.022663] rtk_btusb: config filename rtl8822cu_config
[  114.027083] usb 6-1: Direct firmware load for rtl8822cu_config failed with error -2
[  114.031503] rtk_btusb: fw name is  rtl8822cu_fw
[  114.034913] usb 6-1: Direct firmware load for rtl8822cu_fw failed with error -2
[  114.038243] rtk_btusb: load firmware failed!
[  114.041601] rtk_btusb: Rtk patch end -1
[  114.044977] rtk_btusb: btusb_open failed

无法加载rtl8822cu_config和rtl8822cu_fw

drivers/bluetooth/rtk_misc.c?

(misc.c)load_config ->? (main.c)request_firmware -> (main.c)_request_firmware

drivers/base/firmware_loader/main.c

?

?修改打印输出

diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c
index ca1031ebc431..26cb376dde7e 100644
--- a/drivers/base/firmware_loader/main.c
+++ b/drivers/base/firmware_loader/main.c
@@ -329,7 +329,7 @@ fw_get_filesystem_firmware(struct device *device, struct fw_priv *fw_priv)
                                                msize, id);
                if (rc) {
                        if (rc == -ENOENT)
-                               dev_dbg(device, "loading %s failed with error %d\n",
+                               dev_err(device, "loading %s failed with error %d\n",
                                         path, rc);
                        else
                                dev_warn(device, "loading %s failed with error %d\n",
[  323.565696] usb 6-1: loading /lib/firmware/updates/4.19.193/rtl8822cu_config failed with error -2
[  323.566573] usb 6-1: loading /lib/firmware/updates/rtl8822cu_config failed with error -2
[  323.567465] usb 6-1: loading /lib/firmware/4.19.193/rtl8822cu_config failed with error -2
[  323.568345] usb 6-1: loading /lib/firmware/rtl8822cu_config failed with error -2
[  323.569233] usb 6-1: Direct firmware load for rtl8822cu_config failed with error -2
[  323.570135] rtk_btusb: fw name is  rtl8822cu_fw
[  323.571071] usb 6-1: loading /lib/firmware/updates/4.19.193/rtl8822cu_fw failed with error -2
[  323.572035] usb 6-1: loading /lib/firmware/updates/rtl8822cu_fw failed with error -2
[  323.572968] usb 6-1: loading /lib/firmware/4.19.193/rtl8822cu_fw failed with error -2
[  323.573913] usb 6-1: loading /lib/firmware/rtl8822cu_fw failed with error -2
[  323.574837] usb 6-1: Direct firmware load for rtl8822cu_fw failed with error -2
[  323.575768] rtk_btusb: load firmware failed!
[  323.576682] rtk_btusb: Rtk patch end -1
[  323.577606] rtk_btusb: btusb_open failed

看了一下rtk_misc.c,8822CU和8822CE都使用相同的文件,文件路径跟rkwifibt.sh配置的不一样,改成上面打印出来的其中一个路径即可

@@ -92,10 +92,11 @@ endef
 define RKWIFIBT_REALTEK_BT_INSTALL
     $(INSTALL) -D -m 0755 $(@D)/realtek/rtk_hciattach/rtk_hciattach $(TARGET_DIR)/usr/bin/rtk_hciattach
     $(INSTALL) -D -m 0755 $(@D)/bin/$(RKWIFIBT_ARCH)/* $(TARGET_DIR)/usr/bin/
-    $(INSTALL) -D -m 0644 $(@D)/realtek/$(BR2_PACKAGE_RKWIFIBT_CHIPNAME)/* $(TARGET_DIR)/lib/firmware/rtlbt/
+    $(INSTALL) -D -m 0644 $(@D)/realtek/$(BR2_PACKAGE_RKWIFIBT_CHIPNAME)/* $(TARGET_DIR)/lib/firmware/
     -$(INSTALL) -D -m 0644 $(@D)/realtek/$(BR2_PACKAGE_RKWIFIBT_CHIPNAME)/mp_* $(TARGET_DIR)/lib/firmware/rtlbt/
     -$(INSTALL) -D -m 0644 $(@D)/realtek/$(BR2_PACKAGE_RKWIFIBT_CHIPNAME)/mp_* $(TARGET_DIR)/lib/firmware/
     $(INSTALL) -D -m 0755 $(@D)/bt_realtek* $(TARGET_DIR)/usr/bin/
+    $(INSTALL) -D -m 0644 $(@D)/../*/drivers/bluetooth/rtk_btusb.ko $(TARGET_DIR)/usr/lib/modules/rtk_btusb.ko
     $(INSTALL) -D -m 0644 $(@D)/realtek/bluetooth_uart_driver/hci_uart.ko $(TARGET_DIR)/usr/lib/modules/hci_uart.ko
     $(INSTALL) -D -m 0755 $(@D)/bt_load_rtk_firmware $(TARGET_DIR)/usr/bin/
     $(SED) 's/BT_TTY_DEV/\/dev\/$(BT_TTY_DEV)/g' $(TARGET_DIR)/usr/bin/bt_load_rtk_firmware
[root@rk3399:/]# insmod /usr/lib/modules/rtk_btusb.ko
[  692.608607] rtk_btusb: Realtek Bluetooth USB driver ver 3.1.32e1d0b.20210819-170430
[  692.609896] rtk_btcoex: rtk_btcoex_init: version: 1.2
[  692.611098] rtk_btcoex: create workqueue
[  692.613186] rtk_btcoex: alloc buffers 1792, 2432 for ev and l2
[  692.614518] rtk_btusb: btusb_probe intf->cur_altsetting->desc.bInterfaceNu[rmoot@rk3399:/]# ber 0
[  692.615699] rtk_btusb: btusb_probe can_wakeup 1, may wakeup 0
[  692.616864] rtk_btusb: patch_add
[  692.617942] rtk_btusb: auto suspend is disabled
[  692.619058] rtk_btusb: pid = 0x3548
[  692.620123] rtk_btusb: patch_add: Reset gEVersion to 0xff
[  692.621273] rtk_btusb: set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
[  692.623014] rtk_btusb: btusb_probe: done
[  692.623093] rtk_btusb: btusb_open start
[  692.632470] usbcore: registered new interface driver rtk_btusb
[  692.632950] rtk_btusb: btusb_open hdev->promisc ==0
[  692.634778] rtk_btusb: download_patch start
[  692.635651] rtk_btusb: chip type value: 0x73
[  692.636499] rtk_btusb: HCI reset.
[  692.651303] rtk_btusb: read_ver_rsp->lmp_subver = 0x8822
[  692.652337] rtk_btusb: read_ver_rsp->hci_rev = 0xc
[  692.653348] rtk_btusb: patch_entry->lmp_sub = 0x8822
[  692.654427] rtk_btusb: load_firmware start
[  692.655448] rtk_btusb: lmp_version = 0x8822
[  692.656449] rtk_btusb: config filename rtl8822cu_config
[  692.663614] rtk_btusb: no bdaddr file /opt/bdaddr
[  692.664754] rtk_btusb: Origin cfg len 25
[  692.665812] rtk_btusb: 55 ab 23 87 13 00 0c 00 10 02 80 92 04 50 c5 ea
[  692.666874] rtk_btusb: 19 e1 1b fd af 5f 01 a4 0b
[  692.667961] rtk_btusb: New cfg len 25
[  692.668983] rtk_btusb: 55 ab 23 87 13 00 0c 00 10 02 80 92 04 50 c5 ea
[  692.670011] rtk_btusb: 19 e1 1b fd af 5f 01 a4 0b
[  692.671058] rtk_btusb: fw name is  rtl8822cu_fw
[  692.679225] rtk_btusb: This is not 8723a, use new patch style!
[  692.680312] rtk_btusb: rtk_get_eversion: gEVersion 255
[  692.683394] rtk_btusb: eversion->status = 0x0, eversion->version = 0x3
[  692.684532] rtk_btusb: load_firmware: New gEVersion 3
[  692.685635] rtk_btusb: rtk_get_fw_project_id: opcode 0, len 1, data 13
[  692.686739] rtk_btusb: lmp_version is 8822, project_id is 8822, match!
[  692.698717] rtk_btusb: fw_version = 0x59a25c4
[  692.700018] rtk_btusb: number_of_total_patch = 3
[  692.701266] rtk_btusb: chipID 4
[  692.702524] rtk_btusb: patch_length 0x7d08
[  692.703763] rtk_btusb: start_offset 0x00006380
[  692.705035] rtk_btusb: Svn version:    24075
[  692.706246] rtk_btusb: Coexistence: BTCOEX_20200529-1c1c
[  692.707499] rtk_btusb: buf_len = 0x7d21
[  692.709034] rtk_btusb: fw: exists, config file: exists
[  692.710301] rtk_btusb: load_firmware done
[  692.711667] rtk_btusb: download_data start
[  693.121714] rtk_btusb: download_data done
[  693.124905] rtk_btusb: HCI reset.
[  693.142502] rtk_btusb: read_ver_rsp->lmp_subver = 0x25c4
[  693.144100] rtk_btusb: read_ver_rsp->hci_rev = 0x59a
[  693.145624] rtk_btusb: patch_entry->lmp_sub = 0x8822
[  693.147149] rtk_btusb: Rtk patch end 0
[  693.148636] rtk_btusb: btusb_open set HCI_RUNNING
[  693.150149] rtk_btcoex: Open BTCOEX
[  693.151609] rtk_btusb: btusb_open end
[  693.158545] rtk_btcoex: BTCOEX hci_rev 0x059a
[  693.164533] rtk_btcoex: BTCOEX lmp_subver 0x25c4
[  693.208605] rtk_btusb: btusb_notify: hci0 evt 3
[  695.437425] rtk_btusb: btusb_flush add delay
[  695.450090] rtk_btusb: btusb_close
[  695.465659] rtk_btcoex: Close BTCOEX
[  695.466968] rtk_btcoex: -x

[root@rk3399:/]# lsmod
Module                  Size  Used by    Tainted: G
rtk_btusb              57344  0
8822ce               3010560  0

5、蓝牙调试?

调试工具

  • hciconfig:配置蓝牙设备,用于打印设备信息和配置设备
  • hcitool:配置蓝牙连接,执行扫描等命令

5.1、hciconfig?

[root@rk3399:/]# hciconfig -a
hci0:   Type: Primary  Bus: USB
        BD Address: 48:E7:DA:0A:F3:3C  ACL MTU: 1021:5  SCO MTU: 255:11
        DOWN
        RX bytes:633 acl:0 sco:0 events:35 errors:0
        TX bytes:391 acl:0 sco:0 commands:35 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

?加载驱动后,蓝牙默认关闭,可以使用hciconfig hci0 up启动

[root@rk3399:/]# hciconfig hci0 up
[ 1250.686993] rtk_btusb: btusb_open start
[ 1250.687874] rtk_btusb: btusb_open hdev->promisc ==0
[ 1250.688670] rtk_btusb: download_patch start
[ 1250.689440] rtk_btusb: chip type value: 0x73
[ 1250.690169] rtk_btusb: HCI reset.
[ 1250.705614] rtk_btusb: read_ver_rsp->lmp_subver = 0x25c4
[ 1250.706392] rtk_btusb: read_ver_rsp->hci_rev = 0x59a
[ 1250.707186] rtk_btusb: patch_entry->lmp_sub = 0x8822
[ 1250.707965] rtk_btusb: Firmware already exists
[ 1250.708712] rtk_btusb: Rtk patch end 1
[ 1250.709457] rtk_btusb: btusb_open set HCI_RUNNING
[ 1250.710292] rtk_btcoex: Open BTCOEX
[ 1250.711015] rtk_btusb: btusb_open end
[ 1250.715467] rtk_btcoex: BTCOEX hci_rev 0x059a
[ 1250.720139] rtk_btcoex: BTCOEX lmp_subver 0x25c4
[root@rk3399:/]# hciconfig -a
hci0:   Type: Primary  Bus: USB
        BD Address: 48:E7:DA:0A:F3:3C  ACL MTU: 1021:5  SCO MTU: 255:11
        UP RUNNING
        RX bytes:1820 acl:0 sco:0 events:76 errors:0
        TX bytes:800 acl:0 sco:0 commands:76 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
        Name: 'RTK_BT_5.0'
        Class: 0x000000
        Service Classes: Unspecified
        Device Class: Miscellaneous,
[11876.532603] rtk_btcoex: BT   HCI VeCrsioO:  (0xa)  Revision: 0x59a
        LMP Version: E (0xXa)  Subversion: 0x25c4
        Manufacturer : Realtek Semiconductor Corporation (93)

?如果手机端搜索不到设备,可以设置设备蓝牙模式(iscan或pscan)

[root@rk3399:/]# hciconfig hci0 iscan
[root@rk3399:/]# hciconfig
hci0:   Type: Primary  Bus: USB
        BD Address: 48:E7:DA:0A:F3:3C  ACL MTU: 1021:5  SCO MTU: 255:11
        UP RUNNING ISCAN
        RX bytes:22809 acl:14 sco:0 events:221 errors:0
        TX bytes:1590 acl:17 sco:0 commands:98 errors:0

5.2、hcitool

[root@rk3399:/]# hcitool scan
Scanning ...
[  189.381718] rtk_btcoex: hci (periodic)inq start
[  199.630798] rtk_btcoex: inquiry complete
        98:DA:60:0B:B9:AE       HC-06
        4C:4F:EE:19:18:BD       OnePlus 8 Pro
        C0:B6:F9:95:9B:D7       USER-20231011IA
[root@rk3399:/]# l2ping 4C:4F:EE:19:18:BD
[11977.134637] rtk_btusb: btusb_notify: hci0 evt 1
[11977.138679] rtk_btcoex: hci create connection, start paging
[11980.087826] rtk_btcoex: connected, handle 0002, status 0x00
[11980.093526] rtk_btcoex: Page success
Ping: 4C:4F:EE:19:18:BD from 48:E7:DA:0A:F3:3C (data size 44) ...
44 bytes from 4C:4F:EE:19:18:BD id 0 time 48.66ms
44 bytes from 4C:4F:EE:19:18:BD id 1 time 44.69ms
44 bytes from 4C:4F:EE:19:18:BD id 2 time 46.50ms
44 bytes from 4C:4F:EE:19:18:BD id 3 time 77.84ms
44 bytes from 4C:4F:EE:19:18:BD id 4 time 237.98ms
44 bytes from 4C:4F:EE:19:18:BD id 5 time 74.79ms
44 bytes from 4C:4F:EE:19:18:BD id 6 time 90.38ms
44 bytes from 4C:4F:EE:19:18:BD id 7 time 74.80ms
44 bytes from 4C:4F:EE:19:18:BD id 8 time 60.13ms
^C9 sent, 9 received, 0% loss

?连接有问题

[root@rk3399:/]# hcitool cc 4C:4F:EE:19:18:BD
[  319.489796] rtk_btcoex: hci create connection, start paging
[  319.489922] rtk_btusb: btusb_notify: hci0 evt 1
[  320.565861] rtk_btcoex: connected, handle 0007, status 0x00
[root@rk3399:/]# [  320.572738] rtk_btcoex: Page success
[  322.745642] rtk_btcoex: HCI Disconnect, handle 0007, reason 0x13
[  322.826840] rtk_btcoex: disconn cmpl evt: status 0x00, handle 0007, reason 0x16
[  322.833969] rtk_btcoex: process disconn complete event.
[  322.872103] rtk_btusb: btusb_notify: hci0 evt 2

在网上找到如下方法:rfcomm connect hci0 <bdaddr>

5.3、使用bluetoothd调试

启动bluetoothd服务后,就可以直接使用命令了:scan on, scan off, show, devices, connect等?

[root@rk3399:/]# /usr/libexec/bluetooth/bluetoothd -d -C -n &
[root@rk3399:/]# bluetoothctl

?show(显示本设备信息),devices(显示搜索到的设备)

?pair <bdaddr>? #?配对设备

connect <bdaddr>? # 连接设备

Failed to connect: org.bluez.Error.NotAvailable?

在网上找到如下方法:rfcomm connect hci0 <bdaddr>

文章来源:https://blog.csdn.net/ZOIpuus/article/details/135619228
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。