GentooQEMUBuildBox

From Openmoko

(Difference between revisions)
Jump to: navigation, search
m (Category: -Technical, +Emulation)
Line 110: Line 110:
 
* setup distcc specifying only localhost on emulated system
 
* 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
 
* modify PATH in profile specifying /usr/lib/distcc/bin as first element so only preprocessing is done in qemu and all compilation on localhost
[[category:Technical]]
+
 
 +
[[category:Emulation]]

Revision as of 22:54, 13 September 2008

Contents

Read first

Gentoo, http://www.gentoo.org/doc/en/handbook/handbook-arm.xml


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

run-qemu-1:

#!/bin/bash

CURDIR="/somedirwithqemuscriptsandrootfsimage"
NUMBER=1

KERNEL="$CURDIR/zImage-2.6.23-pinky-3.1-qemuarm.bin"
ROOTFS="$CURDIR/qemuarm-$NUMBER.gentoo.ext2"
SWAPFS="$CURDIR/qemuarm-$NUMBER.swapfs"

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:255.255.255.0\ mem=256M\ quiet

qemu-ifup-1:

#!/bin/sh

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

qemu-ifdown-1:

#!/bin/sh

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


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=192.168.1.1:NFSPATH 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 192.168.1.10 as local ip and 192.168.1.1 as default route)
  • add ntpdate ntp.task.gda.pl 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
Personal tools

Read first

Gentoo, http://www.gentoo.org/doc/en/handbook/handbook-arm.xml


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

run-qemu-1:

#!/bin/bash

CURDIR="/somedirwithqemuscriptsandrootfsimage"
NUMBER=1

KERNEL="$CURDIR/zImage-2.6.23-pinky-3.1-qemuarm.bin"
ROOTFS="$CURDIR/qemuarm-$NUMBER.gentoo.ext2"
SWAPFS="$CURDIR/qemuarm-$NUMBER.swapfs"

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:255.255.255.0\ mem=256M\ quiet

qemu-ifup-1:

#!/bin/sh

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

qemu-ifdown-1:

#!/bin/sh

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


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=192.168.1.1:NFSPATH 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 192.168.1.10 as local ip and 192.168.1.1 as default route)
  • add ntpdate ntp.task.gda.pl 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