蓝牙适配器配置问题(ID 0a12:0001)

Gry*_*ryu 5 bluetooth 19.10

我的蓝牙适配器在 Ubuntu 中不起作用。

$ lsusb | grep tooth
Bus 002 Device 003: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Run Code Online (Sandbox Code Playgroud)
$ hciconfig
hci0:   Type: Primary  Bus: USB
    BD Address: 33:03:30:09:74:B4  ACL MTU: 360:4  SCO MTU: 0:0
    DOWN 
    RX bytes:1106 acl:0 sco:0 events:56 errors:0
    TX bytes:736 acl:0 sco:0 commands:60 errors:0
Run Code Online (Sandbox Code Playgroud)
$ sudo hciconfig hci0 up
Can't init device hci0: Operation not supported (95)
Run Code Online (Sandbox Code Playgroud)
$ bluetoothctl
Agent registered
[bluetooth]# power on
No default controller available
Run Code Online (Sandbox Code Playgroud)
$ hcitool dev
Devices:
$
Run Code Online (Sandbox Code Playgroud)

$ rfkill

ID TYPE      DEVICE      SOFT      HARD
 0 bluetooth hci0   unblocked unblocked
 1 wlan      phy0   unblocked unblocked
Run Code Online (Sandbox Code Playgroud)

尝试了最后两个操作:

Bluetake
在 Ubuntu v10.04 ~ 11.04 中开箱即用,但在 11.10 中停止可靠工作,频繁的内核恐慌和其他一般不好的东西,[错误:901770]

$ lsusb <br>Bus 007 Device 003: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

$ hciconfig -a hci0 <br>Manufacturer: Cambridge Silicon Radio (10)

可能需要与 Belkin 相同的修复:添加blacklist hci_usb/etc/modprobe.d/blacklist.conf,然后添加hci_usb reset=1/etc/modules

也试过

  • 安装内核 5.5.2 内核。但是它登录失败,所以我清除了它并返回到我的5.3.0-29-generic内核。
  • 下一个,但失败了:
    $ make -C /lib/modules/$(uname -r)/build M=$PWD modules
    make: Entering directory '/usr/src/linux-headers-5.3.0-29-generic'
      CC [M]  /home/spacer/kernel/bluetooth/hci_vhci.o
    /home/spacer/kernel/bluetooth/hci_vhci.c: In function ‘vhci_create_device’:
    /home/spacer/kernel/bluetooth/hci_vhci.c:134:2: warning: dereferencing ‘void *’ pointer
      134 |  *skb_put(skb, 1) = 0xff;
          |  ^~~~~~~~~~~~~~~~
    /home/spacer/kernel/bluetooth/hci_vhci.c:134:19: error: invalid use of void expression
      134 |  *skb_put(skb, 1) = 0xff;
          |                   ^
    /home/spacer/kernel/bluetooth/hci_vhci.c:135:2: warning: dereferencing ‘void *’ pointer
      135 |  *skb_put(skb, 1) = dev_type;
          |  ^~~~~~~~~~~~~~~~
    /home/spacer/kernel/bluetooth/hci_vhci.c:135:19: error: invalid use of void expression
      135 |  *skb_put(skb, 1) = dev_type;
          |                   ^
    /home/spacer/kernel/bluetooth/hci_vhci.c: In function ‘vhci_get_user’:
    /home/spacer/kernel/bluetooth/hci_vhci.c:203:19: error: ‘HCI_BREDR’ undeclared (first use in this function)
      203 |   if (dev_type != HCI_BREDR && dev_type != HCI_AMP)
          |                   ^~~~~~~~~
    /home/spacer/kernel/bluetooth/hci_vhci.c:203:19: note: each undeclared identifier is reported only once for each function it appears in
    /home/spacer/kernel/bluetooth/hci_vhci.c: In function ‘vhci_open_timeout’:
    /home/spacer/kernel/bluetooth/hci_vhci.c:307:43: error: ‘HCI_BREDR’ undeclared (first use in this function)
      307 |  vhci_create_device(data, amp ? HCI_AMP : HCI_BREDR);
          |                                           ^~~~~~~~~
    /home/spacer/kernel/bluetooth/hci_vhci.c: At top level:
    /home/spacer/kernel/bluetooth/hci_vhci.c:352:3: error: ‘const struct file_operations’ has no member named ‘aio_write’
      352 |  .aio_write = vhci_write,
          |   ^~~~~~~~~
    /home/spacer/kernel/bluetooth/hci_vhci.c:352:15: error: positional initialization of field in ‘struct’ declared with ‘designated_init’ attribute [-Werror=designated-init]
      352 |  .aio_write = vhci_write,
          |               ^~~~~~~~~~
    /home/spacer/kernel/bluetooth/hci_vhci.c:352:15: note: (near initialization for ‘vhci_fops’)
    /home/spacer/kernel/bluetooth/hci_vhci.c:352:15: error: initialization of ‘ssize_t (*)(struct file *, const char *, size_t,  loff_t *)’ {aka ‘long int (*)(struct file *, const char *, long unsigned int,  long long int *)’} from incompatible pointer type ‘ssize_t (*)(struct kiocb *, const struct iovec *, long unsigned int,  loff_t)’ {aka ‘long int (*)(struct kiocb *, const struct iovec *, long unsigned int,  long long int)’} [-Werror=incompatible-pointer-types]
    /home/spacer/kernel/bluetooth/hci_vhci.c:352:15: note: (near initialization for ‘vhci_fops.write’)
    cc1: some warnings being treated as errors
    make[1]: *** [scripts/Makefile.build:290: /home/spacer/kernel/bluetooth/hci_vhci.o] Error 1
    make: *** [Makefile:1655: _module_/home/spacer/kernel/bluetooth] Error 2
    make: Leaving directory '/usr/src/linux-headers-5.3.0-29-generic'
    
    Run Code Online (Sandbox Code Playgroud)

