Volumio + Bluez-Alsa (a2dp bluetooth support)

The project github.com/Arkq/bluez-alsa brings this feature.
I’ve tried to take notes of the steps to make it work (thanks to Arkq and their help).
With volumio-2.118-2017-03-07-pi and on Raspberry PI3 + Hifiberry DacPlus.
Any comment to improve the process is welcome.

  1. Dependencies

sudo apt-get update sudo apt-get install libasound2-dev sudo apt-get install dh-autoreconf sudo apt-get install libortp-dev sudo apt-get install bluez pi-bluetooth bluez-tools libbluetooth-dev sudo apt-get install libusb-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev sudo apt-get install libsbc1 libsbc-dev
2. Bluez-Alsa

sudo git clone https://github.com/Arkq/bluez-alsa.git cd bluez-alsa sudo autoreconf --install sudo mkdir build && cd build sudo ../configure --disable-hcitop --with-alsaplugindir=/usr/lib/arm-linux-gnueabihf/alsa-lib sudo make && sudo make install
3. Bluetooth
Create file /etc/bluetooth/audio.conf

[General] Class = 0x20041C Enable = Source,Sink,Media,Socket
Update file /etc/bluetooth/main.conf

[General] Class = 0x20041C
4. Automation
Set BlueAlsa as a service
Create file /lib/systemd/system/bluealsa.service

[Unit] Description=BluezAlsa proxy Requires=bluetooth.service After=bluetooth.service [Service] Type=simple User=volumio Group=audio ExecStart=/usr/bin/bluealsa [Install] WantedBy=multi-user.target
And make it start at boot time

sudo systemctl daemon-reload sudo systemctl enable bluealsa.service
Set bluealsa-aplay as a service
Create file /lib/systemd/system/bluealsa-aplay@.service
hw1:0 is the hifiberry audio device I want to use. There may be better way to link it.

[Unit] Description=BlueAlsa-Aplay %I -dhw:1,0 Requires=bluetooth.service bluealsa.service [Service] Type=simple User=volumio Group=audio ExecStart=/usr/bin/bluealsa-aplay %I -dhw:1,0 [Install] WantedBy=multi-user.target
Bluetooth connection & disconnection detection
Create file /etc/udev/rules.d/99-input.rules

KERNEL=="input[0-9]*", RUN+="/home/volumio/a2dp-autoconnect"

And the corresponding script.
Create file /home/volumio/a2dp-autoconnect:


at each BT connection/disconnection start/stop the service bluealsa-aplay

