r676 - developers/werner

werner at sita.openmoko.org werner at sita.openmoko.org
Tue Feb 6 01:40:01 CET 2007


Author: werner
Date: 2007-02-06 01:39:55 +0100 (Tue, 06 Feb 2007)
New Revision: 676

Added:
   developers/werner/WALK-THROUGH
Log:
Description of how to get from scratch to a full build of OpenMoko kernel
and user space, installed on the Neo. The current version of this
walk-through is still incomplete and has known bugs.



Added: developers/werner/WALK-THROUGH
===================================================================
--- developers/werner/WALK-THROUGH	2007-02-05 23:52:30 UTC (rev 675)
+++ developers/werner/WALK-THROUGH	2007-02-06 00:39:55 UTC (rev 676)
@@ -0,0 +1,383 @@
+#
+# OpenMoko Walk-Through
+#
+# by Werner Almesberger <werner at openmoko.org>
+#
+
+# This is a pseudo-shellscript describing how I set up a running OpenMoko
+# system from scratch. You can run this through a shell, but it's usually
+# better to 
+# Do NOT run this through a shell ! Instead, look at each
+# step, read the instructions, and copy and paste what makes sense for you, and
+# adapt what you disagree with.
+#
+# Please note that this file isn't actively maintained and is guaranteed to
+# suffer bit rot as I begin to use more and more shortcuts in the build
+# process. Furthermore, naming and other preferences are my own, may have
+# little to do with what is considered common or even "official" style. If you
+# find anything particularly stupid, please let me know.
+#
+
+
+
+###  Roles  ###################################################################
+#
+# The build process may spread over multiple machines. They have the following
+# roles:
+#
+#   BUILD	build host, with quick access to the files and CPU power. Must
+#		have Internet access.
+#   AUTH	host with access to the OpenMoko build host
+#   LAB		lab machine connected to the debug board (serial and JTAG) and
+#		to USB on the Neo (since this will probably be just a single
+#		machine, the roles are not further divided)
+#   CARD	machine with a USB-attached SD/MMC card reader
+#
+# All machines are assumed to share the same filesystem layout. In the title of
+# each of the section below, the respective role is indicated. "(all)" is for
+# settings that apply to all machines, or that - for simplicity - can be
+# applied to all of them.
+#
+
+
+###  Directory layout (all)  ##################################################
+#
+# $OMDIR (/home/moko)	base directory for the whole tree
+#   openmoko/		files from OpenMoko subversion (SVN) repository
+#   openembedded/	files from OpenEmbedded (OE) Monotone repository
+#   sources/		cached downloads of OE
+#   build/		OE build directory
+#
+
+
+###  Environment variables (all)  #############################################
+#
+# For simplicity, we just set these environment variables on all hosts
+# involved. If you're not comfortable with this, feel free to weed out the ones
+# you don't need.
+
+# Our base directory (configure this for local arrangements):
+
+export OMDIR=/home/moko
+
+# The path to the sources/ directory on the buildhost, in SCP path name syntax
+# (replace "werner" with your user name):
+
+export BUILDHOST_SRC=werner at buildhost.openmoko.org:/space/fic/openmoko/sources/
+
+# The search path for BitBake files. Note that the order is of vital
+# importance.
+
+export BBPATH=$OMDIR/build:$OMDIR/openmoko/trunk/oe:$OMDIR/openembedded
+
+
+###  Permissions (BUILD, AUTH)  ###############################################
+#
+# In order to perform the build process, you have to obtain the following
+# permissions:
+#
+# - write access to the OpenMoko SVN repository (in principle, read access
+#   should be enough. However, there are some secondary repositories that want
+#   authentication. If you have write access, you'll be fine with these, too.)
+# - AUTH must have shell access to the OpenMoko buildhost (to grab files with
+#   SCP)
+#
+
+
+###  Prerequisites (BUILD)  ###################################################
+#
+# In addition to the traditional development tools (gcc, patch, etc.), the
+# following packages must be installed on the build host:
+#
+#   subversion	version control system used by OpenMoko and others
+#   quilt	patch management system used by the Linux kernel and others
+#   monotone	version control system used by OpenEmbedded. Needs a recent
+#		version, e.g., 0.32, although also 0.31 should work.
+#   diffstat	the OE build process wants this
+#   texi2html	this too
+#   git		version control system used by the Linux kernel and others.
+#		Do not confuse this with the "GNU Interactive Tools"
+#
+# Furthermore, the following package can be installed optionally:
+#
+#   psycho	Python just-in-time compiler. Speeds up BitBake considerably.
+#		Strongly recommended.
+#
+
+# Gentoo users can obtain all this with (note that, at the time of writing,
+# Monotone 0.32 isn't available without setting the ~x86 keyword):
+
+echo 'dev-util/monotone ~'`readlink /etc/make.profile | awk -F / '{print $6}'`\
+  >>/etc/portage/package.keywords
+emerge -u subversion quilt monotone diffstat texi2html dev-util/git psyco
+
+# If the local user name does not match the user name with which you access
+# SVN, you can put the following script in your PATH before the regular
+# location of "svn" (usually /usr/bin/).
+#
+# Here, we assume that $HOME/bin is searched early enough. Replace "werner"
+# with your user name.
+
+cat <<EOF >$HOME/bin/svn
+#!/bin/sh
+exec `type -path svn` --username=werner "\$@"
+EOF
+chmod +x $HOME/bin/svn
+
+
+###  Prerequisites (LAB)  #####################################################
+#
+# The following package must be installed on the 
+#
+#   xc		a simple communications program for the serial port
+#
+
+# Gentoo users can obtain this with:
+emerge -u xc
+
+
+###  Assumptions (LAB, CARD)  #################################################
+#
+# There are the following assumptions about hardware setup and devices:
+#
+# - the serial console of the Neo phone is connected to /dev/ttyS0 on LAB
+#   https://wiki.openmoko.org/wiki/Debug_Board
+#
+# - the JTAG wriggler is connected to /dev/parport0 on LAB.
+#   https://wiki.openmoko.org/wiki/Debug_Board
+#   https://wiki.openmoko.org/wiki/Connecting_GTA01Bv2_with_Debug_Board
+#
+# - cards inserted in the SD/MMC card reader appear as /dev/uba on CARD
+#
+
+
+###  OpenEmbedded build: initial downloads (BUILD)  ###########################
+#
+# First, we obtain a snapshot of the OpenEmbedded-based tree used by OpenMoko,
+# plus the OE build tool called BitBake.
+#
+
+# Obtain revision 672 of the OpenMoko tree. This is a "known to be good",
+# version (provided the fixes below are applied). Unfortunately, at some
+# places, "current" versions of upstream packages may get included, thus the
+# build may still fail. If it does, you may wish to inform the authorities.
+#
+# The checkout should take about 45 minutes over an Internet connection with a
+# round-trip time to svn.openmoko.org of 350 ms.
+
+cd $OMDIR
+svn co -r 672 https://svn.openmoko.org:2342 openmoko
+
+# Install version 1.6 of BitBake, the build tool of OE. (This is quick.)
+
+svn co \
+  http://svn.berlios.de/svnroot/repos/bitbake/branches/bitbake-1.6/ bitbake
+cd bitbake
+./setup.py install
+cd ..
+
+# Obtain a snapshot of the Monotone repository of OpenEmbedded, then update it
+# to the latest version, and finally check out our "known to be good" revision.
+# We extract things into $OMDIR/openembedded. OE.mnt.bz2 is about 100 MB.
+
+wget http://www.openembedded.org/snapshots/OE.mtn.bz2
+bunzip2 OE.mtn.bz2
+mtn --db=OE.mtn pull monotone.openembedded.org org.openembedded.dev
+mtn --db=OE.mtn checkout --branch=org.openembedded.dev \
+  -r f499733e6db527846e1a48cf70f9862d6b3798ae openembedded
+
+# Note for advanced uses: if you ever want to update to the latest version of
+# the repository, you would do a "pull" (see above), followed by:
+# cd $OMDIR/openembedded && mnt update
+
+# Set up the directories for the cache of upstream files and all material
+# related to local builds, then put our configuration file there:
+
+mkdir -p sources build/conf build/tmp/stamps/armv4t-linux
+cat <<EOF >build/conf/local.conf
+MACHINE = "fic-gta01"
+DISTRO = "openmoko"
+BUILD_ARCH = "`uname -m`"
+EOF
+
+
+###  OpenEmbedded build: fixes (BUILD or AUTH)  ###############################
+#
+# There are unfortunately some problems in the build process. The following
+# fixes work around them:
+#
+
+cd $OMDIR/sources
+
+# upstream moves old packages away, gratuitously breaking downstreams
+
+wget http://ftp.mozilla.org/pub/mozilla.org/js/older-packages/js-1.5.tar.gz
+touch ../build/tmp/stamps/armv4t-linux/js-1.5-r0.do_fetch
+
+# us2.samba.org mirror has vanished
+
+wget http://us4.samba.org/samba/ftp/stable/samba-3.0.14a.tar.gz
+touch ../build/tmp/stamps/armv4t-linux/samba-3.0.14a-r15.do_fetch
+
+# ghastly patch
+
+perl -pi.orig -e 's/ *$//;s/\r//g' \
+  ../openembedded/packages/gcc/gcc-4.1.1/gcc-4.1.1-pr13685-1.patch
+#dos2unix <gcc/config/i386/i386.c.rej | sed 's/ *$//'
+
+
+###  OpenEmbedded build: fixes (AUTH)  ########################################
+#
+# Some files are currently stored in private repositories that require further
+# authorization. (If you think you should be granted access, ask on IRC.) We
+# get the files from the buildhost.
+#
+
+cd $OMDIR/sources
+
+# access requires authorization
+
+n=omoko_svn.o-hand.com_.repos.contacts.branches.private__now
+scp $BUILDHOST_SRC/$n.tar.gz .
+touch ../build/tmp/stamps/armv4t-linux/openmoko-contacts-0.1+svnnow-r0.do_fetch
+
+# access requires authorization
+
+n=omoko_svn.o-hand.com_.repos.dates.branches.private__now
+scp $BUILDHOST_SRC/$n.tar.gz .
+touch ../build/tmp/stamps/armv4t-linux/openmoko-dates-0.1+svnnow-r0.do_fetch
+
+
+###  OpenEmbedded build  ######################################################
+#
+# We're now ready to run the build. This will take a while.
+#
+
+cd $OMDIR/build
+bitbake openmoko-devel-image
+
+# Note that the build will stop several times to ask for SVN access and whether
+# to accept certificates. If you're not quick enough to respond, the underlying
+# session may time out. In this case, just restart "bitbake
+# openmoko-devel-image" and it pick up from where it left off.
+#
+# The whole build process takes about NNNN hours on an Athlon 64 3200+, and
+# ends with a message like this:
+#
+#
+
+###  Flash boot loader into NAND (LAB)  #######################################
+#
+# As a first step, we transfer the u-boot bootloader into NAND Flash, through
+# the JTAG interface.
+#
+# For this, the u-boot image for to right the board version and the desired
+# build date must be chosen. E.g., an image built for a gta01bv2 board on
+# February 3, 2007 at 13:40:41 would be called
+# u-boot_nand-gta01bv2-20070203134041.bin
+#
+# If this is the first build, there will only be one image for each board
+# version, thus we can use wildcards. Change the gta01bv2 below to gta01v3 or
+# gta01v4, if necessary.
+# 
+
+cd $OMDIR/build/tmp/deploy/images
+
+( echo 0; echo 0; echo 0; echo 2; ) |
+  ./sjf2410 /f:u-boot_nand-gta01bv2-*.bin
+
+# This will take approximately NNN minutes.
+
+
+###  Copy kernel and root FS to microSD card (CARD)  ##########################
+#
+# There are serveral ways to provide the Neo with its kernel and the root file
+# system. The most self-contained way is to put everything into NAND Flash.
+# To transfer the files to the Neo, we first place them on the microSD card.
+#
+
+# Memory cards, including microSD, usually come pre-formatted with VFAT. If we
+# prefer ext2 (e.g., because we want to store a real Linux file system on the
+# card as well), the following steps are needed:
+#
+# sfdisk -c /dev/uba 1 83
+# mke2fs -m0 /dev/uba1
+# tune2fs -c0 -i0 /dev/uba1
+#
+# Note however that leaving the card with VFAT makes it easier to swap data
+# with other people.
+
+# Next, we copy the kernel uImage and the root file system image to the card.
+# As discussed in the previous section, we can use wildcards if this is our
+# first build.
+
+cd $OMDIR/build/tmp/deploy/images
+mount /dev/uba1 /mnt/tmp
+cp uImage-2.6-moko7-r1-fic-gta01-*.bin /mnt/tmp/uImage
+cp openmoko-devel-image-fic-gta01-*.rootfs.jffs2 /mnt/tmp/rootfs.jffs2
+umount /mnt/tmp
+
+
+###  Flash kernel and root FS into NAND (LAB)  ################################
+#
+
+
+###
+# make an ext2 file system on the microSD card
+sfdisk -c /dev/uba 1 83
+mke2fs -m0 /dev/uba1
+tune2fs -c0 -i0 /dev/uba1
+
+cd $OMDIR/build/tmp/deploy/images
+
+mount /dev/uba1 /mnt/tmp
+tar xfzC openmoko-devel-image-fic-gta01-20070204161133.rootfs.tar.gz /mnt/tmp
+cp uImage-2.6-moko7-r1-fic-gta01-20070203211409.bin /mnt/tmp/boot/uImage
+cp openmoko-devel-image-fic-gta01-20070204161133.rootfs.jffs2 /mnt/tmp/rootfs.jffs2
+umount /mnt/tmp
+
+
+### The kernel ################################################################
+
+
+wget http://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.17.14.tar.bz2
+tar xfj linux-2.6.17.14.tar.bz2
+cd linux-2.6.17.14
+QUILT_PATCHES=/home/moko/om/trunk/src/target/kernel/patches quilt push -a
+cp /home/moko/om/trunk/oe/packages/linux/linux-gta01/defconfig-fic-gta01 \
+  .config
+PATH=$OMDIR/build/tmp/cross/bin:$PATH \
+  make ARCH=arm CROSS_COMPILE=arm-linux- oldconfig
+PATH=$OMDIR/build/tmp/cross/bin:$PATH \
+  make ARCH=arm CROSS_COMPILE=arm-linux-
+cd ..
+
+
+###  OpenOCD  #################################################################
+
+
+svn co http://svn.berlios.de/svnroot/repos/openocd/trunk openocd
+cd openocd
+./bootstrap
+./configure --enable-parport
+make
+cd ..
+
+
+### Serial console ############################################################
+
+
+cat <<EOF >~/xc.init
+set bps 115200
+terminal
+EOF
+
+xc -l /dev/ttyS0 -t
+
+
+mmc
+ext2load mmc 0 0x32000000 boot/uImage
+setenv bootargs root=/dev/mmcblk0p1 console=ttySAC0,115200 loglevel=8 rootdelay=10
+bootm 0x32000000
+
+###  END  #####################################################################





More information about the commitlog mailing list