From Openmoko

Jump to: navigation, search


Read first


Needed things

Seting up with local hdd image

dd if=/dev/zero of=qemuarm-0.rootfs.ext2 count=16777216
dd if=/dev/zero of=qemuarm-0.swapfs count=524288
losetup -f qemuarm-0.rootfs.ext2
mkfs.ext2 /dev/loop0
mount /dev/loop0 /mnt
tar -xjpf stage3-armv4tl-*.tar.bz2 -C /mnt
tar -xjpf portage-*.tar.bz2 -C /mnt/usr
umount /mnt
mkswap qemuarm-0.swapfs

QEMU run scripts for local hdd image





qemu-system-arm -kernel $KERNEL -net nic,vlan=0 -net tap,vlan=0,ifname=tap$NUMBER,script=$CURDIR/qemu-ifup-$NUMBER,downscript=$CURDIR/qemu-ifdown-$NUMBER \
    -M versatilepb -hda $ROOTFS -hdb $SWAPFS -no-reboot -m 256 -show-cursor -serial stdio -parallel none \
    -monitor unix:"$QEMU_MONITOR",server,nowait -nographic \
    --append root=/dev/sda\ console=ttyAMA0\ ip=192.168.$NUMBER.10::192.168.$NUMBER.1:\ mem=256M\ quiet



/sbin/ifconfig tap1
echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -I INPUT 1 -s -j ACCEPT
/sbin/iptables -I OUTPUT 1 -s -j ACCEPT
/sbin/iptables -A POSTROUTING -t nat -j MASQUERADE -s



/sbin/ifconfig tap1 down
echo 0 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -D INPUT -s -j ACCEPT
/sbin/iptables -D OUTPUT -s -j ACCEPT
/sbin/iptables -D POSTROUTING -t nat -j MASQUERADE -s

Alternative nfs rootfs

  • Setup nfs server on localhost
  • Unpack stage/portage
tar -xjpf stage3-armv4tl-*.tar.bz2 -C NFSPATH
tar -xjpf portage-*.tar.bz2 -C NFSPATH/usr
  • Make swap patition
  • Replace "root=/dev/sda" with "root=/dev/nfs nfsroot= rw" and remove "-hda $ROOTFS" in run-qemu-1

First boot

  • Add "\ init=/bin/bash" to the end of run-qemu-1 just after quiet to get bash to do initial setup and run it
  • mount -n -o remount,rw /
  • source /etc/profiles; env-update
  • do setup things described in Gentoo
  • mknod /dev/ttyAMA0 c 204 64
  • edit /etc/inittab unhashing s0 and changeing it to ttyAMA0
  • add ttyAMA0 to /etc/securetty
  • emerge ntp (use binaries)
  • setup /etc/resolv.conf and /etc/conf.d/net corectly (useing as local ip and as default route)
  • add ntpdate at the begining of start() in /etc/init,d/fsck to ensure correct date at boot (no rtc clock support in that kernel image)
  • mkdir -p /lib/modules/2.6.23
  • touch /lib/modules/2.6.23/modules.dep
  • sync
  • mount -n -o remount,ro /
  • init 0
  • Use ctrl+a ctrl+x to turn off qemu
  • Remove "\ init=/bin/bash" from run-qemu-1
  • Run run-qemu-1 / fix things if needed

Advanced setup

  • emerge distcc on qemu and localhost
  • install cross armv4tl-softfloat-linux-gnueabi toolchain on localhost (same versions as on gentoo image)
  • setup distcc specifying only localhost on emulated system
  • modify PATH in profile specifying /usr/lib/distcc/bin as first element so only preprocessing is done in qemu and all compilation on localhost

(instead of modifying the profile, just add a .sh file in /etc/profile.d that re-exports path. This will get sourced at the end of /etc/profile) --Trickie 09:34, 23 October 2008 (UTC)

Personal tools