function log {
sudo echo “[$(date)]: $*” >> /var/log/a2dp-autoconnect
if [ $ACTION = “remove” ]
log "Stop Played Connection " $BTMAC
sudo systemctl stop bluealsa-aplay@$BTMAC
elif [ $ACTION = “add” ]
log "Start Played Connection " $BTMAC
sudo systemctl start bluealsa-aplay@$BTMAC
log "Other action " $ACTION
Create also the log file (not sure but that’s the way I’ve made it work) /var/log/a2dp-autoconnect
And made them accessible:

sudo chmod a+rwx /home/volumio/a2dp-autoconnect sudo chmod a+rw /var/log/a2dp-autoconnect

  1. Start
    using bluetoothctl

power on

agent on


scan on => xx:xx of your device

pair xx:xx

trust xx:xx


On your mobile, connect volumio. Should work.
Once the device is connected you should be able to play something …

To check if the services are all up and running: $ systemctl | grep blue
You should get something like that:

sys-subsystem-bluetooth-devices-hci0.device loaded active plugged /sys/subsystem/bluetooth/devices/hci0 sys-subsystem-bluetooth-devices-hci0:11.device loaded active plugged /sys/subsystem/bluetooth/devices/hci0:11 bluealsa-aplay@68:FB:7E:24:25:52.service loaded active running BlueAlsa-Aplay 68:FB:7E:24:25:52 -dhw:1,0 bluealsa.service loaded active running BluezAlsa proxy bluetooth.service loaded active running Bluetooth service system-bluealsa\x2daplay.slice loaded active active system-bluealsa\x2daplay.slice bluetooth.target loaded active active Bluetooth
You can also check the bluetooth connection works in the log file /var/log/a2dp-autoconnect
You should get something like:

[Sun Mar 12 20:49:39 UTC 2017]: Stop Played Connection 68:FB:7E:24:25:52 [Sun Mar 12 20:49:50 UTC 2017]: Start Played Connection 68:FB:7E:24:25:52 [Sun Mar 12 20:55:34 UTC 2017]: Stop Played Connection 68:FB:7E:24:25:52 [Sun Mar 12 20:55:40 UTC 2017]: Start Played Connection 68:FB:7E:24:25:52


Working great!

Great work, I’m currently using blue-alsa, bluez5 etc and works well on my ARM platform. However as blue-alsa appears to be more of a pcm input that needs a specific client’s mac, I have to change the mac with each mobile / tablet that I which to play music from. A real hassle as it’s supposed to be a BT speaker!
I noticed you have a daemon that fires up bluealsa-aplay + mac, under the section Automation ( And the corresponding script. Create file /home/volumio/a2dp-autoconnect: ) Am I correct in assuming that via this you are passing the phone’s / tablet’s mac and connecting via that mac automatically, e.g once BT connection established? If so, brilliant! The pairing and trusting I’ve already done using a modified simple-agent instead of bluetoothctl. Using your posted information regarding the automation, will it seamlessly pick up a different mac each time ( if pre-paired and trusted ) and play?


Yes, you are right. Once paired and trusted, any device connects and plays (one at a time).
I’ve tried to skip the pairing and trusting step but so far I’ve not found the way (in particular to set up a predefined key to allow an automatic pairing).

Yea the automatic pairing trusting bit was tricky, I use a slightly modified bluez5 simple-agent set-up that runs in the background so any phone/table can come along, connect, put in the pin and play music. Next time around they connect and play ( no intervention speaker side ). Fortunately this paring stuff still works with bluealsa as it bolts up to bluez anyway. My only issue is now introducing one of these pre-paired / trusted macs to bluealsa-aplay at rum time. My ARM’s not playing ball with the “udev input[0-9]” bit, any pointers how udev sees the BT/HCI signals or whatever triggers it?

This part comes from here : gist.github.com/oleq/24e09112b07464acbda1
But I’ve not been very far about the understanding of udev itself…
In my case I’m using the on board BT. An USB BT may behave a bit differently.

Could you share or quickly explain how you have set the simple-agent with pin with bluez5 ?

A lot of bluez5 references use bluetoothctl for manual connection its ok but useless in practical use because you want to point your phone at your hardware and just play. Here’s a list of what I start, my boards a Freescale imx running 4.1.35 kernel, you may have to do a few tweaks…

start bluetoothd // if not already

hciconfig hci0 up // bring up your hcix BT device, same if USB-BT or build in BCMxxx - I use both
hciconfig hci0 reset
hciconfig hci0 piscan // this and below imitate bluetoothctl in the way of discovery , pin etc
hciconfig hci0 leadv
hciconfig hci0 sspmode 0
bluealsa ( or pulseaudio -D ) // from github.com/Arkq/bluez-alsa - cross-compiled to suit…
simple-agent-pin -c NoInputNoOutput & // this still comes with the current bluez, mines modified a little for pin.

Try with just simple-agent // no pin first. You may need to comment out the pin line => hciconfig hci0 sspmode 0

At this stage you should be able to auto pair and trust.

bluez5 simple-agent mods:

PIN_CODE = “0000”

@dbus.service.method(AGENT_INTERFACE, in_signature=“os”, out_signature="")
def AuthorizeService(self, device, uuid):
print(“AuthorizeService (%s, %s)” % (device, uuid))

authorize = ask("Authorize connection (yes/no): ")

if (authorize == “yes”):


raise Rejected(“Connection rejected by user”)

@dbus.service.method(AGENT_INTERFACE, in_signature="o", out_signature="s")
def RequestPinCode(self, device):
	print("RequestPinCode (%s)" % (device))
	return PIN_CODE

@dbus.service.method(AGENT_INTERFACE, in_signature=“o”, out_signature="")
def RequestAuthorization(self, device):
print(“RequestAuthorization (%s)” % (device))

auth = ask("Authorize? (yes/no): ")

if (auth == “yes”):


raise Rejected(“Pairing rejected”)

Hope this helps.

Thank you George, I’ll make a try asap.
EDIT 21/03:
I’ve made progress based on your infos. I still see some misbehavior.
The first pairing and then the cycle, connect, play, disconnect works fine, but

  1. If I forget the connection from my mobile, I cannot pair again. I’ve to remove the device in bluetoothctl to pair again. Sometimes I’ve to restart also the simple-agent script to make the sound work.
  2. I don’t see any “RequestAuthorization xx” and “Release” messages. The last one seems more critical.
    It seems that something is missing to manage the complete loop: pair, forget, pair …
    Any idea ?

The settings above work very reliably for me, so a few questions for you so I can help ( possibly… )
1 ) What’s your platform - RPI?
2 ) Linux flavour?
3 ) The back-end of Bluez5, pulseaudio or bluealsa? ( Currently I use pulseaudio hence why I’m here and want to get rid of it )
4 ) HCI device, built in BT ( BCMxxxx etc ) or USB-BT device
5 ) Bluez5 version.

Check your private email ( here )

Hi Guy’s.
I have built a tiny music player & internet radio for my caravan.
Hardware is
Raspberry Pi Zero W
Hifi Berry Dac Zero
128Gb USB pen holding my complete music Lib (converted to MP3)

Software is volumio-2.118-2017-03-07-pi
It all works well connected from the DAC to the Aux In on the Caravan Radio.

I also have a Studio Series Bluetooth speaker and I’d like to stream to it.

I’ve followed the build -Volumio + Bluez-Alsa (a2dp bluetooth support).
Did it on an old Pi B to use it’s wired connection. Had to install all dependencies individually & created the necessary files using nano at the root level.
I’ve just fire up the Zero with this build and have paired the StudioSeries speaker. But not getting any audio from Volumio.

Running $ systemctl | grep blue gives the following output

volumio@volumio:~$ systemctl | grep blue
sys-subsystem-bluetooth-devices-hci0.device loaded active plugged /sys/subsystem/bluetooth/devices/hci0
● bluealsa.service loaded failed failed BluezAlsa proxy
bluetooth.service loaded active running Bluetooth service
bluetooth.target loaded active active Bluetooth

$ ls /var/log/a2dp-autoconnect gives me - ls: cannot access /var/log/a2dp-autoconnect: No such file or directory

Any ideas about where my problem lies?

One other thing. While working through the build I kept encountering the folowing.

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = “en_GB.UTF-8”
are supported and installed on your system.
perl: warning: Falling back to the standard locale (“C”).
I did run $ sudo dpkg-reconfigure locales. Set them to none, but this seemed to make no difference. In the end I did the build ignoring perl: warning.
Thanks for your time

One more thought
I was confused by - Update file nano /etc/bluetooth/main.conf
Class = 0x20041C

I did the following
Class = 0x20041C

Default adaper name

%h - substituted for hostname

%d - substituted for adapter id

Defaults to ‘BlueZ’

#Name = %h-%d

Default device class. Only the major and minor device class bits are

considered. Defaults to ‘0x000000’.

#Class = 0x000100

How long to stay in discoverable mode before going back to non-discoverable

The value is in seconds. Default is 180, i.e. 3 minutes.

0 = disable timer, i.e. stay discoverable forever

#DiscoverableTimeout = 0

How long to stay in pairable mode before going back to non-discoverable

