Archive for December, 2008

Timely blog post fail (Halloween)

Wednesday, December 17th, 2008

Most years, Halloween sort of sneaks up on me — I don’t know what I’m going to do till the last minute, and I don’t bother thinking up a costume till the week before. But then I have to come up with something that I think is clever, or I’ll be sorely disappointed with myself, so I spend an entire day sorting out the minutia of whatever costume I pick. For my space drag costume, that was stringing together CDs with dental floss to make a skirt; for scrabble, it was gluing 225 little squares of felt to my t-shirt.

Which brings us to 2008. My girlfriend being a champion knitter and I being a champion nerd, we spied an opportunity to combine forces wonder-twins-like and make costumes involving knitting and computers.  The thing is, that Venn diagram yields little overlap indeed.  Eventually we settled on a Robot Prom theme — Carly would knit us vintage apparel and I would make it blink. And we even got started almost 3 months before Halloween. It just turns out that 3 months isn’t enough for Robot Prom.

Now, Carly pretty much knew what she was getting into.  She chose challenging patterns and was working uphill against a law school schedule, but she’s knit entire dresses (and sculptures) before.  Me, I’ve programmed plenty, but before August I had never built a single circuit, much less two wearables with multiple inputs and outputs communicating wirelessly.  But that’s what I was going to do, I thought — our costumes were supposed to blink/pulse/whatever slowly and dimly when Carly and I were far apart, and then start spazzing out when we were close together.  We realized that were were basically setting out to make costumes about how we’re an obnoxious, shmoopy couple (with LIGHTS!) but seriously, computers and knitting… there’s just not much you can do.

So Carly started knitting and I started reading and building simple circuits with my new Arduino Diecimila, but the going was pretty slow on my end.  I was making all of the rookie mistakes that anyone new to physical computing makes, including burning out two XBee radios by connecting them to 5 volts (they’re spec’d for a maximum of 3.6) and breaking a multimeter by doing I’m-not-sure-what.  Eventually, realizing that signal strength was not a reliable or fluid indicator of distance between radios, I ditched the S.O.-proximity-meter idea and just decided that our costumes would each have buttons and dials for controlling the light display on the other.  Even so, it wasn’t till a week before Halloween that I had barebones prototypes working and communicating with each other, and those were on breadboards with good old reliable copper wires… I had to make them work on cotton fabric using conductive thread.

We didn’t actually start working on combining our work until the day of our first halloween party, the day before halloween.  I took the day off with the intention of sewing like the wind.  But it turns out I can’t even thread a needle, much less sew, much less sew like something fast or atmospheric.  In a great stroke of luck, my wearable-electronics-ninja friend Grace stopped by for lunch that day, just as I was beginning to get a sense of how totally screwed I was.  She provided such life-saving pointers as: how to keep traces of conductive thread from touching; if the thread touches your skin you will short your circuit; omg you’re totally screwed.

For the rest of the day, Carly and I sewed until our fingers shook and our eyes wouldn’t focus, but we only finished most of her circuit and almost none of mine before it was past time to go to the party.  We knew we had to stop there, but we couldn’t even tell if hers worked at all, because it wasn’t designed to do anything without input from mine, so I quickly reprogrammed it to simplify its functionality (just one tri-color LED in her corsage, and no user control) and cut out the radio entirely. And by god, gutted as it was, it worked.  The little light in Carly’s (beautiful, expertly knit) corsage pulsed different colors.  She didn’t look like a robot, and I didn’t look like anything, but something worked.  So we went to the party and looked like this:

Our sad unfinished costumes at the NYU Law Fall Ball (my sign says Ambitious Costume Fail)

Carly’s corsage went nyeer-nyeer-nyeer (video)

