blob: 1ee7f385b15e6875f08aa244f13625074136d85c [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}"
Manish Pandey1e7be852020-11-09 16:04:48 +000026# SPM out directories
27export spm_secure_out_dir="${spm_secure_out_dir:-secure_aem_v8a_fvp_clang}"
28export spm_non_secure_out_dir="${spm_non_secure_out_dir:-aem_v8a_fvp_clang}"
Manish Pandey3c435582020-07-15 12:14:26 +010029
Fathi Boudra422bf772019-12-02 11:10:16 +020030ns_bl1u_addr="${ns_bl1u_addr:-0x0beb8000}"
31fwu_fip_addr="${fwu_fip_addr:-0x08400000}"
32backup_fip_addr="${backup_fip_addr:-0x09000000}"
33romlib_addr="${romlib_addr:-0x03ff2000}"
34
35uboot32_fip_url="$linaro_release/fvp32-latest-busybox-uboot/fip.bin"
36
Alexei Fedorove405cc32020-09-30 18:13:55 +010037rootfs_url="$linaro_release/lt-vexpress64-openembedded_minimal-armv8-gcc-5.2_20170127-761.img.gz"
Fathi Boudra422bf772019-12-02 11:10:16 +020038
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -050039# Default FVP model variables
40default_model_dtb="fvp-base-gicv3-psci.dtb"
41
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060042# FVP containers and model paths
43fvp_arm_std_library="fvp:fvp_arm_std_library_${model_version}_${model_build};/opt/model/FVP_ARM_Std_Library/models/${model_flavour}"
44fvp_base_revc_2xaemv8a="fvp:fvp_base_revc-2xaemv8a_${model_version}_${model_build};/opt/model/Base_RevC_AEMv8A_pkg/models/${model_flavour}"
45foundation_platform="fvp:foundation_platform_${model_version}_${model_build};/opt/model/Foundation_Platformpkg/models/${model_flavour}"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -050046
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060047# FVP associate array, run_config are keys and fvp container parameters are the values
48# Container parameters syntax: <model name>;<model dir>;<model bin>
49# FIXMEs: fix those ;;; values with real values
50
51declare -A fvp_models
52fvp_models=(
53[base-aemv8a-quad]=";;;"
54[base-aemv8a-revb]=";;;"
55[base-aemv8a-latest-revb]=";;;"
56[base-aemva]=";;;"
Manish V Badarkhee4783832021-02-22 14:36:56 +000057[base-aemv8a-gic600ae]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060058[foundationv8]="${foundation_platform};Foundation_Platform"
59[base-aemv8a]="${fvp_base_revc_2xaemv8a};FVP_Base_RevC-2xAEMv8A"
60[cortex-a32x4]="${fvp_arm_std_library};FVP_Base_Cortex-A32x4"
61[cortex-a35x4]="${fvp_arm_std_library};FVP_Base_Cortex-A35x4"
62[cortex-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A53x4"
Leonardo Sandoval95f896b2021-02-22 10:16:29 -060063[cortex-a55x4-a75x4]="${fvp_arm_std_library};FVP_Base_Cortex-A55x4+Cortex-A75x4"
64[cortex-a55x4-a76x2]="${fvp_arm_std_library};FVP_Base_Cortex-A55x4+Cortex-A76x2"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060065[cortex-a57x1-a53x1]="${fvp_arm_std_library};FVP_Base_Cortex-A57x1-A53x1"
66[cortex-a57x2-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x2-A53x4"
67[cortex-a57x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4"
68[cortex-a57x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4-A53x4"
69[cortex-a65aex8]="${fvp_arm_std_library};FVP_Base_Cortex-A65AEx8"
70[cortex-a65x4]="${fvp_arm_std_library};FVP_Base_Cortex-A65x4"
71[cortex-a72x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72x4"
72[cortex-a72x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72x4-A53x4"
73[cortex-a73x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4"
74[cortex-a73x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4-A53x4"
75[cortex-a75x4]="${fvp_arm_std_library};FVP_Base_Cortex-A75x4"
76[cortex-a76aex4]="${fvp_arm_std_library};FVP_Base_Cortex-A76AEx4"
77[cortex-a76aex2]="${fvp_arm_std_library};FVP_Base_Cortex-A76AEx2"
78[cortex-a76x4]="${fvp_arm_std_library};FVP_Base_Cortex-A76x4"
79[cortex-a77x4]="${fvp_arm_std_library};FVP_Base_Cortex-A77x4"
80[cortex-a78x4]="${fvp_arm_std_library};FVP_Base_Cortex-A78x4"
81[neoverse_e1x1]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x1"
82[neoverse_e1x2]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x2"
83[neoverse_e1x4]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x4"
84[neoverse_n1]="${fvp_arm_std_library};FVP_Base_Neoverse-N1x1"
85[neoverse_n2]=";;;"
86[neoverse-v1x4]=";;;"
87[css-rdv1]=";;;"
88[css-rde1edge]=";;;"
89[css-rdn1edge]=";;;"
90[css-rdn1edgex2]=";;;"
91[css-sgi575]=";;;"
92[css-sgm775]=";;;"
93[tc0]=";;;"
94)
95
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -050096
Fathi Boudra422bf772019-12-02 11:10:16 +020097# FVP Kernel URLs
98declare -A fvp_kernels
99fvp_kernels=(
100[fvp-aarch32-zimage]="$linaro_release/fvp32-latest-busybox-uboot/Image"
101[fvp-busybox-uboot]="$linaro_release/fvp-latest-busybox-uboot/Image"
102[fvp-oe-uboot32]="$linaro_release/fvp32-latest-oe-uboot/Image"
103[fvp-oe-uboot]="$linaro_release/fvp-latest-oe-uboot/Image"
104[fvp-quad-busybox-uboot]="$tfa_downloads/quad_cluster/Image"
105)
106
Fathi Boudra422bf772019-12-02 11:10:16 +0200107# FVP initrd URLs
108declare -A fvp_initrd_urls
109fvp_initrd_urls=(
110[aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img"
Fathi Boudra422bf772019-12-02 11:10:16 +0200111[dummy-ramdisk]="$linaro_release/fvp-latest-oe-uboot/ramdisk.img"
112[dummy-ramdisk32]="$linaro_release/fvp32-latest-oe-uboot/ramdisk.img"
113[default]="$linaro_release/fvp-latest-busybox-uboot/ramdisk.img"
114)
115
Fathi Boudra422bf772019-12-02 11:10:16 +0200116get_optee_bin() {
Sandrine Bailleux25ff2942021-02-25 14:00:10 +0100117 url="$tfa_downloads/optee/tee.bin" \
118 saveas="bl32.bin" fetch_file
Fathi Boudra422bf772019-12-02 11:10:16 +0200119 archive_file "bl32.bin"
120}
121
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100122# For Measured Boot tests using a TA based on OPTEE, it is necessary to use a
123# specific build rather than the default one generated by Jenkins.
124get_ftpm_optee_bin() {
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100125 url="$tfa_downloads/ftpm/optee/tee-header_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100126 saveas="bl32.bin" fetch_file
127 archive_file "bl32.bin"
128
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100129 url="$tfa_downloads/ftpm/optee/tee-pager_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100130 saveas="bl32_extra1.bin" fetch_file
131 archive_file "bl32_extra1.bin"
132
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100133 url="$tfa_downloads/ftpm/optee/tee-pageable_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100134 saveas="bl32_extra2.bin" fetch_file
135 archive_file "bl32_extra2.bin"
136}
137
Fathi Boudra422bf772019-12-02 11:10:16 +0200138get_uboot32_bin() {
139 local tmpdir="$(mktempdir)"
140
141 pushd "$tmpdir"
142 extract_fip "$uboot32_fip_url"
143 mv "nt-fw.bin" "uboot.bin"
144 archive_file "uboot.bin"
145 popd
146}
147
148get_uboot_bin() {
149 local uboot_url="$linaro_release/fvp-latest-busybox-uboot/bl33-uboot.bin"
150
151 url="$uboot_url" saveas="uboot.bin" fetch_file
152 archive_file "uboot.bin"
153}
154
155get_uefi_bin() {
Zelalem219df412020-05-17 19:21:20 -0500156 uefi_downloads="${uefi_downloads:-http://files.oss.arm.com/downloads/uefi}"
157 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 +0200158
159 url=$uefi_ci_bin_url saveas="uefi.bin" fetch_file
160 archive_file "uefi.bin"
161}
162
163get_kernel() {
164 local kernel_type="${kernel_type:?}"
165 local url="${fvp_kernels[$kernel_type]}"
166
167 url="${url:?}" saveas="kernel.bin" fetch_file
168 archive_file "kernel.bin"
169}
170
171get_initrd() {
172 local initrd_type="${initrd_type:?}"
173 local url="${fvp_initrd_urls[$initrd_type]}"
174
175 url="${url:?}" saveas="initrd.bin" fetch_file
176 archive_file "initrd.bin"
177}
178
179get_dtb() {
180 local dtb_type="${dtb_type:?}"
181 local dtb_url
182 local dtb_saveas="$workspace/dtb.bin"
Zelalem219df412020-05-17 19:21:20 -0500183 local cc="$(get_tf_opt CROSS_COMPILE)"
184 local pp_flags="-P -nostdinc -undef -x assembler-with-cpp"
Fathi Boudra422bf772019-12-02 11:10:16 +0200185
186 case "$dtb_type" in
187 "fvp-base-quad-cluster-gicv3-psci")
188 # Get the quad-cluster FDT from pdsw area
189 dtb_url="$tfa_downloads/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb"
190 url="$dtb_url" saveas="$dtb_saveas" fetch_file
191 ;;
192 "sgm775")
193 # Get the SGM775 FDT from pdsw area
194 dtb_url="$sgm_prebuilts/sgm775.dtb"
195 url="$dtb_url" saveas="$dtb_saveas" fetch_file
196 ;;
197 *)
Zelalem219df412020-05-17 19:21:20 -0500198 # Preprocess DTS file
199 ${cc}gcc -E ${pp_flags} -I"$tf_root/fdts" -I"$tf_root/include" \
200 -o "$workspace/${dtb_type}.pre.dts" \
201 "$tf_root/fdts/${dtb_type}.dts"
202 # Generate DTB file from DTS
Fathi Boudra422bf772019-12-02 11:10:16 +0200203 dtc -I dts -O dtb \
Zelalem219df412020-05-17 19:21:20 -0500204 "$workspace/${dtb_type}.pre.dts" -o "$dtb_saveas"
Fathi Boudra422bf772019-12-02 11:10:16 +0200205 esac
206
207 archive_file "$dtb_saveas"
208}
209
210get_rootfs() {
211 local tmpdir
212 local fs_base="$(echo $(basename $rootfs_url) | sed 's/\.gz$//')"
213 local cached="$project_filer/ci-files/$fs_base"
214
215 if upon "$jenkins_run" && [ -f "$cached" ]; then
216 # Job workspace is limited in size, and the root file system is
217 # quite large. This means, parallel runs of root file system
218 # tests could fail. So, for Jenkins runs, copy and use the root
219 # file system image from the $CI_SCRATCH location
220 local private="$CI_SCRATCH/$JOB_NAME-$BUILD_NUMBER"
221 mkdir -p "$private"
222 rm -f "$private/rootfs.bin"
223 url="$cached" saveas="$private/rootfs.bin" fetch_file
224 ln -s "$private/rootfs.bin" "$archive/rootfs.bin"
225 return
226 fi
227
228 tmpdir="$(mktempdir)"
229 pushd "$tmpdir"
230 url="$rootfs_url" saveas="rootfs.bin" fetch_file
231
232 # Possibly, the filesystem image we just downloaded is compressed.
233 # Decompress it if required.
234 if file "rootfs.bin" | grep -iq 'gzip compressed data'; then
235 echo "Decompressing root file system image rootfs.bin ..."
236 gunzip --stdout "rootfs.bin" > uncompressed_fs.bin
237 mv uncompressed_fs.bin "rootfs.bin"
238 fi
239
240 archive_file "rootfs.bin"
241 popd
242}
243
Zelalem219df412020-05-17 19:21:20 -0500244fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i"
245
Fathi Boudra422bf772019-12-02 11:10:16 +0200246fvp_romlib_runtime() {
247 local tmpdir="$(mktempdir)"
248
249 # Save BL1 and romlib binaries from original build
250 mv "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" "$tmpdir/romlib.bin"
251 mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin"
252
253 # Patch index file
Zelalem219df412020-05-17 19:21:20 -0500254 cp "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" "$fvp_romlib_jmptbl_backup"
255 sed -i '/fdt/ s/.$/&\ patch/' ${tf_root:?}/plat/arm/board/fvp/jmptbl.i
Fathi Boudra422bf772019-12-02 11:10:16 +0200256
257 # Rebuild with patched file
258 echo "Building patched romlib:"
259 build_tf
260
Fathi Boudra422bf772019-12-02 11:10:16 +0200261 # Retrieve original BL1 and romlib binaries
262 mv "$tmpdir/romlib.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin"
263 mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin"
264}
265
Zelalem219df412020-05-17 19:21:20 -0500266fvp_romlib_cleanup() {
267 # Restore original index
268 mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
269}
270
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500271
272fvp_gen_bin_url() {
273 local bin_mode="${bin_mode:?}"
274 local bin="${1:?}"
275
276 if upon "$jenkins_run"; then
277 echo "$jenkins_url/job/$JOB_NAME/$BUILD_NUMBER/artifact/artefacts/$bin_mode/$bin"
278 else
279 echo "file://$workspace/artefacts/$bin_mode/$bin"
280 fi
281}
282
283gen_fvp_yaml_template() {
284 local yaml_template_file="$workspace/fvp_template.yaml"
285
286 # must parameters for yaml generation
287 local payload_type="${payload_type:?}"
288
289 "$ci_root/script/gen_fvp_${payload_type}_yaml.sh" > "$yaml_template_file"
290
291 archive_file "$yaml_template_file"
292}
293
294gen_fvp_yaml() {
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600295 local model="${model:?}"
296
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500297 local yaml_template_file="$workspace/fvp_template.yaml"
298 local yaml_file="$workspace/fvp.yaml"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500299 local yaml_job_file="$workspace/job.yaml"
300 local lava_model_params="$workspace/lava_model_params"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500301
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500302 # this function expects a template, quit if it is not present
303 if [ ! -f "$yaml_template_file" ]; then
304 return
305 fi
306
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600307 local model_params="${fvp_models[$model]}"
308 local model_name="$(echo "${model_params}" | awk -F ';' '{print $1}')"
309 local model_dir="$(echo "${model_params}" | awk -F ';' '{print $2}')"
310 local model_bin="$(echo "${model_params}" | awk -F ';' '{print $3}')"
311
312 # model params are required for correct yaml creation, quit if empty
313 if [ -z "${model_name}" ]; then
314 echo "FVP model param 'model_name' variable empty, yaml not produced"
315 return
316 elif [ -z "${model_dir}" ]; then
317 echo "FVP model param 'model_dir' variable empty, yaml not produced"
318 return
319 elif [ -z "${model_bin}" ]; then
320 echo "FVP model param 'model_bin' variable empty, yaml not produced"
321 return
322 fi
323
324 echo "FVP model params: model_name=$model_name model_dir=$model_dir model_bin=$model_bin"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500325
Leonardo Sandovale5cdd362020-12-11 14:59:37 -0600326 # FIXME: Foundation plaforms (model=foundationv8) are failing because LAVA [1]
327 # should read two ports, 5000 and 5002, but LAVA does not support this
328 # feature, so for the moment avoid creating any LAVA test job definition
329 # for this model until a solution is found.
330 # [1] https://tf.validation.linaro.org/scheduler/job/33871
Madhukar Pappireddy21a5e672021-03-08 17:49:45 -0600331 if ! is_arm_jenkins_env && not_upon "$local_ci"; then
Leonardo Sandoval239450c2021-01-11 17:51:12 -0600332 if [ "${model}" = "foundationv8" ]; then
333 return
334 fi
Leonardo Sandovale5cdd362020-12-11 14:59:37 -0600335 fi
336
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500337 # optional parameters, defaults to globals
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500338 local model_dtb="${model_dtb:-$default_model_dtb}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500339
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600340 # possible artefacts
341 backup_fip="$(fvp_gen_bin_url backup_fip.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500342 bl1="$(fvp_gen_bin_url bl1.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600343 bl2="$(fvp_gen_bin_url bl2.bin)"
344 bl31="$(fvp_gen_bin_url bl31.bin)"
345 bl32="$(fvp_gen_bin_url bl32.bin)"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500346 dtb="$(fvp_gen_bin_url ${model_dtb})"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600347 el3_payload="$(fvp_gen_bin_url el3_payload.bin)"
348 fip="$(fvp_gen_bin_url fip.bin)"
349 fwu_fip="$(fvp_gen_bin_url fwu_fip.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500350 image="$(fvp_gen_bin_url kernel.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)"
356 spm="$(fvp_gen_bin_url spm.bin)"
357 tftf="$(fvp_gen_bin_url tftf.bin)"
358 tmp="$(fvp_gen_bin_url tmp.bin)"
359 uboot="$(fvp_gen_bin_url uboot.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500360
361 docker_registry="${docker_registry:-}"
362 docker_registry="$(docker_registry_append)"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500363 docker_name="${docker_registry}$model_name"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600364 prompt1='/ #'
365 prompt2='root@genericarmv8:~#'
366 version_string="\"Fast Models"' [^\\n]+'"\""
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500367
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600368 # arrays that relates variables and template macros
369 # NOTE: any addition on these arrays, requires an addition in the
370 # fvp templates
371 declare -A yaml_macros
372 declare -A artefacts_macros
373 yaml_macros=(
374 [armlmd_license_file]="{ARMLMD_LICENSE_FILE}"
375 [docker_name]="{BOOT_DOCKER_NAME}"
376 [model]="{MODEL}"
377 [model_bin]="{BOOT_IMAGE_BIN}"
378 [model_dir]="{BOOT_IMAGE_DIR}"
379 [prompt1]="{PROMPT1}"
380 [prompt2]="{PROMPT2}"
381 [version_string]="{BOOT_VERSION_STRING}"
382 )
383 artefacts_macros=(
384 [backup_fip]="{BACKUP_FIP}"
385 [bl1]="{BL1}"
386 [bl2]="{BL2}"
387 [bl31]="{BL31}"
388 [bl32]="{BL32}"
389 [dtb]="{DTB}"
390 [el3_payload]="{EL3_PAYLOAD}"
391 [fwu_fip]="{FWU_FIP}"
392 [fip]="{FIP}"
393 [image]="{IMAGE}"
394 [ns_bl1u]="{NS_BL1U}"
395 [ns_bl2u]="{NS_BL2U}"
396 [ramdisk]="{RAMDISK}"
397 [romlib]="{ROMLIB}"
398 [rootfs]="{ROOTFS}"
399 [spm]="{SPM}"
400 [tftf]="{TFTF}"
401 [tmp]="{TMP}"
402 [uboot]="{UBOOT}"
403 )
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500404
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600405 # templates cover all possible artefacts, but model parameters may
406 # not required all, i.e. romlib.bin, so delete those irrelevant from
407 # the template
408 for m in "${!artefacts_macros[@]}"; do
409 # image and ramdisk are special cases: binaries names do not match (job) images names
410 case "$m" in
411 image)
412 if ! grep -q "kernel.bin" "$archive/model_params"; then
413 sed -i "/$m:\$/d" "${yaml_template_file}"
414 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
415 fi
416 ;;
417 ramdisk)
418 if ! grep -q "initrd.bin" "$archive/model_params"; then
419 sed -i "/$m:\$/d" "${yaml_template_file}"
420 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
421 fi
422 ;;
423 rootfs)
424 if ! grep -q "rootfs.bin" "$archive/model_params"; then
425 sed -i "/$m:\$/d" "${yaml_template_file}"
426 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
427 sed -i "/compression: gz\$/d" "${yaml_template_file}"
428 fi
429 ;;
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500430
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600431 *)
432 if ! grep -q "${m}.bin" "$archive/model_params"; then
433 sed -i "/$m:\$/d" "${yaml_template_file}"
434 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
435 fi
436 ;;
437 esac
438 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500439
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600440 # copied files are the working files
441 cp "${yaml_template_file}" "${yaml_file}"
442 cp "$archive/model_params" "$lava_model_params"
443
444 # replace yaml macros with real values
445 for m in "${!yaml_macros[@]}"; do
446 sed -i -e "s|${yaml_macros[$m]}|${!m}|" "$yaml_file"
447 done
448
449 # replace artefact macros with real values
450 for m in "${!artefacts_macros[@]}"; do
451 sed -i -e "s|${artefacts_macros[$m]}|${!m}|" "$yaml_file"
452 done
453
454 # LAVA expects parameters as 'macros', i.e. {X} instead of x.bin, so
455 # replace them
456 for m in "${!artefacts_macros[@]}"; do
457 case "$m" in
458 image)
459 sed -i -e "s|=kernel.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
460 ;;
461 ramdisk)
462 sed -i -e "s|=initrd.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
463 ;;
464 tmp)
465 sed -i -e "s|=.*/${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
466 ;;
467 *)
468 sed -i -e "s|=${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
469 ;;
470 esac
471 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500472
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500473 # include the model parameters
474 while read -r line; do
475 if [ -n "$line" ]; then
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600476 yaml_line="- \"${line}\""
477 sed -i -e "/{BOOT_ARGUMENTS}/i \ \ \ \ $yaml_line" "$yaml_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500478 fi
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500479 done < "$lava_model_params"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600480 sed -i -e '/{BOOT_ARGUMENTS}/d' "$yaml_file"
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500481
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600482 # create job.yaml
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500483 cp "$yaml_file" "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500484
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600485 # archive both yamls
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500486 archive_file "$yaml_file"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500487 archive_file "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500488}
489
490docker_registry_append() {
491 # if docker_registry is empty, just use local docker registry
492 [ -z "$docker_registry" ] && return
493
494 local last=-1
495 local last_char="${docker_registry:last}"
496
497 if [ "$last_char" != '/' ]; then
498 docker_registry="${docker_registry}/";
499 fi
500 echo "$docker_registry"
501}
502
Fathi Boudra422bf772019-12-02 11:10:16 +0200503set +u