Realtek BT 4.2 Adapter (0bda:b009)attaches, then disconnects - Ubuntu 20.04.6 LTS

Hi - I have a HP Windows laptop with Ubuntu 20.04.6 LTS / WSL2 - and the subject BT adapter which is an internal adapter (not a dongle!); Works fine for my Windows - but won’t attach to Ubuntu (or so I thought initially…) - then when I learned about the “dmesg” command, I could then see this was actually happening:

Connected0

So, it appears to be connecting - but just for a fraction of a second.

So, just to confirm, I re-ran the “attach” command from PowerShell, switched quickly to the Ubuntu window, and ran the “lsusb” command repeatedly - and then saw this:

Connected

Tried several tweaks - but it still won’t connect - and stay connected for use in Ubuntu - yet…

Here’s the URL to the pastebinit : https://termbin.com/xmh8

Thanks in advance…

A follow up to my post from 1 January - but no responses so far.

Any takers ?

Since my initial post, I’ve searched the web (a lot), tried suggestions that reportedly worked for others (a lot), dove headfirst into the source code for the USB/BT appliances that are built into the kernel (a fair bit - more than most probably), and tried a fair number of solutions that made no sense at all - just to see if anything worked. No joy yet.

Here are the particulars once again:

Ubuntu Version:

NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.2 LTS (Noble Numbat)"

Kernel (if applicable):

6.6.77-microsoft-standard-WSL2

Problem Description:
Realtek dongles can’t / won’t load firmware - so no bluetooth functionality

Applicable dmesg output:

[  615.194718] vhci_hcd: vhci_device speed not set
[  615.300562] usb 1-1: new full-speed USB device number 2 using vhci_hcd
[  615.416641] vhci_hcd: vhci_device speed not set
[  615.490513] usb 1-1: SetAddress Request (2) to port 0
[  615.554241] usb 1-1: New USB device found, idVendor=7392, idProduct=c611, bcdDevice= 2.00
[  615.554472] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  615.554522] usb 1-1: Product: Edimax Bluetooth Adapter
[  615.554552] usb 1-1: Manufacturer: Realtek
[  615.554554] usb 1-1: SerialNumber: 00E04C239987
[  615.583904] rtk_btusb: btusb_probe intf->cur_altsetting->desc.bInterfaceNumber 0
[  615.583972] rtk_btusb: btusb_probe can_wakeup 0, may wakeup 0
[  615.584026] rtk_btusb: patch_add
[  615.584030] rtk_btusb: auto suspend is disabled
[  615.584032] rtk_btusb: pid = 0xc611
[  615.588976] rtk_btusb: patch_add: Reset gEVersion to 0xff
[  615.635150] rtk_btusb: btusb_probe: done
[  615.639679] rtk_btusb: btusb_open start
[  615.639688] rtk_btusb: btusb_open hdev->promisc ==0
[  615.641368] rtk_btusb: download_patch start
[  615.641371] rtk_btusb: chip type value: 0x74
[  615.655540] rtk_btusb: chip_type->status = 0x0, chip_type->chip = 0xbeef
[  615.655651] rtk_btusb: HCI reset.
[  615.684039] rtk_btusb: read_ver_rsp->lmp_subver = 0x8761
[  615.684044] rtk_btusb: read_ver_rsp->hci_rev = 0xb
[  615.684046] rtk_btusb: patch_entry->lmp_sub = 0x8761
[  615.684047] rtk_btusb: load_firmware start
[  615.684048] rtk_btusb: lmp_version = 0x8761
[  615.684049] rtk_btusb: config filename rtl8761bu_config
[  615.691628] usb 1-1: Direct firmware load for rtl8761bu_config failed with error -2
[  615.691640] rtk_btusb: fw name is  rtl8761bu_fw
[  615.691659] usb 1-1: Direct firmware load for rtl8761bu_fw failed with error -2
[  615.691662] rtk_btusb: request_firmware error
[  615.698572] rtk_btusb: load firmware failed!
[  615.700732] rtk_btusb: Rtk patch end -1
[  615.700738] rtk_btusb: btusb_open failed

What I’ve Tried:

  • Tried using both my laptop’s internal USB BT appliance - and a “Edimax” USB BT dongle - check. (Both devices exhibit the same error message)
  • Used the manufacturer’s Makefile - check.
  • Tried 3rd party scripts that reportedly worked - check.
  • Manually renamed and copied the config/fw files to the correct firmware directories - check
  • Reloaded everything and started from scratch - check (repeated 3X now)
  • Waited for Microsoft to release a new WSL2 kernel that supports BT with a Realtek dongle in Ubuntu - check (well, technically still in progress).

