Realtek RTL8761B Cheap Bluetooth 5.0 USB Dongle Runs on Linux

I bought a mysterious Chinese Bluetooth dongle with "BT 5.0" on Amazon. It was about 800-1000 yen on Amazon, but it seems that you can get something similar on AliExpress for around 200 yen. Will it really work? This dongle uses Realtek's RTL8761B chip, which is compatible with Linux 5.8 and above. However, the major distros don't yet contain the firmware needed to run it, so you'll need to pull the firmware from somewhere and install it.

Change log

--2020/10/27 Corrected the article because it was paired with Google Home and AirPods

Kernel settings

From sudo make menuconfig, go to Networking support-> Bluetooth subsystem support-> Bluetooth device drivers

<M> HCI USB driver
[*]   Realtek protocol support

will do. The HCI USB driver needs to be built as a module. If you install it without building it as a module, the firmware may not be loaded.

.config


CONFIG_BT_HCIBTUSB=m
CONFIG_BT_RTL=m
CONFIG_BT_HCIBTUSB_RTL=y

Firmware installation

Firmware from a dongle driver called Mpow BH456A that uses the same RTL8761B Extract. The firmware included in the Linux version was buggy and some devices could not be paired, so I will use the Windows version except for some files.

$ wget https://mpow.s3-us-west-1.amazonaws.com/mpow_MPBH456AB_driver+for+Linux.tgz
$ tar xzf mpow_MPBH456AB_driver+for+Linux.tgz
$ sudo cp 20200610_LINUX_BT_DRIVER/rtkbt-firmware/lib/firmware/rtlbt/rtl8761b_config /lib/firmware/rtl_bt/rtl8761b_config.bin
$ wget https://mpow.s3-us-west-1.amazonaws.com/mpow_MPBH456AB_driver+for+Windows7_8.1_10.zip
$ unzip mpow_MPBH456AB_driver+for+Windows7_8.1_10.zip
$ sudo cp RTBlueR_Windows_1015.1016.1016.0528.2020_F027_L/BT_Driver/Win10X64/rtl8761b_mp_chip_bt40_fw_asic_rom_patch_new.dll /lib/firmware/rtl_bt/rtl8761b_fw.bin

Now when you plug in the dongle, the kernel should load the firmware and recognize it correctly.

[151940.809102] usb 2-1: new full-speed USB device number 17 using xhci_hcd
[151940.936028] usb 2-1: New USB device found, idVendor=0bda, idProduct=8771, bcdDevice= 2.00
[151940.936033] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[151940.936035] usb 2-1: Product: Bluetooth Radio
[151940.936037] usb 2-1: Manufacturer: Realtek
[151940.936038] usb 2-1: SerialNumber: XXXXXXXXXXXX
[151940.940621] Bluetooth: hci0: RTL: examining hci_ver=0a hci_rev=000b lmp_ver=0a lmp_subver=8761
[151940.941524] Bluetooth: hci0: RTL: rom_version status=0 version=1
[151940.941527] Bluetooth: hci0: RTL: loading rtl_bt/rtl8761b_fw.bin
[151940.941574] Bluetooth: hci0: RTL: loading rtl_bt/rtl8761b_config.bin
[151940.941598] Bluetooth: hci0: RTL: cfg_sz 25, total sz 20237
[151941.051664] Bluetooth: hci0: RTL: fw version 0xd89964cd

trouble shooting

However, in my environment (Linux 5.9.1) the kernel recognizes the dongle, but bluetoothctl does not recognize the dongle at all. The GNOME settings screen also shows that the Bluetooth dongle is not connected. Looking at the communication contents with btmon, it seems that the communication itself is done without problems, but such an error is appearing.

< HCI Command: LE Set Resolvable P.. (0x08|0x002e) plen 2  #235 [hci0] 8.037958
        Timeout: 900 seconds
> HCI Event: Command Complete (0x0e) plen 4                #236 [hci0] 8.038849
      LE Set Resolvable Private Address Timeout (0x08|0x002e) ncmd 2
        Status: Unsupported Remote Feature / Unsupported LMP Feature (0x1a)
= Close Index: XX:XX:XX:XX:XX:XX                                [hci0] 8.038893

