TracNav
Plan of actions
- prepare preinstall environment to boot with
- Preparing a stage3 tarball
Preparing the host and the phone
- setup NFS-boot
- prepare binhost (/etc/exportfs for PORTAGE_BINHOST)
- optionally rsync + http-replicator at server
Preparing the SD-Card in the phone
- perform the boot
- fdisk and mkfs
Install the base system
- Setting up the system
- modules configuration
- booting (uboot)
Installing a cross-compiled system to the phone
This article is about installing your cross-compiled system on the SD-Card of your phone with NFS.
See also an alternative stage4 setup page.
Preparing a stage3 tarball
The first thing is to prepare a cross-compiled base system. To do so, you have to:
- setup your cross-compile environment (see Cross-compiling)
- cross-compile a base system and nfs-utils (make sure you create binpkgs) by typing
emerge-armv4tl-softfloat-linux-gnueabi system emerge-armv4tl-softfloat-linux-gnueabi nfs-utils
- setup a binary package host
- install the packages (optional: set an INSTALL_MASK) from your binhost to a stage3 directory typing
emerge-armv4tl-softfloat-linux-gnueabi --root=<path to stage3 dir> -g system emerge-armv4tl-softfloat-linux-gnueabi --root=<path to stage3 dir> -g nfs-utils
- add missing stuff to the stage directory
cd <path to stage3 dir> mkdir boot dev proc root sys mknod dev/null c 1 3 mknod dev/console c 5 1
- check if the stage3 tarball has a valid gcc set and set one if not
ROOT=<path to stage3 dir> gcc-config -l ROOT=<path to stage3 dir> gcc-config 1
- create a tarball of the stage3 directory
cd <path to stage3 dir> tar cvjf ../gentoo-freerunner-stage3.tar.bz2 .
- make sure you can access the tarball from the phone.
Preparing the host and the phone
You now have a nice starting point for your base system. The next step is to prepare the phone. Before booting the phone, make sure you have:
- installed a SD-Card that is large enough in the Freerunner (2GB should do it)
- a rootfs that you can boot from NAND or over the network (see NFS-Boot) containing the following tools:
- tar
- chroot
- mount
- fdisk
- wget # for downloading the stage3 tarball
- nfs-utils # for accessing NFS
- mkfs # for the filesystem you want to put on the SD-Card
- access to the host (via http or ftp) providing the stage3 tarball we created above
- access to the host (via http or ftp) providing the cross-compiled binpkgs
- recommended: access to the host (via nfs) providing the portage tree
- recommended: access to the host (via nfs) providing the openmoko overlay
Preparing the SD-Card in the phone
Now boot the phone into the (NAND or NFS) rootfs mentioned above! The next step is to prepare the SD-Card:
- check your date setting and correct it if necessary
date date <MMDDhhmmYYYY>
- create the partitions you want (in the following we will only use one partition):
fdisk /dev/mmcblk0
- create the filesystem (in this case ext2):
mke2fs /dev/mmcblk0p1
Install the base system
To install the cross-compiled base system on your phone do the following:
- create the mount point for the sdcard and mount it
mkdir -p /mnt/gentoo mount /dev/mmcblk0p1 /mnt/gentoo
- get the stage3 tarball by e.g. wget
wget ftp://<user>:<passwd>@<host>/gentoo-freerunner-stage3.tar.bz2
- untar the stage3 tarball
tar xvjpf gentoo-freerunner-stage3.tar.bz2 -C /mnt/gentoo sync
- get the portage tree and overlay e.g. via NFS:
mkdir -p /mnt/gentoo/usr/portage mkdir -p /mnt/gentoo/usr/local/portage/openmoko-overlay mount -t nfs 192.168.0.200:<path to portage> /mnt/gentoo/usr/portage -o nolock,nfsvers=2 mount -t nfs 192.168.0.200:<path to overlay> /mnt/gentoo/usr/local/portage/openmoko-overlay -o nolock,nfsvers=2
- now we can continue in the Handbook style
- edit the /etc/make.conf file and make sure you have
- set the USE flags to those you use on the buildhost
- set the VIDEO_CARDS to those you use on the buildhost
- set the INPUT_DEVICES to those you use on the buildhost
- set CHOST="armv4tl-softfloat-linux-gnueabi"
- set CFLAGS to those you use on the buildhost
- add the overlay PORTDIR_OVERLAY="/usr/local/portage/openmoko-overlay/openmoko-target $PORTDIR_OVERLAY"
- set the binhost PORTAGE_BINHOST="ftp://<user>:<passwd>@192.168.119.20"
- set your portage working dir to a tmpfs to preserve your SDCard PORTAGE_TMPDIR=/tmp
- prepare the chrooting
cp /mnt/gentoo/usr/share/zoneinfo/<your timezone> /mnt/gentoo/etc/localtime cp -L /etc/resolv.conf /mnt/gentoo/etc/ mount -t proc none /mnt/gentoo/proc mount -o bind /dev /mnt/gentoo/dev mount -o bind /dev/pts /mnt/gentoo/dev/pts
- chroot to the brand new base system
chroot /mnt/gentoo /bin/bash env-update source /etc/profile
- setup the keywording based on the overlay
cd /etc/portage for c in keywords mask unmask use; do mkdir /etc/portage/package.$c; done for c in keywords mask unmask use; do cd package.$c; ln -s /usr/local/portage/openmoko-overlay/portage-flags-target/$c openmoko; cd -; done
- choose the openmoko profile
cd /etc ln -snf /usr/local/portage/openmoko-overlay/openmoko-target/profiles/openmoko /etc/make.profile
- check if portage itself is setup correctly and let it rebuild its database
emerge --info
- rerun all important pkg_postinst for adding users etc.
find /var/db/pkg -name '*.ebuild' -exec grep -qF 'pkg_postinst()' {} \; -exec ebuild {} postinst \; - install a (binary kernel) and its modules
- Optinal: Reemerge the system and nfs-utils to get all postinstall procs. Get yourself a cup of coffee! This may take a while...
emerge -geq world emerge -geq nfs-utils
Setting up the system
- set a root password
passwd
- edit /etc/fstab and add all required filesystems
nano /etc/fstab
- configure usb0 network starting
nano /etc/conf.d/net --- config_usb0=("192.168.0.202 netmask 255.255.255.0" ) --- cd /etc/init.d/ ln -s net.lo net.usb0 - add all important services to the runlevels
rc-update add udev sysinit rc-update add sshd default rc-update add net.usb0 default rc-update add <service> <runlevel>
- Reboot and have fun!
Few words about modules and configuring modprobe.conf and modules.d
TODO
