Update the scripts to automate tests on fpga_arm platform.

Change-Id: I8313440a5f45a37774de320fb0290c0eb9f03aea
Signed-off-by: Javier Almansa Sobrino <javier.almansasobrino@arm.com>
diff --git a/arm_fpga_utils.sh b/arm_fpga_utils.sh
index 711d12e..dc780c9 100644
--- a/arm_fpga_utils.sh
+++ b/arm_fpga_utils.sh
@@ -13,13 +13,6 @@
 [test-kernel-aarch64]="$tfa_downloads/arm-fpga/kernel-image"
 )
 
-#arm_fpga dtbs
-declare -A arm_fpga_dtbs
-arm_fpga_dtbs=(
-[zeus-dtb]="$tfa_downloads/arm-fpga/zeus.dtb"
-[hera-dtb]="$tfa_downloads/arm-fpga/hera.dtb"
-)
-
 #arm_fpga initramfs
 declare -A arm_fpga_initramfs
 arm_fpga_initramfs=(
@@ -29,48 +22,19 @@
 get_kernel() {
 	local kernel_type="${kernel_type:?}"
 	local url="${arm_fpga_kernels[$kernel_type]}"
-	local kernel_saveas="kernel.bin"
+	local kernel_saveas="${saveas}"
 
 	url="${url:?}" saveas="${kernel_saveas:?}" fetch_file
 	archive_file "$kernel_saveas"
 }
 
-get_dtb() {
-	local dtb_type="${dtb_type:?}"
-	local dtb_url="${arm_fpga_dtbs[$dtb_type]}"
-	local dtb_saveas="dtb.bin"
-
-	url="${dtb_url:?}"  saveas="${dtb_saveas:?}" fetch_file
-	archive_file "$dtb_saveas"
-}
-
 get_initrd() {
 	local initrd_type="${initrd_type:?}"
 	local url="${arm_fpga_initramfs[$initrd_type]}"
-	local initrd_saveas="initrd.bin"
+	local initrd_saveas="${saveas}"
 
 	url="${url:?}" saveas="${initrd_saveas:?}" fetch_file
 	archive_file "$initrd_saveas"
 }
 
-get_linkerscript() {
-	local url="$tfa_downloads/arm-fpga/model.lds"
-	local ld_saveas="linker.ld"
-	local artefacts_dir="${fullpath:?}"
-
-	url="${url:?}" saveas="${ld_saveas:?}" fetch_file
-	sed -i "s+<artefacts>+"$artefacts_dir"+g" $ld_saveas
-	archive_file "$ld_saveas"
-}
-
-link_fpga_images(){
-	local arch="${arch:-aarch64elf}"
-	local ld_file="${ld_file:-linker.ld}"
-	local out="${out:-image.elf}"
-	local cross_compile="${nfs_volume}/pdsw/tools/gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-"
-
-	`echo "$cross_compile"ld` -m $arch -T $ld_file -o $out
-	archive_file "$out"
-}
-
 set +u
diff --git a/script/build_package.sh b/script/build_package.sh
index f373d58..b49c301 100755
--- a/script/build_package.sh
+++ b/script/build_package.sh
@@ -157,7 +157,7 @@
 		return
 	fi
 
-	if ! find "$from" \( -name "*.bin" -o -name '*.elf' -o -name '*.dtb' \) -exec cp -t "${to:?}" '{}' +; then
+	if ! find "$from" \( -name "*.bin" -o -name '*.elf' -o -name '*.dtb' -o -name '*.axf' \) -exec cp -t "${to:?}" '{}' +; then
 		echo "You probably are running local CI on local repositories."
 		echo "Did you set 'dont_clean' but forgot to run 'distclean'?"
 		die
diff --git a/script/test_fpga_payload.sh b/script/test_fpga_payload.sh
index be27918..ee878e2 100644
--- a/script/test_fpga_payload.sh
+++ b/script/test_fpga_payload.sh
@@ -23,6 +23,7 @@
 mkdir -p "$run_root"
 
 archive="$artefacts"
+bootargs_file="bootargs_file"
 
 gen_fpga_params() {
 	local fpga_param_file="fpga_env.sh"
@@ -33,11 +34,27 @@
 	echo "baudrate=$uart_baudrate" > $fpga_param_file
 	echo "fpga=$fpga" >> $fpga_param_file
 	echo "fpga_bitfile=$fpga_bitfile" >> $fpga_param_file
-	echo "fpga_payload=$fpga_payload" >> $fpga_param_file
 	echo "project_name=$project_name" >> $fpga_param_file
 	echo "port=$uart_port" >> $fpga_param_file
 	echo "uart=$uart_descriptor" >> $fpga_param_file
 
+	if [ -n "$bl33_img" ]; then
+        	echo "bl33_img=$bl33_img" >> $fpga_param_file
+		echo "bl33_addr=$bl33_addr" >> $fpga_param_file
+	fi
+
+	if [ -n "$initrd_img" ]; then
+        	echo "initrd_img=$initrd_img" >> $fpga_param_file
+		echo "initrd_addr=$initrd_addr" >> $fpga_param_file
+	fi
+
+	if [ -n "$bootargs" ]; then
+		echo "CMD:$bootargs" > $bootargs_file
+		archive_file "$bootargs_file"
+		echo "cmdline_file=$bootargs_file" >> $fpga_param_file
+		echo "cmdline_addr=$bootargs_addr" >> $fpga_param_file
+	fi
+
 	archive_file "$fpga_param_file"
 }
 
@@ -169,8 +186,18 @@
 echo
 
 # Copy the image to the remote host.
-scp "$artefacts_wd/$fpga_payload" "$remote_user@$remote_host:./$fpga_payload" > \
-							/dev/null
+if [ -n "$bl33_img" ]; then
+	scp "$artefacts_wd/$bl33_img" "$remote_user@$remote_host:." > /dev/null
+fi
+
+if [ -n "$initrd_img" ]; then
+	scp "$artefacts_wd/$initrd_img" "$remote_user@$remote_host:." > /dev/null
+fi
+
+if [ -n "$bootargs" ]; then
+	scp "$artefacts_wd/$bootargs_file" "$remote_user@$remote_host:." > /dev/null
+fi
+scp "$artefacts_wd/bl31.axf" "$remote_user@$remote_host:." > /dev/null
 
 # Copy the env and run scripts to the remote host.
 scp "$artefacts_wd/fpga_env.sh" "$remote_user@$remote_host:." > /dev/null
@@ -178,7 +205,12 @@
 
 echo "FPGA configuration options:"
 echo
-cat "$artefacts_wd/fpga_env.sh"
+while read conf_option; do
+	echo -e "\t$conf_option"
+done <$artefacts/fpga_env.sh
+if [ -n "$bootargs" ]; then
+echo -e "\tKernel bootargs: $bootargs"
+fi
 
 # For an automated run, export a known variable so that we can identify stale
 # processes spawned by Trusted Firmware CI by inspecting its environment.
@@ -194,7 +226,7 @@
 
 # Wait enough time for the UART to show up on the FPGA host so the connection
 # can be stablished.
-sleep 35
+sleep 65
 
 # If it's a test run, skip all the hoops and start a telnet connection to the FPGA.
 if upon "$test_run"; then
@@ -299,6 +331,8 @@
 	fi
 done
 
+ssh "$remote_user@$remote_host" "rm ./$fpga_run_script"
+
 cleanup
 
 if [ "$result" -eq 0 ]; then
diff --git a/tf_config/arm_fpga-default b/tf_config/arm_fpga-default
index 533cc4c..1264655 100644
--- a/tf_config/arm_fpga-default
+++ b/tf_config/arm_fpga-default
@@ -1,4 +1,2 @@
 CROSS_COMPILE=aarch64-none-elf-
-FPGA_PRELOADED_DTB_BASE=0x88000000
 PLAT=arm_fpga
-PRELOADED_BL33_BASE=0x82080000