From 295818470acd4628df8c5de20a8843cb90171b5b Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Tue, 16 Jan 2007 12:23:08 +0000 Subject: runqemu: Revamp scripts, splitting into a core internal script and two helpers, one for use within poky, one outside poky git-svn-id: https://svn.o-hand.com/repos/poky/trunk@1144 311d38ba-8fff-0310-9ca6-ca027cbcb966 --- scripts/runqemu | 89 ++++++++++++++----------------- scripts/runqemu-internal | 129 +++++++++++++++++++++++++++++++++++++++++++++ scripts/runqemu-standalone | 44 ++++++++++++++++ 3 files changed, 214 insertions(+), 48 deletions(-) create mode 100644 scripts/runqemu-internal create mode 100755 scripts/runqemu-standalone (limited to 'scripts') diff --git a/scripts/runqemu b/scripts/runqemu index 63ea856b65..433ceb7e35 100755 --- a/scripts/runqemu +++ b/scripts/runqemu @@ -1,4 +1,20 @@ #!/bin/sh +# +# Handle Poky <-> QEmu interface voodoo +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# if [ "x$BUILDDIR" = "x" ]; then echo "You need to source poky-init-build-env before running this script" @@ -7,17 +23,21 @@ fi PATH=$BUILDDIR/tmp/staging/$BUILD_SYS/bin:$BUILDDIR/tmp/cross/bin:$PATH -KERNEL_NETWORK_CMD="ip=192.168.7.2::192.168.7.1:255.255.255.0" -QEMU_NETWORK_CMD="-net nic,vlan=0 -net tap,vlan=0,ifname=tap0,script=$OEROOT/scripts/qemu-ifup" - if [ -z "$QEMU_MEMORY" ]; then QEMU_MEMORY="64M" fi -if [ "x$1" != "x" ]; then - MACHINE=$1 +if [ "x$1" = "x" ]; then + echo + echo "Run as $0 MACHINE IMAGETYPE ZIMAGE IMAGEFILE" + echo "where:" + echo " MACHINE - the machine to emulate (qemuarm, qemux86)" + echo " IMAGETYPE - the type of image to run (ext2, nfs) (default: ext2)" + echo " ZIMAGE - the kernel to use (optional)" + echo " IMAGEFILE - the image file/location to use (optional)" + exit 1 else - MACHINE="qemuarm" + MACHINE=$1 fi if [ "x$2" != "x" ]; then @@ -35,18 +55,30 @@ if [ "x$4" != "x" ]; then fi if [ "$MACHINE" = "qemuarm" -o "$MACHINE" = "spitz" -o "$MACHINE" = "borzoi" -o "$MACHINE" = "akita" ]; then - QEMU=`which qemu-system-arm` if [ "x$ZIMAGE" = "x" ]; then ZIMAGE=$BUILDDIR/tmp/deploy/images/zImage-$MACHINE.bin fi CROSSPATH=$BUILDDIR/tmp/cross/arm-poky-linux/bin fi + +if [ "$MACHINE" = "qemuarm" ]; then + if [ "$TYPE" = "ext2" ]; then + if [ "x$HDIMAGE" = "x" ]; then + HDIMAGE=$BUILDDIR/tmp/deploy/images/oh-image-sdk-qemuarm.ext2 + fi + fi +fi + if [ "$MACHINE" = "qemux86" ]; then - QEMU=`which qemu` if [ "x$ZIMAGE" = "x" ]; then ZIMAGE=$BUILDDIR/tmp/deploy/images/bzImage-$MACHINE.bin fi + if [ "$TYPE" = "ext2" ]; then + if [ "x$HDIMAGE" = "x" ]; then + HDIMAGE=$BUILDDIR/tmp/deploy/images/oh-image-pda-qemux86.ext2 + fi + fi CROSSPATH=$BUILDDIR/tmp/cross/i586-poky-linux/bin fi @@ -58,54 +90,15 @@ fi DISTCCD=`which distccd` - if [ -x "$DISTCCD" ]; then $DISTCCD --allow 192.168.7.2 --daemon else echo "Warning: distccd not present, no distcc support loaded" fi -if [ "$MACHINE" = "qemuarm" ]; then - if [ "$TYPE" = "ext2" ]; then - if [ "x$HDIMAGE" = "x" ]; then - HDIMAGE=$BUILDDIR/tmp/deploy/images/oh-image-sdk-qemuarm.ext2 - fi - QEMUOPTIONS="-append \"root=/dev/sda mem=$QEMU_MEMORY\" $QEMU_NETWORK_CMD -M versatilepb -hda $HDIMAGE -usb -usbdevice wacom-tablet" - fi - if [ "$TYPE" = "nfs" ]; then - dd if=/dev/zero of=/tmp/blank bs=1024 count=8192 - QEMUOPTIONS="-append \"root=/dev/nfs nfsroot=192.168.7.1:/srv/nfs/qemuarm rw $KERNEL_NETWORK_CMD\" $QEMU_NETWORK_CMD -M versatilepb -hda /tmp/blank" - fi -fi - -if [ "$MACHINE" = "qemux86" ]; then - if [ "$TYPE" = "ext2" ]; then - if [ "x$HDIMAGE" = "x" ]; then - HDIMAGE=$BUILDDIR/tmp/deploy/images/oh-image-pda-qemux86.ext2 - fi - # video=vesafb:1024x768-32@86 - QEMUOPTIONS="-std-vga -append \"root=/dev/hda mem=$QEMU_MEMORY $KERNEL_NETWORK_CMD\" $QEMU_NETWORK_CMD -hda $HDIMAGE -usb -usbdevice wacom-tablet" - fi - if [ "$TYPE" = "nfs" ]; then - dd if=/dev/zero of=/tmp/blank bs=1024 count=8192 - QEMUOPTIONS="-std-vga -append \"root=/dev/nfs nfsroot=192.168.7.1:/srv/nfs/qemux86 rw $KERNEL_NETWORK_CMD\" $QEMU_NETWORK_CMD -hda /tmp/blank" - fi -fi - -if [ "x$QEMUOPTIONS" = "x" ]; then - echo "Sorry, unable to support this configuration" - exit 1 -fi - -echo "Running $QEMU using sudo..." -echo "$QEMU -kernel $ZIMAGE $QEMUOPTIONS" -sudo $QEMU -kernel $ZIMAGE $QEMUOPTIONS -# -serial file:serial.log +source $OEROOT/scripts/runqemu-internal if [ -x "$DISTCCD" ]; then killall distccd fi -if [ -e /tmp/blank ]; then - rm /tmp/blank -fi diff --git a/scripts/runqemu-internal b/scripts/runqemu-internal new file mode 100644 index 0000000000..1ad0ef34b8 --- /dev/null +++ b/scripts/runqemu-internal @@ -0,0 +1,129 @@ +#!/bin/sh +# +# Handle running Poky images under qemu +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# +# Call setting: +# QEMU_MEMORY (optional) set the amount of memory in the emualted system. +# SERIAL_LOGFILE (optional) log the serial port output to a file +# +# Image options: +# MACHINE - the machine to run +# TYPE - the image type to run +# ZIMAGE - the kernel image file to use +# HDIMAGE - the disk image file to use +# + +QEMUIFUP=`which qemu-ifup` +KERNEL_NETWORK_CMD="ip=192.168.7.2::192.168.7.1:255.255.255.0" +QEMU_NETWORK_CMD="-net nic,vlan=0 -net tap,vlan=0,ifname=tap0,script=$QEMUIFUP" + +if [ -z "$QEMU_MEMORY" ]; then + QEMU_MEMORY="64M" +fi + +SERIALOPTS="" +if [ "x$SERIAL_LOGFILE" != "x" ]; then + SERIALOPTS="-serial file:$SERIAL_LOGFILE" +fi + +if [ "$TYPE" != "nfs" -a ! -f "$HDIMAGE" ]; then + echo -e "\nError, image file $HDIMAGE doesn't exist" + exit 1 +fi + +if [ ! -f "$ZIMAGE" ]; then + echo -e "\nError, kernel image file $ZIMAGE doesn't exist" + exit 1 +fi + +if [ "$MACHINE" != "qemuarm" -a "$MACHINE" != "qemux86" ]; then + echo -e "\nError, unsupported machine type $MACHINE" + exit 1 +fi + +if [ "$MACHINE" = "qemuarm" ]; then + QEMU=`which qemu-system-arm` + if [ "$TYPE" = "ext2" ]; then + QEMUOPTIONS="-append \"root=/dev/sda console=ttyAMA0 console=tty0 mem=$QEMU_MEMORY\" $QEMU_NETWORK_CMD -M versatilepb -hda $HDIMAGE -usb -usbdevice wacom-tablet" + fi + if [ "$TYPE" = "nfs" ]; then + if [ "x$HDIMAGE" = "x" ]; then + HDIMAGE=/srv/nfs/qemuarm + fi + if [ ! -d "$HDIMAGE" ]; then + echo -e "\nError, NFS mount point $HDIMAGE doesn't exist" + exit 1 + fi + QEMUOPTIONS="-append \"root=/dev/nfs nfsroot=192.168.7.1:$HDIMAGE rw $KERNEL_NETWORK_CMD\" $QEMU_NETWORK_CMD -M versatilepb" + fi +fi + +if [ "$MACHINE" = "qemux86" ]; then + QEMU=`which qemu` + if [ "$TYPE" = "ext2" ]; then + QEMUOPTIONS="-std-vga -append \"root=/dev/hda mem=$QEMU_MEMORY $KERNEL_NETWORK_CMD\" $QEMU_NETWORK_CMD -hda $HDIMAGE -usb -usbdevice wacom-tablet" + fi + if [ "$TYPE" = "nfs" ]; then + if [ "x$HDIMAGE" = "x" ]; then + HDIMAGE=/srv/nfs/qemux86 + fi + if [ ! -d "$HDIMAGE" ]; then + echo -e "\nError, NFS mount point $HDIMAGE doesn't exist." + exit 1 + fi + QEMUOPTIONS="-std-vga -append \"root=/dev/nfs nfsroot=192.168.7.1:$HDIMAGE rw $KERNEL_NETWORK_CMD\" $QEMU_NETWORK_CMD" + fi +fi + +if [ "$MACHINE" = "spitz" ]; then + QEMU=`which qemu-system-arm` +# QEMU=/usr/local/bin/qemu-system-arm +# if [ "$TYPE" = "ext2" ]; then +# if [ "x$HDIMAGE" = "x" ]; then +# HDIMAGE=`readlink -f $BUILDDIR/tmp/deploy/images/oh-image-sdk-spitz.ext2` +# if [ ! -e $HDIMAGE.mbr ]; then +# cp $OEROOT/mbr.bin $HDIMAGE.mbr +# cat $HDIMAGE >> $HDIMAGE.mbr +# fi +# HDIMAGE=$BUILDDIR/tmp/deploy/images/hdaimage.bin +# fi +# QEMUOPTIONS="-append \"root=/dev/sda mem=$QEMU_MEMORY\" $QEMU_NETWORK_CMD -M spitz -hda $HDIMAGE" +# fi +fi + +if [ "$MACHINE" = "akita" ]; then + QEMU=`which qemu-system-arm` +# QEMU=/usr/local/bin/qemu-system-arm +# if [ "$TYPE" = "ext2" ]; then +# if [ "x$HDIMAGE" = "x" ]; then +# HDIMAGE=$BUILDDIR/tmp/deploy/images/oh-image-sdk-akita.jffs2 +# HDIMAGE=$BUILDDIR/tmp/deploy/images/akita.test +# fi +# QEMUOPTIONS="$QEMU_NETWORK_CMD -M akita -hdd $HDIMAGE" +# fi +fi + +if [ "x$QEMUOPTIONS" = "x" ]; then + echo -e "\nError, unable to support this combination of options" + exit 1 +fi + +echo -e "\nRunning $QEMU using sudo..." +echo "$QEMU -kernel $ZIMAGE $QEMUOPTIONS $SERIALOPTS" +sudo $QEMU -kernel $ZIMAGE $QEMUOPTIONS $SERIALOPTS + + diff --git a/scripts/runqemu-standalone b/scripts/runqemu-standalone new file mode 100755 index 0000000000..6e8218331e --- /dev/null +++ b/scripts/runqemu-standalone @@ -0,0 +1,44 @@ +#!/bin/sh +# +# Handle running Poky images standalone +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +if [ "x$1" = "x" ]; then + MYNAME=`basename $0` + echo -e "\nRun as MACHINE=xyz $MYNAME ZIMAGE IMAGEFILE" + echo "where:" + echo " ZIMAGE - the kernel image file to use" + echo " IMAGEFILE - the image file/location to use" + echo " (NFS booting assumed if IMAGEFILE not specified)" + echo " MACHINE=xyz - the machine name (optional, autodetected from ZIMAGE if unspecified)" + exit 1 +else + ZIMAGE=$1 +fi + +if [ "x$2" = "x" ]; then + TYPE="nfs" +else + TYPE="ext2" + HDIMAGE=$2 +fi + +if [ "x$MACHINE" = "x" ]; then + MACHINE=`basename $ZIMAGE | sed -e 's#.*-\([a-z]*\)-*[0-9]*..*#\1#'` +fi + +source $OEROOT/scripts/runqemu-internal + -- cgit v1.2.3-54-g00ecf