After having my old Bose SoundDock with an old iPhone 30pin plug standing around useless, I thought it is time to give this old device a new life and add Airplay to it.
After some research and dissembling the box I soon figured that the best place to put the additional hardware is the battery pack, I’ve actually never needed before. I use it in my living room and therefore this battery pack is just dead weight to me but the housing is a perfect place to fit a headless Raspberry Pi A+ in. So in the following I’m describing what you need to turn the old Bose SoundDock Portable into an Airplay device.
Requirements:
- Raspberry Pi A+ with 2 GB micro SD card
- Step-Down converter (20V to 5V/USB)
- HifiBerry DAC+ Standard Phone
- Nano Wifi Stick
- 3,5mm male to male aux cable (20cm)
- Micro USB cable (10cm)
- Soldering iron, solder wire, desoldering wick, some wires
- Hot glue gun
- Tools
Dissembling the battery pack
The battery pack comes off easily by turning the lock on the back of the box. Under the sticker saying “Do not open might explode” there are 4 Torx screws that allow you to open the battery pack. Disclaimer: Before opening the pack be sure that you know what you are doing and be careful. The warnings are not without any reason on there and you could harm you, the box, or others.
Having that said, after unscrewing the lid, the battery pack can carefully be removed from the casing (it is glued) and you can use the soldering iron to remove the plug that goes to the box from the board. Again be careful and you might wanna cut the wires coming from the battery first.
This plug you can afterwards glue in the lid of the housing, solder to the most left and most right pin a wire, and use more glue to isolate all the pins (these pins are in the end really close to your Raspi and you don’t want to apply these 20V of the box directly to some components of it.
Preparing the Raspi
Since we’re powering the Raspi directly from the box and don’t want this box and the Raspi running all the time we want a very robust installation that has no problems with power outages. This is done by having a read only filesystem on the card. For the AirPlay client we use Shairport. Since the Raspi A+ has no network and only one USB port I highly recommend to use a USB hub or a model B for the installation.
The general idea of the setup is:
- Install Raspbian, remove unnecessary software (xserver, hwclock, swap, etc), Wifi stick, and connect it to the local WLAN
- Install and Tweak Shairport Shairport
- Install HifiBerry
- Make the disk read only
Install Raspbian
There are several good tutorials on the net how to install Raspbian, so I’m not going into any details here. Also this tutorial is based on the very good tutorials for installing Shairport of Wel!s Blog and creating a read only Raspbian installation of K3A. I just assume you have a up to date Raspbian installation and used raspi-conf
to expand your partition to the size of the disk.
First of all you want to get rid of all the unnecessary things [1][2]:
sudo apt-get remove x11-common x11-utils x11-xkb-utils libx11-6 lxde-common
sudo apt-get remove wolfram-engine triggerhappy cron anacron logrotate
sudo apt-get remove dphys-swapfile xserver-common lightdm fake-hwclock
sudo apt-get autoremove
sudo dpkg --list | grep "^rc" | cut -d " " -f 3 | xargs sudo dpkg --purge
sudo apt-get autoclean
sudo apt-get install busybox-syslogd ntpdate
sudo dpkg --purge rsyslog
The next step is to disable the filesystem check (since you just uninstalled the hwclock), edit /boot/cmdline.txt
and add to the end of the line [2]:
fastboot noswap
Install and Tweak Shairport
Installing Shairport is pretty straight forward [1]:
git clone https://github.com/abrasive/shairport.git
sudo apt-get install avahi-utils libssl-dev libao-dev libpulse-dev libasound2-dev
cd shairport
make
sudo make install
Now everything is installed an you have to add the user shairport, edit the config file and make sure Shairport is started during booting [1]:
sudo adduser --system --disabled-login --ingroup audio shairport
sudo nano /etc/default/shairport
sudo update-rc.d shairport defaults
Note that the AP_NAME only allows names without any blank spaces. I didn’t like that, so I modified the file /etc/init.d/shairport
. The general problem with this file is that the options string for executing shairport in recursively created, wich makes it really hard to escape any blanks or special characters. A quick workaround is to comment out the part where AP_NAME is added to the options sting and rather add is directly using the parameter
-name $AP_NAME
Install HifiBerry
There is a tutorial available on the HifiBerry homepage. With the newest Rasbian distribution the setup, was however slightly different.
First you wanna disable the internal sound card by blacklisting the sound card driver, so edit /etc/modprobe.d/raspi-blacklist.conf
blacklist snd_bcm2835
then you need to change the dtoverlay value in the /boot/config.txt
dtoverlay=hifiberry-dacplus
and create the /etc/asound.conf
file
pcm.!default {
type hw card 0
}
ctl.!default {
type hw card 0
}
This should do the trick and load your HifiBerry sound card during startup.
Make the disk read only
The last part is itself not so difficult but may result in strange behavior during startup. I had the problem that during startup my Raspi was stopping von 1,5 minutes or didn’t give the wlan0 any IPv4 address. If you run in problems like this you might want to try to remove the dhcpcd package and install connman. I also had to manually trigger the IPv4 DHCP request by adding dhclient -4 wlan0
to /etc/rc.local
.
In any case you want the folders with temporary data as tmpfs mounted file systems and your /boot and / as readonly. This results in the following /etc/fstab
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults,ro 0 2
/dev/mmcblk0p2 / ext4 defaults,ro 0 1
tmpfs /tmp tmpfs defaults 0 0
tmpfs /var/lib/dhcp tmpfs defaults 0 0
tmpfs /var/run tmpfs defaults 0 0
tmpfs /var/lock tmpfs defaults 0 0
tmpfs /var/spool tmpfs defaults 0 0
Test it
Now your Airplay Server should work and you are ready to test it. If there is a problem with the setup you can always make the filesystem writeable with the following command:
mount -o remount,rw /
Reassembling the SoundDock
When everything works fine you can start to reassemble the housing. I used a wire cutter to remove the plastic parts on the bottom of the housing and my Raspi A+ fits in perfectly. I then attached the Pi with the USB-cable and the step-down converter to the power source that supposed to be charging the batterie, and drilled a hole for the aux cabe. With a bit of try and error I fit everything back in the housing, was able to close the lid and when re-attaching it to the box everything worked like a charm.
And some more pics: