summaryrefslogtreecommitdiffstats
path: root/meta-sota/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'meta-sota/scripts')
-rwxr-xr-xmeta-sota/scripts/runqemu575
-rwxr-xr-xmeta-sota/scripts/runqemu-addptable2image51
-rwxr-xr-xmeta-sota/scripts/runqemu-export-rootfs163
-rwxr-xr-xmeta-sota/scripts/runqemu-extract-sdk104
-rwxr-xr-xmeta-sota/scripts/runqemu-gen-tapdevs100
-rwxr-xr-xmeta-sota/scripts/runqemu-ifdown66
-rwxr-xr-xmeta-sota/scripts/runqemu-ifup121
-rwxr-xr-xmeta-sota/scripts/runqemu-internal760
-rw-r--r--meta-sota/scripts/runqemu.README42
9 files changed, 1982 insertions, 0 deletions
diff --git a/meta-sota/scripts/runqemu b/meta-sota/scripts/runqemu
new file mode 100755
index 0000000..b6c9b54
--- /dev/null
+++ b/meta-sota/scripts/runqemu
@@ -0,0 +1,575 @@
+#!/bin/bash
+#
+# Handle running OE images standalone with QEMU
+#
+# Copyright (C) 2006-2011 Linux Foundation
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+usage() {
+ MYNAME=`basename $0`
+cat <<_EOF
+
+Usage: you can run this script with any valid combination
+of the following environment variables (in any order):
+ KERNEL - the kernel image file to use
+ ROOTFS - the rootfs image file or nfsroot directory to use
+ MACHINE - the machine name (optional, autodetected from KERNEL filename if unspecified)
+ Simplified QEMU command-line options can be passed with:
+ nographic - disables video console
+ serial - enables a serial console on /dev/ttyS0
+ kvm - enables KVM when running qemux86/qemux86-64 (VT-capable CPU required)
+ kvm-vhost - enables KVM with vhost support when running qemux86/qemux86-64 (VT-capable CPU required)
+ publicvnc - enable a VNC server open to all hosts
+ qemuparams="xyz" - specify custom parameters to QEMU
+ bootparams="xyz" - specify custom kernel parameters during boot
+
+Examples:
+ $MYNAME qemuarm
+ $MYNAME qemux86-64 core-image-sato ext4
+ $MYNAME qemux86-64 wic-image-minimal wic
+ $MYNAME path/to/bzImage-qemux86.bin path/to/nfsrootdir/ serial
+ $MYNAME qemux86 iso/hddimg/vmdk/qcow2/vdi/ramfs/cpio.gz...
+ $MYNAME qemux86 qemuparams="-m 256"
+ $MYNAME qemux86 bootparams="psplash=false"
+ $MYNAME path/to/<image>-<machine>.vmdk
+ $MYNAME path/to/<image>-<machine>.wic
+_EOF
+ exit 1
+}
+
+if [ "x$1" = "x" ]; then
+ usage
+fi
+
+error() {
+ echo "Error: "$*
+ usage
+}
+
+MACHINE=${MACHINE:=""}
+KERNEL=${KERNEL:=""}
+ROOTFS=${ROOTFS:=""}
+FSTYPE=${FSTYPE:=""}
+LAZY_ROOTFS=""
+SCRIPT_QEMU_OPT=""
+SCRIPT_QEMU_EXTRA_OPT=""
+SCRIPT_KERNEL_OPT=""
+SERIALSTDIO=""
+TCPSERIAL_PORTNUM=""
+KVM_ENABLED="no"
+KVM_ACTIVE="no"
+VHOST_ENABLED="no"
+VHOST_ACTIVE="no"
+IS_VM="false"
+
+# Determine whether the file is a kernel or QEMU image, and set the
+# appropriate variables
+process_filename() {
+ filename=$1
+
+ # Extract the filename extension
+ EXT=`echo $filename | awk -F . '{ print \$NF }'`
+ case /$EXT/ in
+ /bin/)
+ # A file ending in .bin is a kernel
+ [ -z "$KERNEL" ] && KERNEL=$filename || \
+ error "conflicting KERNEL args [$KERNEL] and [$filename]"
+ ;;
+ /ext[234]/|/jffs2/|/btrfs/)
+ # A file ending in a supportted fs type is a rootfs image
+ if [ -z "$FSTYPE" -o "$FSTYPE" = "$EXT" ]; then
+ FSTYPE=$EXT
+ ROOTFS=$filename
+ else
+ error "conflicting FSTYPE types [$FSTYPE] and [$EXT]"
+ fi
+ ;;
+ /hddimg/|/hdddirect/|/vmdk/|/wic/|/qcow2/|/vdi/|/otaimg/)
+ FSTYPE=$EXT
+ VM=$filename
+ ROOTFS=$filename
+ IS_VM="true"
+ ;;
+ *)
+ error "unknown file arg [$filename]"
+ ;;
+ esac
+}
+
+check_fstype_conflicts() {
+ if [ -z "$FSTYPE" -o "$FSTYPE" = "$1" ]; then
+ FSTYPE=$1
+ else
+ error "conflicting FSTYPE types [$FSTYPE] and [$1]"
+ fi
+}
+# Parse command line args without requiring specific ordering. It's a
+# bit more complex, but offers a great user experience.
+while true; do
+ arg=${1}
+ case "$arg" in
+ "qemux86" | "qemux86-64" | "qemuarm" | "qemuarm64" | "qemumips" | "qemumipsel" | \
+ "qemumips64" | "qemush4" | "qemuppc" | "qemumicroblaze" | "qemuzynq" | "qemuzynqmp")
+ [ -z "$MACHINE" -o "$MACHINE" = "$arg" ] && MACHINE=$arg || \
+ error "conflicting MACHINE types [$MACHINE] and [$arg]"
+ ;;
+ "ext"[234] | "jffs2" | "nfs" | "btrfs")
+ check_fstype_conflicts $arg
+ ;;
+ "hddimg" | "hdddirect" | "wic" | "vmdk" | "qcow2" | "vdi" | "iso" | "otaimg")
+ check_fstype_conflicts $arg
+ IS_VM="true"
+ ;;
+ "ramfs" | "cpio.gz")
+ FSTYPE=cpio.gz
+ ;;
+ "nographic")
+ SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -nographic"
+ SCRIPT_KERNEL_OPT="$SCRIPT_KERNEL_OPT console=ttyS0"
+ ;;
+ "serial")
+ SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -serial stdio"
+ SCRIPT_KERNEL_OPT="$SCRIPT_KERNEL_OPT console=ttyS0"
+ SERIALSTDIO="1"
+ ;;
+ "tcpserial="*)
+ TCPSERIAL_PORTNUM=${arg##tcpserial=}
+ ;;
+ "biosdir="*)
+ CUSTOMBIOSDIR="${arg##biosdir=}"
+ ;;
+ "biosfilename="*)
+ SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -bios ${arg##biosfilename=}"
+ ;;
+ "qemuparams="*)
+ SCRIPT_QEMU_EXTRA_OPT="${arg##qemuparams=}"
+
+ # Warn user if they try to specify serial or kvm options
+ # to use simplified options instead
+ serial_option=`expr "$SCRIPT_QEMU_EXTRA_OPT" : '.*\(-serial\)'`
+ kvm_option=`expr "$SCRIPT_QEMU_EXTRA_OPT" : '.*\(-enable-kvm\)'`
+ vga_option=`expr "$SCRIPT_QEMU_EXTRA_OPT" : '.*\(-vga\)'`
+ [ ! -z "$serial_option" -o ! -z "$kvm_option" ] && \
+ echo "Please use simplified serial or kvm options instead"
+ ;;
+ "bootparams="*)
+ SCRIPT_KERNEL_OPT="$SCRIPT_KERNEL_OPT ${arg##bootparams=}"
+ ;;
+ "audio")
+ if [ "x$MACHINE" = "xqemux86" -o "x$MACHINE" = "xqemux86-64" ]; then
+ echo "Enabling audio in qemu."
+ echo "Please install snd_intel8x0 or snd_ens1370 driver in linux guest."
+ QEMU_AUDIO_DRV="alsa"
+ SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -soundhw ac97,es1370"
+ fi
+ ;;
+ "kvm")
+ KVM_ENABLED="yes"
+ KVM_CAPABLE=`grep -q 'vmx\|svm' /proc/cpuinfo && echo 1`
+ ;;
+ "kvm-vhost")
+ KVM_ENABLED="yes"
+ KVM_CAPABLE=`grep -q 'vmx\|svm' /proc/cpuinfo && echo 1`
+ VHOST_ENABLED="yes"
+ ;;
+ "slirp")
+ SLIRP_ENABLED="yes"
+ ;;
+ "publicvnc")
+ SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -vnc :0"
+ ;;
+ *-image*)
+ [ -z "$ROOTFS" ] || \
+ error "conflicting ROOTFS args [$ROOTFS] and [$arg]"
+ if [ -f "$arg" ]; then
+ process_filename $arg
+ elif [ -d "$arg" ]; then
+ # Handle the case where the nfsroot dir has -image-
+ # in the pathname
+ echo "Assuming $arg is an nfs rootfs"
+ FSTYPE=nfs
+ ROOTFS=$arg
+ else
+ ROOTFS=$arg
+ LAZY_ROOTFS="true"
+ fi
+ ;;
+ "") break ;;
+ *)
+ # A directory name is an nfs rootfs
+ if [ -d "$arg" ]; then
+ echo "Assuming $arg is an nfs rootfs"
+ if [ -z "$FSTYPE" -o "$FSTYPE" = "nfs" ]; then
+ FSTYPE=nfs
+ else
+ error "conflicting FSTYPE types [$arg] and nfs"
+ fi
+
+ if [ -z "$ROOTFS" ]; then
+ ROOTFS=$arg
+ else
+ error "conflicting ROOTFS args [$ROOTFS] and [$arg]"
+ fi
+ elif [ -f "$arg" ]; then
+ process_filename $arg
+ else
+ error "unable to classify arg [$arg]"
+ fi
+ ;;
+ esac
+ shift
+done
+
+if [ ! -c /dev/net/tun ] ; then
+ echo "TUN control device /dev/net/tun is unavailable; you may need to enable TUN (e.g. sudo modprobe tun)"
+ exit 1
+elif [ ! -w /dev/net/tun ] ; then
+ echo "TUN control device /dev/net/tun is not writable, please fix (e.g. sudo chmod 666 /dev/net/tun)"
+ exit 1
+fi
+
+# Report errors for missing combinations of options
+if [ -z "$MACHINE" -a -z "$KERNEL" -a -z "$VM" -a "$FSTYPE" != "wic" ]; then
+ error "you must specify at least a MACHINE or KERNEL argument"
+fi
+if [ "$FSTYPE" = "nfs" -a -z "$ROOTFS" ]; then
+ error "NFS booting without an explicit ROOTFS path is not yet supported"
+fi
+
+if [ -z "$MACHINE" ]; then
+ if [ "$IS_VM" = "true" ]; then
+ [ "x$FSTYPE" = "xwic" ] && filename=$ROOTFS || filename=$VM
+ MACHINE=`basename $filename | sed -n 's/.*\(qemux86-64\|qemux86\|qemuarm64\|qemuarm\|qemumips64\|qemumips\|qemuppc\|qemush4\).*/\1/p'`
+ if [ -z "$MACHINE" ]; then
+ error "Unable to set MACHINE from image filename [$VM]"
+ fi
+ echo "Set MACHINE to [$MACHINE] based on image [$VM]"
+ else
+ MACHINE=`basename $KERNEL | sed -n 's/.*\(qemux86-64\|qemux86\|qemuarm64\|qemuarm\|qemumips64\|qemumips\|qemuppc\|qemush4\).*/\1/p'`
+ if [ -z "$MACHINE" ]; then
+ error "Unable to set MACHINE from kernel filename [$KERNEL]"
+ fi
+ echo "Set MACHINE to [$MACHINE] based on kernel [$KERNEL]"
+ fi
+fi
+
+YOCTO_KVM_WIKI="https://wiki.yoctoproject.org/wiki/How_to_enable_KVM_for_Poky_qemu"
+YOCTO_PARAVIRT_KVM_WIKI="https://wiki.yoctoproject.org/wiki/Running_an_x86_Yocto_Linux_image_under_QEMU_KVM"
+# Detect KVM configuration
+if [ "x$KVM_ENABLED" = "xyes" ]; then
+ if [ -z "$KVM_CAPABLE" ]; then
+ echo "You are trying to enable KVM on a cpu without VT support."
+ echo "Remove kvm from the command-line, or refer"
+ echo "$YOCTO_KVM_WIKI";
+ exit 1;
+ fi
+ if [ "x$MACHINE" != "xqemux86" -a "x$MACHINE" != "xqemux86-64" ]; then
+ echo "KVM only support x86 & x86-64. Remove kvm from the command-line";
+ exit 1;
+ fi
+ if [ ! -e /dev/kvm ]; then
+ echo "Missing KVM device. Have you inserted kvm modules?"
+ echo "For further help see:"
+ echo "$YOCTO_KVM_WIKI";
+ exit 1;
+ fi
+ if [ -w /dev/kvm -a -r /dev/kvm ]; then
+ SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm"
+ KVM_ACTIVE="yes"
+ else
+ echo "You have no rights on /dev/kvm."
+ echo "Please change the ownership of this file as described at:"
+ echo "$YOCTO_KVM_WIKI";
+ exit 1;
+ fi
+ if [ "x$VHOST_ENABLED" = "xyes" ]; then
+ if [ ! -e /dev/vhost-net ]; then
+ echo "Missing virtio net device. Have you inserted vhost-net module?"
+ echo "For further help see:"
+ echo "$YOCTO_PARAVIRT_KVM_WIKI";
+ exit 1;
+ fi
+
+ if [ -w /dev/vhost-net -a -r /dev/vhost-net ]; then
+ VHOST_ACTIVE="yes"
+ else
+ echo "You have no rights on /dev/vhost-net."
+ echo "Please change the ownership of this file as described at:"
+ echo "$YOCTO_KVM_WIKI";
+ exit 1;
+ fi
+ fi
+fi
+
+machine2=`echo $MACHINE | tr 'a-z' 'A-Z' | sed 's/-/_/'`
+# MACHINE is now set for all cases
+
+# Defaults used when these vars need to be inferred
+QEMUX86_DEFAULT_KERNEL=bzImage-qemux86.bin
+QEMUX86_DEFAULT_FSTYPE=ext4
+
+QEMUX86_64_DEFAULT_KERNEL=bzImage-qemux86-64.bin
+QEMUX86_64_DEFAULT_FSTYPE=ext4
+
+QEMUARM_DEFAULT_KERNEL=zImage-qemuarm.bin
+QEMUARM_DEFAULT_FSTYPE=ext4
+
+QEMUARM64_DEFAULT_KERNEL=Image-qemuarm64.bin
+QEMUARM64_DEFAULT_FSTYPE=ext4
+
+QEMUMIPS_DEFAULT_KERNEL=vmlinux-qemumips.bin
+QEMUMIPS_DEFAULT_FSTYPE=ext4
+
+QEMUMIPSEL_DEFAULT_KERNEL=vmlinux-qemumipsel.bin
+QEMUMIPSEL_DEFAULT_FSTYPE=ext4
+
+QEMUMIPS64_DEFAULT_KERNEL=vmlinux-qemumips64.bin
+QEMUMIPS64_DEFAULT_FSTYPE=ext4
+
+QEMUSH4_DEFAULT_KERNEL=vmlinux-qemumips.bin
+QEMUSH4_DEFAULT_FSTYPE=ext4
+
+QEMUPPC_DEFAULT_KERNEL=vmlinux-qemuppc.bin
+QEMUPPC_DEFAULT_FSTYPE=ext4
+
+QEMUMICROBLAZE_DEFAULT_KERNEL=linux.bin.ub
+QEMUMICROBLAZE_DEFAULT_FSTYPE=cpio
+
+QEMUZYNQ_DEFAULT_KERNEL=uImage
+QEMUZYNQ_DEFAULT_FSTYPE=cpio
+
+QEMUZYNQMP_DEFAULT_KERNEL=Image
+QEMUZYNQMP_DEFAULT_FSTYPE=cpio
+
+setup_path_vars() {
+ if [ -z "$OE_TMPDIR" ] ; then
+ PATHS_REQUIRED=true
+ elif [ "$1" = "1" -a -z "$DEPLOY_DIR_IMAGE" ] ; then
+ PATHS_REQUIRED=true
+ else
+ PATHS_REQUIRED=false
+ fi
+
+ if [ "$PATHS_REQUIRED" = "true" ]; then
+ # Try to get the variable values from bitbake
+ type -P bitbake &>/dev/null || {
+ echo "In order for this script to dynamically infer paths";
+ echo "to kernels or filesystem images, you either need";
+ echo "bitbake in your PATH or to source oe-init-build-env";
+ echo "before running this script" >&2;
+ exit 1; }
+
+ # We have bitbake in PATH, get the variable values from bitbake
+ BITBAKE_ENV_TMPFILE=`mktemp --tmpdir runqemu.XXXXXXXXXX`
+ if [ "$?" != "0" ] ; then
+ echo "Error: mktemp failed for bitbake environment output"
+ exit 1
+ fi
+
+ MACHINE=$MACHINE bitbake -e > $BITBAKE_ENV_TMPFILE
+ if [ -z "$OE_TMPDIR" ] ; then
+ OE_TMPDIR=`sed -n 's/^TMPDIR=\"\(.*\)\"/\1/p' $BITBAKE_ENV_TMPFILE`
+ fi
+ if [ -z "$DEPLOY_DIR_IMAGE" ] ; then
+ DEPLOY_DIR_IMAGE=`sed -n 's/^DEPLOY_DIR_IMAGE=\"\(.*\)\"/\1/p' $BITBAKE_ENV_TMPFILE`
+ fi
+ if [ -z "$QEMU_DTB" ] ; then
+ QEMU_DTB=`sed -n 's/^QEMU_DTB=\"\(.*\)\"/\1/p' $BITBAKE_ENV_TMPFILE`
+ fi
+ if [ -z "$OE_TMPDIR" ]; then
+ # Check for errors from bitbake that the user needs to know about
+ BITBAKE_OUTPUT=`cat $BITBAKE_ENV_TMPFILE | wc -l`
+ if [ "$BITBAKE_OUTPUT" -eq "0" ]; then
+ echo "Error: this script needs to be run from your build directory, or you need"
+ echo "to explicitly set OE_TMPDIR and DEPLOY_DIR_IMAGE in your environment"
+ else
+ echo "There was an error running bitbake to determine TMPDIR"
+ echo "Here is the output from 'bitbake -e':"
+ cat $BITBAKE_ENV_TMPFILE
+ fi
+ rm $BITBAKE_ENV_TMPFILE
+ exit 1
+ fi
+ rm $BITBAKE_ENV_TMPFILE
+ fi
+}
+
+setup_sysroot() {
+ # Toolchain installs set up $OECORE_NATIVE_SYSROOT in their
+ # environment script. If that variable isn't set, we're
+ # either in an in-tree build scenario or the environment
+ # script wasn't source'd.
+ if [ -z "$OECORE_NATIVE_SYSROOT" ]; then
+ setup_path_vars
+ BUILD_ARCH=`uname -m`
+ BUILD_OS=`uname | tr '[A-Z]' '[a-z]'`
+ BUILD_SYS="$BUILD_ARCH-$BUILD_OS"
+
+ OECORE_NATIVE_SYSROOT=$OE_TMPDIR/sysroots/$BUILD_SYS
+ fi
+
+ # Some recipes store the BIOS under $OE_TMPDIR/sysroots/$MACHINE,
+ # now defined as OECORE_MACHINE_SYSROOT. The latter is used when searching
+ # BIOS, VGA BIOS and keymaps.
+ if [ -z "$OECORE_MACHINE_SYSROOT" ]; then
+ OECORE_MACHINE_SYSROOT=$OE_TMPDIR/sysroots/$MACHINE
+ fi
+}
+
+# Locate a rootfs image to boot which matches our expected
+# machine and fstype.
+findimage() {
+ where=$1
+ machine=$2
+ extension=$3
+
+ # Sort rootfs candidates by modification time - the most
+ # recently created one is the one we most likely want to boot.
+ filename=`ls -t1 $where/*-image*$machine.$extension 2>/dev/null | head -n1`
+ if [ "x$filename" != "x" ]; then
+ ROOTFS=$filename
+ return
+ fi
+
+ echo "Couldn't find a $machine rootfs image in $where."
+ exit 1
+}
+
+# Bios is necessary when using otaimg, look for it
+if [ "$FSTYPE" = "otaimg" ]; then
+ setup_path_vars 1
+ bios_option=`expr "$SCRIPT_QEMU_OPT" : '.*\(-bios\)'`
+ echo "bios_option: $bios_option"
+ if [ -z $bios_option ]; then
+ echo "LOOK FOR BIOS at ${DEPLOY_DIR_IMAGE}"
+ # if -bios wasn't specified explicitly, try to look at the default location
+ if [ -e "${DEPLOY_DIR_IMAGE}/u-boot.rom" ]; then
+ SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -bios ${DEPLOY_DIR_IMAGE}/u-boot.rom"
+ else
+ error "OTA image requires specifying u-boot as BIOS"
+ fi
+ fi
+fi
+
+
+# Kernel command line is stored in compressed format as u-boot environment
+# which breaks determining drive interface with grep in runqemu-internal
+if [ "$FSTYPE" = "otaimg" ]; then
+ FORCE_DRIVE_IF="ide"
+fi
+
+if [ -e "$ROOTFS" -a -z "$FSTYPE" ]; then
+ # Extract the filename extension
+ EXT=`echo $ROOTFS | awk -F . '{ print \$NF }'`
+ if [ "x$EXT" = "xext2" -o "x$EXT" = "xext3" -o \
+ "x$EXT" = "xjffs2" -o "x$EXT" = "xbtrfs" -o \
+ "x$EXT" = "xext4" ]; then
+ FSTYPE=$EXT
+ else
+ echo "Note: Unable to determine filesystem extension for $ROOTFS"
+ echo "We will use the default FSTYPE for $MACHINE"
+ # ...which is done further below...
+ fi
+fi
+
+if [ -z "$KERNEL" -a "$IS_VM" = "false" ]; then \
+ setup_path_vars 1
+ eval kernel_file=\$${machine2}_DEFAULT_KERNEL
+ KERNEL=$DEPLOY_DIR_IMAGE/$kernel_file
+
+ if [ -z "$KERNEL" ]; then
+ error "Unable to determine default kernel for MACHINE [$MACHINE]"
+ fi
+fi
+# KERNEL is now set for all cases
+
+if [ -z "$FSTYPE" ]; then
+ eval FSTYPE=\$${machine2}_DEFAULT_FSTYPE
+
+ if [ -z "$FSTYPE" ]; then
+ error "Unable to determine default fstype for MACHINE [$MACHINE]"
+ fi
+fi
+
+# FSTYPE is now set for all cases
+
+# Handle cases where a ROOTFS type is given instead of a filename, e.g.
+# core-image-sato
+if [ "$LAZY_ROOTFS" = "true" ]; then
+ setup_path_vars 1
+ echo "Assuming $ROOTFS really means $DEPLOY_DIR_IMAGE/$ROOTFS-$MACHINE.$FSTYPE"
+ if [ "$IS_VM" = "true" ]; then
+ VM=$DEPLOY_DIR_IMAGE/$ROOTFS-$MACHINE.$FSTYPE
+ else
+ ROOTFS=$DEPLOY_DIR_IMAGE/$ROOTFS-$MACHINE.$FSTYPE
+ fi
+fi
+
+if [ -z "$ROOTFS" ]; then
+ setup_path_vars 1
+ T=$DEPLOY_DIR_IMAGE
+ eval rootfs_list=\$${machine2}_DEFAULT_ROOTFS
+ findimage $T $MACHINE $FSTYPE
+
+ if [ -z "$ROOTFS" ]; then
+ error "Unable to determine default rootfs for MACHINE [$MACHINE]"
+ elif [ "$IS_VM" = "true" ]; then
+ VM=$ROOTFS
+ fi
+fi
+# ROOTFS is now set for all cases, now expand it to be an absolute path, it should exist at this point
+
+ROOTFS=`readlink -f $ROOTFS`
+
+echo ""
+echo "Continuing with the following parameters:"
+if [ "$IS_VM" = "false" ]; then
+ echo "KERNEL: [$KERNEL]"
+ echo "ROOTFS: [$ROOTFS]"
+else
+ echo "VM: [$VM]"
+fi
+echo "FSTYPE: [$FSTYPE]"
+
+setup_sysroot
+# OECORE_NATIVE_SYSROOT and OECORE_MACHINE_SYSROOT are now set for all cases
+
+INTERNAL_SCRIPT="$0-internal"
+if [ ! -f "$INTERNAL_SCRIPT" -o ! -r "$INTERNAL_SCRIPT" ]; then
+INTERNAL_SCRIPT=`which runqemu-internal`
+fi
+
+# Specify directory for BIOS, VGA BIOS and keymaps
+if [ ! -z "$CUSTOMBIOSDIR" ]; then
+ if [ -d "$OECORE_NATIVE_SYSROOT/$CUSTOMBIOSDIR" ]; then
+ echo "Assuming biosdir is $OECORE_NATIVE_SYSROOT/$CUSTOMBIOSDIR"
+ SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -L $OECORE_NATIVE_SYSROOT/$CUSTOMBIOSDIR"
+ elif [ -d "$OECORE_MACHINE_SYSROOT/$CUSTOMBIOSDIR" ]; then
+ echo "Assuming biosdir is $OECORE_MACHINE_SYSROOT/$CUSTOMBIOSDIR"
+ SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -L $OECORE_MACHINE_SYSROOT/$CUSTOMBIOSDIR"
+ else
+ if [ ! -d "$CUSTOMBIOSDIR" ]; then
+ echo "Custom BIOS directory not found. Tried: $CUSTOMBIOSDIR"
+ echo "and $OECORE_NATIVE_SYSROOT/$CUSTOMBIOSDIR"
+ echo "and $OECORE_MACHINE_SYSROOT/$CUSTOMBIOSDIR"
+ exit 1;
+ fi
+ echo "Assuming biosdir is $CUSTOMBIOSDIR"
+ SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -L $CUSTOMBIOSDIR"
+ fi
+fi
+
+. $INTERNAL_SCRIPT
+exit $?
diff --git a/meta-sota/scripts/runqemu-addptable2image b/meta-sota/scripts/runqemu-addptable2image
new file mode 100755
index 0000000..f0195ad
--- /dev/null
+++ b/meta-sota/scripts/runqemu-addptable2image
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+# Add a partion table to an ext2 image file
+#
+# Copyright (C) 2006-2007 OpenedHand Ltd.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+IMAGE=$1
+IMAGEOUT=$2
+
+echo $IMAGE
+echo $IMAGEOUT
+
+size=`ls -l $IMAGE | awk '{ print $5}'`
+size2=`expr $size / 512 / 16 / 63`
+
+echo $size
+echo $size2
+
+# MBR Size = 512 * 63 bytes
+dd if=/dev/zero of=$IMAGEOUT count=63
+
+echo "x" > /tmp/fdisk.cmds
+echo "c" >> /tmp/fdisk.cmds
+echo "1024" >> /tmp/fdisk.cmds
+echo "h" >> /tmp/fdisk.cmds
+echo "16" >> /tmp/fdisk.cmds
+echo "r" >> /tmp/fdisk.cmds
+echo "n" >> /tmp/fdisk.cmds
+echo "p" >> /tmp/fdisk.cmds
+echo "1" >> /tmp/fdisk.cmds
+echo "1" >> /tmp/fdisk.cmds
+echo "$size2" >> /tmp/fdisk.cmds
+echo "w" >> /tmp/fdisk.cmds
+
+/sbin/fdisk $IMAGEOUT < /tmp/fdisk.cmds
+cat $IMAGE >> $IMAGEOUT
diff --git a/meta-sota/scripts/runqemu-export-rootfs b/meta-sota/scripts/runqemu-export-rootfs
new file mode 100755
index 0000000..3dee131
--- /dev/null
+++ b/meta-sota/scripts/runqemu-export-rootfs
@@ -0,0 +1,163 @@
+#!/bin/bash
+#
+# Copyright (c) 2005-2009 Wind River Systems, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+usage() {
+ echo "Usage: $0 {start|stop|restart} <nfs-export-dir>"
+}
+
+if [ $# != 2 ]; then
+ usage
+ exit 1
+fi
+
+if [[ "$1" != "start" && "$1" != "stop" && "$1" != "restart" ]]; then
+ echo "Unknown command '$1'"
+ usage
+ exit 1
+fi
+
+if [ ! -d "$2" ]; then
+ echo "Error: '$2' does not exist"
+ usage
+ exit 1
+fi
+# Ensure the nfs-export-dir is an absolute path
+NFS_EXPORT_DIR=$(cd "$2" && pwd)
+
+SYSROOT_SETUP_SCRIPT=`which oe-find-native-sysroot 2> /dev/null`
+if [ -z "$SYSROOT_SETUP_SCRIPT" ]; then
+ echo "Error: Unable to find the oe-find-native-sysroot script"
+ echo "Did you forget to source your build environment setup script?"
+ exit 1
+fi
+. $SYSROOT_SETUP_SCRIPT
+
+if [ ! -e "$OECORE_NATIVE_SYSROOT/usr/bin/unfsd" ]; then
+ echo "Error: Unable to find unfsd binary in $OECORE_NATIVE_SYSROOT/usr/bin/"
+
+ if [ "x$OECORE_DISTRO_VERSION" = "x" ]; then
+ echo "Have you run 'bitbake meta-ide-support'?"
+ else
+ echo "This shouldn't happen - something is missing from your toolchain installation"
+ fi
+ exit 1
+fi
+
+if [ ! -d ~/.runqemu-sdk ]; then
+ mkdir -p ~/.runqemu-sdk
+fi
+
+NFS_INSTANCE=${NFS_INSTANCE:=0}
+EXPORTS=~/.runqemu-sdk/exports$NFS_INSTANCE
+RMTAB=~/.runqemu-sdk/rmtab$NFS_INSTANCE
+NFSPID=~/.runqemu-sdk/nfs$NFS_INSTANCE.pid
+MOUNTPID=~/.runqemu-sdk/mount$NFS_INSTANCE.pid
+
+PSEUDO_OPTS="-P $OECORE_NATIVE_SYSROOT/usr"
+PSEUDO_LOCALSTATEDIR="$NFS_EXPORT_DIR/../$(basename $NFS_EXPORT_DIR).pseudo_state"
+export PSEUDO_LOCALSTATEDIR
+
+if [ ! -d "$PSEUDO_LOCALSTATEDIR" ]; then
+ echo "Error: $PSEUDO_LOCALSTATEDIR does not exist."
+ echo "Did you create the export directory using runqemu-extract-sdk?"
+ exit 1
+fi
+
+# rpc.mountd RPC port
+NFS_MOUNTPROG=$[ 21111 + $NFS_INSTANCE ]
+# rpc.nfsd RPC port
+NFS_NFSPROG=$[ 11111 + $NFS_INSTANCE ]
+# NFS port number
+NFS_PORT=$[ 3049 + 2 * $NFS_INSTANCE ]
+# mountd port number
+MOUNT_PORT=$[ 3048 + 2 * $NFS_INSTANCE ]
+
+## For debugging you would additionally add
+## --debug all
+UNFSD_OPTS="-p -N -i $NFSPID -e $EXPORTS -x $NFS_NFSPROG -n $NFS_PORT -y $NFS_MOUNTPROG -m $MOUNT_PORT"
+
+# Setup the exports file
+if [ "$1" = "start" ]; then
+ echo "Creating exports file..."
+ echo "$NFS_EXPORT_DIR (rw,async,no_root_squash,no_all_squash,insecure)" > $EXPORTS
+fi
+
+# See how we were called.
+case "$1" in
+ start)
+ PORTMAP_RUNNING=`ps -ef | grep portmap | grep -v grep`
+ RPCBIND_RUNNING=`ps -ef | grep rpcbind | grep -v grep`
+ if [[ "x$PORTMAP_RUNNING" = "x" && "x$RPCBIND_RUNNING" = "x" ]]; then
+ echo "======================================================="
+ echo "Error: neither rpcbind nor portmap appear to be running"
+ echo "Please install and start one of these services first"
+ echo "======================================================="
+ echo "Tip: for recent Ubuntu hosts, run:"
+ echo " sudo apt-get install rpcbind"
+ echo "Then add OPTIONS=\"-i -w\" to /etc/default/rpcbind and run"
+ echo " sudo service portmap restart"
+
+ exit 1
+ fi
+
+ echo "Starting User Mode nfsd"
+ echo " $PSEUDO $PSEUDO_OPTS $OECORE_NATIVE_SYSROOT/usr/bin/unfsd $UNFSD_OPTS"
+ $PSEUDO $PSEUDO_OPTS $OECORE_NATIVE_SYSROOT/usr/bin/unfsd $UNFSD_OPTS
+ if [ ! $? = 0 ]; then
+ echo "Error starting nfsd"
+ exit 1
+ fi
+ # Check to make sure everything started ok.
+ if [ ! -f $NFSPID ]; then
+ echo "rpc.nfsd did not start correctly"
+ exit 1
+ fi
+ ps -fp `cat $NFSPID` > /dev/null 2> /dev/null
+ if [ ! $? = 0 ]; then
+ echo "rpc.nfsd did not start correctly"
+ exit 1
+ fi
+ echo " "
+ echo "On your target please remember to add the following options for NFS"
+ echo "nfsroot=IP_ADDRESS:$NFS_EXPORT_DIR,nfsvers=3,port=$NFSD_PORT,mountprog=$MOUNTD_RPCPORT,nfsprog=$NFSD_RPCPORT,udp,mountport=$MOUNTD_PORT"
+ ;;
+ stop)
+ if [ -f "$NFSPID" ]; then
+ echo "Stopping rpc.nfsd"
+ kill `cat $NFSPID`
+ rm -f $NFSPID
+ else
+ echo "No PID file, not stopping rpc.nfsd"
+ fi
+ if [ -f "$EXPORTS" ]; then
+ echo "Removing exports file"
+ rm -f $EXPORTS
+ fi
+ ;;
+ restart)
+ $0 stop $NFS_EXPORT_DIR
+ $0 start $NFS_EXPORT_DIR
+ if [ ! $? = 0 ]; then
+ exit 1
+ fi
+ ;;
+ *)
+ echo "$0 {start|stop|restart} <nfs-export-dir>"
+ ;;
+esac
+
+exit 0
diff --git a/meta-sota/scripts/runqemu-extract-sdk b/meta-sota/scripts/runqemu-extract-sdk
new file mode 100755
index 0000000..32ddd48
--- /dev/null
+++ b/meta-sota/scripts/runqemu-extract-sdk
@@ -0,0 +1,104 @@
+#!/bin/bash
+#
+# This utility extracts an SDK image tarball using pseudo, and stores
+# the pseudo database in var/pseudo within the rootfs. If you want to
+# boot QEMU using an nfsroot, you *must* use this script to create the
+# rootfs to ensure it is done correctly with pseudo.
+#
+# Copyright (c) 2010 Intel Corp.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+function usage() {
+ echo "Usage: $0 <image-tarball> <extract-dir>"
+}
+
+if [ $# -ne 2 ]; then
+ usage
+ exit 1
+fi
+
+SYSROOT_SETUP_SCRIPT=`which oe-find-native-sysroot 2> /dev/null`
+if [ -z "$SYSROOT_SETUP_SCRIPT" ]; then
+ echo "Error: Unable to find the oe-find-native-sysroot script"
+ echo "Did you forget to source your build system environment setup script?"
+ exit 1
+fi
+. $SYSROOT_SETUP_SCRIPT
+PSEUDO_OPTS="-P $OECORE_NATIVE_SYSROOT/usr"
+
+ROOTFS_TARBALL=$1
+SDK_ROOTFS_DIR=$2
+
+if [ ! -e "$ROOTFS_TARBALL" ]; then
+ echo "Error: sdk tarball '$ROOTFS_TARBALL' does not exist"
+ usage
+ exit 1
+fi
+
+# Convert SDK_ROOTFS_DIR to a full pathname
+if [[ ${SDK_ROOTFS_DIR:0:1} != "/" ]]; then
+ SDK_ROOTFS_DIR=$(readlink -f $(pwd)/$SDK_ROOTFS_DIR)
+fi
+
+TAR_OPTS=""
+if [[ "$ROOTFS_TARBALL" =~ tar\.bz2$ ]]; then
+ TAR_OPTS="--numeric-owner -xjf"
+fi
+if [[ "$ROOTFS_TARBALL" =~ tar\.gz$ ]]; then
+ TAR_OPTS="--numeric-owner -xzf"
+fi
+if [[ "$ROOTFS_TARBALL" =~ \.tar$ ]]; then
+ TAR_OPTS="--numeric-owner -xf"
+fi
+if [ -z "$TAR_OPTS" ]; then
+ echo "Error: Unable to determine sdk tarball format"
+ echo "Accepted types: .tar / .tar.gz / .tar.bz2"
+ exit 1
+fi
+
+if [ ! -d "$SDK_ROOTFS_DIR" ]; then
+ echo "Creating directory $SDK_ROOTFS_DIR"
+ mkdir -p "$SDK_ROOTFS_DIR"
+fi
+
+pseudo_state_dir="$SDK_ROOTFS_DIR/../$(basename "$SDK_ROOTFS_DIR").pseudo_state"
+pseudo_state_dir="$(readlink -f $pseudo_state_dir)"
+
+if [ -e "$pseudo_state_dir" ]; then
+ echo "Error: $pseudo_state_dir already exists!"
+ echo "Please delete the rootfs tree and pseudo directory manually"
+ echo "if this is really what you want."
+ exit 1
+fi
+
+mkdir -p "$pseudo_state_dir"
+touch "$pseudo_state_dir/pseudo.pid"
+PSEUDO_LOCALSTATEDIR="$pseudo_state_dir"
+export PSEUDO_LOCALSTATEDIR
+
+echo "Extracting rootfs tarball using pseudo..."
+echo "$PSEUDO $PSEUDO_OPTS tar -C \"$SDK_ROOTFS_DIR\" $TAR_OPTS \"$ROOTFS_TARBALL\""
+$PSEUDO $PSEUDO_OPTS tar -C "$SDK_ROOTFS_DIR" $TAR_OPTS "$ROOTFS_TARBALL"
+
+DIRCHECK=`ls -l "$SDK_ROOTFS_DIR" | wc -l`
+if [ "$DIRCHECK" -lt 5 ]; then
+ echo "Warning: I don't see many files in $SDK_ROOTFS_DIR"
+ echo "Please double-check the extraction worked as intended"
+ exit 0
+fi
+
+echo "SDK image successfully extracted to $SDK_ROOTFS_DIR"
+
+exit 0
diff --git a/meta-sota/scripts/runqemu-gen-tapdevs b/meta-sota/scripts/runqemu-gen-tapdevs
new file mode 100755
index 0000000..624deac
--- /dev/null
+++ b/meta-sota/scripts/runqemu-gen-tapdevs
@@ -0,0 +1,100 @@
+#!/bin/bash
+#
+# Create a "bank" of tap network devices that can be used by the
+# runqemu script. This script needs to be run as root, and will
+# use the tunctl binary from the build system sysroot. Note: many Linux
+# distros these days still use an older version of tunctl which does not
+# support the group permissions option, hence the need to use the build
+# system provided version.
+#
+# Copyright (C) 2010 Intel Corp.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+usage() {
+ echo "Usage: sudo $0 <uid> <gid> <num> <native-sysroot-basedir>"
+ echo "Where <uid> is the numeric user id the tap devices will be owned by"
+ echo "Where <gid> is the numeric group id the tap devices will be owned by"
+ echo "<num> is the number of tap devices to create (0 to remove all)"
+ echo "<native-sysroot-basedir> is the path to the build system's native sysroot"
+ exit 1
+}
+
+if [ $EUID -ne 0 ]; then
+ echo "Error: This script must be run with root privileges"
+ exit
+fi
+
+if [ $# -ne 4 ]; then
+ echo "Error: Incorrect number of arguments"
+ usage
+fi
+
+TUID=$1
+GID=$2
+COUNT=$3
+SYSROOT=$4
+
+TUNCTL=$SYSROOT/usr/bin/tunctl
+if [[ ! -x "$TUNCTL" || -d "$TUNCTL" ]]; then
+ echo "Error: $TUNCTL is not an executable"
+ usage
+fi
+
+SCRIPT_DIR=`dirname $0`
+RUNQEMU_IFUP="$SCRIPT_DIR/runqemu-ifup"
+if [ ! -x "$RUNQEMU_IFUP" ]; then
+ echo "Error: Unable to find the runqemu-ifup script in $SCRIPT_DIR"
+ exit 1
+fi
+
+IFCONFIG=`which ip 2> /dev/null`
+if [ -z "$IFCONFIG" ]; then
+ # Is it ever anywhere else?
+ IFCONFIG=/sbin/ip
+fi
+if [ ! -x "$IFCONFIG" ]; then
+ echo "$IFCONFIG cannot be executed"
+ exit 1
+fi
+
+# Ensure we start with a clean slate
+for tap in `$IFCONFIG link | grep tap | awk '{ print \$2 }' | sed s/://`; do
+ echo "Note: Destroying pre-existing tap interface $tap..."
+ $TUNCTL -d $tap
+done
+
+echo "Creating $COUNT tap devices for UID: $TUID GID: $GID..."
+for ((index=0; index < $COUNT; index++)); do
+ echo "Creating tap$index"
+ ifup=`$RUNQEMU_IFUP $TUID $GID $SYSROOT 2>&1`
+ if [ $? -ne 0 ]; then
+ echo "Error running tunctl: $ifup"
+ exit 1
+ fi
+done
+
+if [ $COUNT -gt 0 ]; then
+ echo "Note: For systems running NetworkManager, it's recommended"
+ echo "Note: that the tap devices be set as unmanaged in the"
+ echo "Note: NetworkManager.conf file. Add the following lines to"
+ echo "Note: /etc/NetworkManager/NetworkManager.conf"
+ echo "[keyfile]"
+ echo "unmanaged-devices=interface-name:tap*"
+fi
+
+# The runqemu script will check for this file, and if it exists,
+# will use the existing bank of tap devices without creating
+# additional ones via sudo.
+touch /etc/runqemu-nosudo
diff --git a/meta-sota/scripts/runqemu-ifdown b/meta-sota/scripts/runqemu-ifdown
new file mode 100755
index 0000000..8f66cfa
--- /dev/null
+++ b/meta-sota/scripts/runqemu-ifdown
@@ -0,0 +1,66 @@
+#!/bin/bash
+#
+# QEMU network configuration script to bring down tap devices. This
+# utility needs to be run as root, and will use the tunctl binary
+# from the native sysroot.
+#
+# If you find yourself calling this script a lot, you can add the
+# the following to your /etc/sudoers file to be able to run this
+# command without entering your password each time:
+#
+# <my-username> ALL=NOPASSWD: /path/to/runqemu-ifup
+# <my-username> ALL=NOPASSWD: /path/to/runqemu-ifdown
+#
+# Copyright (c) 2006-2011 Linux Foundation
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+usage() {
+ echo "sudo $(basename $0) <tap-dev> <native-sysroot-basedir>"
+}
+
+if [ $EUID -ne 0 ]; then
+ echo "Error: This script (runqemu-ifdown) must be run with root privileges"
+ exit 1
+fi
+
+if [ $# -ne 2 ]; then
+ usage
+ exit 1
+fi
+
+TAP=$1
+NATIVE_SYSROOT_DIR=$2
+
+TUNCTL=$NATIVE_SYSROOT_DIR/usr/bin/tunctl
+if [ ! -e "$TUNCTL" ]; then
+ echo "Error: Unable to find tunctl binary in '$NATIVE_SYSROOT_DIR/usr/bin', please bitbake qemu-helper-native"
+ exit 1
+fi
+
+$TUNCTL -d $TAP
+
+# cleanup the remaining iptables rules
+IPTABLES=`which iptables 2> /dev/null`
+if [ "x$IPTABLES" = "x" ]; then
+ IPTABLES=/sbin/iptables
+fi
+if [ ! -x "$IPTABLES" ]; then
+ echo "$IPTABLES cannot be executed"
+ exit 1
+fi
+n=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ]
+dest=$[ (`echo $TAP | sed 's/tap//'` * 2) + 2 ]
+$IPTABLES -D POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$n/32
+$IPTABLES -D POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$dest/32
diff --git a/meta-sota/scripts/runqemu-ifup b/meta-sota/scripts/runqemu-ifup
new file mode 100755
index 0000000..d9bd894
--- /dev/null
+++ b/meta-sota/scripts/runqemu-ifup
@@ -0,0 +1,121 @@
+#!/bin/bash
+#
+# QEMU network interface configuration script. This utility needs to
+# be run as root, and will use the tunctl binary from a native sysroot.
+# Note: many Linux distros these days still use an older version of
+# tunctl which does not support the group permissions option, hence
+# the need to use build system's version.
+#
+# If you find yourself calling this script a lot, you can add the
+# the following to your /etc/sudoers file to be able to run this
+# command without entering your password each time:
+#
+# <my-username> ALL=NOPASSWD: /path/to/runqemu-ifup
+# <my-username> ALL=NOPASSWD: /path/to/runqemu-ifdown
+#
+# If you'd like to create a bank of tap devices at once, you should use
+# the runqemu-gen-tapdevs script instead. If tap devices are set up using
+# that script, the runqemu script will never end up calling this
+# script.
+#
+# Copyright (c) 2006-2011 Linux Foundation
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+usage() {
+ echo "sudo $(basename $0) <uid> <gid> <native-sysroot-basedir>"
+}
+
+if [ $EUID -ne 0 ]; then
+ echo "Error: This script (runqemu-ifup) must be run with root privileges"
+ exit 1
+fi
+
+if [ $# -ne 3 ]; then
+ usage
+ exit 1
+fi
+
+USERID="-u $1"
+GROUP="-g $2"
+NATIVE_SYSROOT_DIR=$3
+
+TUNCTL=$NATIVE_SYSROOT_DIR/usr/bin/tunctl
+if [ ! -x "$TUNCTL" ]; then
+ echo "Error: Unable to find tunctl binary in '$NATIVE_SYSROOT_DIR/usr/bin', please bitbake qemu-helper-native"
+ exit 1
+fi
+
+TAP=`$TUNCTL -b $GROUP 2>&1`
+STATUS=$?
+if [ $STATUS -ne 0 ]; then
+# If tunctl -g fails, try using tunctl -u, for older host kernels
+# which do not support the TUNSETGROUP ioctl
+ TAP=`$TUNCTL -b $USERID 2>&1`
+ STATUS=$?
+ if [ $STATUS -ne 0 ]; then
+ echo "tunctl failed:"
+ exit 1
+ fi
+fi
+
+IFCONFIG=`which ip 2> /dev/null`
+if [ "x$IFCONFIG" = "x" ]; then
+ # better than nothing...
+ IFCONFIG=/sbin/ip
+fi
+if [ ! -x "$IFCONFIG" ]; then
+ echo "$IFCONFIG cannot be executed"
+ exit 1
+fi
+
+IPTABLES=`which iptables 2> /dev/null`
+if [ "x$IPTABLES" = "x" ]; then
+ IPTABLES=/sbin/iptables
+fi
+if [ ! -x "$IPTABLES" ]; then
+ echo "$IPTABLES cannot be executed"
+ exit 1
+fi
+
+n=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ]
+$IFCONFIG addr add 192.168.7.$n/32 broadcast 192.168.7.255 dev $TAP
+STATUS=$?
+if [ $STATUS -ne 0 ]; then
+ echo "Failed to set up IP addressing on $TAP"
+ exit 1
+fi
+$IFCONFIG link set dev $TAP up
+STATUS=$?
+if [ $STATUS -ne 0 ]; then
+ echo "Failed to bring up $TAP"
+ exit 1
+fi
+
+dest=$[ (`echo $TAP | sed 's/tap//'` * 2) + 2 ]
+$IFCONFIG route add to 192.168.7.$dest dev $TAP
+STATUS=$?
+if [ $STATUS -ne 0 ]; then
+ echo "Failed to add route to 192.168.7.$dest using $TAP"
+ exit 1
+fi
+
+# setup NAT for tap0 interface to have internet access in QEMU
+$IPTABLES -A POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$n/32
+$IPTABLES -A POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$dest/32
+echo 1 > /proc/sys/net/ipv4/ip_forward
+echo 1 > /proc/sys/net/ipv4/conf/$TAP/proxy_arp
+$IPTABLES -P FORWARD ACCEPT
+
+echo $TAP
diff --git a/meta-sota/scripts/runqemu-internal b/meta-sota/scripts/runqemu-internal
new file mode 100755
index 0000000..9811cf9
--- /dev/null
+++ b/meta-sota/scripts/runqemu-internal
@@ -0,0 +1,760 @@
+#!/bin/bash -x
+
+# Handle running OE images under qemu
+#
+# Copyright (C) 2006-2011 Linux Foundation
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+# Call setting:
+# QEMU_MEMORY (optional) - set the amount of memory in the emualted system.
+# SERIAL_LOGFILE (optional) - log the serial port output to a file
+#
+# Image options:
+# MACHINE - the machine to run
+# FSTYPE - the image type to run
+# KERNEL - the kernel image file to use
+# ROOTFS - the disk image file to use
+#
+
+mem_size=-1
+
+#Get rid of <> and get the contents of extra qemu running params
+SCRIPT_QEMU_EXTRA_OPT=`echo $SCRIPT_QEMU_EXTRA_OPT | sed -e 's/<//' -e 's/>//'`
+#if user set qemu memory, eg: -m 256 in qemu extra params, we need to do some
+# validation check
+mem_set=`expr "$SCRIPT_QEMU_EXTRA_OPT" : '.*\(-m[[:space:]] *[0-9]*\)'`
+if [ ! -z "$mem_set" ] ; then
+#Get memory setting size from user input
+ mem_size=`echo $mem_set | sed 's/-m[[:space:]] *//'`
+fi
+
+# This file is created when runqemu-gen-tapdevs creates a bank of tap
+# devices, indicating that the user should not bring up new ones using
+# sudo.
+NOSUDO_FLAG="/etc/runqemu-nosudo"
+
+QEMUIFUP=`which runqemu-ifup 2> /dev/null`
+QEMUIFDOWN=`which runqemu-ifdown 2> /dev/null`
+if [ -z "$QEMUIFUP" -o ! -x "$QEMUIFUP" ]; then
+ echo "runqemu-ifup cannot be found or executed"
+ exit 1
+fi
+if [ -z "$QEMUIFDOWN" -o ! -x "$QEMUIFDOWN" ]; then
+ echo "runqemu-ifdown cannot be found or executed"
+ exit 1
+fi
+
+NFSRUNNING="false"
+
+#capture original stty values
+ORIG_STTY=$(stty -g)
+
+if [ "$SLIRP_ENABLED" = "yes" ]; then
+ KERNEL_NETWORK_CMD="ip=dhcp"
+ QEMU_TAP_CMD=""
+ QEMU_UI_OPTIONS="-show-cursor -usb -usbdevice tablet"
+ QEMU_NETWORK_CMD=""
+ DROOT="/dev/vda"
+ ROOTFS_OPTIONS="-drive file=$ROOTFS,if=virtio,format=raw"
+else
+ acquire_lock() {
+ lockfile=$1
+ if [ -z "$lockfile" ]; then
+ echo "Error: missing lockfile arg passed to acquire_lock()"
+ return 1
+ fi
+
+ touch $lockfile.lock 2>/dev/null
+ if [ $? -ne 0 ]; then
+ echo "Acquiring lockfile for $lockfile.lock failed"
+ return 1
+ fi
+ exec 8>$lockfile.lock
+ flock -n -x 8
+ if [ $? -ne 0 ]; then
+ exec 8>&-
+ return 1
+ fi
+
+ return 0
+ }
+
+ release_lock() {
+ lockfile=$1
+ if [ -z "$lockfile" ]; then
+ echo "Error: missing lockfile arg passed to release_lock()"
+ return 1
+ fi
+
+ rm -f $lockfile.lock
+ exec 8>&-
+ }
+
+ LOCKDIR="/tmp/qemu-tap-locks"
+ if [ ! -d "$LOCKDIR" ]; then
+ mkdir $LOCKDIR
+ chmod 777 $LOCKDIR
+ fi
+
+ IFCONFIG=`which ip 2> /dev/null`
+ if [ -z "$IFCONFIG" ]; then
+ IFCONFIG=/sbin/ip
+ fi
+ if [ ! -x "$IFCONFIG" ]; then
+ echo "$IFCONFIG cannot be executed"
+ exit 1
+ fi
+
+ POSSIBLE=`$IFCONFIG link | grep 'tap' | awk '{print $2}' | sed -e 's/://' -e 's/@.*//'`
+ TAP=""
+ LOCKFILE=""
+ USE_PRECONF_TAP="no"
+ for tap in $POSSIBLE; do
+ LOCKFILE="$LOCKDIR/$tap"
+ if [ -e "$LOCKFILE.skip" ]; then
+ echo "Found $LOCKFILE.skip, skipping $tap"
+ continue
+ fi
+ echo "Acquiring lockfile for $tap..."
+ acquire_lock $LOCKFILE
+ if [ $? -eq 0 ]; then
+ TAP=$tap
+ USE_PRECONF_TAP="yes"
+ break
+ fi
+ done
+
+ if [ "$TAP" = "" ]; then
+ if [ -e "$NOSUDO_FLAG" ]; then
+ echo "Error: There are no available tap devices to use for networking,"
+ echo "and I see $NOSUDO_FLAG exists, so I am not going to try creating"
+ echo "a new one with sudo."
+ exit 1
+ fi
+
+ GROUPID=`id -g`
+ USERID=`id -u`
+ echo "Setting up tap interface under sudo"
+ # Redirect stderr since we could see a LD_PRELOAD warning here if pseudo is loaded
+ # but inactive. This looks scary but is harmless
+ tap=`sudo $QEMUIFUP $USERID $GROUPID $OECORE_NATIVE_SYSROOT 2> /dev/null`
+ if [ $? -ne 0 ]; then
+ # Re-run standalone to see verbose errors
+ sudo $QEMUIFUP $USERID $GROUPID $OECORE_NATIVE_SYSROOT
+ return 1
+ fi
+ LOCKFILE="$LOCKDIR/$tap"
+ echo "Acquiring lockfile for $tap..."
+ acquire_lock $LOCKFILE
+ if [ $? -eq 0 ]; then
+ TAP=$tap
+ fi
+ else
+ echo "Using preconfigured tap device '$TAP'"
+ echo "If this is not intended, touch $LOCKFILE.skip to make runqemu skip $TAP."
+ fi
+
+ cleanup() {
+ if [ ! -e "$NOSUDO_FLAG" -a "$USE_PRECONF_TAP" = "no" ]; then
+ # Redirect stderr since we could see a LD_PRELOAD warning here if pseudo is loaded
+ # but inactive. This looks scary but is harmless
+ sudo $QEMUIFDOWN $TAP $OECORE_NATIVE_SYSROOT 2> /dev/null
+ fi
+ echo "Releasing lockfile of preconfigured tap device '$TAP'"
+ release_lock $LOCKFILE
+
+ if [ "$NFSRUNNING" = "true" ]; then
+ echo "Shutting down the userspace NFS server..."
+ echo "runqemu-export-rootfs stop $ROOTFS"
+ runqemu-export-rootfs stop $ROOTFS
+ fi
+ # If QEMU crashes or somehow tty properties are not restored
+ # after qemu exits, we need to run stty sane
+ #stty sane
+
+ #instead of using stty sane we set the original stty values
+ stty ${ORIG_STTY}
+
+ }
+
+
+ n0=$(echo $TAP | sed 's/tap//')
+
+ case $n0 in
+ ''|*[!0-9]*)
+ echo "Error Couldn't turn $TAP into an interface number?"
+ exit 1
+ ;;
+ esac
+
+ n1=$(($n0 * 2 + 1))
+ n2=$(($n1 + 1))
+
+ KERNEL_NETWORK_CMD="ip=192.168.7.$n2::192.168.7.$n1:255.255.255.0"
+ QEMU_TAP_CMD="-net tap,vlan=0,ifname=$TAP,script=no,downscript=no"
+ if [ "$VHOST_ACTIVE" = "yes" ]; then
+ QEMU_NETWORK_CMD="-net nic,model=virtio $QEMU_TAP_CMD,vhost=on"
+ else
+ QEMU_NETWORK_CMD="-net nic,model=virtio $QEMU_TAP_CMD"
+ fi
+ DROOT="/dev/vda"
+ ROOTFS_OPTIONS="-drive file=$ROOTFS,if=virtio,format=raw"
+
+ KERNCMDLINE="mem=$QEMU_MEMORY"
+ QEMU_UI_OPTIONS="-show-cursor -usb -usbdevice tablet"
+
+ NFS_INSTANCE=`echo $TAP | sed 's/tap//'`
+ export NFS_INSTANCE
+
+ SERIALOPTS=""
+ if [ "x$SERIAL_LOGFILE" != "x" ]; then
+ SERIALOPTS="-serial file:$SERIAL_LOGFILE"
+ fi
+fi
+
+if [ ! -f "$KERNEL" -a "$IS_VM" = "false" ]; then
+ echo "Error: Kernel image file $KERNEL doesn't exist"
+ cleanup
+ return 1
+fi
+
+if [ "$FSTYPE" != "nfs" -a "$IS_VM" = "false" -a ! -f "$ROOTFS" ]; then
+ echo "Error: Image file $ROOTFS doesn't exist"
+ cleanup
+ return 1
+fi
+
+if [ "$NFS_SERVER" = "" ]; then
+ NFS_SERVER="192.168.7.1"
+ if [ "$SLIRP_ENABLED" = "yes" ]; then
+ NFS_SERVER="10.0.2.2"
+ fi
+fi
+
+if [ "$FSTYPE" = "nfs" ]; then
+ NFS_DIR=`echo $ROOTFS | sed 's/^[^:]*:\(.*\)/\1/'`
+ if [ "$NFS_INSTANCE" = "" ] ; then
+ NFS_INSTANCE=0
+ fi
+ MOUNTD_RPCPORT=$[ 21111 + $NFS_INSTANCE ]
+ NFSD_RPCPORT=$[ 11111 + $NFS_INSTANCE ]
+ NFSD_PORT=$[ 3049 + 2 * $NFS_INSTANCE ]
+ MOUNTD_PORT=$[ 3048 + 2 * $NFS_INSTANCE ]
+ UNFS_OPTS="nfsvers=3,port=$NFSD_PORT,mountprog=$MOUNTD_RPCPORT,nfsprog=$NFSD_RPCPORT,udp,mountport=$MOUNTD_PORT"
+
+ PSEUDO_LOCALSTATEDIR=~/.runqemu-sdk/pseudo
+ export PSEUDO_LOCALSTATEDIR
+
+ # Start the userspace NFS server
+ echo "runqemu-export-rootfs restart $ROOTFS"
+ runqemu-export-rootfs restart $ROOTFS
+ if [ $? != 0 ]; then
+ return 1
+ fi
+ NFSRUNNING="true"
+fi
+
+
+set_mem_size() {
+ if [ ! -z "$mem_set" ] ; then
+ #Get memory setting size from user input
+ mem_size=`echo $mem_set | sed 's/-m[[:space:]] *//'`
+ else
+ mem_size=$1
+ fi
+ # QEMU_MEMORY has 'M' appended to mem_size
+ QEMU_MEMORY="$mem_size"M
+
+}
+
+config_qemuarm() {
+ set_mem_size 128
+ QEMU=qemu-system-arm
+ MACHINE_SUBTYPE=versatilepb
+ export QEMU_AUDIO_DRV="none"
+ QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS"
+ if [ "${FSTYPE:0:3}" = "ext" -o "$FSTYPE" = "btrfs" -o "$FSTYPE" = "wic" ]; then
+ KERNCMDLINE="root=$DROOT rw console=ttyAMA0,115200 console=tty $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY highres=off"
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -M ${MACHINE_SUBTYPE} $ROOTFS_OPTIONS -no-reboot $QEMU_UI_OPTIONS"
+ fi
+ if [ "$FSTYPE" = "nfs" ]; then
+ if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then
+ echo "Error: NFS mount point $ROOTFS doesn't exist"
+ cleanup
+ return 1
+ fi
+ KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw console=ttyAMA0,115200 $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -M ${MACHINE_SUBTYPE} --no-reboot $QEMU_UI_OPTIONS"
+ fi
+ if [ "$MACHINE" = "qemuarmv6" ]; then
+ QEMUOPTIONS="$QEMUOPTIONS -cpu arm1136"
+ fi
+ if [ "$MACHINE" = "qemuarmv7" ]; then
+ QEMUOPTIONS="$QEMUOPTIONS -cpu cortex-a8"
+ fi
+}
+
+config_qemuarm64() {
+ set_mem_size 512
+ QEMU=qemu-system-aarch64
+
+ QEMU_NETWORK_CMD="-netdev tap,id=net0,ifname=$TAP,script=no,downscript=no -device virtio-net-device,netdev=net0 "
+ DROOT="/dev/vda"
+ ROOTFS_OPTIONS="-drive id=disk0,file=$ROOTFS,if=none,format=raw -device virtio-blk-device,drive=disk0"
+
+ export QEMU_AUDIO_DRV="none"
+ if [ "x$SERIALSTDIO" = "x" ] ; then
+ QEMU_UI_OPTIONS="-nographic"
+ else
+ QEMU_UI_OPTIONS=""
+ fi
+ if [ "${FSTYPE:0:3}" = "ext" -o "$FSTYPE" = "btrfs" -o "$FSTYPE" = "wic" ]; then
+ KERNCMDLINE="root=$DROOT rw console=ttyAMA0,38400 mem=$QEMU_MEMORY highres=off $KERNEL_NETWORK_CMD"
+ # qemu-system-aarch64 only support '-machine virt -cpu cortex-a57' for now
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -machine virt -cpu cortex-a57 $ROOTFS_OPTIONS $QEMU_UI_OPTIONS"
+ fi
+ if [ "$FSTYPE" = "nfs" ]; then
+ if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then
+ echo "Error: NFS mount point $ROOTFS doesn't exist"
+ cleanup
+ return 1
+ fi
+ KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw console=ttyAMA0,38400 mem=$QEMU_MEMORY highres=off $KERNEL_NETWORK_CMD"
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -machine virt -cpu cortex-a57 $QEMU_UI_OPTIONS"
+ fi
+}
+
+config_qemux86() {
+ set_mem_size 256
+ QEMU=qemu-system-i386
+ if [ "$KVM_ACTIVE" = "yes" ]; then
+ CPU_SUBTYPE=kvm32
+ else
+ CPU_SUBTYPE=qemu32
+ fi
+ if [ ! -z "$vga_option" ]; then
+ QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS"
+ else
+ QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS -vga vmware"
+ fi
+ if [ "${FSTYPE:0:3}" = "ext" -o "$FSTYPE" = "btrfs" -o "$FSTYPE" = "wic" ]; then
+ KERNCMDLINE="vga=0 uvesafb.mode_option=640x480-32 root=$DROOT rw mem=$QEMU_MEMORY $KERNEL_NETWORK_CMD"
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE $ROOTFS_OPTIONS $QEMU_UI_OPTIONS"
+ fi
+ if [ "${FSTYPE:0:4}" = "cpio" ]; then
+ KERNCMDLINE="vga=0 uvesafb.mode_option=640x480-32 root=/dev/ram0 rw mem=$QEMU_MEMORY $KERNEL_NETWORK_CMD"
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE -initrd $ROOTFS $QEMU_UI_OPTIONS"
+ fi
+
+ if [ "$FSTYPE" = "nfs" ]; then
+ if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then
+ echo "Error: NFS mount point $ROOTFS doesn't exist."
+ cleanup
+ return 1
+ fi
+ KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
+ QEMUOPTIONS="$QEMU_NETWORK_CMD $QEMU_UI_OPTIONS"
+ fi
+ if [ "$IS_VM" = "true" ]; then
+ QEMUOPTIONS="$QEMU_NETWORK_CMD $QEMU_UI_OPTIONS"
+ fi
+ # Currently oprofile's event based interrupt mode doesn't work(Bug #828) in
+ # qemux86 and qemux86-64. We can use timer interrupt mode for now.
+ KERNCMDLINE="$KERNCMDLINE oprofile.timer=1"
+}
+
+config_qemux86_64() {
+ set_mem_size 256
+ QEMU=qemu-system-x86_64
+ if [ "$KVM_ACTIVE" = "yes" ]; then
+ CPU_SUBTYPE=kvm64
+ else
+ CPU_SUBTYPE=core2duo
+ fi
+ if [ ! -z "$vga_option" ]; then
+ QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS"
+ else
+ QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS -vga vmware"
+ fi
+ if [ "${FSTYPE:0:3}" = "ext" -o "$FSTYPE" = "btrfs" -o "$FSTYPE" = "wic" ]; then
+ KERNCMDLINE="vga=0 uvesafb.mode_option=640x480-32 root=$DROOT rw mem=$QEMU_MEMORY $KERNEL_NETWORK_CMD"
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE $ROOTFS_OPTIONS $QEMU_UI_OPTIONS"
+ fi
+ if [ "$FSTYPE" = "nfs" ]; then
+ if [ "x$ROOTFS" = "x" ]; then
+ ROOTFS=/srv/nfs/qemux86-64
+ fi
+ if [ ! -d "$ROOTFS" ]; then
+ echo "Error: NFS mount point $ROOTFS doesn't exist."
+ cleanup
+ return 1
+ fi
+ KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE $QEMU_UI_OPTIONS"
+ fi
+ if [ "$IS_VM" = "true" ]; then
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE $QEMU_UI_OPTIONS"
+ fi
+ # Currently oprofile's event based interrupt mode doesn't work(Bug #828) in
+ # qemux86 and qemux86-64. We can use timer interrupt mode for now.
+ KERNCMDLINE="$KERNCMDLINE oprofile.timer=1"
+}
+
+config_qemumips() {
+ set_mem_size 256
+ case "$MACHINE" in
+ qemumips) QEMU=qemu-system-mips ;;
+ qemumipsel) QEMU=qemu-system-mipsel ;;
+ qemumips64) QEMU=qemu-system-mips64 ;;
+ esac
+ MACHINE_SUBTYPE=malta
+ QEMU_UI_OPTIONS="-vga cirrus $QEMU_UI_OPTIONS"
+ if [ "${FSTYPE:0:3}" = "ext" -o "$FSTYPE" = "btrfs" -o "$FSTYPE" = "wic" ]; then
+ #KERNCMDLINE="root=/dev/hda console=ttyS0 console=tty0 $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
+ KERNCMDLINE="root=$DROOT rw console=ttyS0 console=tty $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -M $MACHINE_SUBTYPE $ROOTFS_OPTIONS -no-reboot $QEMU_UI_OPTIONS"
+ fi
+ if [ "$FSTYPE" = "nfs" ]; then
+ if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then
+ echo "Error: NFS mount point $ROOTFS doesn't exist"
+ cleanup
+ return 1
+ fi
+ KERNCMDLINE="root=/dev/nfs console=ttyS0 console=tty nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -M $MACHINE_SUBTYPE -no-reboot $QEMU_UI_OPTIONS"
+ fi
+}
+
+config_qemuppc() {
+ set_mem_size 256
+ QEMU=qemu-system-ppc
+ MACHINE_SUBTYPE=mac99
+ CPU_SUBTYPE=G4
+ QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS"
+ if [ "$SLIRP_ENABLED" = "yes" ]; then
+ QEMU_NETWORK_CMD=""
+ else
+ QEMU_NETWORK_CMD="-net nic,model=pcnet $QEMU_TAP_CMD"
+ fi
+ if [ "${FSTYPE:0:3}" = "ext" -o "$FSTYPE" = "btrfs" -o "$FSTYPE" = "wic" ]; then
+ KERNCMDLINE="root=$DROOT rw console=ttyS0 console=tty $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE -M $MACHINE_SUBTYPE $ROOTFS_OPTIONS -no-reboot $QEMU_UI_OPTIONS"
+ fi
+ if [ "$FSTYPE" = "nfs" ]; then
+ if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then
+ echo "Error: NFS mount point $ROOTFS doesn't exist"
+ cleanup
+ return 1
+ fi
+ KERNCMDLINE="root=/dev/nfs console=ttyS0 console=tty nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE -M $MACHINE_SUBTYPE -no-reboot $QEMU_UI_OPTIONS"
+ fi
+}
+
+config_qemush4() {
+ set_mem_size 1024
+ QEMU=qemu-system-sh4
+ MACHINE_SUBTYPE=r2d
+ QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS"
+ if [ "${FSTYPE:0:3}" = "ext" -o "$FSTYPE" = "btrfs" -o "$FSTYPE" = "wic" ]; then
+ #KERNCMDLINE="root=/dev/hda console=ttyS0 console=tty0 $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
+ KERNCMDLINE="root=/dev/hda rw console=ttySC1 noiotrap earlyprintk=sh-sci.1 console=tty $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -M $MACHINE_SUBTYPE -hda $ROOTFS -no-reboot $QEMU_UI_OPTIONS -monitor null -serial vc -serial stdio"
+ SERIALSTDIO="1"
+ fi
+ if [ "$FSTYPE" = "nfs" ]; then
+ if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then
+ echo "Error: NFS mount point $ROOTFS doesn't exist"
+ cleanup
+ return 1
+ fi
+ KERNCMDLINE="root=/dev/nfs console=ttySC1 noiotrap earlyprintk=sh-sci.1 console=tty nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -M $MACHINE_SUBTYPE -no-reboot $QEMU_UI_OPTIONS -monitor null -serial vc -serial stdio"
+ SERIALSTDIO="1"
+ fi
+}
+
+config_qemuzynq() {
+ set_mem_size 1024
+ QEMU=qemu-system-arm
+ QEMU_NETWORK_CMD="-net nic -net nic $QEMU_TAP_CMD"
+ QEMU_SYSTEM_OPTIONS="$QEMU_NETWORK_CMD -M xilinx-zynq-a9 -serial null -serial mon:stdio -nographic -dtb $KERNEL-$MACHINE.dtb"
+ # zynq serial ports are named 'ttyPS0' and 'ttyPS1', fixup the default values
+ SCRIPT_KERNEL_OPT=$(echo "$SCRIPT_KERNEL_OPT" | sed 's/console=ttyS/console=ttyPS/g')
+ if [ "${FSTYPE:0:3}" = "ext" -o "${FSTYPE:0:4}" = "cpio" ]; then
+ KERNCMDLINE="earlyprintk root=/dev/ram rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
+ QEMUOPTIONS="$QEMU_SYSTEM_OPTIONS -initrd $ROOTFS"
+ fi
+}
+
+config_qemuzynqmp() {
+ set_mem_size 2048
+ QEMU=qemu-system-aarch64
+
+ export QEMU_AUDIO_DRV="none"
+ if [ "x$SERIALSTDIO" = "x" ] ; then
+ QEMU_UI_OPTIONS="-nographic"
+ else
+ QEMU_UI_OPTIONS=""
+ fi
+
+ # Networking and system options required for QEMU ZynqMP machine
+ QEMU_NETWORK_CMD="-net nic -net nic -net nic -net nic -net user,net=10.10.70.0,dhcpstart=10.10.70.1,host=10.10.70.101"
+ QEMU_SYSTEM_OPTIONS="$QEMU_NETWORK_CMD -M xlnx-ep108 -serial mon:stdio -dtb $DEPLOY_DIR_IMAGE/${QEMU_DTB}.dtb"
+
+ QEMUOPTIONS="$QEMU_SYSTEM_OPTIONS $QEMU_UI_OPTIONS -initrd $ROOTFS"
+}
+
+config_qemumicroblaze() {
+ set_mem_size 256
+ QEMU=qemu-system-microblazeel
+ QEMU_SYSTEM_OPTIONS="$QEMU_NETWORK_CMD -M petalogix-ml605 -serial mon:stdio"
+ if [ "${FSTYPE:0:3}" = "ext" -o "${FSTYPE:0:4}" = "cpio" ]; then
+ KERNCMDLINE="earlyprintk root=/dev/ram rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
+ QEMUOPTIONS="$QEMU_SYSTEM_OPTIONS -initrd $ROOTFS"
+ fi
+}
+
+case "$MACHINE" in
+ "qemuarm" | "qemuarmv6" | "qemuarmv7")
+ config_qemuarm
+ ;;
+ "qemuarm64")
+ config_qemuarm64
+ ;;
+ "qemux86")
+ config_qemux86
+ ;;
+ "qemux86-64")
+ config_qemux86_64
+ ;;
+ "qemumips" | "qemumipsel" | "qemumips64")
+ config_qemumips
+ ;;
+ "qemuppc")
+ config_qemuppc
+ ;;
+ "qemush4")
+ config_qemush4
+ ;;
+ "qemuzynq")
+ config_qemuzynq
+ ;;
+ "qemuzynqmp")
+ config_qemuzynqmp
+ ;;
+ "qemumicroblaze")
+ config_qemumicroblaze
+ ;;
+ *)
+ echo "Error: Unsupported machine type $MACHINE"
+ return 1
+ ;;
+esac
+
+# We need to specify -m <mem_size> to overcome a bug in qemu 0.14.0
+# https://bugs.launchpad.net/ubuntu/+source/qemu-kvm/+bug/584480
+if [ -z "$mem_set" ] ; then
+ SCRIPT_QEMU_EXTRA_OPT="$SCRIPT_QEMU_EXTRA_OPT -m $mem_size"
+fi
+
+if [ "${FSTYPE:0:3}" = "ext" ]; then
+ KERNCMDLINE="$KERNCMDLINE rootfstype=$FSTYPE"
+fi
+
+if [ "$FSTYPE" = "cpio.gz" ]; then
+ QEMUOPTIONS="-initrd $ROOTFS -nographic"
+ KERNCMDLINE="root=/dev/ram0 console=ttyS0 debugshell"
+fi
+
+if [ "$FSTYPE" = "iso" ]; then
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -cdrom $ROOTFS $QEMU_UI_OPTIONS"
+fi
+
+if [ "x$QEMUOPTIONS" = "x" ]; then
+ echo "Error: Unable to support this combination of options"
+ cleanup
+ return 1
+fi
+
+if [ "$TCPSERIAL_PORTNUM" != "" ]; then
+ if [ "$MACHINE" = "qemuarm64" ]; then
+ SCRIPT_QEMU_EXTRA_OPT="$SCRIPT_QEMU_EXTRA_OPT -device virtio-serial-device -chardev socket,id=virtcon,port=$TCPSERIAL_PORTNUM,host=127.0.0.1 -device virtconsole,chardev=virtcon"
+ else
+ SCRIPT_QEMU_EXTRA_OPT="$SCRIPT_QEMU_EXTRA_OPT -serial tcp:127.0.0.1:$TCPSERIAL_PORTNUM"
+ fi
+fi
+
+PATH=$OECORE_NATIVE_SYSROOT/usr/bin:$PATH
+
+QEMUBIN=`which $QEMU 2> /dev/null`
+if [ ! -x "$QEMUBIN" ]; then
+ echo "Error: No QEMU binary '$QEMU' could be found."
+ cleanup
+ return 1
+fi
+
+NEED_GL=`ldd $QEMUBIN/$QEMU 2>&1 | grep libGLU`
+# We can't run without a libGL.so
+if [ "$NEED_GL" != "" ]; then
+ libgl='no'
+
+ [ -e /usr/lib/libGL.so -a -e /usr/lib/libGLU.so ] && libgl='yes'
+ [ -e /usr/lib64/libGL.so -a -e /usr/lib64/libGLU.so ] && libgl='yes'
+ [ -e /usr/lib/*-linux-gnu/libGL.so -a -e /usr/lib/*-linux-gnu/libGLU.so ] && libgl='yes'
+
+ if [ "$libgl" != 'yes' ]; then
+ echo "You need libGL.so and libGLU.so to exist in your library path to run the QEMU emulator.
+ Ubuntu package names are: libgl1-mesa-dev and libglu1-mesa-dev.
+ Fedora package names are: mesa-libGL-devel mesa-libGLU-devel."
+ return 1;
+ fi
+fi
+
+do_quit() {
+ cleanup
+ return 1
+}
+
+trap do_quit INT TERM QUIT
+
+# qemu got segfault if linked with nVidia's libgl
+GL_LD_PRELOAD=$LD_PRELOAD
+
+if ldd $QEMUBIN | grep -i nvidia &> /dev/null
+then
+cat << EOM
+WARNING: nVidia proprietary OpenGL libraries detected.
+nVidia's OpenGL libraries are known to have compatibility issues with qemu,
+resulting in a segfault. Please uninstall these drivers or ensure the mesa libGL
+libraries precede nvidia's via LD_PRELOAD(Already do it on Ubuntu 10).
+EOM
+
+# Automatically use Ubuntu system's mesa libGL, other distro can add its own path
+if grep -i ubuntu /etc/lsb-release &> /dev/null
+then
+ # precede nvidia's driver on Ubuntu 10
+ UBUNTU_MAIN_VERSION=`cat /etc/lsb-release |grep DISTRIB_RELEASE |cut -d= -f 2| cut -d. -f 1`
+ if [ "$UBUNTU_MAIN_VERSION" = "10" ];
+ then
+ GL_PATH=""
+ if test -e /usr/lib/libGL.so
+ then
+ GL_PATH="/usr/lib/libGL.so"
+ elif test -e /usr/lib/x86_64-linux-gnu/libGL.so
+ then
+ GL_PATH="/usr/lib/x86_64-linux-gnu/libGL.so"
+ fi
+
+ echo "Skip nVidia's libGL on Ubuntu 10!"
+ GL_LD_PRELOAD="$GL_PATH $LD_PRELOAD"
+ fi
+fi
+fi
+
+if [ "x$SERIALSTDIO" = "x1" ]; then
+ echo "Interrupt character is '^]'"
+ stty intr ^]
+fi
+
+
+# Preserve the multiplexing behavior for the monitor that would be there based
+# on whether nographic is used.
+if echo "$QEMUOPTIONS $SERIALOPTS $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT" | grep -- "-nographic"; then
+ FIRST_SERIAL_OPT="-serial mon:stdio"
+else
+ FIRST_SERIAL_OPT="-serial mon:vc"
+fi
+
+# qemuarm64 uses virtio for any additional serial ports so the normal mechanism
+# of using -serial will not work
+if [ "$MACHINE" = "qemuarm64" ]; then
+ SECOND_SERIAL_OPT="-device virtio-serial-device -chardev null,id=virtcon -device virtconsole,chardev=virtcon"
+else
+ SECOND_SERIAL_OPT="-serial null"
+fi
+
+# We always want a ttyS1. Since qemu by default adds a serial port when
+# nodefaults is not specified, it seems that all that would be needed is to
+# make sure a "-serial" is there. However, it appears that when "-serial" is
+# specified, it ignores the default serial port that is normally added.
+# So here we make sure to add two -serial if there are none. And only one
+# if there is one -serial already.
+NUM_SERIAL_OPTS=`echo $QEMUOPTIONS $SERIALOPTS $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT | sed -e 's/ /\n/g' | grep --count -- -serial`
+
+if [ "$NUM_SERIAL_OPTS" = "0" ]; then
+ SCRIPT_QEMU_EXTRA_OPT="$SCRIPT_QEMU_EXTRA_OPT $FIRST_SERIAL_OPT $SECOND_SERIAL_OPT"
+elif [ "$NUM_SERIAL_OPTS" = "1" ]; then
+ SCRIPT_QEMU_EXTRA_OPT="$SCRIPT_QEMU_EXTRA_OPT $SECOND_SERIAL_OPT"
+fi
+
+echo "Running $QEMU..."
+# -no-reboot is a mandatory option - see bug #100
+if [ "$IS_VM" = "true" ]; then
+ # Check root=/dev/sdX or root=/dev/vdX
+ [ ! -e "$VM" ] && error "VM image is not found!"
+
+ case "$FORCE_DRIVE_IF" in
+ "ide")
+ echo "Using ide drive"
+ VM_DRIVE="$VM"
+ ;;
+ "scsi")
+ echo "Using scsi drive"
+ VM_DRIVE="-drive if=none,id=hd,file=$VM -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=hd"
+ ;;
+ "virtio")
+ echo "Using virtio block drive"
+ VM_DRIVE="-drive if=virtio,file=$VM"
+ ;;
+ "")
+ if grep -q 'root=/dev/sd' $VM; then
+ echo "Using scsi drive"
+ VM_DRIVE="-drive if=none,id=hd,file=$VM -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=hd"
+ elif grep -q 'root=/dev/hd' $VM; then
+ echo "Using ide drive"
+ VM_DRIVE="$VM"
+ else
+ echo "Using virtio block drive"
+ VM_DRIVE="-drive if=virtio,file=$VM"
+ fi
+ ;;
+ *)
+ error "Invalid drive interface: $FORCE_DRIVE_IF"
+ ;;
+ esac
+
+ QEMU_FIRE="$QEMUBIN $VM_DRIVE $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT"
+ echo $QEMU_FIRE
+ LD_PRELOAD="$GL_LD_PRELOAD" $QEMU_FIRE
+elif [ "$FSTYPE" = "iso" -o "$FSTYPE" = "wic" ]; then
+ QEMU_FIRE="$QEMUBIN $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT"
+ echo $QEMU_FIRE
+ LD_PRELOAD="$GL_LD_PRELOAD" $QEMU_FIRE
+else
+ QEMU_FIRE="$QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SLIRP_CMD $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT"
+ echo $QEMU_FIRE -append '"'$KERNCMDLINE $SCRIPT_KERNEL_OPT'"'
+ LD_PRELOAD="$GL_LD_PRELOAD" $QEMU_FIRE -append "$KERNCMDLINE $SCRIPT_KERNEL_OPT"
+fi
+ret=$?
+if [ "$SLIRP_ENABLED" != "yes" ]; then
+ cleanup
+fi
+
+#set the original stty values before exit
+stty ${ORIG_STTY}
+trap - INT TERM QUIT
+
+return $ret
diff --git a/meta-sota/scripts/runqemu.README b/meta-sota/scripts/runqemu.README
new file mode 100644
index 0000000..5908d83
--- /dev/null
+++ b/meta-sota/scripts/runqemu.README
@@ -0,0 +1,42 @@
+Using OE images with QEMU
+=========================
+
+OE-Core can generate qemu bootable kernels and images with can be used
+on a desktop system. The scripts currently support booting ARM, MIPS, PowerPC
+and x86 (32 and 64 bit) images. The scripts can be used within the OE build
+system or externaly.
+
+The runqemu script is run as:
+
+ runqemu <machine> <zimage> <filesystem>
+
+where:
+
+ <machine> is the machine/architecture to use (qemuarm/qemumips/qemuppc/qemux86/qemux86-64)
+ <zimage> is the path to a kernel (e.g. zimage-qemuarm.bin)
+ <filesystem> is the path to an ext2 image (e.g. filesystem-qemuarm.ext2) or an nfs directory
+
+If <machine> isn't specified, the script will try to detect the machine name
+from the name of the <zimage> file.
+
+If <filesystem> isn't specified, nfs booting will be assumed.
+
+When used within the build system, it will default to qemuarm, ext2 and the last kernel and
+core-image-sato-sdk image built by the build system. If an sdk image isn't present it will look
+for sato and minimal images.
+
+Full usage instructions can be seen by running the command with no options specified.
+
+
+Notes
+=====
+
+ - The scripts run qemu using sudo. Change perms on /dev/net/tun to
+ run as non root. The runqemu-gen-tapdevs script can also be used by
+ root to prepopulate the appropriate network devices.
+ - You can access the host computer at 192.168.7.1 within the image.
+ - Your qemu system will be accessible as 192.16.7.2.
+ - The script extracts the root filesystem specified under pseudo and sets up a userspace
+ NFS server to share the image over by default meaning the filesystem can be accessed by
+ both the host and guest systems.
+