I hereby challenge the global community to fix my problem !

I am not sure where rtk_btusb even comes from, I know the Ubuntu 6.11 kernel doesn’t have it

I do know that device works on the Ubuntu 6.11 kernel as that is what I am using now with the Edimaxx BT8500, this might just be an issue with how WSL works but my dmesg shows

[    2.902897] usb 1-1.1: Product: Edimax Bluetooth Adapter
[    5.150485] Bluetooth: Core ver 2.22
[    5.182185] NET: Registered PF_BLUETOOTH protocol family
[    5.182188] Bluetooth: HCI device and connection manager initialized
[    5.182193] Bluetooth: HCI socket layer initialized
[    5.182195] Bluetooth: L2CAP socket layer initialized
[    5.182201] Bluetooth: SCO socket layer initialized
[    5.267683] Bluetooth: hci0: RTL: examining hci_ver=0a hci_rev=000b lmp_ver=0a lmp_subver=8761
[    5.268471] Bluetooth: hci0: RTL: rom_version status=0 version=1
[    5.268477] Bluetooth: hci0: RTL: loading rtl_bt/rtl8761bu_fw.bin
[    5.272280] Bluetooth: hci0: RTL: loading rtl_bt/rtl8761bu_config.bin
[    5.272562] Bluetooth: hci0: RTL: cfg_sz 6, total sz 30210
[    5.440465] Bluetooth: hci0: RTL: fw version 0xdfc6d922
[    6.139210] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[    6.139216] Bluetooth: BNEP filters: protocol multicast
[    6.139221] Bluetooth: BNEP socket layer initialized
[    6.140782] Bluetooth: MGMT ver 1.23
[    6.224600] Bluetooth: hci0: Invalid link address type 1 for 58:a6:39:64:ad:4d
[    9.426186] Bluetooth: RFCOMM TTY layer initialized
[    9.426195] Bluetooth: RFCOMM socket layer initialized
[    9.426200] Bluetooth: RFCOMM ver 1.11

And the lsusb shows ID 7392:c611 Edimax Technology Co., Ltd Edimax Bluetooth Adapter

Hey - Thanks for the reply.

Re: the rtk_btusb - that is part of the manufacturer’s driver package. You have to “make” it yourself after downloading and copying to the system.

The question that occurs to me is, “Did you install the package?” - It would not surprise me if you didn’t.

Other than that, your dmesg output was very helpful - it shows identical IDs for the dongle, same version of the Bluetooth core - so that’s good - but it shows that I’m missing the hci interface functionality on my system. (I think it is pretty important…)

I now believe that I had problems during the initial installation of the driver package.

Might try that again - just to rule it out.

Overall, the Realtek setup is ridiculously complicated - in addition to having to ‘make’ the required drivers and tools (like the rtk_hciattach tool - the instructions say you should not use the hciattach tool that comes with the Bluez stack), you also have to modify the config files and re-make the kernel - which is daunting for noobs (like me) - to say the least. I guess it’s a good way to learn…

Thanks again for the info.

Dave.

I haven’t used rtk_btusb as I have my github site where I try to fix some bluetooth hardware support issues. Do you have a link to the current version of this rtk_btusb code?

Howdy -

The manufacturer’s source package is here - but if your BT is working, my advice is “Don’t fix it !” :slight_smile:

The package has a “readme” in the root - which has commands to “Quickly install automatically” - but so far, those haven’t worked for me; There’s also a “Porting Guide” in the doc folder with a great bit more detail…

I’ve been over both documents several times - but no joy yet…

Found this https://edimax.freshdesk.com/support/solutions/articles/14000135933
Even Edimax says support is built in on kernels 5.15 and newer and I found one of my old posts and it worked on the 4.18 kernels

I might be wrong here, but “error 2” is often “file not found”. Do you have the firmware files (rtl8761bu_fw.bin, rtl8761bu_config.bin) in /usr lib/firmware/rtl_bt/ ?

Nice find, but that driver is looking for files without the .bin extension as that is how the firmware files are from the download and I wonder what results for locate rtl8761bu_fw would be

Merged the two topics.

Thanks for the merge - I should have kept it in the same post.

Re: error 2 - I believe (and multiple posts across the band confirm) that you are correct - and I have seen recommendations to copy (both with and without the .bin extension) for both the “fw” and “config” components to /lib/firmware/rtlbt, /lib/firmware/rtl_bt, and to /lib/firmware as well - since they’re all mentioned in the documentation with the driver package.

