2010-09-17 18:33:01 +00:00
|
|
|
#!/bin/bash -x
|
2007-05-16 13:48:29 +00:00
|
|
|
|
2007-01-16 12:23:08 +00:00
|
|
|
# Handle running Poky images under qemu
|
|
|
|
#
|
2008-01-22 14:12:47 +00:00
|
|
|
# Copyright (C) 2006-2008 OpenedHand Ltd.
|
2007-05-16 13:48:29 +00:00
|
|
|
#
|
2007-01-16 12:23:08 +00:00
|
|
|
# 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.
|
2007-05-16 13:48:29 +00:00
|
|
|
|
2007-01-16 12:23:08 +00:00
|
|
|
# Call setting:
|
2008-01-31 18:45:32 +00:00
|
|
|
# QEMU_MEMORY (optional) - set the amount of memory in the emualted system.
|
|
|
|
# SERIAL_LOGFILE (optional) - log the serial port output to a file
|
|
|
|
# CROSSPATH - the path to any cross toolchain to use with distcc
|
2007-01-16 12:23:08 +00:00
|
|
|
#
|
|
|
|
# Image options:
|
|
|
|
# MACHINE - the machine to run
|
2010-09-28 23:23:54 +00:00
|
|
|
# FSTYPE - the image type to run
|
|
|
|
# KERNEL - the kernel image file to use
|
|
|
|
# ROOTFS - the disk image file to use
|
2007-01-16 12:23:08 +00:00
|
|
|
#
|
|
|
|
|
2008-04-10 09:50:54 +00:00
|
|
|
if [ -z "$QEMU_MEMORY" ]; then
|
2010-09-28 23:23:54 +00:00
|
|
|
case "$MACHINE" in
|
|
|
|
"qemux86")
|
|
|
|
QEMU_MEMORY="128M"
|
|
|
|
;;
|
|
|
|
"qemux86-64")
|
|
|
|
QEMU_MEMORY="128M"
|
|
|
|
;;
|
|
|
|
"qemumips")
|
|
|
|
QEMU_MEMORY="128M"
|
|
|
|
;;
|
|
|
|
"qemuppc")
|
|
|
|
QEMU_MEMORY="128M"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
QEMU_MEMORY="64M"
|
|
|
|
;;
|
|
|
|
esac
|
2008-05-05 08:26:05 +00:00
|
|
|
|
2008-04-10 09:50:54 +00:00
|
|
|
fi
|
|
|
|
|
2010-10-04 04:16:24 +00:00
|
|
|
# This file is created when poky-gen-tapdevs creates a bank of tap
|
|
|
|
# devices, indicating that the user should not bring up new ones using
|
|
|
|
# sudo.
|
2010-10-01 03:39:26 +00:00
|
|
|
NOSUDO_FLAG="/etc/poky-nosudo"
|
|
|
|
|
2007-01-16 13:49:34 +00:00
|
|
|
QEMUIFUP=`which poky-qemu-ifup`
|
2008-01-31 17:42:44 +00:00
|
|
|
QEMUIFDOWN=`which poky-qemu-ifdown`
|
2010-07-21 15:04:59 +00:00
|
|
|
|
2010-09-28 23:23:54 +00:00
|
|
|
NFSRUNNING="false"
|
|
|
|
|
2010-09-29 01:58:33 +00:00
|
|
|
LOCKUTIL=`which lockfile-create`
|
|
|
|
if [ -z "$LOCKUTIL" ]; then
|
|
|
|
echo "Error: Unable to find the lockfile-create utility"
|
|
|
|
echo "On Ubuntu systems this is included in the lockfile-progs package"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2010-08-05 19:13:45 +00:00
|
|
|
LOCKDIR="/tmp/qemu-tap-locks"
|
|
|
|
[ ! -d "$LOCKDIR" ] && mkdir $LOCKDIR
|
|
|
|
|
|
|
|
POSSIBLE=`ifconfig -a | grep '^tap' | awk '{print $1}'`
|
|
|
|
TAP=""
|
|
|
|
LOCKFILE=""
|
|
|
|
for tap in $POSSIBLE; do
|
|
|
|
LOCKFILE="$LOCKDIR/$tap"
|
2010-09-29 01:58:33 +00:00
|
|
|
echo "Acquiring lockfile for $tap..."
|
|
|
|
if lockfile-create --use-pid -r 1 $LOCKFILE; then
|
|
|
|
# the --use-pid option to lockfile-create will give use
|
|
|
|
# the subshell's pid, so override it with the shell's pid:
|
|
|
|
echo $$ > $LOCKFILE.lock
|
2010-09-28 23:23:54 +00:00
|
|
|
TAP=$tap
|
2010-09-29 01:58:33 +00:00
|
|
|
break
|
|
|
|
fi
|
2010-08-05 19:13:45 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
if [ "$TAP" = "" ]; then
|
2010-10-01 03:39:26 +00:00
|
|
|
if [ -e "$NOSUDO_FLAG" ]; then
|
|
|
|
echo "Error: There are no available tap devices to use for networking,"
|
|
|
|
echo "and I see $NOSUDO_FLAG exists, so I am not going to try creating"
|
|
|
|
echo "a new one with sudo."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2010-08-13 18:18:05 +00:00
|
|
|
GROUPID=`id -g`
|
2010-08-05 19:13:45 +00:00
|
|
|
echo 'Setting up tap interface under sudo'
|
2010-09-17 18:33:01 +00:00
|
|
|
tap=`sudo $QEMUIFUP $GROUPID $POKY_NATIVE_SYSROOT`
|
2010-08-18 18:10:14 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
# Re-run standalone to see verbose errors
|
2010-09-03 17:34:24 +00:00
|
|
|
sudo $QEMUIFUP $GROUPID $POKY_NATIVE_SYSROOT
|
2010-08-18 18:10:14 +00:00
|
|
|
return
|
|
|
|
fi
|
2010-09-17 18:33:01 +00:00
|
|
|
LOCKFILE="$LOCKDIR/$tap"
|
2010-09-29 01:58:33 +00:00
|
|
|
echo "Acquiring lockfile for $tap..."
|
|
|
|
if lockfile-create --use-pid -r 1 $LOCKFILE; then
|
|
|
|
# the --use-pid option to lockfile-create will give us
|
|
|
|
# the subshell's pid, so override it with the shell's pid:
|
|
|
|
echo $$ > $LOCKFILE.lock
|
2010-09-28 23:23:54 +00:00
|
|
|
TAP=$tap
|
2010-09-17 18:33:01 +00:00
|
|
|
fi
|
2010-08-05 19:13:45 +00:00
|
|
|
else
|
|
|
|
echo "Using preconfigured tap device '$TAP'"
|
|
|
|
fi
|
2010-07-21 15:04:59 +00:00
|
|
|
|
2010-08-13 18:18:05 +00:00
|
|
|
release_lock() {
|
2010-10-04 04:16:24 +00:00
|
|
|
if [ ! -e "$NOSUDO_FLAG" ]; then
|
2010-09-10 09:27:46 +00:00
|
|
|
$QEMUIFDOWN $TAP $POKY_NATIVE_SYSROOT
|
2010-09-28 23:23:54 +00:00
|
|
|
fi
|
2010-10-04 04:16:24 +00:00
|
|
|
echo "Releasing lockfile of preconfigured tap device '$TAP'"
|
|
|
|
lockfile-remove $LOCKFILE
|
|
|
|
|
|
|
|
if [ "$NFSRUNNING" = "true" ]; then
|
|
|
|
echo "Shutting down the userspace NFS server..."
|
|
|
|
echo "poky-export-rootfs stop $ROOTFS"
|
|
|
|
poky-export-rootfs stop $ROOTFS
|
|
|
|
fi
|
2010-08-13 18:18:05 +00:00
|
|
|
}
|
|
|
|
|
2010-09-10 09:28:09 +00:00
|
|
|
n1=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ]
|
|
|
|
n2=$[ (`echo $TAP | sed 's/tap//'` * 2) + 2 ]
|
|
|
|
|
|
|
|
KERNEL_NETWORK_CMD="ip=192.168.7.$n2::192.168.7.$n1:255.255.255.0"
|
2010-07-21 15:04:59 +00:00
|
|
|
QEMU_TAP_CMD="-net tap,vlan=0,ifname=$TAP,script=no,downscript=no"
|
2008-04-24 22:13:25 +00:00
|
|
|
QEMU_NETWORK_CMD="-net nic,vlan=0 $QEMU_TAP_CMD"
|
2008-01-09 20:13:45 +00:00
|
|
|
KERNCMDLINE="mem=$QEMU_MEMORY"
|
2010-06-04 22:23:37 +00:00
|
|
|
QEMU_UI_OPTIONS="-show-cursor -usb -usbdevice wacom-tablet"
|
2007-01-16 12:23:08 +00:00
|
|
|
|
2010-10-04 04:16:24 +00:00
|
|
|
NFS_INSTANCE=`echo $TAP | sed 's/tap//'`
|
|
|
|
export NFS_INSTANCE
|
|
|
|
|
2007-01-16 12:23:08 +00:00
|
|
|
SERIALOPTS=""
|
|
|
|
if [ "x$SERIAL_LOGFILE" != "x" ]; then
|
|
|
|
SERIALOPTS="-serial file:$SERIAL_LOGFILE"
|
|
|
|
fi
|
|
|
|
|
2008-02-22 16:23:33 +00:00
|
|
|
case "$MACHINE" in
|
2010-09-28 23:23:54 +00:00
|
|
|
"qemuarm") ;;
|
|
|
|
"qemumips") ;;
|
|
|
|
"qemuppc") ;;
|
|
|
|
"qemuarmv6") ;;
|
|
|
|
"qemuarmv7") ;;
|
|
|
|
"qemux86") ;;
|
|
|
|
"qemux86-64") ;;
|
|
|
|
"akita") ;;
|
|
|
|
"spitz") ;;
|
|
|
|
*)
|
|
|
|
echo "Error: Unsupported machine type $MACHINE"
|
|
|
|
return
|
|
|
|
;;
|
2008-02-22 16:23:33 +00:00
|
|
|
esac
|
|
|
|
|
2010-09-28 23:23:54 +00:00
|
|
|
if [ ! -f "$KERNEL" ]; then
|
|
|
|
echo "Error: Kernel image file $KERNEL doesn't exist"
|
2010-08-13 18:18:05 +00:00
|
|
|
release_lock
|
2007-07-25 10:39:44 +00:00
|
|
|
return
|
2007-01-16 12:23:08 +00:00
|
|
|
fi
|
|
|
|
|
2010-09-28 23:23:54 +00:00
|
|
|
if [ "$FSTYPE" != "nfs" -a ! -f "$ROOTFS" ]; then
|
|
|
|
echo "Error: Image file $ROOTFS doesn't exist"
|
|
|
|
release_lock
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$FSTYPE" = "nfs" ]; then
|
2010-08-13 18:18:05 +00:00
|
|
|
NFS_SERVER="192.168.7.1"
|
2010-09-28 23:23:54 +00:00
|
|
|
NFS_DIR=`echo $ROOTFS | sed 's/^[^:]*:\(.*\)/\1/'`
|
2010-10-04 04:16:24 +00:00
|
|
|
MOUNTD_PORT=$[ 21111 + $NFS_INSTANCE ]
|
|
|
|
NFSD_PORT=$[ 11111 + $NFS_INSTANCE ]
|
|
|
|
UNFS_OPTS="nfsvers=2,mountprog=$MOUNTD_PORT,nfsprog=$NFSD_PORT,udp"
|
2010-09-28 23:23:54 +00:00
|
|
|
|
|
|
|
PSEUDO_LOCALSTATEDIR=~/.poky-sdk/pseudo
|
|
|
|
export PSEUDO_LOCALSTATEDIR
|
|
|
|
|
|
|
|
rpcbind_running=`ps ax | grep rpcbind | grep -v grep | wc -l`
|
|
|
|
portmap_running=`ps ax | grep portmap | grep -v grep | wc -l`
|
|
|
|
if [[ $rpcbind_running == 0 && $portmap_running == 0 ]]; then
|
|
|
|
echo "You need to be running either rpcbind or portmap to continue"
|
|
|
|
release_lock
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Start the userspace NFS server
|
|
|
|
echo "poky-export-rootfs restart $ROOTFS"
|
|
|
|
poky-export-rootfs restart $ROOTFS
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
release_lock
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
NFSRUNNING="true"
|
2010-08-05 18:50:14 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$NFS_SERVER" = "" ]; then
|
|
|
|
NFS_SERVER="192.168.7.1"
|
2010-09-28 23:23:54 +00:00
|
|
|
NFS_DIR=$ROOTFS
|
2007-01-16 12:23:08 +00:00
|
|
|
fi
|
|
|
|
|
2010-10-01 14:09:47 +00:00
|
|
|
if [ "$MACHINE" = "qemuarm" -o "$MACHINE" = "qemuarmv6" -o "$MACHINE" = "qemuarmv7" ]; then
|
|
|
|
if [ -e /proc/sys/vm/mmap_min_addr ]; then
|
|
|
|
if [ `cat /proc/sys/vm/mmap_min_addr` != "0" ]; then
|
|
|
|
echo "Error, please set /proc/sys/vm/mmap_min_addr to 0 since otherwise it can cause problems with QEMU"
|
|
|
|
return
|
|
|
|
fi
|
2010-09-29 11:18:34 +00:00
|
|
|
fi
|
|
|
|
|
2008-02-04 19:29:39 +00:00
|
|
|
QEMU=qemu-system-arm
|
2010-07-09 13:26:43 +00:00
|
|
|
MACHINE_SUBTYPE=versatilepb
|
|
|
|
QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS"
|
2010-06-04 22:23:37 +00:00
|
|
|
# QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS -force-pointer"
|
2010-09-28 23:23:54 +00:00
|
|
|
if [ "$FSTYPE" = "ext3" ]; then
|
2010-07-09 13:26:43 +00:00
|
|
|
KERNCMDLINE="root=/dev/sda console=ttyAMA0,115200 console=tty $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY highres=off"
|
2010-09-28 23:23:54 +00:00
|
|
|
QEMUOPTIONS="$QEMU_NETWORK_CMD -M versatilepb -hda $ROOTFS -no-reboot $QEMU_UI_OPTIONS"
|
2007-01-16 12:23:08 +00:00
|
|
|
fi
|
2010-09-28 23:23:54 +00:00
|
|
|
if [ "$FSTYPE" = "nfs" ]; then
|
2010-08-05 18:50:14 +00:00
|
|
|
if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then
|
2010-09-28 23:23:54 +00:00
|
|
|
echo "Error: NFS mount point $ROOTFS doesn't exist"
|
2010-08-13 18:18:05 +00:00
|
|
|
release_lock
|
2007-07-25 10:39:44 +00:00
|
|
|
return
|
2007-01-16 12:23:08 +00:00
|
|
|
fi
|
2010-08-13 18:18:05 +00:00
|
|
|
KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
|
2010-06-04 22:23:37 +00:00
|
|
|
QEMUOPTIONS="$QEMU_NETWORK_CMD -M versatilepb --no-reboot $QEMU_UI_OPTIONS"
|
2007-01-16 12:23:08 +00:00
|
|
|
fi
|
2010-09-28 23:23:54 +00:00
|
|
|
if [ "$MACHINE" = "qemuarmv6" ]; then
|
|
|
|
QEMUOPTIONS="$QEMUOPTIONS -cpu arm1136"
|
|
|
|
fi
|
|
|
|
if [ "$MACHINE" = "qemuarmv7" ]; then
|
|
|
|
QEMUOPTIONS="$QEMUOPTIONS -cpu cortex-a8"
|
|
|
|
fi
|
2007-01-16 12:23:08 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$MACHINE" = "qemux86" ]; then
|
2008-02-04 19:29:39 +00:00
|
|
|
QEMU=qemu
|
2010-06-04 22:23:37 +00:00
|
|
|
QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS -vga vmware -enable-gl"
|
2010-09-28 23:23:54 +00:00
|
|
|
if [ "$FSTYPE" = "ext3" ]; then
|
2009-01-21 17:40:51 +00:00
|
|
|
KERNCMDLINE="vga=0 root=/dev/hda mem=$QEMU_MEMORY $KERNEL_NETWORK_CMD"
|
2010-09-28 23:23:54 +00:00
|
|
|
QEMUOPTIONS="$QEMU_NETWORK_CMD -hda $ROOTFS $QEMU_UI_OPTIONS"
|
2007-01-16 12:23:08 +00:00
|
|
|
fi
|
2010-09-28 23:23:54 +00:00
|
|
|
if [ "$FSTYPE" = "nfs" ]; then
|
2010-08-05 18:50:14 +00:00
|
|
|
if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then
|
2010-09-28 23:23:54 +00:00
|
|
|
echo "Error: NFS mount point $ROOTFS doesn't exist."
|
2010-08-13 18:18:05 +00:00
|
|
|
release_lock
|
2007-07-25 10:39:44 +00:00
|
|
|
return
|
2007-01-16 12:23:08 +00:00
|
|
|
fi
|
2010-08-13 18:18:05 +00:00
|
|
|
KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
|
2010-06-04 22:23:37 +00:00
|
|
|
QEMUOPTIONS="$QEMU_NETWORK_CMD $QEMU_UI_OPTIONS"
|
2007-01-16 12:23:08 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2010-08-02 16:54:03 +00:00
|
|
|
if [ "$MACHINE" = "qemux86-64" ]; then
|
|
|
|
QEMU=qemu-system-x86_64
|
|
|
|
QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS -vga vmware -enable-gl"
|
2010-09-28 23:23:54 +00:00
|
|
|
if [ "$FSTYPE" = "ext3" ]; then
|
2010-08-02 16:54:03 +00:00
|
|
|
KERNCMDLINE="vga=0 root=/dev/hda mem=$QEMU_MEMORY $KERNEL_NETWORK_CMD"
|
2010-09-28 23:23:54 +00:00
|
|
|
QEMUOPTIONS="$QEMU_NETWORK_CMD -hda $ROOTFS $QEMU_UI_OPTIONS"
|
2010-08-02 16:54:03 +00:00
|
|
|
fi
|
2010-09-28 23:23:54 +00:00
|
|
|
if [ "$FSTYPE" = "nfs" ]; then
|
|
|
|
if [ "x$ROOTFS" = "x" ]; then
|
|
|
|
ROOTFS=/srv/nfs/qemux86-64
|
2010-08-02 16:54:03 +00:00
|
|
|
fi
|
2010-09-28 23:23:54 +00:00
|
|
|
if [ ! -d "$ROOTFS" ]; then
|
|
|
|
echo "Error: NFS mount point $ROOTFS doesn't exist."
|
2010-08-13 18:18:05 +00:00
|
|
|
release_lock
|
2010-08-02 16:54:03 +00:00
|
|
|
return
|
|
|
|
fi
|
2010-08-13 18:18:05 +00:00
|
|
|
KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
|
2010-08-02 16:54:03 +00:00
|
|
|
QEMUOPTIONS="$QEMU_NETWORK_CMD $QEMU_UI_OPTIONS"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2007-01-16 12:23:08 +00:00
|
|
|
if [ "$MACHINE" = "spitz" ]; then
|
2008-02-04 19:29:39 +00:00
|
|
|
QEMU=qemu-system-arm
|
2010-09-28 23:23:54 +00:00
|
|
|
if [ "$FSTYPE" = "ext3" ]; then
|
|
|
|
echo $ROOTFS
|
|
|
|
ROOTFS=`readlink -f $ROOTFS`
|
|
|
|
echo $ROOTFS
|
|
|
|
if [ ! -e "$ROOTFS.qemudisk" ]; then
|
2007-01-30 12:23:57 +00:00
|
|
|
echo "Adding a partition table to the ext3 image for use by QEMU, please wait..."
|
2010-09-28 23:23:54 +00:00
|
|
|
poky-addptable2image $ROOTFS $ROOTFS.qemudisk
|
2007-01-30 12:23:57 +00:00
|
|
|
fi
|
2010-09-28 23:23:54 +00:00
|
|
|
QEMUOPTIONS="$QEMU_NETWORK_CMD -M spitz -hda $ROOTFS.qemudisk -portrait"
|
2007-01-30 12:23:57 +00:00
|
|
|
fi
|
2007-01-16 12:23:08 +00:00
|
|
|
fi
|
|
|
|
|
2010-07-09 13:26:43 +00:00
|
|
|
if [ "$MACHINE" = "qemumips" ]; then
|
|
|
|
QEMU=qemu-system-mips
|
|
|
|
MACHINE_SUBTYPE=malta
|
2010-09-21 20:38:08 +00:00
|
|
|
QEMU_UI_OPTIONS="-vga cirrus"
|
2010-07-09 13:26:43 +00:00
|
|
|
if [ "$TYPE" = "ext3" ]; then
|
|
|
|
#KERNCMDLINE="root=/dev/hda console=ttyS0 console=tty0 $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
|
|
|
|
KERNCMDLINE="root=/dev/hda console=ttyS0 console=tty $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
|
2010-09-28 23:23:54 +00:00
|
|
|
QEMUOPTIONS="$QEMU_NETWORK_CMD -M $MACHINE_SUBTYPE -hda $ROOTFS -no-reboot $QEMU_UI_OPTIONS"
|
2010-07-09 13:26:43 +00:00
|
|
|
fi
|
2010-09-28 23:23:54 +00:00
|
|
|
if [ "$FSTYPE" = "nfs" ]; then
|
2010-09-25 03:22:23 +00:00
|
|
|
if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then
|
2010-09-28 23:23:54 +00:00
|
|
|
echo "Error: NFS mount point $ROOTFS doesn't exist"
|
2010-09-25 03:22:23 +00:00
|
|
|
release_lock
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
KERNCMDLINE="root=/dev/nfs console=ttyS0 console=tty nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
|
|
|
|
QEMUOPTIONS="$QEMU_NETWORK_CMD -M $MACHINE_SUBTYPE -no-reboot $QEMU_UI_OPTIONS"
|
|
|
|
fi
|
2010-07-09 13:26:43 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$MACHINE" = "qemuppc" ]; then
|
|
|
|
QEMU=qemu-system-ppc
|
|
|
|
MACHINE_SUBTYPE=prep
|
|
|
|
CPU_SUBTYPE=603e
|
|
|
|
BIOS=powerpc_rom.bin
|
|
|
|
QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS -nographic"
|
2010-09-28 23:23:54 +00:00
|
|
|
if [ "$FSTYPE" = "ext3" ]; then
|
2010-07-09 13:26:43 +00:00
|
|
|
KERNCMDLINE="root=/dev/hda console=ttyS0 console=tty0 $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
|
2010-09-28 23:23:54 +00:00
|
|
|
QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE -M $MACHINE_SUBTYPE -bios $BIOS -hda $ROOTFS -no-reboot $QEMU_UI_OPTIONS"
|
2010-07-09 13:26:43 +00:00
|
|
|
fi
|
2010-09-28 23:23:54 +00:00
|
|
|
if [ "$FSTYPE" = "nfs" ]; then
|
2010-09-25 03:22:23 +00:00
|
|
|
if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then
|
2010-09-28 23:23:54 +00:00
|
|
|
echo "Error: NFS mount point $ROOTFS doesn't exist"
|
2010-09-25 03:22:23 +00:00
|
|
|
release_lock
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
KERNCMDLINE="root=/dev/nfs console=ttyS0 console=tty0 nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
|
|
|
|
QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE -M $MACHINE_SUBTYPE -bios $BIOS -no-reboot $QEMU_UI_OPTIONS"
|
|
|
|
fi
|
2010-07-09 13:26:43 +00:00
|
|
|
fi
|
|
|
|
|
2007-01-16 12:23:08 +00:00
|
|
|
if [ "$MACHINE" = "akita" ]; then
|
2008-02-04 19:29:39 +00:00
|
|
|
QEMU=qemu-system-arm
|
2010-09-28 23:23:54 +00:00
|
|
|
if [ "$FSTYPE" = "jffs2" ]; then
|
|
|
|
ROOTFS=`readlink -f $ROOTFS`
|
|
|
|
if [ ! -e "$ROOTFS.qemuflash" ]; then
|
2007-01-29 17:03:29 +00:00
|
|
|
echo "Converting raw image into flash image format for use by QEMU, please wait..."
|
2010-09-28 23:23:54 +00:00
|
|
|
raw2flash.akita < $ROOTFS > $ROOTFS.qemuflash
|
2008-04-23 09:58:18 +00:00
|
|
|
fi
|
2010-09-28 23:23:54 +00:00
|
|
|
QEMUOPTIONS="$QEMU_NETWORK_CMD -M akita -mtdblock $ROOTFS.qemuflash -portrait"
|
2008-04-23 09:58:18 +00:00
|
|
|
fi
|
|
|
|
fi
|
2008-04-10 09:50:54 +00:00
|
|
|
|
2007-01-16 12:23:08 +00:00
|
|
|
if [ "x$QEMUOPTIONS" = "x" ]; then
|
2008-02-22 16:23:33 +00:00
|
|
|
echo "Error: Unable to support this combination of options"
|
2010-08-13 18:18:05 +00:00
|
|
|
release_lock
|
2007-07-25 10:39:44 +00:00
|
|
|
return
|
2007-01-16 12:23:08 +00:00
|
|
|
fi
|
|
|
|
|
2010-08-02 16:54:03 +00:00
|
|
|
SDKDIR="/opt/poky/sysroots"
|
2008-04-10 09:50:54 +00:00
|
|
|
if [ "$MACHINE" = "qemuarm" -o "$MACHINE" = "spitz" -o "$MACHINE" = "borzoi" -o "$MACHINE" = "akita" -o "$MACHINE" = "nokia800" ]; then
|
2010-08-02 16:54:03 +00:00
|
|
|
SDKPATH="$SDKDIR/arm-poky-linux-gnueabi/bin"
|
2008-01-31 18:45:32 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$MACHINE" = "qemux86" ]; then
|
2010-08-02 16:54:03 +00:00
|
|
|
SDKPATH="$SDKDIR/i586-poky-linux/bin"
|
2008-01-31 18:45:32 +00:00
|
|
|
fi
|
2010-08-02 16:54:03 +00:00
|
|
|
|
|
|
|
if [ "$MACHINE" = "qemux86-64" ]; then
|
|
|
|
SDKPATH="$SDKDIR/x86_64-poky-linux/bin"
|
|
|
|
fi
|
|
|
|
|
2008-01-31 18:45:32 +00:00
|
|
|
PATH=$CROSSPATH:$SDKPATH:$PATH
|
|
|
|
|
2008-02-04 19:29:39 +00:00
|
|
|
QEMUBIN=`which $QEMU`
|
|
|
|
|
2008-02-22 16:23:33 +00:00
|
|
|
if [ ! -x "$QEMUBIN" ]; then
|
|
|
|
echo "Error: No QEMU binary '$QEMU' could be found."
|
2010-08-13 18:18:05 +00:00
|
|
|
release_lock
|
2008-02-22 16:23:33 +00:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2008-01-31 17:42:44 +00:00
|
|
|
function _quit() {
|
|
|
|
if [ -n "$PIDFILE" ]; then
|
2008-01-31 18:45:32 +00:00
|
|
|
#echo kill `cat $PIDFILE`
|
2008-01-31 17:42:44 +00:00
|
|
|
kill `cat $PIDFILE`
|
|
|
|
fi
|
2010-08-13 18:18:05 +00:00
|
|
|
release_lock
|
2008-01-31 17:42:44 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
DISTCCD=`which distccd`
|
|
|
|
PIDFILE=""
|
|
|
|
|
|
|
|
trap _quit INT TERM QUIT
|
|
|
|
|
|
|
|
if [ -x "$DISTCCD" ]; then
|
|
|
|
echo "Starting distccd..."
|
|
|
|
PIDFILE=`mktemp`
|
|
|
|
$DISTCCD --allow 192.168.7.2 --daemon --pid-file $PIDFILE &
|
|
|
|
else
|
|
|
|
echo "Warning: distccd not present, no distcc support loaded."
|
|
|
|
fi
|
|
|
|
|
2010-07-21 15:04:59 +00:00
|
|
|
echo "Running $QEMU..."
|
2010-09-28 23:23:54 +00:00
|
|
|
echo $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS $* --append '"'$KERNCMDLINE'"'
|
|
|
|
$QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS $* --append "$KERNCMDLINE" || /bin/true
|
2010-07-21 15:04:59 +00:00
|
|
|
|
2010-08-13 18:18:05 +00:00
|
|
|
release_lock
|
2008-01-31 17:42:44 +00:00
|
|
|
|
|
|
|
trap - INT TERM QUIT
|
|
|
|
return
|