summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorRichard Purdie <richard@openedhand.com>2007-01-16 12:23:08 +0000
committerRichard Purdie <richard@openedhand.com>2007-01-16 12:23:08 +0000
commit295818470acd4628df8c5de20a8843cb90171b5b (patch)
treeb4734ac58b2195b2b5e8399662df6fc953924533 /scripts
parent5d4e6e72ccd5cf680c4924d10651745cf29b62ba (diff)
downloadpoky-295818470acd4628df8c5de20a8843cb90171b5b.tar.gz
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
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/runqemu89
-rw-r--r--scripts/runqemu-internal129
-rwxr-xr-xscripts/runqemu-standalone44
3 files changed, 214 insertions, 48 deletions
diff --git a/scripts/runqemu b/scripts/runqemu
index 63ea856b65..433ceb7e35 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -1,4 +1,20 @@
1#!/bin/sh 1#!/bin/sh
2#
3# Handle Poky <-> QEmu interface voodoo
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 2 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17#
2 18
3if [ "x$BUILDDIR" = "x" ]; then 19if [ "x$BUILDDIR" = "x" ]; then
4 echo "You need to source poky-init-build-env before running this script" 20 echo "You need to source poky-init-build-env before running this script"
@@ -7,17 +23,21 @@ fi
7 23
8PATH=$BUILDDIR/tmp/staging/$BUILD_SYS/bin:$BUILDDIR/tmp/cross/bin:$PATH 24PATH=$BUILDDIR/tmp/staging/$BUILD_SYS/bin:$BUILDDIR/tmp/cross/bin:$PATH
9 25
10KERNEL_NETWORK_CMD="ip=192.168.7.2::192.168.7.1:255.255.255.0"
11QEMU_NETWORK_CMD="-net nic,vlan=0 -net tap,vlan=0,ifname=tap0,script=$OEROOT/scripts/qemu-ifup"
12
13if [ -z "$QEMU_MEMORY" ]; then 26if [ -z "$QEMU_MEMORY" ]; then
14 QEMU_MEMORY="64M" 27 QEMU_MEMORY="64M"
15fi 28fi
16 29
17if [ "x$1" != "x" ]; then 30if [ "x$1" = "x" ]; then
18 MACHINE=$1 31 echo
32 echo "Run as $0 MACHINE IMAGETYPE ZIMAGE IMAGEFILE"
33 echo "where:"
34 echo " MACHINE - the machine to emulate (qemuarm, qemux86)"
35 echo " IMAGETYPE - the type of image to run (ext2, nfs) (default: ext2)"
36 echo " ZIMAGE - the kernel to use (optional)"
37 echo " IMAGEFILE - the image file/location to use (optional)"
38 exit 1
19else 39else
20 MACHINE="qemuarm" 40 MACHINE=$1
21fi 41fi
22 42
23if [ "x$2" != "x" ]; then 43if [ "x$2" != "x" ]; then
@@ -35,18 +55,30 @@ if [ "x$4" != "x" ]; then
35fi 55fi
36 56
37if [ "$MACHINE" = "qemuarm" -o "$MACHINE" = "spitz" -o "$MACHINE" = "borzoi" -o "$MACHINE" = "akita" ]; then 57if [ "$MACHINE" = "qemuarm" -o "$MACHINE" = "spitz" -o "$MACHINE" = "borzoi" -o "$MACHINE" = "akita" ]; then
38 QEMU=`which qemu-system-arm`
39 if [ "x$ZIMAGE" = "x" ]; then 58 if [ "x$ZIMAGE" = "x" ]; then
40 ZIMAGE=$BUILDDIR/tmp/deploy/images/zImage-$MACHINE.bin 59 ZIMAGE=$BUILDDIR/tmp/deploy/images/zImage-$MACHINE.bin
41 fi 60 fi
42 CROSSPATH=$BUILDDIR/tmp/cross/arm-poky-linux/bin 61 CROSSPATH=$BUILDDIR/tmp/cross/arm-poky-linux/bin
43fi 62fi
44 63
64
65if [ "$MACHINE" = "qemuarm" ]; then
66 if [ "$TYPE" = "ext2" ]; then
67 if [ "x$HDIMAGE" = "x" ]; then
68 HDIMAGE=$BUILDDIR/tmp/deploy/images/oh-image-sdk-qemuarm.ext2
69 fi
70 fi
71fi
72
45if [ "$MACHINE" = "qemux86" ]; then 73if [ "$MACHINE" = "qemux86" ]; then
46 QEMU=`which qemu`
47 if [ "x$ZIMAGE" = "x" ]; then 74 if [ "x$ZIMAGE" = "x" ]; then
48 ZIMAGE=$BUILDDIR/tmp/deploy/images/bzImage-$MACHINE.bin 75 ZIMAGE=$BUILDDIR/tmp/deploy/images/bzImage-$MACHINE.bin
49 fi 76 fi
77 if [ "$TYPE" = "ext2" ]; then
78 if [ "x$HDIMAGE" = "x" ]; then
79 HDIMAGE=$BUILDDIR/tmp/deploy/images/oh-image-pda-qemux86.ext2
80 fi
81 fi
50 CROSSPATH=$BUILDDIR/tmp/cross/i586-poky-linux/bin 82 CROSSPATH=$BUILDDIR/tmp/cross/i586-poky-linux/bin
51fi 83fi
52 84
@@ -58,54 +90,15 @@ fi
58 90
59DISTCCD=`which distccd` 91DISTCCD=`which distccd`
60 92
61
62if [ -x "$DISTCCD" ]; then 93if [ -x "$DISTCCD" ]; then
63 $DISTCCD --allow 192.168.7.2 --daemon 94 $DISTCCD --allow 192.168.7.2 --daemon
64else 95else
65 echo "Warning: distccd not present, no distcc support loaded" 96 echo "Warning: distccd not present, no distcc support loaded"
66fi 97fi
67 98
68if [ "$MACHINE" = "qemuarm" ]; then 99source $OEROOT/scripts/runqemu-internal
69 if [ "$TYPE" = "ext2" ]; then
70 if [ "x$HDIMAGE" = "x" ]; then
71 HDIMAGE=$BUILDDIR/tmp/deploy/images/oh-image-sdk-qemuarm.ext2
72 fi
73 QEMUOPTIONS="-append \"root=/dev/sda mem=$QEMU_MEMORY\" $QEMU_NETWORK_CMD -M versatilepb -hda $HDIMAGE -usb -usbdevice wacom-tablet"
74 fi
75 if [ "$TYPE" = "nfs" ]; then
76 dd if=/dev/zero of=/tmp/blank bs=1024 count=8192
77 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"
78 fi
79fi
80
81if [ "$MACHINE" = "qemux86" ]; then
82 if [ "$TYPE" = "ext2" ]; then
83 if [ "x$HDIMAGE" = "x" ]; then
84 HDIMAGE=$BUILDDIR/tmp/deploy/images/oh-image-pda-qemux86.ext2
85 fi
86 # video=vesafb:1024x768-32@86
87 QEMUOPTIONS="-std-vga -append \"root=/dev/hda mem=$QEMU_MEMORY $KERNEL_NETWORK_CMD\" $QEMU_NETWORK_CMD -hda $HDIMAGE -usb -usbdevice wacom-tablet"
88 fi
89 if [ "$TYPE" = "nfs" ]; then
90 dd if=/dev/zero of=/tmp/blank bs=1024 count=8192
91 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"
92 fi
93fi
94
95if [ "x$QEMUOPTIONS" = "x" ]; then
96 echo "Sorry, unable to support this configuration"
97 exit 1
98fi
99
100echo "Running $QEMU using sudo..."
101echo "$QEMU -kernel $ZIMAGE $QEMUOPTIONS"
102sudo $QEMU -kernel $ZIMAGE $QEMUOPTIONS
103# -serial file:serial.log
104 100
105if [ -x "$DISTCCD" ]; then 101if [ -x "$DISTCCD" ]; then
106 killall distccd 102 killall distccd
107fi 103fi
108 104
109if [ -e /tmp/blank ]; then
110 rm /tmp/blank
111fi
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 @@
1#!/bin/sh
2#
3# Handle running Poky images under qemu
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 2 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17#
18#
19# Call setting:
20# QEMU_MEMORY (optional) set the amount of memory in the emualted system.
21# SERIAL_LOGFILE (optional) log the serial port output to a file
22#
23# Image options:
24# MACHINE - the machine to run
25# TYPE - the image type to run
26# ZIMAGE - the kernel image file to use
27# HDIMAGE - the disk image file to use
28#
29
30QEMUIFUP=`which qemu-ifup`
31KERNEL_NETWORK_CMD="ip=192.168.7.2::192.168.7.1:255.255.255.0"
32QEMU_NETWORK_CMD="-net nic,vlan=0 -net tap,vlan=0,ifname=tap0,script=$QEMUIFUP"
33
34if [ -z "$QEMU_MEMORY" ]; then
35 QEMU_MEMORY="64M"
36fi
37
38SERIALOPTS=""
39if [ "x$SERIAL_LOGFILE" != "x" ]; then
40 SERIALOPTS="-serial file:$SERIAL_LOGFILE"
41fi
42
43if [ "$TYPE" != "nfs" -a ! -f "$HDIMAGE" ]; then
44 echo -e "\nError, image file $HDIMAGE doesn't exist"
45 exit 1
46fi
47
48if [ ! -f "$ZIMAGE" ]; then
49 echo -e "\nError, kernel image file $ZIMAGE doesn't exist"
50 exit 1
51fi
52
53if [ "$MACHINE" != "qemuarm" -a "$MACHINE" != "qemux86" ]; then
54 echo -e "\nError, unsupported machine type $MACHINE"
55 exit 1
56fi
57
58if [ "$MACHINE" = "qemuarm" ]; then
59 QEMU=`which qemu-system-arm`
60 if [ "$TYPE" = "ext2" ]; then
61 QEMUOPTIONS="-append \"root=/dev/sda console=ttyAMA0 console=tty0 mem=$QEMU_MEMORY\" $QEMU_NETWORK_CMD -M versatilepb -hda $HDIMAGE -usb -usbdevice wacom-tablet"
62 fi
63 if [ "$TYPE" = "nfs" ]; then
64 if [ "x$HDIMAGE" = "x" ]; then
65 HDIMAGE=/srv/nfs/qemuarm
66 fi
67 if [ ! -d "$HDIMAGE" ]; then
68 echo -e "\nError, NFS mount point $HDIMAGE doesn't exist"
69 exit 1
70 fi
71 QEMUOPTIONS="-append \"root=/dev/nfs nfsroot=192.168.7.1:$HDIMAGE rw $KERNEL_NETWORK_CMD\" $QEMU_NETWORK_CMD -M versatilepb"
72 fi
73fi
74
75if [ "$MACHINE" = "qemux86" ]; then
76 QEMU=`which qemu`
77 if [ "$TYPE" = "ext2" ]; then
78 QEMUOPTIONS="-std-vga -append \"root=/dev/hda mem=$QEMU_MEMORY $KERNEL_NETWORK_CMD\" $QEMU_NETWORK_CMD -hda $HDIMAGE -usb -usbdevice wacom-tablet"
79 fi
80 if [ "$TYPE" = "nfs" ]; then
81 if [ "x$HDIMAGE" = "x" ]; then
82 HDIMAGE=/srv/nfs/qemux86
83 fi
84 if [ ! -d "$HDIMAGE" ]; then
85 echo -e "\nError, NFS mount point $HDIMAGE doesn't exist."
86 exit 1
87 fi
88 QEMUOPTIONS="-std-vga -append \"root=/dev/nfs nfsroot=192.168.7.1:$HDIMAGE rw $KERNEL_NETWORK_CMD\" $QEMU_NETWORK_CMD"
89 fi
90fi
91
92if [ "$MACHINE" = "spitz" ]; then
93 QEMU=`which qemu-system-arm`
94# QEMU=/usr/local/bin/qemu-system-arm
95# if [ "$TYPE" = "ext2" ]; then
96# if [ "x$HDIMAGE" = "x" ]; then
97# HDIMAGE=`readlink -f $BUILDDIR/tmp/deploy/images/oh-image-sdk-spitz.ext2`
98# if [ ! -e $HDIMAGE.mbr ]; then
99# cp $OEROOT/mbr.bin $HDIMAGE.mbr
100# cat $HDIMAGE >> $HDIMAGE.mbr
101# fi
102# HDIMAGE=$BUILDDIR/tmp/deploy/images/hdaimage.bin
103# fi
104# QEMUOPTIONS="-append \"root=/dev/sda mem=$QEMU_MEMORY\" $QEMU_NETWORK_CMD -M spitz -hda $HDIMAGE"
105# fi
106fi
107
108if [ "$MACHINE" = "akita" ]; then
109 QEMU=`which qemu-system-arm`
110# QEMU=/usr/local/bin/qemu-system-arm
111# if [ "$TYPE" = "ext2" ]; then
112# if [ "x$HDIMAGE" = "x" ]; then
113# HDIMAGE=$BUILDDIR/tmp/deploy/images/oh-image-sdk-akita.jffs2
114# HDIMAGE=$BUILDDIR/tmp/deploy/images/akita.test
115# fi
116# QEMUOPTIONS="$QEMU_NETWORK_CMD -M akita -hdd $HDIMAGE"
117# fi
118fi
119
120if [ "x$QEMUOPTIONS" = "x" ]; then
121 echo -e "\nError, unable to support this combination of options"
122 exit 1
123fi
124
125echo -e "\nRunning $QEMU using sudo..."
126echo "$QEMU -kernel $ZIMAGE $QEMUOPTIONS $SERIALOPTS"
127sudo $QEMU -kernel $ZIMAGE $QEMUOPTIONS $SERIALOPTS
128
129
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 @@
1#!/bin/sh
2#
3# Handle running Poky images standalone
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 2 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17#
18
19if [ "x$1" = "x" ]; then
20 MYNAME=`basename $0`
21 echo -e "\nRun as MACHINE=xyz $MYNAME ZIMAGE IMAGEFILE"
22 echo "where:"
23 echo " ZIMAGE - the kernel image file to use"
24 echo " IMAGEFILE - the image file/location to use"
25 echo " (NFS booting assumed if IMAGEFILE not specified)"
26 echo " MACHINE=xyz - the machine name (optional, autodetected from ZIMAGE if unspecified)"
27 exit 1
28else
29 ZIMAGE=$1
30fi
31
32if [ "x$2" = "x" ]; then
33 TYPE="nfs"
34else
35 TYPE="ext2"
36 HDIMAGE=$2
37fi
38
39if [ "x$MACHINE" = "x" ]; then
40 MACHINE=`basename $ZIMAGE | sed -e 's#.*-\([a-z]*\)-*[0-9]*..*#\1#'`
41fi
42
43source $OEROOT/scripts/runqemu-internal
44