Plug Computer Notes

[Plug computers] (the handout from Akkana Peck's Plug Computer talk)

Hardware

Some specific models

You might hear them called "Sheevaplugs". That's a specific model, but you can't google for "plug" so try "sheevaplug" when googling.

I've used the Ionics PlugComputer plus (works well, generally reliable), GlobalScale GuruPlug (requires an external $40 JTAG connector, comes with no documentation or support and has a reputation for flaky hardware), and the Seagate Dockstar (a great bargain, less capable but extremely inexpensive).

Getting started

Ideally, use a serial/JTAG connection.

screen /dev/ttyUSB0 115200

Screen is a pain, though -- it likes to restrict the page to only 24 lines and there doesn't seem to be any way to get out of that mode. I'd love to hear about a better serial program, or a way to get screen out of 80x24 mode.

Log in as root. Common passwords: nosoup4u, root (check your manufacturer's documentation or website).

You're in Busybox, so you get a basic shell and most of the simple Linux shell commands you're used to.

Since they're marketed as servers, most of them come with some basic services already installed, like a mail server and web server.

Most plugs are Debian or Ubuntu, so you can install new software easily with the usual Debian commands like apt-get.

Dockstar

It's sold as a cloud file server using some kind of proprietary service; if you let it come up on a regular network it'll register with their servers and might not let you log in locally any more, so try it first on a disconnected network, just in case.

More information at PlugApps.com

But how do you find it on a network? The plug probably got an IP address from your DHCP server, so your task is to find it. Try nmap:

# nmap -e eth0 -sP 192.168.1.0/24
but that will only find it if it's doing something to generate traffic. Or you can write a simple script that pings every address. Here's mine: ipsearch.

Then you can ssh in, ssh root@nn.nn.nn.nn, with root password stxadmin.

If something goes wrong and you can't SSH in, you'll have to make a serial cable from a Nokia cable (see the PlugApps.com website).

Unbricking

Bricking: means turning hardware into something non-functional.

(No, it doesn't have to be permanently nonfunctional. In the plug computing world, "unbricking" is a very common term for a very common problem.)

Different on different machines. See my Linux Planet article, Un-Bricking Linux Plug Computers: uBoot, iBoot, We All Boot for uBoot or my poorly organized brain-dump on Building and installing a new kernel for a SheevaPlug.

Writing software for plugs

You can write scripts in Python, Perl, Ruby, sh etc.

You can usually apt-get any libraries normally available on Debian (e.g. python-serial, bluez).

In C, you can apt-get install gcc and the other development tools you need, and compile on the plug ... if you're extremely patient.

If you're impatient, you need a cross compiler. Distro ARM cross-compilers only support ARM v7, so you can't just apt-get or yum install a compiler.

Most popular cross compilers: Code Sourcery and EmDebian.

For kernels, see my LinuxPlanet article on Cross-compiling Custom Kernels for Little Linux Plug Computers. One catch: not all drivers are open source, so it's difficult to build a kernel that has e.g. client wi-fi support.

The kernel technique doesn't work for compiling other packages (without a lot of extra work setting up build flags) -- so use Scratchbox, which sets up an ARM virtual machine.

Some easy project ideas

Network router (the default config on many plugs), web server, mail server, file server, music or media server, Google CloudPrint.

Serving web pages

You can apt-get install apache, lighttp or any web server you want. But if your needs are simpler than that, you can use a tiny Python web server. The one I used in the talk is simpleserver.py.

Talk to a webcam

You need a kernel with a webcam driver. Recent sheeva-with-linux.com kernels will work.

There are lots of streaming webcam video servers, and I don't know enough about them to recommend one. They tend to have 65 dependencies including stuff like mysql, more than I want to install on a plug.

To take still pictures, here's a lightweight solution:

fswebcam --device /dev/video0 -S 1 output.jpeg

Talk to an Arduino

Reqires a kernel with an FTDI driver. Again, recent sheeva-with-linux.com kernels work.

In Python, use python-serial to talk to the Arduino:

apt-get install python-serial
and use /dev/ttyUSB0 (or possibly 1 or more).

For my light sensor example, I used the light sensor from Adafruit and the circuit from the LadyAda photocell tutorial.

Then I wrote this Arduino sketch to print out the values: lightsensor.pde. You can use that in the Arduino environment, or compile it from the commandline with this Arduino Makefile (you'll still need the Arduino libraries somewhere on your system).

With that running on the Arduino, I run this Python script on the plug (or any other Linux machine): readsensor.py.

I used the same technique to talk to an ultrasonic sonar rangefinder plugged in to the Arduino. Here's the Arduino sketch I used: rangefinder.pde, and here's its Arduino Makefile.

The scripts and HTML files

Here are all of the scripts that I used on the plug.

So what's the point?

If you don't care about most of those, a plug might not be the best choice. A cheap netbook isn't much more expensive, includes a screen and keyboard and a much faster CPU, and is x86 compatible so you don't have to mess with cross-compilers or kernels missing drivers.

Plug computers aren't the best setup for everyone -- but the do have size and efficiency advantages that a netbook can't beat.