Cliff Hacks Things.

Monday, June 26, 2006

ASCIIvision

After a lot of tinkering, I've got the Gumstix talking to my CMUcam2.

I started out working with CMU's Java interface code, but it's abysmal. It's like an exercise in how not to write Java. So, scratch that.

I worked in C for a bit, thinking that it would be nice to eliminate the JVM from my cramped root filesystem. Then, I remembered how much IO programming in C can suck, and went back to Java.

So, now, I've written my own interface library for the CMUcam. I quickly got tired of printing numbers and guessing whether or not I had configured the camera properly; I wanted an image, dammit. But on a tiny device, with no display, how do you generate images?

Using ASCII, of course!

Thursday, June 22, 2006

Gumstix -- first experiences

I've finally given in and bought a single-board computer from Gumstix. It's amusingly dinky.



That thar's a 400MHz RISC machine, with 16MB of on-board Flash, 64MB of RAM, and Bluetooth (with antenna attached). It comes out of the box running Linux. I have daughterboards that add RS-232-level serial ports, USB client, and a CompactFlash slot for disk or WiFi.

I've been working with the board for a few days now, and thought it time to post my first experiences.

All in all, I am damn pleased. I haven't had this much fun with an embedded system in years. However, there's a topic that deserves an initial rant.


The Support Rant


First thing: if you want solid support or well-organized technical information, look elsewhere. Gumstix, the company, has no obvious contact information; when I finally tracked down an email address, they redirected me to a public mailing list.

Ah, yes, I remember what running Linux is like.

The good news is, the mailing list is very helpful. I'm sure my questions had been asked a dozen times before, but I received not a single RTFM.

Which is fortunate, as there's no M to FR -- there is no manual. All documentation on the Gumstix and accessories, from features and drivers to pinouts and compatibility matrices, is hidden in a Wiki. And hidden it is. This is one of the worst-organized Wikis I have ever seen, with several pages on any given topic, each of which claims to be canonical and all of which are wrong.

Example: there are pages in the Wiki that discuss setting up the Gumstix development environment on Mac OS X. Don't try it. They're out of date by nearly two years, and will have you check out a branch of the repository that's about that old. Not only do the directions not work, you'll be stuck with an ancient system with very few of the optional packages available.

Example: the PXA255, the processor at the heart of this board, has four UARTs. I remembered this from hacking Linux on my PXA255-powered iPaq years back. You can get various combinations of these UARTs on various daughterboards, sometimes with level-shifters, sometimes at TTL level. However, the actual online store, where you would go to buy such things, doesn't have this information. No, you must dredge the Wiki.

This is includes pretty damn basic details, like which UART the onboard Bluetooth is attached to. (It's the BTUART pins, for those arriving here by Google, but the HWUART driver, routed to the BTUART pins. So, by default, both the HWUART and BTUART are occupied. You can, however, route the HWUART to auxiliary pins.) Likewise, I had to trace schematics to determine which UART their optional GPS would occupy. (It's the STUART, routed through the FIR pins.)

And, here's the kicker: my original board configuration wouldn't have worked, though there's no information on the website to indicate this. Enabling both Bluetooth and the CompactFlash board means the HWUART can no longer be used for anything but Bluetooth. Add the GPS module and I'm down to a single serial port -- not enough for what I'm doing.

Fortunately, I'm pretty familiar with the PXA255 and can trace schematics. Otherwise, this would have been a rude surprise.

Okay, now that that's out of the way:

The Good Stuff



Getting into the Gumstix via Bluetooth from my Mac was trivial. I had a wireless console in well under five minutes. It goes a little something like this:
1. Pair with the Mac from the Gumstix side, since the Gumstix (by default) can't interactively request a PIN. Use hcitool scan to find your Mac, hcitool cc [ your address ]; hcitool auth [ your address ] to pair; the default PIN is 1234.
2. On the Mac, open Bluetooth Preferences, find the Gumstix in the Devices tab, and click Edit Serial Ports.
3. Accept the defaults it offers you.
4. Connect from your favorite terminal emulator; the port is named (by default) Gumstix-1, or /dev/tty.Gumstix-1, to you Unixy types.

All in all, the quality of the Bluetooth support (via BlueZ) blows my mind.

The Gumstix guys have also put together a very nice Linux distribution. It smells like it's based on Familiar -- which is fine by me, having used it in the past. If you have a recent Linux box, you are a Subversion-checkout away from cross-compiling your own images to the board.

They've even got interactive menus for selecting what packages and options to compile into the image; their scripts will go out and fetch the requisite sources and compile everything automatically. Very slick, and it works far better than the buildroot for Familiar did. I had JamVM for Java and the GNU Classpath libraries installed with almost no work at all.

Now I just need the parts to interface this bad boy to the robot....