Sve*_*ven 7

此设备有多个版本,具有相同的 USB ID。有些人认为这些是假的,但我怀疑这些只是芯片的较新型号。

要使芯片正常工作,需要几个怪癖,并且需要修补负责使这些怪癖能够测试这些较新型号的内核代码:

--- drivers/bluetooth/btusb.c.old   2020-03-31 19:14:11.765239911 +0100
+++ drivers/bluetooth/btusb.c   2020-03-31 19:22:17.035003199 +0100
@@ -1643,4 +1643,6 @@
    /* Detect controllers which aren't real CSR ones. */
    if (le16_to_cpu(rp->manufacturer) != 10 ||
+       le16_to_cpu(rp->lmp_subver) == 0x0811 ||
+       le16_to_cpu(rp->lmp_subver) == 0x0812 ||
        le16_to_cpu(rp->lmp_subver) == 0x0c5c) {
        /* Clear the reset quirk since this is not an actual
@@ -3873,5 +3875,5 @@

        /* Fake CSR devices with broken commands */
-       if (bcdDevice <= 0x100 || bcdDevice == 0x134)
+       if (bcdDevice <= 0x100 || bcdDevice == 0x134 || bcdDevice == 0x8891)
            hdev->setup = btusb_setup_csr;
Run Code Online (Sandbox Code Playgroud)

我不保证这会解决所有较新型号的问题,它可能需要额外的测试以包含更多 LMP 子版本和 bcdDevice 编号。但是,对于一些使用较新的蓝牙 4.0 型号的用户和使用蓝牙 5.0 型号的我自己,上述方法确实适用。

它会启动设备,如下所示:

# hciconfig
hci0:   Type: Primary  Bus: USB
    BD Address: 00:1A:7D:DA:71:11  ACL MTU: 679:9  SCO MTU: 48:16
    UP RUNNING 
    RX bytes:56724 acl:29 sco:0 events:7890 errors:0
    TX bytes:4782028 acl:7788 sco:0 commands:84 errors:0
Run Code Online (Sandbox Code Playgroud)

这是使用内核 5.5.13 和来自速卖通的廉价蓝牙 5.0 加密狗进行的测试,现在它可以让我连接到蓝牙 5.0 耳机。

顺便说一下,加密狗在 Windows 10 下工作得很好。

附加:关闭 USB 自动挂起

USB 端口的自动暂停会干扰蓝牙 USB 加密狗。虽然自动挂起有助于节省电量,并且设备应自行快速唤醒,但可能会失败并因此降低蓝牙连接性。默认情况下,内核会在 2 秒后挂起 USB 端口。这可以针对所有 USB 端口或仅针对个别 USB 端口禁用,并且蓝牙 USB 驱动程序有一个参数,专门用于控制 USB 连接的蓝牙加密狗。例如,查看当前状态:

# lsusb
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 003: ID 062a:3633 MosArt Semiconductor Corp. Full-Speed Mouse
Bus 004 Device 002: ID 1b1c:1b39 Corsair Corsair Gaming K65 RGB RAPIDFIRE Keyboard 
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 009 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 008 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

# grep . /sys/bus/usb/devices/[0-9]*/power/control
/sys/bus/usb/devices/4-1/power/control:on
/sys/bus/usb/devices/4-2/power/control:on
/sys/bus/usb/devices/5-5/power/control:auto
Run Code Online (Sandbox Code Playgroud)

此处鼠标和键盘始终处于开机状态,但 CSR 蓝牙 USB 加密狗设置为自动挂起。如果启用了自动挂起并且它引起了问题,那么可以通过暂时禁用它来测试它:

# echo on > /sys/bus/usb/devices/5-5/power/control
# cat /sys/bus/usb/devices/5-5/power/control
on
Run Code Online (Sandbox Code Playgroud)

当这有帮助时,应该永久禁用它,有几种方法可以做到这一点:

  • 当您已经重新编译内核时,最好通过将配置参数CONFIG_BT_HCIBTUSB_AUTOSUSPEND设置为N或通过在内核配置文件中将其注释掉来使用蓝牙 USB 内核模块禁用它。这将导致蓝牙 USB 驱动程序在默认情况下为它找到匹配设备的每个端口禁用自动挂起,并使所有其他 USB 设备保持原样。

  • 无需重新编译内核以及将蓝牙 USB 模块编译到内核的位置,就需要使用引导参数来执行此操作。对于 GRUB,编辑/etc/default/grub并将内核命令行附加到btusb.enable_autosuspend=n。然后通过运行update-grub并重新启动来更新 grub 配置。

文件:/etc/default/grub

...
GRUB_CMDLINE_LINUX_DEFAULT="... btusb.enable_autosuspend=n"
...
Run Code Online (Sandbox Code Playgroud)
  • 在不重新编译内核和可加载蓝牙 USB 模块的情况下,应该在/etc/modprobe.d/ 中创建一个文件来传递参数。然后重新启动,或者拔下加密狗并使用rmmod btusb删除内核模块,然后在再次插入加密狗之前使用service systemd-modules-load restart 重新启动模块服务。

文件:/etc/modprobe.d/bluetooth-usb.conf

options btusb enable_autosuspend=n
Run Code Online (Sandbox Code Playgroud)

附加:启用快速连接设置

改善蓝牙连接的另一种方法是启用bluetoothd守护程序的FastConnectable设置。该设置可以在/etc/bluetooth/main.conf 中找到。

文件:/etc/bluetooth/main.conf

...
# Permanently enables the Fast Connectable setting for adapters that
# support it. When enabled other devices can connect faster to us,
# however the tradeoff is increased power consumptions. This feature
# will fully work only on kernel version 4.1 and newer. Defaults to
# 'false'.
FastConnectable = true
...
Run Code Online (Sandbox Code Playgroud)

  • 当你购买 USB 加密狗并且第一个谷歌结果以“需要修补内核代码”开头时,你一定会喜欢它 (2认同)

小智 5

我有这个加密狗 - 它已经有好几年了,所以我无法评论它是否是假货,或者带有此 USB ID 的现代加密狗是否可能是假货。

Bus 002 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Run Code Online (Sandbox Code Playgroud)

我将它与一台非常旧的 Acer TravelMate 2420 笔记本电脑一起使用(出于必要)使用 Ubuntu 18.04 LTS 的 i386 版本。(截至撰写本文时,当前内核是 4.15.0-106-generic。(无需同情。这只是我放在卧室里偶尔使用的一台旧备用计算机。)

蓝牙对我有用,但不太可靠。我的蓝牙鼠标(Microsoft 蓝牙笔记本鼠标 5000)经常断开连接。

几周前我通过以下更改彻底解决了这些问题/etc/default/tlp

# Exclude listed devices...
USB_BLACKLIST="0a12:0001"
# Bluetooth devices are excluded...
USB_BLACKLIST_BTUSB=1
Run Code Online (Sandbox Code Playgroud)

(找到适当的行并添加第一行并相应地编辑第二行。)

我可能不需要特定的基于 ID 的USB_BLACKLIST命令(我没有测试过这个),但为了安全起见我认为我会保留它。第二个 (USB_BLACKLIST_BTUSB) 在我的系统上默认为 0,我怀疑这是要更改的关键配置。

tlp如果尚未安装该软件包,您可能需要专门安装该软件包。重新配置后不要忘记重新启动它。

我希望这有帮助。