Saturday, May 26, 2012

Running SqueezeSlave on Raspberry Pi

- Running SqueezeSlave on Raspberry Pi

Getting Squeezeslave to run on the RPi is very easy - here is a revised version of the instructions that I posted on the Raspberry PI forum.
NOTE: This has been tested on Debian Squeeze (and I think it also works on Wheezy) - but will almost certainly need some updated to work on hard-float builds such as Raspbian and has been updated since first published to include instructions for Raspbian Wheezy (the hardfloat version of Debian that is endorsed by Raspberry Pi Foundation).
Version numbers shown here were correct when this blog was written but it is possible that newer versions have been released since then ... and they might work better (or worse) so check on Sourceforge (for official release) and GoogleCode (for latest test versions).


Most of what is shown below could be copied to a script and run - but there is no error checking so it is best to run as individual commands - e.g. copy / paste into SSH session

NOTE: Some of the lines below are very long and get wrapped when presented in the blog.
I have left a blank line after those long lines to make it clearer. If you are using copy/paste to replay the commands then make sure that you take the full line and unwrap it if needed.

Start an interactive login to the Raspberry Pi then ...

mkdir squeezeslavesrc
cd squeezeslavesrc
# If on Debian (not Raspbian) then perform the next 2 commands
wget http://sourceforge.net/projects/softsqueeze/files/squeezeslave/squeezeslave-1.2.311/squeezeslave-1.2-311-armel-lnx26.tar.gz

tar -xvf squeezeslave-1.2-311-armel-lnx26.tar.gz


# If on Raspbian (a hardfloat version of Debian) then perform the next 3 commands
wget http://squeezeslave.googlecode.com/files/squeezeslave-1.2-367-armhf-lnx31.tar.gz

tar -xvf squeezeslave-1.2-367-armhf-lnx31.tar.gz

mv squeezeslave-1.2-367 squeezeslave




# at this point you have the various binaries for ARM/Linux so no need to build from source
# and you now have enough to run squeezeslave
# however, by downloading some more files you can make it easier to start/stop squeezeslave

# to test what you already have - assuming you are already running LMS somewhere on the same LAN
# type
./squeezeslave -L
# if this lists audio device(s) then things will probably work for you
# if there are none then try (note - this should not be necessary on Raspbian)
sudo modprobe snd-bcm2835
# and then
./squeezeslave -L

# to run it as a player ...
./squeezeslave -D -F
# to quit from that display mode hit the "q" key
# remember - if you are doing this via SSH from a different room then
# you will only hear something if you are at the device (e.g. the speakers on your TV!)

# If it acts like it is playing something but you cannot hear it then it might be that the sound on the Raspberry PI is set too low (in ALSA).
# In that case - quit (q) Squeezeslave and run
sudo alsamixer
then boost the sound by pressing the up arrow key (and the "esc" key to exit and then try running Squeezeslave again

# assuming all was OK from above - then you can do more to automate the startup


wget http://sourceforge.net/projects/softsqueeze/files/squeezeslave/squeezeslave-1.2.311/squeezeslave-1.2-311-src.tar.bz2

# If you do not have bzip2 on your system you might need
sudo apt-get install bzip2

tar -xjvf squeezeslave-1.2-311-src.tar.bz2

sudo cp squeezeslave /usr/bin

sudo cp squeezeslave-1.2-311/config/squeezeslave.init.debian /etc/init.d/squeezeslave

sudo chmod 755 /etc/init.d/squeezeslave

sudo update-rc.d squeezeslave defaults

echo "SBSHOST=\"-F\"" > defaultsqueezeslave

# the backslashes above are needed to make the quotation marks go into the file
# if you look at the file afterwards it should look like this
# SBSHOST="-F"

# if you needed to run the modprobe to get sound working then also do this
echo "modprobe snd-bcm2835" >> defaultsqueezeslave

# then copy the file over to become the default configuration for SqueezeSlave
# Done this way because trying to use sudo to echo direct to /etc/default does not work on some builds

sudo cp defaultsqueezeslave /etc/default/squeezeslave

# then to start it ...
sudo /etc/init.d/squeezeslave start
# and to stop it (for example if something else is trying to use the audio port and sharing not working)
sudo /etc/init.d/squeezeslave stop

# it should start automatically on the next reboot of your Raspberry Pi

Here is a short video showing the result ... to be honest there is not much to see because it SqueezeSlave is running in the background. However, it does show how quickly the Raspberry Pi reboots.



I also had this synchronising with a couple of real Squeezeboxes. It needed some tweaks to the timing offsets in LMS to get it to be closely in sync.

If you plan to add more SqueezeSlave devices to your set-up then you will need to change the fake MAC address that SqueezeSlave uses. It defaults to 00:00:00:00:00:01
I will probably update the default to set the SqueezeSlave MAC address to be the real MAC address of the Raspberry Pi (which in turn is usually derived from the serial number of the device).

If you did download and unpack the source - then it is also possible to build your own copy of SqueezeSlave. I did this as well and it worked - but you have to build the "contribs" as well to get the ARM version. I might update this blog entry with how to do it if there is some interest.
Remember, though, if you are on Raspbian then start from a software release that is known to work on hard-float (armhf).

September 2012 - updated with some extra information for Raspbian users