STM32MP15X-EVAL: Enable LAVA test job submission

It runs SP-min BL2 test

Signed-off-by: Arthur She <arthur.she@linaro.org>
Change-Id: I8638fc5615eaf9da3feb5dea12e1a0ba80fb00a0
diff --git a/group/tf-l1-boot-tests-plat/stm32mp1-default:stm32mp1-sp_min.bl2 b/group/tf-l1-boot-tests-plat/stm32mp1-default:stm32mp1-sp_min.bl2
new file mode 100644
index 0000000..5515958
--- /dev/null
+++ b/group/tf-l1-boot-tests-plat/stm32mp1-default:stm32mp1-sp_min.bl2
@@ -0,0 +1,6 @@
+#
+# Copyright (c) 2023 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
diff --git a/run_config/stm32mp1-sp_min.bl2 b/run_config/stm32mp1-sp_min.bl2
new file mode 100644
index 0000000..ba7d37d
--- /dev/null
+++ b/run_config/stm32mp1-sp_min.bl2
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2023 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+post_tf_archive() {
+    payload_type="sp_min_bl2" gen_sp_min_bl2_sd_layout
+}
+
+generate_lava_job() {
+    payload_type="sp_min_bl2" gen_stm32mp1_yaml
+}
+
diff --git a/script/gen_stm32mp1_test_yaml.sh b/script/gen_stm32mp1_test_yaml.sh
new file mode 100755
index 0000000..445c9e7
--- /dev/null
+++ b/script/gen_stm32mp1_test_yaml.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2023 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+# Generate a YAML file in order to dispatch STM32MP1 runs on LAVA. Note that this
+# script would produce a meaningful output when run via. Jenkins
+#
+# $bin_mode must be set. This script outputs to STDOUT
+
+ci_root="$(readlink -f "$(dirname "$0")/..")"
+source "$ci_root/utils.sh"
+source "$ci_root/stm32mp1_utils.sh"
+payload_type=${payload_type:?}
+build_mode=$(echo $bin_mode | tr '[:lower:]' '[:upper:]')
+layout_file="FlashLayout_sdcard-stm32mp15x-eval.tsv"
+
+# There will be two types of tests, SP_min BL2 and OP-TEE
+# We do SP_min BL2 first
+case "$payload_type" in
+    sp_min_bl2)
+        job_name="SP_min BL2"
+        rep_bin_file="tf-a-stm32mp157c-ev1.stm32"
+        ;;
+esac
+
+if upon "$jenkins_run"; then
+    file_url="$jenkins_url/job/$JOB_NAME/$BUILD_NUMBER/artifact/artefacts/$bin_mode"
+else
+    file_url="file://$workspace/artefacts/$bin_mode"
+fi
+
+rep_bin_url="$file_url/$rep_bin_file"
+flash_layout_url="$file_url/$layout_file"
+
+expand_template "$(dirname "$0")/lava-templates/stm32mp1-boot-test.yaml"
diff --git a/script/lava-templates/stm32mp1-boot-test.yaml b/script/lava-templates/stm32mp1-boot-test.yaml
new file mode 100644
index 0000000..9717084
--- /dev/null
+++ b/script/lava-templates/stm32mp1-boot-test.yaml
@@ -0,0 +1,36 @@
+device_type: stm32mp15x-eval
+job_name: stm32mp15x-eval $job_name test - $build_mode
+timeouts:
+  job:
+    minutes: 35
+  action:
+    minutes: 15
+  connection:
+    minutes: 5
+priority: medium
+visibility: public
+actions:
+- deploy:
+    timeout:
+      minutes: 30
+    to: flasher
+    images:
+      tarball:
+        url: https://images.validation.linaro.org/people.linaro.org/~theodore.grey/NEWSTM/stm32mp1_ev1_tarball.tar.gz
+      layout:
+        url: $flash_layout_url
+      rep_bin:
+        url: $rep_bin_url
+    os: oe
+- boot:
+    timeout:
+        minutes: 6
+    method: minimal
+- test:
+    timeout:
+      minutes: 10
+    interactive:
+    - name: int_1
+      prompts: ["Hit any key to stop autoboot"]
+      script:
+      - command:
diff --git a/stm32mp1_utils.sh b/stm32mp1_utils.sh
new file mode 100644
index 0000000..0effc6f
--- /dev/null
+++ b/stm32mp1_utils.sh
@@ -0,0 +1,47 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2023 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+set -u
+
+gen_sp_min_bl2_sd_layout() {
+    local layout_file="FlashLayout_sdcard-stm32mp15x-eval.tsv"
+    local payload_type=${payload_type:?}
+
+    case "$payload_type" in
+        sp_min_bl2)
+            cat <<EOF > $layout_file
+#Opt	Id	Name	Type	IP	Offset	Binary
+-	0x01	fsbl-boot	Binary	none	0x0	tf-a-stm32mp157c-ev1-usb.stm32
+-	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
+PED	0x09	fip-b	FIP	mmc0	0x00504400	none
+PED	0x0A	u-boot-env	Binary	mmc0	0x00904400	none
+EOF
+        ;;
+    esac
+
+    archive_file "$layout_file"
+}
+
+gen_stm32mp1_yaml() {
+	local yaml_file="$workspace/stm32mp1.yaml"
+	local job_file="$workspace/job.yaml"
+	local payload_type="${payload_type:?}"
+
+	bin_mode="$mode" payload_type="$payload_type" \
+		"$ci_root/script/gen_stm32mp1_test_yaml.sh" > "$yaml_file"
+
+	cp "$yaml_file" "$job_file"
+	archive_file "$yaml_file"
+	archive_file "$job_file"
+}
+
+set +u