This is an old revision of the document!
Table of Contents
Cross compile per OpenMoko
Per compilare un'applicazione per il FreeRunner su sistema operativo OpenMoko possiamo scegliere tre strade:
- Qemu. È possibile eseguire l'intero sistema opertativo OpenMoko sotto Qemu, tuttavia l'hardware GTA02 (FreeRunner) non è pienamente supportato. Inoltre le utility fornite a corredo dell'emulatore sono scritte per il GTA01 (Neo1973), pertanto la strada per avere l'emulatore funzionante non è semplice. L'emulazione del GTA01/GTA02 non è inclusa nella distrubuzione ufficiale Qemu, bisogna scaricare i sorgenti dal repository SVN apposito.
- MokoMakeFile. Si tratta di uno script che provvede a scaricare e configurare un ambiente completo derivato da OpenEmbedded. Il progetto è considerato obsoleto.
- Toolchain. Questa è la strada consigliata sia per lo sviluppo di una singola applicazione che per un'intera distrubuzione. Consente di compilare codice arm su piattaforma i686 o amd64.
Installare la toolchain
Per installare la toolchain su Debian Lenny si sono seguite queste istruzioni: Openmoko application development in 5 minutes.
Si installano preventivamente i pacchetti:
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
Si scarica la toolchain precompilata dal repository OpenMoko, esiste la versione i686 e amd64, il pacchetto non è rilocabile e va in /usr/local/openmoko
. Invece di installare il tarball, lo si trasforma in uno pseudo pacchetto .deb facilmente (dis)installabile.
Scegliamo openmoko-i686-20090323-armv4t-linux-gnueabi-toolchain-openmoko.tar.bz2 (pacchetto per i686, per compilare codice arm su piattaforma GNU/Linux) ed eseguiamo:
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
Il pacchetto .deb risultante è installabile con
sudo dpkg -i openmoko-i686_20090323-2_all.deb
Usare la toolchain
Prima di compilare qualcosa si deve settare l'environment giusto (PATH
, CPPFLAGS
, CXXFLAGS
, LDFLAGS
, ecc.):
source /usr/local/openmoko/arm/environment-setup
Quindi si usa il compilatore apposito
arm-angstrom-linux-gnueabi-gcc -o test test.c
Un'ipotetico Makefile
potrebbe contenere qualcosa del tipo:
export CC = arm-angstrom-linux-gnueabi-gcc binary: $(CC) -o test test.c
Installazione delle dipendenze
Se il programma da compilare dipende da una libreria OpenMoko, bisogna installarla nella toolchain. Prima di tutto si deve impostare i repository da cui attingere in /usr/local/openmoko/arm/arm-angstrom-linux-gnueabi/etc/opkg.conf
.
L'impostazione predefinita prevede di scaricare da unstable, ecco invece come scaricare i pacchetti da 2008.12:
arch all 1 src/gz all http://downloads.openmoko.org/repository/Om2008.8/all arch armv4t 26 src/gz armv4t http://downloads.openmoko.org/repository/Om2008.8/armv4t arch om-gta02 31 src/gz om-gta02 http://downloads.openmoko.org/repository/Om2008.8/om-gta02
Ecco l'esempio di come installare un pacchetto -dev:
. /usr/local/openmoko/arm/environment-setup opkg-target update opkg-target list opkg-target install gpsd-dev
L'elenco dei pacchetti disponibili viene salvato in /usr/local/openmoko/arm/arm-angstrom-linux-gnueabi/usr/lib/opkg/lists/
.
I pacchetti vengono installati sotto /usr/local/openmoko/arm/arm-angstrom-linux-gnueabi/
.
Compiling a large project: Navit
Please, improve the page Navit on FreeRunner.
First of all, edit the /usr/local/openmoko/arm/environment-setup
script and add the followig line:
export OMTOOL_DIR=/usr/local/openmoko
After toolchain installation, install (with opkg-target
) some OpenMoko -dev
packages required to compile Navit:
. /usr/local/openmoko/arm/environment-setup 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 and run om-conf
to prepare the automake
, autoconf
and make
files to run into the OpenMoko toolchain:
svn co https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit om-conf navit
It's time to cross-compile:
cd navit make
Creare un pacchetto .opk
Check what is provided by the toolchain! The following may be obsolete.
Simply do an:
svn co http://svn.openmoko.org/trunk/src/host/opkg-utils
and use the instructions of ipkg's website but the software from this checkout, the opkg-build.
Qemu and the GTA02 FreeRunner
WARNING: this procedure works only for the GTA01 Neo1973, it fails for the GTA02 FreeRunner.
Install the Debian packages gcc-3.4 and libsdl1.2-dev, download the qemu-neo1973 sources from the svn repository. Run the ./configure && make
.
Edit the openmoko/env
file and set current URLs and filenames:
# Entries for GTA01 kernel_wildcard="uImage-2.6.22.5-moko11+svnr3238-r9-neo1973.bin" rootfs_wildcard="openmoko-image-fic-gta01.jffs2" uboot_wildcard="u-boot-gta01*.bin" download_dir="http://downloads.openmoko.org/distro/obsolete-images/Om2007.11//images/neo1973/"
Run the openmoko/download.sh
and openmoko/flash.sh
scripts.
For the (failed) attempt to run the GTA02 FreeRunner emulator we need different Qemu parameters and different images:
qemu_relative="arm-softmmu/qemu-system-arm -M gta02fake -m 130" # Entries for GTA02, Om2008.12 kernel_wildcard="Om2008.12-om-gta02.uImage.bin" rootfs_wildcard="Om2008.12-om-gta02.rootfs.jffs2" uboot_wildcard="gta02v5_and_up-u-boot.bin" download_dir="http://downloads.openmoko.org/distro/releases/Om2008.12/"
The openmoko/Makefile
should be changed so the openmoko-flash.base (the NAND image) will be 256 Mb in size:
# GTA02 $(FLASHIMG): # Making an empty/erased flash image. Need a correct echo behavior. $(echo) -en \\0377\\0377\\0377\\0377\\0377\\0377\\0377\\0377 > .8b cat .8b .8b .8b .8b .8b .8b .8b .8b > .64b # OOB is 64 bytes cat .64b .64b .64b .64b .64b .64b .64b .64b > .2048b cat .64b .64b .64b .64b .64b .64b .64b .64b >> .2048b cat .64b .64b .64b .64b .64b .64b .64b .64b >> .2048b cat .64b .64b .64b .64b .64b .64b .64b .64b >> .2048b cat .2048b .64b > .sec # A sector is 2048 bytes of data + OOB cat .sec .sec .sec .sec .sec .sec .sec .sec > .8sec cat .8sec .8sec .8sec .8sec .8sec .8sec .8sec .8sec > .64sec cat .64sec .64sec .64sec .64sec .64sec .64sec .64sec .64sec > .512sec cat .512sec .512sec .512sec .512sec > .2ksec cat .2ksec .2ksec .2ksec .2ksec .2ksec .2ksec .2ksec .2ksec > .16ksec # Neo GTA02 NAND is 128k sectors big cat .16ksec .16ksec .16ksec .16ksec .16ksec .16ksec .16ksec .16ksec > $@ rm -rf .8b .64b .2048b .sec .8sec .64sec .512sec .2ksec .16ksec
The openmoko/download.sh
will run, but openmoko/flash.sh
fails with endless errors:
s3c_nand_read: Bad register 0x20
May be there are more instructions for the GTA02 in the wiki page.
We can manually run the emulator to get the U-Boot prompt, but here we have to partition and flash the NAND manually.
arm-softmmu/qemu-system-arm -M gta02fake -m 130 \ -mtdblock openmoko-flash.base \ -kernel u-boot.bin \ -serial stdio -nographic -usb -monitor null