Shairport on Beaglebone Black

There are lots of guides on getting Shairport up on your Blackberry PI, but here’s how to get Shairport 1.0 (the C version – not Perl) running on your Beaglebone Black.  It’s not too different, really.  The biggest thing I did to make my life easier was to replace the default Angstrom Linux with Debian Wheezy.  I have no reason to think you couldn’t do this on Angstrom, but you just can’t beat the immense amount of (more or less correct) information available for Debian on PI and other platforms; 90% of which is totally valid on the BBB.

I used the Wheezy 7.3 hard float image armhf and copied it to the eMMC.  This was not reliable on a normal USB power supply – I had to use a 2 amp one to get it to complete the flash writing operation.

Once Debian is installed, you can log in as debian, password debian.  Then it’s time to update your installation:

sudo apt-get update
sudo apt-get upgrade

Next, install the avahi packages that support Apple-style host discovery.  That will allow you to SSL into your machine as “debian-armhf.local” instead of going to your router to see what IP address was assigned.

apt-get install avahi-daemon avahi-discover libnss-mdns

The Beaglebone Black native audio output is via the HDMI jack.  I chose to use a cheap USB sound dongle, so I needed to install the alsa system, plus some other misc utilities:

sudo apt-get install libpulse-dev
sudo apt-get install alsa-base
sudo apt-get alsa-base-config
sudo apt-get install libavahi-client-dev
sudo apt-get install libasound2-dev
sudo apt-get install libssl-dev
sudo apt-get install git
sudo apt-get install make
sudo apt-get install wget

Then create an /etc/asound.conf file that puts the USB sound card as the default device:

pcm.!default {
        type hw
        card 1

ctl.!default {
        type hw           
        card 1

In /etc/modprobe.d/alsa-base.conf change “options snd-usb-audio index= -2″ to “options snd-usb-audio index=1″ which will allow ALSA to load the USB sound driver and put your card as card 1 (Note: The built in HDMI is card 0.  You can disable the HDMI but it really gains you nothing and you might want to use it later.)

Now is a good time to see if your sound system is working. From your home directory, use aplay -l to test for outputs.

debian@kitchen:/etc/modprobe.d$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Black [TI BeagleBone Black], device 0: HDMI nxp-hdmi-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Set [C-Media USB Headphone Set], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0

If you can see your sound card then you are nearly there.  Plug a set of speakers or headphones in and listen for actual music:

aplay 31beethovens3a.wav

If you hear piano music, that means all is installed correctly and the USB card is the default audio output.  Hooray!  Take a break and have a drink of your choice to celebrate.  Otherwise, you might be in for a tough slog.  Fortunately there is endless Linux sound troubleshooting information out there.

Now it’s time to install shairport. It only takes a few minutes to built it from source, so from your home directory:

git clone
cd shairport
sudo make install

Install copies the shairport executable to /user/local/bin/shairport. Remember that. Next, Add the shairport user, and add the new user to the audio group.  This will avoid lots of mysterious errors later on.

sudo adduser shairport
sudo usermod -G audio shairport

From the ~/shairport/scripts/debian/init.d$ folder in your home directory (where you compiled) edit the shairport file and change the DAEMON” line to read: “DAEMON=/usr/local/bin/shairport”

Copy the shairport script to /etc/init.d/shairport.  From the /etc/init.d folder run

sudo insserv shairport

to create the necessary start and stop links.

Now, test it all from init.d by starting and stopping the service:

debian@kitchen:/etc/init.d$ sudo ./shairport start
[ ok ] Starting Shairport Airtunes emulator: shairport.

debian@kitchen:/etc/init.d$ sudo ./shairport stop
[ ok ] Stopping Shairport Airtunes emulator: shairport.

If you get the “OK” messages then once you reboot you should be up and running. Otherwise you will have some troubleshooting to do.  Good luck!

One thought on “Shairport on Beaglebone Black

  1. Pingback: Shairport on Beaglebone Black | TT's Blog | Ras...

Comments are closed.