Hardware/building/TP-Link UB500
TP-Link UB500 bluetooth key works correctly on Arch Linux starting from kernel 5.15.4-arch1-1, if you are not a masochist I advise you to wait until the appropriate patch is supported by your distribution…
osS)
In over 20 years of Linux I have rarely had such a complicated case. For the past two weeks I have been trying to get my new TP-Link TP-Link UB500 bluetooth key to work on Arch Linux. It had become a challenge.
After Arch Wiki & rtl8761usb drivers installation (chip info in Windows drivers) it didn’t work.
I discovered that there was a patch still under development that would be included in future Kernel releases.
It was necessary to modify the file within the Kernel sources:
/src/.../drivers/bluetooth/btusb.c
adding:
/* Tp-Link UB500 */
{ USB_DEVICE(0x2357, 0x0604), .driver_info = BTUSB_REALTEK },
(Plus editing /src/…/drivers/bluetooth/Edit hci_ldisc.c was not necessary in newer Kernels).
As a first attempt I installed the 5.16 mainline Kernel but even with nvidia-dkms I was unable to boot X.
I tried replacing btusb.ko.zst (compiled and compressed file for Arch) in /lib/modules/5.15.2-arch1-1/kernel/drivers/bluetooth but I later discovered that it was absolutely essential that compiled Kernel version was the same as installed to avoid the damn mistake:
$ sudo modprobe btusb
$ modprobe: ERROR: could not insert 'btusb': Exec format error
I had no idea where to download my Arch Linux 5.15.2-arch1-1 sources.
I gave it a try by re-compiling the kernel from here.
But it was 5.15.2-arch1 version and not 5.15.2-arch1-1, that extra 1 condemned me.
I am not going to list the attempts I made in the meantime and the outputs and logs that I have viewed.
I had read about of waiting for early January for 5.16 patched Vanilla Kernel on Arch Linux so I went ahead with the attempts…
I then discovered a way to get exactly the Kernel sources installed on Arch Linux using the asp tool. In the meantime, we had arrived at the 5.15.3-arch1-1.
# pacman -S asp
$ asp export linux
$ cd linux
$ makepkg -od
Something like 5 GB to download then modify btusb and start building.
$ make -C /lib/modules/$(uname -r)/build M=$(pwd) clean
$ cp /usr/src/linux/.config ./
$ cp /usr/src/linux/Module.symvers Module.symvers
$ make -C /lib/modules/$(uname -r)/build M=$(pwd) modules
$ sudo cp btusb.ko /lib/modules/$(uname -r)/kernel/drivers/bluetooth
After another btusb.ko.zst file replacing I could finally move the GNOME Bluetooth switch to on but it was impossible to connect. I also installed Bluetoother and Blueman GUI tools.
D-Bus error
And here comes the infamous D-Bus error that I had previously underestimated and which apparently acted independently from btusb and concerned Bluez.
× bluetooth.service - Bluetooth service
Loaded: loaded (/usr/lib/systemd/system/bluetooth.service; enabled; vendor preset: disable>
Active: failed (Result: exit-code) since Sun 2021-11-21 19:35:32 UTC; 15min ago
Docs: man:bluetoothd(8)
Process: 1789 ExecStart=/usr/lib/bluetooth/bluetoothd (code=exited, status=1/FAILURE)
Main PID: 1789 (code=exited, status=1/FAILURE)
Status: "Starting up"
CPU: 6ms
nov 21 19:35:32 archlinux systemd[1]: Starting Bluetooth service...
nov 21 19:35:32 archlinux bluetoothd[1789]: Bluetooth daemon 5.62
nov 21 19:35:32 archlinux bluetoothd[1789]: D-Bus setup failed: Connection ":1.97" is not allow>
nov 21 19:35:32 archlinux bluetoothd[1789]: src/main.c:main() Unable to get on D-Bus
nov 21 19:35:32 archlinux systemd[1]: bluetooth.service: Main process exited, code=exited, stat>
nov 21 19:35:32 archlinux systemd[1]: bluetooth.service: Failed with result 'exit-code'.
nov 21 19:35:32 archlinux systemd[1]: Failed to start Bluetooth service
After downgraded Bluez to two previous versions D-Bus error has changed from:
D-Bus setup failed: Connection ":1.97" is not allow
to:
D-Bus setup failed: Name already in use
After hours of trying fighting with any sort of D-Bus connection and permissions even 1:00 in the morning after 11 hours away from home to work (and this tells you a lot about my social life) I found this guide that suggested using the GNOME DFeet GUI, DBus browser to locate Bluez pid and restart it.
$ sudo kill pidnumber
$ rfkill block bluetooth
$ rfkill unblock bluetooth
Finally the turning point, everything started to work…
● bluetooth.service - Bluetooth service
Loaded: loaded (/usr/lib/systemd/system/bluetooth.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2021-11-21 20:19:28 UTC; 7min ago
Docs: man:bluetoothd(8)
Main PID: 4017 (bluetoothd)
Status: "Running"
Tasks: 1 (limit: 19069)
Memory: 1.2M
CPU: 24ms
CGroup: /system.slice/bluetooth.service
└─4017 /usr/lib/bluetooth/bluetoothd
nov 21 20:19:28 archlinux bluetoothd[4017]: Starting SDP server
nov 21 20:19:28 archlinux bluetoothd[4017]: Bluetooth management interface 1.21 initialized
nov 21 20:19:28 archlinux bluetoothd[4017]: Endpoint registered: sender=:1.88 path=/MediaEndpoint>
nov 21 20:19:28 archlinux bluetoothd[4017]: Endpoint registered: sender=:1.88 path=/MediaEndpoint>
nov 21 20:19:28 archlinux bluetoothd[4017]: Endpoint registered: sender=:1.88 path=/MediaEndpoint>
nov 21 20:19:28 archlinux bluetoothd[4017]: Endpoint registered: sender=:1.88 path=/MediaEndpoint>
nov 21 20:19:28 archlinux bluetoothd[4017]: Endpoint registered: sender=:1.88 path=/MediaEndpoint>
nov 21 20:19:28 archlinux bluetoothd[4017]: Endpoint registered: sender=:1.88 path=/MediaEndpoint>
nov 21 20:19:28 archlinux bluetoothd[4017]: Endpoint registered: sender=:1.88 path=/MediaEndpoint>ed una cosa è certa, non voglio piu sentit parlare di btusb..
nov 21 20:19:28 archlinux bluetoothd[4017]: Endpoint registered: sender=:1.88 path=/MediaEndpoint>
No connection
Last night I found something about the missing firmware and downloaded Windows drivers with the intention today to modify them to put into the Kernel.
Today, however, I received the great news that the patch is backported to Linux Kernel 5.15.4 was already available in Arch Linux.
After system update & restart (Bluez & Kernel updated) everything worked immediately and Bluetooth found the available devices.
The lesson
It would have been enough to wait two weeks but this experience helped me to break the ice with my big rock, which I considered impossible and too complex for me to perform and which I had always avoided for this: the Linux Kernel compilation, which I performed at least three (or maybe four) times… and one thing is certain, I don’t want to hear about btusb anymore ..
osS)
Thanks to /forum.manjaro.org/ and cmossimp for the great help.
Some links:
https://forum.manjaro.org/t/requesting-support-for-tp-link-ub500-bluetooth-adapter/88965/40
https://bbs.archlinux.org/viewtopic.php?id=270649
https://bbs.archlinux.org/viewtopic.php?id=271478
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1948502
Leave a Reply