aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/bitbake97
-rwxr-xr-x[-rw-r--r--]scripts/boot.scrbin338 -> 338 bytes
-rwxr-xr-x[-rw-r--r--]scripts/boot.txt4
-rwxr-xr-xscripts/create_img.sh147
-rwxr-xr-xscripts/create_img_vexpress-a9.sh117
-rwxr-xr-xscripts/dl_pkgs.sh49
-rwxr-xr-xscripts/oe-buildenv-internal73
-rwxr-xr-xscripts/oe-setup-builddir92
-rwxr-xr-xscripts/runqemu429
-rwxr-xr-xscripts/runqemu-internal641
-rwxr-xr-x[-rw-r--r--]scripts/uEnv.txt6
11 files changed, 1650 insertions, 5 deletions
diff --git a/scripts/bitbake b/scripts/bitbake
new file mode 100755
index 0000000..86d476a
--- /dev/null
+++ b/scripts/bitbake
@@ -0,0 +1,97 @@
+#!/bin/sh
+
+export BBFETCH2=True
+export BB_ENV_EXTRAWHITE="PSEUDO_BUILD PSEUDO_DISABLED $BB_ENV_EXTRAWHITE"
+
+NO_BUILD_OPTS="--version -h --help -p --parse-only -s --show-versions -e --environment -g --graphviz"
+needpseudo="1"
+for opt in $@; do
+for key in $NO_BUILD_OPTS; do
+ if [ $opt = $key ]
+ then
+ needpseudo="0"
+ break
+ fi
+done
+[ $needpseudo = "0" ] && break
+done
+
+# Make sure we're not using python v3.x. This check can't go into
+# sanity.bbclass because bitbake's source code doesn't even pass
+# parsing stage when used with python v3, so we catch it here so we
+# can offer a meaningful error message.
+py_v3_check=`/usr/bin/env python --version 2>&1 | grep "Python 3"`
+if [ "$py_v3_check" != "" ]; then
+ echo "Bitbake is not compatible with python v3"
+ echo "Please set up python v2 as your default python interpreter"
+ exit 1
+fi
+
+# Similarly, we now have code that doesn't parse correctly with older
+# versions of Python, and rather than fixing that and be eternally
+# vigilant for any other new feature use, just check the version here.
+py_v26_check=`python -c 'import sys; print sys.version_info >= (2,6,0)'`
+if [ "$py_v26_check" != "True" ]; then
+ echo "BitBake requires Python 2.6 or later"
+ exit 1
+fi
+
+needtar="1"
+TARVERSION=`tar --version | head -n 1 | cut -d ' ' -f 4`
+float_test() {
+ echo | awk 'END { exit ( !( '"$1"')); }'
+}
+
+# Tar version 1.24 and onwards handle symlinks in sstate packages correctly
+# but earlier versions do not
+float_test "$TARVERSION > 1.23" && needtar="0"
+
+buildpseudo="1"
+if [ $needpseudo = "1" ] && [ -e "$BUILDDIR/pseudodone" ]; then
+ PSEUDOBINDIR=`cat $BUILDDIR/pseudodone`
+ if [ -e "$PSEUDOBINDIR/pseudo" -a -e "$PSEUDOBINDIR/tar" -a "$needtar" = "1" ]; then
+ buildpseudo="0"
+ fi
+ if [ -e "$PSEUDOBINDIR/pseudo" -a $needtar = "0" ]; then
+ buildpseudo="0"
+ fi
+fi
+if [ $needpseudo = "0" ]; then
+ buildpseudo="0"
+fi
+
+OLDPATH=$PATH
+export PATH=`echo $PATH | sed s#.*/poky/scripts:##`
+if [ $buildpseudo = "1" ]; then
+ echo "Pseudo is not present but is required, building this first before the main build"
+ export PSEUDO_BUILD=1
+ TARTARGET="tar-replacement-native"
+ if [ $needtar = "0" ]; then
+ TARTARGET=""
+ fi
+ bitbake pseudo-native $TARTARGET -c populate_sysroot
+ ret=$?
+ if [ "$ret" != "0" ]; then
+ exit 1
+ fi
+ PSEUDOBINDIR=`bitbake -e | grep STAGING_BINDIR_NATIVE=\" | cut -d '=' -f2 | cut -d '"' -f2`
+ ret=$?
+ if [ "$ret" != "0" ]; then
+ exit 1
+ fi
+ echo $PSEUDOBINDIR > $BUILDDIR/pseudodone
+ # This needs to exist in case pseudo has to log somewhere
+ mkdir -p $PSEUDOBINDIR/../../var/pseudo
+fi
+BITBAKE=`which bitbake`
+export PATH=$OLDPATH
+if [ $needpseudo = "1" ]; then
+ export PSEUDO_BUILD=2
+ PSEUDOBINDIR=`cat $BUILDDIR/pseudodone`
+ PSEUDO_BINDIR=$PSEUDOBINDIR PSEUDO_LIBDIR=$PSEUDOBINDIR/../lib/pseudo/lib PSEUDO_PREFIX=$PSEUDOBINDIR/../../ PSEUDO_DISABLED=1 $PSEUDOBINDIR/pseudo $BITBAKE $@
+else
+ export PSEUDO_BUILD=0
+ $BITBAKE $@
+fi
+ret=$?
+exit $ret
diff --git a/scripts/boot.scr b/scripts/boot.scr
index fc109d7..fc109d7 100644..100755
--- a/scripts/boot.scr
+++ b/scripts/boot.scr
Binary files differ
diff --git a/scripts/boot.txt b/scripts/boot.txt
index 8874bec..0105e84 100644..100755
--- a/scripts/boot.txt
+++ b/scripts/boot.txt
@@ -1,3 +1,3 @@
-setenv bootcmd "fatload mmc 0:1 0x80000000 uImage; bootm 0x80000000"
-setenv bootargs "console=tty0 console=ttyO2,115200n8 mpurate=auto vram=12M omapfb.mode=dvi:1024x768MR-16@60 omapfb.debug=y omapdss.def_disp=dvi root=/dev/mmcblk0p2 rw rootfstype=ext3 rootwait"
+setenv bootcmd "fatload mmc 0:1 0x80000000 uImage; bootm 0x80000000"
+setenv bootargs "console=tty0 console=ttyO2,115200n8 mpurate=auto vram=12M omapfb.mode=dvi:1024x768MR-16@60 omapfb.debug=y omapdss.def_disp=dvi root=/dev/mmcblk0p2 rw rootfstype=ext3 rootwait"
boot \ No newline at end of file
diff --git a/scripts/create_img.sh b/scripts/create_img.sh
new file mode 100755
index 0000000..395015e
--- /dev/null
+++ b/scripts/create_img.sh
@@ -0,0 +1,147 @@
+#!/bin/bash
+
+# This script generates SD card disk images suitable for use with QEMU.
+#
+# Copyright (C) 2011 Ash Charles
+# Based on:
+# Narcissus - Online image builder for the angstrom distribution
+# Copyright (C) 2008 - 2011 Koen Kooi
+# Copyright (C) 2010 Denys Dmytriyenko
+# and
+# Linaro Images Tools.
+# Author: Guilherme Salgado <guilherme.salgado@linaro.org>
+#
+# 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.
+
+LC_ALL=C
+set -e
+
+function usage()
+{
+ echo "This utility generates SD card images suitable for use with QEMU."
+ echo "Usage:"
+ echo " $0 <output name> <mlo> <u-boot> <kernel> <rootfs>"
+ echo "Example:"
+ echo " $0 sd.img ~/MLO ~/u-boot.bin ~/uImage ~/rootfs.tar.bz2"
+}
+
+function check_args()
+{
+ if [ $# -ne 9 ]; then
+ usage
+ exit 1
+ fi
+ OUTFILE=$1
+ MLO=$2
+ UBOOT=$3
+ KERNEL=$4
+ ROOTFS=$5
+ QEMU_IMG=$6
+ UENVTXT=$7
+ BOOTTXT=$8
+ BOOTSCR=$9
+
+ if ! [[ -e ${MLO} ]]; then
+ echo "MLO not found at ${MLO}! Quitting..."
+ exit 1
+ fi
+ if ! [[ -e ${UBOOT} ]]; then
+ echo "U-boot not found at ${UBOOT}! Quitting..."
+ exit 1
+ fi
+ if ! [[ -e ${KERNEL} ]]; then
+ echo "Kernel not found at ${KERNEL}! Quitting..."
+ exit 1
+ fi
+ if ! [[ -e ${ROOTFS} ]]; then
+ echo "Rootfs not found at ${ROOTFS}! Quitting..."
+ exit 1
+ fi
+ if ! [[ -e ${QEMU_IMG} ]]; then
+ echo "Qemu-img not found at ${QEMU_IMG}! Quitting..."
+ exit 1
+ fi
+ if ! [[ -e ${UENVTXT} ]]; then
+ echo "UENVTXT not found at ${UENVTXT}! Quitting..."
+ exit 1
+ fi
+ if ! [[ -e ${BOOTTXT} ]]; then
+ echo "BOOTTXT not found at ${BOOTTXT}! Quitting..."
+ exit 1
+ fi
+ if ! [[ -e ${BOOTSCR} ]]; then
+ echo "BOOTSCR not found at ${BOOTSCR}! Quitting..."
+ exit 1
+ fi
+}
+
+SIZE=1073741824 # 1G by default
+
+function make_image()
+{
+ $QEMU_IMG create -f raw ${OUTFILE} ${SIZE}
+
+ CYLINDERS=`echo ${SIZE}/255/63/512 | bc`
+ {
+ echo ,9,0x0C,*
+ echo ,,,-
+ } | sfdisk -D -H 255 -S 63 -C ${CYLINDERS} ${OUTFILE} &> /dev/null
+
+ # Reverse-engineer the partition setup
+ BYTES_PER_SECTOR="$(/sbin/fdisk -l -u ${OUTFILE} | grep Units | awk '{print $9}')"
+ VFAT_SECTOR_OFFSET="$(/sbin/fdisk -l -u ${OUTFILE} | grep FAT32 | awk '{print $3}')"
+ EXT3_SECTOR_OFFSET="$(/sbin/fdisk -l -u ${OUTFILE} | grep Linux | awk '{print $2}')"
+}
+
+
+
+function populate_image()
+{
+ LOOP_DEV="/dev/loop1"
+ LOOP_DEV_FS="/dev/loop2"
+
+ echo "[ Format vfat partition ]"
+ sudo /sbin/losetup -v -o $(expr ${BYTES_PER_SECTOR} "*" ${VFAT_SECTOR_OFFSET}) ${LOOP_DEV} ${OUTFILE}
+ sudo mkfs.vfat -F 32 -n "boot" ${LOOP_DEV}
+
+ echo "[ Format ext3 partition ]"
+ sudo /sbin/losetup -v -o $(expr ${BYTES_PER_SECTOR} "*" ${EXT3_SECTOR_OFFSET}) ${LOOP_DEV_FS} ${OUTFILE}
+ sudo /sbin/mkfs.ext3 -L rootfs ${LOOP_DEV_FS}
+
+ echo "[ Copying files to vfat ]"
+ sudo mount ${LOOP_DEV} /mnt
+ sudo cp -v ${MLO} /mnt/MLO
+ sudo cp -v ${UBOOT} /mnt/u-boot.bin
+ sudo cp -v ${KERNEL} /mnt/uImage
+ sudo cp -v ${UENVTXT} /mnt/uEnv.txt
+ sudo cp -v ${BOOTTXT} /mnt/boot.txt
+ sudo cp -v ${BOOTSCR} /mnt/boot.scr
+ sudo sync
+ sudo umount ${LOOP_DEV}
+
+ echo "[ Copying file system ]"
+ sudo mount ${LOOP_DEV_FS} /mnt
+ sudo tar xaf ${ROOTFS} -C /mnt
+ sudo sync
+ sudo umount ${LOOP_DEV_FS}
+
+ echo "[ Clean up ]"
+ sudo /sbin/losetup -d ${LOOP_DEV}
+ sudo /sbin/losetup -d ${LOOP_DEV_FS}
+}
+
+ARGS=$*
+check_args $ARGS
+make_image
+populate_image
diff --git a/scripts/create_img_vexpress-a9.sh b/scripts/create_img_vexpress-a9.sh
new file mode 100755
index 0000000..128b08d
--- /dev/null
+++ b/scripts/create_img_vexpress-a9.sh
@@ -0,0 +1,117 @@
+#!/bin/bash
+
+# This script generates SD card disk images suitable for use with QEMU.
+#
+# Copyright (C) 2011 Ash Charles
+# Based on:
+# Narcissus - Online image builder for the angstrom distribution
+# Copyright (C) 2008 - 2011 Koen Kooi
+# Copyright (C) 2010 Denys Dmytriyenko
+# and
+# Linaro Images Tools.
+# Author: Guilherme Salgado <guilherme.salgado@linaro.org>
+#
+# 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.
+
+LC_ALL=C
+set -e
+
+function usage()
+{
+ echo "This utility generates SD card images suitable for use with QEMU."
+ echo "Usage:"
+ echo " $0 <output name> <mlo> <u-boot> <kernel> <rootfs>"
+ echo "Example:"
+ echo " $0 sd.img ~/MLO ~/u-boot.bin ~/uImage ~/rootfs.tar.bz2"
+}
+
+function check_args()
+{
+ if [ $# -ne 4 ]; then
+ usage
+ exit 1
+ fi
+ OUTFILE=$1
+ KERNEL=$2
+ ROOTFS=$3
+ QEMU_IMG=$4
+
+ if ! [[ -e ${KERNEL} ]]; then
+ echo "Kernel not found at ${KERNEL}! Quitting..."
+ exit 1
+ fi
+ if ! [[ -e ${ROOTFS} ]]; then
+ echo "Rootfs not found at ${ROOTFS}! Quitting..."
+ exit 1
+ fi
+ if ! [[ -e ${QEMU_IMG} ]]; then
+ echo "Qemu-img not found at ${QEMU_IMG}! Quitting..."
+ exit 1
+ fi
+}
+
+SIZE=1073741824 # 1G by default
+
+function make_image()
+{
+ $QEMU_IMG create -f raw ${OUTFILE} ${SIZE}
+
+ CYLINDERS=`echo ${SIZE}/255/63/512 | bc`
+ {
+ echo ,9,0x0C,*
+ echo ,,,-
+ } | sfdisk -D -H 255 -S 63 -C ${CYLINDERS} ${OUTFILE} &> /dev/null
+
+ # Reverse-engineer the partition setup
+ BYTES_PER_SECTOR="$(/sbin/fdisk -l -u ${OUTFILE} | grep Units | awk '{print $9}')"
+ VFAT_SECTOR_OFFSET="$(/sbin/fdisk -l -u ${OUTFILE} | grep FAT32 | awk '{print $3}')"
+ EXT3_SECTOR_OFFSET="$(/sbin/fdisk -l -u ${OUTFILE} | grep Linux | awk '{print $2}')"
+}
+
+
+
+function populate_image()
+{
+ LOOP_DEV="/dev/loop1"
+ LOOP_DEV_FS="/dev/loop2"
+
+ echo "[ Format vfat partition ]"
+ sudo /sbin/losetup -v -o $(expr ${BYTES_PER_SECTOR} "*" ${VFAT_SECTOR_OFFSET}) ${LOOP_DEV} ${OUTFILE}
+ sudo mkfs.vfat -F 32 -n "boot" ${LOOP_DEV} > /dev/null
+
+ echo "[ Format ext3 partition ]"
+ sudo /sbin/losetup -v -o $(expr ${BYTES_PER_SECTOR} "*" ${EXT3_SECTOR_OFFSET}) ${LOOP_DEV_FS} ${OUTFILE}
+ sudo /sbin/mkfs.ext3 -L rootfs ${LOOP_DEV_FS} > /dev/null
+
+ echo "[ Copying files to vfat ]"
+ sudo mount ${LOOP_DEV} /mnt
+ sudo cp -v ${KERNEL} /mnt/uImage
+ sudo sync
+ sudo umount ${LOOP_DEV}
+
+ echo "[ Copying file system ]"
+ sudo mount ${LOOP_DEV_FS} /mnt
+ sudo tar xaf ${ROOTFS} -C /mnt
+ sudo sync
+ sudo umount ${LOOP_DEV_FS}
+
+ echo "[ Clean up ]"
+ sudo /sbin/losetup -d ${LOOP_DEV}
+ sudo /sbin/losetup -d ${LOOP_DEV_FS}
+}
+
+ARGS=$*
+check_args $ARGS
+make_image
+populate_image
diff --git a/scripts/dl_pkgs.sh b/scripts/dl_pkgs.sh
new file mode 100755
index 0000000..c06dbdc
--- /dev/null
+++ b/scripts/dl_pkgs.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+# Copyright (c) 2012, Wind River Systems, Inc.
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+GIT_PACKAGES=(layer-management DLT-daemon AudioManager)
+GIT_URLS=(https://git.genivi.org/srv/git/layer_management https://git.genivi.org/srv/git/DLT-daemon https://git.genivi.org/srv/git/AudioManager)
+
+
+echo -e "\nCreating download directory ..."
+mkdir -p ../downloads/git2
+
+echo -e "\nDownloading GENIVI packages ..."
+
+#Download GIT Packages
+for index in ${!GIT_PACKAGES[*]}
+do
+ echo -e "\nPACKAGE ${GIT_PACKAGES[$index]}"
+ URLS2=${GIT_URLS[$index]/https:\/\/}
+ URLS2=${URLS2//\//.}
+ if [ ! -f downloads/${URLS2}.done ]
+ then
+ rm -rf downloads/git2/${URLS2}
+ git clone -q --bare ${GIT_URLS[$index]} downloads/git2/${URLS2}
+ if [ $? == 0 ]
+ then
+ touch downloads/${URLS2}.done
+ fi
+ else
+ echo "${GIT_PACKAGES[$index]} already downloaded"
+ fi
+done
diff --git a/scripts/oe-buildenv-internal b/scripts/oe-buildenv-internal
new file mode 100755
index 0000000..af8fbf5
--- /dev/null
+++ b/scripts/oe-buildenv-internal
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+# OE-Core Build Enviroment Setup 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 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
+
+# It is assumed OEROOT is already defined when this is called
+if [ -z "$OEROOT" ]; then
+ echo >&2 "Error: OEROOT is not defined!"
+ return 1
+fi
+
+if [ "x$BDIR" = "x" ]; then
+ if [ "x$1" = "x" ]; then
+ BDIR="build"
+ else
+ BDIR="$1"
+ if [ "$BDIR" = "/" ]; then
+ echo >&2 "Error: / is not supported as a build directory."
+ return 1
+ fi
+
+ # Remove any possible trailing slashes. This is used to work around
+ # buggy readlink in Ubuntu 10.04 that doesn't ignore trailing slashes
+ # and hence "readlink -f new_dir_to_be_created/" returns empty.
+ BDIR=`echo $BDIR | sed -re 's|/+$||'`
+
+ BDIR=`readlink -f "$BDIR"`
+ if [ -z "$BDIR" ]; then
+ PARENTDIR=`dirname "$1"`
+ echo >&2 "Error: the directory $PARENTDIR does not exist?"
+ return 1
+ fi
+ fi
+fi
+if expr "$BDIR" : '/.*' > /dev/null ; then
+ BUILDDIR="$BDIR"
+else
+ BUILDDIR="`pwd`/$BDIR"
+fi
+unset BDIR
+
+BITBAKEDIR="$OEROOT/poky/bitbake$BBEXTRA/"
+
+BITBAKEDIR=`readlink -f "$BITBAKEDIR"`
+BUILDDIR=`readlink -f "$BUILDDIR"`
+
+if ! (test -d "$BITBAKEDIR"); then
+ echo >&2 "Error: The bitbake directory ($BITBAKEDIR) does not exist! Please ensure a copy of bitbake exists at this location"
+ return 1
+fi
+
+PATH="${OEROOT}/scripts:${OEROOT}/poky/scripts:$BITBAKEDIR/bin/:$PATH"
+unset BITBAKEDIR
+
+# Used by the runqemu script
+export BUILDDIR
+export PATH
+export BB_ENV_EXTRAWHITE="MACHINE DISTRO TCMODE TCLIBC http_proxy ftp_proxy https_proxy all_proxy ALL_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY SDKMACHINE BB_NUMBER_THREADS PARALLEL_MAKE GIT_PROXY_COMMAND GIT_PROXY_IGNORE SOCKS5_PASSWD SOCKS5_USER"
diff --git a/scripts/oe-setup-builddir b/scripts/oe-setup-builddir
new file mode 100755
index 0000000..b472f8c
--- /dev/null
+++ b/scripts/oe-setup-builddir
@@ -0,0 +1,92 @@
+#!/bin/sh
+
+# OE Build Enviroment Setup 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 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
+
+if [ -z "$BUILDDIR" ]; then
+ echo >&2 "Error: The build directory (BUILDDIR) must be set!"
+ exit 1
+fi
+
+mkdir -p $BUILDDIR/conf
+
+if ! (test -d "$BUILDDIR"); then
+ echo >&2 "Error: The builddir ($BUILDDIR) does not exist!"
+ exit 1
+fi
+
+if ! (test -w "$BUILDDIR"); then
+ echo >&2 "Error: Cannot write to $BUILDDIR, perhaps try sourcing with a writable path? i.e. . oe-init-build-env ~/my-build"
+ exit 1
+fi
+
+cd "$BUILDDIR"
+
+TEMPLATECONF=${TEMPLATECONF:conf}
+
+#
+# $TEMPLATECONF can point to a directory for the template local.conf & bblayers.conf
+#
+if [ "x" != "x$TEMPLATECONF" ]; then
+ if ! (test -d "$TEMPLATECONF"); then
+ # Allow TEMPLATECONF=meta-xyz/conf as a shortcut
+ if [ -d "$OEROOT/$TEMPLATECONF" ]; then
+ TEMPLATECONF="$OEROOT/$TEMPLATECONF"
+ fi
+ if ! (test -d "$TEMPLATECONF"); then
+ echo >&2 "Error: '$TEMPLATECONF' must be a directory containing local.conf & bblayers.conf"
+ return
+ fi
+ fi
+ OECORELAYERCONF="$TEMPLATECONF/bblayers.conf.sample"
+ OECORELOCALCONF="$TEMPLATECONF/local.conf.sample"
+fi
+
+if [ "x" = "x$OECORELOCALCONF" ]; then
+ OECORELOCALCONF="$OEROOT/conf/local.conf.sample"
+fi
+if ! (test -r "$BUILDDIR/conf/local.conf"); then
+cat <<EOM
+Default conf/local.conf file created.
+EOM
+ cp -f $OECORELOCALCONF $BUILDDIR/conf/local.conf
+fi
+
+if [ "x" = "x$OECORELAYERCONF" ]; then
+ OECORELAYERCONF="$OEROOT/conf/bblayers.conf.sample"
+fi
+if ! (test -r "$BUILDDIR/conf/bblayers.conf"); then
+cat <<EOM
+Default conf/bblayers.conf file created.
+EOM
+
+ # Put the abosolute path to the layers in bblayers.conf so we can run
+ # bitbake without the init script after the first run
+ sed "s|##COREBASE##|$OEROOT|g" $OECORELAYERCONF > $BUILDDIR/conf/bblayers.conf
+fi
+
+# Prevent disturbing a new GIT clone in same console
+unset OECORELOCALCONF
+unset OECORELAYERCONF
+
+cat <<EOM
+
+1. You can now run 'bitbake discovery-image'
+2. You can also run generated qemu images with a command like 'runqemu discovery-image vexpressa9'
+
+EOM
diff --git a/scripts/runqemu b/scripts/runqemu
new file mode 100755
index 0000000..bc4ba00
--- /dev/null
+++ b/scripts/runqemu
@@ -0,0 +1,429 @@
+#!/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`
+ echo ""
+ echo "Usage: you can run this script with any valid combination"
+ echo "of the following options (in any order):"
+ echo " QEMUARCH - the qemu machine architecture to use"
+ echo " KERNEL - the kernel image file to use"
+ echo " ROOTFS - the rootfs image file or nfsroot directory to use"
+ echo " MACHINE=xyz - the machine name (optional, autodetected from KERNEL filename if unspecified)"
+ echo " Simplified QEMU command-line options can be passed with:"
+ echo " nographic - disables video console"
+ echo " serial - enables a serial console on /dev/ttyS0"
+ echo " kvm - enables KVM when running qemux86/qemux86-64 (VT-capable CPU required)"
+ echo " qemuparams=\"xyz\" - specify custom parameters to QEMU"
+ echo " bootparams=\"xyz\" - specify custom kernel parameters during boot"
+ echo ""
+ echo "Examples:"
+ echo " $MYNAME qemuarm"
+ echo " $MYNAME qemux86-64 core-image-sato ext3"
+ echo " $MYNAME path/to/bzImage-qemux86.bin path/to/nfsrootdir/ serial"
+ echo " $MYNAME qemux86 qemuparams=\"-m 256\""
+ echo " $MYNAME qemux86 bootparams=\"psplash=false\""
+ exit 1
+}
+
+if [ "x$1" = "x" ]; then
+ usage
+fi
+
+MACHINE=${MACHINE:=""}
+KERNEL=""
+FSTYPE=""
+ROOTFS=""
+LAZY_ROOTFS=""
+SCRIPT_QEMU_OPT=""
+SCRIPT_QEMU_EXTRA_OPT=""
+SCRIPT_KERNEL_OPT=""
+
+# Don't use TMPDIR from the external environment, it may be a distro
+# variable pointing to /tmp (e.g. within X on OpenSUSE)
+# Instead, use OE_TMPDIR for passing this in externally.
+TMPDIR="$OE_TMPDIR"
+
+# 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 }'`
+ # A file ending in .bin is a kernel
+ if [ "x$EXT" = "xbin" ]; then
+ if [ -z "$KERNEL" ]; then
+ KERNEL=$filename
+ else
+ echo "Error: conflicting KERNEL args [$KERNEL] and [$filename]"
+ usage
+ fi
+ elif [[ "x$EXT" == "xext2" || "x$EXT" == "xext3" ||
+ "x$EXT" == "xjffs2" || "x$EXT" == "xbtrfs" ]]; then
+ # A file ending in a supportted fs type is a rootfs image
+ if [[ -z "$FSTYPE" || "$FSTYPE" == "$EXT" ]]; then
+ FSTYPE=$EXT
+ ROOTFS=$filename
+ else
+ echo "Error: conflicting FSTYPE types [$FSTYPE] and [$EXT]"
+ usage
+ fi
+ else
+ echo "Error: unknown file arg [$filename]"
+ usage
+ fi
+}
+
+# Parse command line args without requiring specific ordering. It's a
+# bit more complex, but offers a great user experience.
+KVM_ENABLED="no"
+i=1
+while [ $i -le $# ]; do
+ arg=${!i}
+ case $arg in
+ "qemux86" | "qemux86-64" | "qemuarm" | "qemumips" | "qemuppc" | "beagleboard" | "vexpressa9")
+ if [ -z "$MACHINE" ]; then
+ MACHINE=$arg
+ else
+ echo "Error: conflicting MACHINE types [$MACHINE] and [$arg]"
+ usage
+ fi
+ ;;
+ "ext2" | "ext3" | "jffs2" | "nfs" | "btrfs")
+ if [[ -z "$FSTYPE" || "$FSTYPE" == "$arg" ]]; then
+ FSTYPE=$arg
+ else
+ echo "Error: conflicting FSTYPE types [$FSTYPE] and [$arg]"
+ usage
+ fi
+ ;;
+ *-image*)
+ if [ -z "$ROOTFS" ]; then
+ 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
+ else
+ echo "Error: conflicting ROOTFS args [$ROOTFS] and [$arg]"
+ usage
+ fi
+ ;;
+ "nographic")
+ SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -nographic"
+ ;;
+ "serial")
+ SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -serial stdio"
+ SCRIPT_KERNEL_OPT="$SCRIPT_KERNEL_OPT console=ttyS0"
+ ;;
+ "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\)'`
+ if [[ ! -z "$serial_option" || ! -z "$kvm_option" ]]; then
+ echo "Error: Please use simplified serial or kvm options instead"
+ usage
+ fi
+ ;;
+ "bootparams="*)
+ SCRIPT_KERNEL_OPT="$SCRIPT_KERNEL_OPT ${arg##bootparams=}"
+ ;;
+ "audio")
+ if [[ "x$MACHINE" == "xqemux86" || "x$MACHINE" == "xqemux86-64" ]]; then
+ echo "Enable audio on qemu. Pls. 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 'vmx\|smx' /proc/cpuinfo`
+ ;;
+ *)
+ # A directory name is an nfs rootfs
+ if [ -d "$arg" ]; then
+ echo "Assuming $arg is an nfs rootfs"
+ if [[ -z "$FSTYPE" || "$FSTYPE" == "nfs" ]]; then
+ FSTYPE=nfs
+ else
+ echo "Error: conflicting FSTYPE types [$arg] and nfs"
+ usage
+ fi
+
+ if [ -z "$ROOTFS" ]; then
+ ROOTFS=$arg
+ else
+ echo "Error: conflicting ROOTFS args [$ROOTFS] and [$arg]"
+ usage
+ fi
+ elif [ -f "$arg" ]; then
+ process_filename $arg
+ else
+ echo "Error: unable to classify arg [$arg]"
+ usage
+ fi
+ ;;
+ esac
+ i=$((i + 1))
+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
+
+YOCTO_KVM_WIKI="https://wiki.yoctoproject.org/wiki/How_to_enable_KVM_for_Poky_qemu"
+# Detect KVM configuration
+if [[ "x$KVM_ENABLED" == "xyes" ]]; then
+ if [[ -z "$KVM_CAPABLE" ]]; then
+ echo "You are tring to enable KVM on cpu without VT support. Remove kvm from the command-line, or refer";
+ echo "$YOCTO_KVM_WIKI";
+ exit 1;
+ fi
+ if [[ "x$MACHINE" != "xqemux86" && "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? Pls. refer";
+ echo "$YOCTO_KVM_WIKI";
+ exit 1;
+ fi
+ if 9<>/dev/kvm ; then
+ SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm"
+ else
+ echo "You have no rights on /dev/kvm. Pls. change the owndership as described at";
+ echo "$YOCTO_KVM_WIKI";
+ exit 1;
+ fi
+fi
+
+# Report errors for missing combinations of options
+if [[ -z "$MACHINE" && -z "$KERNEL" ]]; then
+ echo "Error: you must specify at least a MACHINE or KERNEL argument"
+ usage
+fi
+if [[ "$FSTYPE" == "nfs" && -z "$ROOTFS" ]]; then
+ echo "Error: NFS booting without an explicit ROOTFS path is not yet supported"
+ usage
+fi
+
+if [ -z "$MACHINE" ]; then
+ MACHINE=`basename $KERNEL | sed 's/.*-\(qemux86-64\|qemux86\|qemuarm\|qemumips\|qemuppc\).*/\1/'`
+ if [ -z "$MACHINE" ]; then
+ echo "Error: Unable to set MACHINE from kernel filename [$KERNEL]"
+ usage
+ fi
+ echo "Set MACHINE to [$MACHINE] based on kernel [$KERNEL]"
+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=ext3
+
+QEMUX86_64_DEFAULT_KERNEL=bzImage-qemux86-64.bin
+QEMUX86_64_DEFAULT_FSTYPE=ext3
+
+QEMUARM_DEFAULT_KERNEL=zImage-qemuarm.bin
+QEMUARM_DEFAULT_FSTYPE=ext3
+
+BEAGLEBOARD_DEFAULT_KERNEL=uImage-beagleboard.bin
+BEAGLEBOARD_DEFAULT_FSTYPE=tar.bz2
+
+VEXPRESSA9_DEFAULT_KERNEL=uImage-vexpressa9.bin
+VEXPRESSA9_DEFAULT_FSTYPE=tar.bz2
+
+QEMUMIPS_DEFAULT_KERNEL=vmlinux-qemumips.bin
+QEMUMIPS_DEFAULT_FSTYPE=ext3
+
+QEMUPPC_DEFAULT_KERNEL=zImage-qemuppc.bin
+QEMUPPC_DEFAULT_FSTYPE=ext3
+
+AKITA_DEFAULT_KERNEL=zImage-akita.bin
+AKITA_DEFAULT_FSTYPE=jffs2
+
+SPITZ_DEFAULT_KERNEL=zImage-spitz.bin
+SPITZ_DEFAULT_FSTYPE=ext3
+
+setup_tmpdir() {
+ if [ -z "$TMPDIR" ]; then
+ # Try to get TMPDIR 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 TMPDIR from bitbake
+ TMPDIR=`bitbake -e | grep ^TMPDIR=\" | cut -d '=' -f2 | cut -d '"' -f2`
+ if [ -z "$TMPDIR" ]; then
+ echo "Error: this script needs to be run from your build directory,"
+ echo "or you need to explicitly set TMPDIR in your environment"
+ exit 1
+ fi
+ 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_tmpdir
+ BUILD_ARCH=`uname -m`
+ BUILD_OS=`uname | tr '[A-Z]' '[a-z]'`
+ BUILD_SYS="$BUILD_ARCH-$BUILD_OS"
+
+ OECORE_NATIVE_SYSROOT=$TMPDIR/sysroots/$BUILD_SYS
+ 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.
+ filenames=`ls -t $where/*-image*$machine.$extension 2>/dev/null | xargs`
+ for name in $filenames; do
+ if [[ "$name" =~ core-image-sato-sdk ||
+ "$name" =~ core-image-sato ||
+ "$name" =~ core-image-lsb ||
+ "$name" =~ core-image-basic ||
+ "$name" =~ core-image-minimal ]]; then
+ ROOTFS=$name
+ return
+ fi
+ done
+
+ echo "Couldn't find a $machine rootfs image in $where."
+ exit 1
+}
+
+if [[ -e "$ROOTFS" && -z "$FSTYPE" ]]; then
+ # Extract the filename extension
+ EXT=`echo $ROOTFS | awk -F . '{ print \$NF }'`
+ if [[ "x$EXT" == "xext2" || "x$EXT" == "xext3" ||
+ "x$EXT" == "xjffs2" || "x$EXT" == "xbtrfs" ]]; 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" ]; then
+ setup_tmpdir
+ eval kernel_file=\$${machine2}_DEFAULT_KERNEL
+ KERNEL=$TMPDIR/deploy/images/$kernel_file
+
+ if [ -z "$KERNEL" ]; then
+ echo "Error: Unable to determine default kernel for MACHINE [$MACHINE]"
+ usage
+ fi
+fi
+# KERNEL is now set for all cases
+
+if [ -z "$FSTYPE" ]; then
+ eval FSTYPE=\$${machine2}_DEFAULT_FSTYPE
+
+ if [ -z "$FSTYPE" ]; then
+ echo "Error: Unable to determine default fstype for MACHINE [$MACHINE]"
+ usage
+ fi
+fi
+
+if [ "$FSTYPE" = "nfs" -a "$MACHINE" = "qemuppc" ]; then
+ echo "Error: usermode NFS boot is not available for qemuppc."
+ exit 1
+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_tmpdir
+ echo "Assuming $ROOTFS really means $TMPDIR/deploy/images/$ROOTFS-$MACHINE.$FSTYPE"
+ IMGNAME=$TMPDIR/deploy/images/$ROOTFS-$MACHINE.img
+ ROOTFS=$TMPDIR/deploy/images/$ROOTFS-$MACHINE.$FSTYPE
+ MLO=$TMPDIR/deploy/images/MLO-$MACHINE
+ UBOOT=$TMPDIR/deploy/images/u-boot-$MACHINE.bin
+fi
+
+if [ -z "$ROOTFS" ]; then
+ setup_tmpdir
+ T=$TMPDIR/deploy/images
+ eval rootfs_list=\$${machine2}_DEFAULT_ROOTFS
+ findimage $T $MACHINE $FSTYPE
+
+ if [ -z "$ROOTFS" ]; then
+ echo "Error: Unable to determine default rootfs for MACHINE [$MACHINE]"
+ usage
+ fi
+fi
+# ROOTFS is now set for all cases
+
+echo ""
+echo "Continuing with the following parameters:"
+echo "KERNEL: [$KERNEL]"
+echo "ROOTFS: [$ROOTFS]"
+echo "FSTYPE: [$FSTYPE]"
+
+setup_sysroot
+# OECORE_NATIVE_SYSROOT is now set for all cases
+
+# We can't run without a libGL.so
+libgl='no'
+
+test -e /usr/lib/libGL.so -a -e /usr/lib/libGLU.so && libgl='yes'
+test -e /usr/lib64/libGL.so -a -e /usr/lib64/libGLU.so && libgl='yes'
+test -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."
+ exit 1;
+fi
+
+INTERNAL_SCRIPT=`which runqemu-internal`
+
+. $INTERNAL_SCRIPT
diff --git a/scripts/runqemu-internal b/scripts/runqemu-internal
new file mode 100755
index 0000000..df9beda
--- /dev/null
+++ b/scripts/runqemu-internal
@@ -0,0 +1,641 @@
+#!/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
+# CROSSPATH - the path to any cross toolchain to use with distcc
+#
+# 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:]] *//'`
+else
+ case "$MACHINE" in
+ "qemux86")
+ mem_size=128
+ ;;
+ "qemux86-64")
+ mem_size=128
+ ;;
+ "qemuarm")
+ mem_size=128
+ ;;
+ "qemuarmv7")
+ mem_size=128
+ ;;
+ "qemumips")
+ mem_size=128
+ ;;
+ "qemuppc")
+ mem_size=128
+ ;;
+ "beagleboard")
+ mem_size=256
+ ;;
+ "vexpressa9")
+ mem_size=1024
+ ;;
+ *)
+ mem_size=64
+ ;;
+ esac
+
+fi
+
+# QEMU_MEMORY has 'M' appended to mem_size
+QEMU_MEMORY="$mem_size"M
+
+# Bug 433: qemuarm cannot use > 128 MB RAM
+if [ "$MACHINE" = "qemuarm" -o "$MACHINE" = "qemuarmv7" ]; then
+ if [[ -z "$mem_size" || $mem_size -gt 128 ]]; then
+ echo "WARNING: qemuarm does not support > 128M of RAM."
+ echo "Changing QEMU_MEMORY to default of 128M."
+ QEMU_MEMORY="128M"
+ SCRIPT_QEMU_EXTRA_OPT=`echo $SCRIPT_QEMU_EXTRA_OPT | sed -e "s/$mem_set/-m 128/" `
+ fi
+fi
+
+# 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
+# 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"
+
+acquire_lock() {
+ lockfile=$1
+ if [ -z "$lockfile" ]; then
+ echo "Error: missing lockfile arg passed to acquire_lock()"
+ return 1
+ fi
+
+ if [ -e "$lockfile.lock" ]; then
+ # Check that the lockfile is not stale
+ ps=`ps -ewwo pid | grep $(cat $lockfile.lock)`
+ if [ -z "$ps" ]; then
+ echo "WARNING: Stale lock file detected, deleting $lockfile.lock."
+ rm -f $lockfile.lock
+ echo $$ > $lockfile.lock
+ else
+ return 1
+ fi
+ else
+ echo $$ > $lockfile.lock
+ 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
+}
+
+LOCKDIR="/tmp/qemu-tap-locks"
+if [ ! -d "$LOCKDIR" ]; then
+ mkdir $LOCKDIR
+ chmod 777 $LOCKDIR
+fi
+
+IFCONFIG=`which ifconfig 2> /dev/null`
+if [ -z "$IFCONFIG" ]; then
+ IFCONFIG=/sbin/ifconfig
+fi
+if [ ! -x "$IFCONFIG" ]; then
+ echo "$IFCONFIG cannot be executed"
+ exit 1
+fi
+
+POSSIBLE=`$IFCONFIG -a | grep '^tap' | awk '{print $1}'`
+TAP=""
+LOCKFILE=""
+for tap in $POSSIBLE; do
+ LOCKFILE="$LOCKDIR/$tap"
+ echo "Acquiring lockfile for $tap..."
+ acquire_lock $LOCKFILE
+ if [ $? -eq 0 ]; then
+ TAP=$tap
+ 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`
+ 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 $GROUPID $OECORE_NATIVE_SYSROOT 2> /dev/null`
+ if [ $? -ne 0 ]; then
+ # Re-run standalone to see verbose errors
+ sudo $QEMUIFUP $GROUPID $OECORE_NATIVE_SYSROOT
+ return
+ 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'"
+fi
+
+cleanup() {
+ if [ ! -e "$NOSUDO_FLAG" ]; 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
+}
+
+n1=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ]
+n2=$[ (`echo $TAP | sed 's/tap//'` * 2) + 2 ]
+
+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"
+QEMU_NETWORK_CMD="-net nic,vlan=0 $QEMU_TAP_CMD"
+KERNCMDLINE="mem=$QEMU_MEMORY"
+if [ $MACHINE != "qemuarmv7" ]; then
+ QEMU_UI_OPTIONS="-show-cursor -usb -usbdevice wacom-tablet"
+else
+ QEMU_UI_OPTIONS="-show-cursor -usb"
+fi
+
+NFS_INSTANCE=`echo $TAP | sed 's/tap//'`
+export NFS_INSTANCE
+
+SERIALOPTS=""
+if [ "x$SERIAL_LOGFILE" != "x" ]; then
+ SERIALOPTS="-serial file:$SERIAL_LOGFILE"
+fi
+
+case "$MACHINE" in
+ "qemuarm") ;;
+ "qemumips") ;;
+ "qemuppc") ;;
+ "qemuarmv6") ;;
+ "beagleboard") ;;
+ "vexpressa9") ;;
+ "qemux86") ;;
+ "qemux86-64") ;;
+ "akita") ;;
+ "spitz") ;;
+ *)
+ echo "Error: Unsupported machine type $MACHINE"
+ return
+ ;;
+esac
+
+if [ ! -f "$KERNEL" ]; then
+ echo "Error: Kernel image file $KERNEL doesn't exist"
+ cleanup
+ return
+fi
+
+PATH=$CROSSPATH:$OECORE_NATIVE_SYSROOT/usr/bin:$PATH
+
+sd_needed() {
+ if [ ! -f $IMGNAME ]; then
+ SD_NEEDED="y"
+ return
+ else
+ STAMP=`stat -c %Y $IMGNAME`
+
+ if [ -f $MLO ]; then
+ if [ `stat -c %Y $MLO` -gt $STAMP ]; then
+ SD_NEEDED="y"
+ return
+ fi
+ fi
+
+ if [ -f $UBOOT ]; then
+ if [ `stat -c %Y $UBOOT` -gt $STAMP ]; then
+ SD_NEEDED="y"
+ return
+ fi
+ fi
+
+ if [ -f $KERNEL ]; then
+ if [ `stat -c %Y $KERNEL` -gt $STAMP ]; then
+ SD_NEEDED="y"
+ return
+ fi
+ fi
+
+ if [ -f $ROOTFS ]; then
+ if [ `stat -c %Y $ROOTFS` -gt $STAMP ]; then
+ SD_NEEDED="y"
+ return
+ fi
+ fi
+
+ SD_NEEDED="n"
+ return
+
+ fi
+}
+
+# Check if we need to regenerate the sd image
+sd_needed
+
+if [ "$MACHINE" = "beagleboard" -a "$SD_NEEDED" = "y" ]; then
+ echo "Creating SD image ..."
+ QEMU_IMG=qemu-img
+ QEMUIMG=`which $QEMU_IMG 2> /dev/null`
+ if [ ! -x "$QEMUIMG" ]; then
+ echo "Error: No QEMUIMG binary '$QEMU_IMG' could be found."
+ cleanup
+ return
+ fi
+ CREATE_SD_SCRIPT=`which create_img.sh`
+ UENVTXT=`which uEnv.txt 2> /dev/null`
+ BOOTTXT=`which boot.txt 2> /dev/null`
+ BOOTSCR=`which boot.scr 2> /dev/null`
+ echo "MLO: $MLO "
+ echo "UBOOT $UBOOT"
+ echo "IMGNAME $IMGNAME"
+ echo "QEMUIMG $QEMUIMG"
+ echo "UENVTXT $UENVTXT"
+ echo "BOOTTXT $BOOTTXT"
+ echo "BOOTSCR $BOOTSCR"
+ $CREATE_SD_SCRIPT $IMGNAME $MLO $UBOOT $KERNEL $ROOTFS $QEMUIMG $UENVTXT $BOOTTXT $BOOTSCR
+ if [ $? != 0 ]; then
+ cleanup
+ return
+ fi
+else
+ echo "No need to create image."
+fi
+
+if [ "$MACHINE" = "vexpressa9" -a "$SD_NEEDED" = "y" ]; then
+ echo "Creating vexpress A9 SD image ..."
+ QEMU_IMG=qemu-img
+ QEMUIMG=`which $QEMU_IMG 2> /dev/null`
+ if [ ! -x "$QEMUIMG" ]; then
+ echo "Error: No QEMUIMG binary '$QEMU_IMG' could be found."
+ cleanup
+ return
+ fi
+ CREATE_SD_SCRIPT=`which create_img_vexpress-a9.sh`
+ echo "IMGNAME $IMGNAME"
+ echo "QEMUIMG $QEMUIMG"
+ $CREATE_SD_SCRIPT $IMGNAME $KERNEL $ROOTFS $QEMUIMG
+ if [ $? != 0 ]; then
+ cleanup
+ return
+ fi
+else
+ echo "No need to create image."
+fi
+
+if [ "$FSTYPE" != "nfs" -a ! -f "$ROOTFS" ]; then
+ echo "Error: Image file $ROOTFS doesn't exist"
+ cleanup
+ return
+fi
+
+if [ "$FSTYPE" = "nfs" ]; then
+ NFS_SERVER="192.168.7.1"
+ NFS_DIR=`echo $ROOTFS | sed 's/^[^:]*:\(.*\)/\1/'`
+ MOUNTD_RPCPORT=$[ 21111 + $NFS_INSTANCE ]
+ NFSD_RPCPORT=$[ 11111 + $NFS_INSTANCE ]
+ NFSD_PORT=$[ 3049 + $NFS_INSTANCE ]
+ MOUNTD_PORT=$[ 3048 + $NFS_INSTANCE ]
+ UNFS_OPTS="nfsvers=2,mountprog=$MOUNTD_RPCPORT,nfsprog=$NFSD_RPCPORT,udp,port=$NFSD_PORT,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
+ cleanup
+ return
+ fi
+ NFSRUNNING="true"
+fi
+
+if [ "$NFS_SERVER" = "" ]; then
+ NFS_SERVER="192.168.7.1"
+ NFS_DIR=$ROOTFS
+fi
+
+if [ "$MACHINE" = "qemuarm" -o "$MACHINE" = "qemuarmv6" -o "$MACHINE" = "qemuarmv7" ]; then
+ QEMU=qemu-system-arm
+ case "$MACHINE" in
+ "qemuarmv7")
+ MACHINE_SUBTYPE=vexpress-a9
+ ;;
+ *)
+ MACHINE_SUBTYPE=versatilepb
+ esac
+ QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS"
+ # QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS -force-pointer"
+ if [ "$FSTYPE" = "ext3" -o "$FSTYPE" = "btrfs" ]; then
+ KERNCMDLINE="root=/dev/sda rw console=ttyAMA0,115200 console=tty $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY highres=off"
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -M $MACHINE_SUBTYPE -hda $ROOTFS -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
+ fi
+ KERNCMDLINE="root=/dev/nfs 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
+ if [ "$MACHINE" = "qemuarmv6" ]; then
+ QEMUOPTIONS="$QEMUOPTIONS -cpu arm1136"
+ fi
+ if [ "$MACHINE" = "qemuarmv7" ]; then
+ QEMUOPTIONS="$QEMUOPTIONS -cpu cortex-a8"
+ fi
+fi
+
+if [ "$MACHINE" = "beagleboard" ]; then
+ QEMU=qemu-system-arm
+ MACHINE_SUBTYPE=beagle
+ QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS"
+ if [ "$FSTYPE" = "tar.bz2" ]; then
+ KERNCMDLINE=""
+ QEMUOPTIONS="-M $MACHINE_SUBTYPE -drive if=sd,cache=writeback,file=$IMGNAME -clock unix -device usb-kbd -device usb-mouse -usb -device usb-net,netdev=mynet -netdev user,id=mynet"
+ # Add
+ # -serial stdio
+ # To redirect serial to stdio
+ fi
+fi
+
+if [ "$MACHINE" = "vexpressa9" ]; then
+ QEMU=qemu-system-arm
+ MACHINE_SUBTYPE=vexpress-a9
+ QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS"
+ export QEMU_AUDIO_DRV="alsa"
+ SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -soundhw all"
+ if [ "$FSTYPE" = "tar.bz2" ]; then
+ KERNCMDLINE="root=/dev/mmcblk0p2 rw mem=1024M raid=noautodetect console=tty0 console=ttyAMA0,38400n8 rootwait vmalloc=256MB devtmpfs.mount=0"
+ QEMUOPTIONS="-M $MACHINE_SUBTYPE -cpu cortex-a9 -sd $IMGNAME"
+ # Add
+ # -serial stdio
+ # To redirect serial to stdio
+ fi
+fi
+
+if [ "$MACHINE" = "qemux86" ]; then
+ QEMU=qemu
+ QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS -vga vmware -enable-gl"
+ if [ "$FSTYPE" = "ext3" -o "$FSTYPE" = "btrfs" ]; then
+ KERNCMDLINE="vga=0 root=/dev/hda rw mem=$QEMU_MEMORY $KERNEL_NETWORK_CMD"
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -hda $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
+ 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
+ # 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"
+fi
+
+if [ "$MACHINE" = "qemux86-64" ]; then
+ QEMU=qemu-system-x86_64
+ QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS -vga vmware -enable-gl"
+ if [ "$FSTYPE" = "ext3" -o "$FSTYPE" = "btrfs" ]; then
+ KERNCMDLINE="vga=0 root=/dev/hda rw mem=$QEMU_MEMORY $KERNEL_NETWORK_CMD"
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -hda $ROOTFS $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
+ 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
+ # 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"
+fi
+
+if [ "$MACHINE" = "spitz" ]; then
+ QEMU=qemu-system-arm
+ if [ "$FSTYPE" = "ext3" -o "$FSTYPE" = "btrfs" ]; then
+ echo $ROOTFS
+ ROOTFS=`readlink -f $ROOTFS`
+ echo $ROOTFS
+ if [ ! -e "$ROOTFS.qemudisk" ]; then
+ echo "Adding a partition table to the ext3 image for use by QEMU, please wait..."
+ runqemu-addptable2image $ROOTFS $ROOTFS.qemudisk
+ fi
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -M spitz -hda $ROOTFS.qemudisk -portrait"
+ fi
+fi
+
+if [ "$MACHINE" = "qemumips" ]; then
+ QEMU=qemu-system-mips
+ MACHINE_SUBTYPE=malta
+ QEMU_UI_OPTIONS="-vga cirrus $QEMU_UI_OPTIONS"
+ if [ "$FSTYPE" = "ext3" -o "$FSTYPE" = "btrfs" ]; then
+ #KERNCMDLINE="root=/dev/hda console=ttyS0 console=tty0 $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
+ KERNCMDLINE="root=/dev/hda rw console=ttyS0 console=tty $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -M $MACHINE_SUBTYPE -hda $ROOTFS -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
+ 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
+fi
+
+if [ "$MACHINE" = "qemuppc" ]; then
+ QEMU=qemu-system-ppc
+ MACHINE_SUBTYPE=prep
+ CPU_SUBTYPE=603e
+ BIOS=powerpc_rom.bin
+ QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS -nographic"
+ if [ "$FSTYPE" = "ext3" -o "$FSTYPE" = "btrfs" ]; then
+ KERNCMDLINE="root=/dev/hda rw console=ttyS0 3 $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE -M $MACHINE_SUBTYPE -bios $BIOS -hda $ROOTFS -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
+ fi
+ KERNCMDLINE="root=/dev/nfs console=ttyS0 3 nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE -M $MACHINE_SUBTYPE -bios $BIOS -no-reboot $QEMU_UI_OPTIONS"
+ fi
+fi
+
+if [ "$MACHINE" = "akita" ]; then
+ QEMU=qemu-system-arm
+ if [ "$FSTYPE" = "jffs2" ]; then
+ ROOTFS=`readlink -f $ROOTFS`
+ if [ ! -e "$ROOTFS.qemuflash" ]; then
+ echo "Converting raw image into flash image format for use by QEMU, please wait..."
+ raw2flash.akita < $ROOTFS > $ROOTFS.qemuflash
+ fi
+ QEMUOPTIONS="$QEMU_NETWORK_CMD -M akita -mtdblock $ROOTFS.qemuflash -portrait"
+ fi
+fi
+
+if [ "x$QEMUOPTIONS" = "x" ]; then
+ echo "Error: Unable to support this combination of options"
+ cleanup
+ return
+fi
+
+#PATH=$CROSSPATH:$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
+fi
+
+function _quit() {
+ if [ -n "$PIDFILE" ]; then
+ #echo kill `cat $PIDFILE`
+ kill `cat $PIDFILE`
+ fi
+ cleanup
+ return
+}
+
+DISTCCD=`which distccd 2> /dev/null`
+PIDFILE=""
+
+trap _quit INT TERM QUIT
+
+if [ -x "$DISTCCD" ]; then
+ echo "Starting distccd..."
+ PIDFILE=`mktemp`
+ $DISTCCD --allow 192.168.7.2 --daemon --pid-file $PIDFILE &
+else
+ echo "WARNING: distccd not present, no distcc support loaded."
+fi
+
+# 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).
+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
+ echo "Skip nVidia's libGL on Ubuntu!"
+ GL_LD_PRELOAD="/usr/lib/libGL.so $LD_PRELOAD"
+ fi
+fi
+
+echo "Running $QEMU..."
+# -no-reboot is a mandatory option - see bug #100
+if [ "$MACHINE" = "beagleboard" ]; then
+ echo $QEMUBIN $QEMUOPTIONS $SERIALOPTS $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT
+ LD_PRELOAD="$GL_LD_PRELOAD" $QEMUBIN $QEMUOPTIONS $SERIALOPTS $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT
+elif [ "$MACHINE" = "vexpressa9" ]; then
+ echo $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append '"'$KERNCMDLINE $SCRIPT_KERNEL_OPT'"'
+ LD_PRELOAD="$GL_LD_PRELOAD" $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append "$KERNCMDLINE $SCRIPT_KERNEL_OPT"
+else
+ echo $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append '"'$KERNCMDLINE $SCRIPT_KERNEL_OPT'"'
+ LD_PRELOAD="$GL_LD_PRELOAD" $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append "$KERNCMDLINE $SCRIPT_KERNEL_OPT"
+fi
+
+
+cleanup
+
+trap - INT TERM QUIT
+return
diff --git a/scripts/uEnv.txt b/scripts/uEnv.txt
index 41d4f96..ce65475 100644..100755
--- a/scripts/uEnv.txt
+++ b/scripts/uEnv.txt
@@ -1,3 +1,3 @@
-bootenv=boot.scr
-loaduimage=fatload mmc ${mmcdev} ${loadaddr} ${bootenv}
-mmcboot=echo Running boot.scr script from mmc ...; source ${loadaddr}
+bootenv=boot.scr
+loaduimage=fatload mmc ${mmcdev} ${loadaddr} ${bootenv}
+mmcboot=echo Running boot.scr script from mmc ...; source ${loadaddr}