Ubuntu – Cannot find Bluetooth device – Ubuntu Core on Raspberry PI 3 B+

bluetoothbluezubuntu-core

I don't see any bluetooth devices when I install the bluez snap and use either hcitool which results in nothing:

$ sudo hcitool dev
Devices:
$

or bluetoothctl:

$ sudo bluetoothctl
Agent registered
[bluetooth]# list
[bluetooth]# show
No default controller available
[bluetooth]#

When I use hciconfig, I get Permission denied error:

$ sudo hciconfig
Can't open HCI socket.: Permission denied
$

I see the following messages in dmesg which indicates that the AppArmor is denying the attempts:

21346.997174] audit: type=1400 audit(1562448858.001:1396): apparmor="DENIED" operation="create" profile="snap.bluez.hcitool" pid=6030 comm="hcitool" family="bluetooth" sock_type="raw" protocol=1 requested_mask="create" denied_mask="create

What do I have to do to be able to enable the bluetooth device, find the device Id, and also be able to scan for new devices.

I manually connected the snap:plug for bluez and bluetooth-control and now have the following connections:

$ snap connections
Interface          Plug                                 Slot                Notes
bluetooth-control  bledetect101:bluetooth-control       :bluetooth-control  manual
bluetooth-control  bluez:bluetooth-control              :bluetooth-control  manual
bluetooth-control  hidra-ble-gateway:bluetooth-control  :bluetooth-control  manual
bluez              bluez:client                         bluez:service       -
network            bledetect101:network                 :network            -
network            hidra-ble-gateway:network            :network            -
uhid               bluez:uhid                           :uhid               -
$

After this running bluez.hciconfig results in showing the bluetooth device:

$ sudo hciconfig dev
hci0:   Type: Primary  Bus: SDIO
    BD Address: 00:00:00:00:00:00  ACL MTU: 0:0  SCO MTU: 0:0
    DOWN
    RX bytes:0 acl:0 sco:0 events:0 errors:0
    TX bytes:0 acl:0 sco:0 commands:0 errors:0  

However, this is shown as down and attempts to bring it up or reset it fails:

$ sudo hciconfig hci0 up
Can't init device hci0: Input/output error (5)
$ sudo hciconfig hci0 reset
Can't init device hci0: Input/output error (5)
$

Any ideas? As mentioned, this is on RPI3 B+ running Ubuntu Core 18.04. output of uname -a:

Linux localhost 4.15.0-1040-raspi2 #43-Ubuntu SMP PREEMPT Tue Jun 25 10:45:04 UTC 2019 armv7l armv7l armv7l GNU/Linux

adding dmesg output:

$ dmesg | grep -i 'bluetooth'
[   10.291904] Bluetooth: Core ver 2.21
[   10.291982] Bluetooth: HCI device and connection manager initialized
[   10.292000] Bluetooth: HCI socket layer initialized
[   10.292013] Bluetooth: L2CAP socket layer initialized
[   10.292036] Bluetooth: SCO socket layer initialized
[   10.305326] Bluetooth: Generic Bluetooth SDIO driver ver 0.1
[   14.254238] audit: type=1400 audit(1562690889.887:11): apparmor="STATUS" operation="profile_load" profile="unconfined" name="snap.bluez.bluetoothctl" pid=949 comm="apparmor_parser"
[   17.377691] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   17.377713] Bluetooth: BNEP filters: protocol multicast
[   17.377736] Bluetooth: BNEP socket layer initialized
[  834.534698] audit: type=1400 audit(1562691819.528:25): apparmor="DENIED" operation="create" profile="snap.bluez.hciconfig" pid=1639 comm="hciconfig" family="bluetooth" sock_type="raw" protocol=1 requested_mask="create" denied_mask="create"
[  839.183488] audit: type=1400 audit(1562691824.176:26): apparmor="DENIED" operation="create" profile="snap.bluez.hciconfig" pid=1660 comm="hciconfig" family="bluetooth" sock_type="raw" protocol=1 requested_mask="create" denied_mask="create"
[  845.163961] audit: type=1400 audit(1562691830.156:27): apparmor="DENIED" operation="create" profile="snap.bluez.hciconfig" pid=1681 comm="hciconfig" family="bluetooth" sock_type="raw" protocol=1 requested_mask="create" denied_mask="create"
[  852.587936] audit: type=1400 audit(1562691837.580:28): apparmor="DENIED" operation="create" profile="snap.bluez.hciconfig" pid=1702 comm="hciconfig" family="bluetooth" sock_type="raw" protocol=1 requested_mask="create" denied_mask="create"
[ 1115.767865] audit: type=1400 audit(1562692100.757:48): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="snap.bluez.bluetoothctl" pid=2506 comm="apparmor_parser"
[ 1219.232771] audit: type=1400 audit(1562692204.225:67): apparmor="DENIED" operation="create" profile="snap.bledetect101.bledetect-cli" pid=2867 comm="bledetect" family="bluetooth" sock_type="raw" protocol=1 requested_mask="create" denied_mask="create"
[ 1219.232819] audit: type=1400 audit(1562692204.225:68): apparmor="DENIED" operation="create" profile="snap.bledetect101.bledetect-cli" pid=2867 comm="bledetect" family="bluetooth" sock_type="raw" protocol=1 requested_mask="create" denied_mask="create"

Best Answer

There is a bug and it is using wrong firmware dir. As temporary fix you can use this command:

sudo ln -s /lib/firmware /etc/firmware

To check it you can use

sudo hciattach /dev/ttyAMA0 bcm43xx 921600 -
Related Question