From 990788b29580f8689933b5af21dc9cb62c726b0e Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Tue, 16 Jan 2007 13:49:34 +0000 Subject: scripts: Rename scripts, update README git-svn-id: https://svn.o-hand.com/repos/poky/trunk@1146 311d38ba-8fff-0310-9ca6-ca027cbcb966 --- scripts/poky-qemu | 45 ++++++++++++++++ scripts/poky-qemu-ifup | 9 ++++ scripts/poky-qemu-internal | 129 +++++++++++++++++++++++++++++++++++++++++++++ scripts/poky-qemu.README | 96 +++++++++++++++++++++++++++++++++ scripts/qemu-ifup | 9 ---- scripts/runqemu | 4 +- scripts/runqemu-internal | 129 --------------------------------------------- scripts/runqemu-standalone | 45 ---------------- scripts/runqemu.README | 61 --------------------- 9 files changed, 281 insertions(+), 246 deletions(-) create mode 100755 scripts/poky-qemu create mode 100755 scripts/poky-qemu-ifup create mode 100755 scripts/poky-qemu-internal create mode 100644 scripts/poky-qemu.README delete mode 100755 scripts/qemu-ifup delete mode 100755 scripts/runqemu-internal delete mode 100755 scripts/runqemu-standalone delete mode 100644 scripts/runqemu.README diff --git a/scripts/poky-qemu b/scripts/poky-qemu new file mode 100755 index 0000000000..8710e05dd6 --- /dev/null +++ b/scripts/poky-qemu @@ -0,0 +1,45 @@ +#!/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 + +INTERNAL_SCRIPT=`which poky-qemu-internal` +source $INTERNAL_SCRIPT + diff --git a/scripts/poky-qemu-ifup b/scripts/poky-qemu-ifup new file mode 100755 index 0000000000..af081fb4d7 --- /dev/null +++ b/scripts/poky-qemu-ifup @@ -0,0 +1,9 @@ +#!/bin/sh + +IFCONFIG=`which ifconfig` +if [ "x$IFCONFIG" = "x" ]; then + # better than nothing... + IFCONFIG=/sbin/ifconfig +fi + +$IFCONFIG tap0 192.168.7.1 diff --git a/scripts/poky-qemu-internal b/scripts/poky-qemu-internal new file mode 100755 index 0000000000..e13f1b6dbe --- /dev/null +++ b/scripts/poky-qemu-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 poky-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/poky-qemu.README b/scripts/poky-qemu.README new file mode 100644 index 0000000000..1b4e763a38 --- /dev/null +++ b/scripts/poky-qemu.README @@ -0,0 +1,96 @@ +Poky images with QEMU +===================== + +Poky can generate qemu bootable kernels and images with can be used +on a desktop system. Both arm and x86 images can currently be booted. +There are two scripts, runqemu and poky-qemu, one for use within poky, +the other externally. + +QEMU outside Poky (poky-qemu) +============================= + +The poky-qemu script is run as: + + MACHINE= poky-qemu + +where: + + is the path to a kernel (e.g. zimage-qemuarm.bin) + is the path to an ext2 image (e.g. filesystem-qemuarm.ext2) + is "qemuarm" or "qemux86" + +The MACHINE= prefix is optional and without it the script will try +to detect the machine name from the name of the file. + +If isn't specified, nfs booting will be assumed. + + +QEMU within Poky (runqemu) +========================== + +The runqemu script is run as: + + runqemu + +where: + + is "qemuarm" or "qemux86" + is "ext2" or "nfs" + is the path to a kernel (zimage-qemuarm.bin) + is the path to an ext2 image (filesystem-qemuarm.ext2) + +It will default to the qemuarm, ext2 and the last kernel and oh-image-sdk +image built by poky. + + +Notes +===== + + - The scripts run qemu using sudo. Change perms on /dev/net/tun to + run as non root + - You can access the host computer at 192.168.7.1 within the image. + - Your qemu system will be accessible as 192.16.7.2. + - The default NFS mount points are /srv/nfs/qemux86 or /srv/nfs/qemuarm + depending on the target type. + - You can set QEMU_MEMORY to control amount of available memory (default 64M). + - You can set SERIAL_LOGFILE to have the serial output from the image logged + to a file. + + +NFS Image Notes +=============== + +As root; + +% apt-get install nfs-kernel-server + +% mkdir /srv/nfs/qemuarm + +Edit via /etc/exports : + +# /etc/exports: the access control list for filesystems which may be exported +# to NFS clients. See exports(5). +/srv/nfs/qemuarm 192.168.7.2(rw,no_root_squash) + +% /etc/init.d/nfs-kernel-server restart + +% modprobe tun + +untar build/tmp/deploy/images/.rootfs.tar.bz2 into /srv/nfs/qemuarm + +Finally, launch: + +% runqemu nfs + +(Substitute qemux86 for qemuarm when using qemux86) + + +Known Issues +============ + + - There is a bug in the ARM qemu in that means occasionally it will use 100% + cpu. You will need to restart it in this situation. + - There is a problem with the ARM image not auto assigning an IP when using an + ext2 image. To have working TCP/IP connectivity run: + 'ifconfig eth0 192.168.7.2 up' + diff --git a/scripts/qemu-ifup b/scripts/qemu-ifup deleted file mode 100755 index af081fb4d7..0000000000 --- a/scripts/qemu-ifup +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -IFCONFIG=`which ifconfig` -if [ "x$IFCONFIG" = "x" ]; then - # better than nothing... - IFCONFIG=/sbin/ifconfig -fi - -$IFCONFIG tap0 192.168.7.1 diff --git a/scripts/runqemu b/scripts/runqemu index 30fd0697c6..7ed080e20a 100755 --- a/scripts/runqemu +++ b/scripts/runqemu @@ -72,7 +72,7 @@ if [ "$MACHINE" = "qemux86" ]; then fi if [ "$TYPE" = "ext2" ]; then if [ "x$HDIMAGE" = "x" ]; then - HDIMAGE=$BUILDDIR/tmp/deploy/images/oh-image-pda-qemux86.ext2 + HDIMAGE=$BUILDDIR/tmp/deploy/images/oh-image-sdk-qemux86.ext2 fi fi CROSSPATH=$BUILDDIR/tmp/cross/i586-poky-linux/bin @@ -92,7 +92,7 @@ else echo "Warning: distccd not present, no distcc support loaded" fi -INTERNAL_SCRIPT=`which runqemu-internal` +INTERNAL_SCRIPT=`which poky-qemu-internal` source $INTERNAL_SCRIPT if [ -x "$DISTCCD" ]; then diff --git a/scripts/runqemu-internal b/scripts/runqemu-internal deleted file mode 100755 index 1ad0ef34b8..0000000000 --- a/scripts/runqemu-internal +++ /dev/null @@ -1,129 +0,0 @@ -#!/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 deleted file mode 100755 index 08829e933f..0000000000 --- a/scripts/runqemu-standalone +++ /dev/null @@ -1,45 +0,0 @@ -#!/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 - -INTERNAL_SCRIPT=`which runqemu-internal` -source $INTERNAL_SCRIPT - diff --git a/scripts/runqemu.README b/scripts/runqemu.README deleted file mode 100644 index 2f68b85cb8..0000000000 --- a/scripts/runqemu.README +++ /dev/null @@ -1,61 +0,0 @@ -Using qemu with poky notes -========================== - -Poky can generate qemu bootable kernels and images with can be used -on a desktop system. Both arm and x86 images can currently be booted. -The runqemu script is run as: - - runqemu - -where: - - is "qemuarm" or "qemux86" - is "ext2" or "nfs" - is the path to a kernel (zimage-qemuarm.bin) - is the path to an ext2 image (filesystem-qemuarm.ext2) - -It will default to the qemuarm, ext2 and the last kernel and oh-image-pda -image built by poky. - -NFS Image Notes -=============== - -As root; - -% apt-get install nfs-kernel-server - -% mkdir /srv/nfs/qemuarm - -Edit via /etc/exports : - -# /etc/exports: the access control list for filesystems which may be exported -# to NFS clients. See exports(5). -/srv/nfs/qemuarm 192.168.7.2(rw,no_root_squash) - -% /etc/init.d/nfs-kernel-server restart - -% modprobe tun - -untar build/tmp/deploy/images/.rootfs.tar.bz2 into /srv/nfs/qemuarm - -Finally, launch: - -% runqemu nfs - -(Substitute qemux86 for qemuarm when using qemux86) - -Notes -===== - - - The runqemu script runs qemu with sudo. Change perms on /dev/net/tun to - run as non root - - You can set QEMU_MEMORY env var to control amount of available memory - ( defaults to 64M ) - - There is a bug in qemu in that means occasionally it will use 100% cpu. - You will need to restart it in this situation. - -More Info -========= - - - See http://o-hand.com/~richard/qemu.html - -- cgit v1.2.3-54-g00ecf