My Musical Raspberry Pi setup has a lot of moving parts, which for me is fine. I recently built my Dad a version of a Musical Raspberry Pi as he was interested in my description of the one I built. The main complication in my setup is not keeping the music on the Raspberry Pi itself, but pulling it from my NAS via NFS.

Everything together

Luckily SDHC cards come in amazingly large sizes these days and seem to mostly work with the Raspberry Pi. I settled on a 32GB card, so the plan was to set aside almost all of that space for music and simply setup all the apps (mpd, mediatomb, samba) to look at this folder.

I ended up setting aside 2.5GB for the main / partition and assigning the remaining space (28GB or thereabouts) for media storage.

The final solution supports:

  1. HiFi quality output via a USB DAC
  2. music folder shared via samba with no authentication to keep things simple
  3. mpd with inotify watching of the music folder
  4. mediatomb for UPnP serving of the music folder
  5. ShairPort for AirTunes support
  6. gmediarender-ressurect for UPnP render support
  7. Internet radio by exposing the playlists folder of mpd and simply putting in a few appropriate m3u files.

Networking

With DHCP and Samba, UPnP and all other broadcast based networking - provided you can get a device onto your network it simply shows up where it should. One irritant here is that Android still doesn't support ZeroConf, so setting up MPDroid on Android still requires know about IP addresses. In fact it's worse than that - to make it useful you have to setup a static MAC/IP address mapping on your router. Hardly user friendly, but thankfully a one off.

There does seem to be a decent library for building ZeroConf support into apps - JmDNS - and MPDroid is open source, so a potential project in the making.

If the Raspberry Pi is going to be connected via Ethernet things are pretty simple and once all the software is setup everything works well.

Easy WiFi

If you want to use WiFi things become harder. Running the Raspberry Pi headless means editing files via SSH to get the WiFi setup, the goal here is to make this easier and accessible to less technically minded users.

One option would of course be to use the full graphical interface and rely on standard GUI tools, but this means getting the Raspberry Pi setup is a completely different way purely to get a SSID and passphrase for the WiFi network.

Windows Problems

The initial plan was to setup an extra FAT32 partition for holding config data, such as WiFi settings (as per the Raspberry Pi config.txt in /boot) and simply allow these to be edited from a Windows machine with a card reader.

Unfortunately Windows only ever gives you access to the first partition on any SD cards or USB devices, which is /boot for the Raspberry Pi. It appears there are workarounds for this, but they definitely are well outside the realms of keeping things simple.

A Simple Solution

So a new route forward is to work with the single FAT32 partition we already have and pollute /boot with an additional file. There is a danger here with getting people to edit files in /boot - the potential for pain is large, but for now it gives us a nice way to setup WiFi on the Raspberry Pi for non-technical users.

The solution involves a few bits:

  1. /boot/wifi.txt
  2. /root/interfaces.tmpl
  3. /root/setup-wifi.sh
  4. rc.local entry to invoke /root/setup-wifi.sh on boot

The setup-wifi.sh script checks the timestamp of wifi.txt and then uses sed to replace the relevant portions of interfaces.tmpl to produce a new /etc/network/interfaces file.

/boot/wifi.txt

wpa-ssid "NetworkSSID"
wpa-psk "PSK"

/root/interfaces.tmpl

auto lo

iface lo inet loopback

allow-hotplug eth0
iface eth0 inet dhcp

allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

{{wpa-ssid}}
{{wpa-psk}}

iface default inet dhcp

/root/setup-wifi.sh

#!/bin/sh

if [ -e /boot/wifi.txt ]
then

	if [ /boot/wifi.txt -nt /etc/network/interfaces ]
	then
		ssid="$(dos2unix < /boot/wifi.txt | grep ssid)"
		psk="$(dos2unix < /boot/wifi.txt | grep psk)"

		cp /root/interfaces.tmpl /etc/network/interfaces	
		sed -i -e "s/{{wpa-ssid}}/$ssid/" /etc/network/interfaces 
		sed -i -e "s/{{wpa-psk}}/$psk/" /etc/network/interfaces 
	fi
fi

Thoughts

I'll happily put my hands up at this point and admit this is a fragile solution that has the potential to go wrong easily. Changing WiFi settings is not something most people will do very often, so it's good enough for now. That said I'm keen to keep exploring the issues raised by this little project to see what more complete solutions may be possible.

3 thoughts on “Making a more appliance like Musical Raspberry Pi

  1. I thought you might be interested in an update on Zeroconf support in MPDroid for Android. There's now fork called Mupeace with various hacks I use for my browsing historical/classical collection and a rudimentary Zeroconf server browser. If #256 is incorporated, MPDroid itself will also gain this feature.

    Reply

Leave a reply

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

required