Sunday, September 28, 2008

Gumstix to go

I had started tampering with Gumstix sometime back, but had run out of spare cycles to devote to it. This weekend, I had unexpected access to time and I figured I'll start playing with my tiny linux machine again. However, I realized that 3 months can be long enough time to entirely forget all the steps I needed to take to have the thing going. So I am back at square one, re-learning everything. So, now I think would be a good time to permanently document my steps so that I can do this again much faster.

I have to hand it gumstix, though. As an embedded development system, it's far easier to get up and running (especially given the price!). Richard Stallman may be on to something :)

To get things started, connect to the middle port on the console-lcd-vx board. If using a usb-to-serial dongle, typically /dev/ttyUSB0 is used with kermit (kermit -l /dev/ttyUSB0)

The board comes with OpenEmbedded (OE) loaded on it. The build system with OE seems rather challenging and daunting. Instead, I prefer buildroot, which seems to use simply the make file syntax. Since this is more "standard" linux fare, I believe working with this will be easier. Though ofcourse I'm sure that a few things I want will be implemented / documented for OE and I'll have to fight to get those working in build-root. But that seems an acceptable compromise.

Download and create build-root environment according to the instructions at the Gumstix buildroot wiki

  • The Gumstix OE Quickstart page is even quicker and will get you started with a hello-world app really quickly. HOWEVER, getting gdb support is tricky. If OE is still the way you want to go, then do everything EXACTLY as laid on this page, and no problems should happen. I have to thank my current company for this discipline. A few years ago, I would've been experimenting and trying to figure out how and why the particular steps are important. Not any more. Not after working at the place I work for a year. I have come to respect the brain-deaded-ness of it all: experiment at your own peril and waste precious time while others who know little off the beaten path try to vainly help you. I have had enough. Or I've just gotten wiser. Or just plain older. But I'm ranting.


The following instructions apply to build-root and getting gdbserver up and running. You will need to replace the default OE kernel and rootfs images with the ones buildroot generates after doing the following:
Follow the instructions EXACTLY.
  • Get gdb / gdbserver compiled for the target. Follow instructions here

    In this example the program to debug is named ‘hello’:

    • Use ‘make menuconfig’ in the buildroot to enable building both GDB server and GDB client on host
    • cd ~/gumstix/gumstix-buildroot
    • make menuconfig
    • make
    • flash the new rootfs to the gumstix using these instructions
gdb cannot run on serial as it is being used for console. Connect the ethernet board.
  • once gumstix boots up, run ifconfig to see ip address
  • run ‘gdbserver localhost:2000 arm_executable’ on the gumstix; (port need not be 2000)
run gdb from directory ‘buildroot/toolchain_build_arm_nofpu/gdbclient-6.3/gdb/’ with options ‘--symbols=hello hello’
  • alias gumstix-gdb='~/gumstix/gumstix-buildroot/toolchain_build_arm_nofpu/gdbclient-6.4/gdb/gdb'
  • cd ~/helloworld
  • gumstix-gdb --symbols=./hello ./hello
  • (gdb) set arm abi AAPCS
  • (gdb) target remote 192.168.0.3:2000 # where 192.168.0.3 is the IP of my gumstix as obtained by ifconfig
The 'set arm abi AAPCS' is really important otherwise gdbserver tends to SIGILL at a breakpoint. Details here
  • Transfer image to gumstix using instructions from here. Hopefully you'll have done things correctly and the board isn't bricked. Also, hopefully you actually do have gdbserver / gdb going correctly.
Now that build system and debugger are in place, time to make the first program. Follow instructions for the Hello world example here

Note: GUMSTIX SVN username = password = root

No comments: