Ultra96のBlutetooth

Ulrtra96のBluetoothが動かない問題について結論が出た。

Ultra96を触り始めた、薄い本を書いたときは動いてたのになぁ〜と、Ultra96勉強会でやってみたら全然動かなかった。

薄い本を書いてた当時からはLinux KernelもBlutetoothのFirmwareも入れ替えたりしてたけど、動くものだとほったらかしにしていた。

って、Ulyra96でBluetooth使う人いる?

まずはエラー内容

ほとんどの人がハマっているエラー内容はこれだと思う。

dmesgで確認すると次のように出ると思う。

root@ultra96:~# dmesg|grep -i bluetooth
[    1.307976] Bluetooth: Core ver 2.22
[    1.308013] Bluetooth: HCI device and connection manager initialized
[    1.308026] Bluetooth: HCI socket layer initialized
[    1.308037] Bluetooth: L2CAP socket layer initialized
[    1.308059] Bluetooth: SCO socket layer initialized
[    1.395439] Bluetooth: HCI UART driver ver 2.3
[    1.395450] Bluetooth: HCI UART protocol H4 registered
[    1.395458] Bluetooth: HCI UART protocol BCSP registered
[    1.395492] Bluetooth: HCI UART protocol LL registered
[    1.395501] Bluetooth: HCI UART protocol ATH3K registered
[    1.395509] Bluetooth: HCI UART protocol Three-wire (H5) registered
[    1.395551] Bluetooth: HCI UART protocol Intel registered
[    1.395559] Bluetooth: HCI UART protocol QCA registered
[    1.395720] Bluetooth: Generic Bluetooth SDIO driver ver 0.1
[    1.403387] Bluetooth: RFCOMM TTY layer initialized
[    1.403399] Bluetooth: RFCOMM socket layer initialized
[    1.403417] Bluetooth: RFCOMM ver 1.11
[    1.403428] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[    1.403435] Bluetooth: BNEP filters: protocol multicast
[    1.403446] Bluetooth: BNEP socket layer initialized
[    1.403454] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[    1.403464] Bluetooth: HIDP socket layer initialized
[    5.338648] Bluetooth: hci0: change remote baud rate command in firmware ← ここで終わり

Firmwareの問題か?

BluetoothのFirmwareは公式っぽいのがいくつかあって、バージョンが違うようなのです。

TIの公式WebサイトからダウンーどしたものからgithubなどのFirwmwareを試してみたけど、結果は変わらず。

データシートを確認

Bluetoothのログの最後が"change remote baud rate command in firmware"だったのでボーレートかな?と思って、データシートを確認するとBluetoothで使用するUARTのところの最大ボーレートが3Mbpsであった。

そういえば、Zynq MPSoCのUARTってもっと出せるんじゃなかったっけ?

そもそも、最大ボーレートを設定する必要があるのでは?

と、Linux KernelのBluetoothを調べてみるとmax-speedなる宣言があるではないですか?

こんなのどこのドキュメントにも書いてませんよ。

最大スピードなんて設定してなかったのでこれかなぁと思いつつ・・・

ログを眺めていたら

いくつかのバージョンのFirmwareのログを眺めていたら・・・

root@ultra96:~# dmesg|grep -i bluetooth
[    1.307762] Bluetooth: Core ver 2.22
[    1.307796] Bluetooth: HCI device and connection manager initialized
[    1.307809] Bluetooth: HCI socket layer initialized
[    1.307820] Bluetooth: L2CAP socket layer initialized
[    1.307847] Bluetooth: SCO socket layer initialized
[    1.395891] Bluetooth: HCI UART driver ver 2.3
[    1.395902] Bluetooth: HCI UART protocol H4 registered
[    1.395910] Bluetooth: HCI UART protocol BCSP registered
[    1.395939] Bluetooth: HCI UART protocol LL registered
[    1.395947] Bluetooth: HCI UART protocol ATH3K registered
[    1.395955] Bluetooth: HCI UART protocol Three-wire (H5) registered
[    1.395995] Bluetooth: HCI UART protocol Intel registered
[    1.396004] Bluetooth: HCI UART protocol QCA registered
[    1.396168] Bluetooth: Generic Bluetooth SDIO driver ver 0.1
[    1.403734] Bluetooth: RFCOMM TTY layer initialized
[    1.403747] Bluetooth: RFCOMM socket layer initialized
[    1.403764] Bluetooth: RFCOMM ver 1.11
[    1.403780] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[    1.403788] Bluetooth: BNEP filters: protocol multicast
[    1.403799] Bluetooth: BNEP socket layer initialized
[    1.403808] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[    1.403818] Bluetooth: HIDP socket layer initialized
[    5.246430] Bluetooth: hci0: change remote baud rate command in firmware ← ここ
[    7.203761] Bluetooth: hci0: sleep command in scr
[    7.706191] Bluetooth: hci0: sleep command in scr
[   14.948453] Bluetooth: hci0 command 0xfe38 tx timeout
[   23.012466] Bluetooth: hci0: send command failed
[   23.017094] Bluetooth: hci0: download firmware failed, retrying...
[   23.560142] Bluetooth: hci0: change remote baud rate command in firmware ← ここ
[   25.412331] Bluetooth: hci0: sleep command in scr
[   25.914661] Bluetooth: hci0: sleep command in scr

あれ?

"change remote baud rate command in firmware"が2回表示されている。

もしかして、Firmwareはちゃんと書き込まれてる?

と、思って、もしかして原因は別のところにある?

もしかして、単にEnableになってないだけ・・・?

HCIを見てみよう

hciconfigなるコマンドがあるらしいので実行してみると・・・

あぁ、やっぱりDOWNやん。

root@ultra96:~# hciconfig hci0 
hci0:   Type: Primary  Bus: UART
    BD Address: 10:CE:A9:E2:B5:AA  ACL MTU: 1021:6  SCO MTU: 180:4
    DOWN 
    RX bytes:4598 acl:0 sco:0 events:597 errors:0
    TX bytes:117960 acl:0 sco:0 commands:598 errors:0

それだったら、upすりゃいいんでしょ。

root@ultra96:~# hciconfig hci0 up
Can't init device hci0: Operation not possible due to RF-kill (132)

ダメやん。

でも、このメッセージが出るってことは・・・

RFを疑ってみた

試しにrfkillしてみる。

root@ultra96:~# rfkill list
0: hci0: bluetooth
    Soft blocked: yes ← ここ
    Hard blocked: no
1: phy0: wlan
    Soft blocked: no
    Hard blocked: no

これやん(苦笑)

結論

rfkillでunblockしたらokなのさ。

root@ultra96:~# rfkill unblock bluetooth
root@ultra96:~# hciconfig hci0 up
root@ultra96:~# hciconfig 
hci0:   Type: Primary  Bus: UART
    BD Address: 10:CE:A9:E2:B5:AA  ACL MTU: 1021:6  SCO MTU: 180:4
    UP RUNNING PSCAN 
    RX bytes:5261 acl:0 sco:0 events:634 errors:0
    TX bytes:118707 acl:0 sco:0 commands:635 errors:0

動作したところでキーボード繋げてみた。

次のようにキーボードも接続できて完了!

root@ultra96:~# bluetoothctl 
[NEW] Controller XX:XX:XX:XX:XX:XX BlueZ 5.48 [default]
[NEW] Device XX:XX:XX:XX:XX:XX SP Abs Fit 2 0149999
[NEW] Device XX:XX:XX:XX:XX:XX KJ-43W870C
[NEW] Device XX:XX:XX:XX:XX:XX SP Body Fit 2 0077772
[NEW] Device XX:XX:XX:XX:XX:XX BSKBB06
Agent registered
[bluetooth]# scan on
Discovery started
[CHG] Controller XX:XX:XX:XX:XX:XX Discovering: yes
[CHG] Device XX:XX:XX:XX:XX:XX RSSI: -73
[CHG] Device XX:XX:XX:XX:XX:XX TxPower: 10
[NEW] Device XX:XX:XX:XX:XX:XX SKB-BT23BK ← これがキーボード
[bluetooth]# pair XX:XX:XX:XX:XX:XX ← キーボードのMACアドレスを入力する
Attempting to pair with XX:XX:XX:XX:XX:XX
[CHG] Device XX:XX:XX:XX:XX:XX Connected: yes
[agent] PIN code: 775270 ← キーボードからこの数字を入力する
[CHG] Device XX:XX:XX:XX:XX:XX ServicesResolved: yes
[CHG] Device XX:XX:XX:XX:XX:XX Paired: yes
Pairing successful
[CHG] Device XX:XX:XX:XX:XX:XX ServicesResolved: no
[CHG] Device XX:XX:XX:XX:XX:XX Connected: no
[bluetooth]# trust XX:XX:XX:XX:XX:XX ← キーボードのMACアドレスを入力して信頼させる
[CHG] Device XX:XX:XX:XX:XX:XX Trusted: yes
Changing XX:XX:XX:XX:XX:XX trust succeeded
[bluetooth]# connect XX:XX:XX:XX:XX:XX ← 最後にキーボードのMACアドレスを入力してコネクションする
Attempting to connect to XX:XX:XX:XX:XX:XX
[CHG] Device XX:XX:XX:XX:XX:XX Connected: yes
Connection successful ← ほら、繋がった

単にLinuxでRFをOffにしていたということだったらしい。

結局、FirmwareはTI公式の最新版で問題なかった。

write: 2018/11/09/ 20:07:38