Saturday, 31 May 2008

SqueezeCenter on the SLUG

At first glance, installing slimserver (now SqueezeCenter) on the SLUG is very straight forward as it's nicely packaged into an ipkg and made available via Optware. However, as indicated on the slimserver application page on the nslu2-linux wiki, things aren't as simple as they first appear. Unfortunately, something is very broken with slimserver and its dependency chain in Optware as things stand at this moment in time. As a result installing slimserver with a view to upgrading to squeezecenter at a later date becomes much more problematic. I need at least SqueezeCenter version 7.0 to operate with the SqueezeBox Duet.

My first target was to run slimserver 6.5.4 which is the latest version from the version 6 line and the version packaged for the SLUG in optware. I tracked the problem down to the mysql dependency for slimserver, it seems since the last update of slimserver in optware, mysql has also been updated and since that time slimserver has been reported as broken on the SLUG. Unfortunately, rolling back versions in optware is not trivial since they only make available the latest version with no access to previously packaged programs. My only option was to check out the mysql build environment from SVN at the previous level and compile up the package from source. This is reported to take in the region of 18 hours natively on the SLUG so I set up a cross-compilation environment on my Fedora 8 box at home. MySQL compiled in about 10-15 minutes and I now had a package to install. The reports were correct, slimserver 6.5.4 was now running on my SLUG, excellent!

The next challenge was to get SqueezeCenter running, and this worked in a similar way to getting slimserver going. There are a few oddities with getting all your ducks in a row while running this stuff on a SLUG, SqueezeCenter is very particular about file permissions, and the newer software introduces a whole bunch of Perl dependencies not present in the earlier slimserver versions. Fortunately, I'm very familiar with Perl as well as Linux (one of the reasons for choosing a squeezebox) and I've managed to compile up the minimum dependencies to get SqueezeCenter going. It seems Slim Devices as a company test against x86 and PPC architectures to the extent they even supply their Perl dependencies for these from CPAN. I'm running on ARM on the SLUG though which introduces a whole world of dependency problems as it seems SqueezeCenter is also pretty sensitive to the version of each Perl module used, it's not just a case of grabbing the latest and greatest from CPAN, a further bind for getting it going nicely. One other thing, CPAN doesn't seem to run at all well on the SLUG, it's far faster to download the tarred packages and compile manually!

I eventually got SqueezeCenter 7.0.1 running on the SLUG, it consumes at least twice the 32MB RAM available so runs pretty slowly while spending a lot of time paging to the USB disk. I set up an additional swap file on disk as well, thinking about it perhaps I should have used the rest of the 8MB flash as swap too! All in all, running SqueezeCenter on a machine with so little memory and on an architecture not supported by Slim Devices has equated to a slow response time and a maintenance headache.

In conclusion, it's been a good experience getting a SLUG and setting up SqueezeCenter on it. But I already need a more powerful box so less than 1 week after the SLUG arrived at my house it's time to sell already. Fortunately, I've found a buyer at work who wants something low power for some really trivial services so the SLUG is ideal for them. For me though, it's a case of getting back to scratching my head over which low power home server solution to try next. Whatever I choose will be more expensive than the SLUG, it's possible I could equal its low power usage, and I definitely now know I need more memory and ideally an x86 architecture.

Friday, 30 May 2008

Google Treasure Hunt Question 3

I've been keeping up with the Google treasure hunt as a bit of fun rather than seriously going after any prizes. At least one other guy at work has been joining me, Nick O'Leary has taken up the challenge too. Question 3 was recently released, and while I thought it might possibly present the greatest challenge yet on first inspection, it turned out to be really rather trivial.

So question 3 is all about IP routing, and tracing a packet route around the network. I was expecting some hardness built in around working out subnet masks, but there was none of that at all, just a simple route to follow resulting in an 11 node path. The question then:

Below is a diagram of a computer network. The nodes are hosts on the network, and the lines between them are links. A packet is sent out from host G with a destination of Which nodes does the packet pass through on its way to the destination? (include start and final node in your answer)

You are then shown a routing table and must trace your way through it from the start node to the end node recording the path taken along the way. This is a solution that is quickly manually traceable since no node should be visited twice (unless Google have given you some really badly designed network).

Having said about the simplicity of this one, I managed to get it wrong the first time around by starting at the wrong node. Reminds me of maths teachers constantly saying "Always Read the Question!". Once I screwed my head on the right way around I correctly answered GFIHDLOPABC for my network.

Thursday, 29 May 2008

Unslinging the SLUG

Having recently purchased the Linksys NSLU2 (commonly called a SLUG) for use in a hacked form as a low power home server, I've been playing around with it a little to customise it towards my needs. The eventual aim is to run SqueezeCenter on it to power my new SqueezeBox Duet. The most commonly used hacked version of Linux provided by the SLUG hacking community is known as uSLUnG, hence hacking the SLUG with this being called unslinging.

The process of unslinging is made very simple, thanks to the great instructions developed over the years by the community, and with such a large community the amount of testing on these instructions is pretty complete too. First step is to download the firmware binaries as described on the SLUG Firmware site. I used firware version 6.10 Beta which is considered the latest stable version in spite of having a beta tag. Then simply followed the instructions in this README file and I was done. The whole process takes no more than 10 minutes or so.

Now I have a nice little low power Linux box sitting on my network raring to run some services for me. Pretty much anything you can think of has been done on the SLUG, Apache, MySQL, etc, etc, etc. So the list and choice of what to do is very complete. For now though, I've just installed a few basic utilities (coreutils), Perl (I know I'll need that later), GCC, and SSH for remote access.

I'll quickly mention the SLUG specs in passing too. It has a 266Mhz ARM based Intel XScale processor, some of the early models were under clocked at 133Mhz but all the recent editions run at full speed; 8MB flash; 32MB RAM; 2 USB 2.0; 10/100 Ethernet; runs from 5V DC power and measures just 2 x 9 x 13cm. With one USB disk attached my Current Cost meter reads it at about 5 watts power usage which I guess may rise a watt or two under load.

Wednesday, 28 May 2008

Choosing the media server

The decision of which media server to go with has easily been the longest and most agonising while putting together new audio solution at home. I'm not the only one at work having recently been looking in this area either, James Taylor has also been looking at home servers with similar requirements in mind to myself. Namely, cheap and low power (low electrical power for always-on as opposed to a slow processor).

In no particular order, options on the list for me were:
EDIT (suggestions from comments, with my thanks):END EDIT

All have clear advantages and weaknesses I wont go into in detail for each box. However, they can roughly be grouped into cheaper solutions as provided by a hacked NAS box, or more expensive PC style systems. Some go straight out of the list on price alone, such as the relatively expensive Mac (I don't understand the Mac fad, single vendor lock-in, haven't we seen that somewhere before?).

I decided to plump for the cheapest of all the options, the SLUG. I figure that even though it has a slow processor and only 32MB memory it does have a fighting chance of running SqueezeCenter to power the Squeezebox Duet based on the reports of other users running SlimServer on it. If all else fails, there are plenty of people at work looking for low power solutions who may be willing to buy a 2nd hand SLUG should I want to upgrade anyway.

The SLUG is a very well-known device in the land of hackery. It can easily be modified to run any one of several different versions of Linux that maintain different levels of compatibility with the original Linksys firmware and interface. It's purpose in life when released (back in 2004 I think) was as a cheap NAS box that simply provides a USB to Ethernet interface. The idea being you plug a cheap USB hard disk into it, configure via the simple web interface, and you have storage you can access from anywhere on your home network. Because Linksys made the device cheap, naturally their choice of operating system was a free one, Linux. The Linux license dictates Linksys had to make their source code available, hence it's easy to modify the original software for your own purposes. The rest follows from there really!

Saturday, 24 May 2008

Choosing the stereo and speakers

