blob: ba326f143135215e23c3285dd51dfdbdb6d3eea5 [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"
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}"
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"
91[cortex-a710]="${fvp_arm_std_library};FVP_Base_Cortex-A710"
Govindraj Raja74e5b452024-06-18 13:34:17 -050092[neoverse_e1x1]="${fvp_arm_std_library_11_24};FVP_Base_Neoverse-E1"
93[neoverse_e1x2]="${fvp_arm_std_library_11_24};FVP_Base_Neoverse-E1"
94[neoverse_e1x4]="${fvp_arm_std_library_11_24};FVP_Base_Neoverse-E1"
laurenw-armafdc3bc2022-09-14 15:31:42 -050095[neoverse_n1]="${fvp_arm_std_library};FVP_Base_Neoverse-N1"
Govindraj Rajae2415462024-06-04 14:50:28 -050096[neoverse_n2]="${fvp_arm_std_library};FVP_Base_Neoverse-N2"
laurenw-armafdc3bc2022-09-14 15:31:42 -050097[neoverse-v1x4]="${fvp_arm_std_library};FVP_Base_Neoverse-V1"
Manish V Badarkhec3ee53f2022-11-04 10:07:19 +000098[morello]="${fvp_morello};FVP_Morello"
99[css-rde1edge]="${fvp_rd_e1_edge};FVP_RD_E1_edge"
100[css-rdn1edgex2]="${fvp_rd_n1_edge};FVP_RD_N1_edge_dual"
101[css-rdv1]="${fvp_rd_v1};FVP_RD_V1"
102[tc0]="${fvp_tc0};FVP_TC0"
103[tc1]="${fvp_tc1};FVP_TC1"
104[tc2]="${fvp_tc2};FVP_TC2"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600105)
106
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500107
Fathi Boudra422bf772019-12-02 11:10:16 +0200108# FVP Kernel URLs
109declare -A fvp_kernels
110fvp_kernels=(
111[fvp-aarch32-zimage]="$linaro_release/fvp32-latest-busybox-uboot/Image"
112[fvp-busybox-uboot]="$linaro_release/fvp-latest-busybox-uboot/Image"
113[fvp-oe-uboot32]="$linaro_release/fvp32-latest-oe-uboot/Image"
114[fvp-oe-uboot]="$linaro_release/fvp-latest-oe-uboot/Image"
115[fvp-quad-busybox-uboot]="$tfa_downloads/quad_cluster/Image"
116)
117
Fathi Boudra422bf772019-12-02 11:10:16 +0200118# FVP initrd URLs
119declare -A fvp_initrd_urls
120fvp_initrd_urls=(
121[aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img"
Fathi Boudra422bf772019-12-02 11:10:16 +0200122[dummy-ramdisk]="$linaro_release/fvp-latest-oe-uboot/ramdisk.img"
123[dummy-ramdisk32]="$linaro_release/fvp32-latest-oe-uboot/ramdisk.img"
124[default]="$linaro_release/fvp-latest-busybox-uboot/ramdisk.img"
125)
126
Fathi Boudra422bf772019-12-02 11:10:16 +0200127get_optee_bin() {
Sandrine Bailleux25ff2942021-02-25 14:00:10 +0100128 url="$tfa_downloads/optee/tee.bin" \
129 saveas="bl32.bin" fetch_file
Fathi Boudra422bf772019-12-02 11:10:16 +0200130 archive_file "bl32.bin"
131}
132
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100133# For Measured Boot tests using a TA based on OPTEE, it is necessary to use a
134# specific build rather than the default one generated by Jenkins.
135get_ftpm_optee_bin() {
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100136 url="$tfa_downloads/ftpm/optee/tee-header_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100137 saveas="bl32.bin" fetch_file
138 archive_file "bl32.bin"
139
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100140 url="$tfa_downloads/ftpm/optee/tee-pager_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100141 saveas="bl32_extra1.bin" fetch_file
142 archive_file "bl32_extra1.bin"
143
Leonardo Sandovalda5f78d2021-03-18 11:09:30 -0600144 # tee-pageable_v2.bin is just a empty file, named as bl32_extra2.bin,
145 # so just create the file
146 touch "bl32_extra2.bin"
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100147 archive_file "bl32_extra2.bin"
148}
149
Fathi Boudra422bf772019-12-02 11:10:16 +0200150get_uboot32_bin() {
151 local tmpdir="$(mktempdir)"
152
153 pushd "$tmpdir"
154 extract_fip "$uboot32_fip_url"
155 mv "nt-fw.bin" "uboot.bin"
156 archive_file "uboot.bin"
157 popd
158}
159
160get_uboot_bin() {
161 local uboot_url="$linaro_release/fvp-latest-busybox-uboot/bl33-uboot.bin"
162
163 url="$uboot_url" saveas="uboot.bin" fetch_file
164 archive_file "uboot.bin"
165}
166
167get_uefi_bin() {
Zelalem219df412020-05-17 19:21:20 -0500168 uefi_downloads="${uefi_downloads:-http://files.oss.arm.com/downloads/uefi}"
169 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 +0200170
171 url=$uefi_ci_bin_url saveas="uefi.bin" fetch_file
172 archive_file "uefi.bin"
173}
174
175get_kernel() {
176 local kernel_type="${kernel_type:?}"
177 local url="${fvp_kernels[$kernel_type]}"
178
179 url="${url:?}" saveas="kernel.bin" fetch_file
180 archive_file "kernel.bin"
181}
182
183get_initrd() {
184 local initrd_type="${initrd_type:?}"
185 local url="${fvp_initrd_urls[$initrd_type]}"
186
187 url="${url:?}" saveas="initrd.bin" fetch_file
188 archive_file "initrd.bin"
189}
190
191get_dtb() {
192 local dtb_type="${dtb_type:?}"
193 local dtb_url
194 local dtb_saveas="$workspace/dtb.bin"
Zelalem219df412020-05-17 19:21:20 -0500195 local cc="$(get_tf_opt CROSS_COMPILE)"
196 local pp_flags="-P -nostdinc -undef -x assembler-with-cpp"
Fathi Boudra422bf772019-12-02 11:10:16 +0200197
198 case "$dtb_type" in
199 "fvp-base-quad-cluster-gicv3-psci")
200 # Get the quad-cluster FDT from pdsw area
201 dtb_url="$tfa_downloads/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb"
202 url="$dtb_url" saveas="$dtb_saveas" fetch_file
203 ;;
Fathi Boudra422bf772019-12-02 11:10:16 +0200204 *)
Zelalem219df412020-05-17 19:21:20 -0500205 # Preprocess DTS file
206 ${cc}gcc -E ${pp_flags} -I"$tf_root/fdts" -I"$tf_root/include" \
207 -o "$workspace/${dtb_type}.pre.dts" \
208 "$tf_root/fdts/${dtb_type}.dts"
209 # Generate DTB file from DTS
Fathi Boudra422bf772019-12-02 11:10:16 +0200210 dtc -I dts -O dtb \
Zelalem219df412020-05-17 19:21:20 -0500211 "$workspace/${dtb_type}.pre.dts" -o "$dtb_saveas"
Fathi Boudra422bf772019-12-02 11:10:16 +0200212 esac
213
214 archive_file "$dtb_saveas"
215}
216
217get_rootfs() {
218 local tmpdir
219 local fs_base="$(echo $(basename $rootfs_url) | sed 's/\.gz$//')"
220 local cached="$project_filer/ci-files/$fs_base"
221
222 if upon "$jenkins_run" && [ -f "$cached" ]; then
223 # Job workspace is limited in size, and the root file system is
224 # quite large. This means, parallel runs of root file system
225 # tests could fail. So, for Jenkins runs, copy and use the root
226 # file system image from the $CI_SCRATCH location
227 local private="$CI_SCRATCH/$JOB_NAME-$BUILD_NUMBER"
228 mkdir -p "$private"
229 rm -f "$private/rootfs.bin"
230 url="$cached" saveas="$private/rootfs.bin" fetch_file
231 ln -s "$private/rootfs.bin" "$archive/rootfs.bin"
232 return
233 fi
234
235 tmpdir="$(mktempdir)"
236 pushd "$tmpdir"
237 url="$rootfs_url" saveas="rootfs.bin" fetch_file
238
239 # Possibly, the filesystem image we just downloaded is compressed.
240 # Decompress it if required.
241 if file "rootfs.bin" | grep -iq 'gzip compressed data'; then
242 echo "Decompressing root file system image rootfs.bin ..."
243 gunzip --stdout "rootfs.bin" > uncompressed_fs.bin
244 mv uncompressed_fs.bin "rootfs.bin"
245 fi
246
247 archive_file "rootfs.bin"
248 popd
249}
250
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200251fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i"
252
Fathi Boudra422bf772019-12-02 11:10:16 +0200253fvp_romlib_runtime() {
254 local tmpdir="$(mktempdir)"
255
256 # Save BL1 and romlib binaries from original build
257 mv "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" "$tmpdir/romlib.bin"
258 mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin"
259
260 # Patch index file
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200261 cp "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" "$fvp_romlib_jmptbl_backup"
262 sed -i '/fdt/ s/.$/&\ patch/' ${tf_root:?}/plat/arm/board/fvp/jmptbl.i
Fathi Boudra422bf772019-12-02 11:10:16 +0200263
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200264 # Rebuild with patched file
265 echo "Building patched romlib:"
266 build_tf
Fathi Boudra422bf772019-12-02 11:10:16 +0200267
Fathi Boudra422bf772019-12-02 11:10:16 +0200268 # Retrieve original BL1 and romlib binaries
269 mv "$tmpdir/romlib.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin"
270 mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin"
271}
272
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200273fvp_romlib_cleanup() {
274 # Restore original index
275 mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
276}
277
278
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500279fvp_gen_bin_url() {
280 local bin_mode="${bin_mode:?}"
281 local bin="${1:?}"
282
283 if upon "$jenkins_run"; then
284 echo "$jenkins_url/job/$JOB_NAME/$BUILD_NUMBER/artifact/artefacts/$bin_mode/$bin"
285 else
286 echo "file://$workspace/artefacts/$bin_mode/$bin"
287 fi
288}
289
Chris Kayfbbf1322022-10-05 13:13:32 +0100290# Generates the template for YAML-based LAVA job definitions from a file
291# corresponding to the currently-selected payload, e.g.:
292#
293# - `lava-templates/fvp-linux.yaml`
294# - `lava-templates/fvp-tftf.yaml`
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500295gen_fvp_yaml_template() {
Chris Kayfbbf1322022-10-05 13:13:32 +0100296 local yaml_template_file="${workspace}/fvp_template.yaml"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500297
Chris Kayc9523b12022-10-10 18:32:20 +0100298 cp "${ci_root}/script/lava-templates/fvp-${payload_type:?}.yaml" \
299 "${yaml_template_file}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500300
Chris Kayfbbf1322022-10-05 13:13:32 +0100301 archive_file "${yaml_template_file}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500302}
303
Chris Kayc9523b12022-10-10 18:32:20 +0100304# Generates the final YAML-based LAVA job definition from a template file.
305#
306# The job definition template is expanded with visibility of all variables that
307# are available from within the function, including those with local scope.
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500308gen_fvp_yaml() {
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600309 local model="${model:?}"
310
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500311 local yaml_template_file="$workspace/fvp_template.yaml"
312 local yaml_file="$workspace/fvp.yaml"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500313 local yaml_job_file="$workspace/job.yaml"
314 local lava_model_params="$workspace/lava_model_params"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500315
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500316 # this function expects a template, quit if it is not present
317 if [ ! -f "$yaml_template_file" ]; then
Paul Sokolovskyf56d9d22023-01-24 18:33:58 +0700318 echo "warning: gen_fvp_yaml: template $yaml_template_file not available, skipping generating LAVA job"
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500319 return
320 fi
321
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600322 local model_params="${fvp_models[$model]}"
323 local model_name="$(echo "${model_params}" | awk -F ';' '{print $1}')"
324 local model_dir="$(echo "${model_params}" | awk -F ';' '{print $2}')"
325 local model_bin="$(echo "${model_params}" | awk -F ';' '{print $3}')"
326
327 # model params are required for correct yaml creation, quit if empty
328 if [ -z "${model_name}" ]; then
329 echo "FVP model param 'model_name' variable empty, yaml not produced"
330 return
331 elif [ -z "${model_dir}" ]; then
332 echo "FVP model param 'model_dir' variable empty, yaml not produced"
333 return
334 elif [ -z "${model_bin}" ]; then
335 echo "FVP model param 'model_bin' variable empty, yaml not produced"
336 return
337 fi
338
339 echo "FVP model params: model_name=$model_name model_dir=$model_dir model_bin=$model_bin"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500340
341 # optional parameters, defaults to globals
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500342 local model_dtb="${model_dtb:-$default_model_dtb}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500343
Chris Kayc9523b12022-10-10 18:32:20 +0100344 if [ -n "${GERRIT_CHANGE_NUMBER}" ]; then
345 local gerrit_url="https://review.trustedfirmware.org/c/${GERRIT_CHANGE_NUMBER}/${GERRIT_PATCHSET_NUMBER}"
346 elif [ -n "${GERRIT_REFSPEC}" ]; then
347 local gerrit_url=$(echo ${GERRIT_REFSPEC} |
348 awk -F/ '{print "https://review.trustedfirmware.org/c/" $4 "/" $5}')
349 fi
350
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500351 docker_registry="${docker_registry:-}"
352 docker_registry="$(docker_registry_append)"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500353 docker_name="${docker_registry}$model_name"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600354 prompt1='/ #'
355 prompt2='root@genericarmv8:~#'
356 version_string="\"Fast Models"' [^\\n]+'"\""
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500357
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500358 test_config="${TEST_CONFIG}"
359
Chris Kay4eb9ded2022-10-10 15:51:40 +0100360 declare -A artefact_filters=(
361 [backup_fip]="backup_fip.bin"
362 [bl1]="bl1.bin"
363 [bl2]="bl2.bin"
364 [bl31]="bl31.bin"
365 [bl32]="bl32.bin"
366 [busybox]="busybox.bin"
367 [cactus_primary]="cactus-primary.pkg"
368 [cactus_secondary]="cactus-secondary.pkg"
369 [cactus_tertiary]="cactus-tertiary.pkg"
370 [coverage_trace_plugin]="coverage_trace.so"
371 [dtb]="dtb.bin"
372 [el3_payload]="el3_payload.bin"
Manish V Badarkhedbb9cb12022-11-16 12:30:41 +0000373 [ete_trace]="libete-plugin.so"
374 [etm_trace]="ETMv4ExamplePlugin.so"
Chris Kay4eb9ded2022-10-10 15:51:40 +0100375 [fip_gpt]="fip_gpt.bin"
376 [fip]="fip.bin"
377 [fvp_spmc_manifest_dtb]="=fvp_spmc_manifest.dtb"
378 [fwu_fip]="fwu_fip.bin"
379 [generic_trace]="GenericTrace.so"
380 [hafnium]="hafnium.bin"
381 [image]="kernel.bin"
382 [ivy]="ivy.pkg"
383 [manifest_dtb]="=manifest.dtb"
Chris Kayfbdd0142022-11-08 12:24:30 +0000384 [mcp_fw]="mcp_fw.bin"
Manish V Badarkhe18c59782022-11-09 10:14:48 +0000385 [mcp_ram]="mcp_ram.bin"
Chris Kay4eb9ded2022-10-10 15:51:40 +0100386 [mcp_rom_hyphen]="mcp-rom.bin"
387 [mcp_rom]="mcp_rom.bin"
388 [ns_bl1u]="ns_bl1u.bin"
389 [ns_bl2u]="ns_bl2u.bin"
390 [ramdisk]="initrd.bin|initrd.img"
391 [romlib]="romlib.bin"
392 [rootfs]="rootfs.bin"
Manish V Badarkhe93093dd2022-11-09 10:29:27 +0000393 [rss_flash]="rss_flash.bin"
394 [rss_rom]="rss_rom.bin"
Chris Kayfbdd0142022-11-08 12:24:30 +0000395 [scp_fw]="scp_fw.bin"
Chris Kay4eb9ded2022-10-10 15:51:40 +0100396 [scp_ram_hyphen]="scp-ram.bin"
397 [scp_ram]="scp_ram.bin"
398 [scp_rom_hyphen]="scp-rom.bin"
399 [scp_rom]="scp_rom.bin"
400 [secure_hafnium]="secure_hafnium.bin"
401 [spm]="spm.bin"
402 [tftf]="tftf.bin"
403 [tmp]="tmp.bin"
404 [uboot]="uboot.bin"
405 )
406
Chris Kayc14743a2022-10-13 11:33:26 +0100407 declare -A artefact_urls=(
408 [backup_fip]="$(fvp_gen_bin_url backup_fip.bin)"
409 [bl1]="$(fvp_gen_bin_url bl1.bin)"
410 [bl2]="$(fvp_gen_bin_url bl2.bin)"
411 [bl31]="$(fvp_gen_bin_url bl31.bin)"
412 [bl32]="$(fvp_gen_bin_url bl32.bin)"
413 [busybox]="$(fvp_gen_bin_url busybox.bin.gz)"
414 [cactus_primary]="$(fvp_gen_bin_url cactus-primary.pkg)"
415 [cactus_secondary]="$(fvp_gen_bin_url cactus-secondary.pkg)"
416 [cactus_tertiary]="$(fvp_gen_bin_url cactus-tertiary.pkg)"
417 [coverage_trace_plugin]="${coverage_trace_plugin}"
418 [dtb]="$(fvp_gen_bin_url ${model_dtb})"
419 [el3_payload]="$(fvp_gen_bin_url el3_payload.bin)"
Manish V Badarkhedbb9cb12022-11-16 12:30:41 +0000420 [ete_trace]="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/libete-plugin.so"
421 [etm_trace]="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/ETMv4ExamplePlugin.so"
Chris Kayc14743a2022-10-13 11:33:26 +0100422 [fip]="$(fvp_gen_bin_url fip.bin)"
423 [fip_gpt]="$(fvp_gen_bin_url fip_gpt.bin)"
424 [fvp_spmc_manifest_dtb]="$(fvp_gen_bin_url fvp_spmc_manifest.dtb)"
425 [fwu_fip]="$(fvp_gen_bin_url fwu_fip.bin)"
426 [generic_trace]="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/GenericTrace.so"
427 [hafnium]="$(fvp_gen_bin_url hafnium.bin)"
428 [image]="$(fvp_gen_bin_url kernel.bin)"
429 [ivy]="$(fvp_gen_bin_url ivy.pkg)"
430 [manifest_dtb]="$(fvp_gen_bin_url manifest.dtb)"
Chris Kayfbdd0142022-11-08 12:24:30 +0000431 [mcp_fw]="$(fvp_gen_bin_url mcp_fw.bin)"
Manish V Badarkhe18c59782022-11-09 10:14:48 +0000432 [mcp_ram]="$(fvp_gen_bin_url mcp_ram.bin)"
Chris Kayc14743a2022-10-13 11:33:26 +0100433 [mcp_rom]="$(fvp_gen_bin_url mcp_rom.bin)"
434 [mcp_rom_hyphen]="$(fvp_gen_bin_url mcp-rom.bin)"
435 [ns_bl1u]="$(fvp_gen_bin_url ns_bl1u.bin)"
436 [ns_bl2u]="$(fvp_gen_bin_url ns_bl2u.bin)"
437 [ramdisk]="$(fvp_gen_bin_url initrd.bin)"
438 [romlib]="$(fvp_gen_bin_url romlib.bin)"
439 [rootfs]="$(fvp_gen_bin_url rootfs.bin.gz)"
Manish V Badarkhe93093dd2022-11-09 10:29:27 +0000440 [rss_flash]="$(fvp_gen_bin_url rss_flash.bin)"
441 [rss_rom]="$(fvp_gen_bin_url rss_rom.bin)"
Chris Kayc14743a2022-10-13 11:33:26 +0100442 [secure_hafnium]="$(fvp_gen_bin_url secure_hafnium.bin)"
Chris Kayfbdd0142022-11-08 12:24:30 +0000443 [scp_fw]="$(fvp_gen_bin_url scp_fw.bin)"
Chris Kayc14743a2022-10-13 11:33:26 +0100444 [scp_ram]="$(fvp_gen_bin_url scp_ram.bin)"
445 [scp_ram_hyphen]="$(fvp_gen_bin_url scp-ram.bin)"
446 [scp_rom]="$(fvp_gen_bin_url scp_rom.bin)"
447 [scp_rom_hyphen]="$(fvp_gen_bin_url scp-rom.bin)"
448 [spm]="$(fvp_gen_bin_url spm.bin)"
449 [tftf]="$(fvp_gen_bin_url tftf.bin)"
450 [tmp]="$(fvp_gen_bin_url tmp.bin)"
451 [uboot]="$(fvp_gen_bin_url uboot.bin)"
452 )
453
Chris Kay5d550d82022-10-12 17:20:31 +0100454 # In LAVA we don't provide the paths to the artefacts directly, but instead
455 # use macros of the form `{XYZ}`. This is a list of regular expression
456 # replacements to run on the model parameters file before we add them to the
457 # LAVA job definition.
458 declare -A artefact_macros=(
459 ["[= ]backup_fip.bin"]="={BACKUP_FIP}"
460 ["[= ]bl1.bin"]="={BL1}"
461 ["[= ]bl2.bin"]="={BL2}"
462 ["[= ]bl31.bin"]="={BL31}"
463 ["[= ]bl32.bin"]="={BL32}"
464 ["[= ]cactus-primary.pkg"]="={CACTUS_PRIMARY}"
465 ["[= ]cactus-secondary.pkg"]="={CACTUS_SECONDARY}"
466 ["[= ]cactus-tertiary.pkg"]="={CACTUS_TERTIARY}"
467 ["[= ].*coverage_trace.so"]="={COVERAGE_TRACE_PLUGIN}"
468 ["[= ]fvp_spmc_manifest.dtb"]="={FVP_SPMC_MANIFEST_DTB}"
469 ["[= ]busybox.bin"]="={BUSYBOX}"
470 ["[= ]dtb.bin"]="={DTB}"
471 ["[= ]el3_payload.bin"]="={EL3_PAYLOAD}"
Manish V Badarkhedbb9cb12022-11-16 12:30:41 +0000472 ["[= ].*libete-plugin.so"]="={ETE_TRACE}"
473 ["[= ].*ETMv4ExamplePlugin.so"]="={ETM_TRACE}"
Chris Kay5d550d82022-10-12 17:20:31 +0100474 ["[= ]fip_gpt.bin"]="={FIP_GPT}"
475 ["[= ]fwu_fip.bin"]="={FWU_FIP}"
476 ["[= ]fip.bin"]="={FIP}"
477 ["[= ].*GenericTrace.so"]="={GENERIC_TRACE}"
478 ["[= ].*/hafnium.bin"]="={HAFNIUM}"
479 ["[= ]kernel.bin"]="={IMAGE}"
480 ["[= ]ivy.pkg"]="={IVY}"
481 ["[= ]manifest.dtb"]="={MANIFEST_DTB}"
Chris Kayfbdd0142022-11-08 12:24:30 +0000482 ["[= ]mcp_fw.bin"]="={MCP_FW}"
Manish V Badarkhe18c59782022-11-09 10:14:48 +0000483 ["[= ]mcp_ram.bin"]="={MCP_RAM}"
Chris Kayef9cc802022-11-08 12:11:58 +0000484 ["[= ]mcp_rom.bin"]="={MCP_ROM}"
485 ["[= ]mcp-rom.bin"]="={MCP_ROM_HYPHEN}"
Chris Kay5d550d82022-10-12 17:20:31 +0100486 ["[= ]ns_bl1u.bin"]="={NS_BL1U}"
487 ["[= ]ns_bl2u.bin"]="={NS_BL2U}"
488 ["[= ]initrd.bin"]="={RAMDISK}"
489 ["[= ]initrd.img"]="={RAMDISK}"
490 ["[= ]romlib.bin"]="={ROMLIB}"
491 ["[= ]rootfs.bin"]="={ROOTFS}"
Manish V Badarkhe93093dd2022-11-09 10:29:27 +0000492 ["[= ]rss_flash.bin"]="={RSS_FLASH}"
493 ["[= ]rss_rom.bin"]="={RSS_ROM}"
Chris Kay5d550d82022-10-12 17:20:31 +0100494 ["[= ].*/secure_hafnium.bin"]="={SECURE_HAFNIUM}"
Chris Kayfbdd0142022-11-08 12:24:30 +0000495 ["[= ]scp_fw.bin"]="={SCP_FW}"
Chris Kay5d550d82022-10-12 17:20:31 +0100496 ["[= ]scp_ram.bin"]="={SCP_RAM}"
497 ["[= ]scp-ram.bin"]="={SCP_RAM_HYPHEN}"
498 ["[= ]scp_rom.bin"]="={SCP_ROM}"
499 ["[= ]scp-rom.bin"]="={SCP_ROM_HYPHEN}"
500 ["[= ]spm.bin"]="={SPM}"
501 ["[= ]tftf.bin"]="={TFTF}"
502 ["[= ].*/tmp.bin"]="={TMP}"
503 ["[= ]uboot.bin"]="={UBOOT}"
504 )
505
Chris Kay4eb9ded2022-10-10 15:51:40 +0100506 declare -a artefacts=()
507
508 for artefact in "${!artefact_filters[@]}"; do
509 if grep -E -q "${artefact_filters[${artefact}]}" "${archive}/model_params"; then
510 artefacts+=("${artefact}")
511 fi
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600512 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500513
Chris Kayc92d9fc2022-10-13 11:19:27 +0100514 # Derive LAVA model parameters from the non-LAVA ones
515 cp "${archive}/model_params" "${lava_model_params}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600516
Chris Kayf07d3392022-10-26 15:42:48 +0100517 # Ensure braces in the FVP model parameters are not accidentally interpreted
518 # as LAVA macros.
519 sed -i -e 's/{/{{/g' "${lava_model_params}"
520 sed -i -e 's/}/}}/g' "${lava_model_params}"
521
Chris Kay5d550d82022-10-12 17:20:31 +0100522 # LAVA expects FVP binary paths as macros, i.e. `{X}` instead of `x.bin`, so
523 # replace the file paths in our pre-generated model parameters.
524 for regex in "${!artefact_macros[@]}"; do
525 sed -i -e "s!${regex}!${artefact_macros[${regex}]}!" \
526 "${lava_model_params}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600527 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500528
Chris Kayc92d9fc2022-10-13 11:19:27 +0100529 # Read boot arguments into an array so that the job template file can
530 # iterate over them.
531 readarray -t boot_arguments < "${lava_model_params}"
532
Chris Kay04b70192022-10-19 17:03:37 +0100533 # Source runtime environment variables now so that they are accessible from
534 # the LAVA job template.
535 local run_root="${archive}/run"
536 local run_env="${run_root}/env"
537
538 if [ -f "${run_env}" ]; then
539 source "${run_env}"
540 fi
541
Chris Kayc92d9fc2022-10-13 11:19:27 +0100542 # Generate the LAVA job definition, minus the test expectations
543 expand_template "${yaml_template_file}" > "${yaml_file}"
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500544
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500545 # Append expect commands into the job definition through test-interactive commands
546 gen_fvp_yaml_expect >> "$yaml_file"
547
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600548 # create job.yaml
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500549 cp "$yaml_file" "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500550
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600551 # archive both yamls
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500552 archive_file "$yaml_file"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500553 archive_file "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500554}
555
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500556gen_fvp_yaml_expect() {
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500557 # Loop through all uarts expect files
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500558 for expect_file in $(find $run_root -name expect); do
Chris Kay04b70192022-10-19 17:03:37 +0100559 local uart_number=$(basename "$(dirname ${expect_file})")
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500560
Chris Kay04b70192022-10-19 17:03:37 +0100561 # Only handle the primary UART through LAVA. The remaining UARTs are
562 # validated after LAVA returns by the post-expect script.
Chris Kaya75c0a62022-11-17 18:53:50 +0000563 if [ "${uart_number:?}" != "uart$(get_primary_uart "${archive}")" ]; then
Chris Kay04b70192022-10-19 17:03:37 +0100564 continue
565 fi
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500566
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500567 # Array containing "interactive" or "monitor" expect strings and populated during run config execution.
568 # Interactive expect scripts are converted into LAVA Interactive Test Actions (see
569 # https://tf.validation.linaro.org/static/docs/v2/interactive.html#writing-tests-interactive) and
570 # monitor expect scripts are converted into LAVA Monitor Test Actions (see
571 # https://validation.linaro.org/static/docs/v2/actions-test.html#monitor)
572 #
573 # Interactive Expect strings have the format 'i;<prompt>;<succeses>;<failures>;<commands>'
574 # where multiple successes or failures or commands are separated by @
575 #
576 # Monitor Expect strings have the format 'm;<start>;<end>;<patterns>'
577 # where multiple patterns are separated by @
578 #
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500579 expect_string=()
580
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500581 # Get the real name of the expect file
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500582 expect_file=$(cat $expect_file)
583
584 # Source the run_config enviroment variables
585 env=$run_root/$uart_number/env
586 if [ -e $env ]; then
587 source $env
588 fi
589
590 # Get all expect strings
Chris Kay047af3e2022-09-30 17:10:28 +0100591 expect_dir="${ci_root}/expect-lava"
592 expect_file="${expect_dir}/${expect_file}"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500593
Chris Kay047af3e2022-09-30 17:10:28 +0100594 # Allow the expectations to be provided directly in LAVA's job YAML
595 # format, rather than converting it from a pseudo-Expect Bash script in
596 # the block below.
597 if [ -f "${expect_file/.exp/.yaml}" ]; then
598 pushd "${expect_dir}"
599 expand_template "${expect_file/.exp/.yaml}"
600 popd
601
602 continue
603 else
604 source "${expect_file}"
605 fi
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500606
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500607 if [ ${#expect_string[@]} -gt 0 ]; then
608
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500609 # expect loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500610 for key in "${!expect_string[@]}"; do
611
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500612 # single raw expect string
613 es="${expect_string[${key}]}"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500614
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500615 # action type: either m or i
616 action="$(echo "${es}" | awk -F ';' '{print $1}')"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500617
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500618 if [ "${action}" = "m" ]; then
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500619
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500620 start="$(echo "${es}" | awk -F ';' '{print $2}')"
621 end="$(echo "${es}" | awk -F ';' '{print $3}')"
622 patterns="$(echo "${es}" | awk -F ';' '{print $4}')"
623
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500624 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500625- test:
626 monitors:
627 - name: tests
628 start: '${start}'
629 end: '${end}'
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500630EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500631 # Patterns are separated by '@'
632 OLD_IFS=$IFS; IFS=$'@'
633 for p in ${patterns}; do
634 cat << EOF
635 pattern: '$p'
636EOF
637 done
638 IFS=$OLD_IFS
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500639 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500640 fixupdict:
641 PASS: pass
642 FAIL: fail
643EOF
644 fi # end of monitor action
645
646 if [ "${action}" = "i" ]; then
647
648 prompts="$(echo "${es}" | awk -F ';' '{print $2}')"
649 successes="$(echo "${es}" | awk -F ';' '{print $3}')"
650 failures="$(echo "${es}" | awk -F ';' '{print $4}')"
651 commands="$(echo "${es}" | awk -F ';' '{print $5}')"
652
653 cat << EOF
654- test:
655 interactive:
656EOF
657 OLD_IFS=$IFS; IFS=$'@'
658
659 if [[ -n "${prompts}" && -n "${successes}" && -n "${failures}" ]]; then
660 cat << EOF
661 - name: interactive_${uart_number}_${key}
662 prompts: ['${prompts}']
663 script:
664EOF
665 if [ -z "${commands}" ]; then
666 cat <<EOF
667 - name: interactive_command_${uart_number}_${key}
668 command:
669EOF
670 else
671 for c in ${commands}; do
672 cat <<EOF
673 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300674 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500675EOF
676 done
677 fi
678 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500679 successes:
680EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500681 for s in ${successes}; do
682 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500683 - message: '$s'
684EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500685 done
686 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500687 failures:
688EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500689 for f in ${failures}; do
690 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500691 - message: '$f'
692EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500693 done
Paul Sokolovskya8eaebc2023-05-15 23:13:00 +0300694 cat << EOF
695 exception: JobError
696EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500697 elif [[ -n "${prompts}" && -n "${successes}" ]]; then
698 cat << EOF
699 - name: interactive_${uart_number}_${key}
700 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500701 script:
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500702EOF
703
704 if [ -z "${commands}" ]; then
705 cat <<EOF
706 - name: interactive_command_${uart_number}_${key}
707 command:
708EOF
709 else
710 for c in ${commands}; do
711 cat <<EOF
712 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300713 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500714EOF
715 done
716 fi
717 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500718 successes:
719EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500720 for s in ${successes}; do
721 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500722 - message: '$s'
723EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500724 done
725
726 elif [[ -n "${prompts}" && -n "${failures}" ]]; then
727 cat << EOF
728 - name: interactive_${uart_number}_${key}
729 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500730 script:
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500731EOF
732 if [ -z "${commands}" ]; then
733 cat <<EOF
734 - name: interactive_command_${uart_number}_${key}
735 command:
736EOF
737 else
738 for c in ${commands}; do
739 cat <<EOF
740 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300741 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500742EOF
743 done
744 fi
745 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500746 failures:
747EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500748 for f in ${failures}; do
749 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500750 - message: '$f'
751EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500752 done
Paul Sokolovskya8eaebc2023-05-15 23:13:00 +0300753 cat << EOF
754 exception: JobError
755EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500756 else
757 cat << EOF
758 - name: interactive_${uart_number}_${key}
759 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500760 script:
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500761EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500762 if [ -z "${commands}" ]; then
763 cat <<EOF
764 - name: interactive_command_${uart_number}_${key}
765 command:
766EOF
767 else
768 for c in ${commands}; do
769 cat <<EOF
770 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300771 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500772EOF
773 done
774 fi
775 fi
776
777 IFS=$OLD_IFS
778 fi # end of interactive action
779
780 done # end of expect loop
781
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500782 fi
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500783 done # end of uart loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500784}
785
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500786docker_registry_append() {
787 # if docker_registry is empty, just use local docker registry
788 [ -z "$docker_registry" ] && return
789
790 local last=-1
791 local last_char="${docker_registry:last}"
792
793 if [ "$last_char" != '/' ]; then
794 docker_registry="${docker_registry}/";
795 fi
796 echo "$docker_registry"
797}
798
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000799# generate GPT image and archive it
800gen_gpt_bin() {
801 raw_image="fip_gpt.bin"
802 img_uuid="FB90808A-BA9A-4D42-B9A2-A7A937144AEE"
803 img_bank_uuid=`uuidgen`
804 disk_uuid=`uuidgen`
805 bin="${1:?}"
806
807 # maximum FIP size 2MB
808 fip_max_size=2097152
809 start_sector=34
810 sector_size=512
811 num_sectors=$(($fip_max_size/$sector_size))
812 bin_size=$(stat -c %s $bin)
813
814 if [[ $fip_max_size -lt $bin_size ]]
815 then
Manish V Badarkhe3640b062022-11-16 11:36:36 +0000816 echo "FIP binary ($bin_size bytes) larger than max partition 1" \
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000817 "size ($fip_max_size byte)"
818 return
819 fi
820
821 # create raw 5MB image
822 dd if=/dev/zero of=$raw_image bs=5M count=1
823
824 # create GPT image
825 sgdisk -a 1 -U $disk_uuid -n 1:$start_sector:+$num_sectors \
826 -c 1:FIP_A -t 1:$img_uuid $raw_image -u $img_bank_uuid
827
828 echo "write binary $bin at sector $start_sector"
829 dd if=$bin of=$raw_image bs=$sector_size seek=$start_sector \
830 count=$num_sectors conv=notrunc
831
832 archive_file "fip_gpt.bin"
833}
834
Fathi Boudra422bf772019-12-02 11:10:16 +0200835set +u