plat(juno): use generic image fetching functions

Some generic functions have been provided for fetching prebuilt images -
use these for Juno runs.

Signed-off-by: Harrison Mutai <harrison.mutai@arm.com>
Change-Id: I77c1a0e3336ecdbbdba88078b8ee6e03dc760b0f
diff --git a/juno_utils.sh b/juno_utils.sh
index 743e9d5..744baad 100644
--- a/juno_utils.sh
+++ b/juno_utils.sh
@@ -30,41 +30,6 @@
 juno_rootfs_url="${juno_rootfs_url:-$linaro_release/linaro-image-minimal-genericarmv8-20170127-888.rootfs.tar.gz}"
 juno32_rootfs_url="${juno32_rootfs_url:-$linaro_release/linaro-image-alip-genericarmv7a-20150710-336.rootfs.tar.gz}"
 
-get_optee_bin() {
-	local tmpdir="$(mktempdir)"
-
-	pushd "$tmpdir"
-	extract_fip "$optee_fip_url"
-	mv "tos-fw.bin" "bl32.bin"
-	archive_file "bl32.bin"
-	popd
-}
-
-get_scp_bl2_bin() {
-	url="$scp_bl2_url" saveas="scp_bl2.bin" fetch_file
-	archive_file "scp_bl2.bin"
-}
-
-get_psci_reset2_scp_bl2_bin() {
-	url="$psci_reset2_scp_bl2_url" saveas="scp_bl2.bin" fetch_file
-	archive_file "scp_bl2.bin"
-}
-
-get_uboot32_bin() {
-	local tmpdir="$(mktempdir)"
-
-	pushd "$tmpdir"
-	extract_fip "$uboot32_fip_url"
-	mv "nt-fw.bin" "uboot.bin"
-	archive_file "uboot.bin"
-	popd
-}
-
-get_uboot_bin() {
-	url="$uboot_bl33_url" saveas="uboot.bin" fetch_file
-	archive_file "uboot.bin"
-}
-
 get_ml_uboot_bin() {
 	url="$ml_uboot_bl33_url" saveas="uboot.bin" fetch_file
 	archive_file "uboot.bin"
diff --git a/run_config/juno-linux.optee b/run_config/juno-linux.optee
index 84f9b47..485220b 100644
--- a/run_config/juno-linux.optee
+++ b/run_config/juno-linux.optee
@@ -6,9 +6,11 @@
 #
 
 post_tf_build() {
-	get_scp_bl2_bin
+	url="${scp_bl2_url}" filename="scp_bl2.bin" fetch_and_archive
 	get_ml_uboot_bin
-	get_optee_bin
+	url="${optee_fip_url}" image="tos-fw.bin" output_name="bl32.bin" \
+		get_boot_image_from_fip
+
 	build_fip BL33="$archive/uboot.bin" BL32="$archive/bl32.bin" SCP_BL2="$archive/scp_bl2.bin"
 }
 
diff --git a/run_config/juno-linux.reboot b/run_config/juno-linux.reboot
index 2a56373..42adc22 100644
--- a/run_config/juno-linux.reboot
+++ b/run_config/juno-linux.reboot
@@ -6,8 +6,8 @@
 #
 
 post_tf_build() {
-	get_scp_bl2_bin
-	get_uboot_bin
+	url="${scp_bl2_url}" filename="scp_bl2.bin" fetch_and_archive
+	url="${uboot_bl33_url}" filename="uboot.bin" fetch_and_archive
 	build_fip BL33="$archive/uboot.bin" SCP_BL2="$archive/scp_bl2.bin"
 }
 
diff --git a/run_config/juno-linux.reboot+aarch32 b/run_config/juno-linux.reboot+aarch32
index 1c1614b..be30e2e 100644
--- a/run_config/juno-linux.reboot+aarch32
+++ b/run_config/juno-linux.reboot+aarch32
@@ -6,8 +6,9 @@
 #
 
 post_tf_build() {
-	get_scp_bl2_bin
-	get_uboot32_bin
+	url="${scp_bl2_url}" filename="scp_bl2.bin" fetch_and_archive
+	url="${uboot32_fip_url}" image="nt-fw.bin" output_name="uboot.bin" \
+	 get_boot_image_from_fip
 
 	# Building FIP for this config requries a BL32 built in AArch32, but
 	# we'll only build that later. An appropriate BL32 image must be updated
diff --git a/run_config/juno-linux.uboot b/run_config/juno-linux.uboot
index 38ddb69..a6ceba0 100644
--- a/run_config/juno-linux.uboot
+++ b/run_config/juno-linux.uboot
@@ -6,7 +6,7 @@
 #
 
 post_tf_build() {
-	get_scp_bl2_bin
+	url="${scp_bl2_url}" filename="scp_bl2.bin" fetch_and_archive
 	get_ml_uboot_bin
 	build_fip BL33="$archive/uboot.bin" SCP_BL2="$archive/scp_bl2.bin"
 }
diff --git a/run_config/juno-linux.uboot+aarch32 b/run_config/juno-linux.uboot+aarch32
index 86050da..cb704b1 100644
--- a/run_config/juno-linux.uboot+aarch32
+++ b/run_config/juno-linux.uboot+aarch32
@@ -6,8 +6,9 @@
 #
 
 post_tf_build() {
-	get_scp_bl2_bin
-	get_uboot32_bin
+	url="${scp_bl2_url}" filename="scp_bl2.bin" fetch_and_archive
+	url="${uboot32_fip_url}" image="nt-fw.bin" output_name="uboot.bin" \
+	 get_boot_image_from_fip
 
 	# Building FIP for this config requries a BL32 built in AArch32, but
 	# we'll only build that later. An appropriate BL32 image must be updated
diff --git a/run_config/juno-tftf b/run_config/juno-tftf
index 7be7909..771027f 100644
--- a/run_config/juno-tftf
+++ b/run_config/juno-tftf
@@ -6,7 +6,7 @@
 #
 
 post_tf_build() {
-	get_scp_bl2_bin
+	url="${scp_bl2_url}" filename="scp_bl2.bin" fetch_and_archive
 	build_fip BL33="$archive/tftf.bin" SCP_BL2="$archive/scp_bl2.bin"
 }
 
diff --git a/run_config/juno-tftf+aarch32 b/run_config/juno-tftf+aarch32
index cfeb176..8f4a25d 100644
--- a/run_config/juno-tftf+aarch32
+++ b/run_config/juno-tftf+aarch32
@@ -6,7 +6,7 @@
 #
 
 post_tf_build() {
-	get_scp_bl2_bin
+	url="${scp_bl2_url}" filename="scp_bl2.bin" fetch_and_archive
 
 	# Building FIP for this config requires a BL32 built in AArch32, but
 	# we'll only build that later. For now, provide a dummy file; we'll
diff --git a/run_config/juno-tftf+aarch32.reboot b/run_config/juno-tftf+aarch32.reboot
index 334e338..e749505 100644
--- a/run_config/juno-tftf+aarch32.reboot
+++ b/run_config/juno-tftf+aarch32.reboot
@@ -6,7 +6,7 @@
 #
 
 post_tf_build() {
-	get_psci_reset2_scp_bl2_bin
+	url="${psci_reset2_scp_bl2_url}" filename="scp_bl2.bin" fetch_and_archive
 
 	# Building FIP for this config requires a BL32 built in AArch32, but
 	# we'll only build that later. For now, provide a dummy file; we'll
diff --git a/run_config/juno-tftf.fwu b/run_config/juno-tftf.fwu
index 8a958c3..86294bb 100644
--- a/run_config/juno-tftf.fwu
+++ b/run_config/juno-tftf.fwu
@@ -12,7 +12,7 @@
 
 # Perform FWU steps after all build products have been archived.
 post_tf_build() {
-	get_scp_bl2_bin
+	url="$scp_bl2_url" filename="scp_bl2.bin" fetch_and_archive
 	fip_targets="fip fwu_fip" build_fip \
 		BL33="$archive/tftf.bin" \
 		SCP_BL2="$archive/scp_bl2.bin" \
diff --git a/run_config/juno-tftf.reboot b/run_config/juno-tftf.reboot
index 4683c46..7351cd9 100644
--- a/run_config/juno-tftf.reboot
+++ b/run_config/juno-tftf.reboot
@@ -6,7 +6,7 @@
 #
 
 post_tf_build() {
-	get_psci_reset2_scp_bl2_bin
+	url="${psci_reset2_scp_bl2_url}" filename="scp_bl2.bin" fetch_and_archive
 	build_fip BL33="$archive/tftf.bin" SCP_BL2="$archive/scp_bl2.bin"
 }