feat(fwu): add a case to corrupt FWU-metadata
Add a case within the 'corrupt_gpt_bin' function specifically
tailored for corrupting FWU metadata. This case should be
adaptable for use in a test configuration aimed at
corrupting FWU metadata.
Signed-off-by: Manish V Badarkhe <Manish.Badarkhe@arm.com>
Change-Id: I18ff6abd2499bcdb1a32f88bc15f89c1fdd5efa0
diff --git a/expect-lava/backup_fwu_metadata.exp b/expect-lava/backup_fwu_metadata.exp
new file mode 100644
index 0000000..c242865
--- /dev/null
+++ b/expect-lava/backup_fwu_metadata.exp
@@ -0,0 +1,11 @@
+#
+# Copyright (c) 2024 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware Test Framework
+#
+
+expect_string+=('i;loading of FWU-Metadata failed, using Bkup-FWU-Metadata')
+
+source $ci_root/expect-lava/tftf.inc
diff --git a/expect/backup_fwu_metadata.exp b/expect/backup_fwu_metadata.exp
new file mode 100644
index 0000000..f18b616
--- /dev/null
+++ b/expect/backup_fwu_metadata.exp
@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2024 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware Test Framework
+#
+
+source [file join [file dirname [info script]] handle-arguments.inc]
+
+expect_string "loading of FWU-Metadata failed, using Bkup-FWU-Metadata"
+
+source [file join [file dirname [info script]] tftf.inc]
+
+exit_uart -1
diff --git a/fvp_utils.sh b/fvp_utils.sh
index 015a9b9..69bdc0a 100644
--- a/fvp_utils.sh
+++ b/fvp_utils.sh
@@ -595,6 +595,12 @@
seek=2
count=32
;;
+ "fwu-metadata")
+ # Get the LBA number for the FWU metadata. Size of which is always
+ # 1 sector (512 bytes).
+ seek=$(gdisk -l $bin | grep " FWU-Metadata$" | awk '{print $2}')
+ count=1
+ ;;
*)
echo "Invalid $corrupt_data. Use 'header', 'partition-entries'"
return 1
diff --git a/group/tftf-l2-fvp/fvp-tbb-mbedtls-romlib-fwu,fvp-default:fvp-tftf.fwu_metadata_backup_gpt-aemv8a.gpt-debug b/group/tftf-l2-fvp/fvp-tbb-mbedtls-romlib-fwu,fvp-default:fvp-tftf.fwu_metadata_backup_gpt-aemv8a.gpt-debug
new file mode 100644
index 0000000..e337bb0
--- /dev/null
+++ b/group/tftf-l2-fvp/fvp-tbb-mbedtls-romlib-fwu,fvp-default:fvp-tftf.fwu_metadata_backup_gpt-aemv8a.gpt-debug
@@ -0,0 +1,5 @@
+#
+# Copyright (c) 2024, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
diff --git a/run_config/fvp-tftf.fwu_metadata_backup_gpt b/run_config/fvp-tftf.fwu_metadata_backup_gpt
new file mode 100644
index 0000000..a37e6ec
--- /dev/null
+++ b/run_config/fvp-tftf.fwu_metadata_backup_gpt
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2024, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+post_tf_build() {
+ build_fip BL33="$archive/tftf.bin"
+}
+
+post_tf_archive() {
+ # Maximum FIP size is 2MiB = 2097152
+ gen_gpt_bin "$archive/fip.bin" 2097152
+
+ # Corrupt primary GPT entries to force TF-A to use the backup
+ corrupt_gpt_bin "$archive/fip_gpt.bin" "fwu-metadata"
+}
+
+generate_lava_job_template() {
+ uart="0" file="backup_fwu_metadata.exp" track_expect
+ uart="1" file="hold_uart.exp" track_expect
+
+ payload_type="tftf" gen_yaml_template
+}