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