But that’s about it.  The next day (Halloween), Carly spent all day sewing again, and I joined in as soon as I could, but by the time we had to leave, we were still missing pieces from the costumes, and the radios weren’t working (at one point I thought I actually destroyed my whole costume by connecting my Lilypad to 9v, but I got lucky).  So again we had to cut back on functionality, but at least this time we both had blinky lights and buttons and knobs to control them.  Also, we bought some silver face paint so that when people asked us what we were, we could say “Robot Prom!” without having to put “well, we were supposed to be…” in front of it.  All told, it still didn’t make any damn sense but at least it looked like a Halloween costume:

Our much-improved costumes of Halloween proper

We lost a lot of sleep, I broke some electronics, we had to explain our costumes to everyone, and by the end of the process we weren’t having any fun at all.  But on the other hand I got this sweet vest out of the deal and we didn’t break up.  And isn’t that what really matters?

Some more pictures:

The table covered in all our crap Furious sewing Testing Carly\'s corsage

The table covered in all our crap

Furious sewing

Testing Carly’s corsage

Android on Openmoko Freerunner (Ubuntu 8.04 Hardy Heron)

Monday, December 8th, 2008

Note: these instructions may be out of date.  Consider trying whatever instructions are posted on the Android-on-Freerunner page at openmoko.org.

I got Android working (as far as it goes) on my Freerunner using Sean McNeil’s kernel and filesystem images.1  These instructions are intended for the average Ubuntu users who wants to see the magic of Android on his/her phone with as little futzing about as possible.

Step 1: Partition your MicroSD card

