Jumat, Januari 08, 2010

SheevaPlug - a Debian home server in a wall-wart

Personally I have always been interested in unusual hardware. Coming from a background in electronics, I tend to find "standard" computer hardware rather boring and always like to experiment with stuff that is off the beaten path. So I was thrilled when I found out about the Linux-powered Marvell SheevaPlug and ordered one right away from GlobalScale Technologies for only US$99. My intended project was replacing my ageing and power-hungry home server with this tiny, power-saving device.

System-level decisions

The SheevaPlug (pictured on the left) is an ARM-based computer with a 1.2 GHz processor, 512 MB of RAM and 512 MB of Flash memory, a Gigabit Ethernet port and a USB host connector, all rolled into the tiny form factor of a wall-wart power adapter. It is offered as a development kit in the hope that developers will find cool things to do with it and jump start a new concept called "plug computing". Since its introduction, several web sites have sprung up that provide valuable information to get it up and running for a variety of applications.

Installing Linux on a device like this is nothing like the standard pop-in-a-CD-and-go install process we are accustomed to when installing Linux on a normal PC. For one thing, there is no local user interface in the form of a monitor and keyboard. There is also no CD drive, and the device has no BIOS, instead it has a powerful open-source boot-loader called U-Boot that is quite famous in embedded systems circles.

The SheevaPlug comes with a stripped-down Ubuntu already pre-installed on the Flash drive and, for many uses as a standard file or web server, this may be just fine. But I use my home server as a MythTV backend, and I was surprised to find that the pre-installed Ubuntu does not have any kernel modules installed. This caused my USB TV tuner not to be recognized. I might have been able to hack in the right modules, but since I was going to add an external USB hard drive to store network backups and recorded TV shows anyway, I decided to leave the Ubuntu installation on the Flash drive alone and install a Debian system on the USB hard drive instead.

In case someone would like to install a fresh Ubuntu, it is worth noting that the ARM edition of Ubuntu 9.10 is not compatible with the SheevaPlug processor. Ubuntu 9.10 uses the ARMv6+VFP instruction set, while the SheevaPlug processor can only handle ARMv5 instructions. As far as I know, every other distro with an ARM branch should work though, as does Ubuntu 9.04.

A quick note on running a MythTV backend on the SheevaPlug. While the SheevaPlug has a processor that is quite capable of handling many server-related workloads, it is missing a floating point unit which causes media encoding performance to be pretty poor. In my setup, I only receive over-the-air HDTV, and the incoming MPEG2 stream can be dumped straight to the hard drive without requiring extra encoding. If you were to try to make MythTV on a SheevaPlug record analog TV though, the results would likely be very poor, since the SheevaPlug doesn't have the muscle to handle the required encoding in real time. As always, use the right tool for the task. In my case, not requiring additional encoding, the SheevaPlug handles the backend tasks for both playback of recorded shows and live TV playback with time-shifting just fine.

Installation

After I had already started this project, I found out that there are different ways to install Debian on the SheevaPlug that are probably easier than what I did, but since I didn't use them, I can't comment on them here. Instead I followed the manual bootstrapping procedure described here which is probably harder, but worked well for me nonetheless. The initial step needs to be performed on a different machine that is already running Debian. I didn't follow the procedure to the letter but made some changes to customize my system. For one thing, instead of Debian "unstable", I decided to install Debian "testing". It has a kernel that is recent enough to support my TV tuner (an ATI TV Wonder 600 USB, well supported under Linux), and it is more stable than Debian's "unstable" branch.

I customized /etc/hostname, /etc/network/interfaces and /etc/fstab to fit my network and system. I decided to partition the USB hard drive to have an ext3 system partition, a 1 GB swap partition and use the rest of the drive as a JFS file system that would hold network storage, backups and MythTV recordings. I chose the lesser known JFS file system because it deals well with the large files generated by MythTV and it is well know to be light on CPU usage, a marked advantage for a low-end system like this one. I decided to skip some of the read-only-root recommendations listed in the procedure since I was not using a Flash storage device but a real hard drive.

