Rtl8761b bluetooth driver fix

I have a bluetooth usb dongle,type is rtl8761b. CoreELEC kernel 4.9.113 identified it as rtl8761a and not work. So I modified btrtl.c driver, replaced rtl8761a to rtl8761b. It works fine . The below is my patch. It just replace rtl8761a to rtl8761b,so It’s not fit for rtl8761a users.Maybe someone need it .

diff --git a/drivers/bluetooth//btrtl.c b/drivers/bluetooth/btrtl.c
index fc9b257..25d0926 100644
--- a/drivers/bluetooth/btrtl.c
+++ b/drivers/bluetooth/btrtl.c
@@ -32,7 +32,7 @@
 #define RTL_ROM_LMP_8723A      0x1200
 #define RTL_ROM_LMP_8723B      0x8723
 #define RTL_ROM_LMP_8821A      0x8821
-#define RTL_ROM_LMP_8761A      0x8761
+#define RTL_ROM_LMP_8761B      0x8761
 #define RTL_ROM_LMP_8822B      0x8822
 
 static int rtl_read_rom_version(struct hci_dev *hdev, u8 *version)
@@ -86,7 +86,7 @@ static int rtl8723b_parse_firmware(struct hci_dev *hdev, u16 lmp_subver,
                { RTL_ROM_LMP_8723A, 0 },
                { RTL_ROM_LMP_8723B, 1 },
                { RTL_ROM_LMP_8821A, 2 },
-               { RTL_ROM_LMP_8761A, 3 },
+               { RTL_ROM_LMP_8761B, 14 },
                { RTL_ROM_LMP_8822B, 8 },
        };
 
@@ -339,8 +339,8 @@ static int btrtl_setup_rtl8723b(struct hci_dev *hdev, u16 lmp_subver,
        case RTL_ROM_LMP_8821A:
                cfg_name = "rtl_bt/rtl8821a_config.bin";
                break;
-       case RTL_ROM_LMP_8761A:
-               cfg_name = "rtl_bt/rtl8761a_config.bin";
+       case RTL_ROM_LMP_8761B:
+               cfg_name = "rtl_bt/rtl8761b_config.bin";
                break;
        case RTL_ROM_LMP_8822B:
                cfg_name = "rtl_bt/rtl8822b_config.bin";
@@ -454,9 +454,9 @@ int btrtl_setup_realtek(struct hci_dev *hdev)
        case RTL_ROM_LMP_8821A:
                return btrtl_setup_rtl8723b(hdev, lmp_subver,
                                            "rtl_bt/rtl8821a_fw.bin");
-       case RTL_ROM_LMP_8761A:
+       case RTL_ROM_LMP_8761B:
                return btrtl_setup_rtl8723b(hdev, lmp_subver,
-                                           "rtl_bt/rtl8761a_fw.bin");
+                                           "rtl_bt/rtl8761b_fw.bin");
        case RTL_ROM_LMP_8822B:
                return btrtl_setup_rtl8723b(hdev, lmp_subver,
                                            "rtl_bt/rtl8822b_fw.bin");

Am I right in thinking that this is a BT 5 dongle?

You’re right.It’s bluetooth 5.

2 Likes

Excellent.

I’ve been wanting a BT 5 option for a while and so the Maxesla 5.0 dongle should do the trick.

Nice one :smiley:

After replace /usr/lib/kernel-overlays/base/lib/modules/4.9.113/kernel/drivers/bluetooth/btrtl.ko. We need to disable built-in bluetooth and active usb dongle.We can vi /storage/.config/autostart.sh , add these lines:

rfkill list |grep `hciconfig -a |grep UART|cut -f1 -d:`|cut -f1 -d:|xargs -n1 rfkill block
systemctl restart bluetooth.service

Let’s review information about rtl8761b:

