2007-01-16 12:23:08 +00:00
|
|
|
#!/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
|
|
|
|
#
|
|
|
|
|
2007-01-16 13:49:34 +00:00
|
|
|
QEMUIFUP=`which poky-qemu-ifup`
|
2007-01-16 12:23:08 +00:00
|
|
|
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
|
2007-01-17 16:36:32 +00:00
|
|
|
echo "Error, image file $HDIMAGE doesn't exist"
|
2007-01-16 12:23:08 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f "$ZIMAGE" ]; then
|
2007-01-17 16:36:32 +00:00
|
|
|
echo "Error, kernel image file $ZIMAGE doesn't exist"
|
2007-01-16 12:23:08 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2007-01-30 12:23:57 +00:00
|
|
|
if [ "$MACHINE" != "qemuarm" -a "$MACHINE" != "qemux86" -a "$MACHINE" != "akita" -a "$MACHINE" != "spitz" ]; then
|
2007-01-17 16:36:32 +00:00
|
|
|
echo "Error, unsupported machine type $MACHINE"
|
2007-01-16 12:23:08 +00:00
|
|
|
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
|
2007-01-17 16:36:32 +00:00
|
|
|
echo "Error, NFS mount point $HDIMAGE doesn't exist"
|
2007-01-16 12:23:08 +00:00
|
|
|
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
|
2007-01-17 16:36:32 +00:00
|
|
|
echo "Error, NFS mount point $HDIMAGE doesn't exist."
|
2007-01-16 12:23:08 +00:00
|
|
|
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`
|
2007-01-30 12:23:57 +00:00
|
|
|
if [ "$TYPE" = "ext3" ]; then
|
|
|
|
echo $HDIMAGE
|
|
|
|
HDIMAGE=`readlink -f $HDIMAGE`
|
|
|
|
echo $HDIMAGE
|
|
|
|
if [ ! -e "$HDIMAGE.qemudisk" ]; then
|
|
|
|
echo "Adding a partition table to the ext3 image for use by QEMU, please wait..."
|
|
|
|
poky-addptable2image $HDIMAGE $HDIMAGE.qemudisk
|
|
|
|
fi
|
|
|
|
QEMUOPTIONS="$QEMU_NETWORK_CMD -M spitz -hda $HDIMAGE.qemudisk -vertical"
|
|
|
|
fi
|
2007-01-16 12:23:08 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$MACHINE" = "akita" ]; then
|
|
|
|
QEMU=`which qemu-system-arm`
|
2007-01-29 17:03:29 +00:00
|
|
|
if [ "$TYPE" = "jffs2" ]; then
|
2007-01-30 12:23:57 +00:00
|
|
|
HDIMAGE=`readlink -f $HDIMAGE`
|
2007-01-29 17:03:29 +00:00
|
|
|
if [ ! -e "$HDIMAGE.qemuflash" ]; then
|
|
|
|
echo "Converting raw image into flash image format for use by QEMU, please wait..."
|
|
|
|
raw2flash.akita < $HDIMAGE > $HDIMAGE.qemuflash
|
|
|
|
fi
|
|
|
|
QEMUOPTIONS="$QEMU_NETWORK_CMD -M akita -mtdblock $HDIMAGE.qemuflash -vertical"
|
|
|
|
fi
|
2007-01-16 12:23:08 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "x$QEMUOPTIONS" = "x" ]; then
|
2007-01-17 16:36:32 +00:00
|
|
|
echo "Error, unable to support this combination of options"
|
2007-01-16 12:23:08 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2007-01-17 16:36:32 +00:00
|
|
|
echo "Running $QEMU using sudo..."
|
2007-01-16 12:23:08 +00:00
|
|
|
echo "$QEMU -kernel $ZIMAGE $QEMUOPTIONS $SERIALOPTS"
|
|
|
|
sudo $QEMU -kernel $ZIMAGE $QEMUOPTIONS $SERIALOPTS
|
|
|
|
|
|
|
|
|