blob: 26fc82a9b21441738255142c73826bc77c661375 [file] [log] [blame]
Leonardo Sandoval9dfdd1b2020-08-06 17:08:11 -05001#!/usr/bin/env bash
Fathi Boudra422bf772019-12-02 11:10:16 +02002#
Rupinderjit Singh385f17d2022-07-18 20:28:10 +01003# Copyright (c) 2020-2022, Arm Limited. All rights reserved.
Fathi Boudra422bf772019-12-02 11:10:16 +02004#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
8set -u
9
10bl1_addr="${bl1_addr:-0x0}"
Zelalem219df412020-05-17 19:21:20 -050011bl31_addr="${bl31_addr:-0x04001000}"
Zelalem1b874612020-08-04 18:08:18 -050012bl32_addr="${bl32_addr:-0x04003000}"
Fathi Boudra422bf772019-12-02 11:10:16 +020013bl33_addr="${bl33_addr:-0x88000000}"
14dtb_addr="${dtb_addr:-0x82000000}"
15fip_addr="${fip_addr:-0x08000000}"
16initrd_addr="${initrd_addr:-0x84000000}"
17kernel_addr="${kernel_addr:-0x80080000}"
18el3_payload_addr="${el3_payload_addr:-0x80000000}"
19
Manish Pandey3c435582020-07-15 12:14:26 +010020# SPM requires following addresses for RESET_TO_BL31 case
21spm_addr="${spm_addr:-0x6000000}"
22spmc_manifest_addr="${spmc_addr:-0x0403f000}"
23sp1_addr="${sp1_addr:-0x7000000}"
24sp2_addr="${sp2_addr:-0x7100000}"
Olivier Deprez0b834092020-08-21 08:36:01 +020025sp3_addr="${sp3_addr:-0x7200000}"
Olivier Deprezdd9ed332021-07-02 12:07:17 +020026sp4_addr="${sp4_addr:-0x7600000}"
Manish Pandey1e7be852020-11-09 16:04:48 +000027# SPM out directories
28export spm_secure_out_dir="${spm_secure_out_dir:-secure_aem_v8a_fvp_clang}"
29export spm_non_secure_out_dir="${spm_non_secure_out_dir:-aem_v8a_fvp_clang}"
Manish Pandey3c435582020-07-15 12:14:26 +010030
Fathi Boudra422bf772019-12-02 11:10:16 +020031ns_bl1u_addr="${ns_bl1u_addr:-0x0beb8000}"
32fwu_fip_addr="${fwu_fip_addr:-0x08400000}"
33backup_fip_addr="${backup_fip_addr:-0x09000000}"
34romlib_addr="${romlib_addr:-0x03ff2000}"
35
36uboot32_fip_url="$linaro_release/fvp32-latest-busybox-uboot/fip.bin"
37
Alexei Fedorove405cc32020-09-30 18:13:55 +010038rootfs_url="$linaro_release/lt-vexpress64-openembedded_minimal-armv8-gcc-5.2_20170127-761.img.gz"
Fathi Boudra422bf772019-12-02 11:10:16 +020039
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -050040# Default FVP model variables
Leonardo Sandovale1460662021-05-27 16:05:38 -050041default_model_dtb="dtb.bin"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -050042
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060043# FVP containers and model paths
laurenw-armafdc3bc2022-09-14 15:31:42 -050044fvp_arm_std_library_11_16="fvp:fvp_arm_std_library_${model_version_11_16}_${model_build_11_16};/opt/model/FVP_ARM_Std_Library/FVP_Base"
45fvp_arm_std_library_11_17="fvp:fvp_arm_std_library_${model_version_11_17}_${model_build_11_17};/opt/model/FVP_ARM_Std_Library/FVP_Base"
Maksims Svecovs284a50d2021-11-02 11:09:47 +000046fvp_arm_std_library="fvp:fvp_arm_std_library_${model_version}_${model_build};/opt/model/FVP_ARM_Std_Library/FVP_Base"
laurenw-armafdc3bc2022-09-14 15:31:42 -050047fvp_base_aemva="fvp:fvp_base_aemva_${model_version}_${model_build};/opt/model/FVP_Base_AEMvA/models/${model_flavour}"
laurenw-armf414aba2021-04-26 15:58:56 -050048fvp_base_revc_2xaemva="fvp:fvp_base_revc-2xaemva_${model_version}_${model_build};/opt/model/Base_RevC_AEMvA_pkg/models/${model_flavour}"
laurenw-armafdc3bc2022-09-14 15:31:42 -050049fvp_base_aemv8a_gic600ae="fvp:fvp_base_aemv8a-gic600ae_${model_version_11_17}_${model_build_11_17};/opt/model/FVP_Base_AEMv8A-GIC600AE_pkg/models/${model_flavour_11_17}"
50fvp_base_aemv8a_aemv8a_aemv8a_aemv8a_ccn502="fvp:fvp_base_aemv8a-aemv8a-aemv8a-aemv8a-ccn502_${model_version_11_17}_${model_build_11_17};/opt/model/FVP_Base_AEMv8A-AEMv8A-AEMv8A-AEMv8A-CCN502_pkg/models/${model_flavour_11_17}"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060051foundation_platform="fvp:foundation_platform_${model_version}_${model_build};/opt/model/Foundation_Platformpkg/models/${model_flavour}"
johpow01936638d2021-11-08 18:22:24 -060052fvp_base_aemv8r="fvp:fvp_base_aemv8r_${model_version}_${model_build};/opt/model/AEMv8R_base_pkg/models/${model_flavour}"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -050053
Manish V Badarkhec3ee53f2022-11-04 10:07:19 +000054# CSS model list
55fvp_morello="fvp:fvp_morello_0.11_33;/opt/model/FVP_Morello/models/Linux64_GCC-6.4"
56fvp_rd_e1_edge="fvp:fvp_rd_e1_edge_11.17_29;/opt/model/FVP_RD_E1_edge/models/${model_flavour}"
57fvp_rd_n1_edge="fvp:fvp_rd_n1_edge_11.17_29;/opt/model/FVP_RD_N1_edge/models/${model_flavour}"
58fvp_rd_v1="fvp:fvp_rd_v1_11.17_29;/opt/model/FVP_RD_V1/models/${model_flavour}"
59fvp_tc0="fvp:fvp_tc0_11.17_18;/opt/model/FVP_TC0/models/${model_flavour}"
60fvp_tc1="fvp:fvp_tc1_11.17_33;/opt/model/FVP_TC1/models/${model_flavour}"
61fvp_tc2="fvp:fvp_tc2_11.18_28;/opt/model/FVP_TC2/models/${model_flavour}"
62
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060063# FVP associate array, run_config are keys and fvp container parameters are the values
64# Container parameters syntax: <model name>;<model dir>;<model bin>
65# FIXMEs: fix those ;;; values with real values
66
67declare -A fvp_models
68fvp_models=(
Manish V Badarkhe253a1602022-11-09 09:22:44 +000069[base-aemv8a-quad]="${fvp_base_aemv8a_aemv8a_aemv8a_aemv8a_ccn502};FVP_Base_AEMv8A-AEMv8A-AEMv8A-AEMv8A-CCN502"
laurenw-armafdc3bc2022-09-14 15:31:42 -050070[base-aemv8a-revb]="${fvp_arm_std_library};FVP_Base_AEMvA-AEMvA"
71[base-aemv8a-latest-revb]="${fvp_arm_std_library};FVP_Base_AEMvA-AEMvA"
Manish V Badarkhe253a1602022-11-09 09:22:44 +000072[base-aemva]="${fvp_base_aemva};FVP_Base_AEMvA"
73[base-aemv8a-gic600ae]="${fvp_base_aemv8a_gic600ae};FVP_Base_AEMv8A-GIC600AE"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060074[foundationv8]="${foundation_platform};Foundation_Platform"
laurenw-armf414aba2021-04-26 15:58:56 -050075[base-aemv8a]="${fvp_base_revc_2xaemva};FVP_Base_RevC-2xAEMvA"
Olivier Deprez038596c2024-04-18 12:25:42 +020076[cortex-a32x4]="${fvp_arm_std_library};FVP_Base_Cortex-A32x4"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060077[cortex-a35x4]="${fvp_arm_std_library};FVP_Base_Cortex-A35x4"
78[cortex-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A53x4"
laurenw-armafdc3bc2022-09-14 15:31:42 -050079[cortex-a55x4]="${fvp_arm_std_library};FVP_Base_Cortex-A55"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060080[cortex-a57x1-a53x1]="${fvp_arm_std_library};FVP_Base_Cortex-A57x1-A53x1"
81[cortex-a57x2-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x2-A53x4"
82[cortex-a57x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4"
83[cortex-a57x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4-A53x4"
laurenw-armafdc3bc2022-09-14 15:31:42 -050084[cortex-a65aex8]="${fvp_arm_std_library};FVP_Base_Cortex-A65AE"
85[cortex-a65x4]="${fvp_arm_std_library};FVP_Base_Cortex-A65"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060086[cortex-a72x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72x4"
87[cortex-a72x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72x4-A53x4"
88[cortex-a73x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4"
89[cortex-a73x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4-A53x4"
laurenw-armafdc3bc2022-09-14 15:31:42 -050090[cortex-a75x4]="${fvp_arm_std_library};FVP_Base_Cortex-A75"
91[cortex-a76aex4]="${fvp_arm_std_library};FVP_Base_Cortex-A76AE"
92[cortex-a76aex2]="${fvp_arm_std_library};FVP_Base_Cortex-A76AE"
93[cortex-a76x4]="${fvp_arm_std_library};FVP_Base_Cortex-A76"
94[cortex-a77x4]="${fvp_arm_std_library};FVP_Base_Cortex-A77"
95[cortex-a78x4]="${fvp_arm_std_library};FVP_Base_Cortex-A78"
96[cortex-a78cx4]="${fvp_arm_std_library};FVP_Base_Cortex-A78C"
97[cortex-x2]="${fvp_arm_std_library_11_17};FVP_Base_Cortex-X2x4"
98[cortex-a710]="${fvp_arm_std_library_11_17};FVP_Base_Cortex-A710x4"
99[neoverse_e1x1]="${fvp_arm_std_library};FVP_Base_Neoverse-E1"
100[neoverse_e1x2]="${fvp_arm_std_library};FVP_Base_Neoverse-E1"
101[neoverse_e1x4]="${fvp_arm_std_library};FVP_Base_Neoverse-E1"
102[neoverse_n1]="${fvp_arm_std_library};FVP_Base_Neoverse-N1"
103[neoverse_n2]="${fvp_arm_std_library_11_16};FVP_Base_Neoverse-N1x4"
104[neoverse-v1x4]="${fvp_arm_std_library};FVP_Base_Neoverse-V1"
Manish V Badarkhec3ee53f2022-11-04 10:07:19 +0000105[morello]="${fvp_morello};FVP_Morello"
106[css-rde1edge]="${fvp_rd_e1_edge};FVP_RD_E1_edge"
107[css-rdn1edgex2]="${fvp_rd_n1_edge};FVP_RD_N1_edge_dual"
108[css-rdv1]="${fvp_rd_v1};FVP_RD_V1"
109[tc0]="${fvp_tc0};FVP_TC0"
110[tc1]="${fvp_tc1};FVP_TC1"
111[tc2]="${fvp_tc2};FVP_TC2"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600112)
113
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500114
Fathi Boudra422bf772019-12-02 11:10:16 +0200115# FVP Kernel URLs
116declare -A fvp_kernels
117fvp_kernels=(
118[fvp-aarch32-zimage]="$linaro_release/fvp32-latest-busybox-uboot/Image"
119[fvp-busybox-uboot]="$linaro_release/fvp-latest-busybox-uboot/Image"
120[fvp-oe-uboot32]="$linaro_release/fvp32-latest-oe-uboot/Image"
121[fvp-oe-uboot]="$linaro_release/fvp-latest-oe-uboot/Image"
122[fvp-quad-busybox-uboot]="$tfa_downloads/quad_cluster/Image"
123)
124
Fathi Boudra422bf772019-12-02 11:10:16 +0200125# FVP initrd URLs
126declare -A fvp_initrd_urls
127fvp_initrd_urls=(
128[aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img"
Fathi Boudra422bf772019-12-02 11:10:16 +0200129[dummy-ramdisk]="$linaro_release/fvp-latest-oe-uboot/ramdisk.img"
130[dummy-ramdisk32]="$linaro_release/fvp32-latest-oe-uboot/ramdisk.img"
131[default]="$linaro_release/fvp-latest-busybox-uboot/ramdisk.img"
132)
133
Fathi Boudra422bf772019-12-02 11:10:16 +0200134get_optee_bin() {
Sandrine Bailleux25ff2942021-02-25 14:00:10 +0100135 url="$tfa_downloads/optee/tee.bin" \
136 saveas="bl32.bin" fetch_file
Fathi Boudra422bf772019-12-02 11:10:16 +0200137 archive_file "bl32.bin"
138}
139
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100140# For Measured Boot tests using a TA based on OPTEE, it is necessary to use a
141# specific build rather than the default one generated by Jenkins.
142get_ftpm_optee_bin() {
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100143 url="$tfa_downloads/ftpm/optee/tee-header_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100144 saveas="bl32.bin" fetch_file
145 archive_file "bl32.bin"
146
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100147 url="$tfa_downloads/ftpm/optee/tee-pager_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100148 saveas="bl32_extra1.bin" fetch_file
149 archive_file "bl32_extra1.bin"
150
Leonardo Sandovalda5f78d2021-03-18 11:09:30 -0600151 # tee-pageable_v2.bin is just a empty file, named as bl32_extra2.bin,
152 # so just create the file
153 touch "bl32_extra2.bin"
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100154 archive_file "bl32_extra2.bin"
155}
156
Fathi Boudra422bf772019-12-02 11:10:16 +0200157get_uboot32_bin() {
158 local tmpdir="$(mktempdir)"
159
160 pushd "$tmpdir"
161 extract_fip "$uboot32_fip_url"
162 mv "nt-fw.bin" "uboot.bin"
163 archive_file "uboot.bin"
164 popd
165}
166
167get_uboot_bin() {
168 local uboot_url="$linaro_release/fvp-latest-busybox-uboot/bl33-uboot.bin"
169
170 url="$uboot_url" saveas="uboot.bin" fetch_file
171 archive_file "uboot.bin"
172}
173
174get_uefi_bin() {
Zelalem219df412020-05-17 19:21:20 -0500175 uefi_downloads="${uefi_downloads:-http://files.oss.arm.com/downloads/uefi}"
176 uefi_ci_bin_url="${uefi_ci_bin_url:-$uefi_downloads/Artifacts/Linux/github/fvp/static/DEBUG_GCC5/FVP_AARCH64_EFI.fd}"
Fathi Boudra422bf772019-12-02 11:10:16 +0200177
178 url=$uefi_ci_bin_url saveas="uefi.bin" fetch_file
179 archive_file "uefi.bin"
180}
181
182get_kernel() {
183 local kernel_type="${kernel_type:?}"
184 local url="${fvp_kernels[$kernel_type]}"
185
186 url="${url:?}" saveas="kernel.bin" fetch_file
187 archive_file "kernel.bin"
188}
189
190get_initrd() {
191 local initrd_type="${initrd_type:?}"
192 local url="${fvp_initrd_urls[$initrd_type]}"
193
194 url="${url:?}" saveas="initrd.bin" fetch_file
195 archive_file "initrd.bin"
196}
197
198get_dtb() {
199 local dtb_type="${dtb_type:?}"
200 local dtb_url
201 local dtb_saveas="$workspace/dtb.bin"
Zelalem219df412020-05-17 19:21:20 -0500202 local cc="$(get_tf_opt CROSS_COMPILE)"
203 local pp_flags="-P -nostdinc -undef -x assembler-with-cpp"
Fathi Boudra422bf772019-12-02 11:10:16 +0200204
205 case "$dtb_type" in
206 "fvp-base-quad-cluster-gicv3-psci")
207 # Get the quad-cluster FDT from pdsw area
208 dtb_url="$tfa_downloads/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb"
209 url="$dtb_url" saveas="$dtb_saveas" fetch_file
210 ;;
Fathi Boudra422bf772019-12-02 11:10:16 +0200211 *)
Zelalem219df412020-05-17 19:21:20 -0500212 # Preprocess DTS file
213 ${cc}gcc -E ${pp_flags} -I"$tf_root/fdts" -I"$tf_root/include" \
214 -o "$workspace/${dtb_type}.pre.dts" \
215 "$tf_root/fdts/${dtb_type}.dts"
216 # Generate DTB file from DTS
Fathi Boudra422bf772019-12-02 11:10:16 +0200217 dtc -I dts -O dtb \
Zelalem219df412020-05-17 19:21:20 -0500218 "$workspace/${dtb_type}.pre.dts" -o "$dtb_saveas"
Fathi Boudra422bf772019-12-02 11:10:16 +0200219 esac
220
221 archive_file "$dtb_saveas"
222}
223
224get_rootfs() {
225 local tmpdir
226 local fs_base="$(echo $(basename $rootfs_url) | sed 's/\.gz$//')"
227 local cached="$project_filer/ci-files/$fs_base"
228
229 if upon "$jenkins_run" && [ -f "$cached" ]; then
230 # Job workspace is limited in size, and the root file system is
231 # quite large. This means, parallel runs of root file system
232 # tests could fail. So, for Jenkins runs, copy and use the root
233 # file system image from the $CI_SCRATCH location
234 local private="$CI_SCRATCH/$JOB_NAME-$BUILD_NUMBER"
235 mkdir -p "$private"
236 rm -f "$private/rootfs.bin"
237 url="$cached" saveas="$private/rootfs.bin" fetch_file
238 ln -s "$private/rootfs.bin" "$archive/rootfs.bin"
239 return
240 fi
241
242 tmpdir="$(mktempdir)"
243 pushd "$tmpdir"
244 url="$rootfs_url" saveas="rootfs.bin" fetch_file
245
246 # Possibly, the filesystem image we just downloaded is compressed.
247 # Decompress it if required.
248 if file "rootfs.bin" | grep -iq 'gzip compressed data'; then
249 echo "Decompressing root file system image rootfs.bin ..."
250 gunzip --stdout "rootfs.bin" > uncompressed_fs.bin
251 mv uncompressed_fs.bin "rootfs.bin"
252 fi
253
254 archive_file "rootfs.bin"
255 popd
256}
257
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200258fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i"
259
Fathi Boudra422bf772019-12-02 11:10:16 +0200260fvp_romlib_runtime() {
261 local tmpdir="$(mktempdir)"
262
263 # Save BL1 and romlib binaries from original build
264 mv "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" "$tmpdir/romlib.bin"
265 mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin"
266
267 # Patch index file
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200268 cp "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" "$fvp_romlib_jmptbl_backup"
269 sed -i '/fdt/ s/.$/&\ patch/' ${tf_root:?}/plat/arm/board/fvp/jmptbl.i
Fathi Boudra422bf772019-12-02 11:10:16 +0200270
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200271 # Rebuild with patched file
272 echo "Building patched romlib:"
273 build_tf
Fathi Boudra422bf772019-12-02 11:10:16 +0200274
Fathi Boudra422bf772019-12-02 11:10:16 +0200275 # Retrieve original BL1 and romlib binaries
276 mv "$tmpdir/romlib.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin"
277 mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin"
278}
279
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200280fvp_romlib_cleanup() {
281 # Restore original index
282 mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
283}
284
285
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500286fvp_gen_bin_url() {
287 local bin_mode="${bin_mode:?}"
288 local bin="${1:?}"
289
290 if upon "$jenkins_run"; then
291 echo "$jenkins_url/job/$JOB_NAME/$BUILD_NUMBER/artifact/artefacts/$bin_mode/$bin"
292 else
293 echo "file://$workspace/artefacts/$bin_mode/$bin"
294 fi
295}
296
Chris Kayfbbf1322022-10-05 13:13:32 +0100297# Generates the template for YAML-based LAVA job definitions from a file
298# corresponding to the currently-selected payload, e.g.:
299#
300# - `lava-templates/fvp-linux.yaml`
301# - `lava-templates/fvp-tftf.yaml`
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500302gen_fvp_yaml_template() {
Chris Kayfbbf1322022-10-05 13:13:32 +0100303 local yaml_template_file="${workspace}/fvp_template.yaml"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500304
Chris Kayc9523b12022-10-10 18:32:20 +0100305 cp "${ci_root}/script/lava-templates/fvp-${payload_type:?}.yaml" \
306 "${yaml_template_file}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500307
Chris Kayfbbf1322022-10-05 13:13:32 +0100308 archive_file "${yaml_template_file}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500309}
310
Chris Kayc9523b12022-10-10 18:32:20 +0100311# Generates the final YAML-based LAVA job definition from a template file.
312#
313# The job definition template is expanded with visibility of all variables that
314# are available from within the function, including those with local scope.
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500315gen_fvp_yaml() {
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600316 local model="${model:?}"
317
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500318 local yaml_template_file="$workspace/fvp_template.yaml"
319 local yaml_file="$workspace/fvp.yaml"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500320 local yaml_job_file="$workspace/job.yaml"
321 local lava_model_params="$workspace/lava_model_params"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500322
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500323 # this function expects a template, quit if it is not present
324 if [ ! -f "$yaml_template_file" ]; then
Paul Sokolovskyf56d9d22023-01-24 18:33:58 +0700325 echo "warning: gen_fvp_yaml: template $yaml_template_file not available, skipping generating LAVA job"
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500326 return
327 fi
328
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600329 local model_params="${fvp_models[$model]}"
330 local model_name="$(echo "${model_params}" | awk -F ';' '{print $1}')"
331 local model_dir="$(echo "${model_params}" | awk -F ';' '{print $2}')"
332 local model_bin="$(echo "${model_params}" | awk -F ';' '{print $3}')"
333
334 # model params are required for correct yaml creation, quit if empty
335 if [ -z "${model_name}" ]; then
336 echo "FVP model param 'model_name' variable empty, yaml not produced"
337 return
338 elif [ -z "${model_dir}" ]; then
339 echo "FVP model param 'model_dir' variable empty, yaml not produced"
340 return
341 elif [ -z "${model_bin}" ]; then
342 echo "FVP model param 'model_bin' variable empty, yaml not produced"
343 return
344 fi
345
346 echo "FVP model params: model_name=$model_name model_dir=$model_dir model_bin=$model_bin"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500347
348 # optional parameters, defaults to globals
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500349 local model_dtb="${model_dtb:-$default_model_dtb}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500350
Chris Kayc9523b12022-10-10 18:32:20 +0100351 if [ -n "${GERRIT_CHANGE_NUMBER}" ]; then
352 local gerrit_url="https://review.trustedfirmware.org/c/${GERRIT_CHANGE_NUMBER}/${GERRIT_PATCHSET_NUMBER}"
353 elif [ -n "${GERRIT_REFSPEC}" ]; then
354 local gerrit_url=$(echo ${GERRIT_REFSPEC} |
355 awk -F/ '{print "https://review.trustedfirmware.org/c/" $4 "/" $5}')
356 fi
357
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500358 docker_registry="${docker_registry:-}"
359 docker_registry="$(docker_registry_append)"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500360 docker_name="${docker_registry}$model_name"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600361 prompt1='/ #'
362 prompt2='root@genericarmv8:~#'
363 version_string="\"Fast Models"' [^\\n]+'"\""
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500364
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500365 test_config="${TEST_CONFIG}"
366
Chris Kay4eb9ded2022-10-10 15:51:40 +0100367 declare -A artefact_filters=(
368 [backup_fip]="backup_fip.bin"
369 [bl1]="bl1.bin"
370 [bl2]="bl2.bin"
371 [bl31]="bl31.bin"
372 [bl32]="bl32.bin"
373 [busybox]="busybox.bin"
374 [cactus_primary]="cactus-primary.pkg"
375 [cactus_secondary]="cactus-secondary.pkg"
376 [cactus_tertiary]="cactus-tertiary.pkg"
377 [coverage_trace_plugin]="coverage_trace.so"
378 [dtb]="dtb.bin"
379 [el3_payload]="el3_payload.bin"
Manish V Badarkhedbb9cb12022-11-16 12:30:41 +0000380 [ete_trace]="libete-plugin.so"
381 [etm_trace]="ETMv4ExamplePlugin.so"
Chris Kay4eb9ded2022-10-10 15:51:40 +0100382 [fip_gpt]="fip_gpt.bin"
383 [fip]="fip.bin"
384 [fvp_spmc_manifest_dtb]="=fvp_spmc_manifest.dtb"
385 [fwu_fip]="fwu_fip.bin"
386 [generic_trace]="GenericTrace.so"
387 [hafnium]="hafnium.bin"
388 [image]="kernel.bin"
389 [ivy]="ivy.pkg"
390 [manifest_dtb]="=manifest.dtb"
Chris Kayfbdd0142022-11-08 12:24:30 +0000391 [mcp_fw]="mcp_fw.bin"
Manish V Badarkhe18c59782022-11-09 10:14:48 +0000392 [mcp_ram]="mcp_ram.bin"
Chris Kay4eb9ded2022-10-10 15:51:40 +0100393 [mcp_rom_hyphen]="mcp-rom.bin"
394 [mcp_rom]="mcp_rom.bin"
395 [ns_bl1u]="ns_bl1u.bin"
396 [ns_bl2u]="ns_bl2u.bin"
397 [ramdisk]="initrd.bin|initrd.img"
398 [romlib]="romlib.bin"
399 [rootfs]="rootfs.bin"
Manish V Badarkhe93093dd2022-11-09 10:29:27 +0000400 [rss_flash]="rss_flash.bin"
401 [rss_rom]="rss_rom.bin"
Chris Kayfbdd0142022-11-08 12:24:30 +0000402 [scp_fw]="scp_fw.bin"
Chris Kay4eb9ded2022-10-10 15:51:40 +0100403 [scp_ram_hyphen]="scp-ram.bin"
404 [scp_ram]="scp_ram.bin"
405 [scp_rom_hyphen]="scp-rom.bin"
406 [scp_rom]="scp_rom.bin"
407 [secure_hafnium]="secure_hafnium.bin"
408 [spm]="spm.bin"
409 [tftf]="tftf.bin"
410 [tmp]="tmp.bin"
411 [uboot]="uboot.bin"
412 )
413
Chris Kayc14743a2022-10-13 11:33:26 +0100414 declare -A artefact_urls=(
415 [backup_fip]="$(fvp_gen_bin_url backup_fip.bin)"
416 [bl1]="$(fvp_gen_bin_url bl1.bin)"
417 [bl2]="$(fvp_gen_bin_url bl2.bin)"
418 [bl31]="$(fvp_gen_bin_url bl31.bin)"
419 [bl32]="$(fvp_gen_bin_url bl32.bin)"
420 [busybox]="$(fvp_gen_bin_url busybox.bin.gz)"
421 [cactus_primary]="$(fvp_gen_bin_url cactus-primary.pkg)"
422 [cactus_secondary]="$(fvp_gen_bin_url cactus-secondary.pkg)"
423 [cactus_tertiary]="$(fvp_gen_bin_url cactus-tertiary.pkg)"
424 [coverage_trace_plugin]="${coverage_trace_plugin}"
425 [dtb]="$(fvp_gen_bin_url ${model_dtb})"
426 [el3_payload]="$(fvp_gen_bin_url el3_payload.bin)"
Manish V Badarkhedbb9cb12022-11-16 12:30:41 +0000427 [ete_trace]="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/libete-plugin.so"
428 [etm_trace]="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/ETMv4ExamplePlugin.so"
Chris Kayc14743a2022-10-13 11:33:26 +0100429 [fip]="$(fvp_gen_bin_url fip.bin)"
430 [fip_gpt]="$(fvp_gen_bin_url fip_gpt.bin)"
431 [fvp_spmc_manifest_dtb]="$(fvp_gen_bin_url fvp_spmc_manifest.dtb)"
432 [fwu_fip]="$(fvp_gen_bin_url fwu_fip.bin)"
433 [generic_trace]="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/GenericTrace.so"
434 [hafnium]="$(fvp_gen_bin_url hafnium.bin)"
435 [image]="$(fvp_gen_bin_url kernel.bin)"
436 [ivy]="$(fvp_gen_bin_url ivy.pkg)"
437 [manifest_dtb]="$(fvp_gen_bin_url manifest.dtb)"
Chris Kayfbdd0142022-11-08 12:24:30 +0000438 [mcp_fw]="$(fvp_gen_bin_url mcp_fw.bin)"
Manish V Badarkhe18c59782022-11-09 10:14:48 +0000439 [mcp_ram]="$(fvp_gen_bin_url mcp_ram.bin)"
Chris Kayc14743a2022-10-13 11:33:26 +0100440 [mcp_rom]="$(fvp_gen_bin_url mcp_rom.bin)"
441 [mcp_rom_hyphen]="$(fvp_gen_bin_url mcp-rom.bin)"
442 [ns_bl1u]="$(fvp_gen_bin_url ns_bl1u.bin)"
443 [ns_bl2u]="$(fvp_gen_bin_url ns_bl2u.bin)"
444 [ramdisk]="$(fvp_gen_bin_url initrd.bin)"
445 [romlib]="$(fvp_gen_bin_url romlib.bin)"
446 [rootfs]="$(fvp_gen_bin_url rootfs.bin.gz)"
Manish V Badarkhe93093dd2022-11-09 10:29:27 +0000447 [rss_flash]="$(fvp_gen_bin_url rss_flash.bin)"
448 [rss_rom]="$(fvp_gen_bin_url rss_rom.bin)"
Chris Kayc14743a2022-10-13 11:33:26 +0100449 [secure_hafnium]="$(fvp_gen_bin_url secure_hafnium.bin)"
Chris Kayfbdd0142022-11-08 12:24:30 +0000450 [scp_fw]="$(fvp_gen_bin_url scp_fw.bin)"
Chris Kayc14743a2022-10-13 11:33:26 +0100451 [scp_ram]="$(fvp_gen_bin_url scp_ram.bin)"
452 [scp_ram_hyphen]="$(fvp_gen_bin_url scp-ram.bin)"
453 [scp_rom]="$(fvp_gen_bin_url scp_rom.bin)"
454 [scp_rom_hyphen]="$(fvp_gen_bin_url scp-rom.bin)"
455 [spm]="$(fvp_gen_bin_url spm.bin)"
456 [tftf]="$(fvp_gen_bin_url tftf.bin)"
457 [tmp]="$(fvp_gen_bin_url tmp.bin)"
458 [uboot]="$(fvp_gen_bin_url uboot.bin)"
459 )
460
Chris Kay5d550d82022-10-12 17:20:31 +0100461 # In LAVA we don't provide the paths to the artefacts directly, but instead
462 # use macros of the form `{XYZ}`. This is a list of regular expression
463 # replacements to run on the model parameters file before we add them to the
464 # LAVA job definition.
465 declare -A artefact_macros=(
466 ["[= ]backup_fip.bin"]="={BACKUP_FIP}"
467 ["[= ]bl1.bin"]="={BL1}"
468 ["[= ]bl2.bin"]="={BL2}"
469 ["[= ]bl31.bin"]="={BL31}"
470 ["[= ]bl32.bin"]="={BL32}"
471 ["[= ]cactus-primary.pkg"]="={CACTUS_PRIMARY}"
472 ["[= ]cactus-secondary.pkg"]="={CACTUS_SECONDARY}"
473 ["[= ]cactus-tertiary.pkg"]="={CACTUS_TERTIARY}"
474 ["[= ].*coverage_trace.so"]="={COVERAGE_TRACE_PLUGIN}"
475 ["[= ]fvp_spmc_manifest.dtb"]="={FVP_SPMC_MANIFEST_DTB}"
476 ["[= ]busybox.bin"]="={BUSYBOX}"
477 ["[= ]dtb.bin"]="={DTB}"
478 ["[= ]el3_payload.bin"]="={EL3_PAYLOAD}"
Manish V Badarkhedbb9cb12022-11-16 12:30:41 +0000479 ["[= ].*libete-plugin.so"]="={ETE_TRACE}"
480 ["[= ].*ETMv4ExamplePlugin.so"]="={ETM_TRACE}"
Chris Kay5d550d82022-10-12 17:20:31 +0100481 ["[= ]fip_gpt.bin"]="={FIP_GPT}"
482 ["[= ]fwu_fip.bin"]="={FWU_FIP}"
483 ["[= ]fip.bin"]="={FIP}"
484 ["[= ].*GenericTrace.so"]="={GENERIC_TRACE}"
485 ["[= ].*/hafnium.bin"]="={HAFNIUM}"
486 ["[= ]kernel.bin"]="={IMAGE}"
487 ["[= ]ivy.pkg"]="={IVY}"
488 ["[= ]manifest.dtb"]="={MANIFEST_DTB}"
Chris Kayfbdd0142022-11-08 12:24:30 +0000489 ["[= ]mcp_fw.bin"]="={MCP_FW}"
Manish V Badarkhe18c59782022-11-09 10:14:48 +0000490 ["[= ]mcp_ram.bin"]="={MCP_RAM}"
Chris Kayef9cc802022-11-08 12:11:58 +0000491 ["[= ]mcp_rom.bin"]="={MCP_ROM}"
492 ["[= ]mcp-rom.bin"]="={MCP_ROM_HYPHEN}"
Chris Kay5d550d82022-10-12 17:20:31 +0100493 ["[= ]ns_bl1u.bin"]="={NS_BL1U}"
494 ["[= ]ns_bl2u.bin"]="={NS_BL2U}"
495 ["[= ]initrd.bin"]="={RAMDISK}"
496 ["[= ]initrd.img"]="={RAMDISK}"
497 ["[= ]romlib.bin"]="={ROMLIB}"
498 ["[= ]rootfs.bin"]="={ROOTFS}"
Manish V Badarkhe93093dd2022-11-09 10:29:27 +0000499 ["[= ]rss_flash.bin"]="={RSS_FLASH}"
500 ["[= ]rss_rom.bin"]="={RSS_ROM}"
Chris Kay5d550d82022-10-12 17:20:31 +0100501 ["[= ].*/secure_hafnium.bin"]="={SECURE_HAFNIUM}"
Chris Kayfbdd0142022-11-08 12:24:30 +0000502 ["[= ]scp_fw.bin"]="={SCP_FW}"
Chris Kay5d550d82022-10-12 17:20:31 +0100503 ["[= ]scp_ram.bin"]="={SCP_RAM}"
504 ["[= ]scp-ram.bin"]="={SCP_RAM_HYPHEN}"
505 ["[= ]scp_rom.bin"]="={SCP_ROM}"
506 ["[= ]scp-rom.bin"]="={SCP_ROM_HYPHEN}"
507 ["[= ]spm.bin"]="={SPM}"
508 ["[= ]tftf.bin"]="={TFTF}"
509 ["[= ].*/tmp.bin"]="={TMP}"
510 ["[= ]uboot.bin"]="={UBOOT}"
511 )
512
Chris Kay4eb9ded2022-10-10 15:51:40 +0100513 declare -a artefacts=()
514
515 for artefact in "${!artefact_filters[@]}"; do
516 if grep -E -q "${artefact_filters[${artefact}]}" "${archive}/model_params"; then
517 artefacts+=("${artefact}")
518 fi
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600519 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500520
Chris Kayc92d9fc2022-10-13 11:19:27 +0100521 # Derive LAVA model parameters from the non-LAVA ones
522 cp "${archive}/model_params" "${lava_model_params}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600523
Chris Kayf07d3392022-10-26 15:42:48 +0100524 # Ensure braces in the FVP model parameters are not accidentally interpreted
525 # as LAVA macros.
526 sed -i -e 's/{/{{/g' "${lava_model_params}"
527 sed -i -e 's/}/}}/g' "${lava_model_params}"
528
Chris Kay5d550d82022-10-12 17:20:31 +0100529 # LAVA expects FVP binary paths as macros, i.e. `{X}` instead of `x.bin`, so
530 # replace the file paths in our pre-generated model parameters.
531 for regex in "${!artefact_macros[@]}"; do
532 sed -i -e "s!${regex}!${artefact_macros[${regex}]}!" \
533 "${lava_model_params}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600534 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500535
Chris Kayc92d9fc2022-10-13 11:19:27 +0100536 # Read boot arguments into an array so that the job template file can
537 # iterate over them.
538 readarray -t boot_arguments < "${lava_model_params}"
539
Chris Kay04b70192022-10-19 17:03:37 +0100540 # Source runtime environment variables now so that they are accessible from
541 # the LAVA job template.
542 local run_root="${archive}/run"
543 local run_env="${run_root}/env"
544
545 if [ -f "${run_env}" ]; then
546 source "${run_env}"
547 fi
548
Chris Kayc92d9fc2022-10-13 11:19:27 +0100549 # Generate the LAVA job definition, minus the test expectations
550 expand_template "${yaml_template_file}" > "${yaml_file}"
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500551
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500552 # Append expect commands into the job definition through test-interactive commands
553 gen_fvp_yaml_expect >> "$yaml_file"
554
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600555 # create job.yaml
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500556 cp "$yaml_file" "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500557
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600558 # archive both yamls
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500559 archive_file "$yaml_file"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500560 archive_file "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500561}
562
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500563gen_fvp_yaml_expect() {
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500564 # Loop through all uarts expect files
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500565 for expect_file in $(find $run_root -name expect); do
Chris Kay04b70192022-10-19 17:03:37 +0100566 local uart_number=$(basename "$(dirname ${expect_file})")
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500567
Chris Kay04b70192022-10-19 17:03:37 +0100568 # Only handle the primary UART through LAVA. The remaining UARTs are
569 # validated after LAVA returns by the post-expect script.
Chris Kaya75c0a62022-11-17 18:53:50 +0000570 if [ "${uart_number:?}" != "uart$(get_primary_uart "${archive}")" ]; then
Chris Kay04b70192022-10-19 17:03:37 +0100571 continue
572 fi
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500573
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500574 # Array containing "interactive" or "monitor" expect strings and populated during run config execution.
575 # Interactive expect scripts are converted into LAVA Interactive Test Actions (see
576 # https://tf.validation.linaro.org/static/docs/v2/interactive.html#writing-tests-interactive) and
577 # monitor expect scripts are converted into LAVA Monitor Test Actions (see
578 # https://validation.linaro.org/static/docs/v2/actions-test.html#monitor)
579 #
580 # Interactive Expect strings have the format 'i;<prompt>;<succeses>;<failures>;<commands>'
581 # where multiple successes or failures or commands are separated by @
582 #
583 # Monitor Expect strings have the format 'm;<start>;<end>;<patterns>'
584 # where multiple patterns are separated by @
585 #
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500586 expect_string=()
587
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500588 # Get the real name of the expect file
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500589 expect_file=$(cat $expect_file)
590
591 # Source the run_config enviroment variables
592 env=$run_root/$uart_number/env
593 if [ -e $env ]; then
594 source $env
595 fi
596
597 # Get all expect strings
Chris Kay047af3e2022-09-30 17:10:28 +0100598 expect_dir="${ci_root}/expect-lava"
599 expect_file="${expect_dir}/${expect_file}"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500600
Chris Kay047af3e2022-09-30 17:10:28 +0100601 # Allow the expectations to be provided directly in LAVA's job YAML
602 # format, rather than converting it from a pseudo-Expect Bash script in
603 # the block below.
604 if [ -f "${expect_file/.exp/.yaml}" ]; then
605 pushd "${expect_dir}"
606 expand_template "${expect_file/.exp/.yaml}"
607 popd
608
609 continue
610 else
611 source "${expect_file}"
612 fi
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500613
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500614 if [ ${#expect_string[@]} -gt 0 ]; then
615
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500616 # expect loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500617 for key in "${!expect_string[@]}"; do
618
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500619 # single raw expect string
620 es="${expect_string[${key}]}"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500621
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500622 # action type: either m or i
623 action="$(echo "${es}" | awk -F ';' '{print $1}')"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500624
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500625 if [ "${action}" = "m" ]; then
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500626
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500627 start="$(echo "${es}" | awk -F ';' '{print $2}')"
628 end="$(echo "${es}" | awk -F ';' '{print $3}')"
629 patterns="$(echo "${es}" | awk -F ';' '{print $4}')"
630
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500631 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500632- test:
633 monitors:
634 - name: tests
635 start: '${start}'
636 end: '${end}'
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500637EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500638 # Patterns are separated by '@'
639 OLD_IFS=$IFS; IFS=$'@'
640 for p in ${patterns}; do
641 cat << EOF
642 pattern: '$p'
643EOF
644 done
645 IFS=$OLD_IFS
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500646 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500647 fixupdict:
648 PASS: pass
649 FAIL: fail
650EOF
651 fi # end of monitor action
652
653 if [ "${action}" = "i" ]; then
654
655 prompts="$(echo "${es}" | awk -F ';' '{print $2}')"
656 successes="$(echo "${es}" | awk -F ';' '{print $3}')"
657 failures="$(echo "${es}" | awk -F ';' '{print $4}')"
658 commands="$(echo "${es}" | awk -F ';' '{print $5}')"
659
660 cat << EOF
661- test:
662 interactive:
663EOF
664 OLD_IFS=$IFS; IFS=$'@'
665
666 if [[ -n "${prompts}" && -n "${successes}" && -n "${failures}" ]]; then
667 cat << EOF
668 - name: interactive_${uart_number}_${key}
669 prompts: ['${prompts}']
670 script:
671EOF
672 if [ -z "${commands}" ]; then
673 cat <<EOF
674 - name: interactive_command_${uart_number}_${key}
675 command:
676EOF
677 else
678 for c in ${commands}; do
679 cat <<EOF
680 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300681 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500682EOF
683 done
684 fi
685 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500686 successes:
687EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500688 for s in ${successes}; do
689 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500690 - message: '$s'
691EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500692 done
693 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500694 failures:
695EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500696 for f in ${failures}; do
697 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500698 - message: '$f'
699EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500700 done
Paul Sokolovskya8eaebc2023-05-15 23:13:00 +0300701 cat << EOF
702 exception: JobError
703EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500704 elif [[ -n "${prompts}" && -n "${successes}" ]]; then
705 cat << EOF
706 - name: interactive_${uart_number}_${key}
707 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500708 script:
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500709EOF
710
711 if [ -z "${commands}" ]; then
712 cat <<EOF
713 - name: interactive_command_${uart_number}_${key}
714 command:
715EOF
716 else
717 for c in ${commands}; do
718 cat <<EOF
719 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300720 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500721EOF
722 done
723 fi
724 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500725 successes:
726EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500727 for s in ${successes}; do
728 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500729 - message: '$s'
730EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500731 done
732
733 elif [[ -n "${prompts}" && -n "${failures}" ]]; then
734 cat << EOF
735 - name: interactive_${uart_number}_${key}
736 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500737 script:
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500738EOF
739 if [ -z "${commands}" ]; then
740 cat <<EOF
741 - name: interactive_command_${uart_number}_${key}
742 command:
743EOF
744 else
745 for c in ${commands}; do
746 cat <<EOF
747 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300748 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500749EOF
750 done
751 fi
752 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500753 failures:
754EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500755 for f in ${failures}; do
756 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500757 - message: '$f'
758EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500759 done
Paul Sokolovskya8eaebc2023-05-15 23:13:00 +0300760 cat << EOF
761 exception: JobError
762EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500763 else
764 cat << EOF
765 - name: interactive_${uart_number}_${key}
766 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500767 script:
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500768EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500769 if [ -z "${commands}" ]; then
770 cat <<EOF
771 - name: interactive_command_${uart_number}_${key}
772 command:
773EOF
774 else
775 for c in ${commands}; do
776 cat <<EOF
777 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300778 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500779EOF
780 done
781 fi
782 fi
783
784 IFS=$OLD_IFS
785 fi # end of interactive action
786
787 done # end of expect loop
788
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500789 fi
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500790 done # end of uart loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500791}
792
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500793docker_registry_append() {
794 # if docker_registry is empty, just use local docker registry
795 [ -z "$docker_registry" ] && return
796
797 local last=-1
798 local last_char="${docker_registry:last}"
799
800 if [ "$last_char" != '/' ]; then
801 docker_registry="${docker_registry}/";
802 fi
803 echo "$docker_registry"
804}
805
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000806# generate GPT image and archive it
807gen_gpt_bin() {
808 raw_image="fip_gpt.bin"
809 img_uuid="FB90808A-BA9A-4D42-B9A2-A7A937144AEE"
810 img_bank_uuid=`uuidgen`
811 disk_uuid=`uuidgen`
812 bin="${1:?}"
813
814 # maximum FIP size 2MB
815 fip_max_size=2097152
816 start_sector=34
817 sector_size=512
818 num_sectors=$(($fip_max_size/$sector_size))
819 bin_size=$(stat -c %s $bin)
820
821 if [[ $fip_max_size -lt $bin_size ]]
822 then
Manish V Badarkhe3640b062022-11-16 11:36:36 +0000823 echo "FIP binary ($bin_size bytes) larger than max partition 1" \
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000824 "size ($fip_max_size byte)"
825 return
826 fi
827
828 # create raw 5MB image
829 dd if=/dev/zero of=$raw_image bs=5M count=1
830
831 # create GPT image
832 sgdisk -a 1 -U $disk_uuid -n 1:$start_sector:+$num_sectors \
833 -c 1:FIP_A -t 1:$img_uuid $raw_image -u $img_bank_uuid
834
835 echo "write binary $bin at sector $start_sector"
836 dd if=$bin of=$raw_image bs=$sector_size seek=$start_sector \
837 count=$num_sectors conv=notrunc
838
839 archive_file "fip_gpt.bin"
840}
841
Fathi Boudra422bf772019-12-02 11:10:16 +0200842set +u