OpenMoko + Gentoo [0]

Me and some friends of mine received our OpenMoko FreeRunner some days ago. Since then I have used some hours playing around with it. Short explained, it is an open sourced linux powered phone where the software is not yet finished. The phone is contains two accelerometers, bluetooth support, a GPS, micro SD card reader, wlan, usb-plug , a large touch-sensitiv screen and an ARM SOC.

Setting up network

I assume that my system had the needed drivers loaded already, so if I want to do this by hand I do as root (after pluging in the phone)

root@laptop ~ # ifconfig usb0 192.168.0.200 netmask 255.255.255.192 up
root@laptop ~ # echo 1 > /proc/sys/net/ipv4/ip_forward
root@laptop ~ # iptables -t nat -A POSTROUTING -j MASQUERADE

Permanent stuff is much more distro-specific to note here.

Setting up the prebuilt toolchain

First I thought that I wanted to build everything myself, but after spending some hours with that, I figured that there really wasn't any reason for that, since I could download a ready-made toolchain for x86 that didn't depend on any wierd preinstalled libraries of speific versions; how neat.

stian@laptop ~ $ mkdir moko
stian@laptop ~ $ cd moko
stian@laptop ~/moko $ mkdir sources
stian@laptop ~/moko $ cd sources
stian@laptop ~/moko/sources $ wget http://buildhost.openmoko.org/daily/sdk/openmoko-P1-Snapshot-20080714-armv4t-linux-gnueabi-toolchain-openmoko.tar.bz2
--2008-07-15 21:57:47-- http://buildhost.openmoko.org/daily/sdk/openmoko-P1-Snapshot-20080714-armv4t-linux-gnueabi-toolchain-openmoko.tar.bz2
Resolving downloads.openmoko.org... 88.198.93.219
Connecting to downloads.openmoko.org|88.198.93.219|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 50316780 (48M) [application/x-tar]
Saving to: `openmoko-P1-Snapshot-20080714-armv4t-linux-gnueabi-toolchain-openmoko.tar.bz2'

100%[======================================================================================>] 50,316,780 286K/s in 50s

2008-07-15 22:04:32 (989 KB/s) - `openmoko-P1-Snapshot-20080714-armv4t-linux-gnueabi-toolchain-openmoko.tar.bz2' saved [50316780/50316780]

stian@laptop ~/moko/sources $ tar xfj openmoko-P1-Snapshot-20080714-armv4t-linux-gnueabi-toolchain-openmoko.tar.bz2
stian@laptop ~/moko/sources $ su -c "ln -s ~/moko/sources/usr/local/openmoko /usr/local"
stian@laptop ~/moko/sources $ wget http://buildhost.openmoko.org/daily/tools/dfu-util
--2008-07-16 00:49:02-- http://buildhost.openmoko.org/daily/tools/dfu-util
Resolving buildhost.openmoko.org... 78.47.190.211
Connecting to buildhost.openmoko.org|78.47.190.211|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 536980 (524K) [text/plain]
/ Saving to: `dfu-util'

100%[======================================================================================>] 536,980 148K/s in 3.7s

2008-07-16 00:49:06 (141 KB/s) - `dfu-util' saved [536980/536980]

stian@laptop ~/moko/sources $ chmod a+x dfu-util

So each time I now want to use the toolchain I do this in the shell

stian@laptop ~ $ . /usr/local/openmoko/arm/setup-env

Compiling your own kernel

First I got lost with the kernel-patch-set that was present in the monotone repository until I discovered that openmoko has their own git repository (see here for info). Also, please note the need for unset LDFLAGS when compiling the kernel-tree!. So here we go:

