ci: add FIP compilation and test for STM32MP157C-EV1 board

The U-Boot binary and DT (v2024.04) are stored in a dedicated download
folder [1], use them to build the FIP binary.
This generated FIP is used to test the STM32MP157C-EV1 board.
Pass fip.bin & tf-a-stm32mp157c-ev1.stm32 through rep_bin.tar.bz2.
There are also bootfs and rootfs that will allow booting until Linux
kernel console.
The flashlayout is also updated with metadata_v2.bin file. It will
allow testing PSA_FWU_SUPPORT in the future, as TF-A now only
support version 2 of metadata.

[1] https://downloads.trustedfirmware.org/tf-a/stm32mp157c-ev1/

Signed-off-by: Arthur She <arthur.she@linaro.org>
Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: Ia768509efd1775c66832fda180a6f2bb668474d2
diff --git a/run_config/stm32mp1-sp_min.bl2 b/run_config/stm32mp1-sp_min.bl2
index ba7d37d..166bcb1 100644
--- a/run_config/stm32mp1-sp_min.bl2
+++ b/run_config/stm32mp1-sp_min.bl2
@@ -1,12 +1,26 @@
 #!/usr/bin/env bash
 #
 # Copyright (c) 2023 Arm Limited. All rights reserved.
+# Copyright (c) 2024, STMicroelectronics - All Rights Reserved
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
 
+
+post_tf_build() {
+	url="${tfa_downloads}/stm32mp157c-ev1/u-boot-nodtb.bin" filename="u-boot-nodtb.bin" fetch_and_archive
+	url="${tfa_downloads}/stm32mp157c-ev1/u-boot.dtb"  filename="u-boot.dtb" fetch_and_archive
+	build_fip BL33="$archive/u-boot-nodtb.bin" BL33_CFG="$archive/u-boot.dtb"
+}
+
 post_tf_archive() {
+    rep_bin="$workspace/rep_bin.tar.bz2"
+
     payload_type="sp_min_bl2" gen_sp_min_bl2_sd_layout
+
+    # pack tf-a-stm32mp157c-ev1.stm32 and fip.bin
+    tar -jcf $rep_bin -C $archive tf-a-stm32mp157c-ev1.stm32 fip.bin
+    archive_file "$rep_bin"
 }
 
 generate_lava_job() {
diff --git a/script/gen_stm32mp1_test_yaml.sh b/script/gen_stm32mp1_test_yaml.sh
index 445c9e7..c720134 100755
--- a/script/gen_stm32mp1_test_yaml.sh
+++ b/script/gen_stm32mp1_test_yaml.sh
@@ -1,6 +1,7 @@
 #!/usr/bin/env bash
 #
 # Copyright (c) 2023 Arm Limited. All rights reserved.
+# Copyright (c) 2024, STMicroelectronics - All Rights Reserved
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -22,7 +23,7 @@
 case "$payload_type" in
     sp_min_bl2)
         job_name="SP_min BL2"
-        rep_bin_file="tf-a-stm32mp157c-ev1.stm32"
+        rep_bin_file="rep_bin.tar.bz2"
         ;;
 esac
 
diff --git a/script/lava-templates/stm32mp1-boot-test.yaml b/script/lava-templates/stm32mp1-boot-test.yaml
index 9717084..1520138 100644
--- a/script/lava-templates/stm32mp1-boot-test.yaml
+++ b/script/lava-templates/stm32mp1-boot-test.yaml
@@ -16,7 +16,7 @@
     to: flasher
     images:
       tarball:
-        url: https://images.validation.linaro.org/people.linaro.org/~theodore.grey/NEWSTM/stm32mp1_ev1_tarball.tar.gz
+        url: https://images.validation.linaro.org/people.linaro.org/~arthur.she/images/stm32mp15/rootfs_test/stm32mp157c-ev1-filesystem.tar.bz2
       layout:
         url: $flash_layout_url
       rep_bin:
@@ -31,6 +31,6 @@
       minutes: 10
     interactive:
     - name: int_1
-      prompts: ["Hit any key to stop autoboot"]
+      prompts: ["buildroot login"]
       script:
       - command:
diff --git a/stm32mp1_utils.sh b/stm32mp1_utils.sh
index 08839d5..dbcb50e 100644
--- a/stm32mp1_utils.sh
+++ b/stm32mp1_utils.sh
@@ -1,6 +1,7 @@
 #!/usr/bin/env bash
 #
-# Copyright (c) 2023 Arm Limited. All rights reserved.
+# Copyright (c) 2023-2024 Arm Limited. All rights reserved.
+# Copyright (c) 2024, STMicroelectronics - All Rights Reserved
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -19,11 +20,13 @@
 -	0x03	fip-boot	FIP	none	0x0	fip-stm32mp157c-ev1-trusted.bin
 P	0x04	fsbl1	Binary	mmc0	0x00004400	tf-a-stm32mp157c-ev1.stm32
 P	0x05	fsbl2	Binary	mmc0	0x00044400	tf-a-stm32mp157c-ev1.stm32
-P	0x06	metadata1	Binary	mmc0	0x00084400	metadata.bin
-P	0x07	metadata2	Binary	mmc0	0x000C4400	metadata.bin
-P	0x08	fip-a	FIP	mmc0	0x00104400	fip-stm32mp157c-ev1-trusted.bin
+P	0x06	metadata1	Binary	mmc0	0x00084400	metadata_v2.bin
+P	0x07	metadata2	Binary	mmc0	0x000C4400	metadata_v2.bin
+P	0x08	fip-a	FIP	mmc0	0x00104400	fip.bin
 PE	0x09	fip-b	FIP	mmc0	0x00504400	none
 PE	0x0A	u-boot-env	Binary	mmc0	0x00904400	none
+P	0x10	bootfs	System	mmc0	0x00984400	bootfs.ext2
+P	0x12	rootfs	FileSystem	mmc0	0x02984400	rootfs.ext2
 EOF
         ;;
     esac