ci(n1sdp): refactor fip fragment for specificity
The ``n1sdp-fip`` fragment builds the fip image with UEFI. Replace the
fragment to target this specific use case as we also want to generate
fip images with other NS workloads i.e. TFTF. Move parts of the code for
creating a fip image with xCP firmware to a generic location so it may
be used by other fragments.
Signed-off-by: Harrison Mutai <harrison.mutai@arm.com>
Change-Id: I37433e32f1bc235e4c524ceed5730b0bc4c63ddd
diff --git a/group/scp-boot-tests/n1sdp,n1sdp-tbb:n1sdp-linux-fip-firmware b/group/scp-boot-tests/n1sdp,n1sdp-tbb:n1sdp-linux-fip.uefi-firmware
similarity index 100%
rename from group/scp-boot-tests/n1sdp,n1sdp-tbb:n1sdp-linux-fip-firmware
rename to group/scp-boot-tests/n1sdp,n1sdp-tbb:n1sdp-linux-fip.uefi-firmware
diff --git a/group/tf-l3-boot-tests-n1sdp/n1sdp-tbb:n1sdp-linux-fip-firmware-debug b/group/tf-l3-boot-tests-n1sdp/n1sdp-tbb:n1sdp-linux-fip.uefi-firmware-debug
similarity index 100%
rename from group/tf-l3-boot-tests-n1sdp/n1sdp-tbb:n1sdp-linux-fip-firmware-debug
rename to group/tf-l3-boot-tests-n1sdp/n1sdp-tbb:n1sdp-linux-fip.uefi-firmware-debug
diff --git a/lava_utils.sh b/lava_utils.sh
index 7040454..39fbb8e 100644
--- a/lava_utils.sh
+++ b/lava_utils.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
-# Copyright (c) 2019-2022, Arm Limited. All rights reserved.
+# Copyright (c) 2023, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -12,10 +12,12 @@
# Bash doesn't have array values, we have to create references to the
# array of artefacts and their urls.
- declare -n artefacts="$1"
- declare -n artefact_urls="$2"
+ declare -n artefacts="${1-null}"
+ declare -n artefact_urls="${2-null}"
- readarray -t boot_arguments < "${lava_model_params}"
+ if [ -f "${lava_model_params}" ]; then
+ readarray -t boot_arguments < "${lava_model_params}"
+ fi
# Source runtime environment variables now so that they are accessible from
# the LAVA job template.
diff --git a/n1sdp_utils.sh b/n1sdp_utils.sh
index 0f88c21..f0c196a 100644
--- a/n1sdp_utils.sh
+++ b/n1sdp_utils.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
-# Copyright (c) 2021-2022 Arm Limited. All rights reserved.
+# Copyright (c) 2021-2023 Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -16,7 +16,30 @@
archive_file "n1sdp-board-firmware.zip"
}
-gen_recovery_image_n1sdp() {
+fetch_prebuilt_fw_images() {
+ url="$n1sdp_prebuilts/n1sdp-board-firmware.zip" filename="n1sdp-board-firmware.zip" \
+ fetch_and_archive
+
+ #Fetch pre-built SCP/MCP binaries if they haven't been built
+ if [ ! -f "$archive/mcp_rom.bin" ]; then
+ url="$scp_mcp_prebuilts/mcp_romfw.bin" filename="mcp_rom.bin" \
+ fetch_and_archive
+ fi
+ if [ ! -f "$archive/scp_rom.bin" ]; then
+ url="$scp_mcp_prebuilts/scp_romfw.bin" filename="scp_rom.bin" \
+ fetch_and_archive
+ fi
+ if [ ! -f "$archive/scp_ram.bin" ]; then
+ url="$scp_mcp_prebuilts/scp_ramfw.bin" filename="scp_ram.bin" \
+ fetch_and_archive
+ fi
+ if [ ! -f "$archive/mcp_ram.bin" ]; then
+ url="$scp_mcp_prebuilts/mcp_ramfw.bin" filename="mcp_ram.bin" \
+ fetch_and_archive
+ fi
+}
+
+gen_recovery_image() {
local zip_dir="$workspace/$mode/n1sdp-board-firmware_primary"
local zip_file="${zip_dir}.zip"
@@ -24,26 +47,46 @@
extract_tarball "$archive/n1sdp-board-firmware.zip" "$zip_dir"
+ scp_uuid="cfacc2c4-15e8-4668-82be-430a38fad705"
+ mcp_uuid="54464222-a4cf-4bf8-b1b6-cee7dade539e"
+
+ # Create FIP for SCP
+ "$fiptool" create --blob \
+ uuid=$scp_uuid,file=$tf_build_root/n1sdp/$bin_mode/bl1.bin \
+ --scp-fw "$archive/scp_ram.bin" "scp_fw.bin"
+
+ archive_file "scp_fw.bin"
+
+ # Create FIP for MCP, this needs fixed uuid for now
+ "$fiptool" create --blob \
+ uuid=$mcp_uuid,file="$archive/mcp_ram.bin" "mcp_fw.bin"
+
+ archive_file "mcp_fw.bin"
+
cp -Rp --no-preserve=ownership "$archive/mcp_fw.bin" "$zip_dir/SOFTWARE"
cp -Rp --no-preserve=ownership "$archive/mcp_rom.bin" "$zip_dir/SOFTWARE"
cp -Rp --no-preserve=ownership "$archive/scp_fw.bin" "$zip_dir/SOFTWARE"
cp -Rp --no-preserve=ownership "$archive/scp_rom.bin" "$zip_dir/SOFTWARE"
cp -Rp --no-preserve=ownership "$archive/fip.bin" "$zip_dir/SOFTWARE"
- (cd "$zip_dir" && zip -rq "$zip_file" -- *)
+ (cd "$zip_dir" && zip -rq "$zip_file" -x \.* -- *)
archive_file "$zip_file"
}
gen_n1sdp_yaml() {
- local yaml_file="$workspace/n1sdp.yaml"
- local job_file="$workspace/job.yaml"
- local payload_type="${payload_type:?}"
+ yaml_template_file="$workspace/n1sdp_template.yaml"
+ yaml_file="$workspace/n1sdp.yaml"
+ yaml_job_file="$workspace/job.yaml"
- bin_mode="$mode" \
- "$ci_root/script/gen_n1sdp_${payload_type}_yaml.sh" > "$yaml_file"
+ # this function expects a template, quit if it is not present
+ if [ ! -f "$yaml_template_file" ]; then
+ return
+ fi
- cp "$yaml_file" "$job_file"
- archive_file "$yaml_file"
- archive_file "$job_file"
+ yaml_template_file="$yaml_template_file" \
+ yaml_file="$yaml_file" \
+ yaml_job_file="$yaml_job_file" \
+ recovery_img_url="$(gen_bin_url n1sdp-board-firmware_primary.zip)" \
+ gen_lava_job_def
}
diff --git a/run_config/n1sdp-fip b/run_config/n1sdp-fip
deleted file mode 100644
index 948bd02..0000000
--- a/run_config/n1sdp-fip
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/usr/bin/env bash
-#
-# Copyright (c) 2021-2023 Arm Limited. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
-#
-
-post_tf_build() {
- #Fetch pre-built SCP/MCP binaries if they haven't been built
- if [ ! -f "$archive/mcp_rom.bin" ]; then
- url="$scp_mcp_prebuilts/mcp_romfw.bin" saveas="mcp_rom.bin" fetch_file
- archive_file "mcp_rom.bin"
- fi
- if [ ! -f "$archive/scp_rom.bin" ]; then
- url="$scp_mcp_prebuilts/scp_romfw.bin" saveas="scp_rom.bin" fetch_file
- archive_file "scp_rom.bin"
- fi
- if [ ! -f "$archive/scp_ram.bin" ]; then
- url="$scp_mcp_prebuilts/scp_ramfw.bin" saveas="scp_ram.bin" fetch_file
- archive_file "scp_ram.bin"
- fi
- if [ ! -f "$archive/mcp_ram.bin" ]; then
- url="$scp_mcp_prebuilts/mcp_ramfw.bin" saveas="mcp_ram.bin" fetch_file
- archive_file "mcp_ram.bin"
- fi
-
- # Create FIP for SCP
- "$fiptool" create --blob uuid=cfacc2c4-15e8-4668-82be-430a38fad705,file="$tf_root/build/n1sdp/$bin_mode/bl1.bin" --scp-fw "$archive/scp_ram.bin" "scp_fw.bin"
- archive_file "scp_fw.bin"
-
- # Create FIP for MCP, this needs fixed uuid for now
- "$fiptool" create --blob uuid=54464222-a4cf-4bf8-b1b6-cee7dade539e,file="$archive/mcp_ram.bin" "mcp_fw.bin"
- archive_file "mcp_fw.bin"
-
- # Fetch BL33 [uefi.bin] for N1SDP
- url="$n1sdp_prebuilts/uefi.bin" filename="uefi.bin" fetch_and_archive
-
- # Create FIP for BL2, BL31, and BL33
- build_fip BL31="$bl31" BL2="$bl2" BL33="$archive/uefi.bin"
-
-}
diff --git a/run_config/n1sdp-fip.uefi b/run_config/n1sdp-fip.uefi
new file mode 100644
index 0000000..4849238
--- /dev/null
+++ b/run_config/n1sdp-fip.uefi
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2023 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+post_tf_build() {
+ # Fetch BL33 [uefi.bin] for N1SDP
+ url="$n1sdp_prebuilts/uefi.bin" filename="uefi.bin" fetch_and_archive
+
+ # Create FIP for BL2, BL31, and BL33
+ build_fip BL31="$bl31" BL2="$bl2" BL33="$archive/uefi.bin"
+}
diff --git a/run_config/n1sdp-firmware b/run_config/n1sdp-firmware
index 02bcf3a..e7c1a40 100644
--- a/run_config/n1sdp-firmware
+++ b/run_config/n1sdp-firmware
@@ -1,10 +1,14 @@
#!/usr/bin/env bash
#
-# Copyright (c) 2021 Arm Limited. All rights reserved.
+# Copyright (c) 2021-2023 Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
fetch_tf_resource() {
- n1sdp_firmware_bin_url="$n1sdp_prebuilts/n1sdp-board-firmware.zip" get_n1sdp_firmware
+ fetch_prebuilt_fw_images
+}
+
+post_fetch_tf_resource() {
+ gen_recovery_image
}
diff --git a/run_config/n1sdp-linux b/run_config/n1sdp-linux
index b50417a..364982d 100644
--- a/run_config/n1sdp-linux
+++ b/run_config/n1sdp-linux
@@ -1,11 +1,11 @@
#!/usr/bin/env bash
#
-# Copyright (c) 2021 Arm Limited. All rights reserved.
+# Copyright (c) 2021-2023 Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
-post_fetch_tf_resource() {
- gen_recovery_image_n1sdp "$archive/n1sdp-board-firmware.zip"
- payload_type="linux" gen_n1sdp_yaml
+generate_lava_job(){
+ target="n1sdp" payload_type="linux" gen_yaml_template
+ gen_n1sdp_yaml
}