Re: the Edimax article - those instructions should work for me - but don’t;

My “uname -r” is:

5.15.167.4-microsoft-standard-WSL2

and so the make crashes with:

*** /lib/modules/5.15.167.4-microsoft-standard-WSL2/build: No such file or directory.  Stop.

Here’s my locate result for the fw:

/usr/lib/firmware/rtl8761bu_fw
/usr/lib/firmware/rtl8761bu_fw.bin
/usr/lib/firmware/rtl_bt/rtl8761bu_fw
/usr/lib/firmware/rtl_bt/rtl8761bu_fw.bin
/usr/lib/firmware/rtlbt/rtl8761bu_fw
/usr/lib/firmware/rtlbt/rtl8761bu_fw.bin
/usr/lib/firmware/updates/rtl8761bu_fw
/usr/lib/firmware/updates/rtl8761bu_fw.bin

I am coming to the point where (as a real Linux noob) I think I must’ve missed a required step in the setup starting from WSL installation and ending with plugging in the dongle - I’ve read at least a dozen “How-tos” - each slightly different - and some got me closer than others;

At one point I could power up the dongle and pair with it - but couldn’t access the port ( iirc, I don’t think there was a port - there was no entry in the /dev list)…

Thanks for all inputs. If anyone knows the “right” info source on how to set this up, I’d appreciate a link. I’m still looking at the Windows sources (since they own WSL) - but if it works, it works. If anyone has a list of steps (with just enough noob - friendly detail) I would be more than obliged …

For this kernel you may have to sudo apt install linux-headers-$(uname -r)
The source code from WSL doesn’t appear much different from Ubuntu kernels as far as bluetooth. From this kernel see if the device is in lsusb results and look for errors in sudo dmesg|egrep -i 'blue|firm', might also check rfkill list to see if it is blocked and then bluetoothctl if it has no error try power on and scan on

My currently installed kernel (which I compiled again this morning) is:

6.6.77-microsoft-standard-WSL2

There’s no “standard” header package for that name - so I installed a generic set:

linux-headers-6.8.0-53 - and dpkg also lists another - linux-headers-6.8.0-53-generic.

Not sure if that’s a no-no to have two at once or not…

Both of my devices (the laptop’s internal USB device and the Edimax dongle) appear to show up correctly via lsusb;

The dmesg output still shows the same ‘load firmware’ failure - which I believe to be due to the missing “hciattach_rtk” appliance - which does not appear to have been successfully compiled yet on my system.

rfkill provides no output - I don’t think it has ever worked for me so far;

bluetoothctl is functional - and when queried for “devices” reports “No default controller available”

Regarding the missing “hciattach_rtk” appliance - I think this is the root of my problem.

This morning after building the 6.6.77 kernel, I noticed that in the output of the make command, a SYMLINK was created which referred to a build directory:

/lib/modules/6.6.77-microsoft-standard-WSL2/build → /home/user/linux-6.6.77/

(Not sure this is the actual link - I rebooted since and the output is now gone…)

Anyway, I then recalled that during an earlier attempt to build this missing “hciattach_rtk” appliance, make initially threw an error that there was no such “build” directory - so I created it manually and tried again. The new folder was empty, so got a “No rule…” error.

Seeing that new symlink output made me question my setup to build the driver package (which includes the missing hciattach_rtk program):

The manufacturer’s documentation does not specify where to download the folder to before attempting to make driver or install driver files… so I had that folder in my default user directory - and when I downloaded the 6.6.77 WSL kernel , I put that in the same folder as well.

So now my question is, “If I need to load manufacturer’s drivers, should that be done before or after I load the upgraded kernel ?” Does it even matter ?

This reinforces my belief in the importance of the “Big picture” for setting up WSL…

Thanks again for all inputs…

I’m starting a detailed log so that when I finally get it working, I’ll be able to post a list of steps to help the “future searchers”… :sunglasses:

Is there any result for ls /lib/modules/$(uname -r)/kernel/drivers/bluetooth/

Nothing shown - but I’m expecting that…
In the release notes here, Microsoft says:

“We are very excited kernel module support is now available in WSL2! With this latest kernel update, a large set of loadable modules has been introduced, accompanied by an overall config file update. However, please be aware that when using a custom kernel, the default module support is disabled for now. If you’re using a custom kernel, we recommend you edit your kernel config file to build-in all of the modules that you need.”

