blob: e783bbf620d2e51f79dcecd20b7c5ae84a24393b [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}"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -050048
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060049# FVP associate array, run_config are keys and fvp container parameters are the values
50# Container parameters syntax: <model name>;<model dir>;<model bin>
51# FIXMEs: fix those ;;; values with real values
52
53declare -A fvp_models
54fvp_models=(
55[base-aemv8a-quad]=";;;"
56[base-aemv8a-revb]=";;;"
57[base-aemv8a-latest-revb]=";;;"
58[base-aemva]=";;;"
Manish V Badarkhee4783832021-02-22 14:36:56 +000059[base-aemv8a-gic600ae]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060060[foundationv8]="${foundation_platform};Foundation_Platform"
laurenw-armf414aba2021-04-26 15:58:56 -050061[base-aemv8a]="${fvp_base_revc_2xaemva};FVP_Base_RevC-2xAEMvA"
laurenw-arm35faeaa2021-05-03 14:28:17 -050062[cortex-a32x4]="${fvp_arm_std_library_11_12};FVP_Base_Cortex-A32x4"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060063[cortex-a35x4]="${fvp_arm_std_library};FVP_Base_Cortex-A35x4"
64[cortex-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A53x4"
Leonardo Sandoval95f896b2021-02-22 10:16:29 -060065[cortex-a55x4-a75x4]="${fvp_arm_std_library};FVP_Base_Cortex-A55x4+Cortex-A75x4"
66[cortex-a55x4-a76x2]="${fvp_arm_std_library};FVP_Base_Cortex-A55x4+Cortex-A76x2"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060067[cortex-a57x1-a53x1]="${fvp_arm_std_library};FVP_Base_Cortex-A57x1-A53x1"
68[cortex-a57x2-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x2-A53x4"
69[cortex-a57x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4"
70[cortex-a57x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4-A53x4"
71[cortex-a65aex8]="${fvp_arm_std_library};FVP_Base_Cortex-A65AEx8"
72[cortex-a65x4]="${fvp_arm_std_library};FVP_Base_Cortex-A65x4"
73[cortex-a72x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72x4"
74[cortex-a72x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72x4-A53x4"
75[cortex-a73x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4"
76[cortex-a73x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4-A53x4"
77[cortex-a75x4]="${fvp_arm_std_library};FVP_Base_Cortex-A75x4"
78[cortex-a76aex4]="${fvp_arm_std_library};FVP_Base_Cortex-A76AEx4"
79[cortex-a76aex2]="${fvp_arm_std_library};FVP_Base_Cortex-A76AEx2"
80[cortex-a76x4]="${fvp_arm_std_library};FVP_Base_Cortex-A76x4"
81[cortex-a77x4]="${fvp_arm_std_library};FVP_Base_Cortex-A77x4"
82[cortex-a78x4]="${fvp_arm_std_library};FVP_Base_Cortex-A78x4"
83[neoverse_e1x1]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x1"
84[neoverse_e1x2]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x2"
85[neoverse_e1x4]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x4"
Leonardo Sandoval54f1ade2021-06-26 19:20:48 -050086[neoverse_n1]="${fvp_arm_std_library};FVP_Base_Neoverse-N1x4"
Maksims Svecovsd10c1b92021-10-06 10:25:40 +010087[neoverse_n2]="${fvp_arm_std_library_11_12};FVP_Base_Neoverse-N1x4"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060088[neoverse-v1x4]=";;;"
Manish V Badarkhecbed15e2021-07-02 09:34:53 +010089[cortexa710x4]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060090[css-rdv1]=";;;"
91[css-rde1edge]=";;;"
92[css-rdn1edge]=";;;"
93[css-rdn1edgex2]=";;;"
94[css-sgi575]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060095[tc0]=";;;"
Usama Arifcba711d2021-08-04 15:53:42 +010096[tc1]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060097)
98
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -050099
Fathi Boudra422bf772019-12-02 11:10:16 +0200100# FVP Kernel URLs
101declare -A fvp_kernels
102fvp_kernels=(
103[fvp-aarch32-zimage]="$linaro_release/fvp32-latest-busybox-uboot/Image"
104[fvp-busybox-uboot]="$linaro_release/fvp-latest-busybox-uboot/Image"
105[fvp-oe-uboot32]="$linaro_release/fvp32-latest-oe-uboot/Image"
106[fvp-oe-uboot]="$linaro_release/fvp-latest-oe-uboot/Image"
107[fvp-quad-busybox-uboot]="$tfa_downloads/quad_cluster/Image"
108)
109
Fathi Boudra422bf772019-12-02 11:10:16 +0200110# FVP initrd URLs
111declare -A fvp_initrd_urls
112fvp_initrd_urls=(
113[aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img"
Fathi Boudra422bf772019-12-02 11:10:16 +0200114[dummy-ramdisk]="$linaro_release/fvp-latest-oe-uboot/ramdisk.img"
115[dummy-ramdisk32]="$linaro_release/fvp32-latest-oe-uboot/ramdisk.img"
116[default]="$linaro_release/fvp-latest-busybox-uboot/ramdisk.img"
117)
118
Fathi Boudra422bf772019-12-02 11:10:16 +0200119get_optee_bin() {
Sandrine Bailleux25ff2942021-02-25 14:00:10 +0100120 url="$tfa_downloads/optee/tee.bin" \
121 saveas="bl32.bin" fetch_file
Fathi Boudra422bf772019-12-02 11:10:16 +0200122 archive_file "bl32.bin"
123}
124
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100125# For Measured Boot tests using a TA based on OPTEE, it is necessary to use a
126# specific build rather than the default one generated by Jenkins.
127get_ftpm_optee_bin() {
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100128 url="$tfa_downloads/ftpm/optee/tee-header_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100129 saveas="bl32.bin" fetch_file
130 archive_file "bl32.bin"
131
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100132 url="$tfa_downloads/ftpm/optee/tee-pager_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100133 saveas="bl32_extra1.bin" fetch_file
134 archive_file "bl32_extra1.bin"
135
Leonardo Sandovalda5f78d2021-03-18 11:09:30 -0600136 # tee-pageable_v2.bin is just a empty file, named as bl32_extra2.bin,
137 # so just create the file
138 touch "bl32_extra2.bin"
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100139 archive_file "bl32_extra2.bin"
140}
141
Fathi Boudra422bf772019-12-02 11:10:16 +0200142get_uboot32_bin() {
143 local tmpdir="$(mktempdir)"
144
145 pushd "$tmpdir"
146 extract_fip "$uboot32_fip_url"
147 mv "nt-fw.bin" "uboot.bin"
148 archive_file "uboot.bin"
149 popd
150}
151
152get_uboot_bin() {
153 local uboot_url="$linaro_release/fvp-latest-busybox-uboot/bl33-uboot.bin"
154
155 url="$uboot_url" saveas="uboot.bin" fetch_file
156 archive_file "uboot.bin"
157}
158
159get_uefi_bin() {
Zelalem219df412020-05-17 19:21:20 -0500160 uefi_downloads="${uefi_downloads:-http://files.oss.arm.com/downloads/uefi}"
161 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 +0200162
163 url=$uefi_ci_bin_url saveas="uefi.bin" fetch_file
164 archive_file "uefi.bin"
165}
166
167get_kernel() {
168 local kernel_type="${kernel_type:?}"
169 local url="${fvp_kernels[$kernel_type]}"
170
171 url="${url:?}" saveas="kernel.bin" fetch_file
172 archive_file "kernel.bin"
173}
174
175get_initrd() {
176 local initrd_type="${initrd_type:?}"
177 local url="${fvp_initrd_urls[$initrd_type]}"
178
179 url="${url:?}" saveas="initrd.bin" fetch_file
180 archive_file "initrd.bin"
181}
182
183get_dtb() {
184 local dtb_type="${dtb_type:?}"
185 local dtb_url
186 local dtb_saveas="$workspace/dtb.bin"
Zelalem219df412020-05-17 19:21:20 -0500187 local cc="$(get_tf_opt CROSS_COMPILE)"
188 local pp_flags="-P -nostdinc -undef -x assembler-with-cpp"
Fathi Boudra422bf772019-12-02 11:10:16 +0200189
190 case "$dtb_type" in
191 "fvp-base-quad-cluster-gicv3-psci")
192 # Get the quad-cluster FDT from pdsw area
193 dtb_url="$tfa_downloads/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb"
194 url="$dtb_url" saveas="$dtb_saveas" fetch_file
195 ;;
Fathi Boudra422bf772019-12-02 11:10:16 +0200196 *)
Zelalem219df412020-05-17 19:21:20 -0500197 # Preprocess DTS file
198 ${cc}gcc -E ${pp_flags} -I"$tf_root/fdts" -I"$tf_root/include" \
199 -o "$workspace/${dtb_type}.pre.dts" \
200 "$tf_root/fdts/${dtb_type}.dts"
201 # Generate DTB file from DTS
Fathi Boudra422bf772019-12-02 11:10:16 +0200202 dtc -I dts -O dtb \
Zelalem219df412020-05-17 19:21:20 -0500203 "$workspace/${dtb_type}.pre.dts" -o "$dtb_saveas"
Fathi Boudra422bf772019-12-02 11:10:16 +0200204 esac
205
206 archive_file "$dtb_saveas"
207}
208
209get_rootfs() {
210 local tmpdir
211 local fs_base="$(echo $(basename $rootfs_url) | sed 's/\.gz$//')"
212 local cached="$project_filer/ci-files/$fs_base"
213
214 if upon "$jenkins_run" && [ -f "$cached" ]; then
215 # Job workspace is limited in size, and the root file system is
216 # quite large. This means, parallel runs of root file system
217 # tests could fail. So, for Jenkins runs, copy and use the root
218 # file system image from the $CI_SCRATCH location
219 local private="$CI_SCRATCH/$JOB_NAME-$BUILD_NUMBER"
220 mkdir -p "$private"
221 rm -f "$private/rootfs.bin"
222 url="$cached" saveas="$private/rootfs.bin" fetch_file
223 ln -s "$private/rootfs.bin" "$archive/rootfs.bin"
224 return
225 fi
226
227 tmpdir="$(mktempdir)"
228 pushd "$tmpdir"
229 url="$rootfs_url" saveas="rootfs.bin" fetch_file
230
231 # Possibly, the filesystem image we just downloaded is compressed.
232 # Decompress it if required.
233 if file "rootfs.bin" | grep -iq 'gzip compressed data'; then
234 echo "Decompressing root file system image rootfs.bin ..."
235 gunzip --stdout "rootfs.bin" > uncompressed_fs.bin
236 mv uncompressed_fs.bin "rootfs.bin"
237 fi
238
239 archive_file "rootfs.bin"
240 popd
241}
242
Zelalem219df412020-05-17 19:21:20 -0500243fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i"
244
Fathi Boudra422bf772019-12-02 11:10:16 +0200245fvp_romlib_runtime() {
246 local tmpdir="$(mktempdir)"
247
248 # Save BL1 and romlib binaries from original build
249 mv "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" "$tmpdir/romlib.bin"
250 mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin"
251
252 # Patch index file
Zelalem219df412020-05-17 19:21:20 -0500253 cp "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" "$fvp_romlib_jmptbl_backup"
254 sed -i '/fdt/ s/.$/&\ patch/' ${tf_root:?}/plat/arm/board/fvp/jmptbl.i
Fathi Boudra422bf772019-12-02 11:10:16 +0200255
256 # Rebuild with patched file
257 echo "Building patched romlib:"
258 build_tf
259
Fathi Boudra422bf772019-12-02 11:10:16 +0200260 # Retrieve original BL1 and romlib binaries
261 mv "$tmpdir/romlib.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin"
262 mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin"
263}
264
Zelalem219df412020-05-17 19:21:20 -0500265fvp_romlib_cleanup() {
266 # Restore original index
267 mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
268}
269
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500270
271fvp_gen_bin_url() {
272 local bin_mode="${bin_mode:?}"
273 local bin="${1:?}"
274
275 if upon "$jenkins_run"; then
276 echo "$jenkins_url/job/$JOB_NAME/$BUILD_NUMBER/artifact/artefacts/$bin_mode/$bin"
277 else
278 echo "file://$workspace/artefacts/$bin_mode/$bin"
279 fi
280}
281
282gen_fvp_yaml_template() {
283 local yaml_template_file="$workspace/fvp_template.yaml"
284
285 # must parameters for yaml generation
286 local payload_type="${payload_type:?}"
287
288 "$ci_root/script/gen_fvp_${payload_type}_yaml.sh" > "$yaml_template_file"
289
290 archive_file "$yaml_template_file"
291}
292
293gen_fvp_yaml() {
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600294 local model="${model:?}"
295
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500296 local yaml_template_file="$workspace/fvp_template.yaml"
297 local yaml_file="$workspace/fvp.yaml"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500298 local yaml_job_file="$workspace/job.yaml"
299 local lava_model_params="$workspace/lava_model_params"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500300
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500301 # this function expects a template, quit if it is not present
302 if [ ! -f "$yaml_template_file" ]; then
303 return
304 fi
305
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600306 local model_params="${fvp_models[$model]}"
307 local model_name="$(echo "${model_params}" | awk -F ';' '{print $1}')"
308 local model_dir="$(echo "${model_params}" | awk -F ';' '{print $2}')"
309 local model_bin="$(echo "${model_params}" | awk -F ';' '{print $3}')"
310
311 # model params are required for correct yaml creation, quit if empty
312 if [ -z "${model_name}" ]; then
313 echo "FVP model param 'model_name' variable empty, yaml not produced"
314 return
315 elif [ -z "${model_dir}" ]; then
316 echo "FVP model param 'model_dir' variable empty, yaml not produced"
317 return
318 elif [ -z "${model_bin}" ]; then
319 echo "FVP model param 'model_bin' variable empty, yaml not produced"
320 return
321 fi
322
323 echo "FVP model params: model_name=$model_name model_dir=$model_dir model_bin=$model_bin"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500324
325 # optional parameters, defaults to globals
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500326 local model_dtb="${model_dtb:-$default_model_dtb}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500327
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600328 # possible artefacts
329 backup_fip="$(fvp_gen_bin_url backup_fip.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500330 bl1="$(fvp_gen_bin_url bl1.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600331 bl2="$(fvp_gen_bin_url bl2.bin)"
332 bl31="$(fvp_gen_bin_url bl31.bin)"
333 bl32="$(fvp_gen_bin_url bl32.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600334 busybox="$(fvp_gen_bin_url busybox.bin.gz)"
335 cactus_primary="$(fvp_gen_bin_url cactus-primary.pkg)"
336 cactus_secondary="$(fvp_gen_bin_url cactus-secondary.pkg)"
337 cactus_tertiary="$(fvp_gen_bin_url cactus-tertiary.pkg)"
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500338 coverage_trace_plugin="${coverage_trace_plugin}"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500339 dtb="$(fvp_gen_bin_url ${model_dtb})"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600340 el3_payload="$(fvp_gen_bin_url el3_payload.bin)"
341 fip="$(fvp_gen_bin_url fip.bin)"
Leonardo Sandovalcc52beb2021-05-05 19:05:31 -0500342 fip_gpt="$(fvp_gen_bin_url fip_gpt.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600343 fwu_fip="$(fvp_gen_bin_url fwu_fip.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600344 generic_trace="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/GenericTrace.so"
345 hafnium="$(fvp_gen_bin_url hafnium.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500346 image="$(fvp_gen_bin_url kernel.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600347 mcp_rom="$(fvp_gen_bin_url mcp_rom.bin)"
348 mcp_rom_hyphen="$(fvp_gen_bin_url mcp-rom.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500349 ns_bl1u="$(fvp_gen_bin_url ns_bl1u.bin)"
350 ns_bl2u="$(fvp_gen_bin_url ns_bl2u.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600351 ramdisk="$(fvp_gen_bin_url initrd.bin)"
352 romlib="$(fvp_gen_bin_url romlib.bin)"
353 rootfs="$(fvp_gen_bin_url rootfs.bin.gz)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600354 secure_hafnium="$(fvp_gen_bin_url secure_hafnium.bin)"
355 scp_ram="$(fvp_gen_bin_url scp_ram.bin)"
356 scp_ram_hyphen="$(fvp_gen_bin_url scp-ram.bin)"
357 scp_rom="$(fvp_gen_bin_url scp_rom.bin)"
358 scp_rom_hyphen="$(fvp_gen_bin_url scp-rom.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600359 spm="$(fvp_gen_bin_url spm.bin)"
360 tftf="$(fvp_gen_bin_url tftf.bin)"
361 tmp="$(fvp_gen_bin_url tmp.bin)"
362 uboot="$(fvp_gen_bin_url uboot.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500363
364 docker_registry="${docker_registry:-}"
365 docker_registry="$(docker_registry_append)"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500366 docker_name="${docker_registry}$model_name"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600367 prompt1='/ #'
368 prompt2='root@genericarmv8:~#'
369 version_string="\"Fast Models"' [^\\n]+'"\""
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500370
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500371 test_config="${TEST_CONFIG}"
372
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600373 # arrays that relates variables and template macros
374 # NOTE: any addition on these arrays, requires an addition in the
375 # fvp templates
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500376 declare -A metadata_macros
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600377 declare -A yaml_macros
378 declare -A artefacts_macros
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500379 metadata_macros=(
380 [test_config]="{TEST_CONFIG}"
381 )
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600382 yaml_macros=(
383 [armlmd_license_file]="{ARMLMD_LICENSE_FILE}"
384 [docker_name]="{BOOT_DOCKER_NAME}"
385 [model]="{MODEL}"
386 [model_bin]="{BOOT_IMAGE_BIN}"
387 [model_dir]="{BOOT_IMAGE_DIR}"
388 [prompt1]="{PROMPT1}"
389 [prompt2]="{PROMPT2}"
390 [version_string]="{BOOT_VERSION_STRING}"
391 )
392 artefacts_macros=(
393 [backup_fip]="{BACKUP_FIP}"
394 [bl1]="{BL1}"
395 [bl2]="{BL2}"
396 [bl31]="{BL31}"
397 [bl32]="{BL32}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600398 [cactus_primary]="{CACTUS_PRIMARY}"
399 [cactus_secondary]="{CACTUS_SECONDARY}"
400 [cactus_tertiary]="{CACTUS_TERTIARY}"
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500401 [coverage_trace_plugin]="{COVERAGE_TRACE_PLUGIN}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600402 [busybox]="{BUSYBOX}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600403 [dtb]="{DTB}"
404 [el3_payload]="{EL3_PAYLOAD}"
Leonardo Sandovalcc52beb2021-05-05 19:05:31 -0500405 [fip_gpt]="{FIP_GPT}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600406 [fwu_fip]="{FWU_FIP}"
407 [fip]="{FIP}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600408 [generic_trace]="{GENERIC_TRACE}"
409 [hafnium]="{HAFNIUM}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600410 [image]="{IMAGE}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600411 [mcp_rom]="{MCP_ROM}"
412 [mcp_rom_hyphen]="{MCP_ROM_HYPHEN}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600413 [ns_bl1u]="{NS_BL1U}"
414 [ns_bl2u]="{NS_BL2U}"
415 [ramdisk]="{RAMDISK}"
416 [romlib]="{ROMLIB}"
417 [rootfs]="{ROOTFS}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600418 [secure_hafnium]="{SECURE_HAFNIUM}"
419 [scp_ram]="{SCP_RAM}"
420 [scp_ram_hyphen]="{SCP_RAM_HYPHEN}"
421 [scp_rom]="{SCP_ROM}"
422 [scp_rom_hyphen]="{SCP_ROM_HYPHEN}"
423 [spm]="{SPM}"
424 [tftf]="{TFTF}"
425 [tmp]="{TMP}"
426 [uboot]="{UBOOT}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600427 )
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500428
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600429 # templates cover all possible artefacts, but model parameters may
430 # not required all, i.e. romlib.bin, so delete those irrelevant from
431 # the template
432 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600433 # there are artefacts where deletion is handled in special case, so treat them accordingly
434 case "$m" in
435 busybox)
436 # besides the macro removal, remove the compression field
437 if ! grep -q "${m}.bin" "$archive/model_params"; then
438 sed -i "/$m:\$/d" "${yaml_template_file}"
439 sed -i "/url: ${artefacts_macros[$m]}\$/,/compression: gz\$/d" "${yaml_template_file}"
440 fi
441 ;;
442 cactus_primary)
443 # cactus packages have a hyphen, not an underscore
444 if ! grep -E -q "cactus-primary.pkg" "$archive/model_params"; then
445 sed -i "/$m:\$/d" "${yaml_template_file}"
446 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
447 fi
448 ;;
449 cactus_secondary)
450 # cactus packages have a hyphen, not an underscore
451 if ! grep -E -q "cactus-secondary.pkg" "$archive/model_params"; then
452 sed -i "/$m:\$/d" "${yaml_template_file}"
453 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
454 fi
455 ;;
456 cactus_tertiary)
457 # cactus packages have a hyphen, not an underscore
458 if ! grep -E -q "cactus-tertiary.pkg" "$archive/model_params"; then
459 sed -i "/$m:\$/d" "${yaml_template_file}"
460 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
461 fi
462 ;;
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500463 coverage_trace_plugin)
464 if ! grep -q "coverage_trace.so" "$archive/model_params"; then
465 sed -i "/$m:\$/d" "${yaml_template_file}"
466 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
467 fi
468 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600469 dtb)
470 # dtb can come in different names, i.e. dtb.bin, manifest.dtb,
471 # so handle with regex
472 if ! grep -E -q "=.*dtb.*@" "$archive/model_params"; then
473 sed -i "/$m:\$/d" "${yaml_template_file}"
474 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
475 fi
476 ;;
477 generic_trace)
478 # the image (Linux Kernel) is named as kernel.bin
479 if ! grep -q "GenericTrace.so" "$archive/model_params"; then
480 sed -i "/$m:\$/d" "${yaml_template_file}"
481 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
482 fi
483 ;;
484 image)
485 # the image (Linux Kernel) is named as kernel.bin
486 if ! grep -q "kernel.bin" "$archive/model_params"; then
487 sed -i "/$m:\$/d" "${yaml_template_file}"
488 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
489 fi
490 ;;
491 mcp_rom_hyphen)
492 # mcp rom is either present as mcp-rom or mcp_rom, handle the former case
493 if ! grep -q "mcp-rom.bin" "$archive/model_params"; then
494 sed -i "/$m:\$/d" "${yaml_template_file}"
495 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
496 fi
497 ;;
498 ramdisk)
499 # ramdisk is named initrd and is present with to extensions: bin or img
500 if ! grep -E -q "initrd.bin|initrd.img" "$archive/model_params"; then
501 sed -i "/$m:\$/d" "${yaml_template_file}"
502 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
503 fi
504 ;;
505 rootfs)
506 # besides the macro removal, remove the compression field
507 if ! grep -q "rootfs.bin" "$archive/model_params"; then
508 sed -i "/$m:\$/d" "${yaml_template_file}"
509 sed -i "/url: ${artefacts_macros[$m]}\$/,/compression: gz\$/d" "${yaml_template_file}"
510 fi
511 ;;
512 scp_ram_hyphen)
513 # scp ram is either present as scp-ram or scp_ram, handle the former case
514 if ! grep -q "scp-ram.bin" "$archive/model_params"; then
515 sed -i "/$m:\$/d" "${yaml_template_file}"
516 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
517 fi
518 ;;
519 scp_rom_hyphen)
520 # scp rom is either present as scp-rom or scp_rom, handle the former case
521 if ! grep -q "scp-rom.bin" "$archive/model_params"; then
522 sed -i "/$m:\$/d" "${yaml_template_file}"
523 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
524 fi
525 ;;
526 *)
527 if ! grep -q "${m}.bin" "$archive/model_params"; then
528 sed -i "/$m:\$/d" "${yaml_template_file}"
529 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
530 fi
531 ;;
532 esac
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600533 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500534
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600535 # copied files are the working files
536 cp "${yaml_template_file}" "${yaml_file}"
537 cp "$archive/model_params" "$lava_model_params"
538
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500539 # replace metadata macros with real values
540 for m in "${!metadata_macros[@]}"; do
541 sed -i -e "s|${metadata_macros[$m]}|${!m}|" "$yaml_file"
542 done
543
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600544 # replace yaml macros with real values
545 for m in "${!yaml_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600546 sed -i -e "s|${yaml_macros[$m]}|${!m}|" "$yaml_file"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600547 done
548
549 # replace artefact macros with real values
550 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600551 sed -i -e "s|${artefacts_macros[$m]}|${!m}|" "$yaml_file"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600552 done
553
554 # LAVA expects parameters as 'macros', i.e. {X} instead of x.bin, so
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600555 # replace them. As in the macro removal above, handle special cases for several
556 # artefacts
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600557 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600558 case "$m" in
559 dtb)
560 sed -i -e "s|=.*dtb.*@|=${artefacts_macros[$m]}@|" "$lava_model_params"
561 ;;
562 cactus_primary)
563 sed -i -e "s|=cactus-primary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
564 ;;
565 cactus_secondary)
566 sed -i -e "s|=cactus-secondary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
567 ;;
568 cactus_tertiary)
569 sed -i -e "s|=cactus-tertiary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
570 ;;
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500571 coverage_trace_plugin)
572 sed -i -e "s|--plugin .*coverage_trace.so|--plugin ${artefacts_macros[$m]}|" "$lava_model_params"
573 sed -i -e "s|--plugin=.*coverage_trace.so|--plugin=${artefacts_macros[$m]}|" "$lava_model_params"
574 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600575 generic_trace)
576 sed -i -e "s|--plugin .*GenericTrace.so|--plugin ${artefacts_macros[$m]}|" "$lava_model_params"
577 sed -i -e "s|--plugin=.*GenericTrace.so|--plugin=${artefacts_macros[$m]}|" "$lava_model_params"
578 ;;
579 image)
580 sed -i -e "s|=kernel.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
581 ;;
582 mcp_rom_hyphen)
583 sed -i -e "s|=mcp-rom.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
584 ;;
585 ramdisk)
586 sed -i -e "s|=initrd.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
587 sed -i -e "s|=initrd.img|=${artefacts_macros[$m]}|" "$lava_model_params"
588 ;;
589 scp_ram_hyphen)
590 sed -i -e "s|=scp-ram.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
591 ;;
592 scp_rom_hyphen)
593 sed -i -e "s|=scp-rom.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
594 ;;
595 tmp | hafnium | secure_hafnium)
596 sed -i -e "s|=.*/${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
597 ;;
598 *)
599 sed -i -e "s|=${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
600 ;;
601 esac
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600602 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500603
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500604 # include the model parameters
605 while read -r line; do
606 if [ -n "$line" ]; then
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600607 yaml_line="- \"${line}\""
608 sed -i -e "/{BOOT_ARGUMENTS}/i \ \ \ \ $yaml_line" "$yaml_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500609 fi
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500610 done < "$lava_model_params"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600611 sed -i -e '/{BOOT_ARGUMENTS}/d' "$yaml_file"
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500612
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500613 # Append expect commands into the job definition through test-interactive commands
614 gen_fvp_yaml_expect >> "$yaml_file"
615
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600616 # create job.yaml
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500617 cp "$yaml_file" "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500618
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600619 # archive both yamls
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500620 archive_file "$yaml_file"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500621 archive_file "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500622}
623
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500624gen_fvp_yaml_expect() {
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500625
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500626 run_root="$archive/run"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500627
628 # Loop through all uarts expect files
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500629 for expect_file in $(find $run_root -name expect); do
630
631 # TODO: currently, only handle UART 0
632 case $expect_file in
633 *uart0* )
634 uart_number=uart0
635 ;;
636 *)
637 continue
638 ;;
639 esac
640
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500641 # Array containing "interactive" or "monitor" expect strings and populated during run config execution.
642 # Interactive expect scripts are converted into LAVA Interactive Test Actions (see
643 # https://tf.validation.linaro.org/static/docs/v2/interactive.html#writing-tests-interactive) and
644 # monitor expect scripts are converted into LAVA Monitor Test Actions (see
645 # https://validation.linaro.org/static/docs/v2/actions-test.html#monitor)
646 #
647 # Interactive Expect strings have the format 'i;<prompt>;<succeses>;<failures>;<commands>'
648 # where multiple successes or failures or commands are separated by @
649 #
650 # Monitor Expect strings have the format 'm;<start>;<end>;<patterns>'
651 # where multiple patterns are separated by @
652 #
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500653 expect_string=()
654
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500655 # Get the real name of the expect file
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500656 expect_file=$(cat $expect_file)
657
658 # Source the run_config enviroment variables
659 env=$run_root/$uart_number/env
660 if [ -e $env ]; then
661 source $env
662 fi
663
664 # Get all expect strings
665 expect_file=$ci_root/lava-expect/${expect_file}
666 source $expect_file
667
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500668
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500669 if [ ${#expect_string[@]} -gt 0 ]; then
670
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500671 # expect loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500672 for key in "${!expect_string[@]}"; do
673
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500674 # single raw expect string
675 es="${expect_string[${key}]}"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500676
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500677 # action type: either m or i
678 action="$(echo "${es}" | awk -F ';' '{print $1}')"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500679
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500680 if [ "${action}" = "m" ]; then
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500681
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500682 start="$(echo "${es}" | awk -F ';' '{print $2}')"
683 end="$(echo "${es}" | awk -F ';' '{print $3}')"
684 patterns="$(echo "${es}" | awk -F ';' '{print $4}')"
685
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500686 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500687- test:
688 monitors:
689 - name: tests
690 start: '${start}'
691 end: '${end}'
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500692EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500693 # Patterns are separated by '@'
694 OLD_IFS=$IFS; IFS=$'@'
695 for p in ${patterns}; do
696 cat << EOF
697 pattern: '$p'
698EOF
699 done
700 IFS=$OLD_IFS
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500701 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500702 fixupdict:
703 PASS: pass
704 FAIL: fail
705EOF
706 fi # end of monitor action
707
708 if [ "${action}" = "i" ]; then
709
710 prompts="$(echo "${es}" | awk -F ';' '{print $2}')"
711 successes="$(echo "${es}" | awk -F ';' '{print $3}')"
712 failures="$(echo "${es}" | awk -F ';' '{print $4}')"
713 commands="$(echo "${es}" | awk -F ';' '{print $5}')"
714
715 cat << EOF
716- test:
717 interactive:
718EOF
719 OLD_IFS=$IFS; IFS=$'@'
720
721 if [[ -n "${prompts}" && -n "${successes}" && -n "${failures}" ]]; then
722 cat << EOF
723 - name: interactive_${uart_number}_${key}
724 prompts: ['${prompts}']
725 script:
726EOF
727 if [ -z "${commands}" ]; then
728 cat <<EOF
729 - name: interactive_command_${uart_number}_${key}
730 command:
731EOF
732 else
733 for c in ${commands}; do
734 cat <<EOF
735 - name: interactive_command_${uart_number}_${key}
736 command: $c
737EOF
738 done
739 fi
740 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500741 successes:
742EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500743 for s in ${successes}; do
744 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500745 - message: '$s'
746EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500747 done
748 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500749 failures:
750EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500751 for f in ${failures}; do
752 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500753 - message: '$f'
754EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500755 done
756 elif [[ -n "${prompts}" && -n "${successes}" ]]; then
757 cat << EOF
758 - name: interactive_${uart_number}_${key}
759 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500760 script:
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500761EOF
762
763 if [ -z "${commands}" ]; then
764 cat <<EOF
765 - name: interactive_command_${uart_number}_${key}
766 command:
767EOF
768 else
769 for c in ${commands}; do
770 cat <<EOF
771 - name: interactive_command_${uart_number}_${key}
772 command: $c
773EOF
774 done
775 fi
776 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500777 successes:
778EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500779 for s in ${successes}; do
780 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500781 - message: '$s'
782EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500783 done
784
785 elif [[ -n "${prompts}" && -n "${failures}" ]]; 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 if [ -z "${commands}" ]; then
792 cat <<EOF
793 - name: interactive_command_${uart_number}_${key}
794 command:
795EOF
796 else
797 for c in ${commands}; do
798 cat <<EOF
799 - name: interactive_command_${uart_number}_${key}
800 command: $c
801EOF
802 done
803 fi
804 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500805 failures:
806EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500807 for f in ${failures}; do
808 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500809 - message: '$f'
810EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500811 done
812 else
813 cat << EOF
814 - name: interactive_${uart_number}_${key}
815 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500816 script:
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500817EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500818 if [ -z "${commands}" ]; then
819 cat <<EOF
820 - name: interactive_command_${uart_number}_${key}
821 command:
822EOF
823 else
824 for c in ${commands}; do
825 cat <<EOF
826 - name: interactive_command_${uart_number}_${key}
827 command: $c
828EOF
829 done
830 fi
831 fi
832
833 IFS=$OLD_IFS
834 fi # end of interactive action
835
836 done # end of expect loop
837
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500838 fi
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500839 done # end of uart loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500840}
841
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500842docker_registry_append() {
843 # if docker_registry is empty, just use local docker registry
844 [ -z "$docker_registry" ] && return
845
846 local last=-1
847 local last_char="${docker_registry:last}"
848
849 if [ "$last_char" != '/' ]; then
850 docker_registry="${docker_registry}/";
851 fi
852 echo "$docker_registry"
853}
854
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000855# generate GPT image and archive it
856gen_gpt_bin() {
857 raw_image="fip_gpt.bin"
858 img_uuid="FB90808A-BA9A-4D42-B9A2-A7A937144AEE"
859 img_bank_uuid=`uuidgen`
860 disk_uuid=`uuidgen`
861 bin="${1:?}"
862
863 # maximum FIP size 2MB
864 fip_max_size=2097152
865 start_sector=34
866 sector_size=512
867 num_sectors=$(($fip_max_size/$sector_size))
868 bin_size=$(stat -c %s $bin)
869
870 if [[ $fip_max_size -lt $bin_size ]]
871 then
872 echo "FIP binary ($bin_size bytes) larger than max partition 1"
873 "size ($fip_max_size byte)"
874 return
875 fi
876
877 # create raw 5MB image
878 dd if=/dev/zero of=$raw_image bs=5M count=1
879
880 # create GPT image
881 sgdisk -a 1 -U $disk_uuid -n 1:$start_sector:+$num_sectors \
882 -c 1:FIP_A -t 1:$img_uuid $raw_image -u $img_bank_uuid
883
884 echo "write binary $bin at sector $start_sector"
885 dd if=$bin of=$raw_image bs=$sector_size seek=$start_sector \
886 count=$num_sectors conv=notrunc
887
888 archive_file "fip_gpt.bin"
889}
890
Fathi Boudra422bf772019-12-02 11:10:16 +0200891set +u