blob: 0213d933f732667358aefd3be90b60d53ba9e78b [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_17="fvp:fvp_arm_std_library_${model_version_11_17}_${model_build_11_17};/opt/model/FVP_ARM_Std_Library/FVP_Base"
Govindraj Rajae2415462024-06-04 14:50:28 -050045
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-armf414aba2021-04-26 15:58:56 -050047fvp_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 -050048fvp_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}"
Govindraj Rajae2415462024-06-04 14:50:28 -050049fvp_base_aemv8a_aemv8a_aemv8a_aemv8a_ccn502="fvp:fvp_base_aemv8a-aemv8a-aemv8a-aemv8a-ccn502_${model_version}_${model_build};/opt/model/FVP_Base_AEMv8A-AEMv8A-AEMv8A-AEMv8A-CCN502_pkg/models/${model_flavour}"
johpow01936638d2021-11-08 18:22:24 -060050fvp_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 -050051
Manish V Badarkhec3ee53f2022-11-04 10:07:19 +000052# CSS model list
53fvp_morello="fvp:fvp_morello_0.11_33;/opt/model/FVP_Morello/models/Linux64_GCC-6.4"
54fvp_rd_e1_edge="fvp:fvp_rd_e1_edge_11.17_29;/opt/model/FVP_RD_E1_edge/models/${model_flavour}"
55fvp_rd_n1_edge="fvp:fvp_rd_n1_edge_11.17_29;/opt/model/FVP_RD_N1_edge/models/${model_flavour}"
56fvp_rd_v1="fvp:fvp_rd_v1_11.17_29;/opt/model/FVP_RD_V1/models/${model_flavour}"
57fvp_tc0="fvp:fvp_tc0_11.17_18;/opt/model/FVP_TC0/models/${model_flavour}"
58fvp_tc1="fvp:fvp_tc1_11.17_33;/opt/model/FVP_TC1/models/${model_flavour}"
59fvp_tc2="fvp:fvp_tc2_11.18_28;/opt/model/FVP_TC2/models/${model_flavour}"
60
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060061# FVP associate array, run_config are keys and fvp container parameters are the values
62# Container parameters syntax: <model name>;<model dir>;<model bin>
63# FIXMEs: fix those ;;; values with real values
64
65declare -A fvp_models
66fvp_models=(
Manish V Badarkhe253a1602022-11-09 09:22:44 +000067[base-aemv8a-quad]="${fvp_base_aemv8a_aemv8a_aemv8a_aemv8a_ccn502};FVP_Base_AEMv8A-AEMv8A-AEMv8A-AEMv8A-CCN502"
laurenw-armafdc3bc2022-09-14 15:31:42 -050068[base-aemv8a-revb]="${fvp_arm_std_library};FVP_Base_AEMvA-AEMvA"
69[base-aemv8a-latest-revb]="${fvp_arm_std_library};FVP_Base_AEMvA-AEMvA"
Manish Pandeye5df9312024-03-11 09:58:53 +000070[base-aemva]="${fvp_base_revc_2xaemva};FVP_Base_RevC-2xAEMvA"
Manish V Badarkhe253a1602022-11-09 09:22:44 +000071[base-aemv8a-gic600ae]="${fvp_base_aemv8a_gic600ae};FVP_Base_AEMv8A-GIC600AE"
laurenw-armf414aba2021-04-26 15:58:56 -050072[base-aemv8a]="${fvp_base_revc_2xaemva};FVP_Base_RevC-2xAEMvA"
Olivier Deprez038596c2024-04-18 12:25:42 +020073[cortex-a32x4]="${fvp_arm_std_library};FVP_Base_Cortex-A32x4"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060074[cortex-a35x4]="${fvp_arm_std_library};FVP_Base_Cortex-A35x4"
75[cortex-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A53x4"
laurenw-armafdc3bc2022-09-14 15:31:42 -050076[cortex-a55x4]="${fvp_arm_std_library};FVP_Base_Cortex-A55"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060077[cortex-a57x1-a53x1]="${fvp_arm_std_library};FVP_Base_Cortex-A57x1-A53x1"
78[cortex-a57x2-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x2-A53x4"
79[cortex-a57x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4"
80[cortex-a57x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4-A53x4"
laurenw-armafdc3bc2022-09-14 15:31:42 -050081[cortex-a65aex8]="${fvp_arm_std_library};FVP_Base_Cortex-A65AE"
82[cortex-a65x4]="${fvp_arm_std_library};FVP_Base_Cortex-A65"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060083[cortex-a72x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72x4"
84[cortex-a72x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72x4-A53x4"
85[cortex-a73x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4"
86[cortex-a73x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4-A53x4"
laurenw-armafdc3bc2022-09-14 15:31:42 -050087[cortex-a75x4]="${fvp_arm_std_library};FVP_Base_Cortex-A75"
88[cortex-a76aex4]="${fvp_arm_std_library};FVP_Base_Cortex-A76AE"
89[cortex-a76aex2]="${fvp_arm_std_library};FVP_Base_Cortex-A76AE"
90[cortex-a76x4]="${fvp_arm_std_library};FVP_Base_Cortex-A76"
91[cortex-a77x4]="${fvp_arm_std_library};FVP_Base_Cortex-A77"
92[cortex-a78x4]="${fvp_arm_std_library};FVP_Base_Cortex-A78"
93[cortex-a78cx4]="${fvp_arm_std_library};FVP_Base_Cortex-A78C"
Govindraj Rajae2415462024-06-04 14:50:28 -050094[cortex-x2]="${fvp_arm_std_library};FVP_Base_Cortex-X2"
95[cortex-a710]="${fvp_arm_std_library};FVP_Base_Cortex-A710"
laurenw-armafdc3bc2022-09-14 15:31:42 -050096[neoverse_e1x1]="${fvp_arm_std_library};FVP_Base_Neoverse-E1"
97[neoverse_e1x2]="${fvp_arm_std_library};FVP_Base_Neoverse-E1"
98[neoverse_e1x4]="${fvp_arm_std_library};FVP_Base_Neoverse-E1"
99[neoverse_n1]="${fvp_arm_std_library};FVP_Base_Neoverse-N1"
Govindraj Rajae2415462024-06-04 14:50:28 -0500100[neoverse_n2]="${fvp_arm_std_library};FVP_Base_Neoverse-N2"
laurenw-armafdc3bc2022-09-14 15:31:42 -0500101[neoverse-v1x4]="${fvp_arm_std_library};FVP_Base_Neoverse-V1"
Manish V Badarkhec3ee53f2022-11-04 10:07:19 +0000102[morello]="${fvp_morello};FVP_Morello"
103[css-rde1edge]="${fvp_rd_e1_edge};FVP_RD_E1_edge"
104[css-rdn1edgex2]="${fvp_rd_n1_edge};FVP_RD_N1_edge_dual"
105[css-rdv1]="${fvp_rd_v1};FVP_RD_V1"
106[tc0]="${fvp_tc0};FVP_TC0"
107[tc1]="${fvp_tc1};FVP_TC1"
108[tc2]="${fvp_tc2};FVP_TC2"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600109)
110
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500111
Fathi Boudra422bf772019-12-02 11:10:16 +0200112# FVP Kernel URLs
113declare -A fvp_kernels
114fvp_kernels=(
115[fvp-aarch32-zimage]="$linaro_release/fvp32-latest-busybox-uboot/Image"
116[fvp-busybox-uboot]="$linaro_release/fvp-latest-busybox-uboot/Image"
117[fvp-oe-uboot32]="$linaro_release/fvp32-latest-oe-uboot/Image"
118[fvp-oe-uboot]="$linaro_release/fvp-latest-oe-uboot/Image"
119[fvp-quad-busybox-uboot]="$tfa_downloads/quad_cluster/Image"
120)
121
Fathi Boudra422bf772019-12-02 11:10:16 +0200122# FVP initrd URLs
123declare -A fvp_initrd_urls
124fvp_initrd_urls=(
125[aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img"
Fathi Boudra422bf772019-12-02 11:10:16 +0200126[dummy-ramdisk]="$linaro_release/fvp-latest-oe-uboot/ramdisk.img"
127[dummy-ramdisk32]="$linaro_release/fvp32-latest-oe-uboot/ramdisk.img"
128[default]="$linaro_release/fvp-latest-busybox-uboot/ramdisk.img"
129)
130
Fathi Boudra422bf772019-12-02 11:10:16 +0200131get_optee_bin() {
Sandrine Bailleux25ff2942021-02-25 14:00:10 +0100132 url="$tfa_downloads/optee/tee.bin" \
133 saveas="bl32.bin" fetch_file
Fathi Boudra422bf772019-12-02 11:10:16 +0200134 archive_file "bl32.bin"
135}
136
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100137# For Measured Boot tests using a TA based on OPTEE, it is necessary to use a
138# specific build rather than the default one generated by Jenkins.
139get_ftpm_optee_bin() {
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100140 url="$tfa_downloads/ftpm/optee/tee-header_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100141 saveas="bl32.bin" fetch_file
142 archive_file "bl32.bin"
143
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100144 url="$tfa_downloads/ftpm/optee/tee-pager_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100145 saveas="bl32_extra1.bin" fetch_file
146 archive_file "bl32_extra1.bin"
147
Leonardo Sandovalda5f78d2021-03-18 11:09:30 -0600148 # tee-pageable_v2.bin is just a empty file, named as bl32_extra2.bin,
149 # so just create the file
150 touch "bl32_extra2.bin"
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100151 archive_file "bl32_extra2.bin"
152}
153
Fathi Boudra422bf772019-12-02 11:10:16 +0200154get_uboot32_bin() {
155 local tmpdir="$(mktempdir)"
156
157 pushd "$tmpdir"
158 extract_fip "$uboot32_fip_url"
159 mv "nt-fw.bin" "uboot.bin"
160 archive_file "uboot.bin"
161 popd
162}
163
164get_uboot_bin() {
165 local uboot_url="$linaro_release/fvp-latest-busybox-uboot/bl33-uboot.bin"
166
167 url="$uboot_url" saveas="uboot.bin" fetch_file
168 archive_file "uboot.bin"
169}
170
171get_uefi_bin() {
Zelalem219df412020-05-17 19:21:20 -0500172 uefi_downloads="${uefi_downloads:-http://files.oss.arm.com/downloads/uefi}"
173 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 +0200174
175 url=$uefi_ci_bin_url saveas="uefi.bin" fetch_file
176 archive_file "uefi.bin"
177}
178
179get_kernel() {
180 local kernel_type="${kernel_type:?}"
181 local url="${fvp_kernels[$kernel_type]}"
182
183 url="${url:?}" saveas="kernel.bin" fetch_file
184 archive_file "kernel.bin"
185}
186
187get_initrd() {
188 local initrd_type="${initrd_type:?}"
189 local url="${fvp_initrd_urls[$initrd_type]}"
190
191 url="${url:?}" saveas="initrd.bin" fetch_file
192 archive_file "initrd.bin"
193}
194
195get_dtb() {
196 local dtb_type="${dtb_type:?}"
197 local dtb_url
198 local dtb_saveas="$workspace/dtb.bin"
Zelalem219df412020-05-17 19:21:20 -0500199 local cc="$(get_tf_opt CROSS_COMPILE)"
200 local pp_flags="-P -nostdinc -undef -x assembler-with-cpp"
Fathi Boudra422bf772019-12-02 11:10:16 +0200201
202 case "$dtb_type" in
203 "fvp-base-quad-cluster-gicv3-psci")
204 # Get the quad-cluster FDT from pdsw area
205 dtb_url="$tfa_downloads/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb"
206 url="$dtb_url" saveas="$dtb_saveas" fetch_file
207 ;;
Fathi Boudra422bf772019-12-02 11:10:16 +0200208 *)
Zelalem219df412020-05-17 19:21:20 -0500209 # Preprocess DTS file
210 ${cc}gcc -E ${pp_flags} -I"$tf_root/fdts" -I"$tf_root/include" \
211 -o "$workspace/${dtb_type}.pre.dts" \
212 "$tf_root/fdts/${dtb_type}.dts"
213 # Generate DTB file from DTS
Fathi Boudra422bf772019-12-02 11:10:16 +0200214 dtc -I dts -O dtb \
Zelalem219df412020-05-17 19:21:20 -0500215 "$workspace/${dtb_type}.pre.dts" -o "$dtb_saveas"
Fathi Boudra422bf772019-12-02 11:10:16 +0200216 esac
217
218 archive_file "$dtb_saveas"
219}
220
221get_rootfs() {
222 local tmpdir
223 local fs_base="$(echo $(basename $rootfs_url) | sed 's/\.gz$//')"
224 local cached="$project_filer/ci-files/$fs_base"
225
226 if upon "$jenkins_run" && [ -f "$cached" ]; then
227 # Job workspace is limited in size, and the root file system is
228 # quite large. This means, parallel runs of root file system
229 # tests could fail. So, for Jenkins runs, copy and use the root
230 # file system image from the $CI_SCRATCH location
231 local private="$CI_SCRATCH/$JOB_NAME-$BUILD_NUMBER"
232 mkdir -p "$private"
233 rm -f "$private/rootfs.bin"
234 url="$cached" saveas="$private/rootfs.bin" fetch_file
235 ln -s "$private/rootfs.bin" "$archive/rootfs.bin"
236 return
237 fi
238
239 tmpdir="$(mktempdir)"
240 pushd "$tmpdir"
241 url="$rootfs_url" saveas="rootfs.bin" fetch_file
242
243 # Possibly, the filesystem image we just downloaded is compressed.
244 # Decompress it if required.
245 if file "rootfs.bin" | grep -iq 'gzip compressed data'; then
246 echo "Decompressing root file system image rootfs.bin ..."
247 gunzip --stdout "rootfs.bin" > uncompressed_fs.bin
248 mv uncompressed_fs.bin "rootfs.bin"
249 fi
250
251 archive_file "rootfs.bin"
252 popd
253}
254
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200255fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i"
256
Fathi Boudra422bf772019-12-02 11:10:16 +0200257fvp_romlib_runtime() {
258 local tmpdir="$(mktempdir)"
259
260 # Save BL1 and romlib binaries from original build
261 mv "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" "$tmpdir/romlib.bin"
262 mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin"
263
264 # Patch index file
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200265 cp "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" "$fvp_romlib_jmptbl_backup"
266 sed -i '/fdt/ s/.$/&\ patch/' ${tf_root:?}/plat/arm/board/fvp/jmptbl.i
Fathi Boudra422bf772019-12-02 11:10:16 +0200267
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200268 # Rebuild with patched file
269 echo "Building patched romlib:"
270 build_tf
Fathi Boudra422bf772019-12-02 11:10:16 +0200271
Fathi Boudra422bf772019-12-02 11:10:16 +0200272 # Retrieve original BL1 and romlib binaries
273 mv "$tmpdir/romlib.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin"
274 mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin"
275}
276
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200277fvp_romlib_cleanup() {
278 # Restore original index
279 mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
280}
281
282
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500283fvp_gen_bin_url() {
284 local bin_mode="${bin_mode:?}"
285 local bin="${1:?}"
286
287 if upon "$jenkins_run"; then
288 echo "$jenkins_url/job/$JOB_NAME/$BUILD_NUMBER/artifact/artefacts/$bin_mode/$bin"
289 else
290 echo "file://$workspace/artefacts/$bin_mode/$bin"
291 fi
292}
293
Chris Kayfbbf1322022-10-05 13:13:32 +0100294# Generates the template for YAML-based LAVA job definitions from a file
295# corresponding to the currently-selected payload, e.g.:
296#
297# - `lava-templates/fvp-linux.yaml`
298# - `lava-templates/fvp-tftf.yaml`
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500299gen_fvp_yaml_template() {
Chris Kayfbbf1322022-10-05 13:13:32 +0100300 local yaml_template_file="${workspace}/fvp_template.yaml"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500301
Chris Kayc9523b12022-10-10 18:32:20 +0100302 cp "${ci_root}/script/lava-templates/fvp-${payload_type:?}.yaml" \
303 "${yaml_template_file}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500304
Chris Kayfbbf1322022-10-05 13:13:32 +0100305 archive_file "${yaml_template_file}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500306}
307
Chris Kayc9523b12022-10-10 18:32:20 +0100308# Generates the final YAML-based LAVA job definition from a template file.
309#
310# The job definition template is expanded with visibility of all variables that
311# are available from within the function, including those with local scope.
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500312gen_fvp_yaml() {
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600313 local model="${model:?}"
314
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500315 local yaml_template_file="$workspace/fvp_template.yaml"
316 local yaml_file="$workspace/fvp.yaml"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500317 local yaml_job_file="$workspace/job.yaml"
318 local lava_model_params="$workspace/lava_model_params"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500319
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500320 # this function expects a template, quit if it is not present
321 if [ ! -f "$yaml_template_file" ]; then
Paul Sokolovskyf56d9d22023-01-24 18:33:58 +0700322 echo "warning: gen_fvp_yaml: template $yaml_template_file not available, skipping generating LAVA job"
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500323 return
324 fi
325
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600326 local model_params="${fvp_models[$model]}"
327 local model_name="$(echo "${model_params}" | awk -F ';' '{print $1}')"
328 local model_dir="$(echo "${model_params}" | awk -F ';' '{print $2}')"
329 local model_bin="$(echo "${model_params}" | awk -F ';' '{print $3}')"
330
331 # model params are required for correct yaml creation, quit if empty
332 if [ -z "${model_name}" ]; then
333 echo "FVP model param 'model_name' variable empty, yaml not produced"
334 return
335 elif [ -z "${model_dir}" ]; then
336 echo "FVP model param 'model_dir' variable empty, yaml not produced"
337 return
338 elif [ -z "${model_bin}" ]; then
339 echo "FVP model param 'model_bin' variable empty, yaml not produced"
340 return
341 fi
342
343 echo "FVP model params: model_name=$model_name model_dir=$model_dir model_bin=$model_bin"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500344
345 # optional parameters, defaults to globals
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500346 local model_dtb="${model_dtb:-$default_model_dtb}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500347
Chris Kayc9523b12022-10-10 18:32:20 +0100348 if [ -n "${GERRIT_CHANGE_NUMBER}" ]; then
349 local gerrit_url="https://review.trustedfirmware.org/c/${GERRIT_CHANGE_NUMBER}/${GERRIT_PATCHSET_NUMBER}"
350 elif [ -n "${GERRIT_REFSPEC}" ]; then
351 local gerrit_url=$(echo ${GERRIT_REFSPEC} |
352 awk -F/ '{print "https://review.trustedfirmware.org/c/" $4 "/" $5}')
353 fi
354
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500355 docker_registry="${docker_registry:-}"
356 docker_registry="$(docker_registry_append)"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500357 docker_name="${docker_registry}$model_name"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600358 prompt1='/ #'
359 prompt2='root@genericarmv8:~#'
360 version_string="\"Fast Models"' [^\\n]+'"\""
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500361
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500362 test_config="${TEST_CONFIG}"
363
Chris Kay4eb9ded2022-10-10 15:51:40 +0100364 declare -A artefact_filters=(
365 [backup_fip]="backup_fip.bin"
366 [bl1]="bl1.bin"
367 [bl2]="bl2.bin"
368 [bl31]="bl31.bin"
369 [bl32]="bl32.bin"
370 [busybox]="busybox.bin"
371 [cactus_primary]="cactus-primary.pkg"
372 [cactus_secondary]="cactus-secondary.pkg"
373 [cactus_tertiary]="cactus-tertiary.pkg"
374 [coverage_trace_plugin]="coverage_trace.so"
375 [dtb]="dtb.bin"
376 [el3_payload]="el3_payload.bin"
Manish V Badarkhedbb9cb12022-11-16 12:30:41 +0000377 [ete_trace]="libete-plugin.so"
378 [etm_trace]="ETMv4ExamplePlugin.so"
Chris Kay4eb9ded2022-10-10 15:51:40 +0100379 [fip_gpt]="fip_gpt.bin"
380 [fip]="fip.bin"
381 [fvp_spmc_manifest_dtb]="=fvp_spmc_manifest.dtb"
382 [fwu_fip]="fwu_fip.bin"
383 [generic_trace]="GenericTrace.so"
384 [hafnium]="hafnium.bin"
385 [image]="kernel.bin"
386 [ivy]="ivy.pkg"
387 [manifest_dtb]="=manifest.dtb"
Chris Kayfbdd0142022-11-08 12:24:30 +0000388 [mcp_fw]="mcp_fw.bin"
Manish V Badarkhe18c59782022-11-09 10:14:48 +0000389 [mcp_ram]="mcp_ram.bin"
Chris Kay4eb9ded2022-10-10 15:51:40 +0100390 [mcp_rom_hyphen]="mcp-rom.bin"
391 [mcp_rom]="mcp_rom.bin"
392 [ns_bl1u]="ns_bl1u.bin"
393 [ns_bl2u]="ns_bl2u.bin"
394 [ramdisk]="initrd.bin|initrd.img"
395 [romlib]="romlib.bin"
396 [rootfs]="rootfs.bin"
Manish V Badarkhe93093dd2022-11-09 10:29:27 +0000397 [rss_flash]="rss_flash.bin"
398 [rss_rom]="rss_rom.bin"
Chris Kayfbdd0142022-11-08 12:24:30 +0000399 [scp_fw]="scp_fw.bin"
Chris Kay4eb9ded2022-10-10 15:51:40 +0100400 [scp_ram_hyphen]="scp-ram.bin"
401 [scp_ram]="scp_ram.bin"
402 [scp_rom_hyphen]="scp-rom.bin"
403 [scp_rom]="scp_rom.bin"
404 [secure_hafnium]="secure_hafnium.bin"
405 [spm]="spm.bin"
406 [tftf]="tftf.bin"
407 [tmp]="tmp.bin"
408 [uboot]="uboot.bin"
409 )
410
Chris Kayc14743a2022-10-13 11:33:26 +0100411 declare -A artefact_urls=(
412 [backup_fip]="$(fvp_gen_bin_url backup_fip.bin)"
413 [bl1]="$(fvp_gen_bin_url bl1.bin)"
414 [bl2]="$(fvp_gen_bin_url bl2.bin)"
415 [bl31]="$(fvp_gen_bin_url bl31.bin)"
416 [bl32]="$(fvp_gen_bin_url bl32.bin)"
417 [busybox]="$(fvp_gen_bin_url busybox.bin.gz)"
418 [cactus_primary]="$(fvp_gen_bin_url cactus-primary.pkg)"
419 [cactus_secondary]="$(fvp_gen_bin_url cactus-secondary.pkg)"
420 [cactus_tertiary]="$(fvp_gen_bin_url cactus-tertiary.pkg)"
421 [coverage_trace_plugin]="${coverage_trace_plugin}"
422 [dtb]="$(fvp_gen_bin_url ${model_dtb})"
423 [el3_payload]="$(fvp_gen_bin_url el3_payload.bin)"
Manish V Badarkhedbb9cb12022-11-16 12:30:41 +0000424 [ete_trace]="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/libete-plugin.so"
425 [etm_trace]="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/ETMv4ExamplePlugin.so"
Chris Kayc14743a2022-10-13 11:33:26 +0100426 [fip]="$(fvp_gen_bin_url fip.bin)"
427 [fip_gpt]="$(fvp_gen_bin_url fip_gpt.bin)"
428 [fvp_spmc_manifest_dtb]="$(fvp_gen_bin_url fvp_spmc_manifest.dtb)"
429 [fwu_fip]="$(fvp_gen_bin_url fwu_fip.bin)"
430 [generic_trace]="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/GenericTrace.so"
431 [hafnium]="$(fvp_gen_bin_url hafnium.bin)"
432 [image]="$(fvp_gen_bin_url kernel.bin)"
433 [ivy]="$(fvp_gen_bin_url ivy.pkg)"
434 [manifest_dtb]="$(fvp_gen_bin_url manifest.dtb)"
Chris Kayfbdd0142022-11-08 12:24:30 +0000435 [mcp_fw]="$(fvp_gen_bin_url mcp_fw.bin)"
Manish V Badarkhe18c59782022-11-09 10:14:48 +0000436 [mcp_ram]="$(fvp_gen_bin_url mcp_ram.bin)"
Chris Kayc14743a2022-10-13 11:33:26 +0100437 [mcp_rom]="$(fvp_gen_bin_url mcp_rom.bin)"
438 [mcp_rom_hyphen]="$(fvp_gen_bin_url mcp-rom.bin)"
439 [ns_bl1u]="$(fvp_gen_bin_url ns_bl1u.bin)"
440 [ns_bl2u]="$(fvp_gen_bin_url ns_bl2u.bin)"
441 [ramdisk]="$(fvp_gen_bin_url initrd.bin)"
442 [romlib]="$(fvp_gen_bin_url romlib.bin)"
443 [rootfs]="$(fvp_gen_bin_url rootfs.bin.gz)"
Manish V Badarkhe93093dd2022-11-09 10:29:27 +0000444 [rss_flash]="$(fvp_gen_bin_url rss_flash.bin)"
445 [rss_rom]="$(fvp_gen_bin_url rss_rom.bin)"
Chris Kayc14743a2022-10-13 11:33:26 +0100446 [secure_hafnium]="$(fvp_gen_bin_url secure_hafnium.bin)"
Chris Kayfbdd0142022-11-08 12:24:30 +0000447 [scp_fw]="$(fvp_gen_bin_url scp_fw.bin)"
Chris Kayc14743a2022-10-13 11:33:26 +0100448 [scp_ram]="$(fvp_gen_bin_url scp_ram.bin)"
449 [scp_ram_hyphen]="$(fvp_gen_bin_url scp-ram.bin)"
450 [scp_rom]="$(fvp_gen_bin_url scp_rom.bin)"
451 [scp_rom_hyphen]="$(fvp_gen_bin_url scp-rom.bin)"
452 [spm]="$(fvp_gen_bin_url spm.bin)"
453 [tftf]="$(fvp_gen_bin_url tftf.bin)"
454 [tmp]="$(fvp_gen_bin_url tmp.bin)"
455 [uboot]="$(fvp_gen_bin_url uboot.bin)"
456 )
457
Chris Kay5d550d82022-10-12 17:20:31 +0100458 # In LAVA we don't provide the paths to the artefacts directly, but instead
459 # use macros of the form `{XYZ}`. This is a list of regular expression
460 # replacements to run on the model parameters file before we add them to the
461 # LAVA job definition.
462 declare -A artefact_macros=(
463 ["[= ]backup_fip.bin"]="={BACKUP_FIP}"
464 ["[= ]bl1.bin"]="={BL1}"
465 ["[= ]bl2.bin"]="={BL2}"
466 ["[= ]bl31.bin"]="={BL31}"
467 ["[= ]bl32.bin"]="={BL32}"
468 ["[= ]cactus-primary.pkg"]="={CACTUS_PRIMARY}"
469 ["[= ]cactus-secondary.pkg"]="={CACTUS_SECONDARY}"
470 ["[= ]cactus-tertiary.pkg"]="={CACTUS_TERTIARY}"
471 ["[= ].*coverage_trace.so"]="={COVERAGE_TRACE_PLUGIN}"
472 ["[= ]fvp_spmc_manifest.dtb"]="={FVP_SPMC_MANIFEST_DTB}"
473 ["[= ]busybox.bin"]="={BUSYBOX}"
474 ["[= ]dtb.bin"]="={DTB}"
475 ["[= ]el3_payload.bin"]="={EL3_PAYLOAD}"
Manish V Badarkhedbb9cb12022-11-16 12:30:41 +0000476 ["[= ].*libete-plugin.so"]="={ETE_TRACE}"
477 ["[= ].*ETMv4ExamplePlugin.so"]="={ETM_TRACE}"
Chris Kay5d550d82022-10-12 17:20:31 +0100478 ["[= ]fip_gpt.bin"]="={FIP_GPT}"
479 ["[= ]fwu_fip.bin"]="={FWU_FIP}"
480 ["[= ]fip.bin"]="={FIP}"
481 ["[= ].*GenericTrace.so"]="={GENERIC_TRACE}"
482 ["[= ].*/hafnium.bin"]="={HAFNIUM}"
483 ["[= ]kernel.bin"]="={IMAGE}"
484 ["[= ]ivy.pkg"]="={IVY}"
485 ["[= ]manifest.dtb"]="={MANIFEST_DTB}"
Chris Kayfbdd0142022-11-08 12:24:30 +0000486 ["[= ]mcp_fw.bin"]="={MCP_FW}"
Manish V Badarkhe18c59782022-11-09 10:14:48 +0000487 ["[= ]mcp_ram.bin"]="={MCP_RAM}"
Chris Kayef9cc802022-11-08 12:11:58 +0000488 ["[= ]mcp_rom.bin"]="={MCP_ROM}"
489 ["[= ]mcp-rom.bin"]="={MCP_ROM_HYPHEN}"
Chris Kay5d550d82022-10-12 17:20:31 +0100490 ["[= ]ns_bl1u.bin"]="={NS_BL1U}"
491 ["[= ]ns_bl2u.bin"]="={NS_BL2U}"
492 ["[= ]initrd.bin"]="={RAMDISK}"
493 ["[= ]initrd.img"]="={RAMDISK}"
494 ["[= ]romlib.bin"]="={ROMLIB}"
495 ["[= ]rootfs.bin"]="={ROOTFS}"
Manish V Badarkhe93093dd2022-11-09 10:29:27 +0000496 ["[= ]rss_flash.bin"]="={RSS_FLASH}"
497 ["[= ]rss_rom.bin"]="={RSS_ROM}"
Chris Kay5d550d82022-10-12 17:20:31 +0100498 ["[= ].*/secure_hafnium.bin"]="={SECURE_HAFNIUM}"
Chris Kayfbdd0142022-11-08 12:24:30 +0000499 ["[= ]scp_fw.bin"]="={SCP_FW}"
Chris Kay5d550d82022-10-12 17:20:31 +0100500 ["[= ]scp_ram.bin"]="={SCP_RAM}"
501 ["[= ]scp-ram.bin"]="={SCP_RAM_HYPHEN}"
502 ["[= ]scp_rom.bin"]="={SCP_ROM}"
503 ["[= ]scp-rom.bin"]="={SCP_ROM_HYPHEN}"
504 ["[= ]spm.bin"]="={SPM}"
505 ["[= ]tftf.bin"]="={TFTF}"
506 ["[= ].*/tmp.bin"]="={TMP}"
507 ["[= ]uboot.bin"]="={UBOOT}"
508 )
509
Chris Kay4eb9ded2022-10-10 15:51:40 +0100510 declare -a artefacts=()
511
512 for artefact in "${!artefact_filters[@]}"; do
513 if grep -E -q "${artefact_filters[${artefact}]}" "${archive}/model_params"; then
514 artefacts+=("${artefact}")
515 fi
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600516 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500517
Chris Kayc92d9fc2022-10-13 11:19:27 +0100518 # Derive LAVA model parameters from the non-LAVA ones
519 cp "${archive}/model_params" "${lava_model_params}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600520
Chris Kayf07d3392022-10-26 15:42:48 +0100521 # Ensure braces in the FVP model parameters are not accidentally interpreted
522 # as LAVA macros.
523 sed -i -e 's/{/{{/g' "${lava_model_params}"
524 sed -i -e 's/}/}}/g' "${lava_model_params}"
525
Chris Kay5d550d82022-10-12 17:20:31 +0100526 # LAVA expects FVP binary paths as macros, i.e. `{X}` instead of `x.bin`, so
527 # replace the file paths in our pre-generated model parameters.
528 for regex in "${!artefact_macros[@]}"; do
529 sed -i -e "s!${regex}!${artefact_macros[${regex}]}!" \
530 "${lava_model_params}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600531 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500532
Chris Kayc92d9fc2022-10-13 11:19:27 +0100533 # Read boot arguments into an array so that the job template file can
534 # iterate over them.
535 readarray -t boot_arguments < "${lava_model_params}"
536
Chris Kay04b70192022-10-19 17:03:37 +0100537 # Source runtime environment variables now so that they are accessible from
538 # the LAVA job template.
539 local run_root="${archive}/run"
540 local run_env="${run_root}/env"
541
542 if [ -f "${run_env}" ]; then
543 source "${run_env}"
544 fi
545
Chris Kayc92d9fc2022-10-13 11:19:27 +0100546 # Generate the LAVA job definition, minus the test expectations
547 expand_template "${yaml_template_file}" > "${yaml_file}"
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500548
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500549 # Append expect commands into the job definition through test-interactive commands
550 gen_fvp_yaml_expect >> "$yaml_file"
551
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600552 # create job.yaml
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500553 cp "$yaml_file" "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500554
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600555 # archive both yamls
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500556 archive_file "$yaml_file"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500557 archive_file "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500558}
559
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500560gen_fvp_yaml_expect() {
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500561 # Loop through all uarts expect files
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500562 for expect_file in $(find $run_root -name expect); do
Chris Kay04b70192022-10-19 17:03:37 +0100563 local uart_number=$(basename "$(dirname ${expect_file})")
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500564
Chris Kay04b70192022-10-19 17:03:37 +0100565 # Only handle the primary UART through LAVA. The remaining UARTs are
566 # validated after LAVA returns by the post-expect script.
Chris Kaya75c0a62022-11-17 18:53:50 +0000567 if [ "${uart_number:?}" != "uart$(get_primary_uart "${archive}")" ]; then
Chris Kay04b70192022-10-19 17:03:37 +0100568 continue
569 fi
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500570
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500571 # Array containing "interactive" or "monitor" expect strings and populated during run config execution.
572 # Interactive expect scripts are converted into LAVA Interactive Test Actions (see
573 # https://tf.validation.linaro.org/static/docs/v2/interactive.html#writing-tests-interactive) and
574 # monitor expect scripts are converted into LAVA Monitor Test Actions (see
575 # https://validation.linaro.org/static/docs/v2/actions-test.html#monitor)
576 #
577 # Interactive Expect strings have the format 'i;<prompt>;<succeses>;<failures>;<commands>'
578 # where multiple successes or failures or commands are separated by @
579 #
580 # Monitor Expect strings have the format 'm;<start>;<end>;<patterns>'
581 # where multiple patterns are separated by @
582 #
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500583 expect_string=()
584
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500585 # Get the real name of the expect file
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500586 expect_file=$(cat $expect_file)
587
588 # Source the run_config enviroment variables
589 env=$run_root/$uart_number/env
590 if [ -e $env ]; then
591 source $env
592 fi
593
594 # Get all expect strings
Chris Kay047af3e2022-09-30 17:10:28 +0100595 expect_dir="${ci_root}/expect-lava"
596 expect_file="${expect_dir}/${expect_file}"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500597
Chris Kay047af3e2022-09-30 17:10:28 +0100598 # Allow the expectations to be provided directly in LAVA's job YAML
599 # format, rather than converting it from a pseudo-Expect Bash script in
600 # the block below.
601 if [ -f "${expect_file/.exp/.yaml}" ]; then
602 pushd "${expect_dir}"
603 expand_template "${expect_file/.exp/.yaml}"
604 popd
605
606 continue
607 else
608 source "${expect_file}"
609 fi
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500610
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500611 if [ ${#expect_string[@]} -gt 0 ]; then
612
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500613 # expect loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500614 for key in "${!expect_string[@]}"; do
615
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500616 # single raw expect string
617 es="${expect_string[${key}]}"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500618
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500619 # action type: either m or i
620 action="$(echo "${es}" | awk -F ';' '{print $1}')"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500621
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500622 if [ "${action}" = "m" ]; then
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500623
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500624 start="$(echo "${es}" | awk -F ';' '{print $2}')"
625 end="$(echo "${es}" | awk -F ';' '{print $3}')"
626 patterns="$(echo "${es}" | awk -F ';' '{print $4}')"
627
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500628 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500629- test:
630 monitors:
631 - name: tests
632 start: '${start}'
633 end: '${end}'
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500634EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500635 # Patterns are separated by '@'
636 OLD_IFS=$IFS; IFS=$'@'
637 for p in ${patterns}; do
638 cat << EOF
639 pattern: '$p'
640EOF
641 done
642 IFS=$OLD_IFS
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500643 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500644 fixupdict:
645 PASS: pass
646 FAIL: fail
647EOF
648 fi # end of monitor action
649
650 if [ "${action}" = "i" ]; then
651
652 prompts="$(echo "${es}" | awk -F ';' '{print $2}')"
653 successes="$(echo "${es}" | awk -F ';' '{print $3}')"
654 failures="$(echo "${es}" | awk -F ';' '{print $4}')"
655 commands="$(echo "${es}" | awk -F ';' '{print $5}')"
656
657 cat << EOF
658- test:
659 interactive:
660EOF
661 OLD_IFS=$IFS; IFS=$'@'
662
663 if [[ -n "${prompts}" && -n "${successes}" && -n "${failures}" ]]; then
664 cat << EOF
665 - name: interactive_${uart_number}_${key}
666 prompts: ['${prompts}']
667 script:
668EOF
669 if [ -z "${commands}" ]; then
670 cat <<EOF
671 - name: interactive_command_${uart_number}_${key}
672 command:
673EOF
674 else
675 for c in ${commands}; do
676 cat <<EOF
677 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300678 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500679EOF
680 done
681 fi
682 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500683 successes:
684EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500685 for s in ${successes}; do
686 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500687 - message: '$s'
688EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500689 done
690 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500691 failures:
692EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500693 for f in ${failures}; do
694 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500695 - message: '$f'
696EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500697 done
Paul Sokolovskya8eaebc2023-05-15 23:13:00 +0300698 cat << EOF
699 exception: JobError
700EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500701 elif [[ -n "${prompts}" && -n "${successes}" ]]; then
702 cat << EOF
703 - name: interactive_${uart_number}_${key}
704 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500705 script:
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500706EOF
707
708 if [ -z "${commands}" ]; then
709 cat <<EOF
710 - name: interactive_command_${uart_number}_${key}
711 command:
712EOF
713 else
714 for c in ${commands}; do
715 cat <<EOF
716 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300717 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500718EOF
719 done
720 fi
721 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500722 successes:
723EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500724 for s in ${successes}; do
725 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500726 - message: '$s'
727EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500728 done
729
730 elif [[ -n "${prompts}" && -n "${failures}" ]]; then
731 cat << EOF
732 - name: interactive_${uart_number}_${key}
733 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500734 script:
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500735EOF
736 if [ -z "${commands}" ]; then
737 cat <<EOF
738 - name: interactive_command_${uart_number}_${key}
739 command:
740EOF
741 else
742 for c in ${commands}; do
743 cat <<EOF
744 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300745 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500746EOF
747 done
748 fi
749 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500750 failures:
751EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500752 for f in ${failures}; do
753 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500754 - message: '$f'
755EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500756 done
Paul Sokolovskya8eaebc2023-05-15 23:13:00 +0300757 cat << EOF
758 exception: JobError
759EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500760 else
761 cat << EOF
762 - name: interactive_${uart_number}_${key}
763 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500764 script:
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500765EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500766 if [ -z "${commands}" ]; then
767 cat <<EOF
768 - name: interactive_command_${uart_number}_${key}
769 command:
770EOF
771 else
772 for c in ${commands}; do
773 cat <<EOF
774 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300775 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500776EOF
777 done
778 fi
779 fi
780
781 IFS=$OLD_IFS
782 fi # end of interactive action
783
784 done # end of expect loop
785
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500786 fi
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500787 done # end of uart loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500788}
789
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500790docker_registry_append() {
791 # if docker_registry is empty, just use local docker registry
792 [ -z "$docker_registry" ] && return
793
794 local last=-1
795 local last_char="${docker_registry:last}"
796
797 if [ "$last_char" != '/' ]; then
798 docker_registry="${docker_registry}/";
799 fi
800 echo "$docker_registry"
801}
802
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000803# generate GPT image and archive it
804gen_gpt_bin() {
805 raw_image="fip_gpt.bin"
806 img_uuid="FB90808A-BA9A-4D42-B9A2-A7A937144AEE"
807 img_bank_uuid=`uuidgen`
808 disk_uuid=`uuidgen`
809 bin="${1:?}"
810
811 # maximum FIP size 2MB
812 fip_max_size=2097152
813 start_sector=34
814 sector_size=512
815 num_sectors=$(($fip_max_size/$sector_size))
816 bin_size=$(stat -c %s $bin)
817
818 if [[ $fip_max_size -lt $bin_size ]]
819 then
Manish V Badarkhe3640b062022-11-16 11:36:36 +0000820 echo "FIP binary ($bin_size bytes) larger than max partition 1" \
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000821 "size ($fip_max_size byte)"
822 return
823 fi
824
825 # create raw 5MB image
826 dd if=/dev/zero of=$raw_image bs=5M count=1
827
828 # create GPT image
829 sgdisk -a 1 -U $disk_uuid -n 1:$start_sector:+$num_sectors \
830 -c 1:FIP_A -t 1:$img_uuid $raw_image -u $img_bank_uuid
831
832 echo "write binary $bin at sector $start_sector"
833 dd if=$bin of=$raw_image bs=$sector_size seek=$start_sector \
834 count=$num_sectors conv=notrunc
835
836 archive_file "fip_gpt.bin"
837}
838
Fathi Boudra422bf772019-12-02 11:10:16 +0200839set +u