Skip to content

Instantly share code, notes, and snippets.

@av1d
Last active February 27, 2024 18:16
Show Gist options
  • Save av1d/83180f5ef6c99ad3c2c1643c76d4b63b to your computer and use it in GitHub Desktop.
Save av1d/83180f5ef6c99ad3c2c1643c76d4b63b to your computer and use it in GitHub Desktop.
Troubleshooting / repairing Bluetooth on Linux, bluetoothctl connection issues

Make sure you check dmesg periodically between these steps for errors...

First try this:

sudo apt-get update
sudo apt-get install --reinstall linux-modules-$(uname -r)
sudo apt-get install --reinstall linux-headers-$(uname -r)
sudo dkms autoinstall
hciconfig -a

if still nothing

sudo modprobe btusb reset=1

if still nothing, check contents of this directory for btusb:

/lib/modules/5.4.0-150-generic/kernel/drivers/bluetooth

if it's not there, reinstall drivers. If it is there try this (line by line, do not paste all):

sudo modprobe -r btusb  # Remove the module
sudo modprobe btusb     # Insert the module
hciconfig -a
# if still nothing:
sudo systemctl restart bluetooth
hciconfig -a
# Still nothing:
sudo modprobe -v btusb
# If still nothing, reload modules:
sudo depmod -a
hciconfig -a
# Hopefully that worked...

You might have errors like this in bluetoothctl where it can't stay connected:

[bluetooth]# connect D6:32:34:34:7D:3C 
Attempting to connect to D6:32:34:34:7D:3C
[CHG] Device D6:32:34:34:7D:3C Connected: yes
Connection successful
[CHG] Device D6:32:34:34:7D:3C Connected: no
[CHG] Device D6:32:34:34:7D:3C Paired: yes

If you see this in dmesg:

Bluetooth: hci0: ACL packet for unknown connection handle 64

It could be that /var/lib/bluetooth needs to be deleted:

sudo mv /var/lib/bluetooth /var/lib/bluetooth.old  # move the folder
sudo depmod -a
sudo systemctl restart bluetooth

now try bluetoothctl again, should work (hopefully). Unfortunately this directory is created each time you run bluetoothctl and it will ruin the connection each time so you must remove it prior to running it every time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment