Wednesday, March 10, 2010

Unbricking a bricked SheevaPlug

My development PlugPC (SheevaPlug) arrived last week, and going back over previous postings I attempted to follow my own guidelines and setup my development environment (boot from USB drive, setup Mono, IronPython etc.). The first difference between the TonidoPlug and the SheevaPlug is that the SheevaPlug really is a developers tool and so you have to do some more basic things that you don't need to do on the TonidoPlug.

My first job was to get the SheevaPlug (SP) to boot from an external drive (as it only has 500Mb onboard). Actually, this time I tried to set it up to boot from an SDHC card, which the TonidoPlug has no built-in support for. To cut a long story short, the installation went smoothly, but then the SP died a few days later - removing the SDHC card did not cause the SP to boot from the internal drive (because I did not know how to reconfigure UBoot - see below - back to the correct configuration) - it was officially 'bricked'. The SDHC did seem to get very hot so maybe it literally got fried. But I also remembered that SDHC cards only have a limited number of rewrite cycles, something like 1000000. This seems like a huge number, but maybe given how active your average OS is, SDHC just isn't a good choice for running an OS from... or maybe I just had a faulty card. Anyway, OfficeMax gave me my money back and I took advantage of a sale they were having in USB storage. For the price of the 16GB SanDisk SDHC Card I got 48Gb (16, 16, 8, 4) worth of Toshiba Transmemory USB flash storage - a great deal (I thought). However, after a 4-5 attempts at building an OS on the Toshiba flash storage I still could not get the SP to boot from it... from the lack of LED activity on the Toshiba I guess it was something to do with power management... but whatever it was, it didn't work. My last attempt was with a SanDisk Cruzer 16Gb USB Flash drive; this is what I use without trouble on my TonidoPlug. As with my TonidoPlug, the process to install Ubuntu Jaunty onto the Cruzer drive went flawlessly. So, save yourself the trouble an get one of these right off the get go.

The SP comes with a serial port (via a micro-USB connection), and so initial configuration is done through this port. Again I used PuTTY, but selected the Serial Port option rather than SSH which I've been using to talk to my TonidoPlug. Once you have your SP connected to your desktop, launch a PuTTY serial connection (the default port for my SP was 'COM4', but yours might be different. If you're using Windows just open your Device Manager (under Control Panel -> System) and check to see was Ports are available - your SP should be connected via a USB Serial Port), and start pressing the space bar. You have to get your timing right, as what your trying to do is interrupt the SP boot process with the keyboard presses. If you're successful you'll see 'Marvell>' at the prompt. As an excercise, enter 'reset' and then you get to watch the whole boot process in your PuTTY serial window - again press the spacebar at the appropraite moment to stop the SP booting into Ubuntu.

The boot process is directed by UBoot, so one of your first chores is to make sure you have the latest version of UBoot installed. The instructions here, worked perfectly for me. I went the USB route rather than the TFTP one, and got my Uboot upgraded to version 3.4.27.

The next stage was to build a new OS on my Cruzer drive and configure UBoot to boot from it. The instructions here, again, worked fine for me... although they failed a number of times when I was attempting to do the same thing with the SDHC ccard or the Toshiba flash drive.

So unbricking my bricked SP was not too much trouble as long as I used a compatible USB flash drive.

In all my messing around I also realized that I did not need to go through the process of building Mono and IronPythong from scratch. So, once I had my SP working again, I connected to it via SSH and executed the following commands:

>>apt-get update (this updated the repositories)
>>apt-get dist-upgrade (to make sure my OS was up-to-date)
>>apt-get install ironpython

This last stage installs Mono version 1.9.1 and IronPython 1.1.1. These are earlier version than those I was using on my TonidoPlug, but I'm hoping they're good enough to be going on with. The advantage is that I can rely on apt-get to update them whenever updates are available in the repositories, rather than mess around maintaining them myself (unless I find I have problems and am forced to - but let's not do extra work unless we have to). The other advantage is that I can run IronPython with 'ipy' from any directory rather than 'mono ipy.exe' from the IronPython-2.6 directory like before.

The first thing I noticed is that the IronPython 1.1.1 interactive mode is rather fickle (don't go using the up and down cursors thinking you can scroll through past entries - it doesn't work, and just corrupts the current line, so even if you then enter a legit command it fails), but you get used to it... just be very precise with your typing!

Anyway, I now have a SheevaPlug set up and ready to go. The previous tests regarding Serial Port access, Amazon SimpleDB access, etc., all worked fine, ALTHOUGH you must use a POWERED USB hub to connect the XBee coordinator and the USB drive hosting the OS.

We're ready to move forward once again... keep on pluggin'