It seems that he is angry by issuing an unsupported command called LE Set Resolvable Private Address Timeout. The version of Bluetooth confirmed at this time was 5.1.

< HCI Command: Read Local Version In.. (0x04|0x0001) plen 0  #1 [hci0] 7.862404
> HCI Event: Command Complete (0x0e) plen 12                 #2 [hci0] 7.863819
      Read Local Version Information (0x04|0x0001) ncmd 2
        Status: Success (0x00)
        HCI version: Bluetooth 5.1 (0x0a) - Revision 11 (0x000b)
        LMP version: Bluetooth 5.1 (0x0a) - Subversion 34657 (0x8761)
        Manufacturer: Realtek Semiconductor Corporation (93)

Looking at the kernel commit log, I find that this commit is suspicious.

Bluetooth: Enable RPA Timeout Enable RPA timeout during bluetooth initialization. The RPA timeout value is used from hdev, which initialized from debug_fs

Since the code was added in Linux 5.9, this dongle may have worked fine in earlier kernels as well. It's a code that doesn't seem to affect anything else, so I'll delete it entirely.

rtl8761b.patch


diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index c8e67042a3b1..74740a103c6f 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -1649,8 +1649,6 @@ struct hci_rp_le_read_resolv_list_size {
 
 #define HCI_OP_LE_SET_ADDR_RESOLV_ENABLE 0x202d
 
-#define HCI_OP_LE_SET_RPA_TIMEOUT	0x202e
-
 #define HCI_OP_LE_READ_MAX_DATA_LEN	0x202f
 struct hci_rp_le_read_max_data_len {
 	__u8	status;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 502552d6e9af..e0872ba36aa1 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -763,14 +763,6 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
 			hci_req_add(req, HCI_OP_LE_CLEAR_RESOLV_LIST, 0, NULL);
 		}
 
-		if (hdev->commands[35] & 0x40) {
-			__le16 rpa_timeout = cpu_to_le16(hdev->rpa_timeout);
-
-			/* Set RPA timeout */
-			hci_req_add(req, HCI_OP_LE_SET_RPA_TIMEOUT, 2,
-				    &rpa_timeout);
-		}
-
 		if (hdev->le_features[0] & HCI_LE_DATA_LEN_EXT) {
 			/* Read LE Maximum Data Length */
 			hci_req_add(req, HCI_OP_LE_READ_MAX_DATA_LEN, 0, NULL);

When I rebuilt the kernel and rebooted, the dongle, which had never glowed before, glowed blue and was correctly recognized as a controller by bluetoothctl.

When the initialization was completed, the version was down to Bluetooth 5.0 for some reason.

< HCI Command: Read Loc.. (0x04|0x0001) plen 0  #98 [hci0] 3.818177
> HCI Event: Command Complete (0x0e) plen 12    #99 [hci0] 3.818995
      Read Local Version Information (0x04|0x0001) ncmd 2
        Status: Success (0x00)
        HCI version: Bluetooth 5.0 (0x09) - Revision 55449 (0xd899)
        LMP version: Bluetooth 5.0 (0x09) - Subversion 25805 (0x64cd)
        Manufacturer: Realtek Semiconductor Corporation (93)

Apparently, if you apply the firmware, the Bluetooth version will be downgraded from 5.1 to 5.0. (Re: [PATCH v2 1/1] Bluetooth: btrtl: Add support for RTL8761B --Marcel Holtmann)

Impressions I tried using

I tried it with my Bluetooth device such as mouse, keyboard, AirPods, iPhone, Google Home, and all of them were paired successfully. When I play music on AirPods, the sound is interrupted at a reasonable frequency. Also, if you scan the surrounding Bluetooth device or check the battery level of the device while playing music, you will not hear the music at all. Even so, the connection itself was not interrupted, and the mouse and keyboard connected at the same time could be used stably. The impression is that the stability is higher than Qualcomm (CSR) chips and lower than Broadcom chips. However, when the sound is interrupted, it feels like the entire OS freezes, so it may not be a chipset problem but a driver problem.

Recommended Posts

Realtek RTL8761B Cheap Bluetooth 5.0 USB Dongle Runs on Linux
Make Live USB on Alpine Linux