stian@laptop ~ $ . /usr/local/openmoko/arm/setup-env
stian@laptop ~ $ unset LDFLAGS
stian@laptop ~ $ cd moko/sources
stian@laptop ~/moko/sources $ git clone git://git.openmoko.org/git/kernel.git linux-2.6
Initialized empty Git repository in /home/stian/moko/sources/linux-2.6/.git/
remote: Generating pack...
remote: Counting objects...811553
remote: Deltifying 811553 objects.
remote: 100% (811553/811553) done
remote: Total 811553, written 811553 (delta 659856), reused 788543 (delta 639591)
Receiving objects: 100% (811553/811553), 242.30 MiB | 1978 KiB/s, done.
Resolving deltas: 100% (659856/659856), done.
Checking out files: 100% (24270/24270), done.

stian@laptop ~/moko/sources $ cd linux-2.6
stian@laptop ~/moko/sources/linux-2.6 $ git checkout origin/andy
Note: moving to "origin/andy" which isn't a local branch
If you want to create a new branch from this checkout, you may do so
(now or later) by using -b with the checkout command again. Example:
git checkout -b <new_branch_name>
HEAD is now at 0fd3c05... add-limit-sdcard-clk-cmdline.patch
stian@laptop ~/moko/sources/linux-2.6 $ cp defconfig-gta02 .config
stian@laptop ~/moko/sources/linux-2.6 $ make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- oldconfig
... (way to much stuff to paste in here) ..

stian@laptop ~/moko/sources/linux-2.6 $ make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- menuconfig
... (way to much stuff to paste in here, please append a version string when you are configuring) ..

stian@laptop ~/moko/sources/linux-2.6 $ mkdir dest
stian@laptop ~/moko/sources/linux-2.6 $ make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- INSTALL_MOD_PATH=`pwd`/dest vmlinux modules modules_install
... (way to much stuff to paste in here) ..

stian@laptop ~/moko/sources/linux-2.6 $ arm-angstrom-linux-gnueabi-objcopy -O binary -R .note -R .comment -S vmlinux linux.bin
stian@laptop ~/moko/sources/linux-2.6 $ gzip -9 linux.bin
stian@laptop ~/moko/sources/linux-2.6 $ mkimage -A arm -O linux -T kernel -C gzip -a 30008000 -e 30008000 -n "Kernel Image 2.6.24-stian" -d linux.bin.gz uImage
# Part of dev-embedded/u-boot-tools on Gentoo
# Part of uboot-mkimage on debian (lenny and sid)
Image Name: Kernel Image 2.6.24-stian
Created: Wed Jul 16 01:12:34 2008
Image Type: ARM Linux Kernel Image (gzip compressed)
Data Size: 1669293 Bytes = 1630.17 kB = 1.59 MB
Load Address: 0x30008000
Entry Point: 0x30008000

stian@laptop ~/moko/sources/linux-2.6 $ rm dest/lib/modules/2.6.24-stian/build dest/lib/modules/2.6.24-stian/source
... since we don't want scp bellow to transer the entire kernel-tree etc.. But please note that there is no / after source and build... VERY IMPORTANT)
stian@laptop ~/moko/sources/linux-2.6 $ scp -r dest/* root@192.168.0.202:/
... (way to much stuff to paste in here) ..
# Now reboot the telephone (without USB plug'ed in) by pressing power, and after a second, hold AUX aswell. U-Boot should now appear on the screen. Then plug the USB cable in again.

stian@laptop ~/moko/sources/linux-2.6 $ su -c "../dfu-util -a kernel -R -D uImage"
Password:
dfu-util - (C) 2007 by OpenMoko Inc.
This program is Free Software and has ABSOLUTELY NO WARRANTY

Opening USB Device 0x0000:0x0000...
Claiming USB DFU Runtime Interface...
Determining device status: state = appIDLE, status = 0
Device really in Runtime Mode, send DFU detach request...
Resetting USB...
Opening USB Device...
Found Runtime: [0x1d50:0x5119] devnum=11, cfg=0, intf=0, alt=0, name="RAM 0x32000000"
Claiming USB DFU Interface...
Setting Alternate Setting ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Transfer Size = 0x1000
bytes_per_hash=33387
Starting download: [##################################################] finished!
state(2) = dfuIDLE, status(0) = No error condition is present
Done!
Resetting USB to switch back to runtime mode