4

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"
3
  • 1
    Looks like there is a bug and it points to wrong firmware dir. So fix for access denied is to run: ln -s /lib/firmware /etc/firmware
    – IGHOR
    Aug 1, 2019 at 19:45
  • You can check it by this command sudo hciattach /dev/ttyAMA0 bcm43xx 921600
    – IGHOR
    Aug 1, 2019 at 19:56
  • @IGHOR, I switched to experimenting with Arch Linux and Ubuntu 18.x on the RPI. However I did face similar issues with them too and your suggestions definitely works! I haven't tried it on Ubuntu Core though... Anyway, Thanks for your help.
    – Srihari
    Aug 18, 2019 at 2:14

1 Answer 1

6

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 -
6
  • I tried this solution on Ubuntu 18.04.3 LTS running on a Raspberry Pi 3 B+ and it works. IGHOR, would you mind sharing whatever info you have on this bug (link, perhaps?) so we can track it and know when it's fixed?
    – Alejandro
    Sep 10, 2019 at 16:06
  • I have found that command hciattach.. and by its output Cannot open directory '/etc/firmware': No such file or directory I understood what to do. I have not found any bug report related to it.
    – IGHOR
    Sep 10, 2019 at 20:11
  • 1
    Thank you. I wasted almost a day on finding this fix
    – kashesandr
    Sep 4, 2020 at 20:15
  • Any ideas how to automate the device initialization process after every reboot?
    – kashesandr
    Sep 11, 2020 at 18:55
  • You may add some systemd service that runs at boot and doing what you need. I give up on Ubuntu on Raspberry Pi since it freezes sometimes. Using Raspberry OS 64 bit version for few months already, no problems so far.
    – IGHOR
    Sep 11, 2020 at 22:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .