Openmoko development

From Navit's Wiki
Jump to: navigation, search

Compiling Navit from Source

I find it useful to use agps, as it will shorten the time to first fix considerably. you can find the software here .

Compiling on the FreeRunner itself

If you decide to to compile the software on the freerunner itself, don't forget to set the CC flags! :

export CCFLAGS="-march=armv4t -mtune=arm920t"
export CC=`which armv4tl-softfloat-linux-gnueabi-gcc`
./configure
make

Cross-compile on Debian Lenny GNU/Linux

How to cross-compile Navit for the OpenMoko FreeRunner, using a Debian box with the OpenMoko Toolchain. Tested on OpenMoko 2008.12.

On the Debian box install some required development packages:

apt-get install alien autoconf automake autotools-dev build-essential ccache check curl \
fakeroot gettext intltool libgconf2-dev libglib2.0-dev libtool libxrender-dev mtools uboot-mkimage

Install the OpenMoko Toolchain, we decided to make a Debian package from the tarball, so (dis)installation is easy:

wget http://downloads.openmoko.org/developer/toolchains/openmoko-i686-20090323-armv4t-linux-gnueabi-toolchain-openmoko.tar.bz2
bunzip2 openmoko-i686-20090323-armv4t-linux-gnueabi-toolchain-openmoko.tar.bz2
gzip openmoko-i686-20090323-armv4t-linux-gnueabi-toolchain-openmoko.tar
fakeroot alien -d openmoko-i686-20090323-armv4t-linux-gnueabi-toolchain-openmoko.tar.gz
sudo dpkg -i openmoko-i686_20090323-2_all.deb

Edit /usr/local/openmoko/arm/arm-angstrom-linux-gnueabi/etc/opkg.conf and set your preferred OpenMoko repositories. Default is unstable, I used Om2008.8 instead.

Add the following line to /usr/local/openmoko/arm/environment-setup:

export OMTOOL_DIR=/usr/local/openmoko

Install with opkg-target some OpenMoko -dev packages required to compile Navit:

. /usr/local/openmoko/arm/environment-setup
opkg-target update
opkg-target install gpsd-dev
opkg-target install gtk+-dev
opkg-target install libspeechd-dev

Now we check-out Navit sources from the SVN repository:

svn co  svn://svn.code.sf.net/p/navit/code/trunk/navit

Instead of running the traditional ./autogen.sh; ./configure in the navit source tree, we must run the om-conf script, which will modify the automake, autoconf and make files to run into the OpenMoko toolchain.

Because Navit on the OpenMoko FreeRunner requires some configure options, we will pass them to the script. Run om-conf from the directory containing the source tree (not inside it):

om-conf --host=arm-angstrom-linux-gnueabi --enable-avoid-unaligned --enable-avoid-float \
    --enable-cache-size=20971520 --with-saxon=saxon-xslt --with-xslts=openmoko \
    --enable-svg2png-scaling=16,32,48,96 --enable-svg2png-scaling-flag=32,48 \
    navit

In the example above we used some ./configure options, among them:

–with-saxon=saxon-xslt
This is because we have the Debian libsaxon-java package, where the executable is called saxon-xslt instead of saxon.

–enable-svg2png-scaling=16,32,48,96
For each .svg icon, render a png image of the specified size. Images will be named icon_XX_YY.png.

–enable-svg2png-scaling-flag=32,48
Same as above, but only for country flag icons.

It's time to cross-compile:

cd navit
make

TODO: Check for the saxon program, required by the Makefile. Debian has the saxon-xslt program instead, provided by the libsaxon-java package. So you have to modify navit/navit/Makefile.am and change the saxon -snone invocation with saxon-xslt.

TODO: Check compile flags and optimization.

Make an .opk package

The OpenMoko toolchain provides the om-make-ipkg utility. It requires the directory name where to execute the make install and the name of the control file:

. /usr/local/openmoko/arm/environment-setup
om-make-ipkg navit navit-control

The control file is described here.

If you need more control files (e.g. a postinst or alike) you have to tweak with the om-make-ipkg script. Here it is the script I use, it looks for the control files into an opkg directory, so you have to pass just the directory name containing the source tree.

#!/bin/sh -e
 
error_exit () {
        echo usage: $(basename ${0}) [app_dir_name] [ipkg_control_file]
        exit 1
}
 
test x${OMTOOL_DIR} = x && . /usr/local/openmoko/arm/setup-env
. ${OMTOOL_DIR}/arm/scripts/functions
S=${1}
(test x${S} = x || test ! -d ${S}) && error_exit
appname=$(basename ${S})
tmpdir=/tmp/${appname}-ipkg-tmp
test -e "${tmpdir}" && echo Cannot use ${tmpdir} because it already exists. && exit 1
make -C ${S} install DESTDIR="${tmpdir}"
# Copy control files to destination directory.
cp -pr opkg/* ${tmpdir}
ipkg-build -o 0 -g 0 ${tmpdir}
rm -rf ${tmpdir}

Control files and other files are arranged into the opkg directory as needed, here it is an example:

opkg/CONTROL/postinst
opkg/CONTROL/control
opkg/etc/rcS.d/S96overcommit_memory.sh