Commit 03beeb20 authored by Selvarasu Ganesan's avatar Selvarasu Ganesan Committed by Deepak Pandey
Browse files

aemfvp-a/run-model: Add SATA device parameters to support distro boot



Also, add the following changes to this patch:
1. Add changes for accessing Terminal-0 via Telnet if the Armv-A
   Base AEM FVP is running on non-Xserver support.
2. Add separate scripts for busybox and distro boot support
   on Armv-A Base AEM FVP.
Signed-off-by: Selvarasu Ganesan's avatarSelvarasu Ganesan <Selvarasu.Ganesan@arm.com>
Change-Id: I06a7a31be749f5fe88c9b2c148d1e787ede7b70f
parent 316f9305
#!/bin/bash
# Copyright (c) 2021, 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.
readonly bootloader_options=(
"uefi"
"u-boot"
)
#Set default bootloader
bootloader="uefi"
#Set default platform
platform="aemfvp-a"
#Network disabled by default
net_enable="false"
__print_examples()
{
echo "Example 1: ./boot.sh"
echo " Starts the execution of the $1 model and the software boots upto the"
echo " busybox prompt. Here the default platform and bootloader"
echo " selections are \"aemfvp-a\" and \"uefi\""
echo ""
echo "Example 2: ./boot.sh -p $1"
echo " Starts the execution of the $1 model and the software boots upto the"
echo " busybox prompt. Here the default bootloader selection is \"uefi\""
echo ""
echo "Example 3: ./boot.sh -p $1 -b [uefi|u-boot]"
echo " Starts the execution of the $1 model and the software boots upto the"
echo " busybox prompt. The selection of the bootloader to be either uefi or u-boot"
echo " is based on command line parameters."
echo ""
echo "Example 4: ./boot.sh -p $1 -b [uefi|u-boot] -n true"
echo " Starts the execution of the $1 model and the software boots upto the"
echo " busybox prompt. The selection of the bootloader to be either uefi or u-boot"
echo " is based on command line parameters. The model supports networking allowing"
echo " the software running within the model to access the network."
echo ""
}
print_usage ()
{
echo ""
echo "Boots upto busybox console on a specified platform."
echo "Usage: ./boot.sh -p <platform> [-b <uefi|u-boot>] [-n <true|false>]"
echo ""
echo "Supported command line parameters - "
echo " -p Specifies the platform to be selected \(default/optional\)"
echo " Supported platform is -"
echo " aemfvp-a"
echo " -b Specifies the bootloader to be selected \(optional\)"
echo " Supported bootloader options are -"
echo " ${bootloader_options[@]}"
echo " -n Enable or disable network controller support on the platform \(optional\)."
echo " If not specified, network support is disabled by default."
echo ""
__print_examples "aemfvp-a"
echo ""
}
while getopts "p:b:n:h" opt; do
case $opt in
p)
platform=$OPTARG
;;
b)
bootloader=$OPTARG
;;
n)
net_enable=$OPTARG
;;
*)
print_usage
exit 1
;;
esac
done
__parse_params_validate()
{
#Ensure that the platform is supported
if [ -z "$platform" ] ; then
print_usage
exit 1
fi
if [ "$platform" != "aemfvp-a" ]; then
echo "[ERROR] Could not deduce which platform to execute on."
echo "Supported platform is -"
echo "aemfvp-a"
exit 1
fi
}
#Ensure that the platform is supported
__parse_params_validate
if [ "${bootloader}" != "uefi" ] && [ "${bootloader}" != "u-boot" ] ;then
echo "[ERROR] Invalid bootloader selection"
print_usage
exit 1
fi
if [ "${net_enable}" != "true" ] && [ "${net_enable}" != "false" ]; then
echo "[ERROR] Unsupported <network_enabled> selected"
print_usage
exit 1;
fi
out_dir="output/$platform"
BL1="$out_dir/$platform/tf-bl1.bin"
if [ "$bootloader" == "u-boot" ]; then
FIP="$out_dir/$platform/fip-uboot.bin"
IMAGE="$out_dir/$platform/Image"
DTB="$out_dir/$platform/fvp-base-revc.dtb"
else
FIP="$out_dir/$platform/fip-uefi.bin"
fi
if [ "${net_enable}" == "true" ]; then
NET=1
fi
DISK="$out_dir/components/$platform/grub-busybox.img"
source ./model-scripts/$platform/run_model.sh
#!/bin/bash
# Copyright (c) 2021, 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.
installer_image=""
disk_size=""
mode=""
#Set default platform
platform="aemfvp-a"
#Network disabled by default
net_enable="false"
install ()
{
#Sata disk output directory
mkdir -p "$PWD/satadisk"
export SATADISK_IMAGE_PATH="$PWD/satadisk/$RANDOM.satadisk"
# Create a disk of $disk_size GB
dd if=/dev/zero of=$SATADISK_IMAGE_PATH bs=1G count=$disk_size
echo "Created $SATADISK_IMAGE_PATH of size $disk_size GB, proceeding to install $installer_image ..."
./model-scripts/$platform/run_model.sh -f distro
}
boot ()
{
# Check if an installed sata disk image is supplied. If yes, boot from it.
if [ ! -z "$disk_image" ] ; then
dir_name="$(dirname $disk_image)"
if [ $dir_name == "." ] ; then
disk_image="$PWD/$disk_image"
fi
echo "Proceeding to boot supplied disk image name: $disk_image ..."
export SATADISK_IMAGE_PATH=$disk_image
./model-scripts/$platform/run_model.sh -f distro
exit 0
fi
# If $disk_image is not specified, see if there are more than one
# .satadisk files, if so, prompt the user to pick one with -d.
# If there is exactly one available, boot it. If there are none, prompt
# the user to install with -i/-s
available_images=$(find . -name "*.satadisk")
num_available_images=$(echo $available_images | wc -w)
case $num_available_images in
1)
# In the case of exactly one, the list of images will
# be the image name so just use it
echo "Found $available_images, proceeding to boot ..."
available_images=$PWD/$available_images
export SATADISK_IMAGE_PATH=$available_images
./model-scripts/$platform/run_model.sh -f distro
;;
*)
if [[ -z "$disk_image" ]]; then
echo "Found several available images:"
echo ""
echo $available_images | sed 's/\.\///g' | tr ' ' '\n'
echo ""
echo "Please choose one using distro_boot -d [disk_image]"
echo ""
fi
;;
esac
}
__print_examples()
{
echo "Example 1: ./distro.sh -p $1 -i Fedora-Server-dvd-aarch64-34-1.2.iso -s 16"
echo " Installs Fedora 34 on to a 16 GB disk."
echo ""
echo "Example 2: ./distro.sh -p $1"
echo " Finds an available installed disk image and boots from it."
echo ""
echo "Example 3: ./distro.sh -p $1 -d fedora34.satadisk"
echo " Boot from an existing installed disk image"
}
print_usage ()
{
echo ""
echo "Install or boot linux distribution."
echo "Usage: ./distro.sh -p <platform> -i <image> -s <disk size> [-d <disk image>] [-n <true|false>]"
echo ""
echo "Supported command line parameters:"
echo " -p platform name (optional)"
echo " Supported platform is -"
echo " aemfvp-a"
echo " -i Image, takes a path to an iso installer image (mandatory for installation)"
echo " -s Disk size in GB (mandatory for installation)"
echo " -d Disk image with previously installed distro, used for"
echo " disambiguation if there are more than one installed"
echo " concurrently."
echo " -n Enable network: true or false (default: false)"
echo ""
__print_examples "aemfvp-a"
echo ""
}
while getopts "p:i:s:d:n:h" opt; do
case $opt in
p)
platform=$OPTARG
;;
i)
installer_image=$OPTARG
;;
s)
disk_size=$OPTARG
;;
d)
disk_image=$OPTARG
;;
n)
net_enable=$OPTARG
;;
*)
print_usage
exit 1
;;
esac
done
# Either an installer and a disk size is specified or neither.
# If they are specified, create a new disk and boot the model with those params
# if not, check for an existing .satadisk file and use that to boot from
# otherwise throw an error
if [[ ! -z $disk_size ]] && [[ ! -z $installer_image ]]; then
mode="install"
elif [[ -z $disk_size ]] && [[ -z $installer_image ]]; then
# There is no need to separate the boot from single / multiple images
# at this stage, we can handle that in boot()
mode="boot"
else
print_usage
exit 1
fi
__parse_params_validate()
{
#Ensure that the platform is supported
if [ -z "$platform" ] ; then
print_usage
exit 1
fi
if [ "$platform" != "aemfvp-a" ]; then
echo "[ERROR] Could not deduce which platform to execute on."
echo "Supported platform is -"
echo "aemfvp-a"
exit 1
fi
}
#Ensure that the platform is supported
__parse_params_validate
out_dir="output/$platform"
export BL1="$out_dir/$platform/tf-bl1.bin"
export FIP="$out_dir/$platform/fip-uefi.bin"
export DISK=$installer_image
if [ "${net_enable}" != "true" ] && [ "${net_enable}" != "false" ]; then
echo "[ERROR] Unsupported <network_enabled> selected"
print_usage
exit 1;
fi
if [ "${net_enable}" == "true" ]; then
export NET=1
fi
case $mode in
install)
install
;;
boot)
boot
;;
*)
echo "Unknown mode"
exit 1
;;
esac
#!/bin/bash
# Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
# Copyright (c) 2015-2021, 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:
......@@ -30,52 +30,32 @@
err=0
function usage
{
echo "usage: $0 [--aarch32] [rundir]"
echo "Options:"
echo " --aarch32 run the model in Aarch32 mode, if available"
echo " [rundir] the script will run from a directory specified on the commandline"
echo " otherwise it will run from the current working directory"
echo " use this to tell the model where to find the binaries you want"
echo " to load if they aren't in the current directory."
exit
}
MODEL_TYPE="aemfvp-a"
# Set default fs_type
FS_TYPE="busybox"
while [ "$1" != "" ]; do
case $1 in
"-h" | "-?" | "-help" | "--help" | "--h" | "help" )
usage
exit
;;
"--aarch32" | "--Aarch32" | "--AARCH32" )
model_arch=aarch32
;;
"--aarch64" | "--Aarch64" | "--AARCH64" )
model_arch=aarch64
;;
*)
if [ "$rundir" == "" ]
then
rundir=$1
-f)
shift
if test $# -gt 0; then
FS_TYPE=$1
fi
shift
;;
esac
shift
done
model_arch=${model_arch:-aarch64}
rundir=${rundir:-.}
if [ -e $rundir ]; then
cd $rundir
else
echo "ERROR: the run directory to $rundir, however that path does not exist"
exit 1
fi
CLUSTER0_NUM_CORES=${CLUSTER0_NUM_CORES:-1}
CLUSTER1_NUM_CORES=${CLUSTER1_NUM_CORES:-1}
CLUSTER0_NUM_CORES=${CLUSTER0_NUM_CORES:-4}
CLUSTER1_NUM_CORES=${CLUSTER1_NUM_CORES:-4}
# Check for obvious errors and set err=1 if we encounter one
if [ ! -e "$MODEL" ]; then
......@@ -88,27 +68,15 @@ else
case $version in
*Foundation* )
model_type=foundation
DTB=${DTB:-foundation-v8-gicv3.dtb}
err=1
;;
*Cortex_A32* )
model_type=cortex-a32
DTB=${DTB:-fvp-base-aemv8a-aemv8a.dtb}
err=1
;;
* )
model_type=aemv8
DTB=${DTB:-fvp-base-aemv8a-aemv8a.dtb}
if [ "$model_arch" == "aarch32" ]; then
arch_params=" -C cluster0.cpu0.CONFIG64=0 \
-C cluster0.cpu1.CONFIG64=0 \
-C cluster0.cpu2.CONFIG64=0 \
-C cluster0.cpu3.CONFIG64=0 \
-C cluster1.cpu0.CONFIG64=0 \
-C cluster1.cpu1.CONFIG64=0 \
-C cluster1.cpu2.CONFIG64=0 \
-C cluster1.cpu3.CONFIG64=0 \
"
fi
cores="-C cluster0.NUM_CORES=$CLUSTER0_NUM_CORES \
-C cluster1.NUM_CORES=$CLUSTER1_NUM_CORES"
;;
......@@ -176,7 +144,6 @@ SECURE_MEMORY=${SECURE_MEMORY:-0}
echo "Running FVP Base Model with these parameters:"
echo "MODEL=$MODEL"
echo "model_arch=$model_arch"
echo "rundir=$rundir"
echo "BL1=$BL1"
echo "FIP=$FIP"
echo "IMAGE=$IMAGE"
......@@ -188,120 +155,127 @@ echo "CLUSTER0_NUM_CORES=$CLUSTER0_NUM_CORES"
echo "CLUSTER1_NUM_CORES=$CLUSTER1_NUM_CORES"
echo "SECURE_MEMORY=$SECURE_MEMORY"
echo "NET=$NET"
echo "TAP_INTERFACE=$TAP_INTERFACE"
echo "SATADISK_IMAGE_PATH=$SATADISK_IMAGE_PATH"
kern_addr=0x80080000
dtb_addr=0x82000000
dtb_addr=0x83000000
initrd_addr=0x84000000
if [ "$model_type" == "foundation" ]; then
GICV3=${GICV3:-1}
echo "GICV3=$GICV3"
if [ "$NET" == "1" ]; then
# The Foundation Model MAC address appears to be 00:02:F7:EF
# followed by the last two bytes of the host's MAC address.
net="--network bridged --network-bridge=ARM$USER"
fi
if [ "$DISK" != "" ]; then
disk_param=" --block-device=$DISK "
fi
CACHE_STATE_MODELLED=${CACHE_STATE_MODELLED:=0}
echo "CACHE_STATE_MODELLED=$CACHE_STATE_MODELLED"
if [ "$SECURE_MEMORY" == "1" ]; then
secure_memory_param=" --secure-memory"
# search all the available network interfaces and find an available tap
# network interface to use.
find_tap_interface()
{
echo -e "\n[INFO] Finding available TAP interface..."
if [[ -n "$TAP_NAME" ]]; then
TAP_INTERFACE=$TAP_NAME
else
secure_memory_param=" --no-secure-memory"
echo -e "\n[WARN] Environment variable TAP_NAME is not defined."
echo -e "[INFO] If you want to use a particular interface then please export TAP_NAME with the interface name."
echo -e "[INFO] Searching for available TAP device(s)..."
ALL_INTERFACES=`ifconfig -a | sed 's/[ \t].*//;/^\(lo\|\)$/d'`
while read -r line; do
last_char="${line: -1}"
#On machines with ubuntu 18.04+, the interface name ends with ":" character.
#Strip this character from the network interface name.
if [ "$last_char" == ":" ]; then
TAP_INTERFACE=${line::-1}
else
TAP_INTERFACE=$line
fi
# The file tun_flags will only be available under tap interface directory.
# Incase of multiple tap interfaces, only the first available tap interface will be used.
if [ -f "/sys/class/net/$TAP_INTERFACE/tun_flags" ];then
break;
fi
done <<< "$ALL_INTERFACES"
fi
if [ "$GICV3" == "1" ]; then
gic_param=" --gicv3"
if [[ -z "$TAP_INTERFACE" ]]; then
echo -e "[WARN] No TAP interface found !!! Please create a new tap interface for network to work inside the model."
return 1
else
gic_param=" --no-gicv3"
echo -e "[INFO] Interface Found : $TAP_INTERFACE"
fi
return 0
}
if [ "$IMAGE" != "" ]; then
image_param="--data=${IMAGE}@${kern_addr}"
fi
if [ "$INITRD" != "" ]; then
initrd_param="--data=${INITRD}@${initrd_addr}"
fi
if [ "$DTB" != "" ]; then
dtb_param="--data=${DTB}@${dtb_addr}"
if [ "$NET" == "1" ]; then
find_tap_interface
if [[ -z $TAP_INTERFACE ]]; then
echo "[ERROR] network interface name is empty"
exit 1;
fi
cmd="$MODEL \
--cores=$CLUSTER0_NUM_CORES \
$secure_memory_param \
--visualization \
--use-real-time \
$gic_param \
--data=${BL1}@0x0 \
--data=${FIP}@0x8000000 \
$image_param \
$dtb_param \
$initrd_param \
$disk_param \
$net \
--arm-v8.0
"
else
CACHE_STATE_MODELLED=${CACHE_STATE_MODELLED:=0}
echo "CACHE_STATE_MODELLED=$CACHE_STATE_MODELLED"
if [ "$NET" == "1" ]; then
if [ "$MACADDR" == "" ]; then
# if the user didn't supply a MAC address, generate one
MACADDR=`echo -n 00:02:F7; dd bs=1 count=3 if=/dev/random 2>/dev/null |hexdump -v -e '/1 ":%02X"'`
echo MACADDR=$MACADDR
fi
if [ "$MACADDR" == "" ]; then
# if the user didn't supply a MAC address, generate one
MACADDR=`echo -n 00:02:F7; dd bs=1 count=3 if=/dev/random 2>/dev/null |hexdump -v -e '/1 ":%02X"'`
echo MACADDR=$MACADDR
fi
net="-C bp.hostbridge.interfaceName=ARM$USER \
net="-C bp.hostbridge.interfaceName=$TAP_INTERFACE \
-C bp.smsc_91c111.enabled=true \
-C bp.smsc_91c111.mac_address=${MACADDR}"
fi
fi
if [ "$DISK" != "" ]; then
disk_param=" -C bp.virtioblockdevice.image_path=$DISK "
fi
if [[ ! -z $FS_TYPE ]] && [ ${FS_TYPE,,} == "distro" ]; then
if [ "$IMAGE" != "" ]; then
image_param="--data cluster0.cpu0=${IMAGE}@${kern_addr}"
fi
if [ "$INITRD" != "" ]; then
initrd_param="--data cluster0.cpu0=${INITRD}@${initrd_addr}"
fi
if [ "$DTB" != "" ]; then
dtb_param="--data cluster0.cpu0=${DTB}@${dtb_addr}"
if [[ -n "$SATADISK_IMAGE_PATH" ]]; then
sata_disk_path="-C pci.ahci_pci.ahci.image_path=${SATADISK_IMAGE_PATH}"
else
echo "Error:Valid SATA hard disk image required to install the distribution image."
echo "Please create sata disk image and export using SATADISK_IMAGE_PATH variable"
exit 1
fi
remove_unused_virtio="-C pci.pcidevice0.bus=0xFF \