blob: 4b6a7656d63afae95c344b9b58419b9d2f39b5a6 [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"
85[neoverse_e1x1]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x1"
86[neoverse_e1x2]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x2"
87[neoverse_e1x4]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x4"
Leonardo Sandoval54f1ade2021-06-26 19:20:48 -050088[neoverse_n1]="${fvp_arm_std_library};FVP_Base_Neoverse-N1x4"
Maksims Svecovsd10c1b92021-10-06 10:25:40 +010089[neoverse_n2]="${fvp_arm_std_library_11_12};FVP_Base_Neoverse-N1x4"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060090[neoverse-v1x4]=";;;"
Manish V Badarkhecbed15e2021-07-02 09:34:53 +010091[cortexa710x4]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060092[css-rdv1]=";;;"
93[css-rde1edge]=";;;"
94[css-rdn1edge]=";;;"
95[css-rdn1edgex2]=";;;"
96[css-sgi575]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060097[tc0]=";;;"
Usama Arifcba711d2021-08-04 15:53:42 +010098[tc1]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060099)
100
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500101
Fathi Boudra422bf772019-12-02 11:10:16 +0200102# FVP Kernel URLs
103declare -A fvp_kernels
104fvp_kernels=(
105[fvp-aarch32-zimage]="$linaro_release/fvp32-latest-busybox-uboot/Image"
106[fvp-busybox-uboot]="$linaro_release/fvp-latest-busybox-uboot/Image"
107[fvp-oe-uboot32]="$linaro_release/fvp32-latest-oe-uboot/Image"
108[fvp-oe-uboot]="$linaro_release/fvp-latest-oe-uboot/Image"
109[fvp-quad-busybox-uboot]="$tfa_downloads/quad_cluster/Image"
110)
111
Fathi Boudra422bf772019-12-02 11:10:16 +0200112# FVP initrd URLs
113declare -A fvp_initrd_urls
114fvp_initrd_urls=(
115[aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img"
Fathi Boudra422bf772019-12-02 11:10:16 +0200116[dummy-ramdisk]="$linaro_release/fvp-latest-oe-uboot/ramdisk.img"
117[dummy-ramdisk32]="$linaro_release/fvp32-latest-oe-uboot/ramdisk.img"
118[default]="$linaro_release/fvp-latest-busybox-uboot/ramdisk.img"
119)
120
Fathi Boudra422bf772019-12-02 11:10:16 +0200121get_optee_bin() {
Sandrine Bailleux25ff2942021-02-25 14:00:10 +0100122 url="$tfa_downloads/optee/tee.bin" \
123 saveas="bl32.bin" fetch_file
Fathi Boudra422bf772019-12-02 11:10:16 +0200124 archive_file "bl32.bin"
125}
126
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100127# For Measured Boot tests using a TA based on OPTEE, it is necessary to use a
128# specific build rather than the default one generated by Jenkins.
129get_ftpm_optee_bin() {
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100130 url="$tfa_downloads/ftpm/optee/tee-header_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100131 saveas="bl32.bin" fetch_file
132 archive_file "bl32.bin"
133
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100134 url="$tfa_downloads/ftpm/optee/tee-pager_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100135 saveas="bl32_extra1.bin" fetch_file
136 archive_file "bl32_extra1.bin"
137
Leonardo Sandovalda5f78d2021-03-18 11:09:30 -0600138 # tee-pageable_v2.bin is just a empty file, named as bl32_extra2.bin,
139 # so just create the file
140 touch "bl32_extra2.bin"
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100141 archive_file "bl32_extra2.bin"
142}
143
Fathi Boudra422bf772019-12-02 11:10:16 +0200144get_uboot32_bin() {
145 local tmpdir="$(mktempdir)"
146
147 pushd "$tmpdir"
148 extract_fip "$uboot32_fip_url"
149 mv "nt-fw.bin" "uboot.bin"
150 archive_file "uboot.bin"
151 popd
152}
153
154get_uboot_bin() {
155 local uboot_url="$linaro_release/fvp-latest-busybox-uboot/bl33-uboot.bin"
156
157 url="$uboot_url" saveas="uboot.bin" fetch_file
158 archive_file "uboot.bin"
159}
160
161get_uefi_bin() {
Zelalem219df412020-05-17 19:21:20 -0500162 uefi_downloads="${uefi_downloads:-http://files.oss.arm.com/downloads/uefi}"
163 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 +0200164
165 url=$uefi_ci_bin_url saveas="uefi.bin" fetch_file
166 archive_file "uefi.bin"
167}
168
169get_kernel() {
170 local kernel_type="${kernel_type:?}"
171 local url="${fvp_kernels[$kernel_type]}"
172
173 url="${url:?}" saveas="kernel.bin" fetch_file
174 archive_file "kernel.bin"
175}
176
177get_initrd() {
178 local initrd_type="${initrd_type:?}"
179 local url="${fvp_initrd_urls[$initrd_type]}"
180
181 url="${url:?}" saveas="initrd.bin" fetch_file
182 archive_file "initrd.bin"
183}
184
185get_dtb() {
186 local dtb_type="${dtb_type:?}"
187 local dtb_url
188 local dtb_saveas="$workspace/dtb.bin"
Zelalem219df412020-05-17 19:21:20 -0500189 local cc="$(get_tf_opt CROSS_COMPILE)"
190 local pp_flags="-P -nostdinc -undef -x assembler-with-cpp"
Fathi Boudra422bf772019-12-02 11:10:16 +0200191
192 case "$dtb_type" in
193 "fvp-base-quad-cluster-gicv3-psci")
194 # Get the quad-cluster FDT from pdsw area
195 dtb_url="$tfa_downloads/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb"
196 url="$dtb_url" saveas="$dtb_saveas" fetch_file
197 ;;
Fathi Boudra422bf772019-12-02 11:10:16 +0200198 *)
Zelalem219df412020-05-17 19:21:20 -0500199 # Preprocess DTS file
200 ${cc}gcc -E ${pp_flags} -I"$tf_root/fdts" -I"$tf_root/include" \
201 -o "$workspace/${dtb_type}.pre.dts" \
202 "$tf_root/fdts/${dtb_type}.dts"
203 # Generate DTB file from DTS
Fathi Boudra422bf772019-12-02 11:10:16 +0200204 dtc -I dts -O dtb \
Zelalem219df412020-05-17 19:21:20 -0500205 "$workspace/${dtb_type}.pre.dts" -o "$dtb_saveas"
Fathi Boudra422bf772019-12-02 11:10:16 +0200206 esac
207
208 archive_file "$dtb_saveas"
209}
210
211get_rootfs() {
212 local tmpdir
213 local fs_base="$(echo $(basename $rootfs_url) | sed 's/\.gz$//')"
214 local cached="$project_filer/ci-files/$fs_base"
215
216 if upon "$jenkins_run" && [ -f "$cached" ]; then
217 # Job workspace is limited in size, and the root file system is
218 # quite large. This means, parallel runs of root file system
219 # tests could fail. So, for Jenkins runs, copy and use the root
220 # file system image from the $CI_SCRATCH location
221 local private="$CI_SCRATCH/$JOB_NAME-$BUILD_NUMBER"
222 mkdir -p "$private"
223 rm -f "$private/rootfs.bin"
224 url="$cached" saveas="$private/rootfs.bin" fetch_file
225 ln -s "$private/rootfs.bin" "$archive/rootfs.bin"
226 return
227 fi
228
229 tmpdir="$(mktempdir)"
230 pushd "$tmpdir"
231 url="$rootfs_url" saveas="rootfs.bin" fetch_file
232
233 # Possibly, the filesystem image we just downloaded is compressed.
234 # Decompress it if required.
235 if file "rootfs.bin" | grep -iq 'gzip compressed data'; then
236 echo "Decompressing root file system image rootfs.bin ..."
237 gunzip --stdout "rootfs.bin" > uncompressed_fs.bin
238 mv uncompressed_fs.bin "rootfs.bin"
239 fi
240
241 archive_file "rootfs.bin"
242 popd
243}
244
Zelalem219df412020-05-17 19:21:20 -0500245fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i"
246
Fathi Boudra422bf772019-12-02 11:10:16 +0200247fvp_romlib_runtime() {
248 local tmpdir="$(mktempdir)"
249
250 # Save BL1 and romlib binaries from original build
251 mv "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" "$tmpdir/romlib.bin"
252 mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin"
253
254 # Patch index file
Zelalem219df412020-05-17 19:21:20 -0500255 cp "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" "$fvp_romlib_jmptbl_backup"
256 sed -i '/fdt/ s/.$/&\ patch/' ${tf_root:?}/plat/arm/board/fvp/jmptbl.i
Fathi Boudra422bf772019-12-02 11:10:16 +0200257
258 # Rebuild with patched file
259 echo "Building patched romlib:"
260 build_tf
261
Fathi Boudra422bf772019-12-02 11:10:16 +0200262 # Retrieve original BL1 and romlib binaries
263 mv "$tmpdir/romlib.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin"
264 mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin"
265}
266
Zelalem219df412020-05-17 19:21:20 -0500267fvp_romlib_cleanup() {
268 # Restore original index
269 mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
270}
271
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500272
273fvp_gen_bin_url() {
274 local bin_mode="${bin_mode:?}"
275 local bin="${1:?}"
276
277 if upon "$jenkins_run"; then
278 echo "$jenkins_url/job/$JOB_NAME/$BUILD_NUMBER/artifact/artefacts/$bin_mode/$bin"
279 else
280 echo "file://$workspace/artefacts/$bin_mode/$bin"
281 fi
282}
283
284gen_fvp_yaml_template() {
285 local yaml_template_file="$workspace/fvp_template.yaml"
286
287 # must parameters for yaml generation
288 local payload_type="${payload_type:?}"
289
290 "$ci_root/script/gen_fvp_${payload_type}_yaml.sh" > "$yaml_template_file"
291
292 archive_file "$yaml_template_file"
293}
294
295gen_fvp_yaml() {
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600296 local model="${model:?}"
297
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500298 local yaml_template_file="$workspace/fvp_template.yaml"
299 local yaml_file="$workspace/fvp.yaml"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500300 local yaml_job_file="$workspace/job.yaml"
301 local lava_model_params="$workspace/lava_model_params"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500302
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500303 # this function expects a template, quit if it is not present
304 if [ ! -f "$yaml_template_file" ]; then
305 return
306 fi
307
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600308 local model_params="${fvp_models[$model]}"
309 local model_name="$(echo "${model_params}" | awk -F ';' '{print $1}')"
310 local model_dir="$(echo "${model_params}" | awk -F ';' '{print $2}')"
311 local model_bin="$(echo "${model_params}" | awk -F ';' '{print $3}')"
312
313 # model params are required for correct yaml creation, quit if empty
314 if [ -z "${model_name}" ]; then
315 echo "FVP model param 'model_name' variable empty, yaml not produced"
316 return
317 elif [ -z "${model_dir}" ]; then
318 echo "FVP model param 'model_dir' variable empty, yaml not produced"
319 return
320 elif [ -z "${model_bin}" ]; then
321 echo "FVP model param 'model_bin' variable empty, yaml not produced"
322 return
323 fi
324
325 echo "FVP model params: model_name=$model_name model_dir=$model_dir model_bin=$model_bin"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500326
327 # optional parameters, defaults to globals
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500328 local model_dtb="${model_dtb:-$default_model_dtb}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500329
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600330 # possible artefacts
331 backup_fip="$(fvp_gen_bin_url backup_fip.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500332 bl1="$(fvp_gen_bin_url bl1.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600333 bl2="$(fvp_gen_bin_url bl2.bin)"
334 bl31="$(fvp_gen_bin_url bl31.bin)"
335 bl32="$(fvp_gen_bin_url bl32.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600336 busybox="$(fvp_gen_bin_url busybox.bin.gz)"
337 cactus_primary="$(fvp_gen_bin_url cactus-primary.pkg)"
338 cactus_secondary="$(fvp_gen_bin_url cactus-secondary.pkg)"
339 cactus_tertiary="$(fvp_gen_bin_url cactus-tertiary.pkg)"
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500340 coverage_trace_plugin="${coverage_trace_plugin}"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500341 dtb="$(fvp_gen_bin_url ${model_dtb})"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600342 el3_payload="$(fvp_gen_bin_url el3_payload.bin)"
343 fip="$(fvp_gen_bin_url fip.bin)"
Leonardo Sandovalcc52beb2021-05-05 19:05:31 -0500344 fip_gpt="$(fvp_gen_bin_url fip_gpt.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600345 fwu_fip="$(fvp_gen_bin_url fwu_fip.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600346 generic_trace="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/GenericTrace.so"
347 hafnium="$(fvp_gen_bin_url hafnium.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500348 image="$(fvp_gen_bin_url kernel.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600349 mcp_rom="$(fvp_gen_bin_url mcp_rom.bin)"
350 mcp_rom_hyphen="$(fvp_gen_bin_url mcp-rom.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500351 ns_bl1u="$(fvp_gen_bin_url ns_bl1u.bin)"
352 ns_bl2u="$(fvp_gen_bin_url ns_bl2u.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600353 ramdisk="$(fvp_gen_bin_url initrd.bin)"
354 romlib="$(fvp_gen_bin_url romlib.bin)"
355 rootfs="$(fvp_gen_bin_url rootfs.bin.gz)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600356 secure_hafnium="$(fvp_gen_bin_url secure_hafnium.bin)"
357 scp_ram="$(fvp_gen_bin_url scp_ram.bin)"
358 scp_ram_hyphen="$(fvp_gen_bin_url scp-ram.bin)"
359 scp_rom="$(fvp_gen_bin_url scp_rom.bin)"
360 scp_rom_hyphen="$(fvp_gen_bin_url scp-rom.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600361 spm="$(fvp_gen_bin_url spm.bin)"
362 tftf="$(fvp_gen_bin_url tftf.bin)"
363 tmp="$(fvp_gen_bin_url tmp.bin)"
364 uboot="$(fvp_gen_bin_url uboot.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500365
366 docker_registry="${docker_registry:-}"
367 docker_registry="$(docker_registry_append)"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500368 docker_name="${docker_registry}$model_name"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600369 prompt1='/ #'
370 prompt2='root@genericarmv8:~#'
371 version_string="\"Fast Models"' [^\\n]+'"\""
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500372
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500373 test_config="${TEST_CONFIG}"
374
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600375 # arrays that relates variables and template macros
376 # NOTE: any addition on these arrays, requires an addition in the
377 # fvp templates
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500378 declare -A metadata_macros
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600379 declare -A yaml_macros
380 declare -A artefacts_macros
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500381 metadata_macros=(
382 [test_config]="{TEST_CONFIG}"
383 )
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600384 yaml_macros=(
385 [armlmd_license_file]="{ARMLMD_LICENSE_FILE}"
386 [docker_name]="{BOOT_DOCKER_NAME}"
387 [model]="{MODEL}"
388 [model_bin]="{BOOT_IMAGE_BIN}"
389 [model_dir]="{BOOT_IMAGE_DIR}"
390 [prompt1]="{PROMPT1}"
391 [prompt2]="{PROMPT2}"
392 [version_string]="{BOOT_VERSION_STRING}"
393 )
394 artefacts_macros=(
395 [backup_fip]="{BACKUP_FIP}"
396 [bl1]="{BL1}"
397 [bl2]="{BL2}"
398 [bl31]="{BL31}"
399 [bl32]="{BL32}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600400 [cactus_primary]="{CACTUS_PRIMARY}"
401 [cactus_secondary]="{CACTUS_SECONDARY}"
402 [cactus_tertiary]="{CACTUS_TERTIARY}"
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500403 [coverage_trace_plugin]="{COVERAGE_TRACE_PLUGIN}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600404 [busybox]="{BUSYBOX}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600405 [dtb]="{DTB}"
406 [el3_payload]="{EL3_PAYLOAD}"
Leonardo Sandovalcc52beb2021-05-05 19:05:31 -0500407 [fip_gpt]="{FIP_GPT}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600408 [fwu_fip]="{FWU_FIP}"
409 [fip]="{FIP}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600410 [generic_trace]="{GENERIC_TRACE}"
411 [hafnium]="{HAFNIUM}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600412 [image]="{IMAGE}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600413 [mcp_rom]="{MCP_ROM}"
414 [mcp_rom_hyphen]="{MCP_ROM_HYPHEN}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600415 [ns_bl1u]="{NS_BL1U}"
416 [ns_bl2u]="{NS_BL2U}"
417 [ramdisk]="{RAMDISK}"
418 [romlib]="{ROMLIB}"
419 [rootfs]="{ROOTFS}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600420 [secure_hafnium]="{SECURE_HAFNIUM}"
421 [scp_ram]="{SCP_RAM}"
422 [scp_ram_hyphen]="{SCP_RAM_HYPHEN}"
423 [scp_rom]="{SCP_ROM}"
424 [scp_rom_hyphen]="{SCP_ROM_HYPHEN}"
425 [spm]="{SPM}"
426 [tftf]="{TFTF}"
427 [tmp]="{TMP}"
428 [uboot]="{UBOOT}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600429 )
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500430
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600431 # templates cover all possible artefacts, but model parameters may
432 # not required all, i.e. romlib.bin, so delete those irrelevant from
433 # the template
434 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600435 # there are artefacts where deletion is handled in special case, so treat them accordingly
436 case "$m" in
437 busybox)
438 # besides the macro removal, remove the compression field
439 if ! grep -q "${m}.bin" "$archive/model_params"; then
440 sed -i "/$m:\$/d" "${yaml_template_file}"
441 sed -i "/url: ${artefacts_macros[$m]}\$/,/compression: gz\$/d" "${yaml_template_file}"
442 fi
443 ;;
444 cactus_primary)
445 # cactus packages have a hyphen, not an underscore
446 if ! grep -E -q "cactus-primary.pkg" "$archive/model_params"; then
447 sed -i "/$m:\$/d" "${yaml_template_file}"
448 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
449 fi
450 ;;
451 cactus_secondary)
452 # cactus packages have a hyphen, not an underscore
453 if ! grep -E -q "cactus-secondary.pkg" "$archive/model_params"; then
454 sed -i "/$m:\$/d" "${yaml_template_file}"
455 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
456 fi
457 ;;
458 cactus_tertiary)
459 # cactus packages have a hyphen, not an underscore
460 if ! grep -E -q "cactus-tertiary.pkg" "$archive/model_params"; then
461 sed -i "/$m:\$/d" "${yaml_template_file}"
462 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
463 fi
464 ;;
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500465 coverage_trace_plugin)
466 if ! grep -q "coverage_trace.so" "$archive/model_params"; then
467 sed -i "/$m:\$/d" "${yaml_template_file}"
468 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
469 fi
470 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600471 dtb)
472 # dtb can come in different names, i.e. dtb.bin, manifest.dtb,
473 # so handle with regex
474 if ! grep -E -q "=.*dtb.*@" "$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 ;;
479 generic_trace)
480 # the image (Linux Kernel) is named as kernel.bin
481 if ! grep -q "GenericTrace.so" "$archive/model_params"; then
482 sed -i "/$m:\$/d" "${yaml_template_file}"
483 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
484 fi
485 ;;
486 image)
487 # the image (Linux Kernel) is named as kernel.bin
488 if ! grep -q "kernel.bin" "$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 mcp_rom_hyphen)
494 # mcp rom is either present as mcp-rom or mcp_rom, handle the former case
495 if ! grep -q "mcp-rom.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 ;;
500 ramdisk)
501 # ramdisk is named initrd and is present with to extensions: bin or img
502 if ! grep -E -q "initrd.bin|initrd.img" "$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 rootfs)
508 # besides the macro removal, remove the compression field
509 if ! grep -q "rootfs.bin" "$archive/model_params"; then
510 sed -i "/$m:\$/d" "${yaml_template_file}"
511 sed -i "/url: ${artefacts_macros[$m]}\$/,/compression: gz\$/d" "${yaml_template_file}"
512 fi
513 ;;
514 scp_ram_hyphen)
515 # scp ram is either present as scp-ram or scp_ram, handle the former case
516 if ! grep -q "scp-ram.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 scp_rom_hyphen)
522 # scp rom is either present as scp-rom or scp_rom, handle the former case
523 if ! grep -q "scp-rom.bin" "$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 *)
529 if ! grep -q "${m}.bin" "$archive/model_params"; then
530 sed -i "/$m:\$/d" "${yaml_template_file}"
531 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
532 fi
533 ;;
534 esac
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600535 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500536
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600537 # copied files are the working files
538 cp "${yaml_template_file}" "${yaml_file}"
539 cp "$archive/model_params" "$lava_model_params"
540
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500541 # replace metadata macros with real values
542 for m in "${!metadata_macros[@]}"; do
543 sed -i -e "s|${metadata_macros[$m]}|${!m}|" "$yaml_file"
544 done
545
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600546 # replace yaml macros with real values
547 for m in "${!yaml_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600548 sed -i -e "s|${yaml_macros[$m]}|${!m}|" "$yaml_file"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600549 done
550
551 # replace artefact macros with real values
552 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600553 sed -i -e "s|${artefacts_macros[$m]}|${!m}|" "$yaml_file"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600554 done
555
556 # LAVA expects parameters as 'macros', i.e. {X} instead of x.bin, so
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600557 # replace them. As in the macro removal above, handle special cases for several
558 # artefacts
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600559 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600560 case "$m" in
561 dtb)
562 sed -i -e "s|=.*dtb.*@|=${artefacts_macros[$m]}@|" "$lava_model_params"
563 ;;
564 cactus_primary)
565 sed -i -e "s|=cactus-primary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
566 ;;
567 cactus_secondary)
568 sed -i -e "s|=cactus-secondary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
569 ;;
570 cactus_tertiary)
571 sed -i -e "s|=cactus-tertiary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
572 ;;
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500573 coverage_trace_plugin)
574 sed -i -e "s|--plugin .*coverage_trace.so|--plugin ${artefacts_macros[$m]}|" "$lava_model_params"
575 sed -i -e "s|--plugin=.*coverage_trace.so|--plugin=${artefacts_macros[$m]}|" "$lava_model_params"
576 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600577 generic_trace)
578 sed -i -e "s|--plugin .*GenericTrace.so|--plugin ${artefacts_macros[$m]}|" "$lava_model_params"
579 sed -i -e "s|--plugin=.*GenericTrace.so|--plugin=${artefacts_macros[$m]}|" "$lava_model_params"
580 ;;
581 image)
582 sed -i -e "s|=kernel.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
583 ;;
584 mcp_rom_hyphen)
585 sed -i -e "s|=mcp-rom.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
586 ;;
587 ramdisk)
588 sed -i -e "s|=initrd.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
589 sed -i -e "s|=initrd.img|=${artefacts_macros[$m]}|" "$lava_model_params"
590 ;;
591 scp_ram_hyphen)
592 sed -i -e "s|=scp-ram.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
593 ;;
594 scp_rom_hyphen)
595 sed -i -e "s|=scp-rom.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
596 ;;
597 tmp | hafnium | secure_hafnium)
598 sed -i -e "s|=.*/${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
599 ;;
600 *)
601 sed -i -e "s|=${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
602 ;;
603 esac
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600604 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500605
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500606 # include the model parameters
607 while read -r line; do
608 if [ -n "$line" ]; then
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600609 yaml_line="- \"${line}\""
610 sed -i -e "/{BOOT_ARGUMENTS}/i \ \ \ \ $yaml_line" "$yaml_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500611 fi
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500612 done < "$lava_model_params"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600613 sed -i -e '/{BOOT_ARGUMENTS}/d' "$yaml_file"
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500614
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500615 # Append expect commands into the job definition through test-interactive commands
616 gen_fvp_yaml_expect >> "$yaml_file"
617
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600618 # create job.yaml
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500619 cp "$yaml_file" "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500620
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600621 # archive both yamls
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500622 archive_file "$yaml_file"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500623 archive_file "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500624}
625
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500626gen_fvp_yaml_expect() {
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500627
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500628 run_root="$archive/run"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500629
630 # Loop through all uarts expect files
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500631 for expect_file in $(find $run_root -name expect); do
632
633 # TODO: currently, only handle UART 0
634 case $expect_file in
635 *uart0* )
636 uart_number=uart0
637 ;;
638 *)
639 continue
640 ;;
641 esac
642
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500643 # Array containing "interactive" or "monitor" expect strings and populated during run config execution.
644 # Interactive expect scripts are converted into LAVA Interactive Test Actions (see
645 # https://tf.validation.linaro.org/static/docs/v2/interactive.html#writing-tests-interactive) and
646 # monitor expect scripts are converted into LAVA Monitor Test Actions (see
647 # https://validation.linaro.org/static/docs/v2/actions-test.html#monitor)
648 #
649 # Interactive Expect strings have the format 'i;<prompt>;<succeses>;<failures>;<commands>'
650 # where multiple successes or failures or commands are separated by @
651 #
652 # Monitor Expect strings have the format 'm;<start>;<end>;<patterns>'
653 # where multiple patterns are separated by @
654 #
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500655 expect_string=()
656
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500657 # Get the real name of the expect file
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500658 expect_file=$(cat $expect_file)
659
660 # Source the run_config enviroment variables
661 env=$run_root/$uart_number/env
662 if [ -e $env ]; then
663 source $env
664 fi
665
666 # Get all expect strings
667 expect_file=$ci_root/lava-expect/${expect_file}
668 source $expect_file
669
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500670
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500671 if [ ${#expect_string[@]} -gt 0 ]; then
672
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500673 # expect loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500674 for key in "${!expect_string[@]}"; do
675
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500676 # single raw expect string
677 es="${expect_string[${key}]}"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500678
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500679 # action type: either m or i
680 action="$(echo "${es}" | awk -F ';' '{print $1}')"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500681
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500682 if [ "${action}" = "m" ]; then
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500683
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500684 start="$(echo "${es}" | awk -F ';' '{print $2}')"
685 end="$(echo "${es}" | awk -F ';' '{print $3}')"
686 patterns="$(echo "${es}" | awk -F ';' '{print $4}')"
687
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500688 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500689- test:
690 monitors:
691 - name: tests
692 start: '${start}'
693 end: '${end}'
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500694EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500695 # Patterns are separated by '@'
696 OLD_IFS=$IFS; IFS=$'@'
697 for p in ${patterns}; do
698 cat << EOF
699 pattern: '$p'
700EOF
701 done
702 IFS=$OLD_IFS
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500703 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500704 fixupdict:
705 PASS: pass
706 FAIL: fail
707EOF
708 fi # end of monitor action
709
710 if [ "${action}" = "i" ]; then
711
712 prompts="$(echo "${es}" | awk -F ';' '{print $2}')"
713 successes="$(echo "${es}" | awk -F ';' '{print $3}')"
714 failures="$(echo "${es}" | awk -F ';' '{print $4}')"
715 commands="$(echo "${es}" | awk -F ';' '{print $5}')"
716
717 cat << EOF
718- test:
719 interactive:
720EOF
721 OLD_IFS=$IFS; IFS=$'@'
722
723 if [[ -n "${prompts}" && -n "${successes}" && -n "${failures}" ]]; then
724 cat << EOF
725 - name: interactive_${uart_number}_${key}
726 prompts: ['${prompts}']
727 script:
728EOF
729 if [ -z "${commands}" ]; then
730 cat <<EOF
731 - name: interactive_command_${uart_number}_${key}
732 command:
733EOF
734 else
735 for c in ${commands}; do
736 cat <<EOF
737 - name: interactive_command_${uart_number}_${key}
738 command: $c
739EOF
740 done
741 fi
742 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500743 successes:
744EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500745 for s in ${successes}; do
746 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500747 - message: '$s'
748EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500749 done
750 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500751 failures:
752EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500753 for f in ${failures}; do
754 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500755 - message: '$f'
756EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500757 done
758 elif [[ -n "${prompts}" && -n "${successes}" ]]; then
759 cat << EOF
760 - name: interactive_${uart_number}_${key}
761 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500762 script:
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500763EOF
764
765 if [ -z "${commands}" ]; then
766 cat <<EOF
767 - name: interactive_command_${uart_number}_${key}
768 command:
769EOF
770 else
771 for c in ${commands}; do
772 cat <<EOF
773 - name: interactive_command_${uart_number}_${key}
774 command: $c
775EOF
776 done
777 fi
778 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500779 successes:
780EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500781 for s in ${successes}; do
782 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500783 - message: '$s'
784EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500785 done
786
787 elif [[ -n "${prompts}" && -n "${failures}" ]]; then
788 cat << EOF
789 - name: interactive_${uart_number}_${key}
790 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500791 script:
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500792EOF
793 if [ -z "${commands}" ]; then
794 cat <<EOF
795 - name: interactive_command_${uart_number}_${key}
796 command:
797EOF
798 else
799 for c in ${commands}; do
800 cat <<EOF
801 - name: interactive_command_${uart_number}_${key}
802 command: $c
803EOF
804 done
805 fi
806 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500807 failures:
808EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500809 for f in ${failures}; do
810 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500811 - message: '$f'
812EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500813 done
814 else
815 cat << EOF
816 - name: interactive_${uart_number}_${key}
817 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500818 script:
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500819EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500820 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}
829 command: $c
830EOF
831 done
832 fi
833 fi
834
835 IFS=$OLD_IFS
836 fi # end of interactive action
837
838 done # end of expect loop
839
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500840 fi
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500841 done # end of uart loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500842}
843
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500844docker_registry_append() {
845 # if docker_registry is empty, just use local docker registry
846 [ -z "$docker_registry" ] && return
847
848 local last=-1
849 local last_char="${docker_registry:last}"
850
851 if [ "$last_char" != '/' ]; then
852 docker_registry="${docker_registry}/";
853 fi
854 echo "$docker_registry"
855}
856
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000857# generate GPT image and archive it
858gen_gpt_bin() {
859 raw_image="fip_gpt.bin"
860 img_uuid="FB90808A-BA9A-4D42-B9A2-A7A937144AEE"
861 img_bank_uuid=`uuidgen`
862 disk_uuid=`uuidgen`
863 bin="${1:?}"
864
865 # maximum FIP size 2MB
866 fip_max_size=2097152
867 start_sector=34
868 sector_size=512
869 num_sectors=$(($fip_max_size/$sector_size))
870 bin_size=$(stat -c %s $bin)
871
872 if [[ $fip_max_size -lt $bin_size ]]
873 then
874 echo "FIP binary ($bin_size bytes) larger than max partition 1"
875 "size ($fip_max_size byte)"
876 return
877 fi
878
879 # create raw 5MB image
880 dd if=/dev/zero of=$raw_image bs=5M count=1
881
882 # create GPT image
883 sgdisk -a 1 -U $disk_uuid -n 1:$start_sector:+$num_sectors \
884 -c 1:FIP_A -t 1:$img_uuid $raw_image -u $img_bank_uuid
885
886 echo "write binary $bin at sector $start_sector"
887 dd if=$bin of=$raw_image bs=$sector_size seek=$start_sector \
888 count=$num_sectors conv=notrunc
889
890 archive_file "fip_gpt.bin"
891}
892
Fathi Boudra422bf772019-12-02 11:10:16 +0200893set +u