While working out how to string together my new audio solution I decided to replace my faithful old Aiwa NSX-S505 stereo system. The Aiwa has been a good servant over the years and seen a lot of action, but with the volume knob broken and one of the two tape players knackered, when the CD player refused to play a CD enough was enough.

I've always loved Denon kit as being simple yet very good quality, stylish and innovative at the same time, so I was immediately drawn to them for a new stereo. I was looking at the Denon D-M35DAB system as my choice item but before I purchased it used it as the bar for a quick shop-around.

While reading reviews I discovered Onkyo which was a company I'd heard of before but never really heard anyone buying their kit. I came across their direct competitor to the Denon model I was looking at, the CS-515 which has pretty much the exact same feature set. I'm no audiophile so I take great note of what the professional reviewers have to say, and with What Hi-Fi product of the year award, and Best Hi-Fi under £500 awarded to it I had to look much more seriously at the Onkyo. It was, eventually, to be the model I decided on based purely on Internet shopping having never touched or listened to either the Onkyo or the Denon before.

I have pretty simple requirements for a stereo. It has to have enough inputs for me to connect my various devices (Media Centre, possibly TV, etc), I wanted something quite small in terms of height so it would sit in my TV cabinet, and something of a better sound quality than the Aiwa (which really was an excellent buy for what I paid for it many years ago). Feature wise, I wasn't bothered about a tape player any more (we ditched our tapes a while ago), so just a simple CD player and digital radio would be good enough. Conveniently, both of the systems I found fitted these.

When I purchased the Onkyo I didn't go for the CS-515, but rather the CR-515 which is exactly the same unit minus the speakers. The Onkyo speakers are reviewed as being an excellent set, particularly for ones that are shipped as a standard set of speakers with a hi-fi system. However, I decided to go with the professional opinion once again and opted for the current set of award-winning small-sized speakers, the Tannoy Mercury F1 bookshelf speaker set. They're slightly larger than the Denon SCM-50 bookshelf speaker set I have in the kitchen, which are fantastic so the Tannoy's had a lot to live up to. I'm pleased to report they sound really quite nice when attached to the Onkyo, although my first sound test was somewhat inhibited by Beth vacuuming the rest of the house at the time!

Wednesday, 21 May 2008

Choosing the media streamer

Having recently upgraded my home audio system, the choice of which media streamer to go for was not a hard decision. There are a few different manufacturers out there producing different types of hardware that would result in completely different solutions. These seem to be categorised into roughly three areas.

First, you have the traditional hi-fi system manufacturers who are adding more modern media methods to their kit. Sony have the gigajuke systems with built-in hard disks, while phillips have the streamium systems. I discounted these fairly early on as being rather expensive and full of gimicks I wouldn't really care about or use, while not providing the full functionality that I really wanted at a price I was happy with.

Next there are the traditional NAS manufacturers who are upgrading their firmware to include media streaming functionality. This was slightly more tempting in some ways than a stereo system with this functionality built in. However, the lack of remote control or feedback without a PC switched on was very off-putting here.

