蓝牙扫描未在 Ubuntu 21.10 上检测到任何设备

蓝牙扫描未在 Ubuntu 21.10 上检测到任何设备

我刚买了一个 Tp-link 蓝牙 5.0 USB 适配器 (UB500),我检查了一下,它的芯片是 Realtek RTL8761B。它在 Windows 10 上运行良好,但我在 Ubuntu 上遇到了问题。我正在运行 Ubuntu 21.10,我刚刚升级到最新的稳定内核版本:5.14.14。升级之前我尝试了这个解决方案,但没有成功:https://linuxreviews.org/Realtek_RTL8761B

我几乎尝试了在线上找到的所有方法,但大多数解决方案都不适用,因为没有明显的问题:适配器似乎已正确安装并正常工作,但扫描未检测到任何蓝牙设备。我试过两个耳机(我知道它们工作正常)和我的手机,但都没有成功。当我在手机上执行扫描时,即使我已将其设置为可见,计算机也不会显示出来。

我不明白问题是什么。

    dmesg |grep -i bluetooth
    [    3.596913] Bluetooth: Core ver 2.22
    [    3.596935] NET: Registered PF_BLUETOOTH protocol family
    [    3.596936] Bluetooth: HCI device and connection manager initialized
    [    3.596939] Bluetooth: HCI socket layer initialized
    [    3.596941] Bluetooth: L2CAP socket layer initialized
    [    3.596945] Bluetooth: SCO socket layer initialized
    [   93.519895] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
    [   93.519899] Bluetooth: BNEP filters: protocol multicast
    [   93.519903] Bluetooth: BNEP socket layer initialized
    [  144.060814] Bluetooth: RFCOMM TTY layer initialized
    [  144.060821] Bluetooth: RFCOMM socket layer initialized
    [  144.060825] Bluetooth: RFCOMM ver 1.11
    hciconfig -a
    hci0:    Type: Primary  Bus: USB
        BD Address: E8:48:B8:C8:20:00  ACL MTU: 1021:6  SCO MTU: 255:12
        UP RUNNING 
        RX bytes:4264 acl:0 sco:0 events:560 errors:0
        TX bytes:9000 acl:0 sco:0 commands:490 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: 'gaia-ubuntu-desktop'
        Class: 0x7c0104
        Service Classes: Rendering, Capturing, Object Transfer, Audio, Telephony
        Device Class: Computer, Desktop workstation
        HCI Version: 5.1 (0xa)  Revision: 0xb
        LMP Version: 5.1 (0xa)  Subversion: 0x8761
        Manufacturer: Realtek Semiconductor Corporation (93)
    rfkill list
    0: hci0: Bluetooth
        Soft blocked: no
        Hard blocked: no
    lsusb
    Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 003 Device 004: ID 046d:0826 Logitech, Inc. HD Webcam C525
    Bus 003 Device 003: ID 04b8:013d Seiko Epson Corp. Epson Perfection V39
    Bus 003 Device 002: ID 0c76:2068 JMTek, LLC. USB MIC-SG01
    Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 001 Device 003: ID 2357:0604 TP-Link TP%Link UB500 Adapter
    Bus 001 Device 002: ID 062a:3633 MosArt Semiconductor Corp. Full-Speed Mouse
    Bus 001 Device 004: ID 145f:0176 Trust Isla Keyboard
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
usb-devices | awk '/0604/' RS=
T:  Bus=01 Lev=01 Prnt=01 Port=07 Cnt=03 Dev#=  3 Spd=12  MxCh= 0
D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=2357 ProdID=0604 Rev=02.00
S:  Manufacturer= 
S:  Product=TP%Link UB500 Adapter
S:  SerialNumber=E848B8C82000
C:  #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA
I:  If#=0x0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
I:  If#=0x1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb

答案1

我在使用 Tp-Link UB500 适配器时也遇到过同样的问题,我可以按照 Pilot6 的建议解决这个问题。请按照以下步骤操作。感谢 Pilot6。

步骤1:下载并提取Linux内核源文件。

wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.11.tar.xz
tar xpvf linux-5.11.tar.xz