So, I set all components to be built-in - i.e., not a module. Here’s a screen shot of my “make menuconfig” showing the manufacturer-directed additions for the custom options for the Edimax dongle:

image

I checked out the Edimax article you linked - and they say that for a kernel this recent, the dongle should be “Plug and play”… Well, that’s what I was thinking !! (Foolishly.)

Maybe they meant for bare metal installations - but not for WSL.

I just had another revelation while getting the screen shot above - all of the custom kernel edits disappear when you load the new kernel ! That might be obvious - but not until you understand the process a bit more… I’m in the process…

Thanks again for the input.

I had WSL on my Windows PC and checked out what drivers were included and there wasn’t much compared to what the source code I found was showing. I looked at the kernel config for Ubuntu 6.8 and found these settings for Bluetooth hardware support

# Bluetooth device drivers
#
CONFIG_BT_INTEL=m
CONFIG_BT_BCM=m
CONFIG_BT_RTL=m
CONFIG_BT_QCA=m
CONFIG_BT_MTK=m
CONFIG_BT_HCIBTUSB=m
CONFIG_BT_HCIBTUSB_AUTOSUSPEND=y
CONFIG_BT_HCIBTUSB_POLL_SYNC=y
CONFIG_BT_HCIBTUSB_BCM=y
CONFIG_BT_HCIBTUSB_MTK=y
CONFIG_BT_HCIBTUSB_RTL=y
CONFIG_BT_HCIBTSDIO=m
CONFIG_BT_HCIUART=m
CONFIG_BT_HCIUART_SERDEV=y
CONFIG_BT_HCIUART_H4=y
CONFIG_BT_HCIUART_NOKIA=m
CONFIG_BT_HCIUART_BCSP=y
CONFIG_BT_HCIUART_ATH3K=y
CONFIG_BT_HCIUART_LL=y
CONFIG_BT_HCIUART_3WIRE=y
CONFIG_BT_HCIUART_INTEL=y
CONFIG_BT_HCIUART_BCM=y
CONFIG_BT_HCIUART_RTL=y
CONFIG_BT_HCIUART_QCA=y
CONFIG_BT_HCIUART_AG6XX=y
CONFIG_BT_HCIUART_MRVL=y
CONFIG_BT_HCIBCM203X=m
CONFIG_BT_HCIBCM4377=m
CONFIG_BT_HCIBPA10X=m
CONFIG_BT_HCIBFUSB=m
CONFIG_BT_HCIDTL1=m
CONFIG_BT_HCIBT3C=m
CONFIG_BT_HCIBLUECARD=m
CONFIG_BT_HCIVHCI=m
CONFIG_BT_MRVL=m
CONFIG_BT_MRVL_SDIO=m
CONFIG_BT_ATH3K=m
CONFIG_BT_MTKSDIO=m
CONFIG_BT_MTKUART=m
CONFIG_BT_HCIRSI=m
CONFIG_BT_VIRTIO=m
CONFIG_BT_NXPUART=m
# end of Bluetooth device drivers

I would only change CONFIG_BT_HCIBTUSB_AUTOSUSPEND=y to CONFIG_BT_HCIBTUSB_AUTOSUSPEND=n as I haven’t compiled an entire kernel in 10 years and I know that the Edimax uses btusb and btrtl and possibly others
lsmod | grep btusb shows bluetooth 1015808 44 btrtl,btmtk,btintel,btbcm,bnep,btusb,rfcomm

Here’s my current info in the same section:

#
# Bluetooth device drivers
#
CONFIG_BT_HCIBTUSB=y
CONFIG_BT_HCIBTUSB_RTLBTUSB=y
CONFIG_BT_HCIUART=y
CONFIG_BT_HCIUART_H4=y
# CONFIG_BT_HCIUART_BCSP is not set
# CONFIG_BT_HCIUART_RTKH5 is not set
CONFIG_BT_HCIUART_RTL3WIRE=y
# CONFIG_BT_HCIUART_LL is not set
# CONFIG_BT_HCIBCM203X is not set
# CONFIG_BT_HCIBPA10X is not set
# CONFIG_BT_HCIBFUSB is not set
# CONFIG_BT_HCIVHCI is not set
# CONFIG_BT_MRVL is not set
# CONFIG_BT_ATH3K is not set
# end of Bluetooth device drivers

You can see that I have the RT versions of the standard items marked as “Y” - those were the ones I added IAW the manufacturer’s instructions…

I checked, and my AUTOSUSPEND is disabled, though…

Update - I have an incremental improvement - the “hciattach_rtk” appliance is now part of my kernel:

~$ sudo rtk_hciattach
Realtek Bluetooth :hciattach - HCI UART driver initialization utility
Realtek Bluetooth :Usage:
Realtek Bluetooth :     hciattach [-n] [-p] [-b] [-r] [-t timeout] [-s initial_speed] <tty> <type | id> [speed] [flow|noflow] [bdaddr]
Realtek Bluetooth :     hciattach -l

~$ sudo rtk_hciattach -l
Realtek Bluetooth :any       0x0000,0x0000
Realtek Bluetooth :rtk_h4    0x0000,0x0000
Realtek Bluetooth :rtk_h5    0x0000,0x0000

~$ sudo rtk_hciattach -n -s 115200 ttyUSB0 rtk_h5
Realtek Bluetooth ERROR: Can't open serial port, 2, No such file or directory
Realtek Bluetooth ERROR: Can't initialize device 2, No such file or directory

Now it appears that the specified initialization command above is attempting to open a serial port (ttyUSB0) -but there’s no corresponding port or entry in the /dev folder to allow it to connect…

I call it progress anyway…

Current status:

Linux sees the dongle when inserted - and bluetooth is up and running.

The devices are not loading firmware…

The fw and config files for both devices I am trying are loaded in all the likely folders - with and without the .bin extension.

The Realtek appliances are compiled, installed and functional.

After some experiments with the specified initialization command:

“rtk_hciattach -n -s 115200 ttyS0 rtk_h5”

That resulted in:

$ sudo rtk_hciattach -n -s115200 ttyS0 rtk_h5
Realtek Bluetooth ERROR: Can't get port settings, 5, Input/output error
Realtek Bluetooth ERROR: Can't initialize device 5, Input/output error

it’s apparent that a serial port is not created for the dongle automatically…
After trying a few of the other ports in /dev, I got a bit more of a response:
Here I used tty60:

$ sudo rtk_hciattach -n -s115200 tty60 rtk_h5
Realtek Bluetooth :Realtek Bluetooth init uart with init speed:115200, type:HCI UART H5
Realtek Bluetooth :Realtek hciattach version 3.1.8c8cc93.20230801-094614

Realtek Bluetooth :Use epoll
Realtek Bluetooth ERROR: Can't set port settings
Realtek Bluetooth ERROR: Can't initialize device 22, Invalid argument

Closer and closer !

It may be looking for the firmware without the .bin extension in /usr/lib/firmware as now they are in a different directory

Thanks and roger that - already had those in there - but I added versions with the .bin extension - just to be consistent… Here’s the updated content of that folder:

/usr/lib/firmware$ ll rtl8761b*
-rw-r--r-- 1 root root    33 Feb 17 09:24 rtl8761b_config
-rw-r--r-- 1 root root    33 Feb 20 09:31 rtl8761b_config.bin
-rw-r--r-- 1 root root 42572 Feb 17 09:24 rtl8761b_fw
-rw-r--r-- 1 root root 42572 Feb 20 09:32 rtl8761b_fw.bin
-rw-r--r-- 1 root root    14 Feb  6 08:03 rtl8761bu_config
-rw-r--r-- 1 root root    14 Feb 20 09:32 rtl8761bu_config.bin
-rw-r--r-- 1 root root 41612 Feb  6 08:03 rtl8761bu_fw
-rw-r--r-- 1 root root 41612 Feb 20 09:32 rtl8761bu_fw.bin
/usr/lib/firmware$ ll rtl8723*
-rw-r--r-- 1 root root    22 Feb  6 08:03 rtl8723b_config
-rw-r--r-- 1 root root    22 Feb 26 12:44 rtl8723b_config.bin
-rw-r--r-- 1 root root 45560 Feb  6 08:03 rtl8723b_fw
-rw-r--r-- 1 root root 45560 Feb 26 12:44 rtl8723b_fw.bin
-rw-r--r-- 1 root root    22 Feb  6 08:03 rtl8723du_config
-rw-r--r-- 1 root root    22 Feb 18 11:22 rtl8723du_config.bin
-rw-r--r-- 1 root root 55012 Feb  6 08:03 rtl8723du_fw
-rw-r--r-- 1 root root 55012 Feb 18 11:22 rtl8723du_fw.bin

I’m now pondering on how to create a new custom serial port in /dev for this purpose that I could use to attach to… I think it should be possible - but my noob is making everything difficult…