Digital Finds

joseph dot reeves at thehumanjourney dot net

Compile an application for the FreeRunner like an archaeologist:

May 23, 2008 by Joseph Reeves

In a recent email conversation with Michael Shiloh (much of which ended up here) I commented that the mobile hackers currently working on the FreeRunner wouldn't be too impressed with my compiling achievements. Michael pointed out the other users of the device and made me realise a couple of things; the first was that if I can follow the instructions, anyone could, and the second was that there could well be people out there that would benefit from being walked through an example and shown how easy it sometimes is.

This then, is how an archaeologist compiled an app for the FreeRunner. Flames in the comments please. I'm using Ubuntu 7.10 throughout this process because 8.04 suffers a show stopper of a bug.

Note: I am not a computer programmer; the hacks described herein could lead to the same mistakes that happened last time somebody fiddled with something.

First things first; what to compile? I thought about applications I was using at work and which ones were neither included with the FreeRunner and were simple enough for me to get running. In the end I decided upon MTR; I'd been using it a small amount lately and thought that on a device with such great connectivity options it could be a useful debugging tool.

To start then, you need to grab the most recent source code, save it to your home directory and think about how to get it working on the FreeRunner. The documentation for such things is great; I simply read the toolchain page from top to bottom.

If you're using Ubuntu 8.04, use the provided command to install everything you need. I'm not, so I'll just install what it tells me to and cross my fingers:

joseph@joseph-work:~$ sudo apt-get install gcc g++ autoconf automake binutils libtool libglib2.0-dev ccache libxrender-dev intltool libgconf2-dev mtools

I've already done some compiling on this machine, so there's some stuff there already, there's also some errors about unauthenticated packages; let's hope I don't get a rootkit! I'm an archaeologist though, so I'll ignore best practice procedures, fudge my way through, install any missing things when I get moaned at and simply hope that it all works.

So far so good, we're on to the next step. I'm using a 32 bit machine, so I do the following:

joseph@joseph-work:~$ mkdir ~/sources
joseph@joseph-work:~$ cd ~/sources
joseph@joseph-work:~/sources$ wget
=> `openmoko-i686-arm-linux-gnueabi-toolchain.tar.bz2'
Connecting to||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 47,964,117 (46M) [application/x-tar]

100%[====================================>] 47,964,117 426.40K/s ETA 00:00

15:29:02 (444.41 KB/s) - `openmoko-i686-arm-linux-gnueabi-toolchain.tar.bz2' saved [47964117/47964117]


Now, we're told that this has to go where it wants to go, so we move to / and extract it. It's going to go into some dangerous and scary places, so we do it as sudo (let's hope it don't break nothing). Of course, if you run the command provided in the wiki, it won't work:

tar -xjvf ~/sources/openmoko-XYZ-arm-linux-gnueabi-toolchain.tar.bz2

So just copy in:

tar -xjvf ~/sources/openmoko-

And hit tab; it'll auto-complete the file name for you. On my system, we end up with:

joseph@joseph-work:~$ cd /
joseph@joseph-work:/$ sudo tar -xjvf /home/joseph/sources/openmoko-i686-arm-linux-gnueabi-toolchain.tar.bz2

And a lot of satisfying text scrolls past and we're almost there. We're told that we need to set up our environment properly every time we want to use the tool chain by running:

. /usr/local/openmoko/arm/setup-env

But we're not ready for that yet; we first need to get the mtr source code extracted. I saved it to my home folder, so I just opened it up in Dolphin, right clicked on the mtr file and selected "extract here". I go back to my Konsole, it's still pointed at / and I want to go home, so I:

joseph@joseph-work:/$ cd ~

Ok, let's see if we can get this to work!

Following the instructions we set our environment:

joseph@joseph-work:~$mtr-0.73$ . /usr/local/openmoko/arm/setup-env

We cross our fingers and run the Openmoko conf tool:

joseph@joseph-work:~$ om-conf mtr-0.73
Source directory: /home/joseph/mtr-0.73
Extra configure arguments:
automake (GNU automake) 1.10
Written by Tom Tromey
and Alexandre Duret-Lutz .

Copyright 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
AUTOV is 1
NOTE: Executing autoreconf --verbose --install --force -I/usr/local/openmoko/arm /arm-angstrom-linux-gnueabi/share/aclocal/aclocal-1 -I /usr/local/openmoko/arm/a rm-angstrom-linux-gnueabi/share/aclocal/aclocal
autoreconf: Entering directory `.'
autoreconf: not using Gettext
autoreconf: running: aclocal --force warning: macro `AM_PATH_GTK_2_0' not found in library warning: macro `AM_PATH_GTK' not found in library
autoreconf: tracing
autoreconf: not using Libtool
autoreconf: running: /usr/bin/autoconf --include=/usr/local/openmoko/arm/arm-ang strom-linux-gnueabi/share/aclocal/aclocal-1 --include=/usr/local/openmoko/arm/ar m-angstrom-linux-gnueabi/share/aclocal/aclocal --force --warnings=cross error: possibly undefined macro: AM_PATH_GTK_2_0
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation. error: possibly undefined macro: AM_PATH_GTK
autoreconf: /usr/bin/autoconf failed with exit status: 1
FATAL: autoreconf execution failed.

It failed! It doesn't seem to like AM_PATH_GTK as found in Let's open up that file in kate and control-F for AM_PATH_GTK:

if test "x$WANTS_GTK" = "xyes"; then
if test "x$WANTS_GTK2" = "xyes"; then
AC_MSG_WARN(Building without GTK2 display support)
AC_MSG_WARN(Building without GTK+ display support)

I wonder what would happen if we commented out everything there except for the AC_DEFINE(NO_GTK) bit? Do that by adding a # to the start of every line you want rid of. Save the file, go back to Konsole, push the up arrow key and hit enter. It does much better, but dies with a:

/home/joseph/mtr-0.73/configure: line 6453: syntax error near unexpected token `fi'
/home/joseph/mtr-0.73/configure: line 6453: `fi'
FATAL: oe_runconf failed

Now, that fi is visible just below the section we commented out. Let's get rid of it and try again...

It completes without error! We're really making progress through this wiki page now! We're told that we just need to change to the directory and run make:

joseph@joseph-work:~$ cd mtr-0.73/
joseph@joseph-work:~/mtr-0.73$ make

And it again finishes without error; all this computer hacking is making me thirsty!

There's a load of text in the wiki now... We're not here to read, however, we're here to kludge this thing together! Let's get it packaged into the portable .ipk format:

joseph@joseph-work:~/mtr-0.73$ cd ~
joseph@joseph-work:~$ om-make-ipkg mtr-0.73
make: Entering directory `/home/joseph/mtr-0.73'
Making install in img
make[1]: Entering directory `/home/joseph/mtr-0.73/img'
make[2]: Entering directory `/home/joseph/mtr-0.73/img'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/home/joseph/mtr-0.73/img'
make[1]: Leaving directory `/home/joseph/mtr-0.73/img'
make[1]: Entering directory `/home/joseph/mtr-0.73'
make[2]: Entering directory `/home/joseph/mtr-0.73'
test -z "/usr/sbin" || /bin/mkdir -p "/tmp/mtr-0.73-ipkg-tmp/usr/sbin"
/usr/bin/install -c 'mtr' '/tmp/mtr-0.73-ipkg-tmp/usr/sbin/mtr'
make install-exec-hook
make[3]: Entering directory `/home/joseph/mtr-0.73'
chmod u+s /tmp/mtr-0.73-ipkg-tmp/usr/sbin/mtr
make[3]: Leaving directory `/home/joseph/mtr-0.73'
test -z "/usr/share/man/man8" || /bin/mkdir -p "/tmp/mtr-0.73-ipkg-tmp/usr/share/man/man8"
/usr/bin/install -c -m 644 './mtr.8' '/tmp/mtr-0.73-ipkg-tmp/usr/share/man/man8/mtr.8'
make[2]: Leaving directory `/home/joseph/mtr-0.73'
make[1]: Leaving directory `/home/joseph/mtr-0.73'
make: Leaving directory `/home/joseph/mtr-0.73'
Packaged contents of /tmp/mtr-0.73-ipkg-tmp into /home/joseph/mtr-0.73_0.1_armv4t.ipk

Now it tells me that its created the ipk file. Let's see if it really works by copying the file to the phone. First I have to get my USB networking working as the phone was just sat on my desk:

joseph@joseph-work:~$ sudo ifconfig usb0
[sudo] password for joseph:
joseph@joseph-work:~$ scp mtr-0.73_0.1_armv4t.ipk root@
root@'s password:
mtr-0.73_0.1_armv4t.ipk 100% 37KB 36.7KB/s 00:00

We just need to ssh in and get it installed:

joseph@joseph-work:~$ ssh root@
root@'s password:
root@om-gta02:~# opkg install mtr-0.73_0.1_armv4t.ipk
Installing mtr-0.73 (0.1) to root...
Configuring mtr-0.73

Scary stuff; it doesn't seem to have failed so far... What does opkg tell us about it:

root@om-gta02:~# opkg info mtr-0.73
Package: mtr-0.73
Version: 0.1
Status: install user installed
Architecture: armv4t
Installed-Time: 1211303925


Not much meta data there! Perhaps that was in the bit we skipped through earlier? Never mind that though, lets run it:

root@om-gta02:~# mtr

I won't show the output, because you don't need to be viewing the internals of our network, but it seems to work! It's too cramped to run on the included terminal, but it's working at least.

And if I can get that far anyone can.

Post a Comment:
Comments are closed for this entry.