blob: 7755565ffa9f5a34843f5b3114524d3258c00567 [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
laurenw-arm35faeaa2021-05-03 14:28:17 -050043fvp_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}"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060044fvp_arm_std_library="fvp:fvp_arm_std_library_${model_version}_${model_build};/opt/model/FVP_ARM_Std_Library/models/${model_flavour}"
laurenw-armf414aba2021-04-26 15:58:56 -050045fvp_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 -060046foundation_platform="fvp:foundation_platform_${model_version}_${model_build};/opt/model/Foundation_Platformpkg/models/${model_flavour}"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -050047
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060048# FVP associate array, run_config are keys and fvp container parameters are the values
49# Container parameters syntax: <model name>;<model dir>;<model bin>
50# FIXMEs: fix those ;;; values with real values
51
52declare -A fvp_models
53fvp_models=(
54[base-aemv8a-quad]=";;;"
55[base-aemv8a-revb]=";;;"
56[base-aemv8a-latest-revb]=";;;"
57[base-aemva]=";;;"
Manish V Badarkhee4783832021-02-22 14:36:56 +000058[base-aemv8a-gic600ae]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060059[foundationv8]="${foundation_platform};Foundation_Platform"
laurenw-armf414aba2021-04-26 15:58:56 -050060[base-aemv8a]="${fvp_base_revc_2xaemva};FVP_Base_RevC-2xAEMvA"
laurenw-arm35faeaa2021-05-03 14:28:17 -050061[cortex-a32x4]="${fvp_arm_std_library_11_12};FVP_Base_Cortex-A32x4"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060062[cortex-a35x4]="${fvp_arm_std_library};FVP_Base_Cortex-A35x4"
63[cortex-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A53x4"
Leonardo Sandoval95f896b2021-02-22 10:16:29 -060064[cortex-a55x4-a75x4]="${fvp_arm_std_library};FVP_Base_Cortex-A55x4+Cortex-A75x4"
65[cortex-a55x4-a76x2]="${fvp_arm_std_library};FVP_Base_Cortex-A55x4+Cortex-A76x2"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060066[cortex-a57x1-a53x1]="${fvp_arm_std_library};FVP_Base_Cortex-A57x1-A53x1"
67[cortex-a57x2-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x2-A53x4"
68[cortex-a57x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4"
69[cortex-a57x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4-A53x4"
70[cortex-a65aex8]="${fvp_arm_std_library};FVP_Base_Cortex-A65AEx8"
71[cortex-a65x4]="${fvp_arm_std_library};FVP_Base_Cortex-A65x4"
72[cortex-a72x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72x4"
73[cortex-a72x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72x4-A53x4"
74[cortex-a73x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4"
75[cortex-a73x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4-A53x4"
76[cortex-a75x4]="${fvp_arm_std_library};FVP_Base_Cortex-A75x4"
77[cortex-a76aex4]="${fvp_arm_std_library};FVP_Base_Cortex-A76AEx4"
78[cortex-a76aex2]="${fvp_arm_std_library};FVP_Base_Cortex-A76AEx2"
79[cortex-a76x4]="${fvp_arm_std_library};FVP_Base_Cortex-A76x4"
80[cortex-a77x4]="${fvp_arm_std_library};FVP_Base_Cortex-A77x4"
81[cortex-a78x4]="${fvp_arm_std_library};FVP_Base_Cortex-A78x4"
82[neoverse_e1x1]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x1"
83[neoverse_e1x2]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x2"
84[neoverse_e1x4]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x4"
85[neoverse_n1]="${fvp_arm_std_library};FVP_Base_Neoverse-N1x1"
86[neoverse_n2]=";;;"
87[neoverse-v1x4]=";;;"
Bipin Ravif924efc2021-03-22 16:08:33 -050088[matterhornx4]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060089[css-rdv1]=";;;"
90[css-rde1edge]=";;;"
91[css-rdn1edge]=";;;"
92[css-rdn1edgex2]=";;;"
93[css-sgi575]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060094[tc0]=";;;"
95)
96
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -050097
Fathi Boudra422bf772019-12-02 11:10:16 +020098# FVP Kernel URLs
99declare -A fvp_kernels
100fvp_kernels=(
101[fvp-aarch32-zimage]="$linaro_release/fvp32-latest-busybox-uboot/Image"
102[fvp-busybox-uboot]="$linaro_release/fvp-latest-busybox-uboot/Image"
103[fvp-oe-uboot32]="$linaro_release/fvp32-latest-oe-uboot/Image"
104[fvp-oe-uboot]="$linaro_release/fvp-latest-oe-uboot/Image"
105[fvp-quad-busybox-uboot]="$tfa_downloads/quad_cluster/Image"
106)
107
Fathi Boudra422bf772019-12-02 11:10:16 +0200108# FVP initrd URLs
109declare -A fvp_initrd_urls
110fvp_initrd_urls=(
111[aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img"
Fathi Boudra422bf772019-12-02 11:10:16 +0200112[dummy-ramdisk]="$linaro_release/fvp-latest-oe-uboot/ramdisk.img"
113[dummy-ramdisk32]="$linaro_release/fvp32-latest-oe-uboot/ramdisk.img"
114[default]="$linaro_release/fvp-latest-busybox-uboot/ramdisk.img"
115)
116
Fathi Boudra422bf772019-12-02 11:10:16 +0200117get_optee_bin() {
Sandrine Bailleux25ff2942021-02-25 14:00:10 +0100118 url="$tfa_downloads/optee/tee.bin" \
119 saveas="bl32.bin" fetch_file
Fathi Boudra422bf772019-12-02 11:10:16 +0200120 archive_file "bl32.bin"
121}
122
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100123# For Measured Boot tests using a TA based on OPTEE, it is necessary to use a
124# specific build rather than the default one generated by Jenkins.
125get_ftpm_optee_bin() {
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100126 url="$tfa_downloads/ftpm/optee/tee-header_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100127 saveas="bl32.bin" fetch_file
128 archive_file "bl32.bin"
129
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100130 url="$tfa_downloads/ftpm/optee/tee-pager_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100131 saveas="bl32_extra1.bin" fetch_file
132 archive_file "bl32_extra1.bin"
133
Leonardo Sandovalda5f78d2021-03-18 11:09:30 -0600134 # tee-pageable_v2.bin is just a empty file, named as bl32_extra2.bin,
135 # so just create the file
136 touch "bl32_extra2.bin"
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100137 archive_file "bl32_extra2.bin"
138}
139
Fathi Boudra422bf772019-12-02 11:10:16 +0200140get_uboot32_bin() {
141 local tmpdir="$(mktempdir)"
142
143 pushd "$tmpdir"
144 extract_fip "$uboot32_fip_url"
145 mv "nt-fw.bin" "uboot.bin"
146 archive_file "uboot.bin"
147 popd
148}
149
150get_uboot_bin() {
151 local uboot_url="$linaro_release/fvp-latest-busybox-uboot/bl33-uboot.bin"
152
153 url="$uboot_url" saveas="uboot.bin" fetch_file
154 archive_file "uboot.bin"
155}
156
157get_uefi_bin() {
Zelalem219df412020-05-17 19:21:20 -0500158 uefi_downloads="${uefi_downloads:-http://files.oss.arm.com/downloads/uefi}"
159 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 +0200160
161 url=$uefi_ci_bin_url saveas="uefi.bin" fetch_file
162 archive_file "uefi.bin"
163}
164
165get_kernel() {
166 local kernel_type="${kernel_type:?}"
167 local url="${fvp_kernels[$kernel_type]}"
168
169 url="${url:?}" saveas="kernel.bin" fetch_file
170 archive_file "kernel.bin"
171}
172
173get_initrd() {
174 local initrd_type="${initrd_type:?}"
175 local url="${fvp_initrd_urls[$initrd_type]}"
176
177 url="${url:?}" saveas="initrd.bin" fetch_file
178 archive_file "initrd.bin"
179}
180
181get_dtb() {
182 local dtb_type="${dtb_type:?}"
183 local dtb_url
184 local dtb_saveas="$workspace/dtb.bin"
Zelalem219df412020-05-17 19:21:20 -0500185 local cc="$(get_tf_opt CROSS_COMPILE)"
186 local pp_flags="-P -nostdinc -undef -x assembler-with-cpp"
Fathi Boudra422bf772019-12-02 11:10:16 +0200187
188 case "$dtb_type" in
189 "fvp-base-quad-cluster-gicv3-psci")
190 # Get the quad-cluster FDT from pdsw area
191 dtb_url="$tfa_downloads/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb"
192 url="$dtb_url" saveas="$dtb_saveas" fetch_file
193 ;;
Fathi Boudra422bf772019-12-02 11:10:16 +0200194 *)
Zelalem219df412020-05-17 19:21:20 -0500195 # Preprocess DTS file
196 ${cc}gcc -E ${pp_flags} -I"$tf_root/fdts" -I"$tf_root/include" \
197 -o "$workspace/${dtb_type}.pre.dts" \
198 "$tf_root/fdts/${dtb_type}.dts"
199 # Generate DTB file from DTS
Fathi Boudra422bf772019-12-02 11:10:16 +0200200 dtc -I dts -O dtb \
Zelalem219df412020-05-17 19:21:20 -0500201 "$workspace/${dtb_type}.pre.dts" -o "$dtb_saveas"
Fathi Boudra422bf772019-12-02 11:10:16 +0200202 esac
203
204 archive_file "$dtb_saveas"
205}
206
207get_rootfs() {
208 local tmpdir
209 local fs_base="$(echo $(basename $rootfs_url) | sed 's/\.gz$//')"
210 local cached="$project_filer/ci-files/$fs_base"
211
212 if upon "$jenkins_run" && [ -f "$cached" ]; then
213 # Job workspace is limited in size, and the root file system is
214 # quite large. This means, parallel runs of root file system
215 # tests could fail. So, for Jenkins runs, copy and use the root
216 # file system image from the $CI_SCRATCH location
217 local private="$CI_SCRATCH/$JOB_NAME-$BUILD_NUMBER"
218 mkdir -p "$private"
219 rm -f "$private/rootfs.bin"
220 url="$cached" saveas="$private/rootfs.bin" fetch_file
221 ln -s "$private/rootfs.bin" "$archive/rootfs.bin"
222 return
223 fi
224
225 tmpdir="$(mktempdir)"
226 pushd "$tmpdir"
227 url="$rootfs_url" saveas="rootfs.bin" fetch_file
228
229 # Possibly, the filesystem image we just downloaded is compressed.
230 # Decompress it if required.
231 if file "rootfs.bin" | grep -iq 'gzip compressed data'; then
232 echo "Decompressing root file system image rootfs.bin ..."
233 gunzip --stdout "rootfs.bin" > uncompressed_fs.bin
234 mv uncompressed_fs.bin "rootfs.bin"
235 fi
236
237 archive_file "rootfs.bin"
238 popd
239}
240
Zelalem219df412020-05-17 19:21:20 -0500241fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i"
242
Fathi Boudra422bf772019-12-02 11:10:16 +0200243fvp_romlib_runtime() {
244 local tmpdir="$(mktempdir)"
245
246 # Save BL1 and romlib binaries from original build
247 mv "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" "$tmpdir/romlib.bin"
248 mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin"
249
250 # Patch index file
Zelalem219df412020-05-17 19:21:20 -0500251 cp "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" "$fvp_romlib_jmptbl_backup"
252 sed -i '/fdt/ s/.$/&\ patch/' ${tf_root:?}/plat/arm/board/fvp/jmptbl.i
Fathi Boudra422bf772019-12-02 11:10:16 +0200253
254 # Rebuild with patched file
255 echo "Building patched romlib:"
256 build_tf
257
Fathi Boudra422bf772019-12-02 11:10:16 +0200258 # Retrieve original BL1 and romlib binaries
259 mv "$tmpdir/romlib.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin"
260 mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin"
261}
262
Zelalem219df412020-05-17 19:21:20 -0500263fvp_romlib_cleanup() {
264 # Restore original index
265 mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
266}
267
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500268
269fvp_gen_bin_url() {
270 local bin_mode="${bin_mode:?}"
271 local bin="${1:?}"
272
273 if upon "$jenkins_run"; then
274 echo "$jenkins_url/job/$JOB_NAME/$BUILD_NUMBER/artifact/artefacts/$bin_mode/$bin"
275 else
276 echo "file://$workspace/artefacts/$bin_mode/$bin"
277 fi
278}
279
280gen_fvp_yaml_template() {
281 local yaml_template_file="$workspace/fvp_template.yaml"
282
283 # must parameters for yaml generation
284 local payload_type="${payload_type:?}"
285
286 "$ci_root/script/gen_fvp_${payload_type}_yaml.sh" > "$yaml_template_file"
287
288 archive_file "$yaml_template_file"
289}
290
291gen_fvp_yaml() {
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600292 local model="${model:?}"
293
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500294 local yaml_template_file="$workspace/fvp_template.yaml"
295 local yaml_file="$workspace/fvp.yaml"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500296 local yaml_job_file="$workspace/job.yaml"
297 local lava_model_params="$workspace/lava_model_params"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500298
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500299 # this function expects a template, quit if it is not present
300 if [ ! -f "$yaml_template_file" ]; then
301 return
302 fi
303
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600304 local model_params="${fvp_models[$model]}"
305 local model_name="$(echo "${model_params}" | awk -F ';' '{print $1}')"
306 local model_dir="$(echo "${model_params}" | awk -F ';' '{print $2}')"
307 local model_bin="$(echo "${model_params}" | awk -F ';' '{print $3}')"
308
309 # model params are required for correct yaml creation, quit if empty
310 if [ -z "${model_name}" ]; then
311 echo "FVP model param 'model_name' variable empty, yaml not produced"
312 return
313 elif [ -z "${model_dir}" ]; then
314 echo "FVP model param 'model_dir' variable empty, yaml not produced"
315 return
316 elif [ -z "${model_bin}" ]; then
317 echo "FVP model param 'model_bin' variable empty, yaml not produced"
318 return
319 fi
320
321 echo "FVP model params: model_name=$model_name model_dir=$model_dir model_bin=$model_bin"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500322
Leonardo Sandovale5cdd362020-12-11 14:59:37 -0600323 # FIXME: Foundation plaforms (model=foundationv8) are failing because LAVA [1]
324 # should read two ports, 5000 and 5002, but LAVA does not support this
325 # feature, so for the moment avoid creating any LAVA test job definition
326 # for this model until a solution is found.
327 # [1] https://tf.validation.linaro.org/scheduler/job/33871
Madhukar Pappireddy21a5e672021-03-08 17:49:45 -0600328 if ! is_arm_jenkins_env && not_upon "$local_ci"; then
Leonardo Sandoval239450c2021-01-11 17:51:12 -0600329 if [ "${model}" = "foundationv8" ]; then
330 return
331 fi
Leonardo Sandovale5cdd362020-12-11 14:59:37 -0600332 fi
333
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500334 # optional parameters, defaults to globals
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500335 local model_dtb="${model_dtb:-$default_model_dtb}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500336
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600337 # possible artefacts
338 backup_fip="$(fvp_gen_bin_url backup_fip.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500339 bl1="$(fvp_gen_bin_url bl1.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600340 bl2="$(fvp_gen_bin_url bl2.bin)"
341 bl31="$(fvp_gen_bin_url bl31.bin)"
342 bl32="$(fvp_gen_bin_url bl32.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600343 busybox="$(fvp_gen_bin_url busybox.bin.gz)"
344 cactus_primary="$(fvp_gen_bin_url cactus-primary.pkg)"
345 cactus_secondary="$(fvp_gen_bin_url cactus-secondary.pkg)"
346 cactus_tertiary="$(fvp_gen_bin_url cactus-tertiary.pkg)"
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500347 coverage_trace_plugin="${coverage_trace_plugin}"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500348 dtb="$(fvp_gen_bin_url ${model_dtb})"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600349 el3_payload="$(fvp_gen_bin_url el3_payload.bin)"
350 fip="$(fvp_gen_bin_url fip.bin)"
Leonardo Sandovalcc52beb2021-05-05 19:05:31 -0500351 fip_gpt="$(fvp_gen_bin_url fip_gpt.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600352 fwu_fip="$(fvp_gen_bin_url fwu_fip.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600353 generic_trace="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/GenericTrace.so"
354 hafnium="$(fvp_gen_bin_url hafnium.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500355 image="$(fvp_gen_bin_url kernel.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600356 mcp_rom="$(fvp_gen_bin_url mcp_rom.bin)"
357 mcp_rom_hyphen="$(fvp_gen_bin_url mcp-rom.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500358 ns_bl1u="$(fvp_gen_bin_url ns_bl1u.bin)"
359 ns_bl2u="$(fvp_gen_bin_url ns_bl2u.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600360 ramdisk="$(fvp_gen_bin_url initrd.bin)"
361 romlib="$(fvp_gen_bin_url romlib.bin)"
362 rootfs="$(fvp_gen_bin_url rootfs.bin.gz)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600363 secure_hafnium="$(fvp_gen_bin_url secure_hafnium.bin)"
364 scp_ram="$(fvp_gen_bin_url scp_ram.bin)"
365 scp_ram_hyphen="$(fvp_gen_bin_url scp-ram.bin)"
366 scp_rom="$(fvp_gen_bin_url scp_rom.bin)"
367 scp_rom_hyphen="$(fvp_gen_bin_url scp-rom.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600368 spm="$(fvp_gen_bin_url spm.bin)"
369 tftf="$(fvp_gen_bin_url tftf.bin)"
370 tmp="$(fvp_gen_bin_url tmp.bin)"
371 uboot="$(fvp_gen_bin_url uboot.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500372
373 docker_registry="${docker_registry:-}"
374 docker_registry="$(docker_registry_append)"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500375 docker_name="${docker_registry}$model_name"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600376 prompt1='/ #'
377 prompt2='root@genericarmv8:~#'
378 version_string="\"Fast Models"' [^\\n]+'"\""
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500379
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600380 # arrays that relates variables and template macros
381 # NOTE: any addition on these arrays, requires an addition in the
382 # fvp templates
383 declare -A yaml_macros
384 declare -A artefacts_macros
385 yaml_macros=(
386 [armlmd_license_file]="{ARMLMD_LICENSE_FILE}"
387 [docker_name]="{BOOT_DOCKER_NAME}"
388 [model]="{MODEL}"
389 [model_bin]="{BOOT_IMAGE_BIN}"
390 [model_dir]="{BOOT_IMAGE_DIR}"
391 [prompt1]="{PROMPT1}"
392 [prompt2]="{PROMPT2}"
393 [version_string]="{BOOT_VERSION_STRING}"
394 )
395 artefacts_macros=(
396 [backup_fip]="{BACKUP_FIP}"
397 [bl1]="{BL1}"
398 [bl2]="{BL2}"
399 [bl31]="{BL31}"
400 [bl32]="{BL32}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600401 [cactus_primary]="{CACTUS_PRIMARY}"
402 [cactus_secondary]="{CACTUS_SECONDARY}"
403 [cactus_tertiary]="{CACTUS_TERTIARY}"
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500404 [coverage_trace_plugin]="{COVERAGE_TRACE_PLUGIN}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600405 [busybox]="{BUSYBOX}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600406 [dtb]="{DTB}"
407 [el3_payload]="{EL3_PAYLOAD}"
Leonardo Sandovalcc52beb2021-05-05 19:05:31 -0500408 [fip_gpt]="{FIP_GPT}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600409 [fwu_fip]="{FWU_FIP}"
410 [fip]="{FIP}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600411 [generic_trace]="{GENERIC_TRACE}"
412 [hafnium]="{HAFNIUM}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600413 [image]="{IMAGE}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600414 [mcp_rom]="{MCP_ROM}"
415 [mcp_rom_hyphen]="{MCP_ROM_HYPHEN}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600416 [ns_bl1u]="{NS_BL1U}"
417 [ns_bl2u]="{NS_BL2U}"
418 [ramdisk]="{RAMDISK}"
419 [romlib]="{ROMLIB}"
420 [rootfs]="{ROOTFS}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600421 [secure_hafnium]="{SECURE_HAFNIUM}"
422 [scp_ram]="{SCP_RAM}"
423 [scp_ram_hyphen]="{SCP_RAM_HYPHEN}"
424 [scp_rom]="{SCP_ROM}"
425 [scp_rom_hyphen]="{SCP_ROM_HYPHEN}"
426 [spm]="{SPM}"
427 [tftf]="{TFTF}"
428 [tmp]="{TMP}"
429 [uboot]="{UBOOT}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600430 )
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500431
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600432 # templates cover all possible artefacts, but model parameters may
433 # not required all, i.e. romlib.bin, so delete those irrelevant from
434 # the template
435 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600436 # there are artefacts where deletion is handled in special case, so treat them accordingly
437 case "$m" in
438 busybox)
439 # besides the macro removal, remove the compression field
440 if ! grep -q "${m}.bin" "$archive/model_params"; then
441 sed -i "/$m:\$/d" "${yaml_template_file}"
442 sed -i "/url: ${artefacts_macros[$m]}\$/,/compression: gz\$/d" "${yaml_template_file}"
443 fi
444 ;;
445 cactus_primary)
446 # cactus packages have a hyphen, not an underscore
447 if ! grep -E -q "cactus-primary.pkg" "$archive/model_params"; then
448 sed -i "/$m:\$/d" "${yaml_template_file}"
449 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
450 fi
451 ;;
452 cactus_secondary)
453 # cactus packages have a hyphen, not an underscore
454 if ! grep -E -q "cactus-secondary.pkg" "$archive/model_params"; then
455 sed -i "/$m:\$/d" "${yaml_template_file}"
456 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
457 fi
458 ;;
459 cactus_tertiary)
460 # cactus packages have a hyphen, not an underscore
461 if ! grep -E -q "cactus-tertiary.pkg" "$archive/model_params"; then
462 sed -i "/$m:\$/d" "${yaml_template_file}"
463 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
464 fi
465 ;;
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500466 coverage_trace_plugin)
467 if ! grep -q "coverage_trace.so" "$archive/model_params"; then
468 sed -i "/$m:\$/d" "${yaml_template_file}"
469 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
470 fi
471 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600472 dtb)
473 # dtb can come in different names, i.e. dtb.bin, manifest.dtb,
474 # so handle with regex
475 if ! grep -E -q "=.*dtb.*@" "$archive/model_params"; then
476 sed -i "/$m:\$/d" "${yaml_template_file}"
477 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
478 fi
479 ;;
480 generic_trace)
481 # the image (Linux Kernel) is named as kernel.bin
482 if ! grep -q "GenericTrace.so" "$archive/model_params"; then
483 sed -i "/$m:\$/d" "${yaml_template_file}"
484 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
485 fi
486 ;;
487 image)
488 # the image (Linux Kernel) is named as kernel.bin
489 if ! grep -q "kernel.bin" "$archive/model_params"; then
490 sed -i "/$m:\$/d" "${yaml_template_file}"
491 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
492 fi
493 ;;
494 mcp_rom_hyphen)
495 # mcp rom is either present as mcp-rom or mcp_rom, handle the former case
496 if ! grep -q "mcp-rom.bin" "$archive/model_params"; then
497 sed -i "/$m:\$/d" "${yaml_template_file}"
498 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
499 fi
500 ;;
501 ramdisk)
502 # ramdisk is named initrd and is present with to extensions: bin or img
503 if ! grep -E -q "initrd.bin|initrd.img" "$archive/model_params"; then
504 sed -i "/$m:\$/d" "${yaml_template_file}"
505 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
506 fi
507 ;;
508 rootfs)
509 # besides the macro removal, remove the compression field
510 if ! grep -q "rootfs.bin" "$archive/model_params"; then
511 sed -i "/$m:\$/d" "${yaml_template_file}"
512 sed -i "/url: ${artefacts_macros[$m]}\$/,/compression: gz\$/d" "${yaml_template_file}"
513 fi
514 ;;
515 scp_ram_hyphen)
516 # scp ram is either present as scp-ram or scp_ram, handle the former case
517 if ! grep -q "scp-ram.bin" "$archive/model_params"; then
518 sed -i "/$m:\$/d" "${yaml_template_file}"
519 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
520 fi
521 ;;
522 scp_rom_hyphen)
523 # scp rom is either present as scp-rom or scp_rom, handle the former case
524 if ! grep -q "scp-rom.bin" "$archive/model_params"; then
525 sed -i "/$m:\$/d" "${yaml_template_file}"
526 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
527 fi
528 ;;
529 *)
530 if ! grep -q "${m}.bin" "$archive/model_params"; then
531 sed -i "/$m:\$/d" "${yaml_template_file}"
532 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
533 fi
534 ;;
535 esac
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600536 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500537
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600538 # copied files are the working files
539 cp "${yaml_template_file}" "${yaml_file}"
540 cp "$archive/model_params" "$lava_model_params"
541
542 # replace yaml macros with real values
543 for m in "${!yaml_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600544 sed -i -e "s|${yaml_macros[$m]}|${!m}|" "$yaml_file"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600545 done
546
547 # replace artefact macros with real values
548 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600549 sed -i -e "s|${artefacts_macros[$m]}|${!m}|" "$yaml_file"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600550 done
551
552 # LAVA expects parameters as 'macros', i.e. {X} instead of x.bin, so
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600553 # replace them. As in the macro removal above, handle special cases for several
554 # artefacts
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600555 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600556 case "$m" in
557 dtb)
558 sed -i -e "s|=.*dtb.*@|=${artefacts_macros[$m]}@|" "$lava_model_params"
559 ;;
560 cactus_primary)
561 sed -i -e "s|=cactus-primary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
562 ;;
563 cactus_secondary)
564 sed -i -e "s|=cactus-secondary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
565 ;;
566 cactus_tertiary)
567 sed -i -e "s|=cactus-tertiary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
568 ;;
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500569 coverage_trace_plugin)
570 sed -i -e "s|--plugin .*coverage_trace.so|--plugin ${artefacts_macros[$m]}|" "$lava_model_params"
571 sed -i -e "s|--plugin=.*coverage_trace.so|--plugin=${artefacts_macros[$m]}|" "$lava_model_params"
572 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600573 generic_trace)
574 sed -i -e "s|--plugin .*GenericTrace.so|--plugin ${artefacts_macros[$m]}|" "$lava_model_params"
575 sed -i -e "s|--plugin=.*GenericTrace.so|--plugin=${artefacts_macros[$m]}|" "$lava_model_params"
576 ;;
577 image)
578 sed -i -e "s|=kernel.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
579 ;;
580 mcp_rom_hyphen)
581 sed -i -e "s|=mcp-rom.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
582 ;;
583 ramdisk)
584 sed -i -e "s|=initrd.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
585 sed -i -e "s|=initrd.img|=${artefacts_macros[$m]}|" "$lava_model_params"
586 ;;
587 scp_ram_hyphen)
588 sed -i -e "s|=scp-ram.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
589 ;;
590 scp_rom_hyphen)
591 sed -i -e "s|=scp-rom.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
592 ;;
593 tmp | hafnium | secure_hafnium)
594 sed -i -e "s|=.*/${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
595 ;;
596 *)
597 sed -i -e "s|=${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
598 ;;
599 esac
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600600 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500601
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500602 # include the model parameters
603 while read -r line; do
604 if [ -n "$line" ]; then
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600605 yaml_line="- \"${line}\""
606 sed -i -e "/{BOOT_ARGUMENTS}/i \ \ \ \ $yaml_line" "$yaml_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500607 fi
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500608 done < "$lava_model_params"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600609 sed -i -e '/{BOOT_ARGUMENTS}/d' "$yaml_file"
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500610
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600611 # create job.yaml
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500612 cp "$yaml_file" "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500613
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600614 # archive both yamls
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500615 archive_file "$yaml_file"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500616 archive_file "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500617}
618
619docker_registry_append() {
620 # if docker_registry is empty, just use local docker registry
621 [ -z "$docker_registry" ] && return
622
623 local last=-1
624 local last_char="${docker_registry:last}"
625
626 if [ "$last_char" != '/' ]; then
627 docker_registry="${docker_registry}/";
628 fi
629 echo "$docker_registry"
630}
631
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000632# generate GPT image and archive it
633gen_gpt_bin() {
634 raw_image="fip_gpt.bin"
635 img_uuid="FB90808A-BA9A-4D42-B9A2-A7A937144AEE"
636 img_bank_uuid=`uuidgen`
637 disk_uuid=`uuidgen`
638 bin="${1:?}"
639
640 # maximum FIP size 2MB
641 fip_max_size=2097152
642 start_sector=34
643 sector_size=512
644 num_sectors=$(($fip_max_size/$sector_size))
645 bin_size=$(stat -c %s $bin)
646
647 if [[ $fip_max_size -lt $bin_size ]]
648 then
649 echo "FIP binary ($bin_size bytes) larger than max partition 1"
650 "size ($fip_max_size byte)"
651 return
652 fi
653
654 # create raw 5MB image
655 dd if=/dev/zero of=$raw_image bs=5M count=1
656
657 # create GPT image
658 sgdisk -a 1 -U $disk_uuid -n 1:$start_sector:+$num_sectors \
659 -c 1:FIP_A -t 1:$img_uuid $raw_image -u $img_bank_uuid
660
661 echo "write binary $bin at sector $start_sector"
662 dd if=$bin of=$raw_image bs=$sector_size seek=$start_sector \
663 count=$num_sectors conv=notrunc
664
665 archive_file "fip_gpt.bin"
666}
667
Fathi Boudra422bf772019-12-02 11:10:16 +0200668set +u