blob: 0cfbe52663a634bf8a495761b024371596fdb3ed [file] [log] [blame]
Leonardo Sandoval9dfdd1b2020-08-06 17:08:11 -05001#!/usr/bin/env bash
Fathi Boudra422bf772019-12-02 11:10:16 +02002#
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -06003# Copyright (c) 2020-2021, 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-arm35faeaa2021-05-03 14:28:17 -050044fvp_arm_std_library_11_12="fvp:fvp_arm_std_library_${model_version_11_12}_${model_build_11_12};/opt/model/FVP_ARM_Std_Library/models/${model_flavour_11_12}"
Maksims Svecovs284a50d2021-11-02 11:09:47 +000045fvp_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 -050046fvp_base_revc_2xaemva="fvp:fvp_base_revc-2xaemva_${model_version}_${model_build};/opt/model/Base_RevC_AEMvA_pkg/models/${model_flavour}"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060047foundation_platform="fvp:foundation_platform_${model_version}_${model_build};/opt/model/Foundation_Platformpkg/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
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060050# FVP associate array, run_config are keys and fvp container parameters are the values
51# Container parameters syntax: <model name>;<model dir>;<model bin>
52# FIXMEs: fix those ;;; values with real values
53
54declare -A fvp_models
55fvp_models=(
56[base-aemv8a-quad]=";;;"
57[base-aemv8a-revb]=";;;"
58[base-aemv8a-latest-revb]=";;;"
59[base-aemva]=";;;"
Manish V Badarkhee4783832021-02-22 14:36:56 +000060[base-aemv8a-gic600ae]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060061[foundationv8]="${foundation_platform};Foundation_Platform"
laurenw-armf414aba2021-04-26 15:58:56 -050062[base-aemv8a]="${fvp_base_revc_2xaemva};FVP_Base_RevC-2xAEMvA"
johpow01936638d2021-11-08 18:22:24 -060063[baser-aemv8r]=";;;"
laurenw-arm35faeaa2021-05-03 14:28:17 -050064[cortex-a32x4]="${fvp_arm_std_library_11_12};FVP_Base_Cortex-A32x4"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060065[cortex-a35x4]="${fvp_arm_std_library};FVP_Base_Cortex-A35x4"
66[cortex-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A53x4"
Leonardo Sandoval95f896b2021-02-22 10:16:29 -060067[cortex-a55x4-a75x4]="${fvp_arm_std_library};FVP_Base_Cortex-A55x4+Cortex-A75x4"
68[cortex-a55x4-a76x2]="${fvp_arm_std_library};FVP_Base_Cortex-A55x4+Cortex-A76x2"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060069[cortex-a57x1-a53x1]="${fvp_arm_std_library};FVP_Base_Cortex-A57x1-A53x1"
70[cortex-a57x2-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x2-A53x4"
71[cortex-a57x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4"
72[cortex-a57x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4-A53x4"
73[cortex-a65aex8]="${fvp_arm_std_library};FVP_Base_Cortex-A65AEx8"
74[cortex-a65x4]="${fvp_arm_std_library};FVP_Base_Cortex-A65x4"
75[cortex-a72x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72x4"
76[cortex-a72x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72x4-A53x4"
77[cortex-a73x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4"
78[cortex-a73x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4-A53x4"
79[cortex-a75x4]="${fvp_arm_std_library};FVP_Base_Cortex-A75x4"
80[cortex-a76aex4]="${fvp_arm_std_library};FVP_Base_Cortex-A76AEx4"
81[cortex-a76aex2]="${fvp_arm_std_library};FVP_Base_Cortex-A76AEx2"
82[cortex-a76x4]="${fvp_arm_std_library};FVP_Base_Cortex-A76x4"
83[cortex-a77x4]="${fvp_arm_std_library};FVP_Base_Cortex-A77x4"
84[cortex-a78x4]="${fvp_arm_std_library};FVP_Base_Cortex-A78x4"
laurenw-arm06c4a192022-07-12 14:55:28 -050085[cortex-a78cx4]="${fvp_arm_std_library};FVP_Base_Cortex-A78Cx4"
johpow011008edc2022-02-01 18:50:33 -060086[cortex-x2]="${fvp_arm_std_library};FVP_Base_Cortex-X2x4"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060087[neoverse_e1x1]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x1"
88[neoverse_e1x2]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x2"
89[neoverse_e1x4]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x4"
Leonardo Sandoval54f1ade2021-06-26 19:20:48 -050090[neoverse_n1]="${fvp_arm_std_library};FVP_Base_Neoverse-N1x4"
Maksims Svecovsd10c1b92021-10-06 10:25:40 +010091[neoverse_n2]="${fvp_arm_std_library_11_12};FVP_Base_Neoverse-N1x4"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060092[neoverse-v1x4]=";;;"
Manish V Badarkhecbed15e2021-07-02 09:34:53 +010093[cortexa710x4]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060094[css-rdv1]=";;;"
95[css-rde1edge]=";;;"
96[css-rdn1edge]=";;;"
97[css-rdn1edgex2]=";;;"
98[css-sgi575]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060099[tc0]=";;;"
Usama Arifcba711d2021-08-04 15:53:42 +0100100[tc1]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600101)
102
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500103
Fathi Boudra422bf772019-12-02 11:10:16 +0200104# FVP Kernel URLs
105declare -A fvp_kernels
106fvp_kernels=(
107[fvp-aarch32-zimage]="$linaro_release/fvp32-latest-busybox-uboot/Image"
108[fvp-busybox-uboot]="$linaro_release/fvp-latest-busybox-uboot/Image"
109[fvp-oe-uboot32]="$linaro_release/fvp32-latest-oe-uboot/Image"
110[fvp-oe-uboot]="$linaro_release/fvp-latest-oe-uboot/Image"
111[fvp-quad-busybox-uboot]="$tfa_downloads/quad_cluster/Image"
112)
113
Fathi Boudra422bf772019-12-02 11:10:16 +0200114# FVP initrd URLs
115declare -A fvp_initrd_urls
116fvp_initrd_urls=(
117[aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img"
Fathi Boudra422bf772019-12-02 11:10:16 +0200118[dummy-ramdisk]="$linaro_release/fvp-latest-oe-uboot/ramdisk.img"
119[dummy-ramdisk32]="$linaro_release/fvp32-latest-oe-uboot/ramdisk.img"
120[default]="$linaro_release/fvp-latest-busybox-uboot/ramdisk.img"
121)
122
Fathi Boudra422bf772019-12-02 11:10:16 +0200123get_optee_bin() {
Sandrine Bailleux25ff2942021-02-25 14:00:10 +0100124 url="$tfa_downloads/optee/tee.bin" \
125 saveas="bl32.bin" fetch_file
Fathi Boudra422bf772019-12-02 11:10:16 +0200126 archive_file "bl32.bin"
127}
128
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100129# For Measured Boot tests using a TA based on OPTEE, it is necessary to use a
130# specific build rather than the default one generated by Jenkins.
131get_ftpm_optee_bin() {
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100132 url="$tfa_downloads/ftpm/optee/tee-header_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100133 saveas="bl32.bin" fetch_file
134 archive_file "bl32.bin"
135
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100136 url="$tfa_downloads/ftpm/optee/tee-pager_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100137 saveas="bl32_extra1.bin" fetch_file
138 archive_file "bl32_extra1.bin"
139
Leonardo Sandovalda5f78d2021-03-18 11:09:30 -0600140 # tee-pageable_v2.bin is just a empty file, named as bl32_extra2.bin,
141 # so just create the file
142 touch "bl32_extra2.bin"
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100143 archive_file "bl32_extra2.bin"
144}
145
Fathi Boudra422bf772019-12-02 11:10:16 +0200146get_uboot32_bin() {
147 local tmpdir="$(mktempdir)"
148
149 pushd "$tmpdir"
150 extract_fip "$uboot32_fip_url"
151 mv "nt-fw.bin" "uboot.bin"
152 archive_file "uboot.bin"
153 popd
154}
155
156get_uboot_bin() {
157 local uboot_url="$linaro_release/fvp-latest-busybox-uboot/bl33-uboot.bin"
158
159 url="$uboot_url" saveas="uboot.bin" fetch_file
160 archive_file "uboot.bin"
161}
162
163get_uefi_bin() {
Zelalem219df412020-05-17 19:21:20 -0500164 uefi_downloads="${uefi_downloads:-http://files.oss.arm.com/downloads/uefi}"
165 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 +0200166
167 url=$uefi_ci_bin_url saveas="uefi.bin" fetch_file
168 archive_file "uefi.bin"
169}
170
171get_kernel() {
172 local kernel_type="${kernel_type:?}"
173 local url="${fvp_kernels[$kernel_type]}"
174
175 url="${url:?}" saveas="kernel.bin" fetch_file
176 archive_file "kernel.bin"
177}
178
179get_initrd() {
180 local initrd_type="${initrd_type:?}"
181 local url="${fvp_initrd_urls[$initrd_type]}"
182
183 url="${url:?}" saveas="initrd.bin" fetch_file
184 archive_file "initrd.bin"
185}
186
187get_dtb() {
188 local dtb_type="${dtb_type:?}"
189 local dtb_url
190 local dtb_saveas="$workspace/dtb.bin"
Zelalem219df412020-05-17 19:21:20 -0500191 local cc="$(get_tf_opt CROSS_COMPILE)"
192 local pp_flags="-P -nostdinc -undef -x assembler-with-cpp"
Fathi Boudra422bf772019-12-02 11:10:16 +0200193
194 case "$dtb_type" in
195 "fvp-base-quad-cluster-gicv3-psci")
196 # Get the quad-cluster FDT from pdsw area
197 dtb_url="$tfa_downloads/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb"
198 url="$dtb_url" saveas="$dtb_saveas" fetch_file
199 ;;
Fathi Boudra422bf772019-12-02 11:10:16 +0200200 *)
Zelalem219df412020-05-17 19:21:20 -0500201 # Preprocess DTS file
202 ${cc}gcc -E ${pp_flags} -I"$tf_root/fdts" -I"$tf_root/include" \
203 -o "$workspace/${dtb_type}.pre.dts" \
204 "$tf_root/fdts/${dtb_type}.dts"
205 # Generate DTB file from DTS
Fathi Boudra422bf772019-12-02 11:10:16 +0200206 dtc -I dts -O dtb \
Zelalem219df412020-05-17 19:21:20 -0500207 "$workspace/${dtb_type}.pre.dts" -o "$dtb_saveas"
Fathi Boudra422bf772019-12-02 11:10:16 +0200208 esac
209
210 archive_file "$dtb_saveas"
211}
212
213get_rootfs() {
214 local tmpdir
215 local fs_base="$(echo $(basename $rootfs_url) | sed 's/\.gz$//')"
216 local cached="$project_filer/ci-files/$fs_base"
217
218 if upon "$jenkins_run" && [ -f "$cached" ]; then
219 # Job workspace is limited in size, and the root file system is
220 # quite large. This means, parallel runs of root file system
221 # tests could fail. So, for Jenkins runs, copy and use the root
222 # file system image from the $CI_SCRATCH location
223 local private="$CI_SCRATCH/$JOB_NAME-$BUILD_NUMBER"
224 mkdir -p "$private"
225 rm -f "$private/rootfs.bin"
226 url="$cached" saveas="$private/rootfs.bin" fetch_file
227 ln -s "$private/rootfs.bin" "$archive/rootfs.bin"
228 return
229 fi
230
231 tmpdir="$(mktempdir)"
232 pushd "$tmpdir"
233 url="$rootfs_url" saveas="rootfs.bin" fetch_file
234
235 # Possibly, the filesystem image we just downloaded is compressed.
236 # Decompress it if required.
237 if file "rootfs.bin" | grep -iq 'gzip compressed data'; then
238 echo "Decompressing root file system image rootfs.bin ..."
239 gunzip --stdout "rootfs.bin" > uncompressed_fs.bin
240 mv uncompressed_fs.bin "rootfs.bin"
241 fi
242
243 archive_file "rootfs.bin"
244 popd
245}
246
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200247fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i"
248
Fathi Boudra422bf772019-12-02 11:10:16 +0200249fvp_romlib_runtime() {
250 local tmpdir="$(mktempdir)"
251
252 # Save BL1 and romlib binaries from original build
253 mv "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" "$tmpdir/romlib.bin"
254 mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin"
255
256 # Patch index file
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200257 cp "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" "$fvp_romlib_jmptbl_backup"
258 sed -i '/fdt/ s/.$/&\ patch/' ${tf_root:?}/plat/arm/board/fvp/jmptbl.i
Fathi Boudra422bf772019-12-02 11:10:16 +0200259
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200260 # Rebuild with patched file
261 echo "Building patched romlib:"
262 build_tf
Fathi Boudra422bf772019-12-02 11:10:16 +0200263
Fathi Boudra422bf772019-12-02 11:10:16 +0200264 # Retrieve original BL1 and romlib binaries
265 mv "$tmpdir/romlib.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin"
266 mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin"
267}
268
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200269fvp_romlib_cleanup() {
270 # Restore original index
271 mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
272}
273
274
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500275fvp_gen_bin_url() {
276 local bin_mode="${bin_mode:?}"
277 local bin="${1:?}"
278
279 if upon "$jenkins_run"; then
280 echo "$jenkins_url/job/$JOB_NAME/$BUILD_NUMBER/artifact/artefacts/$bin_mode/$bin"
281 else
282 echo "file://$workspace/artefacts/$bin_mode/$bin"
283 fi
284}
285
286gen_fvp_yaml_template() {
287 local yaml_template_file="$workspace/fvp_template.yaml"
288
289 # must parameters for yaml generation
290 local payload_type="${payload_type:?}"
291
292 "$ci_root/script/gen_fvp_${payload_type}_yaml.sh" > "$yaml_template_file"
293
294 archive_file "$yaml_template_file"
295}
296
297gen_fvp_yaml() {
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600298 local model="${model:?}"
299
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500300 local yaml_template_file="$workspace/fvp_template.yaml"
301 local yaml_file="$workspace/fvp.yaml"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500302 local yaml_job_file="$workspace/job.yaml"
303 local lava_model_params="$workspace/lava_model_params"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500304
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500305 # this function expects a template, quit if it is not present
306 if [ ! -f "$yaml_template_file" ]; then
307 return
308 fi
309
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600310 local model_params="${fvp_models[$model]}"
311 local model_name="$(echo "${model_params}" | awk -F ';' '{print $1}')"
312 local model_dir="$(echo "${model_params}" | awk -F ';' '{print $2}')"
313 local model_bin="$(echo "${model_params}" | awk -F ';' '{print $3}')"
314
315 # model params are required for correct yaml creation, quit if empty
316 if [ -z "${model_name}" ]; then
317 echo "FVP model param 'model_name' variable empty, yaml not produced"
318 return
319 elif [ -z "${model_dir}" ]; then
320 echo "FVP model param 'model_dir' variable empty, yaml not produced"
321 return
322 elif [ -z "${model_bin}" ]; then
323 echo "FVP model param 'model_bin' variable empty, yaml not produced"
324 return
325 fi
326
327 echo "FVP model params: model_name=$model_name model_dir=$model_dir model_bin=$model_bin"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500328
329 # optional parameters, defaults to globals
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500330 local model_dtb="${model_dtb:-$default_model_dtb}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500331
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600332 # possible artefacts
333 backup_fip="$(fvp_gen_bin_url backup_fip.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500334 bl1="$(fvp_gen_bin_url bl1.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600335 bl2="$(fvp_gen_bin_url bl2.bin)"
336 bl31="$(fvp_gen_bin_url bl31.bin)"
337 bl32="$(fvp_gen_bin_url bl32.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600338 busybox="$(fvp_gen_bin_url busybox.bin.gz)"
339 cactus_primary="$(fvp_gen_bin_url cactus-primary.pkg)"
340 cactus_secondary="$(fvp_gen_bin_url cactus-secondary.pkg)"
341 cactus_tertiary="$(fvp_gen_bin_url cactus-tertiary.pkg)"
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500342 coverage_trace_plugin="${coverage_trace_plugin}"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500343 dtb="$(fvp_gen_bin_url ${model_dtb})"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600344 el3_payload="$(fvp_gen_bin_url el3_payload.bin)"
345 fip="$(fvp_gen_bin_url fip.bin)"
Leonardo Sandovalcc52beb2021-05-05 19:05:31 -0500346 fip_gpt="$(fvp_gen_bin_url fip_gpt.bin)"
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600347 fvp_spmc_manifest_dtb="$(fvp_gen_bin_url fvp_spmc_manifest.dtb)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600348 fwu_fip="$(fvp_gen_bin_url fwu_fip.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600349 generic_trace="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/GenericTrace.so"
350 hafnium="$(fvp_gen_bin_url hafnium.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500351 image="$(fvp_gen_bin_url kernel.bin)"
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600352 ivy="$(fvp_gen_bin_url ivy.pkg)"
353 manifest_dtb="$(fvp_gen_bin_url manifest.dtb)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600354 mcp_rom="$(fvp_gen_bin_url mcp_rom.bin)"
355 mcp_rom_hyphen="$(fvp_gen_bin_url mcp-rom.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500356 ns_bl1u="$(fvp_gen_bin_url ns_bl1u.bin)"
357 ns_bl2u="$(fvp_gen_bin_url ns_bl2u.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600358 ramdisk="$(fvp_gen_bin_url initrd.bin)"
359 romlib="$(fvp_gen_bin_url romlib.bin)"
360 rootfs="$(fvp_gen_bin_url rootfs.bin.gz)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600361 secure_hafnium="$(fvp_gen_bin_url secure_hafnium.bin)"
362 scp_ram="$(fvp_gen_bin_url scp_ram.bin)"
363 scp_ram_hyphen="$(fvp_gen_bin_url scp-ram.bin)"
364 scp_rom="$(fvp_gen_bin_url scp_rom.bin)"
365 scp_rom_hyphen="$(fvp_gen_bin_url scp-rom.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600366 spm="$(fvp_gen_bin_url spm.bin)"
367 tftf="$(fvp_gen_bin_url tftf.bin)"
368 tmp="$(fvp_gen_bin_url tmp.bin)"
369 uboot="$(fvp_gen_bin_url uboot.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500370
371 docker_registry="${docker_registry:-}"
372 docker_registry="$(docker_registry_append)"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500373 docker_name="${docker_registry}$model_name"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600374 prompt1='/ #'
375 prompt2='root@genericarmv8:~#'
376 version_string="\"Fast Models"' [^\\n]+'"\""
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500377
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500378 test_config="${TEST_CONFIG}"
379
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600380 # arrays that relates variables and template macros
381 # NOTE: any addition on these arrays, requires an addition in the
382 # fvp templates
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500383 declare -A metadata_macros
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600384 declare -A yaml_macros
385 declare -A artefacts_macros
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500386 metadata_macros=(
387 [test_config]="{TEST_CONFIG}"
388 )
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600389 yaml_macros=(
390 [armlmd_license_file]="{ARMLMD_LICENSE_FILE}"
391 [docker_name]="{BOOT_DOCKER_NAME}"
392 [model]="{MODEL}"
393 [model_bin]="{BOOT_IMAGE_BIN}"
394 [model_dir]="{BOOT_IMAGE_DIR}"
395 [prompt1]="{PROMPT1}"
396 [prompt2]="{PROMPT2}"
397 [version_string]="{BOOT_VERSION_STRING}"
398 )
399 artefacts_macros=(
400 [backup_fip]="{BACKUP_FIP}"
401 [bl1]="{BL1}"
402 [bl2]="{BL2}"
403 [bl31]="{BL31}"
404 [bl32]="{BL32}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600405 [cactus_primary]="{CACTUS_PRIMARY}"
406 [cactus_secondary]="{CACTUS_SECONDARY}"
407 [cactus_tertiary]="{CACTUS_TERTIARY}"
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500408 [coverage_trace_plugin]="{COVERAGE_TRACE_PLUGIN}"
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600409 [fvp_spmc_manifest_dtb]="{FVP_SPMC_MANIFEST_DTB}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600410 [busybox]="{BUSYBOX}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600411 [dtb]="{DTB}"
412 [el3_payload]="{EL3_PAYLOAD}"
Leonardo Sandovalcc52beb2021-05-05 19:05:31 -0500413 [fip_gpt]="{FIP_GPT}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600414 [fwu_fip]="{FWU_FIP}"
415 [fip]="{FIP}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600416 [generic_trace]="{GENERIC_TRACE}"
417 [hafnium]="{HAFNIUM}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600418 [image]="{IMAGE}"
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600419 [ivy]="{IVY}"
420 [manifest_dtb]="{MANIFEST_DTB}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600421 [mcp_rom]="{MCP_ROM}"
422 [mcp_rom_hyphen]="{MCP_ROM_HYPHEN}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600423 [ns_bl1u]="{NS_BL1U}"
424 [ns_bl2u]="{NS_BL2U}"
425 [ramdisk]="{RAMDISK}"
426 [romlib]="{ROMLIB}"
427 [rootfs]="{ROOTFS}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600428 [secure_hafnium]="{SECURE_HAFNIUM}"
429 [scp_ram]="{SCP_RAM}"
430 [scp_ram_hyphen]="{SCP_RAM_HYPHEN}"
431 [scp_rom]="{SCP_ROM}"
432 [scp_rom_hyphen]="{SCP_ROM_HYPHEN}"
433 [spm]="{SPM}"
434 [tftf]="{TFTF}"
435 [tmp]="{TMP}"
436 [uboot]="{UBOOT}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600437 )
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500438
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600439 # templates cover all possible artefacts, but model parameters may
440 # not required all, i.e. romlib.bin, so delete those irrelevant from
441 # the template
442 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600443 # there are artefacts where deletion is handled in special case, so treat them accordingly
444 case "$m" in
445 busybox)
446 # besides the macro removal, remove the compression field
447 if ! grep -q "${m}.bin" "$archive/model_params"; then
448 sed -i "/$m:\$/d" "${yaml_template_file}"
449 sed -i "/url: ${artefacts_macros[$m]}\$/,/compression: gz\$/d" "${yaml_template_file}"
450 fi
451 ;;
452 cactus_primary)
453 # cactus packages have a hyphen, not an underscore
454 if ! grep -E -q "cactus-primary.pkg" "$archive/model_params"; then
455 sed -i "/$m:\$/d" "${yaml_template_file}"
456 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
457 fi
458 ;;
459 cactus_secondary)
460 # cactus packages have a hyphen, not an underscore
461 if ! grep -E -q "cactus-secondary.pkg" "$archive/model_params"; then
462 sed -i "/$m:\$/d" "${yaml_template_file}"
463 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
464 fi
465 ;;
466 cactus_tertiary)
467 # cactus packages have a hyphen, not an underscore
468 if ! grep -E -q "cactus-tertiary.pkg" "$archive/model_params"; then
469 sed -i "/$m:\$/d" "${yaml_template_file}"
470 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
471 fi
472 ;;
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500473 coverage_trace_plugin)
474 if ! grep -q "coverage_trace.so" "$archive/model_params"; then
475 sed -i "/$m:\$/d" "${yaml_template_file}"
476 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
477 fi
478 ;;
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600479 fvp_spmc_manifest_dtb)
480 # handles fvp_spmc_manifest.dtb as DTB file
481 if ! grep -q "=fvp_spmc_manifest.dtb" "$archive/model_params"; then
482 sed -i "/ $m:\$/d" "${yaml_template_file}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600483 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
484 fi
485 ;;
486 generic_trace)
487 # the image (Linux Kernel) is named as kernel.bin
488 if ! grep -q "GenericTrace.so" "$archive/model_params"; then
489 sed -i "/$m:\$/d" "${yaml_template_file}"
490 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
491 fi
492 ;;
493 image)
494 # the image (Linux Kernel) is named as kernel.bin
495 if ! grep -q "kernel.bin" "$archive/model_params"; then
496 sed -i "/$m:\$/d" "${yaml_template_file}"
497 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
498 fi
499 ;;
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600500 ivy)
501 # the ivy package
502 if ! grep -q "ivy.pkg" "$archive/model_params"; then
503 sed -i "/$m:\$/d" "${yaml_template_file}"
504 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
505 fi
506 ;;
507 manifest_dtb)
508 # handles manifest.dtb as DTB file
509 if ! grep -q "=manifest.dtb" "$archive/model_params"; then
510 sed -i "/ $m:\$/d" "${yaml_template_file}"
511 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
512 fi
513 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600514 mcp_rom_hyphen)
515 # mcp rom is either present as mcp-rom or mcp_rom, handle the former case
516 if ! grep -q "mcp-rom.bin" "$archive/model_params"; then
517 sed -i "/$m:\$/d" "${yaml_template_file}"
518 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
519 fi
520 ;;
521 ramdisk)
522 # ramdisk is named initrd and is present with to extensions: bin or img
523 if ! grep -E -q "initrd.bin|initrd.img" "$archive/model_params"; then
524 sed -i "/$m:\$/d" "${yaml_template_file}"
525 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
526 fi
527 ;;
528 rootfs)
529 # besides the macro removal, remove the compression field
530 if ! grep -q "rootfs.bin" "$archive/model_params"; then
531 sed -i "/$m:\$/d" "${yaml_template_file}"
532 sed -i "/url: ${artefacts_macros[$m]}\$/,/compression: gz\$/d" "${yaml_template_file}"
533 fi
534 ;;
535 scp_ram_hyphen)
536 # scp ram is either present as scp-ram or scp_ram, handle the former case
537 if ! grep -q "scp-ram.bin" "$archive/model_params"; then
538 sed -i "/$m:\$/d" "${yaml_template_file}"
539 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
540 fi
541 ;;
542 scp_rom_hyphen)
543 # scp rom is either present as scp-rom or scp_rom, handle the former case
544 if ! grep -q "scp-rom.bin" "$archive/model_params"; then
545 sed -i "/$m:\$/d" "${yaml_template_file}"
546 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
547 fi
548 ;;
549 *)
550 if ! grep -q "${m}.bin" "$archive/model_params"; then
551 sed -i "/$m:\$/d" "${yaml_template_file}"
552 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
553 fi
554 ;;
555 esac
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600556 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500557
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600558 # copied files are the working files
559 cp "${yaml_template_file}" "${yaml_file}"
560 cp "$archive/model_params" "$lava_model_params"
561
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500562 # replace metadata macros with real values
563 for m in "${!metadata_macros[@]}"; do
564 sed -i -e "s|${metadata_macros[$m]}|${!m}|" "$yaml_file"
565 done
566
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600567 # replace yaml macros with real values
568 for m in "${!yaml_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600569 sed -i -e "s|${yaml_macros[$m]}|${!m}|" "$yaml_file"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600570 done
571
572 # replace artefact macros with real values
573 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600574 sed -i -e "s|${artefacts_macros[$m]}|${!m}|" "$yaml_file"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600575 done
576
577 # LAVA expects parameters as 'macros', i.e. {X} instead of x.bin, so
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600578 # replace them. As in the macro removal above, handle special cases for several
579 # artefacts
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600580 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600581 case "$m" in
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600582 cactus_primary)
583 sed -i -e "s|=cactus-primary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
584 ;;
585 cactus_secondary)
586 sed -i -e "s|=cactus-secondary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
587 ;;
588 cactus_tertiary)
589 sed -i -e "s|=cactus-tertiary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
590 ;;
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500591 coverage_trace_plugin)
592 sed -i -e "s|--plugin .*coverage_trace.so|--plugin ${artefacts_macros[$m]}|" "$lava_model_params"
593 sed -i -e "s|--plugin=.*coverage_trace.so|--plugin=${artefacts_macros[$m]}|" "$lava_model_params"
594 ;;
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600595 fvp_spmc_manifest_dtb)
596 sed -i -e "s|=fvp_spmc_manifest.dtb|=${artefacts_macros[$m]}|" "$lava_model_params"
597 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600598 generic_trace)
599 sed -i -e "s|--plugin .*GenericTrace.so|--plugin ${artefacts_macros[$m]}|" "$lava_model_params"
600 sed -i -e "s|--plugin=.*GenericTrace.so|--plugin=${artefacts_macros[$m]}|" "$lava_model_params"
601 ;;
602 image)
603 sed -i -e "s|=kernel.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
604 ;;
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600605 ivy)
606 sed -i -e "s|=ivy.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
607 ;;
608 manifest_dtb)
609 sed -i -e "s|=manifest.dtb|=${artefacts_macros[$m]}|" "$lava_model_params"
610 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600611 mcp_rom_hyphen)
612 sed -i -e "s|=mcp-rom.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
613 ;;
614 ramdisk)
615 sed -i -e "s|=initrd.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
616 sed -i -e "s|=initrd.img|=${artefacts_macros[$m]}|" "$lava_model_params"
617 ;;
618 scp_ram_hyphen)
619 sed -i -e "s|=scp-ram.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
620 ;;
621 scp_rom_hyphen)
622 sed -i -e "s|=scp-rom.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
623 ;;
624 tmp | hafnium | secure_hafnium)
625 sed -i -e "s|=.*/${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
626 ;;
627 *)
628 sed -i -e "s|=${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
629 ;;
630 esac
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600631 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500632
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500633 # include the model parameters
634 while read -r line; do
635 if [ -n "$line" ]; then
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600636 yaml_line="- \"${line}\""
637 sed -i -e "/{BOOT_ARGUMENTS}/i \ \ \ \ $yaml_line" "$yaml_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500638 fi
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500639 done < "$lava_model_params"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600640 sed -i -e '/{BOOT_ARGUMENTS}/d' "$yaml_file"
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500641
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500642 # Append expect commands into the job definition through test-interactive commands
643 gen_fvp_yaml_expect >> "$yaml_file"
644
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600645 # create job.yaml
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500646 cp "$yaml_file" "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500647
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600648 # archive both yamls
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500649 archive_file "$yaml_file"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500650 archive_file "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500651}
652
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500653gen_fvp_yaml_expect() {
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500654
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500655 run_root="$archive/run"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500656
657 # Loop through all uarts expect files
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500658 for expect_file in $(find $run_root -name expect); do
659
660 # TODO: currently, only handle UART 0
661 case $expect_file in
662 *uart0* )
663 uart_number=uart0
664 ;;
665 *)
666 continue
667 ;;
668 esac
669
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500670 # Array containing "interactive" or "monitor" expect strings and populated during run config execution.
671 # Interactive expect scripts are converted into LAVA Interactive Test Actions (see
672 # https://tf.validation.linaro.org/static/docs/v2/interactive.html#writing-tests-interactive) and
673 # monitor expect scripts are converted into LAVA Monitor Test Actions (see
674 # https://validation.linaro.org/static/docs/v2/actions-test.html#monitor)
675 #
676 # Interactive Expect strings have the format 'i;<prompt>;<succeses>;<failures>;<commands>'
677 # where multiple successes or failures or commands are separated by @
678 #
679 # Monitor Expect strings have the format 'm;<start>;<end>;<patterns>'
680 # where multiple patterns are separated by @
681 #
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500682 expect_string=()
683
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500684 # Get the real name of the expect file
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500685 expect_file=$(cat $expect_file)
686
687 # Source the run_config enviroment variables
688 env=$run_root/$uart_number/env
689 if [ -e $env ]; then
690 source $env
691 fi
692
693 # Get all expect strings
Paul Sokolovskyeece6f72021-12-01 15:04:29 +0300694 expect_file=$ci_root/expect-lava/${expect_file}
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500695 source $expect_file
696
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500697
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500698 if [ ${#expect_string[@]} -gt 0 ]; then
699
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500700 # expect loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500701 for key in "${!expect_string[@]}"; do
702
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500703 # single raw expect string
704 es="${expect_string[${key}]}"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500705
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500706 # action type: either m or i
707 action="$(echo "${es}" | awk -F ';' '{print $1}')"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500708
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500709 if [ "${action}" = "m" ]; then
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500710
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500711 start="$(echo "${es}" | awk -F ';' '{print $2}')"
712 end="$(echo "${es}" | awk -F ';' '{print $3}')"
713 patterns="$(echo "${es}" | awk -F ';' '{print $4}')"
714
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500715 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500716- test:
717 monitors:
718 - name: tests
719 start: '${start}'
720 end: '${end}'
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500721EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500722 # Patterns are separated by '@'
723 OLD_IFS=$IFS; IFS=$'@'
724 for p in ${patterns}; do
725 cat << EOF
726 pattern: '$p'
727EOF
728 done
729 IFS=$OLD_IFS
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500730 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500731 fixupdict:
732 PASS: pass
733 FAIL: fail
734EOF
735 fi # end of monitor action
736
737 if [ "${action}" = "i" ]; then
738
739 prompts="$(echo "${es}" | awk -F ';' '{print $2}')"
740 successes="$(echo "${es}" | awk -F ';' '{print $3}')"
741 failures="$(echo "${es}" | awk -F ';' '{print $4}')"
742 commands="$(echo "${es}" | awk -F ';' '{print $5}')"
743
744 cat << EOF
745- test:
746 interactive:
747EOF
748 OLD_IFS=$IFS; IFS=$'@'
749
750 if [[ -n "${prompts}" && -n "${successes}" && -n "${failures}" ]]; then
751 cat << EOF
752 - name: interactive_${uart_number}_${key}
753 prompts: ['${prompts}']
754 script:
755EOF
756 if [ -z "${commands}" ]; then
757 cat <<EOF
758 - name: interactive_command_${uart_number}_${key}
759 command:
760EOF
761 else
762 for c in ${commands}; do
763 cat <<EOF
764 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300765 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500766EOF
767 done
768 fi
769 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500770 successes:
771EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500772 for s in ${successes}; do
773 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500774 - message: '$s'
775EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500776 done
777 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500778 failures:
779EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500780 for f in ${failures}; do
781 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500782 - message: '$f'
783EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500784 done
785 elif [[ -n "${prompts}" && -n "${successes}" ]]; then
786 cat << EOF
787 - name: interactive_${uart_number}_${key}
788 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500789 script:
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500790EOF
791
792 if [ -z "${commands}" ]; then
793 cat <<EOF
794 - name: interactive_command_${uart_number}_${key}
795 command:
796EOF
797 else
798 for c in ${commands}; do
799 cat <<EOF
800 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300801 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500802EOF
803 done
804 fi
805 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500806 successes:
807EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500808 for s in ${successes}; do
809 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500810 - message: '$s'
811EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500812 done
813
814 elif [[ -n "${prompts}" && -n "${failures}" ]]; then
815 cat << EOF
816 - name: interactive_${uart_number}_${key}
817 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500818 script:
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500819EOF
820 if [ -z "${commands}" ]; then
821 cat <<EOF
822 - name: interactive_command_${uart_number}_${key}
823 command:
824EOF
825 else
826 for c in ${commands}; do
827 cat <<EOF
828 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300829 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500830EOF
831 done
832 fi
833 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500834 failures:
835EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500836 for f in ${failures}; do
837 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500838 - message: '$f'
839EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500840 done
841 else
842 cat << EOF
843 - name: interactive_${uart_number}_${key}
844 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500845 script:
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500846EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500847 if [ -z "${commands}" ]; then
848 cat <<EOF
849 - name: interactive_command_${uart_number}_${key}
850 command:
851EOF
852 else
853 for c in ${commands}; do
854 cat <<EOF
855 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300856 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500857EOF
858 done
859 fi
860 fi
861
862 IFS=$OLD_IFS
863 fi # end of interactive action
864
865 done # end of expect loop
866
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500867 fi
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500868 done # end of uart loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500869}
870
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500871docker_registry_append() {
872 # if docker_registry is empty, just use local docker registry
873 [ -z "$docker_registry" ] && return
874
875 local last=-1
876 local last_char="${docker_registry:last}"
877
878 if [ "$last_char" != '/' ]; then
879 docker_registry="${docker_registry}/";
880 fi
881 echo "$docker_registry"
882}
883
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000884# generate GPT image and archive it
885gen_gpt_bin() {
886 raw_image="fip_gpt.bin"
887 img_uuid="FB90808A-BA9A-4D42-B9A2-A7A937144AEE"
888 img_bank_uuid=`uuidgen`
889 disk_uuid=`uuidgen`
890 bin="${1:?}"
891
892 # maximum FIP size 2MB
893 fip_max_size=2097152
894 start_sector=34
895 sector_size=512
896 num_sectors=$(($fip_max_size/$sector_size))
897 bin_size=$(stat -c %s $bin)
898
899 if [[ $fip_max_size -lt $bin_size ]]
900 then
901 echo "FIP binary ($bin_size bytes) larger than max partition 1"
902 "size ($fip_max_size byte)"
903 return
904 fi
905
906 # create raw 5MB image
907 dd if=/dev/zero of=$raw_image bs=5M count=1
908
909 # create GPT image
910 sgdisk -a 1 -U $disk_uuid -n 1:$start_sector:+$num_sectors \
911 -c 1:FIP_A -t 1:$img_uuid $raw_image -u $img_bank_uuid
912
913 echo "write binary $bin at sector $start_sector"
914 dd if=$bin of=$raw_image bs=$sector_size seek=$start_sector \
915 count=$num_sectors conv=notrunc
916
917 archive_file "fip_gpt.bin"
918}
919
Fathi Boudra422bf772019-12-02 11:10:16 +0200920set +u