summaryrefslogtreecommitdiffstats
path: root/scripts/poky-qemu
diff options
context:
space:
mode:
authorScott Garman <scott.a.garman@intel.com>2010-10-04 21:04:15 -0700
committerRichard Purdie <rpurdie@linux.intel.com>2010-10-07 19:57:34 +0100
commit0f973ed66551cdd1112ee9df42df5603835b8384 (patch)
tree753442dd27a029749846a718353e1fba02a09e49 /scripts/poky-qemu
parente70c8981f250ead9e025ecd27aef94b67d784fc6 (diff)
downloadpoky-0f973ed66551cdd1112ee9df42df5603835b8384.tar.gz
Merge runqemu features into poky-qemu
This merges the functionality of the runqemu script into poky-qemu. It also removes the requirement to order command line args to poky-qemu in any particular order. This fixes a slew of runqemu-related bugs by making the runqemu script obsolete (and fixing the issues in the new poky-qemu), including [BUGID #294] [BUGID #295] [BUGID #371] and [BUGID #324]. Signed-off-by: Scott Garman <scott.a.garman@intel.com>
Diffstat (limited to 'scripts/poky-qemu')
-rwxr-xr-xscripts/poky-qemu280
1 files changed, 250 insertions, 30 deletions
diff --git a/scripts/poky-qemu b/scripts/poky-qemu
index 111aa15b70..ad4bdbf91c 100755
--- a/scripts/poky-qemu
+++ b/scripts/poky-qemu
@@ -1,8 +1,8 @@
1#!/bin/bash 1#!/bin/bash
2 2#
3# Handle running Poky images standalone with QEMU 3# Handle running Poky images standalone with QEMU
4# 4#
5# Copyright (C) 2006-2007 OpenedHand Ltd. 5# Copyright (C) 2006-2010 Intel Corp.
6# 6#
7# This program is free software; you can redistribute it and/or modify 7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License version 2 as 8# it under the terms of the GNU General Public License version 2 as
@@ -17,47 +17,267 @@
17# with this program; if not, write to the Free Software Foundation, Inc., 17# with this program; if not, write to the Free Software Foundation, Inc.,
18# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 19
20 20usage() {
21if [ "x$1" = "x" ]; then
22 MYNAME=`basename $0` 21 MYNAME=`basename $0`
23 echo "Run as MACHINE=xyz $MYNAME KERNEL ROOTFS [OPTIONS]" 22 echo ""
24 echo "where:" 23 echo "Usage: you can run this script with any valid combination"
24 echo "of the following options (in any order):"
25 echo " QEMUARCH - the qemu machine architecture to use"
25 echo " KERNEL - the kernel image file to use" 26 echo " KERNEL - the kernel image file to use"
26 echo " ROOTFS - the rootfs image file or nfsroot directory to use" 27 echo " ROOTFS - the rootfs image file or nfsroot directory to use"
27# echo " (NFS booting assumed if ROOTFS not specified)"
28 echo " MACHINE=xyz - the machine name (optional, autodetected from KERNEL filename if unspecified)" 28 echo " MACHINE=xyz - the machine name (optional, autodetected from KERNEL filename if unspecified)"
29 echo " OPTIONS - extra options to pass to QEMU" 29 echo " Additional QEMU command-line options can be passed with:"
30 echo " serial - enables a serial console on /dev/ttyS0"
31 echo ""
32 echo "Examples:"
33 echo " $0 qemuarm"
34 echo " $0 qemux86-64 poky-image-sato ext3"
35 echo " $0 path/to/bzImage-qemux86.bin path/to/nfsrootdir/ serial"
30 exit 1 36 exit 1
31else 37}
32 KERNEL=$1 38
33 shift 39if [ "x$1" = "x" ]; then
40 usage
34fi 41fi
35 42
36if [ "x$MACHINE" = "x" ]; then 43MACHINE=${MACHINE:=""}
44KERNEL=""
45FSTYPE=""
46ROOTFS=""
47SCRIPT_QEMU_OPT=""
48SCRIPT_KERNEL_OPT=""
49
50TMPDIR=""
51
52# Parse command line args without requiring specific ordering. It's a
53# bit more complex, but offers a great user experience.
54i=1
55while [ $i -le $# ]; do
56 arg=${!i}
57 case $arg in
58 "qemux86" | "qemux86-64" | "qemuarm" | "qemumips" | "qemuppc")
59 if [ -z "$MACHINE" ]; then
60 MACHINE=$arg
61 else
62 echo "Error: conflicting MACHINE types [$MACHINE] and [$arg]"
63 usage
64 fi
65 ;;
66 "ext2" | "ext3" | "jffs2" | "nfs")
67 if [ -z "$FSTYPE" ]; then
68 FSTYPE=$arg
69 else
70 echo "Error: conflicting FSTYPE types [$FSTYPE] and [$arg]"
71 usage
72 fi
73 ;;
74 *-image-*)
75 if [ -z "$ROOTFS" ]; then
76 ROOTFS=$arg
77 else
78 echo "Error: conflicting ROOTFS args [$ROOTFS] and [$arg]"
79 usage
80 fi
81 ;;
82 "serial")
83 # Will need to append to these variables when we
84 # accept more values
85 SCRIPT_QEMU_OPT="-serial stdio"
86 SCRIPT_KERNEL_OPT="console=ttyS0"
87 ;;
88 *)
89 # A directory name is an nfs rootfs
90 if [ -d "$arg" ]; then
91 echo "Assuming $arg is an nfs rootfs"
92 if [[ -z "$FSTYPE" || "$FSTYPE" == "nfs" ]]; then
93 FSTYPE=nfs
94 else
95 echo "Error: conflicting FSTYPE types [$arg] and nfs"
96 usage
97 fi
98
99 if [ -z "$ROOTFS" ]; then
100 ROOTFS=$arg
101 else
102 echo "Error: conflicting ROOTFS args [$ROOTFS] and [$arg]"
103 usage
104 fi
105 elif [ -f "$arg" ]; then
106 # Extract the filename extension
107 EXT=`echo $arg | awk -F . '{ print \$NF }'`
108 # A file ending in .bin is a kernel
109 if [ "x$EXT" = "xbin" ]; then
110 if [ -z "$KERNEL" ]; then
111 KERNEL=$arg
112 else
113 echo "Error: conflicting KERNEL args [$KERNEL] and [$arg]"
114 usage
115 fi
116 elif [[ "x$EXT" == "xext2" || "x$EXT" == "xext3" ||
117 "x$EXT" == "xjffs2" ]]; then
118 # A file ending in a supportted fs type is a rootfs image
119 if [[ -z "$FSTYPE" || "$FSTYPE" == "$EXT" ]]; then
120 FSTYPE=$EXT
121 ROOTFS=$arg
122 else
123 echo "Error: conflicting FSTYPE types [$FSTYPE] and [$arg]"
124 usage
125 fi
126 else
127 echo "Error: unknown file arg [$arg]"
128 usage
129 fi
130 else
131 echo "Error: unable to classify arg [$arg]"
132 usage
133 fi
134 ;;
135 esac
136 i=$((i + 1))
137done
138
139# Report errors for missing combinations of options
140if [[ -z "$MACHINE" && -z "$KERNEL" ]]; then
141 echo "Error: you must specify at least a MACHINE or KERNEL argument"
142 usage
143fi
144if [[ "$FSTYPE" == "nfs" && -z "$ROOTFS" ]]; then
145 echo "Error: NFS booting without an explicit ROOTFS path is not yet supported"
146 usage
147fi
148
149if [ -z "$MACHINE" ]; then
37 MACHINE=`basename $KERNEL | sed -r -e 's#.*-([a-z]+[0-9\-]*)-?[0-9]*..*#\1#'` 150 MACHINE=`basename $KERNEL | sed -r -e 's#.*-([a-z]+[0-9\-]*)-?[0-9]*..*#\1#'`
151 if [ -z "$MACHINE" ]; then
152 echo "Error: Unable to set MACHINE from kernel filename [$KERNEL]"
153 usage
154 fi
155 echo "Set MACHINE to [$MACHINE] based on kernel [$KERNEL]"
38fi 156fi
157machine2=`echo $MACHINE | tr 'a-z' 'A-Z' | sed 's/-/_/'`
158# MACHINE is now set for all cases
39 159
40if [ "x$1" = "x" ]; then 160# Defaults used when these vars need to be inferred
41 FSTYPE="nfs" 161QEMUX86_DEFAULT_KERNEL=bzImage-qemux86.bin
42 echo "Error: NFS booting without an explicit ROOTFS path is not yet supported" 162QEMUX86_DEFAULT_FSTYPE=ext3
43 exit 1 163QEMUX86_DEFAULT_ROOTFS="poky-image-sdk poky-image-sato poky-image-lsb poky-image-basic poky-image-minimal"
44else 164
45 ROOTFS=$1 165QEMUX86_64_DEFAULT_KERNEL=bzImage-qemux86-64.bin
46 166QEMUX86_64_DEFAULT_FSTYPE=ext3
47 if [ -d "$1" ]; then 167QEMUX86_64_DEFAULT_ROOTFS="poky-image-sdk poky-image-sato poky-image-lsb poky-image-basic poky-image-minimal"
48 echo "$ROOTFS is a directory, assuming nfsroot" 168
49 FSTYPE="nfs" 169QEMUARM_DEFAULT_KERNEL=zImage-qemuarm.bin
50 else 170QEMUARM_DEFAULT_FSTYPE=ext3
51 FSTYPE="ext3" 171QEMUARM_DEFAULT_ROOTFS="poky-image-sdk poky-image-sato poky-image-lsb poky-image-basic poky-image-minimal"
52 EXT=${ROOTFS##.*} 172
53 if [[ "x$EXT" == "xext2" || "x$EXT" == "xext3" || 173QEMUMIPS_DEFAULT_KERNEL=vmlinux-qemumips.bin
54 "x$EXT" == "xjffs2" ]]; then 174QEMUMIPS_DEFAULT_FSTYPE=ext3
55 FSTYPE=$EXT 175QEMUMIPS_DEFAULT_ROOTFS="poky-image-sdk poky-image-sato poky-image-lsb poky-image-basic poky-image-minimal"
176
177QEMUPPC_DEFAULT_KERNEL=zImage-qemuppc.bin
178QEMUPPC_DEFAULT_FSTYPE=ext3
179QEMUPPC_DEFAULT_ROOTFS="poky-image-sdk poky-image-sato poky-image-lsb poky-image-basic poky-image-minimal"
180
181AKITA_DEFAULT_KERNEL=zImage-akita.bin
182AKITA_DEFAULT_FSTYPE=jffs2
183AKITA_DEFAULT_ROOTFS="poky-image-sato"
184
185SPITZ_DEFAULT_KERNEL=zImage-spitz.bin
186SPITZ_DEFAULT_FSTYPE=ext3
187SPITZ_DEFAULT_ROOTFS="poky-image-sato"
188
189setup_tmpdir() {
190 if [ -z "$TMPDIR" ]; then
191 if [ "x$BUILDDIR" = "x" ]; then
192 # BUILDDIR unset, try and get TMPDIR from bitbake
193 type -P bitbake &>/dev/null || {
194 echo "In order for this script to dynamically infer paths";
195 echo "to kernels or filesystem images, you either need";
196 echo "bitbake in your PATH or to source poky-init-build-env";
197 echo "before running this script" >&2;
198 exit 1; }
199
200 # We have bitbake in PATH, get TMPDIR and BUILD_SYS
201 # from the environment
202 TMPDIR=`bitbake -e | grep TMPDIR=\" | cut -d '=' -f2 | cut -d '"' -f2`
203 BUILD_SYS=`bitbake -e | grep BUILD_SYS=\" | cut -d '=' -f2 | cut -d '"' -f2`
204 else
205 BUILD_ARCH=`uname -m`
206 BUILD_OS=`uname | tr '[A-Z]' '[a-z]'`
207 BUILD_SYS="$BUILD_ARCH-$BUILD_OS"
208 TMPDIR=$BUILDDIR/tmp
56 fi 209 fi
57 echo "Using $FSTYPE as filesytem type for $ROOTFS" 210 if [ -z "$POKY_NATIVE_SYSROOT" ]; then
211 POKY_NATIVE_SYSROOT=$TMPDIR/sysroots/$BUILD_SYS
212 fi
213 CROSSPATH=$POKY_NATIVE_SYSROOT/usr/bin
214 fi
215}
216
217# Locate a rootfs image based on defaults defined above
218findimage() {
219 where=$1
220 machine=$2
221 extension=$3
222 names=$4
223
224 for name in $names; do
225 fullname=$where/$name-$machine.$extension
226 if [ -e "$fullname" ]; then
227 ROOTFS=$fullname
228 return
229 fi
230 done
231
232 echo "Couldn't find image in $where. Attempted image names were:"
233 for name in $names; do
234 echo $name-$machine.$extension
235 done
236
237 exit 1
238}
239
240if [ -z "$KERNEL" ]; then
241 setup_tmpdir
242 eval kernel_file=\$${machine2}_DEFAULT_KERNEL
243 KERNEL=$TMPDIR/deploy/images/$kernel_file
244
245 if [ -z "$KERNEL" ]; then
246 echo "Error: Unable to determine default kernel for MACHINE [$MACHINE]"
247 usage
248 fi
249fi
250# KERNEL is now set for all cases
251
252if [ -z "$FSTYPE" ]; then
253 setup_tmpdir
254 eval FSTYPE=\$${machine2}_DEFAULT_FSTYPE
255
256 if [ -z "$FSTYPE" ]; then
257 echo "Error: Unable to determine default fstype for MACHINE [$MACHINE]"
258 usage
58 fi 259 fi
59 shift
60fi 260fi
261# FSTYPE is now set for all cases
262
263if [ -z "$ROOTFS" ]; then
264 setup_tmpdir
265 T=$TMPDIR/deploy/images
266 eval rootfs_list=\$${machine2}_DEFAULT_ROOTFS
267 findimage $T $MACHINE $FSTYPE "$rootfs_list"
268
269 if [ -z "$ROOTFS" ]; then
270 echo "Error: Unable to determine default rootfs for MACHINE [$MACHINE]"
271 usage
272 fi
273fi
274# ROOTFS is now set for all cases
275
276echo ""
277echo "Continuing with the following parameters:"
278echo "KERNEL: [$KERNEL]"
279echo "ROOTFS: [$ROOTFS]"
280echo "FSTYPE: [$FSTYPE]"
61 281
62# We can't run without a libGL.so 282# We can't run without a libGL.so
63libgl='no' 283libgl='no'