CoreELEC:~ # hciconfig -a
hci0:   Type: Primary  Bus: USB
        BD Address: xx:xx:xx:xx:xx:xx ACL MTU: 1021:5  SCO MTU: 255:11
        UP RUNNING PSCAN 
        RX bytes:77530663 acl:129616 sco:0 events:2347 errors:0
        TX bytes:80981 acl:2069 sco:0 commands:225 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: 'CoreELEC #1'
        Class: 0x0c0000
        Service Classes: Rendering, Capturing
        Device Class: Miscellaneous, 
        HCI Version: 5.1 (0xa)  Revision: 0xd99
        LMP Version: 5.1 (0xa)  Subversion: 0x646b
        Manufacturer: Realtek Semiconductor Corporation (93)

CoreELEC:~ # lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 0bda:8771 Realtek Semiconductor Corp. Bluetooth Radio
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

CoreELEC:~ # lsusb -s 001:002  -v

Bus 001 Device 002: ID 0bda:8771 Realtek Semiconductor Corp. Bluetooth Radio
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass          224 Wireless
  bDeviceSubClass         1 Radio Frequency
  bDeviceProtocol         1 Bluetooth
  bMaxPacketSize0        64
  idVendor           0x0bda Realtek Semiconductor Corp.
  idProduct          0x8771 
  bcdDevice            2.00
  iManufacturer           1 Realtek
  iProduct                2 Bluetooth Radio
  iSerial                 3 00E04C239987
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x00b1
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower              500mA
...

Maybe driver could be changed to support both versions (a and b) like mainline linux does.

Thinking a little more about this, although the simple changes enable a rtl8761b to work, I wonder whether it will only effectively work with the functionality of a rtl8761a and so not exploit the full BT 5 capabilities that come with the rtl8761b.

All functionalities are supported by firmware. btrtl.c just a interface to guide kernel finding appropriate firmware. So don’t worry about that. Everythins is ok ,all BT5 functionality will you get.

1 Like

Thanks for the confirmation.

I will order a dongle to try today.

Be patient.You must be sure that you can compile source code, rebuild image or mksquashfs etc.And as I Know,APTX, LDAC not supported by PulseAudio in CoreELEC.

That part I was not expecting lol

I will gen up again on compiling.

Is it not possible to replace an existing btrtl.ko file in a working build with an already modified and working one?

This is my solution :

  1. cp btrtl.ko /storage

2.vi /storage/.config/modprobe.d/disable-btrtl.conf
to disable built-in module btusb,btrtl been loaded at boot

blacklist btusb
blacklist btrtl

3.vi /storage/.config/autostart.sh
to install modified btrtl by manual

# install module  btrtl.ko been modified
insmod /storage/btrtl.ko
modprobe btusb

# waiting for hci ready
sleep 2

# disable built-in bluetooth 4.2
rfkill list |grep `hciconfig -a |grep UART|cut -f1 -d:`|cut -f1 -d:|xargs -n1 rfkill block

systemctl restart bluetooth.service
  1. reboot -f and enjoy it.

Is btrtk.ko modified or is this the “vanilla” version from CE19rc2?
I tried all the above commands, bit it is not working. CE searches still for rtl_bt/rtl8761a_fw.bin instead of 8761b.
Can you please give us a link to the modified (working) btrtl.ko?
Thx

What about if you just rename firmware file from b to a?

That was the first thing I tried :wink: did not work

I would pick the mainline driver fix:

so both devices are supported at one time

and here is the firmware:
https://aur.archlinux.org/packages/rtl8761b-fw/

It is not included on linux firmware package:
https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/rtl_bt

This patch is suitable for linux kernel 5 above.
CoreELEC use kernel 4.9,btrtl.c source code is different .

It’s invalid if you just rename firmware file from b to a.
Because device’s project id is different.
rlt8761a 's id is 3,rtl8761b’s id is 14.

btrtl.ko been modified .
You can download it from here:

Three steps to active it:
1.got btrtl.ko and firmware, put them into corrent directory
2.edit /storage/.config/autostart.sh and /storage/.config/modprobe.d/disable-btrtl.conf
3.reboot

About | FAQ | Terms of Service | Privacy Policy | Legal Notice