With my hard drive now set up with the first stage of the bootstrap system, it was time to hook it up to the SheevaPlug and give it a spin. Since I needed to hook up both a USB hard drive and a USB tuner, I had to add an external USB hub to split the one USB connection on the SheevaPlug into four. I do wish the manufacturer would have included a USB hub in the SheevaPlug hardware so more than just one USB connector would be available, but alas, an external hub does the trick.

The SheevaPlug has no connection for a screen, instead the initial console is accessed through a separate USB device connection that provides a virtual serial port. In fact, two virtual serial ports are provided through this connection: one provides JTAG connectivity for very low-level debugging, the other one provides a serial console at 115,200 bps. On a Linux system, these virtual serial ports can be accessed as /dev/ttyUSBx devices, and the serial console ends up being the second device. An inconvenience is that these devices only appear after the SheevaPlug is powered up, so you have to be fast in making your serial terminal connection once the devices appear to be able to stop the automatic bootloader in time.

After changing the bootloader parameters according to the directions in the procedure, I booted and reached a Bash prompt where I could run the second stage of the bootstrap process and the remaining setup. Besides the regular Debian package sources, I also added the debian-multimedia.org repository and was pleasantly surprised how well stocked their ARM repository is. Debian proper has an excellent reputation when it comes to supporting different architectures, but I hadn't expected this to extend to third-party repositories. A MythTV package for ARM was readily available, saving me the lengthy compile-cycle I had been expecting.

Still, I wasn't able to escape compiling entirely. I ran into trouble getting the USB tuner to work, although it is supposed to work just fine under Linux. The kernel always failed to load the firmware, although I had added it according to the instructions, and the kernel could find the file just fine, but then would error out trying to add a duplicate device node. Plugging the tuner in to my netbook running sidux, it worked just fine out of the box. This had me stumped for a while, but eventually I traced the problem down to a difference in how the Debian ARM and x86 kernels are configured. The ARM kernel has an option set to have the I2C device file system compiled into the kernel, while this is a module in the x86 kernel. The USB tuner uses components that connect to each other using the I2C bus, and both the I2C device file system and the TV tuner driver were trying to create device nodes for these components. I solved the issue by having APT download the kernel sources, copying the standard kernel configuration from the /boot directory, changing this troublesome option and recompiling the kernel.

I finished my system by using apt-get to install SSH, Samba, SWAT, MySQL, MythTV, rsync and probably some other stuff I forgot. How to set all these up is beyond the scope of this article and works pretty much the same as on any other Debian system, so plenty of information is available. The only thing that is unusual and that may confuse people is how to run mythtv-setup, since this is a Qt program and the SheevaPlug has no native GUI interface. The answer is that you can use ssh -X to log in to the SheevaPlug with port forwarding, and then when you run mythtv-setup, the user interface will be exported to the machine you're logging in from.

* * * * *
Conclusion


This write-up was intended as a very high-level review of my experience setting up this unusual system, and is by no means a step-by-step walkthrough. There is plenty of detailed information available online on websites such as plugcomputer.org and computingplugs.com that can prove invaluable to get things working on the SheevaPlug. As remarked before, the system is sold as a developer's kit and setting it up is definitely not for the faint of heart or for those who avoid the terminal like the plague. In the end, I had a lot of fun getting this to work and the system is working beautifully. I learned a lot in the process and am amazed yet again at how flexible Debian is as an operating system for just about any computer, even embedded systems like this one.

About the author. Patrick Van Oosterwijck is an embedded software developer who in his professional life spends most of his days designing embedded systems and writing software for micro-controllers, usually on bare-metal devices without operating systems. His interest in Linux started about six years ago and since then he has experimented with everything from SuSE and Ubuntu to Gentoo and Buildroot. The last couple of years he has worked on several projects that apply Linux to embedded systems running on x86, Blackfin and ARM processors.

taken from distro watch issue

0 komentar: