summaryrefslogtreecommitdiffstats
path: root/scripts/poky-qemu
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-04-20 16:44:10 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-04-21 00:29:29 +0100
commit08127d444e05d8d33ce39abdce677655bd4766ea (patch)
tree926947a62cc4b1cbed4afc31a717305de9b1c57d /scripts/poky-qemu
parent46d0cc3dc88307d69a7884c0e5c79e0c8d5e4dc7 (diff)
downloadpoky-08127d444e05d8d33ce39abdce677655bd4766ea.tar.gz
Rename poky-qemu to runqemu
(From OE-Core rev: 7687d91f73f4a116593315b3b1488ac3f0904905) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/poky-qemu')
-rwxr-xr-xscripts/poky-qemu399
1 files changed, 0 insertions, 399 deletions
diff --git a/scripts/poky-qemu b/scripts/poky-qemu
deleted file mode 100755
index c76b3ab7b6..0000000000
--- a/scripts/poky-qemu
+++ /dev/null
@@ -1,399 +0,0 @@
1#!/bin/bash
2#
3# Handle running Poky images standalone with QEMU
4#
5# Copyright (C) 2006-2010 Intel Corp.
6#
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
9# published by the Free Software Foundation.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License along
17# with this program; if not, write to the Free Software Foundation, Inc.,
18# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20usage() {
21 MYNAME=`basename $0`
22 echo ""
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"
26 echo " KERNEL - the kernel image file to use"
27 echo " ROOTFS - the rootfs image file or nfsroot directory to use"
28 echo " MACHINE=xyz - the machine name (optional, autodetected from KERNEL filename if unspecified)"
29 echo " Additional QEMU command-line options can be passed with:"
30 echo " nographic - disables video console"
31 echo " serial - enables a serial console on /dev/ttyS0"
32 echo " kvm - enables KVM when running qemux86/qemux86-64, VT capable CPU required"
33 echo " \"<extra-qemu-options>\" - enables extra qemu options, excluding serial and kvm"
34 echo ""
35 echo "Examples:"
36 echo " $MYNAME qemuarm"
37 echo " $MYNAME qemux86-64 poky-image-sato ext3"
38 echo " $MYNAME path/to/bzImage-qemux86.bin path/to/nfsrootdir/ serial"
39 echo " $MYNAME qemux86 \"<-m 256>\""
40 exit 1
41}
42
43if [ "x$1" = "x" ]; then
44 usage
45fi
46
47MACHINE=${MACHINE:=""}
48KERNEL=""
49FSTYPE=""
50ROOTFS=""
51LAZY_ROOTFS=""
52SCRIPT_QEMU_OPT=""
53SCRIPT_QEMU_EXTRA_OPT=""
54SCRIPT_KERNEL_OPT=""
55
56TMPDIR=""
57
58# Determine whether the file is a kernel or QEMU image, and set the
59# appropriate variables
60process_filename() {
61 filename=$1
62
63 # Extract the filename extension
64 EXT=`echo $filename | awk -F . '{ print \$NF }'`
65 # A file ending in .bin is a kernel
66 if [ "x$EXT" = "xbin" ]; then
67 if [ -z "$KERNEL" ]; then
68 KERNEL=$filename
69 else
70 echo "Error: conflicting KERNEL args [$KERNEL] and [$filename]"
71 usage
72 fi
73 elif [[ "x$EXT" == "xext2" || "x$EXT" == "xext3" ||
74 "x$EXT" == "xjffs2" ]]; then
75 # A file ending in a supportted fs type is a rootfs image
76 if [[ -z "$FSTYPE" || "$FSTYPE" == "$EXT" ]]; then
77 FSTYPE=$EXT
78 ROOTFS=$filename
79 else
80 echo "Error: conflicting FSTYPE types [$FSTYPE] and [$EXT]"
81 usage
82 fi
83 else
84 echo "Error: unknown file arg [$filename]"
85 usage
86 fi
87}
88
89# Parse command line args without requiring specific ordering. It's a
90# bit more complex, but offers a great user experience.
91KVM_ENABLED="no"
92i=1
93while [ $i -le $# ]; do
94 arg=${!i}
95 case $arg in
96 "qemux86" | "qemux86-64" | "qemuarm" | "qemumips" | "qemuppc")
97 if [ -z "$MACHINE" ]; then
98 MACHINE=$arg
99 else
100 echo "Error: conflicting MACHINE types [$MACHINE] and [$arg]"
101 usage
102 fi
103 ;;
104 "ext2" | "ext3" | "jffs2" | "nfs")
105 if [[ -z "$FSTYPE" || "$FSTYPE" == "$arg" ]]; then
106 FSTYPE=$arg
107 else
108 echo "Error: conflicting FSTYPE types [$FSTYPE] and [$arg]"
109 usage
110 fi
111 ;;
112 *-image-*)
113 if [ -z "$ROOTFS" ]; then
114 if [ -f "$arg" ]; then
115 process_filename $arg
116 elif [ -d "$arg" ]; then
117 # Handle the case where the nfsroot dir has -image-
118 # in the pathname
119 echo "Assuming $arg is an nfs rootfs"
120 FSTYPE=nfs
121 ROOTFS=$arg
122 else
123 ROOTFS=$arg
124 LAZY_ROOTFS="true"
125 fi
126 else
127 echo "Error: conflicting ROOTFS args [$ROOTFS] and [$arg]"
128 usage
129 fi
130 ;;
131 "nographic")
132 SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -nographic"
133 ;;
134 "serial")
135 SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -serial stdio"
136 SCRIPT_KERNEL_OPT="$SCRIPT_KERNEL_OPT console=ttyS0"
137 ;;
138 "audio")
139 if [[ "x$MACHINE" == "xqemux86" || "x$MACHINE" == "xqemux86-64" ]]; then
140 echo "Enable audio on qemu. Pls. install snd_intel8x0 or snd_ens1370 driver in linux guest.";
141 QEMU_AUDIO_DRV="alsa"
142 SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -soundhw ac97,es1370"
143 fi
144 ;;
145 "kvm")
146 KVM_ENABLED="yes"
147 KVM_CAPABLE=`grep 'vmx\|smx' /proc/cpuinfo`
148 ;;
149 \<*\>)
150 SCRIPT_QEMU_EXTRA_OPT=$arg
151 serial_option=`expr "$SCRIPT_QEMU_EXTRA_OPT" : '.*\(-serial\)'`
152 kvm_option=`expr "$SCRIPT_QEMU_EXTRA_OPT" : '.*\(-enable-kvm\)'`
153 echo "$kvm_option"
154 if [[ ! -z "$serial_option" || ! -z "$kvm_option" ]]; then
155 echo "Error: Please use serial or kvm params instead!"
156 usage
157 fi
158 ;;
159 *)
160 # A directory name is an nfs rootfs
161 if [ -d "$arg" ]; then
162 echo "Assuming $arg is an nfs rootfs"
163 if [[ -z "$FSTYPE" || "$FSTYPE" == "nfs" ]]; then
164 FSTYPE=nfs
165 else
166 echo "Error: conflicting FSTYPE types [$arg] and nfs"
167 usage
168 fi
169
170 if [ -z "$ROOTFS" ]; then
171 ROOTFS=$arg
172 else
173 echo "Error: conflicting ROOTFS args [$ROOTFS] and [$arg]"
174 usage
175 fi
176 elif [ -f "$arg" ]; then
177 process_filename $arg
178 else
179 echo "Error: unable to classify arg [$arg]"
180 usage
181 fi
182 ;;
183 esac
184 i=$((i + 1))
185done
186
187POKY_KVM_WIKI="https://wiki.yoctoproject.org/wiki/How_to_enable_KVM_for_Poky_qemu"
188# Detect KVM configuration
189if [[ "x$KVM_ENABLED" == "xyes" ]]; then
190 if [[ -z "$KVM_CAPABLE" ]]; then
191 echo "You are tring to enable KVM on cpu without VT support. Remove kvm from the command-line, or refer";
192 echo "$POKY_KVM_WIKI";
193 exit 1;
194 fi
195 if [[ "x$MACHINE" != "xqemux86" && "x$MACHINE" != "xqemux86-64" ]]; then
196 echo "KVM only support x86 & x86-64. Remove kvm from the command-line";
197 exit 1;
198 fi
199 if [ ! -e /dev/kvm ]; then
200 echo "Missing KVM device. Have you inserted kvm modules? Pls. refer";
201 echo "$POKY_KVM_WIKI";
202 exit 1;
203 fi
204 if 9<>/dev/kvm ; then
205 SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm"
206 else
207 echo "You have no rights on /dev/kvm. Pls. change the owndership as described at";
208 echo "$POKY_KVM_WIKI";
209 exit 1;
210 fi
211fi
212
213# Report errors for missing combinations of options
214if [[ -z "$MACHINE" && -z "$KERNEL" ]]; then
215 echo "Error: you must specify at least a MACHINE or KERNEL argument"
216 usage
217fi
218if [[ "$FSTYPE" == "nfs" && -z "$ROOTFS" ]]; then
219 echo "Error: NFS booting without an explicit ROOTFS path is not yet supported"
220 usage
221fi
222
223if [ -z "$MACHINE" ]; then
224 MACHINE=`basename $KERNEL | sed 's/.*-\(qemux86-64\|qemux86\|qemuarm\|qemumips\|qemuppc\).*/\1/'`
225 if [ -z "$MACHINE" ]; then
226 echo "Error: Unable to set MACHINE from kernel filename [$KERNEL]"
227 usage
228 fi
229 echo "Set MACHINE to [$MACHINE] based on kernel [$KERNEL]"
230fi
231machine2=`echo $MACHINE | tr 'a-z' 'A-Z' | sed 's/-/_/'`
232# MACHINE is now set for all cases
233
234# Defaults used when these vars need to be inferred
235QEMUX86_DEFAULT_KERNEL=bzImage-qemux86.bin
236QEMUX86_DEFAULT_FSTYPE=ext3
237QEMUX86_DEFAULT_ROOTFS="poky-image-sato-sdk poky-image-sato poky-image-lsb poky-image-basic poky-image-minimal"
238
239QEMUX86_64_DEFAULT_KERNEL=bzImage-qemux86-64.bin
240QEMUX86_64_DEFAULT_FSTYPE=ext3
241QEMUX86_64_DEFAULT_ROOTFS="poky-image-sato-sdk poky-image-sato poky-image-lsb poky-image-basic poky-image-minimal"
242
243QEMUARM_DEFAULT_KERNEL=zImage-qemuarm.bin
244QEMUARM_DEFAULT_FSTYPE=ext3
245QEMUARM_DEFAULT_ROOTFS="poky-image-sato-sdk poky-image-sato poky-image-lsb poky-image-basic poky-image-minimal"
246
247QEMUMIPS_DEFAULT_KERNEL=vmlinux-qemumips.bin
248QEMUMIPS_DEFAULT_FSTYPE=ext3
249QEMUMIPS_DEFAULT_ROOTFS="poky-image-sato-sdk poky-image-sato poky-image-lsb poky-image-basic poky-image-minimal"
250
251QEMUPPC_DEFAULT_KERNEL=zImage-qemuppc.bin
252QEMUPPC_DEFAULT_FSTYPE=ext3
253QEMUPPC_DEFAULT_ROOTFS="poky-image-sato-sdk poky-image-sato poky-image-lsb poky-image-basic poky-image-minimal"
254
255AKITA_DEFAULT_KERNEL=zImage-akita.bin
256AKITA_DEFAULT_FSTYPE=jffs2
257AKITA_DEFAULT_ROOTFS="poky-image-sato"
258
259SPITZ_DEFAULT_KERNEL=zImage-spitz.bin
260SPITZ_DEFAULT_FSTYPE=ext3
261SPITZ_DEFAULT_ROOTFS="poky-image-sato"
262
263setup_tmpdir() {
264 if [ -z "$TMPDIR" ]; then
265 if [ "x$BUILDDIR" = "x" -o ! -d "$BUILDDIR/tmp" ]; then
266 # BUILDDIR unset, try and get TMPDIR from bitbake
267 type -P bitbake &>/dev/null || {
268 echo "In order for this script to dynamically infer paths";
269 echo "to kernels or filesystem images, you either need";
270 echo "bitbake in your PATH or to source poky-init-build-env";
271 echo "before running this script" >&2;
272 exit 1; }
273
274 # We have bitbake in PATH, get TMPDIR from bitbake
275 TMPDIR=`bitbake -e | grep TMPDIR=\" | cut -d '=' -f2 | cut -d '"' -f2`
276 else
277 TMPDIR=$BUILDDIR/tmp
278 fi
279 fi
280}
281
282setup_sysroot() {
283 # Toolchain installs set up $POKY_NATIVE_SYSROOT in their
284 # environment script. If that variable isn't set, we're
285 # either in an in-tree poky scenario or the environment
286 # script wasn't source'd.
287 if [ -z "$POKY_NATIVE_SYSROOT" ]; then
288 setup_tmpdir
289 BUILD_ARCH=`uname -m`
290 BUILD_OS=`uname | tr '[A-Z]' '[a-z]'`
291 BUILD_SYS="$BUILD_ARCH-$BUILD_OS"
292
293 POKY_NATIVE_SYSROOT=$TMPDIR/sysroots/$BUILD_SYS
294 fi
295}
296
297# Locate a rootfs image based on defaults defined above
298findimage() {
299 where=$1
300 machine=$2
301 extension=$3
302 names=$4
303
304 for name in $names; do
305 fullname=$where/$name-$machine.$extension
306 if [ -e "$fullname" ]; then
307 ROOTFS=$fullname
308 return
309 fi
310 done
311
312 echo "Couldn't find image in $where. Attempted image names were:"
313 for name in $names; do
314 echo $name-$machine.$extension
315 done
316
317 exit 1
318}
319
320if [[ -e "$ROOTFS" && -z "$FSTYPE" ]]; then
321 # Extract the filename extension
322 EXT=`echo $ROOTFS | awk -F . '{ print \$NF }'`
323 if [[ "x$EXT" == "xext2" || "x$EXT" == "xext3" ||
324 "x$EXT" == "xjffs2" ]]; then
325 FSTYPE=$EXT
326 else
327 echo "Note: Unable to determine filesystem extension for $ROOTFS"
328 echo "We will use the default FSTYPE for $MACHINE"
329 # ...which is done further below...
330 fi
331fi
332
333if [ -z "$KERNEL" ]; then
334 setup_tmpdir
335 eval kernel_file=\$${machine2}_DEFAULT_KERNEL
336 KERNEL=$TMPDIR/deploy/images/$kernel_file
337
338 if [ -z "$KERNEL" ]; then
339 echo "Error: Unable to determine default kernel for MACHINE [$MACHINE]"
340 usage
341 fi
342fi
343# KERNEL is now set for all cases
344
345if [ -z "$FSTYPE" ]; then
346 eval FSTYPE=\$${machine2}_DEFAULT_FSTYPE
347
348 if [ -z "$FSTYPE" ]; then
349 echo "Error: Unable to determine default fstype for MACHINE [$MACHINE]"
350 usage
351 fi
352fi
353# FSTYPE is now set for all cases
354
355# Handle cases where a ROOTFS type is given instead of a filename, e.g.
356# poky-image-sato
357if [ "$LAZY_ROOTFS" = "true" ]; then
358 setup_tmpdir
359 echo "Assuming $ROOTFS really means $TMPDIR/deploy/images/$ROOTFS-$MACHINE.$FSTYPE"
360 ROOTFS=$TMPDIR/deploy/images/$ROOTFS-$MACHINE.$FSTYPE
361fi
362
363if [ -z "$ROOTFS" ]; then
364 setup_tmpdir
365 T=$TMPDIR/deploy/images
366 eval rootfs_list=\$${machine2}_DEFAULT_ROOTFS
367 findimage $T $MACHINE $FSTYPE "$rootfs_list"
368
369 if [ -z "$ROOTFS" ]; then
370 echo "Error: Unable to determine default rootfs for MACHINE [$MACHINE]"
371 usage
372 fi
373fi
374# ROOTFS is now set for all cases
375
376echo ""
377echo "Continuing with the following parameters:"
378echo "KERNEL: [$KERNEL]"
379echo "ROOTFS: [$ROOTFS]"
380echo "FSTYPE: [$FSTYPE]"
381
382setup_sysroot
383# POKY_NATIVE_SYSROOT is now set for all cases
384
385# We can't run without a libGL.so
386libgl='no'
387
388test -e /usr/lib/libGL.so -a -e /usr/lib/libGLU.so && libgl='yes'
389test -e /usr/lib64/libGL.so -a -e /usr/lib64/libGLU.so && libgl='yes'
390
391if [ "$libgl" != 'yes' ]; then
392 echo "You need libGL.so and libGLU.so to exist in your library path to run the QEMU emulator.
393 Ubuntu package names are: libgl1-mesa-dev and libglu1-mesa-dev."
394 exit 1;
395fi
396
397INTERNAL_SCRIPT=`which poky-qemu-internal`
398
399. $INTERNAL_SCRIPT