blob: e01d276f7b4fe5b7fc8700e2c5af16554ab7fc36 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001#!/bin/bash
2#
3# Handle running OE images standalone with QEMU
4#
5# Copyright (C) 2006-2011 Linux Foundation
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 environment variables (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 - the machine name (optional, autodetected from KERNEL filename if unspecified)"
29 echo " RAMFS - boot a ramfs-based image"
30 echo " ISO - boot an ISO image"
31 echo " VM - boot a virtual machine image (= a file representing a full disk with boot loader)"
32 echo " Simplified QEMU command-line options can be passed with:"
33 echo " nographic - disables video console"
34 echo " serial - enables a serial console on /dev/ttyS0"
35 echo " kvm - enables KVM when running qemux86/qemux86-64 (VT-capable CPU required)"
Patrick Williamsf1e5d692016-03-30 15:21:19 -050036 echo " kvm-vhost - enables KVM with vhost support when running qemux86/qemux86-64 (VT-capable CPU required)"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050037 echo " publicvnc - enable a VNC server open to all hosts"
38 echo " qemuparams=\"xyz\" - specify custom parameters to QEMU"
39 echo " bootparams=\"xyz\" - specify custom kernel parameters during boot"
40 echo ""
41 echo "Examples:"
42 echo " $MYNAME qemuarm"
43 echo " $MYNAME qemux86-64 core-image-sato ext4"
44 echo " $MYNAME path/to/bzImage-qemux86.bin path/to/nfsrootdir/ serial"
45 echo " $MYNAME qemux86 ramfs"
46 echo " $MYNAME qemux86 iso"
47 echo " $MYNAME qemux86 qemuparams=\"-m 256\""
48 echo " $MYNAME qemux86 bootparams=\"psplash=false\""
49 echo " $MYNAME path/to/<image>-<machine>.vmdk"
50 exit 1
51}
52
53if [ "x$1" = "x" ]; then
54 usage
55fi
56
57error() {
58 echo "Error: "$*
59 usage
60}
61
62MACHINE=${MACHINE:=""}
63KERNEL=${KERNEL:=""}
64ROOTFS=${ROOTFS:=""}
65VM=${VM:=""}
66FSTYPE=${FSTYPE:=""}
67LAZY_ROOTFS=""
68SCRIPT_QEMU_OPT=""
69SCRIPT_QEMU_EXTRA_OPT=""
70SCRIPT_KERNEL_OPT=""
71SERIALSTDIO=""
72TCPSERIAL_PORTNUM=""
73KVM_ENABLED="no"
74KVM_ACTIVE="no"
Patrick Williamsf1e5d692016-03-30 15:21:19 -050075VHOST_ENABLED="no"
76VHOST_ACTIVE="no"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050077
78# Determine whether the file is a kernel or QEMU image, and set the
79# appropriate variables
80process_filename() {
81 filename=$1
82
83 # Extract the filename extension
84 EXT=`echo $filename | awk -F . '{ print \$NF }'`
85 case /$EXT/ in
86 /bin/)
87 # A file ending in .bin is a kernel
88 [ -z "$KERNEL" ] && KERNEL=$filename || \
89 error "conflicting KERNEL args [$KERNEL] and [$filename]"
90 ;;
91 /ext[234]/|/jffs2/|/btrfs/)
92 # A file ending in a supportted fs type is a rootfs image
93 if [ -z "$FSTYPE" -o "$FSTYPE" = "$EXT" ]; then
94 FSTYPE=$EXT
95 ROOTFS=$filename
96 else
97 error "conflicting FSTYPE types [$FSTYPE] and [$EXT]"
98 fi
99 ;;
100 /hddimg/|/hdddirect/|/vmdk/)
101 FSTYPE=$EXT
102 VM=$filename
103 ;;
104 *)
105 error "unknown file arg [$filename]"
106 ;;
107 esac
108}
109
110# Parse command line args without requiring specific ordering. It's a
111# bit more complex, but offers a great user experience.
112while true; do
113 arg=${1}
114 case "$arg" in
115 "qemux86" | "qemux86-64" | "qemuarm" | "qemuarm64" | "qemumips" | "qemumipsel" | \
116 "qemumips64" | "qemush4" | "qemuppc" | "qemumicroblaze" | "qemuzynq")
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500117 [ -z "$MACHINE" -o "$MACHINE" = "$arg" ] && MACHINE=$arg || \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500118 error "conflicting MACHINE types [$MACHINE] and [$arg]"
119 ;;
120 "ext2" | "ext3" | "ext4" | "jffs2" | "nfs" | "btrfs" | "hddimg" | "hdddirect" )
121 [ -z "$FSTYPE" -o "$FSTYPE" = "$arg" ] && FSTYPE=$arg || \
122 error "conflicting FSTYPE types [$FSTYPE] and [$arg]"
123 ;;
124 "ramfs")
125 FSTYPE=cpio.gz
126 RAMFS=true
127 ;;
128 "iso")
129 FSTYPE=iso
130 ISOFS=true
131 ;;
132 "nographic")
133 SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -nographic"
134 SCRIPT_KERNEL_OPT="$SCRIPT_KERNEL_OPT console=ttyS0"
135 ;;
136 "serial")
137 SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -serial stdio"
138 SCRIPT_KERNEL_OPT="$SCRIPT_KERNEL_OPT console=ttyS0"
139 SERIALSTDIO="1"
140 ;;
141 "tcpserial="*)
142 TCPSERIAL_PORTNUM=${arg##tcpserial=}
143 ;;
144 "biosdir="*)
145 CUSTOMBIOSDIR="${arg##biosdir=}"
146 ;;
147 "biosfilename="*)
148 SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -bios ${arg##biosfilename=}"
149 ;;
150 "qemuparams="*)
151 SCRIPT_QEMU_EXTRA_OPT="${arg##qemuparams=}"
152
153 # Warn user if they try to specify serial or kvm options
154 # to use simplified options instead
155 serial_option=`expr "$SCRIPT_QEMU_EXTRA_OPT" : '.*\(-serial\)'`
156 kvm_option=`expr "$SCRIPT_QEMU_EXTRA_OPT" : '.*\(-enable-kvm\)'`
157 vga_option=`expr "$SCRIPT_QEMU_EXTRA_OPT" : '.*\(-vga\)'`
158 [ ! -z "$serial_option" -o ! -z "$kvm_option" ] && \
159 echo "Please use simplified serial or kvm options instead"
160 ;;
161 "bootparams="*)
162 SCRIPT_KERNEL_OPT="$SCRIPT_KERNEL_OPT ${arg##bootparams=}"
163 ;;
164 "audio")
165 if [ "x$MACHINE" = "xqemux86" -o "x$MACHINE" = "xqemux86-64" ]; then
166 echo "Enabling audio in qemu."
167 echo "Please install snd_intel8x0 or snd_ens1370 driver in linux guest."
168 QEMU_AUDIO_DRV="alsa"
169 SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -soundhw ac97,es1370"
170 fi
171 ;;
172 "kvm")
173 KVM_ENABLED="yes"
174 KVM_CAPABLE=`grep -q 'vmx\|svm' /proc/cpuinfo && echo 1`
175 ;;
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500176 "kvm-vhost")
177 KVM_ENABLED="yes"
178 KVM_CAPABLE=`grep -q 'vmx\|svm' /proc/cpuinfo && echo 1`
179 VHOST_ENABLED="yes"
180 ;;
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500181 "slirp")
182 SLIRP_ENABLED="yes"
183 ;;
184 "publicvnc")
185 SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -vnc 0.0.0.0:0"
186 ;;
187 *-image*)
188 [ -z "$ROOTFS" ] || \
189 error "conflicting ROOTFS args [$ROOTFS] and [$arg]"
190 if [ -f "$arg" ]; then
191 process_filename $arg
192 elif [ -d "$arg" ]; then
193 # Handle the case where the nfsroot dir has -image-
194 # in the pathname
195 echo "Assuming $arg is an nfs rootfs"
196 FSTYPE=nfs
197 ROOTFS=$arg
198 else
199 ROOTFS=$arg
200 LAZY_ROOTFS="true"
201 fi
202 ;;
203 "") break ;;
204 *)
205 # A directory name is an nfs rootfs
206 if [ -d "$arg" ]; then
207 echo "Assuming $arg is an nfs rootfs"
208 if [ -z "$FSTYPE" -o "$FSTYPE" = "nfs" ]; then
209 FSTYPE=nfs
210 else
211 error "conflicting FSTYPE types [$arg] and nfs"
212 fi
213
214 if [ -z "$ROOTFS" ]; then
215 ROOTFS=$arg
216 else
217 error "conflicting ROOTFS args [$ROOTFS] and [$arg]"
218 fi
219 elif [ -f "$arg" ]; then
220 process_filename $arg
221 else
222 error "unable to classify arg [$arg]"
223 fi
224 ;;
225 esac
226 shift
227done
228
229if [ ! -c /dev/net/tun ] ; then
230 echo "TUN control device /dev/net/tun is unavailable; you may need to enable TUN (e.g. sudo modprobe tun)"
231 exit 1
232elif [ ! -w /dev/net/tun ] ; then
233 echo "TUN control device /dev/net/tun is not writable, please fix (e.g. sudo chmod 666 /dev/net/tun)"
234 exit 1
235fi
236
237# Report errors for missing combinations of options
238if [ -z "$MACHINE" -a -z "$KERNEL" -a -z "$VM" ]; then
239 error "you must specify at least a MACHINE, VM, or KERNEL argument"
240fi
241if [ "$FSTYPE" = "nfs" -a -z "$ROOTFS" ]; then
242 error "NFS booting without an explicit ROOTFS path is not yet supported"
243fi
244
245if [ -z "$MACHINE" ]; then
246 if [ "x$FSTYPE" = "xvmdk" ] || [ "x$FSTYPE" = "xhddimg" ] || [ "x$FSTYPE" = "xhdddirect" ]; then
247 MACHINE=`basename $VM | sed -n 's/.*\(qemux86-64\|qemux86\|qemuarm64\|qemuarm\|qemumips64\|qemumips\|qemuppc\|qemush4\).*/\1/p'`
248 if [ -z "$MACHINE" ]; then
249 error "Unable to set MACHINE from image filename [$VM]"
250 fi
251 echo "Set MACHINE to [$MACHINE] based on image [$VM]"
252 else
253 MACHINE=`basename $KERNEL | sed -n 's/.*\(qemux86-64\|qemux86\|qemuarm64\|qemuarm\|qemumips64\|qemumips\|qemuppc\|qemush4\).*/\1/p'`
254 if [ -z "$MACHINE" ]; then
255 error "Unable to set MACHINE from kernel filename [$KERNEL]"
256 fi
257 echo "Set MACHINE to [$MACHINE] based on kernel [$KERNEL]"
258 fi
259fi
260
261YOCTO_KVM_WIKI="https://wiki.yoctoproject.org/wiki/How_to_enable_KVM_for_Poky_qemu"
262YOCTO_PARAVIRT_KVM_WIKI="https://wiki.yoctoproject.org/wiki/Running_an_x86_Yocto_Linux_image_under_QEMU_KVM"
263# Detect KVM configuration
264if [ "x$KVM_ENABLED" = "xyes" ]; then
265 if [ -z "$KVM_CAPABLE" ]; then
266 echo "You are trying to enable KVM on a cpu without VT support."
267 echo "Remove kvm from the command-line, or refer"
268 echo "$YOCTO_KVM_WIKI";
269 exit 1;
270 fi
271 if [ "x$MACHINE" != "xqemux86" -a "x$MACHINE" != "xqemux86-64" ]; then
272 echo "KVM only support x86 & x86-64. Remove kvm from the command-line";
273 exit 1;
274 fi
275 if [ ! -e /dev/kvm ]; then
276 echo "Missing KVM device. Have you inserted kvm modules?"
277 echo "For further help see:"
278 echo "$YOCTO_KVM_WIKI";
279 exit 1;
280 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500281 if [ -w /dev/kvm -a -r /dev/kvm ]; then
282 SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm"
283 KVM_ACTIVE="yes"
284 else
285 echo "You have no rights on /dev/kvm."
286 echo "Please change the ownership of this file as described at:"
287 echo "$YOCTO_KVM_WIKI";
288 exit 1;
289 fi
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500290 if [ "x$VHOST_ENABLED" = "xyes" ]; then
291 if [ ! -e /dev/vhost-net ]; then
292 echo "Missing virtio net device. Have you inserted vhost-net module?"
293 echo "For further help see:"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500294 echo "$YOCTO_PARAVIRT_KVM_WIKI";
295 exit 1;
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500296 fi
297
298 if [ -w /dev/vhost-net -a -r /dev/vhost-net ]; then
299 VHOST_ACTIVE="yes"
300 else
301 echo "You have no rights on /dev/vhost-net."
302 echo "Please change the ownership of this file as described at:"
303 echo "$YOCTO_KVM_WIKI";
304 exit 1;
305 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500306 fi
307fi
308
309machine2=`echo $MACHINE | tr 'a-z' 'A-Z' | sed 's/-/_/'`
310# MACHINE is now set for all cases
311
312# Defaults used when these vars need to be inferred
313QEMUX86_DEFAULT_KERNEL=bzImage-qemux86.bin
314QEMUX86_DEFAULT_FSTYPE=ext4
315
316QEMUX86_64_DEFAULT_KERNEL=bzImage-qemux86-64.bin
317QEMUX86_64_DEFAULT_FSTYPE=ext4
318
319QEMUARM_DEFAULT_KERNEL=zImage-qemuarm.bin
320QEMUARM_DEFAULT_FSTYPE=ext4
321
322QEMUARM64_DEFAULT_KERNEL=Image-qemuarm64.bin
323QEMUARM64_DEFAULT_FSTYPE=ext4
324
325QEMUMIPS_DEFAULT_KERNEL=vmlinux-qemumips.bin
326QEMUMIPS_DEFAULT_FSTYPE=ext4
327
328QEMUMIPSEL_DEFAULT_KERNEL=vmlinux-qemumipsel.bin
329QEMUMIPSEL_DEFAULT_FSTYPE=ext4
330
331QEMUMIPS64_DEFAULT_KERNEL=vmlinux-qemumips64.bin
332QEMUMIPS64_DEFAULT_FSTYPE=ext4
333
334QEMUSH4_DEFAULT_KERNEL=vmlinux-qemumips.bin
335QEMUSH4_DEFAULT_FSTYPE=ext4
336
337QEMUPPC_DEFAULT_KERNEL=vmlinux-qemuppc.bin
338QEMUPPC_DEFAULT_FSTYPE=ext4
339
340QEMUMICROBLAZE_DEFAULT_KERNEL=linux.bin.ub
341QEMUMICROBLAZE_DEFAULT_FSTYPE=cpio
342
343QEMUZYNQ_DEFAULT_KERNEL=uImage
344QEMUZYNQ_DEFAULT_FSTYPE=cpio
345
346AKITA_DEFAULT_KERNEL=zImage-akita.bin
347AKITA_DEFAULT_FSTYPE=jffs2
348
349SPITZ_DEFAULT_KERNEL=zImage-spitz.bin
350SPITZ_DEFAULT_FSTYPE=ext3
351
352setup_path_vars() {
353 if [ -z "$OE_TMPDIR" ] ; then
354 PATHS_REQUIRED=true
355 elif [ "$1" = "1" -a -z "$DEPLOY_DIR_IMAGE" ] ; then
356 PATHS_REQUIRED=true
357 else
358 PATHS_REQUIRED=false
359 fi
360
361 if [ "$PATHS_REQUIRED" = "true" ]; then
362 # Try to get the variable values from bitbake
363 type -P bitbake &>/dev/null || {
364 echo "In order for this script to dynamically infer paths";
365 echo "to kernels or filesystem images, you either need";
366 echo "bitbake in your PATH or to source oe-init-build-env";
367 echo "before running this script" >&2;
368 exit 1; }
369
370 # We have bitbake in PATH, get the variable values from bitbake
371 BITBAKE_ENV_TMPFILE=`mktemp --tmpdir runqemu.XXXXXXXXXX`
372 if [ "$?" != "0" ] ; then
373 echo "Error: mktemp failed for bitbake environment output"
374 exit 1
375 fi
376
377 MACHINE=$MACHINE bitbake -e > $BITBAKE_ENV_TMPFILE
378 if [ -z "$OE_TMPDIR" ] ; then
379 OE_TMPDIR=`sed -n 's/^TMPDIR=\"\(.*\)\"/\1/p' $BITBAKE_ENV_TMPFILE`
380 fi
381 if [ -z "$DEPLOY_DIR_IMAGE" ] ; then
382 DEPLOY_DIR_IMAGE=`sed -n 's/^DEPLOY_DIR_IMAGE=\"\(.*\)\"/\1/p' $BITBAKE_ENV_TMPFILE`
383 fi
384 if [ -z "$OE_TMPDIR" ]; then
385 # Check for errors from bitbake that the user needs to know about
386 BITBAKE_OUTPUT=`cat $BITBAKE_ENV_TMPFILE | wc -l`
387 if [ "$BITBAKE_OUTPUT" -eq "0" ]; then
388 echo "Error: this script needs to be run from your build directory, or you need"
389 echo "to explicitly set OE_TMPDIR and DEPLOY_DIR_IMAGE in your environment"
390 else
391 echo "There was an error running bitbake to determine TMPDIR"
392 echo "Here is the output from 'bitbake -e':"
393 cat $BITBAKE_ENV_TMPFILE
394 fi
395 rm $BITBAKE_ENV_TMPFILE
396 exit 1
397 fi
398 rm $BITBAKE_ENV_TMPFILE
399 fi
400}
401
402setup_sysroot() {
403 # Toolchain installs set up $OECORE_NATIVE_SYSROOT in their
404 # environment script. If that variable isn't set, we're
405 # either in an in-tree build scenario or the environment
406 # script wasn't source'd.
407 if [ -z "$OECORE_NATIVE_SYSROOT" ]; then
408 setup_path_vars
409 BUILD_ARCH=`uname -m`
410 BUILD_OS=`uname | tr '[A-Z]' '[a-z]'`
411 BUILD_SYS="$BUILD_ARCH-$BUILD_OS"
412
413 OECORE_NATIVE_SYSROOT=$OE_TMPDIR/sysroots/$BUILD_SYS
414 fi
415
416 # Some recipes store the BIOS under $OE_TMPDIR/sysroots/$MACHINE,
417 # now defined as OECORE_MACHINE_SYSROOT. The latter is used when searching
418 # BIOS, VGA BIOS and keymaps.
419 if [ -z "$OECORE_MACHINE_SYSROOT" ]; then
420 OECORE_MACHINE_SYSROOT=$OE_TMPDIR/sysroots/$MACHINE
421 fi
422}
423
424# Locate a rootfs image to boot which matches our expected
425# machine and fstype.
426findimage() {
427 where=$1
428 machine=$2
429 extension=$3
430
431 # Sort rootfs candidates by modification time - the most
432 # recently created one is the one we most likely want to boot.
433 filename=`ls -t1 $where/*-image*$machine.$extension 2>/dev/null | head -n1`
434 if [ "x$filename" != "x" ]; then
435 ROOTFS=$filename
436 return
437 fi
438
439 echo "Couldn't find a $machine rootfs image in $where."
440 exit 1
441}
442
443if [ -e "$ROOTFS" -a -z "$FSTYPE" ]; then
444 # Extract the filename extension
445 EXT=`echo $ROOTFS | awk -F . '{ print \$NF }'`
446 if [ "x$EXT" = "xext2" -o "x$EXT" = "xext3" -o \
447 "x$EXT" = "xjffs2" -o "x$EXT" = "xbtrfs" -o \
448 "x$EXT" = "xext4" ]; then
449 FSTYPE=$EXT
450 else
451 echo "Note: Unable to determine filesystem extension for $ROOTFS"
452 echo "We will use the default FSTYPE for $MACHINE"
453 # ...which is done further below...
454 fi
455fi
456
457if [ -z "$KERNEL" -a "x$FSTYPE" != "xvmdk" -a "x$FSTYPE" != "xhddimg" -a "x$FSTYPE" != "xhdddirect" ]; then
458 setup_path_vars 1
459 eval kernel_file=\$${machine2}_DEFAULT_KERNEL
460 KERNEL=$DEPLOY_DIR_IMAGE/$kernel_file
461
462 if [ -z "$KERNEL" ]; then
463 error "Unable to determine default kernel for MACHINE [$MACHINE]"
464 fi
465fi
466# KERNEL is now set for all cases
467
468if [ -z "$FSTYPE" ]; then
469 eval FSTYPE=\$${machine2}_DEFAULT_FSTYPE
470
471 if [ -z "$FSTYPE" ]; then
472 error "Unable to determine default fstype for MACHINE [$MACHINE]"
473 fi
474fi
475
476# FSTYPE is now set for all cases
477
478# Handle cases where a ROOTFS type is given instead of a filename, e.g.
479# core-image-sato
480if [ "$LAZY_ROOTFS" = "true" ]; then
481 setup_path_vars 1
482 echo "Assuming $ROOTFS really means $DEPLOY_DIR_IMAGE/$ROOTFS-$MACHINE.$FSTYPE"
483 if [ "$FSTYPE" = "hddimg" -o "x$FSTYPE" = "xhdddirect" ]; then
484 VM=$DEPLOY_DIR_IMAGE/$ROOTFS-$MACHINE.$FSTYPE
485 else
486 ROOTFS=$DEPLOY_DIR_IMAGE/$ROOTFS-$MACHINE.$FSTYPE
487 fi
488fi
489
490if [ -z "$ROOTFS" -a "x$FSTYPE" != "xvmdk" -a "x$FSTYPE" != "xhddimg" -a "x$FSTYPE" != "xhdddirect" ]; then
491 setup_path_vars 1
492 T=$DEPLOY_DIR_IMAGE
493 eval rootfs_list=\$${machine2}_DEFAULT_ROOTFS
494 findimage $T $MACHINE $FSTYPE
495
496 if [ -z "$ROOTFS" ]; then
497 error "Unable to determine default rootfs for MACHINE [$MACHINE]"
498 fi
499fi
500# ROOTFS is now set for all cases, now expand it to be an absolute path, it should exist at this point
501
502ROOTFS=`readlink -f $ROOTFS`
503
504echo ""
505echo "Continuing with the following parameters:"
506if [ "x$FSTYPE" != "xvmdk" -a "x$FSTYPE" != "xhddimg" -a "x$FSTYPE" != "xhdddirect" ]; then
507 echo "KERNEL: [$KERNEL]"
508 echo "ROOTFS: [$ROOTFS]"
509else
510 echo "VMDK: [$VM]"
511fi
512echo "FSTYPE: [$FSTYPE]"
513
514setup_sysroot
515# OECORE_NATIVE_SYSROOT and OECORE_MACHINE_SYSROOT are now set for all cases
516
517INTERNAL_SCRIPT="$0-internal"
518if [ ! -f "$INTERNAL_SCRIPT" -o ! -r "$INTERNAL_SCRIPT" ]; then
519INTERNAL_SCRIPT=`which runqemu-internal`
520fi
521
522# Specify directory for BIOS, VGA BIOS and keymaps
523if [ ! -z "$CUSTOMBIOSDIR" ]; then
524 if [ -d "$OECORE_NATIVE_SYSROOT/$CUSTOMBIOSDIR" ]; then
525 echo "Assuming biosdir is $OECORE_NATIVE_SYSROOT/$CUSTOMBIOSDIR"
526 SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -L $OECORE_NATIVE_SYSROOT/$CUSTOMBIOSDIR"
527 elif [ -d "$OECORE_MACHINE_SYSROOT/$CUSTOMBIOSDIR" ]; then
528 echo "Assuming biosdir is $OECORE_MACHINE_SYSROOT/$CUSTOMBIOSDIR"
529 SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -L $OECORE_MACHINE_SYSROOT/$CUSTOMBIOSDIR"
530 else
531 if [ ! -d "$CUSTOMBIOSDIR" ]; then
532 echo "Custom BIOS directory not found. Tried: $CUSTOMBIOSDIR"
533 echo "and $OECORE_NATIVE_SYSROOT/$CUSTOMBIOSDIR"
534 echo "and $OECORE_MACHINE_SYSROOT/$CUSTOMBIOSDIR"
535 exit 1;
536 fi
537 echo "Assuming biosdir is $CUSTOMBIOSDIR"
538 SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -L $CUSTOMBIOSDIR"
539 fi
540fi
541
542. $INTERNAL_SCRIPT
543exit $?