What I really wanted was something to stream music from a PC to an existing stereo system that provided good feedback to the user with a remote control too. Enter the third set of devices, the dedicated media streamers designed to work with various media servers such as Firefly, SlimServer, iTunes, etc. When looking at these, my choices were quickly narrowed to a set of 3 possible candidates, in descending order of price:

  1. A collection of various Sonos hardware
  2. A SqueezeBox Duet from Slim Devices (now owned by Logitech
  3. A Pinnacle Soundbridge

I would have dearly liked to get my hands on the market leading Sonos which tops all the reviews while having the reviewer salivate over their nicely designed hardware, excellent interface and crystal sound quality. However, coming in at £700 sterling it seemed a bit expensive, especially as I would be spending more on another hi-fi system too, so it was reluctantly ruled out quite early on.

The next rejection waas the Pinnacle Sound Bridge, rejected for many reasons. It's easily the cheapest of the three on the list at under £100 though. I found it very difficult to find a dealer in the UK who had these things in stock so that was one rather off-putting factor - if there's no demand, then how good could the product be? The killer for me was when I compared to the Roku Soundbridge though. I found out Pinnacle license the soundbridge technology from an American firm, Roku, for marketing in Europe. That's all very well, except the European Soundbridge is inferior (much smaller and less usable display). This annoyed me to such an extent I felt I couldn't buy the European model and there are no American models for sale over here, except possibly some second hand ones on eBay.

Squeezebox Duet
The option I went for is the Slim Devices SqueezeBox Duet which seems like a really nice bit of kit, although not exactly cheap to buy either. It comes in two parts, the receiver box you hook up to your stereo system, and the remote control you use to browse and control the music.

The receiver is a pretty simple box, it has an Ethernet port, built-in wireless, RCA analogue audio output, and a digital output too. It sits on your network waiting for commands from the squeezebox controller and outputting any media streams it receives to a stereo (or powered speakers).

The controller is a little more interesting. It's also a wireless device, and has a jog wheel and LCD screen. Wireless means you don't have to have line of sight to the receiver, so you can hide the receiver away somewhere out of sight near your stereo. The interface is quite polished and very easy to understand. It's firmware upgradeable too so it'll only get better over time.

One of the things I really love about the SqueezeBox stuff is their openness. They use open source development to produce the SqueezeCentre (formerly slimserver) media streamer and as such it's got a nice little community of people outside the main company producing plugins to do all sorts of stuff as you can imagine. They adopt a similar approach for their firmware as well, while I've not come across the source code yet (I've not looked to see if it's available), the controller has some nice open type touches to it such as the ability to use your flickr pictures as the screensaver on the LCD screen when it's not in use. Overall I hope, and I think, I've made a good choice.

Tuesday, 20 May 2008

Google Treasure Hunt Question 2

After solving question 1 successfully I decided to plod on and answer question 2 as well. It was, for me at least, far less challenging than the first question.

This time, you are generated a set of files with random directories and file names that you are asked to download and process. Once I got passed the immediate suspicion of downloading a zip file (for fear of viruses) it took no time at all to whip up a solution. My question was:

Here is a random zip archive for you to download:

Unzip the archive, then process the resulting files to obtain a numeric result. You'll be taking the sum of lines from files matching a certain description, and multiplying those sums together to obtain a final result. Note that files have many different extensions, like '.pdf' and '.js', but all are plain text files containing a small number of lines of text.

Sum of line 4 for all files with path or name containing BCD and ending in .pdf
Sum of line 5 for all files with path or name containing mno and ending in .rtf
Hint: If the requested line does not exist, do not increment the sum.

Multiply all the above sums together and enter the product below.
(Note: Answer must be an exact, decimal representation of the number.)

Again, my solution was Perl based and generated a correct answer of 364264342 for my particular zip file:
#!/usr/bin/perl -w
use strict;
use File::Find;
use FileHandle;
my $total1 = 0;
my $total2 = 0;
find(\&wanted, ("/home/gwhite/GoogleTreasureHunt08_15866755520722619948"));
print $total1*$total2."\n";
sub wanted {
return if (-d $File::Find::name);
if (($File::Find::name=~m!BCD!i) && ($File::Find::name=~m!\.pdf$!i)) {
my $fh = new FileHandle;
$fh->open($File::Find::name) || die ($File::Find::name." Oops: $!\n");
while (<$fh>) {
last if ($fh->input_line_number>4);
$total1+=$_ if ($fh->input_line_number==4);
elsif (($File::Find::name=~m!mno!i) && ($File::Find::name=~m!\.rtf$!i)) {
my $fh = new FileHandle;
$fh->open($File::Find::name) || die ($File::Find::name." Oops: $!\n");
while (<$fh>) {
last if ($fh->input_line_number>5);
$total2+=$_ if ($fh->input_line_number==5);

Monday, 19 May 2008

Google Treasure Hunt

I've just discovered today (rather late I know) that Google have released a treasure hunt which is quite interesting. It's not what you might think. Given the name, I would have guessed it involved using the google search engine to find things on the Internet. However, it's actually a problem solving challenge where they pose questions and you submit your answer. I think question 2 is due out today (they obfuscate when the next question will be released), nobody seems to know how many questions there are, exactly how long this will go on for, etc. But there is a prize for "the first person to answer all the questions correctly" whatever that means.

A word of warning, don't read the rest of this if you want to work out the answer yourself!!!

My question number 1:
Google Treasure Hunt Q1
A robot is located at the top-left corner of a 65 x 61 grid (marked 'Start' in the diagram above)*.

The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the not to scale diagram below).

How many possible unique paths are there?
(Note: Answer must be an exact, decimal representation of the number.)

The problem here is the vast number of different routes that can be taken, which would overflow 32 bit computers for numbers this size. My (correct) answer was 1426507627253102510231886503468838531 which I calculated using the formula (x+y-2)! / ((x-1)! (y-1)!)

A few simple lines of Perl later and I had the answer:
#!/usr/bin/perl -w
use strict;
use Math::BigInt;
# change these to match your X & Y grid size
my $xgrid = 61;
my $ygrid = 65;
my $x = Math::BigInt->new($xgrid-1)->bfac();
my $y = Math::BigInt->new($ygrid-1)->bfac();
my $z = Math::BigInt->new($xgrid+$ygrid-2)->bfac();
print $z->bdiv($x->bmul($y))."\n";

Friday, 16 May 2008

In with the new

Related to my previous post "Out with the old" I have been thinking about what's next for me in terms of a home media solution. I've also been spurred on by my recent purchase of a Current Cost meter which I can hook up to a computer, but more about that another time. Similar to my old system, I'm not bothered about video so this is purely an audio solution.

There are some things I took into consideration when building the old system that I don't consider to be so important this time around. I'm not bothered about browsing the Internet on my TV and I'm prepared to spend a bit more cash, for example. But rather than concentrate on those points, here's a list of things I would like to include in the new system:

  • Switchable speakers in different rooms (kitchen and living room)
  • Connection to my stereo amplifier
  • Access to my mp3 collection without leaving my PC powered on
  • Access to Internet music (podcasts, radio, etc)
  • Remotely controlled
  • Separate screen (from the TV)

After much research, here's what I've come up with:
Setup Diagram Click to enlarge.

I'm going to use a Linksys NSLU2 (a.k.a. a SLUG) which can be modified to run Linux so I can hack it into submission to be my low powered music server. The SLUG will provide my music collection over my wireless network to a Slim Devices Squeezebox Duet system. The Squeezebox is also able to access all the Internet services I want and similar to the SLUG runs open source software so has a fantastic community of users. The Duet comes with a wifi remote control with built-in LCD screen so I can interact with the system from anywhere in the house. From the Squeezebox is an audio connection to the amplifier which, similarly to my old system, is connected to a speaker switcher box.

That little lot should keep me busy for a while and give me all I want from music at home. As I mentioned, a lot of research went into deciding which components to choose. The weak link here will likely be the SLUG because it's such a small box with only 32Mb RAM and a relatively slow processor (just 264 bogomips) but it should do for the time being. Here's my component list:

Tuesday, 13 May 2008

Out with the old

I moved house pretty much spot on 6 months ago now and we're still settling into the new house. Aside from decorating, emptying boxes and all the other things you have to do at the time, it's also an opportunity for re-thinking some of the technology used in our previous house. To that end, one of the things I want to update is my audio solution. I shy away from saying media centre as that seems to brew up ideas of full on PVR systems for most people which would include recording television; something I don't care about as I have a commercial hard disk recorder I'm very happy with.

My current solution was documented at the time on Eight Bar as a description using an IBM Thinkpad built as a media centre with more details of the process, also on Eight Bar. This solution worked extremely well while having its problems at the same time. My requirements for putting the solution together were cost (it was experimental and needed a good wife acceptance factor so price was all important), fast start-up, easy and remotely controllable, and integrated with my current home stereo and speaker arrangement. I think I achieved this, it cost about 20 quid for the cables and keyboard, the Thinkpad was borrowed from work, I used the Amarok music player which made things very easy, hooked up my stereo remote control to the Thinkpad and integrated it nicely. See the no-expense-spared diagram below...

diagram Click to enlarge.
It's running Fedora Linux on the Thinkpad, with a KDE desktop and Amarok as I mentioned. I don't have a huge music collection so all my mp3s fit on the Thinkpad hard disk. I configured Linux to suspend to RAM and thus boot extremely quickly with auto-login to the KDE desktop and auto-start of various programs including the music player should a cold boot be required. The thinkpad has a serial port so I was able to hook up a serial IR receiver using LIRC to receive signals, with the audio cables going to my stereo using the minidisk port. With no minidisk attached I had spare keys on the remote control (such as play/pause/stop/next/previous) that had no effect when pointed at the stereo while other controls (such as volume) function as expected. This means I can program the spare keys to be picked up by the laptop IR receiver instead, in order to operate Amarok, and with no interference with normal operation of my stereo (so only one remote control needed for the whole solution). A nice bonus of this set up was the ability to display the screen on the television via the thinkpad s-video port. With a radio controlled keyboard and built-in mouse it's easy to sit on your sofa browsing the Internet or e-mailing with the convenience of your TV and wireless broadband.

This is all sounding marvelous and when described like that I wonder why I think about replacing it, but it does have issues. Browsing the web on your TV is great, but it's not particularly convenient when someone else wants to use the TV for its main purpose in life. Niether is it convenient browsing the Internet in 800x600 which is the highest resolution my CRT TV can cope with, then there's the wireless keyboard which is slightly fiddly but I'm just being picky now. The next major problem is a bug with the thinkpad firmware that causes the wireless to stay disconnected after a certain amount of uptime, which is unresolvable and requires a full reboot to temporarily fix until the next time it goes down. Another slight usability issue is user feedback. Browsing songs, playlists, podcasts and all in Amarok is stupidly easy, but controlling from a remote control when you can't see the screen (that was another idea for putting it on the TV) is not easy. It's great you've got the secondary screen you can use if necessary, but if you're trying to do something else or not in the same room it becomes much more difficult.

So, all these little niggles to what is in theory quite a nice setup have got me thinking of a better way to solve my requirements.

Monday, 12 May 2008


I'm sitting here having just started a new blog and wondering whether to write a this is my first post entry or not, cheesy as it may be, here it is...

I've been involved with various blogs over the years but never set one up externally to the company I work for that my overlap with my professional interests. There are, of course, external blogs I've written for including Eight Bar and the blog I write with Beth about our allotment. My personal interests regularly overlap those I have at work, I intentionally use the term professional interests having recently been certified by the British Computer Society as a Chartered IT Professional; I usually describe myself informally at work as A Professional Linux Geek. I currently have some ideas I wanted to write about that don't really fit in any of the places I not-so-regularly write, I hope to log these here and continue to do so in the future.

Picture of GrahamA quick intro to me then. I've already given away I have technical interests and the name of my current employer. I left Exeter University with a degree in Computer Science and Management Science to work at the Hursley location where I established an interest in Linux. This has since been broadened into open source software generally, and open standards and the web. All this has been through a number of interesting positions working in internal support, super computing, and customer facing consulting. I'm currently working for an organisation called Emerging Technology Services that offer great skills to our customers interested in all things new and trendy.

Away from work I like to get out and about. Whether that's playing badminton (I do that a lot), or out with Beth Geocaching, general walking, or working down at our allotment. I like a lot of sports to both play and watch (except football/soccer). I have an interest in music, listening to as much as I get time for and having played the piano since just before I was 5 I think. When all else fails I can usually be found playing the odd computer game on the PC or the Wii, or around the house somewhere doing some DIY.