确保使用适合您系统的内核版本(可以使用uname -r

步骤2:编辑btusb.c

cd linux-5.11/drivers/bluetooth
gedit btusb.c

添加以下内容

/* Tp-Link UB500 */
{ USB_DEVICE(0x2357, 0x0604), .driver_info = BTUSB_REALTEK },

在“static const struct usb_device_id blacklist_table[]”部分下。在 /* Silicon Wave based devices */ 之后。

步骤3:编辑hci_ldisc.c

(对于某些版本的内核可能不需要 - 如果你不确定是否有必要,那么在第 4 步尝试运行 make 时就会变得很明显,因为编译器在分配时会抱怨指针类型不兼容hci_uart_tty_read

代替

static ssize_t hci_uart_tty_read(struct tty_struct *tty, struct file *file,
                 unsigned char __user *buf, size_t nr)

static ssize_t hci_uart_tty_read(struct tty_struct *tty, struct file *file,
                 unsigned char __user *buf, size_t nr,
                 void **cookie, unsigned long offset)

步骤4:编译模块

make -C /lib/modules/$(uname -r)/build M=$(pwd) clean
cp /usr/src/linux-headers-$(uname -r)/.config ./
cp /usr/src/linux-headers-$(uname -r)/Module.symvers Module.symvers
make -C /lib/modules/$(uname -r)/build M=$(pwd) modules

如果您有安全启动,则还需要对模块进行签名,请搜索“如何为安全启动签名”。

步骤 5:更换旧模块

sudo cp btusb.ko /lib/modules/$(uname -r)/kernel/drivers/bluetooth

步骤 6:加载新的 btusb

sudo modprobe -r btusb
sudo modprobe -v btusb

它对我有用!

答案2

我按照@gauthsree 回答中的步骤操作,系统停止检测适配器。

然后(经过大量的搜索和阅读)我运行lsusb; dmesg | egrep -i 'blue|firm'并得到了这个:

RTL: firmware file rtl_bt/rtl8761b_fw.bin not found

因此,我下载了该文件并将其放置在:/lib/firmware/rtl_bt/

然后,重新启动系统,终于可以正常工作了!

我遵循了本教程:蓝牙 5.0 芯片组 Realtek RTL8761B下载并复制固件。

我的系统:

  • 操作系统:Ubuntu 20.04.1
  • 内核:5.11.0-46-generic

希望这有帮助!

答案3

如果设备是,则需要RTL8761B修补内核代码,添加以下内容:btusb.c

 /* Tp-Link UB500 */
{ USB_DEVICE(0x2357, 0x0604), .driver_info = BTUSB_REALTEK },

问题是还没有人把这个设备添加到 Linux 内核。这个芯片似乎受支持,但是 Tp-Link id 不存在。

我建议向 Launchpad 报告此问题。使用 Ubuntu 内核启动并在终端中运行

ubuntu-bug linux

这将创建一个错误报告。

更新:对于具有 5.15 内核的 Ubuntu 20.04 和 Ubuntu 22.04+,补丁已添加到内核源中。设备应该无需额外努力即可工作。

答案4

这是一个执行 Aeolun 所有步骤的脚本。

还像 Laion 描述的那样下载并复制了驱动程序。

(我刚刚学习 bash 脚本,我尝试了这个并且愿意分享。)

#!/bin/bash

# Initialization

FIX_UB_500_BT_Stick () {
echo -e "This Script is intended to fix the not working BT Stick UB 500 by TP-Link"
echo -e ""
echo -e "As descrbed in https://askubuntu.com/questions/1370663/bluetooth-scan-doesnt-detect-any-device-on-ubuntu-21-10"
echo -e ""
echo -e "This scripts guides you through all necessary steps. However, please take care. This can break your system, or at least  break your bluetooth."
echo -e ""
echo -e "\033[33mStep 1: Download and extract Linux kernel source file."
echo -e "\033[0m"
echo -e ""
echo -e "Your Kernel-Version: "
version=$(uname -r)
echo $version
echo -e "If not 5.13, change script and restart! (Just search and replace 5.13 with your Version, as long as it is a 5.x)"
read -n 1 -p "Do you want to continue? [y/n]" start
  if [ "$start" = "y" ] ; then
    cd
    mkdir FIX_UB_500_BT_Stick
    cd FIX_UB_500_BT_Stick
    wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.13.tar.xz
    tar xpvf linux-5.13.tar.xz
    echo -e "\033[33mDownload location and files:"
    echo -e "\033[0m"
    pwd
    ls
    echo -e "\033[33mLocation of files to be changed:"
    echo -e "\033[0m"
    cd linux-5.13/drivers/bluetooth
    pwd
    echo -e "\033[33mStep 2: Edit btusb.c"
    echo -e "\033[31m"
    echo "Add:"
    echo -e "\033[0m"
    echo "/* Tp-Link UB500 */"
    echo "{ USB_DEVICE(0x2357, 0x0604), .driver_info = BTUSB_REALTEK },"
    echo -e "\033[33m"
    echo "Under the section"
    echo -e "\033[0m"
    echo "static const struct usb_device_id blacklist_table[]"
    echo -e "\033[33m"
    echo "After"
    echo -e "\033[0m"
    echo "/* Silicon Wave based devices */"
    echo -e "\033[33m"
    echo "in btusb.c"
    echo ""
    echo "It should look something like this:"
    echo -e "\033[0m"
    echo "/* Silicon Wave based devices */"
    echo "{ USB_DEVICE(0x0c10, 0x0000), .driver_info = BTUSB_SWAVE },"
    echo "/* Tp-Link UB500 */"
    echo "{ USB_DEVICE(0x2357, 0x0604), .driver_info = BTUSB_REALTEK }, "
    echo "{ }/* Terminating entry */"
    echo ""
    echo -e "\033[31m Safe and close KWrite."
    sleep 5
    kwrite btusb.c
    read -n 1 -p "Did you change the file and want to continue? [y/n]" filechange1
    if [ "$filechange1" = "y" ]; then
      echo -e "\033[33m"
      echo "Ok, continuing."
      echo -e "\033[0m"
    elif [ "$filechange1" = "n" ];then
      sudo rm -r /home/max/FIX_UB_500_BT_Stick
      exit
    else
      echo -e "\033[31mDid you change the file and want to continue? [y/n]; Press ctrl+c to abort."
      echo -e "\033[0m"
      read -n 1
    fi
    echo -e "\033[33mStep 3: Edit hci_ldisc.c"
    echo -e "\033[0m"
    echo -e ""
    File="hci_ldisc.c"
    if grep -q "void **cookie, unsigned long offset)" "$File"; then
      echo -e "\033[33mStep not necessary. File already correct."
      echo -e "\033[0m"
    else
      echo -e "\033[33mChange:"
      echo -e "\033[0m"
      echo "static ssize_t hci_uart_tty_read(struct tty_struct *tty, struct file *file,"
      echo "                 unsigned char __user *buf, size_t nr)"
      echo ""
      echo -e "\033[33minto"
      echo -e "\033[0m"
      echo "static ssize_t hci_uart_tty_read(struct tty_struct *tty, struct file *file,"
      echo "                 unsigned char __user *buf, size_t nr, "
      echo "                 void **cookie, unsigned long offset) "
      echo -e "\033[33m"
      echo "in hci_ldisc.c"
      echo ""
      echo "Safe and Close KWrite. (This step might not be necessary for some versions)"
      sleep 5
      kwrite hci_ldisc.c
      read -n 1 -p "Did you change the file and want to continue? [y/n]" filechange2
      if [ "$filechange2" = "y" ]; then
        echo -e "\033[33m"
        echo "Ok, continuing."
        echo -e "\033[0m"
      elif [ "$filechange2" = "n" ];then
        sudo rm -r /home/max/FIX_UB_500_BT_Stick
        exit
      else
      echo -e "\033[31mDid you change the file and want to continue? [y/n];"
        read -n 1
      fi
    fi
    echo -e "\033[33mStep 4: Compile modules."
    echo -e "\033[0m"
    make -C /lib/modules/$(uname -r)/build M=$(pwd) clean
    echo -e "\033[33mMake 1 done."
    echo -e "\033[0m"
    cp /usr/src/linux-headers-$(uname -r)/.config ./
    cp /usr/src/linux-headers-$(uname -r)/Module.symvers Module.symvers
    make -C /lib/modules/$(uname -r)/build M=$(pwd) modules
    echo -e "\033[33mMake 2 done."
    echo -e "\033[33mStep 5: Replace the old module."
      echo -e "\033[0m"
    sudo cp btusb.ko /lib/modules/$(uname -r)/kernel/drivers/bluetooth
    echo -e "\033[33mCopied to current Kernel"
    echo -e ""
    echo -e "\033[33mStep 6: Load new btusb."
    echo -e "\033[0m"
    sudo modprobe -r btusb
    sudo modprobe -v btusb
    echo -e "\033[33mModprobe done"
    echo -e "\033[0m"


    if [[ ! -f "/lib/firmware/rtl_bt/rtl8761b_fw.bin" ]]
    then
        echo -e "\033[33mStep 7: Download Firmware for UB500 from Realteks GIT."
        read -n 1 -p "The FW for the UB500 BT-Dongle is not present in /lib/firmware/rtl_bt/. /n Do you wish to download the file from Realteks Git and copy it to your system? [y/n]" FW_Install
          if [ "$FW_Install" = "y" ]; then
            echo -e "\033[33m"
            echo "Ok, continuing."
            echo -e "\033[0m"
            cd /home/max/FIX_UB_500_BT_Stick
            mkdir FW
            cd FW
            wget https://github.com/Realtek-OpenSource/android_hardware_realtek/raw/rtk1395/bt/rtkbt/Firmware/BT/rtl8761b_fw
            sudo cp /home/max/FIX_UB_500_BT_Stick/FW/rtl8761b_fw /lib/firmware/rtl_bt/rtl8761b_fw.bin
            if [[ -f "/lib/firmware/rtl_bt/rtl8761b_fw.bin" ]]; then
              echo -e "\033[33mFW was successfully copied. Reboot and try your bluetooth stick. It should work now."
            else
              echo -e "\033[33mSomething went wrong.You will have to download the FW yourself and place it in the folder /lib/firmware/rtl_bt/ with the name rtl8761b_fw.bin /n You'll find the file in this Repo: https://github.com/Realtek-OpenSource/android_hardware_realtek/raw/rtk1395/bt/rtkbt/Firmware/BT/rtl8761b_config /n If you placed the file there, reboot and your UB500 should work now."
            fi
          elif [ "$fFW_Install" = "n" ];then
            sudo rm -r /home/max/FIX_UB_500_BT_Stick
            echo -e "\033[33mFW was not downloaded. You will have to download the FW yourself and place it in the folder /lib/firmware/rtl_bt/ with the name rtl8761b_fw.bin /n You'll find the file in this Repo: https://github.com/Realtek-OpenSource/android_hardware_realtek/raw/rtk1395/bt/rtkbt/Firmware/BT/rtl8761b_config /n If you placed the file there, reboot and your UB500 should work now."
            echo -e "\033[0m"
            exit
          else
          echo -e "\033[31mDownload the FW? [y/n];"
            read -n 1
          fi
    else
      echo -e "\033[33mIt looks like, /lib/firmware/rtl_bt/rtl8761b_fw.bin already exists. No further steps needed. Reboot and try your UB500 BT-Stick."
    fi
    sudo rm -r /home/max/FIX_UB_500_BT_Stick
    echo -e "\033[33mDeleted downloaded files and dircetory /home/max/FIX_UB_500_BT_Stick"
    echo -e "\033[0m"
  elif [ "$start" = "n" ];then
    sudo rm -r /home/max/FIX_UB_500_BT_Stick
    exit
  else
    echo -e "\033[33mYou have entered an invallid selection!"
    echo -e "\033[33mPlease try again!"
    echo -e ""
    echo -e "\033[31mPress any key to continue..."
    read -n 1

  fi
  }

FIX_UB_500_BT_Stick

遗憾的是,在步骤 3 中,hci_ldisc.c 中的检查不起作用。因此您必须手动检查。

它使用 kwrite 作为文本编辑器。

不要以 sudo 身份运行脚本。等待它要求您输入 sudo。

如果你和我一样对这一切感到陌生:

为了实现此功能,请创建一个文本文件,但使用扩展名 .sh 而不是 .txt

复制其中的所有代码并保存。

在您的目录中打开一个终端。

chmod a + x YOURFILE.sh

bash你的文件.sh

严格遵循指示。

我对我的答案进行了大量编辑,以使其更有帮助。

相关内容