You need to put a FAT (DOS) partition and an ext2 (or ext3) partition on your MicroSD card in order for Android to boot properly.  If it’s possible to do this by plugging your Freerunner into USB, I don’t know how.  So you will need some other way of reading your MicroSD card with your PC, for example a MicroSD to SD adapter (if your PC has an SD card reader built in) or a MicroSD to USB adapter.  Once you have one of these…

  1. Insert your MicroSD card into your card reader, and your card reader into your PC.
  2. If there is a filesystem on your MicroSD card already, it may auto-mount.  You must unmount the drive(s) on the card before proceeding.  You can do this either through Nautilus (right-click the drive and click “Unmount”) or from the command prompt:sudo umount /path/to/disk/2

    Partitions (old or new) may remount themselves after you add or remove them using fdisk (below). If so, you will have to unmount those as well.

  3. Run fdisk: sudo fdisk /dev/[device number]
  • Enter “p” to display existing partitions and their sizes.
  • For each existing partition, enter “d” and then the partition number to delete it.
  • Enter “p” again to make sure there are no partitions left on the card, and note the total number of cylinders on the card.
  • Create the first partition: enter “n” (new partition), then “p” (for a primary partition), then “1″ (for the first partition), then “1″ (start at the first cylinder), then enter half of the total number of cylinders (to make the first partition half the size of the card).
  • Create the second partition:3 enter “n” (new partition), then “p” (for a primary partition), then “2″ (for the second partition), then accept the defaults for the start and end cylinders.
  • Enter “p” to make sure that both of your partitions have been created.  If they have not, make sure you have unmounted all of the existing partitions and add any missing partition according to #7 and/or 8 above.
  • Enter “w” to write the partition table, then “q” to quit.
  1. Create filesystems on the new partitions:
  • sudo mkfs.vfat /dev/[first partition device number]
  • sudo mkfs.ext3 /dev/[second parition device number]
  1. If any of the new partitions are mounted, unmount them (see #2 above).
  2. Put the MicroSD card and battery back into your Freerunner and close it up.

Step 2: Download the firmware image files

Android requires three image files: the kernel, the root filesystem, and the bootloader.4  For now, the best kernel and rootfs images to use are those packaged by a developer named Sean McNeil.  The latest files can be found here.  I provide links to the existing images below, but the filenames may change.  The Qi bootloader image is packaged by a user named Andy and is available here (for Android, use the file that begins “qi-s3c2442-”).  Again, the names and locations of these files may change as development progresses, so if these links break, just seek out the most recent files.

  1. Download the kernel
  2. Download the root filesystem
  3. Download the Qi bootloader

Step 3: Download and set up the “neotool” flash utility and dfu-util

NeoTool is a handy, lightweight graphical tool for flashing images to your Freerunner’s memory.  It uses a command-line utility called dfu-util to do this, so you’ll need that too.

  1. Download the NeoTool script (this is just a text file, so you may want to right-click and “Save Link As…”)
  2. Download dfu-util
  3. Make both files executable—from the command line, navigate to the directory where you downloaded them and enter: chmod +x neotool dfu-util
  4. Run NeoTool—in the same directory, enter: sudo ./neotool
  5. In the NeoTool menu, select “Setup NeoTool”, then “Locate dfu-util”.  Find dfu-util on your drive and click “OK”.  Click “OK” again to return to the main NeoTool menu.

Step 4: Flash the images to your Freerunner with NeoTool

Now we will load the images into your Freerunner’s memory.

  1. Make sure your Freerunner has a decent charge in its battery, is turned off, and is disconnected from your PC.
  2. Boot the Freerunner into its NOR boot menu: while holding down the AUX (side) button on your Freerunner, press and hold the power button until a menu appears.5
  3. Attach the Freerunner to your PC via USB.
  4. From the NeoTool menu, select “Flash your Neo”.
  5. Select “Root-Filesystem”, “Kernel”, and “Bootloader” from the list.
  6. NeoTool will ask you to locate the image file for the Root FS first.  Locate the file (androidfs.jffs2) on your drive, select it, and click “OK”.
  7. Next, do the same for the kernel (uImage-android).
  8. Next, do the same for the Bootloader (NeoTool will ask you for UBOOT even though we are using Qi).
  9. Click “OK” through the scary message.
  10. Wait for NeoTool to finish flashing the firmware (you can follow the progress in the terminal from which you started NeoTool).
  11. When NeoTool has finished doing its thing, press the AUX button on your Freerunner until “Power off” is highlighted.  Press the power button to select it and power down your Freerunner.
  12. Unplug your Freerunner from USB power.

Step 5: Boot into Android

  1. Hold down the Freerunner’s power button until the screen’s backlight turns on (the screen will still be black) and then for a few seconds more.
  2. Release the power button and wait for Android to load.
  3. Android loads!  Hurrah!  This is way better than Om2008!  It found my network!  Calling works!
  4. Oh look, it’s going into suspend.  Wait, why does it look like nuclear winter?  Why is the screen white?  Why doesn’t the power button do anything?  I guess I’ll take out the battery.  (NB: suspend doesn’t work yet.)

I hope this helps someone.  Feel free to send/post feedback.

  1. Despite the Freerunner’s agonizing early history, there is still a very active community developing and testing the platform, and though none of the many distributions available for the platform are ready for primetime, that community has actually accomplished a lot.  Unfortunately, relatively little effort is dedicated to “bringing up the rear,” i.e. explaining clearly to less sophisticated users how to do all of the fun stuff the hardcore developers are doing.  Sean McNeil’s kernel and filesystem images go a long way toward making Android accessible to the average user, but his instructions for installing them do not work for me, and I couldn’t find any that did.  I pieced together these from 3 or 4 different sources, none of which contained the whole answer.  I hope they’ll be useful to someone. []
  2. When I mounted the MicroSD card using an SD adapter, it mounted as /dev/mmcblk0 and I unmounted the drives using: sudo umount /dev/mmcblk0p*. When I used a USB adapter, it mounted as /dev/sdb and I unmounted the drives using sudo umount /dev/sdb*. Yours may mount differently. Be careful that you have correctly identified the SD card and not some other more important drive on your computer. []
  3. Again, you may need to unmount the first partition before you can do this. []
  4. Supposedly you can use the default bootloader, u-boot, to load Android if you modify its environment to allow for larger kernels.  I tried this several times and was unsuccessful.  I have had no issues using Qi and it is reportedly faster. []
  5. This menu will only be displayed for 30 seconds, and then the phone will turn off again.  If this happens before you begin flashing the firmware, just repeat this step. []