有馬総一郎のブログ

(彼氏の事情)

2021年04月09日 22:08:05 JST - 2 minute read - Comments - Linux

BluetoothがONにならない、`Can't init device hci0: Connection timed out (110)`とUPできない。

BluetoothがOnにならない…GUI上からONにしても駄目。

Ubuntu 20.04 Bluetooth
Ubuntu 20.04 Bluetooth

hciconfigというBluetoothデバイス情報を確認するコマンドで調べると。

$ sudo hciconfig -a
hci0:	Type: Primary  Bus: USB
	BD Address: 00:00:00:00:00:00  ACL MTU: 0:0  SCO MTU: 0:0
	DOWN 
	RX bytes:890 acl:0 sco:0 events:144 errors:0
	TX bytes:34686 acl:0 sco:0 commands:143 errors:1
	Features: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
	Packet type: DM1 DH1 HV1 
	Link policy: 
	Link mode: SLAVE ACCEPT 

ダウンになっている。じゃあ、上げようとしても…

$ sudo hciconfig hci0 up
Can't init device hci0: Connection timed out (110)

とエラーになる。

rfkillという無線送信器の状態を調べるコマンドで確認する。

$ rfkill list
0: hci0: Bluetooth
	Soft blocked: no
	Hard blocked: no
1: phy0: Wireless LAN
	Soft blocked: no
	Hard blocked: no

ブロックされていない。

再起動するとたまに直ったりするのだが、これじゃあBluetooth機器使えないじゃん、と困っていた。

sudo service bluetooth restartしても駄目。

わざとブロックさせてから解除しても駄目。

sudo rfkill block bluetooth
sudo rfkill unblock bluetooth

正直、諦めかけていたのだが、解決法があった。

debian - Bluetooth intermittently disconnects - Unix & Linux Stack Exchange

sudo hciconfig hci0 down
sudo rmmod btusb
sudo modprobe btusb
sudo hciconfig hci0 up

カーネルモジュールのアンロード、ロードを行うことで、直った。

なお、コマンドラインでモジュールをアンロードする際は、rmmodコマンドよりも、「modprobe」コマンド(連載第269回)を使う方がよいでしょう。「modprobe」コマンドの「-r」オプションでモジュールをアンロードできます。

とあるが、

 「rmmod」コマンドでは違います。指定されたモジュールをアンロードするだけで、被依存モジュールについては何も行いません。

という違いがあるらしい。

【 lsmod 】コマンド――ロード済みのカーネルモジュールを一覧表示する:Linux基本コマンドTips(267) - @ITで確認。

$ lsmod | grep btusb
btusb                  57344  0
btrtl                  24576  1 btusb
btbcm                  16384  1 btusb
btintel                28672  1 btusb
bluetooth             581632  41 btrtl,btintel,btbcm,bnep,btusb,rfcomm

これで、永続的に直ったかと思ったら再発する。その無効になっている時にlsmod | grep btusbやっても結果は同じだった。手順としてはDown→Upする必要なく

sudo rmmod btusb
sudo modprobe btusb

とやるだけでBluetoothは有効となった。永続的に直せんかな。