summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Harkin <ryan.harkin@linaro.org>2015-06-23 10:33:03 +0100
committerRyan Harkin <ryan.harkin@linaro.org>2015-06-23 10:33:03 +0100
commitba210746dceb50ad4e4ac3d4634658de90cf3ac0 (patch)
treec21cdba94299b3696f2aff380883fddfe05af0bb
downloadmodel-scripts-ba210746dceb50ad4e4ac3d4634658de90cf3ac0.tar.gz
Added run_model.shjuno
Added the initial version of the run_model.sh script. This model allows the user to specify variables for most parameters used when running the models, or to choose sensible defaults where possible. Signed-off-by: Ryan Harkin <ryan.harkin@linaro.org>
-rwxr-xr-xrun_model.sh181
1 files changed, 181 insertions, 0 deletions
diff --git a/run_model.sh b/run_model.sh
new file mode 100755
index 0000000..5f1ff58
--- /dev/null
+++ b/run_model.sh
@@ -0,0 +1,181 @@
+#!/bin/bash
+
+# Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+#
+# Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# Neither the name of ARM nor the names of its contributors may be used
+# to endorse or promote products derived from this software without specific
+# prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+err=0
+
+# $1 - the output dir to run in the model
+rundir=$1
+
+# If the run dir is not set, use the current dir
+if [ "$rundir" != "" ]; then
+ if [ -e $rundir ]; then
+ cd $rundir
+ else
+ echo "ERROR: you set the run directory to $rundir, however that path does not exist"
+ exit 1
+ fi
+fi
+
+# Check for obvious errors and set err=1 if we encounter one
+if [ ! -e "$MODEL" ]; then
+ echo "ERROR: you should set variable MODEL to point to a valid FVP model binary, currently it is set to \"$MODEL\""
+ err=1
+else
+ # Check if we are running the foundation model or the AEMv8 model
+ if [[ $($MODEL --version) == *Foundation* ]]; then
+ FOUNDATION=1
+ else
+ FOUNDATION=0
+ fi
+
+fi
+
+# Set some sane defaults before continuing to error check
+BL1=${BL1:-bl1.bin}
+FIP=${FIP:-fip.bin}
+IMAGE=${IMAGE:-Image}
+INITRD=${INITRD:-ramdisk.img}
+CLUSTER0_NUM_CORES=${CLUSTER0_NUM_CORES:-1}
+CLUSTER1_NUM_CORES=${CLUSTER1_NUM_CORES:-1}
+
+# Set defaults based on model type
+if [ "$FOUNDATION" == "1" ]; then
+ DTB=${DTB:-foundation-v8.dtb}
+else
+ DTB=${DTB:-fvp-base-gicv2-psci.dtb}
+fi
+
+# Continue error checking...
+if [ ! -e "$BL1" ]; then
+ echo "ERROR: you should set variable BL1 to point to a valid BL1 binary, currently it is set to \"$BL1\""
+ err=1
+fi
+
+if [ ! -e "$FIP" ]; then
+ echo "ERROR: you should set variable FIP to point to a valid FIP binary, currently it is set to \"$FIP\""
+ err=1
+fi
+
+if [ ! -e "$IMAGE" ]; then
+ echo "ERROR: you should set variable IMAGE to point to a valid kernel image, currently it is set to \"$IMAGE\""
+ err=1
+fi
+if [ ! -e "$INITRD" ]; then
+ echo "ERROR: you should set variable INITRD to point to a valid initrd/ramdisk image, currently it is set to \"$INITRD\""
+ err=1
+fi
+if [ ! -e "$DTB" ]; then
+ echo "ERROR: you should set variable DTB to point to a valid device tree binary (.dtb), currently it is set to \"$DTB\""
+ err=1
+fi
+
+# Exit if any obvious errors happened
+if [ $err == 1 ]; then
+ exit 1
+fi
+
+# check for warnings, like no disk specified.
+# note: busybox variants don't need a disk, so it may be OK for DISK to be empty/missing
+if [ ! -e "$DISK" ]; then
+ echo "WARNING: you should set variable DISK to point to a valid disk image, currently it is set to \"$DISK\""
+ warn=1
+fi
+
+# Optional VARS arg.
+# If a filename is given in the VARS variable, use it to set the contents of the
+# 2nd bank of NOR flash: where UEFI stores it's config
+if [ "$VARS" != "" ]; then
+ # if the $VARS file doesn't exist, create it
+ touch $VARS
+ VARS="-C bp.flashloader1.fname=$VARS -C bp.flashloader1.fnameWrite=$VARS"
+else
+ VARS=""
+fi
+
+echo "Running FVP Base Model with these parameters:"
+echo "MODEL=$MODEL"
+echo "BL1=$BL1"
+echo "FIP=$FIP"
+echo "IMAGE=$IMAGE"
+echo "INITRD=$INITRD"
+echo "DTB=$DTB"
+echo "VARS=$VARS"
+echo "DISK=$DISK"
+echo "CLUSTER0_NUM_CORES=$CLUSTER0_NUM_CORES"
+echo "CLUSTER1_NUM_CORES=$CLUSTER1_NUM_CORES"
+
+kern_addr=0x80080000
+dtb_addr=0x83000000
+initrd_addr=0x84000000
+
+if [ "$FOUNDATION" == "1" ]; then
+ if [ "$DISK" != "" ]; then
+ disk_param=" --block-device=$DISK "
+ fi
+
+ cmd="$FOUNDATION_MODEL \
+ --cores=$CLUSTER0_NUM_CORES \
+ --no-secure-memory \
+ --visualization \
+ --gicv3 \
+ --data=${BL1}@0x0 \
+ --data=${FIP}@0x8000000 \
+ --data=${IMAGE}@${kern_addr} \
+ --data=${DTB}@${dtb_addr} \
+ --data=${INITRD}@${initrd_addr} \
+ $disk_param \
+ "
+else
+ if [ "$DISK" != "" ]; then
+ disk_param=" -C bp.virtioblockdevice.image_path=$DISK "
+ fi
+
+ cmd="$MODEL \
+ -C pctl.startup=0.0.0.0 \
+ -C bp.secure_memory=0 \
+ -C cluster0.NUM_CORES=$CLUSTER0_NUM_CORES \
+ -C cluster1.NUM_CORES=$CLUSTER1_NUM_CORES \
+ -C cache_state_modelled=0 \
+ -C bp.pl011_uart0.untimed_fifos=1 \
+ -C bp.secureflashloader.fname=$BL1 \
+ -C bp.flashloader0.fname=$FIP \
+ --data cluster0.cpu0=${IMAGE}@${kern_addr} \
+ --data cluster0.cpu0=${DTB}@${dtb_addr} \
+ --data cluster0.cpu0=${INITRD}@${initrd_addr} \
+ -C bp.ve_sysregs.mmbSiteDefault=0 \
+ $disk_param \
+ $VARS \
+ "
+fi
+
+echo "Executing Model Command:"
+echo " $cmd"
+
+$cmd