The value is in seconds. Default is 0.

Should I have updated this line?
#Class = 0x000100
and do I un-statement it?

Trying to follow these instructions and keep getting met with Dependency errors. Have tried installing the dependents and just fall into this rabbit hole of dependents. Is there something that I am missing?

volumio@loftmusic:~$ sudo apt-get install libasound2-dev
Reading package lists… Done
Building dependency tree
Reading state information… Done
You might want to run ‘apt-get -f install’ to correct these:
The following packages have unmet dependencies:
libasound2-dev : Depends: libasound2 (= 1.0.28-1+rpi2)
libpam-systemd : Depends: systemd (= 215-17+deb8u7) but 215-17+deb8u6 is to be installed
systemd : Depends: libsystemd0 (= 215-17+deb8u6) but 215-17+deb8u7 is to be installed
E: Unmet dependencies. Try ‘apt-get -f install’ with no packages (or specify a solution).

Have also tried -f install to no avail

Did you somehow solved the problem? I have the same situation here.

Hi there, I’ve just bought a Pi Zero W and JustBoom Amp to build a boom box and was trying to add bluetooth connectivity and I seem to be getting the same issue as the posters above.

systemctl | grep blue gives the output:-

sys-subsystem-bluetooth-devices-hci0.device loaded active plugged /sys/subsystem/bluetooth/devices/hci0 ● bluealsa.service loaded failed failed BluezAlsa proxy bluetooth.service loaded active running Bluetooth service bluetooth.target loaded active active Bluetooth

and after rebooting the a2dp-autoconnect log file disappears.

If i try to start bluealsa manually i get:

Couldn't initialize controller thread: Permission denied

Any hints on how to get the service active?

I’m getting this from aplay -l for the JustBoom card:

card 1: sndrpiboomberry [snd_rpi_boomberry_dac], device 0: BoomBerry DAC HiFi pcm512x-hifi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0

I’m assuming this matches the -dhw:1,0 in the bluealsa-aplay@.service script?

This is the deepest i’ve delved into Linux so I’m a bit lost, any help is greatly appreciated.

Hi, I’m trying to add bluetooth function for my raspberry machine (Pi zero w and pHAT DAC); I’ve followed the guide but I’m not sure of what I’ve done because I’m not very applied with linux command lines :smiley: ;
At the end of the procedure I can find with my phone the bluetooth hotspot of my raspberry but even if connected I can’t hear anything from my hifi.
What should I do? :question:
Thanks for the answer and sorry for my inexperience :slight_smile:

FWIW I used this version https://github.com/BaReinhard/Super-Simple-Raspberry-Pi-Audio-Receiver-Install on a clean Raspbian install and it works perfectly.

I think it’s very similar to the one posted here but allows automatic pairing without using the terminal. I mainly did this as a test but as the main thing I wanted was the bluetooth connection I’m sticking with it just now. I did go into the desktop and set the max volume and then disabled the loading of the GUI.

There must be enough differences between the Volumio build and bog standard Raspbian to stop it working but it’s beyond me how to work out what those differences are. It may also be that this is just an issue on the Pi Zero as one of the options on the link above during install is for Volumio but I couldn’t get that to work on Volumio. I used the custom install option on Raspbian.

Hi, Thanks for answer.
I’ve tried also BaReinhard tool but it didn’t work with Volumio. As you said it could be a problem of compatibility with Pi Zero, maybe a future update will solve it.

I have exactly the same Problem. Anyone has an solution yet?

Regarding the problem that bluealsa fails to start and “Couldn’t initialize controller thread: Permission denied” is shown when starting it manually:

In the description at the beginning of this thread go to

  1. Automation
    Set BlueAlsa as a service
    Create file /lib/systemd/system/bluealsa.service


That fixed it for me. I found the hint on the developer’s page: github.com/Arkq/bluez-alsa/issues/2

Hi there,

Can you please tell me where you got the full source code for the simple agent?