blob: 802d072cb7057d30cf6db39cbab0c1707ad3a08f [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
Govindraj Raja74e5b452024-06-18 13:34:17 -050044fvp_arm_std_library_11_24="fvp:fvp_arm_std_library_${model_version_11_24}_${model_build_11_24};/opt/model/FVP_ARM_Std_Library/FVP_Base"
45
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"
Govindraj Rajaec664ac2025-06-30 14:25:38 -050047fvp_base_revc_2xaemva="fvp:fvp_base_revc-2xaemva_${model_version}_${model_build}_linux64;/opt/model/Base_RevC_AEMvA_pkg/models/${model_flavour}"
johpow01936638d2021-11-08 18:22:24 -060048fvp_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 -050049
Manish V Badarkhec3ee53f2022-11-04 10:07:19 +000050# CSS model list
51fvp_morello="fvp:fvp_morello_0.11_33;/opt/model/FVP_Morello/models/Linux64_GCC-6.4"
52fvp_rd_e1_edge="fvp:fvp_rd_e1_edge_11.17_29;/opt/model/FVP_RD_E1_edge/models/${model_flavour}"
53fvp_rd_n1_edge="fvp:fvp_rd_n1_edge_11.17_29;/opt/model/FVP_RD_N1_edge/models/${model_flavour}"
54fvp_rd_v1="fvp:fvp_rd_v1_11.17_29;/opt/model/FVP_RD_V1/models/${model_flavour}"
55fvp_tc0="fvp:fvp_tc0_11.17_18;/opt/model/FVP_TC0/models/${model_flavour}"
56fvp_tc1="fvp:fvp_tc1_11.17_33;/opt/model/FVP_TC1/models/${model_flavour}"
57fvp_tc2="fvp:fvp_tc2_11.18_28;/opt/model/FVP_TC2/models/${model_flavour}"
58
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060059# FVP associate array, run_config are keys and fvp container parameters are the values
60# Container parameters syntax: <model name>;<model dir>;<model bin>
61# FIXMEs: fix those ;;; values with real values
62
63declare -A fvp_models
64fvp_models=(
laurenw-armafdc3bc2022-09-14 15:31:42 -050065[base-aemv8a-revb]="${fvp_arm_std_library};FVP_Base_AEMvA-AEMvA"
66[base-aemv8a-latest-revb]="${fvp_arm_std_library};FVP_Base_AEMvA-AEMvA"
Manish Pandeye5df9312024-03-11 09:58:53 +000067[base-aemva]="${fvp_base_revc_2xaemva};FVP_Base_RevC-2xAEMvA"
laurenw-armf414aba2021-04-26 15:58:56 -050068[base-aemv8a]="${fvp_base_revc_2xaemva};FVP_Base_RevC-2xAEMvA"
Olivier Deprez038596c2024-04-18 12:25:42 +020069[cortex-a32x4]="${fvp_arm_std_library};FVP_Base_Cortex-A32x4"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060070[cortex-a35x4]="${fvp_arm_std_library};FVP_Base_Cortex-A35x4"
71[cortex-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A53x4"
laurenw-armafdc3bc2022-09-14 15:31:42 -050072[cortex-a55x4]="${fvp_arm_std_library};FVP_Base_Cortex-A55"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060073[cortex-a57x1-a53x1]="${fvp_arm_std_library};FVP_Base_Cortex-A57x1-A53x1"
74[cortex-a57x2-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x2-A53x4"
75[cortex-a57x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4"
76[cortex-a57x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4-A53x4"
Govindraj Raja74e5b452024-06-18 13:34:17 -050077[cortex-a65aex8]="${fvp_arm_std_library_11_24};FVP_Base_Cortex-A65AE"
78[cortex-a65x4]="${fvp_arm_std_library_11_24};FVP_Base_Cortex-A65"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060079[cortex-a72x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72x4"
80[cortex-a72x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72x4-A53x4"
81[cortex-a73x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4"
82[cortex-a73x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4-A53x4"
laurenw-armafdc3bc2022-09-14 15:31:42 -050083[cortex-a75x4]="${fvp_arm_std_library};FVP_Base_Cortex-A75"
84[cortex-a76aex4]="${fvp_arm_std_library};FVP_Base_Cortex-A76AE"
85[cortex-a76aex2]="${fvp_arm_std_library};FVP_Base_Cortex-A76AE"
86[cortex-a76x4]="${fvp_arm_std_library};FVP_Base_Cortex-A76"
87[cortex-a77x4]="${fvp_arm_std_library};FVP_Base_Cortex-A77"
88[cortex-a78x4]="${fvp_arm_std_library};FVP_Base_Cortex-A78"
89[cortex-a78cx4]="${fvp_arm_std_library};FVP_Base_Cortex-A78C"
Govindraj Rajae2415462024-06-04 14:50:28 -050090[cortex-x2]="${fvp_arm_std_library};FVP_Base_Cortex-X2"
Govindraj Rajabddd31f2024-07-01 14:31:31 -050091[cortex-a710x8]="${fvp_arm_std_library};FVP_Base_Cortex-A710"
Govindraj Raja4a5da262024-06-26 17:34:56 -050092[neoverse_e1]="${fvp_arm_std_library_11_24};FVP_Base_Neoverse-E1"
laurenw-armafdc3bc2022-09-14 15:31:42 -050093[neoverse_n1]="${fvp_arm_std_library};FVP_Base_Neoverse-N1"
Govindraj Rajae2415462024-06-04 14:50:28 -050094[neoverse_n2]="${fvp_arm_std_library};FVP_Base_Neoverse-N2"
laurenw-armafdc3bc2022-09-14 15:31:42 -050095[neoverse-v1x4]="${fvp_arm_std_library};FVP_Base_Neoverse-V1"
Manish V Badarkhec3ee53f2022-11-04 10:07:19 +000096[morello]="${fvp_morello};FVP_Morello"
97[css-rde1edge]="${fvp_rd_e1_edge};FVP_RD_E1_edge"
98[css-rdn1edgex2]="${fvp_rd_n1_edge};FVP_RD_N1_edge_dual"
99[css-rdv1]="${fvp_rd_v1};FVP_RD_V1"
100[tc0]="${fvp_tc0};FVP_TC0"
101[tc1]="${fvp_tc1};FVP_TC1"
102[tc2]="${fvp_tc2};FVP_TC2"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600103)
104
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500105
Fathi Boudra422bf772019-12-02 11:10:16 +0200106# FVP Kernel URLs
107declare -A fvp_kernels
108fvp_kernels=(
109[fvp-aarch32-zimage]="$linaro_release/fvp32-latest-busybox-uboot/Image"
110[fvp-busybox-uboot]="$linaro_release/fvp-latest-busybox-uboot/Image"
111[fvp-oe-uboot32]="$linaro_release/fvp32-latest-oe-uboot/Image"
112[fvp-oe-uboot]="$linaro_release/fvp-latest-oe-uboot/Image"
113[fvp-quad-busybox-uboot]="$tfa_downloads/quad_cluster/Image"
114)
115
Fathi Boudra422bf772019-12-02 11:10:16 +0200116# FVP initrd URLs
117declare -A fvp_initrd_urls
118fvp_initrd_urls=(
119[aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img"
Fathi Boudra422bf772019-12-02 11:10:16 +0200120[dummy-ramdisk]="$linaro_release/fvp-latest-oe-uboot/ramdisk.img"
121[dummy-ramdisk32]="$linaro_release/fvp32-latest-oe-uboot/ramdisk.img"
122[default]="$linaro_release/fvp-latest-busybox-uboot/ramdisk.img"
123)
124
Fathi Boudra422bf772019-12-02 11:10:16 +0200125get_optee_bin() {
Sandrine Bailleux25ff2942021-02-25 14:00:10 +0100126 url="$tfa_downloads/optee/tee.bin" \
127 saveas="bl32.bin" fetch_file
Fathi Boudra422bf772019-12-02 11:10:16 +0200128 archive_file "bl32.bin"
129}
130
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100131# For Measured Boot tests using a TA based on OPTEE, it is necessary to use a
132# specific build rather than the default one generated by Jenkins.
133get_ftpm_optee_bin() {
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100134 url="$tfa_downloads/ftpm/optee/tee-header_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100135 saveas="bl32.bin" fetch_file
136 archive_file "bl32.bin"
137
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100138 url="$tfa_downloads/ftpm/optee/tee-pager_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100139 saveas="bl32_extra1.bin" fetch_file
140 archive_file "bl32_extra1.bin"
141
Leonardo Sandovalda5f78d2021-03-18 11:09:30 -0600142 # tee-pageable_v2.bin is just a empty file, named as bl32_extra2.bin,
143 # so just create the file
144 touch "bl32_extra2.bin"
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100145 archive_file "bl32_extra2.bin"
146}
147
Fathi Boudra422bf772019-12-02 11:10:16 +0200148get_uboot32_bin() {
149 local tmpdir="$(mktempdir)"
150
151 pushd "$tmpdir"
152 extract_fip "$uboot32_fip_url"
153 mv "nt-fw.bin" "uboot.bin"
154 archive_file "uboot.bin"
155 popd
156}
157
158get_uboot_bin() {
159 local uboot_url="$linaro_release/fvp-latest-busybox-uboot/bl33-uboot.bin"
160
161 url="$uboot_url" saveas="uboot.bin" fetch_file
162 archive_file "uboot.bin"
163}
164
165get_uefi_bin() {
Zelalem219df412020-05-17 19:21:20 -0500166 uefi_downloads="${uefi_downloads:-http://files.oss.arm.com/downloads/uefi}"
167 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 +0200168
169 url=$uefi_ci_bin_url saveas="uefi.bin" fetch_file
170 archive_file "uefi.bin"
171}
172
173get_kernel() {
174 local kernel_type="${kernel_type:?}"
175 local url="${fvp_kernels[$kernel_type]}"
176
177 url="${url:?}" saveas="kernel.bin" fetch_file
178 archive_file "kernel.bin"
179}
180
181get_initrd() {
182 local initrd_type="${initrd_type:?}"
183 local url="${fvp_initrd_urls[$initrd_type]}"
184
185 url="${url:?}" saveas="initrd.bin" fetch_file
186 archive_file "initrd.bin"
187}
188
189get_dtb() {
190 local dtb_type="${dtb_type:?}"
191 local dtb_url
192 local dtb_saveas="$workspace/dtb.bin"
Zelalem219df412020-05-17 19:21:20 -0500193 local cc="$(get_tf_opt CROSS_COMPILE)"
194 local pp_flags="-P -nostdinc -undef -x assembler-with-cpp"
Fathi Boudra422bf772019-12-02 11:10:16 +0200195
196 case "$dtb_type" in
197 "fvp-base-quad-cluster-gicv3-psci")
198 # Get the quad-cluster FDT from pdsw area
199 dtb_url="$tfa_downloads/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb"
200 url="$dtb_url" saveas="$dtb_saveas" fetch_file
201 ;;
Fathi Boudra422bf772019-12-02 11:10:16 +0200202 *)
Zelalem219df412020-05-17 19:21:20 -0500203 # Preprocess DTS file
204 ${cc}gcc -E ${pp_flags} -I"$tf_root/fdts" -I"$tf_root/include" \
205 -o "$workspace/${dtb_type}.pre.dts" \
206 "$tf_root/fdts/${dtb_type}.dts"
207 # Generate DTB file from DTS
Fathi Boudra422bf772019-12-02 11:10:16 +0200208 dtc -I dts -O dtb \
Zelalem219df412020-05-17 19:21:20 -0500209 "$workspace/${dtb_type}.pre.dts" -o "$dtb_saveas"
Fathi Boudra422bf772019-12-02 11:10:16 +0200210 esac
211
212 archive_file "$dtb_saveas"
213}
214
215get_rootfs() {
216 local tmpdir
217 local fs_base="$(echo $(basename $rootfs_url) | sed 's/\.gz$//')"
218 local cached="$project_filer/ci-files/$fs_base"
219
220 if upon "$jenkins_run" && [ -f "$cached" ]; then
221 # Job workspace is limited in size, and the root file system is
222 # quite large. This means, parallel runs of root file system
223 # tests could fail. So, for Jenkins runs, copy and use the root
224 # file system image from the $CI_SCRATCH location
225 local private="$CI_SCRATCH/$JOB_NAME-$BUILD_NUMBER"
226 mkdir -p "$private"
227 rm -f "$private/rootfs.bin"
228 url="$cached" saveas="$private/rootfs.bin" fetch_file
229 ln -s "$private/rootfs.bin" "$archive/rootfs.bin"
230 return
231 fi
232
233 tmpdir="$(mktempdir)"
234 pushd "$tmpdir"
235 url="$rootfs_url" saveas="rootfs.bin" fetch_file
236
237 # Possibly, the filesystem image we just downloaded is compressed.
238 # Decompress it if required.
239 if file "rootfs.bin" | grep -iq 'gzip compressed data'; then
240 echo "Decompressing root file system image rootfs.bin ..."
241 gunzip --stdout "rootfs.bin" > uncompressed_fs.bin
242 mv uncompressed_fs.bin "rootfs.bin"
243 fi
244
245 archive_file "rootfs.bin"
246 popd
247}
248
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200249fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i"
250
Fathi Boudra422bf772019-12-02 11:10:16 +0200251fvp_romlib_runtime() {
252 local tmpdir="$(mktempdir)"
253
254 # Save BL1 and romlib binaries from original build
255 mv "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" "$tmpdir/romlib.bin"
256 mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin"
257
258 # Patch index file
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200259 cp "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" "$fvp_romlib_jmptbl_backup"
260 sed -i '/fdt/ s/.$/&\ patch/' ${tf_root:?}/plat/arm/board/fvp/jmptbl.i
Fathi Boudra422bf772019-12-02 11:10:16 +0200261
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200262 # Rebuild with patched file
263 echo "Building patched romlib:"
264 build_tf
Fathi Boudra422bf772019-12-02 11:10:16 +0200265
Fathi Boudra422bf772019-12-02 11:10:16 +0200266 # Retrieve original BL1 and romlib binaries
267 mv "$tmpdir/romlib.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin"
268 mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin"
269}
270
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200271fvp_romlib_cleanup() {
272 # Restore original index
273 mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
274}
275
276
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500277fvp_gen_bin_url() {
278 local bin_mode="${bin_mode:?}"
279 local bin="${1:?}"
280
281 if upon "$jenkins_run"; then
282 echo "$jenkins_url/job/$JOB_NAME/$BUILD_NUMBER/artifact/artefacts/$bin_mode/$bin"
283 else
284 echo "file://$workspace/artefacts/$bin_mode/$bin"
285 fi
286}
287
Chris Kayfbbf1322022-10-05 13:13:32 +0100288# Generates the template for YAML-based LAVA job definitions from a file
289# corresponding to the currently-selected payload, e.g.:
290#
291# - `lava-templates/fvp-linux.yaml`
292# - `lava-templates/fvp-tftf.yaml`
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500293gen_fvp_yaml_template() {
Chris Kayfbbf1322022-10-05 13:13:32 +0100294 local yaml_template_file="${workspace}/fvp_template.yaml"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500295
Chris Kayc9523b12022-10-10 18:32:20 +0100296 cp "${ci_root}/script/lava-templates/fvp-${payload_type:?}.yaml" \
297 "${yaml_template_file}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500298
Chris Kayfbbf1322022-10-05 13:13:32 +0100299 archive_file "${yaml_template_file}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500300}
301
Chris Kayc9523b12022-10-10 18:32:20 +0100302# Generates the final YAML-based LAVA job definition from a template file.
303#
304# The job definition template is expanded with visibility of all variables that
305# are available from within the function, including those with local scope.
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500306gen_fvp_yaml() {
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600307 local model="${model:?}"
308
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500309 local yaml_template_file="$workspace/fvp_template.yaml"
310 local yaml_file="$workspace/fvp.yaml"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500311 local yaml_job_file="$workspace/job.yaml"
312 local lava_model_params="$workspace/lava_model_params"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500313
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500314 # this function expects a template, quit if it is not present
315 if [ ! -f "$yaml_template_file" ]; then
Paul Sokolovskyf56d9d22023-01-24 18:33:58 +0700316 echo "warning: gen_fvp_yaml: template $yaml_template_file not available, skipping generating LAVA job"
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500317 return
318 fi
319
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600320 local model_params="${fvp_models[$model]}"
321 local model_name="$(echo "${model_params}" | awk -F ';' '{print $1}')"
322 local model_dir="$(echo "${model_params}" | awk -F ';' '{print $2}')"
323 local model_bin="$(echo "${model_params}" | awk -F ';' '{print $3}')"
324
325 # model params are required for correct yaml creation, quit if empty
326 if [ -z "${model_name}" ]; then
327 echo "FVP model param 'model_name' variable empty, yaml not produced"
328 return
329 elif [ -z "${model_dir}" ]; then
330 echo "FVP model param 'model_dir' variable empty, yaml not produced"
331 return
332 elif [ -z "${model_bin}" ]; then
333 echo "FVP model param 'model_bin' variable empty, yaml not produced"
334 return
335 fi
336
337 echo "FVP model params: model_name=$model_name model_dir=$model_dir model_bin=$model_bin"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500338
339 # optional parameters, defaults to globals
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500340 local model_dtb="${model_dtb:-$default_model_dtb}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500341
Chris Kayc9523b12022-10-10 18:32:20 +0100342 if [ -n "${GERRIT_CHANGE_NUMBER}" ]; then
343 local gerrit_url="https://review.trustedfirmware.org/c/${GERRIT_CHANGE_NUMBER}/${GERRIT_PATCHSET_NUMBER}"
344 elif [ -n "${GERRIT_REFSPEC}" ]; then
345 local gerrit_url=$(echo ${GERRIT_REFSPEC} |
346 awk -F/ '{print "https://review.trustedfirmware.org/c/" $4 "/" $5}')
347 fi
348
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500349 docker_registry="${docker_registry:-}"
350 docker_registry="$(docker_registry_append)"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500351 docker_name="${docker_registry}$model_name"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600352 prompt1='/ #'
353 prompt2='root@genericarmv8:~#'
354 version_string="\"Fast Models"' [^\\n]+'"\""
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500355
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500356 test_config="${TEST_CONFIG}"
357
Chris Kay4eb9ded2022-10-10 15:51:40 +0100358 declare -A artefact_filters=(
359 [backup_fip]="backup_fip.bin"
360 [bl1]="bl1.bin"
361 [bl2]="bl2.bin"
362 [bl31]="bl31.bin"
363 [bl32]="bl32.bin"
364 [busybox]="busybox.bin"
365 [cactus_primary]="cactus-primary.pkg"
366 [cactus_secondary]="cactus-secondary.pkg"
367 [cactus_tertiary]="cactus-tertiary.pkg"
368 [coverage_trace_plugin]="coverage_trace.so"
369 [dtb]="dtb.bin"
370 [el3_payload]="el3_payload.bin"
371 [fip_gpt]="fip_gpt.bin"
372 [fip]="fip.bin"
373 [fvp_spmc_manifest_dtb]="=fvp_spmc_manifest.dtb"
374 [fwu_fip]="fwu_fip.bin"
Chris Kay4eb9ded2022-10-10 15:51:40 +0100375 [hafnium]="hafnium.bin"
376 [image]="kernel.bin"
377 [ivy]="ivy.pkg"
378 [manifest_dtb]="=manifest.dtb"
Chris Kayfbdd0142022-11-08 12:24:30 +0000379 [mcp_fw]="mcp_fw.bin"
Manish V Badarkhe18c59782022-11-09 10:14:48 +0000380 [mcp_ram]="mcp_ram.bin"
Chris Kay4eb9ded2022-10-10 15:51:40 +0100381 [mcp_rom_hyphen]="mcp-rom.bin"
382 [mcp_rom]="mcp_rom.bin"
383 [ns_bl1u]="ns_bl1u.bin"
384 [ns_bl2u]="ns_bl2u.bin"
385 [ramdisk]="initrd.bin|initrd.img"
386 [romlib]="romlib.bin"
387 [rootfs]="rootfs.bin"
Manish V Badarkhe93093dd2022-11-09 10:29:27 +0000388 [rss_flash]="rss_flash.bin"
389 [rss_rom]="rss_rom.bin"
Chris Kayfbdd0142022-11-08 12:24:30 +0000390 [scp_fw]="scp_fw.bin"
Chris Kay4eb9ded2022-10-10 15:51:40 +0100391 [scp_ram_hyphen]="scp-ram.bin"
392 [scp_ram]="scp_ram.bin"
393 [scp_rom_hyphen]="scp-rom.bin"
394 [scp_rom]="scp_rom.bin"
395 [secure_hafnium]="secure_hafnium.bin"
396 [spm]="spm.bin"
397 [tftf]="tftf.bin"
398 [tmp]="tmp.bin"
399 [uboot]="uboot.bin"
400 )
401
Chris Kayc14743a2022-10-13 11:33:26 +0100402 declare -A artefact_urls=(
403 [backup_fip]="$(fvp_gen_bin_url backup_fip.bin)"
404 [bl1]="$(fvp_gen_bin_url bl1.bin)"
405 [bl2]="$(fvp_gen_bin_url bl2.bin)"
406 [bl31]="$(fvp_gen_bin_url bl31.bin)"
407 [bl32]="$(fvp_gen_bin_url bl32.bin)"
408 [busybox]="$(fvp_gen_bin_url busybox.bin.gz)"
409 [cactus_primary]="$(fvp_gen_bin_url cactus-primary.pkg)"
410 [cactus_secondary]="$(fvp_gen_bin_url cactus-secondary.pkg)"
411 [cactus_tertiary]="$(fvp_gen_bin_url cactus-tertiary.pkg)"
412 [coverage_trace_plugin]="${coverage_trace_plugin}"
413 [dtb]="$(fvp_gen_bin_url ${model_dtb})"
414 [el3_payload]="$(fvp_gen_bin_url el3_payload.bin)"
415 [fip]="$(fvp_gen_bin_url fip.bin)"
416 [fip_gpt]="$(fvp_gen_bin_url fip_gpt.bin)"
417 [fvp_spmc_manifest_dtb]="$(fvp_gen_bin_url fvp_spmc_manifest.dtb)"
418 [fwu_fip]="$(fvp_gen_bin_url fwu_fip.bin)"
Chris Kayc14743a2022-10-13 11:33:26 +0100419 [hafnium]="$(fvp_gen_bin_url hafnium.bin)"
420 [image]="$(fvp_gen_bin_url kernel.bin)"
421 [ivy]="$(fvp_gen_bin_url ivy.pkg)"
422 [manifest_dtb]="$(fvp_gen_bin_url manifest.dtb)"
Chris Kayfbdd0142022-11-08 12:24:30 +0000423 [mcp_fw]="$(fvp_gen_bin_url mcp_fw.bin)"
Manish V Badarkhe18c59782022-11-09 10:14:48 +0000424 [mcp_ram]="$(fvp_gen_bin_url mcp_ram.bin)"
Chris Kayc14743a2022-10-13 11:33:26 +0100425 [mcp_rom]="$(fvp_gen_bin_url mcp_rom.bin)"
426 [mcp_rom_hyphen]="$(fvp_gen_bin_url mcp-rom.bin)"
427 [ns_bl1u]="$(fvp_gen_bin_url ns_bl1u.bin)"
428 [ns_bl2u]="$(fvp_gen_bin_url ns_bl2u.bin)"
429 [ramdisk]="$(fvp_gen_bin_url initrd.bin)"
430 [romlib]="$(fvp_gen_bin_url romlib.bin)"
431 [rootfs]="$(fvp_gen_bin_url rootfs.bin.gz)"
Manish V Badarkhe93093dd2022-11-09 10:29:27 +0000432 [rss_flash]="$(fvp_gen_bin_url rss_flash.bin)"
433 [rss_rom]="$(fvp_gen_bin_url rss_rom.bin)"
Chris Kayc14743a2022-10-13 11:33:26 +0100434 [secure_hafnium]="$(fvp_gen_bin_url secure_hafnium.bin)"
Chris Kayfbdd0142022-11-08 12:24:30 +0000435 [scp_fw]="$(fvp_gen_bin_url scp_fw.bin)"
Chris Kayc14743a2022-10-13 11:33:26 +0100436 [scp_ram]="$(fvp_gen_bin_url scp_ram.bin)"
437 [scp_ram_hyphen]="$(fvp_gen_bin_url scp-ram.bin)"
438 [scp_rom]="$(fvp_gen_bin_url scp_rom.bin)"
439 [scp_rom_hyphen]="$(fvp_gen_bin_url scp-rom.bin)"
440 [spm]="$(fvp_gen_bin_url spm.bin)"
441 [tftf]="$(fvp_gen_bin_url tftf.bin)"
442 [tmp]="$(fvp_gen_bin_url tmp.bin)"
443 [uboot]="$(fvp_gen_bin_url uboot.bin)"
444 )
445
Chris Kay5d550d82022-10-12 17:20:31 +0100446 # In LAVA we don't provide the paths to the artefacts directly, but instead
447 # use macros of the form `{XYZ}`. This is a list of regular expression
448 # replacements to run on the model parameters file before we add them to the
449 # LAVA job definition.
450 declare -A artefact_macros=(
451 ["[= ]backup_fip.bin"]="={BACKUP_FIP}"
452 ["[= ]bl1.bin"]="={BL1}"
453 ["[= ]bl2.bin"]="={BL2}"
454 ["[= ]bl31.bin"]="={BL31}"
455 ["[= ]bl32.bin"]="={BL32}"
456 ["[= ]cactus-primary.pkg"]="={CACTUS_PRIMARY}"
457 ["[= ]cactus-secondary.pkg"]="={CACTUS_SECONDARY}"
458 ["[= ]cactus-tertiary.pkg"]="={CACTUS_TERTIARY}"
459 ["[= ].*coverage_trace.so"]="={COVERAGE_TRACE_PLUGIN}"
460 ["[= ]fvp_spmc_manifest.dtb"]="={FVP_SPMC_MANIFEST_DTB}"
461 ["[= ]busybox.bin"]="={BUSYBOX}"
462 ["[= ]dtb.bin"]="={DTB}"
463 ["[= ]el3_payload.bin"]="={EL3_PAYLOAD}"
464 ["[= ]fip_gpt.bin"]="={FIP_GPT}"
465 ["[= ]fwu_fip.bin"]="={FWU_FIP}"
466 ["[= ]fip.bin"]="={FIP}"
Chris Kay5d550d82022-10-12 17:20:31 +0100467 ["[= ].*/hafnium.bin"]="={HAFNIUM}"
468 ["[= ]kernel.bin"]="={IMAGE}"
469 ["[= ]ivy.pkg"]="={IVY}"
470 ["[= ]manifest.dtb"]="={MANIFEST_DTB}"
Chris Kayfbdd0142022-11-08 12:24:30 +0000471 ["[= ]mcp_fw.bin"]="={MCP_FW}"
Manish V Badarkhe18c59782022-11-09 10:14:48 +0000472 ["[= ]mcp_ram.bin"]="={MCP_RAM}"
Chris Kayef9cc802022-11-08 12:11:58 +0000473 ["[= ]mcp_rom.bin"]="={MCP_ROM}"
474 ["[= ]mcp-rom.bin"]="={MCP_ROM_HYPHEN}"
Chris Kay5d550d82022-10-12 17:20:31 +0100475 ["[= ]ns_bl1u.bin"]="={NS_BL1U}"
476 ["[= ]ns_bl2u.bin"]="={NS_BL2U}"
477 ["[= ]initrd.bin"]="={RAMDISK}"
478 ["[= ]initrd.img"]="={RAMDISK}"
479 ["[= ]romlib.bin"]="={ROMLIB}"
480 ["[= ]rootfs.bin"]="={ROOTFS}"
Manish V Badarkhe93093dd2022-11-09 10:29:27 +0000481 ["[= ]rss_flash.bin"]="={RSS_FLASH}"
482 ["[= ]rss_rom.bin"]="={RSS_ROM}"
Chris Kay5d550d82022-10-12 17:20:31 +0100483 ["[= ].*/secure_hafnium.bin"]="={SECURE_HAFNIUM}"
Chris Kayfbdd0142022-11-08 12:24:30 +0000484 ["[= ]scp_fw.bin"]="={SCP_FW}"
Chris Kay5d550d82022-10-12 17:20:31 +0100485 ["[= ]scp_ram.bin"]="={SCP_RAM}"
486 ["[= ]scp-ram.bin"]="={SCP_RAM_HYPHEN}"
487 ["[= ]scp_rom.bin"]="={SCP_ROM}"
488 ["[= ]scp-rom.bin"]="={SCP_ROM_HYPHEN}"
489 ["[= ]spm.bin"]="={SPM}"
490 ["[= ]tftf.bin"]="={TFTF}"
491 ["[= ].*/tmp.bin"]="={TMP}"
492 ["[= ]uboot.bin"]="={UBOOT}"
493 )
494
Chris Kay4eb9ded2022-10-10 15:51:40 +0100495 declare -a artefacts=()
496
497 for artefact in "${!artefact_filters[@]}"; do
498 if grep -E -q "${artefact_filters[${artefact}]}" "${archive}/model_params"; then
499 artefacts+=("${artefact}")
500 fi
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600501 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500502
Chris Kayc92d9fc2022-10-13 11:19:27 +0100503 # Derive LAVA model parameters from the non-LAVA ones
504 cp "${archive}/model_params" "${lava_model_params}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600505
Chris Kayf07d3392022-10-26 15:42:48 +0100506 # Ensure braces in the FVP model parameters are not accidentally interpreted
507 # as LAVA macros.
508 sed -i -e 's/{/{{/g' "${lava_model_params}"
509 sed -i -e 's/}/}}/g' "${lava_model_params}"
510
Chris Kay5d550d82022-10-12 17:20:31 +0100511 # LAVA expects FVP binary paths as macros, i.e. `{X}` instead of `x.bin`, so
512 # replace the file paths in our pre-generated model parameters.
513 for regex in "${!artefact_macros[@]}"; do
514 sed -i -e "s!${regex}!${artefact_macros[${regex}]}!" \
515 "${lava_model_params}"
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 # Read boot arguments into an array so that the job template file can
519 # iterate over them.
520 readarray -t boot_arguments < "${lava_model_params}"
521
Chris Kay04b70192022-10-19 17:03:37 +0100522 # Source runtime environment variables now so that they are accessible from
523 # the LAVA job template.
524 local run_root="${archive}/run"
525 local run_env="${run_root}/env"
526
527 if [ -f "${run_env}" ]; then
528 source "${run_env}"
529 fi
530
Chris Kayc92d9fc2022-10-13 11:19:27 +0100531 # Generate the LAVA job definition, minus the test expectations
532 expand_template "${yaml_template_file}" > "${yaml_file}"
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500533
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500534 # Append expect commands into the job definition through test-interactive commands
535 gen_fvp_yaml_expect >> "$yaml_file"
536
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600537 # create job.yaml
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500538 cp "$yaml_file" "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500539
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600540 # archive both yamls
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500541 archive_file "$yaml_file"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500542 archive_file "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500543}
544
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500545gen_fvp_yaml_expect() {
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500546 # Loop through all uarts expect files
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500547 for expect_file in $(find $run_root -name expect); do
Chris Kay04b70192022-10-19 17:03:37 +0100548 local uart_number=$(basename "$(dirname ${expect_file})")
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500549
Chris Kay04b70192022-10-19 17:03:37 +0100550 # Only handle the primary UART through LAVA. The remaining UARTs are
551 # validated after LAVA returns by the post-expect script.
Chris Kaya75c0a62022-11-17 18:53:50 +0000552 if [ "${uart_number:?}" != "uart$(get_primary_uart "${archive}")" ]; then
Chris Kay04b70192022-10-19 17:03:37 +0100553 continue
554 fi
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500555
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500556 # Array containing "interactive" or "monitor" expect strings and populated during run config execution.
557 # Interactive expect scripts are converted into LAVA Interactive Test Actions (see
558 # https://tf.validation.linaro.org/static/docs/v2/interactive.html#writing-tests-interactive) and
559 # monitor expect scripts are converted into LAVA Monitor Test Actions (see
560 # https://validation.linaro.org/static/docs/v2/actions-test.html#monitor)
561 #
562 # Interactive Expect strings have the format 'i;<prompt>;<succeses>;<failures>;<commands>'
563 # where multiple successes or failures or commands are separated by @
564 #
565 # Monitor Expect strings have the format 'm;<start>;<end>;<patterns>'
566 # where multiple patterns are separated by @
567 #
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500568 expect_string=()
569
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500570 # Get the real name of the expect file
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500571 expect_file=$(cat $expect_file)
572
573 # Source the run_config enviroment variables
574 env=$run_root/$uart_number/env
575 if [ -e $env ]; then
576 source $env
577 fi
578
579 # Get all expect strings
Chris Kay047af3e2022-09-30 17:10:28 +0100580 expect_dir="${ci_root}/expect-lava"
581 expect_file="${expect_dir}/${expect_file}"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500582
Chris Kay047af3e2022-09-30 17:10:28 +0100583 # Allow the expectations to be provided directly in LAVA's job YAML
584 # format, rather than converting it from a pseudo-Expect Bash script in
585 # the block below.
586 if [ -f "${expect_file/.exp/.yaml}" ]; then
587 pushd "${expect_dir}"
588 expand_template "${expect_file/.exp/.yaml}"
589 popd
590
591 continue
592 else
593 source "${expect_file}"
594 fi
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500595
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500596 if [ ${#expect_string[@]} -gt 0 ]; then
597
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500598 # expect loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500599 for key in "${!expect_string[@]}"; do
600
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500601 # single raw expect string
602 es="${expect_string[${key}]}"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500603
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500604 # action type: either m or i
605 action="$(echo "${es}" | awk -F ';' '{print $1}')"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500606
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500607 if [ "${action}" = "m" ]; then
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500608
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500609 start="$(echo "${es}" | awk -F ';' '{print $2}')"
610 end="$(echo "${es}" | awk -F ';' '{print $3}')"
611 patterns="$(echo "${es}" | awk -F ';' '{print $4}')"
612
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500613 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500614- test:
615 monitors:
616 - name: tests
617 start: '${start}'
618 end: '${end}'
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500619EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500620 # Patterns are separated by '@'
621 OLD_IFS=$IFS; IFS=$'@'
622 for p in ${patterns}; do
623 cat << EOF
624 pattern: '$p'
625EOF
626 done
627 IFS=$OLD_IFS
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500628 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500629 fixupdict:
630 PASS: pass
631 FAIL: fail
632EOF
633 fi # end of monitor action
634
635 if [ "${action}" = "i" ]; then
636
637 prompts="$(echo "${es}" | awk -F ';' '{print $2}')"
638 successes="$(echo "${es}" | awk -F ';' '{print $3}')"
639 failures="$(echo "${es}" | awk -F ';' '{print $4}')"
640 commands="$(echo "${es}" | awk -F ';' '{print $5}')"
641
642 cat << EOF
643- test:
644 interactive:
645EOF
646 OLD_IFS=$IFS; IFS=$'@'
647
648 if [[ -n "${prompts}" && -n "${successes}" && -n "${failures}" ]]; then
649 cat << EOF
650 - name: interactive_${uart_number}_${key}
651 prompts: ['${prompts}']
652 script:
653EOF
654 if [ -z "${commands}" ]; then
655 cat <<EOF
656 - name: interactive_command_${uart_number}_${key}
657 command:
658EOF
659 else
660 for c in ${commands}; do
661 cat <<EOF
662 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300663 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500664EOF
665 done
666 fi
667 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500668 successes:
669EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500670 for s in ${successes}; do
671 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500672 - message: '$s'
673EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500674 done
675 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500676 failures:
677EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500678 for f in ${failures}; do
679 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500680 - message: '$f'
681EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500682 done
Paul Sokolovskya8eaebc2023-05-15 23:13:00 +0300683 cat << EOF
684 exception: JobError
685EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500686 elif [[ -n "${prompts}" && -n "${successes}" ]]; then
687 cat << EOF
688 - name: interactive_${uart_number}_${key}
689 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500690 script:
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500691EOF
692
693 if [ -z "${commands}" ]; then
694 cat <<EOF
695 - name: interactive_command_${uart_number}_${key}
696 command:
697EOF
698 else
699 for c in ${commands}; do
700 cat <<EOF
701 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300702 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500703EOF
704 done
705 fi
706 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500707 successes:
708EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500709 for s in ${successes}; do
710 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500711 - message: '$s'
712EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500713 done
714
715 elif [[ -n "${prompts}" && -n "${failures}" ]]; then
716 cat << EOF
717 - name: interactive_${uart_number}_${key}
718 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500719 script:
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500720EOF
721 if [ -z "${commands}" ]; then
722 cat <<EOF
723 - name: interactive_command_${uart_number}_${key}
724 command:
725EOF
726 else
727 for c in ${commands}; do
728 cat <<EOF
729 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300730 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500731EOF
732 done
733 fi
734 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500735 failures:
736EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500737 for f in ${failures}; do
738 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500739 - message: '$f'
740EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500741 done
Paul Sokolovskya8eaebc2023-05-15 23:13:00 +0300742 cat << EOF
743 exception: JobError
744EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500745 else
746 cat << EOF
747 - name: interactive_${uart_number}_${key}
748 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500749 script:
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500750EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500751 if [ -z "${commands}" ]; then
752 cat <<EOF
753 - name: interactive_command_${uart_number}_${key}
754 command:
755EOF
756 else
757 for c in ${commands}; do
758 cat <<EOF
759 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300760 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500761EOF
762 done
763 fi
764 fi
765
766 IFS=$OLD_IFS
767 fi # end of interactive action
768
769 done # end of expect loop
770
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500771 fi
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500772 done # end of uart loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500773}
774
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500775docker_registry_append() {
776 # if docker_registry is empty, just use local docker registry
777 [ -z "$docker_registry" ] && return
778
779 local last=-1
780 local last_char="${docker_registry:last}"
781
782 if [ "$last_char" != '/' ]; then
783 docker_registry="${docker_registry}/";
784 fi
785 echo "$docker_registry"
786}
787
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000788# generate GPT image and archive it
789gen_gpt_bin() {
790 raw_image="fip_gpt.bin"
791 img_uuid="FB90808A-BA9A-4D42-B9A2-A7A937144AEE"
792 img_bank_uuid=`uuidgen`
793 disk_uuid=`uuidgen`
794 bin="${1:?}"
795
796 # maximum FIP size 2MB
797 fip_max_size=2097152
798 start_sector=34
799 sector_size=512
800 num_sectors=$(($fip_max_size/$sector_size))
801 bin_size=$(stat -c %s $bin)
802
803 if [[ $fip_max_size -lt $bin_size ]]
804 then
Manish V Badarkhe3640b062022-11-16 11:36:36 +0000805 echo "FIP binary ($bin_size bytes) larger than max partition 1" \
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000806 "size ($fip_max_size byte)"
807 return
808 fi
809
810 # create raw 5MB image
811 dd if=/dev/zero of=$raw_image bs=5M count=1
812
813 # create GPT image
814 sgdisk -a 1 -U $disk_uuid -n 1:$start_sector:+$num_sectors \
815 -c 1:FIP_A -t 1:$img_uuid $raw_image -u $img_bank_uuid
816
817 echo "write binary $bin at sector $start_sector"
818 dd if=$bin of=$raw_image bs=$sector_size seek=$start_sector \
819 count=$num_sectors conv=notrunc
820
821 archive_file "fip_gpt.bin"
822}
823
Fathi Boudra422bf772019-12-02 11:10:16 +0200824set +u