blob: 00400328a6aeff87296cb394b0200f0ab0615ffe [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}"
laurenw-armf414aba2021-04-26 15:58:56 -050044fvp_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 -060045foundation_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"
laurenw-armf414aba2021-04-26 15:58:56 -050059[base-aemv8a]="${fvp_base_revc_2xaemva};FVP_Base_RevC-2xAEMvA"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060060[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]=";;;"
Bipin Ravif924efc2021-03-22 16:08:33 -050087[matterhornx4]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060088[css-rdv1]=";;;"
89[css-rde1edge]=";;;"
90[css-rdn1edge]=";;;"
91[css-rdn1edgex2]=";;;"
92[css-sgi575]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060093[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
Leonardo Sandovalda5f78d2021-03-18 11:09:30 -0600133 # tee-pageable_v2.bin is just a empty file, named as bl32_extra2.bin,
134 # so just create the file
135 touch "bl32_extra2.bin"
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100136 archive_file "bl32_extra2.bin"
137}
138
Fathi Boudra422bf772019-12-02 11:10:16 +0200139get_uboot32_bin() {
140 local tmpdir="$(mktempdir)"
141
142 pushd "$tmpdir"
143 extract_fip "$uboot32_fip_url"
144 mv "nt-fw.bin" "uboot.bin"
145 archive_file "uboot.bin"
146 popd
147}
148
149get_uboot_bin() {
150 local uboot_url="$linaro_release/fvp-latest-busybox-uboot/bl33-uboot.bin"
151
152 url="$uboot_url" saveas="uboot.bin" fetch_file
153 archive_file "uboot.bin"
154}
155
156get_uefi_bin() {
Zelalem219df412020-05-17 19:21:20 -0500157 uefi_downloads="${uefi_downloads:-http://files.oss.arm.com/downloads/uefi}"
158 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 +0200159
160 url=$uefi_ci_bin_url saveas="uefi.bin" fetch_file
161 archive_file "uefi.bin"
162}
163
164get_kernel() {
165 local kernel_type="${kernel_type:?}"
166 local url="${fvp_kernels[$kernel_type]}"
167
168 url="${url:?}" saveas="kernel.bin" fetch_file
169 archive_file "kernel.bin"
170}
171
172get_initrd() {
173 local initrd_type="${initrd_type:?}"
174 local url="${fvp_initrd_urls[$initrd_type]}"
175
176 url="${url:?}" saveas="initrd.bin" fetch_file
177 archive_file "initrd.bin"
178}
179
180get_dtb() {
181 local dtb_type="${dtb_type:?}"
182 local dtb_url
183 local dtb_saveas="$workspace/dtb.bin"
Zelalem219df412020-05-17 19:21:20 -0500184 local cc="$(get_tf_opt CROSS_COMPILE)"
185 local pp_flags="-P -nostdinc -undef -x assembler-with-cpp"
Fathi Boudra422bf772019-12-02 11:10:16 +0200186
187 case "$dtb_type" in
188 "fvp-base-quad-cluster-gicv3-psci")
189 # Get the quad-cluster FDT from pdsw area
190 dtb_url="$tfa_downloads/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb"
191 url="$dtb_url" saveas="$dtb_saveas" fetch_file
192 ;;
Fathi Boudra422bf772019-12-02 11:10:16 +0200193 *)
Zelalem219df412020-05-17 19:21:20 -0500194 # Preprocess DTS file
195 ${cc}gcc -E ${pp_flags} -I"$tf_root/fdts" -I"$tf_root/include" \
196 -o "$workspace/${dtb_type}.pre.dts" \
197 "$tf_root/fdts/${dtb_type}.dts"
198 # Generate DTB file from DTS
Fathi Boudra422bf772019-12-02 11:10:16 +0200199 dtc -I dts -O dtb \
Zelalem219df412020-05-17 19:21:20 -0500200 "$workspace/${dtb_type}.pre.dts" -o "$dtb_saveas"
Fathi Boudra422bf772019-12-02 11:10:16 +0200201 esac
202
203 archive_file "$dtb_saveas"
204}
205
206get_rootfs() {
207 local tmpdir
208 local fs_base="$(echo $(basename $rootfs_url) | sed 's/\.gz$//')"
209 local cached="$project_filer/ci-files/$fs_base"
210
211 if upon "$jenkins_run" && [ -f "$cached" ]; then
212 # Job workspace is limited in size, and the root file system is
213 # quite large. This means, parallel runs of root file system
214 # tests could fail. So, for Jenkins runs, copy and use the root
215 # file system image from the $CI_SCRATCH location
216 local private="$CI_SCRATCH/$JOB_NAME-$BUILD_NUMBER"
217 mkdir -p "$private"
218 rm -f "$private/rootfs.bin"
219 url="$cached" saveas="$private/rootfs.bin" fetch_file
220 ln -s "$private/rootfs.bin" "$archive/rootfs.bin"
221 return
222 fi
223
224 tmpdir="$(mktempdir)"
225 pushd "$tmpdir"
226 url="$rootfs_url" saveas="rootfs.bin" fetch_file
227
228 # Possibly, the filesystem image we just downloaded is compressed.
229 # Decompress it if required.
230 if file "rootfs.bin" | grep -iq 'gzip compressed data'; then
231 echo "Decompressing root file system image rootfs.bin ..."
232 gunzip --stdout "rootfs.bin" > uncompressed_fs.bin
233 mv uncompressed_fs.bin "rootfs.bin"
234 fi
235
236 archive_file "rootfs.bin"
237 popd
238}
239
Zelalem219df412020-05-17 19:21:20 -0500240fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i"
241
Fathi Boudra422bf772019-12-02 11:10:16 +0200242fvp_romlib_runtime() {
243 local tmpdir="$(mktempdir)"
244
245 # Save BL1 and romlib binaries from original build
246 mv "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" "$tmpdir/romlib.bin"
247 mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin"
248
249 # Patch index file
Zelalem219df412020-05-17 19:21:20 -0500250 cp "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" "$fvp_romlib_jmptbl_backup"
251 sed -i '/fdt/ s/.$/&\ patch/' ${tf_root:?}/plat/arm/board/fvp/jmptbl.i
Fathi Boudra422bf772019-12-02 11:10:16 +0200252
253 # Rebuild with patched file
254 echo "Building patched romlib:"
255 build_tf
256
Fathi Boudra422bf772019-12-02 11:10:16 +0200257 # Retrieve original BL1 and romlib binaries
258 mv "$tmpdir/romlib.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin"
259 mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin"
260}
261
Zelalem219df412020-05-17 19:21:20 -0500262fvp_romlib_cleanup() {
263 # Restore original index
264 mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
265}
266
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500267
268fvp_gen_bin_url() {
269 local bin_mode="${bin_mode:?}"
270 local bin="${1:?}"
271
272 if upon "$jenkins_run"; then
273 echo "$jenkins_url/job/$JOB_NAME/$BUILD_NUMBER/artifact/artefacts/$bin_mode/$bin"
274 else
275 echo "file://$workspace/artefacts/$bin_mode/$bin"
276 fi
277}
278
279gen_fvp_yaml_template() {
280 local yaml_template_file="$workspace/fvp_template.yaml"
281
282 # must parameters for yaml generation
283 local payload_type="${payload_type:?}"
284
285 "$ci_root/script/gen_fvp_${payload_type}_yaml.sh" > "$yaml_template_file"
286
287 archive_file "$yaml_template_file"
288}
289
290gen_fvp_yaml() {
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600291 local model="${model:?}"
292
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500293 local yaml_template_file="$workspace/fvp_template.yaml"
294 local yaml_file="$workspace/fvp.yaml"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500295 local yaml_job_file="$workspace/job.yaml"
296 local lava_model_params="$workspace/lava_model_params"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500297
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500298 # this function expects a template, quit if it is not present
299 if [ ! -f "$yaml_template_file" ]; then
300 return
301 fi
302
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600303 local model_params="${fvp_models[$model]}"
304 local model_name="$(echo "${model_params}" | awk -F ';' '{print $1}')"
305 local model_dir="$(echo "${model_params}" | awk -F ';' '{print $2}')"
306 local model_bin="$(echo "${model_params}" | awk -F ';' '{print $3}')"
307
308 # model params are required for correct yaml creation, quit if empty
309 if [ -z "${model_name}" ]; then
310 echo "FVP model param 'model_name' variable empty, yaml not produced"
311 return
312 elif [ -z "${model_dir}" ]; then
313 echo "FVP model param 'model_dir' variable empty, yaml not produced"
314 return
315 elif [ -z "${model_bin}" ]; then
316 echo "FVP model param 'model_bin' variable empty, yaml not produced"
317 return
318 fi
319
320 echo "FVP model params: model_name=$model_name model_dir=$model_dir model_bin=$model_bin"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500321
Leonardo Sandovale5cdd362020-12-11 14:59:37 -0600322 # FIXME: Foundation plaforms (model=foundationv8) are failing because LAVA [1]
323 # should read two ports, 5000 and 5002, but LAVA does not support this
324 # feature, so for the moment avoid creating any LAVA test job definition
325 # for this model until a solution is found.
326 # [1] https://tf.validation.linaro.org/scheduler/job/33871
Madhukar Pappireddy21a5e672021-03-08 17:49:45 -0600327 if ! is_arm_jenkins_env && not_upon "$local_ci"; then
Leonardo Sandoval239450c2021-01-11 17:51:12 -0600328 if [ "${model}" = "foundationv8" ]; then
329 return
330 fi
Leonardo Sandovale5cdd362020-12-11 14:59:37 -0600331 fi
332
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500333 # optional parameters, defaults to globals
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500334 local model_dtb="${model_dtb:-$default_model_dtb}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500335
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600336 # possible artefacts
337 backup_fip="$(fvp_gen_bin_url backup_fip.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500338 bl1="$(fvp_gen_bin_url bl1.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600339 bl2="$(fvp_gen_bin_url bl2.bin)"
340 bl31="$(fvp_gen_bin_url bl31.bin)"
341 bl32="$(fvp_gen_bin_url bl32.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600342 busybox="$(fvp_gen_bin_url busybox.bin.gz)"
343 cactus_primary="$(fvp_gen_bin_url cactus-primary.pkg)"
344 cactus_secondary="$(fvp_gen_bin_url cactus-secondary.pkg)"
345 cactus_tertiary="$(fvp_gen_bin_url cactus-tertiary.pkg)"
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500346 coverage_trace_plugin="${coverage_trace_plugin}"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500347 dtb="$(fvp_gen_bin_url ${model_dtb})"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600348 el3_payload="$(fvp_gen_bin_url el3_payload.bin)"
349 fip="$(fvp_gen_bin_url fip.bin)"
350 fwu_fip="$(fvp_gen_bin_url fwu_fip.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600351 generic_trace="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/GenericTrace.so"
352 hafnium="$(fvp_gen_bin_url hafnium.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500353 image="$(fvp_gen_bin_url kernel.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600354 mcp_rom="$(fvp_gen_bin_url mcp_rom.bin)"
355 mcp_rom_hyphen="$(fvp_gen_bin_url mcp-rom.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500356 ns_bl1u="$(fvp_gen_bin_url ns_bl1u.bin)"
357 ns_bl2u="$(fvp_gen_bin_url ns_bl2u.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600358 ramdisk="$(fvp_gen_bin_url initrd.bin)"
359 romlib="$(fvp_gen_bin_url romlib.bin)"
360 rootfs="$(fvp_gen_bin_url rootfs.bin.gz)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600361 secure_hafnium="$(fvp_gen_bin_url secure_hafnium.bin)"
362 scp_ram="$(fvp_gen_bin_url scp_ram.bin)"
363 scp_ram_hyphen="$(fvp_gen_bin_url scp-ram.bin)"
364 scp_rom="$(fvp_gen_bin_url scp_rom.bin)"
365 scp_rom_hyphen="$(fvp_gen_bin_url scp-rom.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600366 spm="$(fvp_gen_bin_url spm.bin)"
367 tftf="$(fvp_gen_bin_url tftf.bin)"
368 tmp="$(fvp_gen_bin_url tmp.bin)"
369 uboot="$(fvp_gen_bin_url uboot.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500370
371 docker_registry="${docker_registry:-}"
372 docker_registry="$(docker_registry_append)"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500373 docker_name="${docker_registry}$model_name"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600374 prompt1='/ #'
375 prompt2='root@genericarmv8:~#'
376 version_string="\"Fast Models"' [^\\n]+'"\""
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500377
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600378 # arrays that relates variables and template macros
379 # NOTE: any addition on these arrays, requires an addition in the
380 # fvp templates
381 declare -A yaml_macros
382 declare -A artefacts_macros
383 yaml_macros=(
384 [armlmd_license_file]="{ARMLMD_LICENSE_FILE}"
385 [docker_name]="{BOOT_DOCKER_NAME}"
386 [model]="{MODEL}"
387 [model_bin]="{BOOT_IMAGE_BIN}"
388 [model_dir]="{BOOT_IMAGE_DIR}"
389 [prompt1]="{PROMPT1}"
390 [prompt2]="{PROMPT2}"
391 [version_string]="{BOOT_VERSION_STRING}"
392 )
393 artefacts_macros=(
394 [backup_fip]="{BACKUP_FIP}"
395 [bl1]="{BL1}"
396 [bl2]="{BL2}"
397 [bl31]="{BL31}"
398 [bl32]="{BL32}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600399 [cactus_primary]="{CACTUS_PRIMARY}"
400 [cactus_secondary]="{CACTUS_SECONDARY}"
401 [cactus_tertiary]="{CACTUS_TERTIARY}"
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500402 [coverage_trace_plugin]="{COVERAGE_TRACE_PLUGIN}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600403 [busybox]="{BUSYBOX}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600404 [dtb]="{DTB}"
405 [el3_payload]="{EL3_PAYLOAD}"
406 [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
539 # replace yaml macros with real values
540 for m in "${!yaml_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600541 sed -i -e "s|${yaml_macros[$m]}|${!m}|" "$yaml_file"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600542 done
543
544 # replace artefact macros with real values
545 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600546 sed -i -e "s|${artefacts_macros[$m]}|${!m}|" "$yaml_file"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600547 done
548
549 # LAVA expects parameters as 'macros', i.e. {X} instead of x.bin, so
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600550 # replace them. As in the macro removal above, handle special cases for several
551 # artefacts
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600552 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600553 case "$m" in
554 dtb)
555 sed -i -e "s|=.*dtb.*@|=${artefacts_macros[$m]}@|" "$lava_model_params"
556 ;;
557 cactus_primary)
558 sed -i -e "s|=cactus-primary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
559 ;;
560 cactus_secondary)
561 sed -i -e "s|=cactus-secondary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
562 ;;
563 cactus_tertiary)
564 sed -i -e "s|=cactus-tertiary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
565 ;;
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500566 coverage_trace_plugin)
567 sed -i -e "s|--plugin .*coverage_trace.so|--plugin ${artefacts_macros[$m]}|" "$lava_model_params"
568 sed -i -e "s|--plugin=.*coverage_trace.so|--plugin=${artefacts_macros[$m]}|" "$lava_model_params"
569 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600570 generic_trace)
571 sed -i -e "s|--plugin .*GenericTrace.so|--plugin ${artefacts_macros[$m]}|" "$lava_model_params"
572 sed -i -e "s|--plugin=.*GenericTrace.so|--plugin=${artefacts_macros[$m]}|" "$lava_model_params"
573 ;;
574 image)
575 sed -i -e "s|=kernel.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
576 ;;
577 mcp_rom_hyphen)
578 sed -i -e "s|=mcp-rom.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
579 ;;
580 ramdisk)
581 sed -i -e "s|=initrd.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
582 sed -i -e "s|=initrd.img|=${artefacts_macros[$m]}|" "$lava_model_params"
583 ;;
584 scp_ram_hyphen)
585 sed -i -e "s|=scp-ram.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
586 ;;
587 scp_rom_hyphen)
588 sed -i -e "s|=scp-rom.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
589 ;;
590 tmp | hafnium | secure_hafnium)
591 sed -i -e "s|=.*/${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
592 ;;
593 *)
594 sed -i -e "s|=${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
595 ;;
596 esac
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600597 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500598
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500599 # include the model parameters
600 while read -r line; do
601 if [ -n "$line" ]; then
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600602 yaml_line="- \"${line}\""
603 sed -i -e "/{BOOT_ARGUMENTS}/i \ \ \ \ $yaml_line" "$yaml_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500604 fi
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500605 done < "$lava_model_params"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600606 sed -i -e '/{BOOT_ARGUMENTS}/d' "$yaml_file"
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500607
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600608 # create job.yaml
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500609 cp "$yaml_file" "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500610
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600611 # archive both yamls
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500612 archive_file "$yaml_file"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500613 archive_file "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500614}
615
616docker_registry_append() {
617 # if docker_registry is empty, just use local docker registry
618 [ -z "$docker_registry" ] && return
619
620 local last=-1
621 local last_char="${docker_registry:last}"
622
623 if [ "$last_char" != '/' ]; then
624 docker_registry="${docker_registry}/";
625 fi
626 echo "$docker_registry"
627}
628
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000629# generate GPT image and archive it
630gen_gpt_bin() {
631 raw_image="fip_gpt.bin"
632 img_uuid="FB90808A-BA9A-4D42-B9A2-A7A937144AEE"
633 img_bank_uuid=`uuidgen`
634 disk_uuid=`uuidgen`
635 bin="${1:?}"
636
637 # maximum FIP size 2MB
638 fip_max_size=2097152
639 start_sector=34
640 sector_size=512
641 num_sectors=$(($fip_max_size/$sector_size))
642 bin_size=$(stat -c %s $bin)
643
644 if [[ $fip_max_size -lt $bin_size ]]
645 then
646 echo "FIP binary ($bin_size bytes) larger than max partition 1"
647 "size ($fip_max_size byte)"
648 return
649 fi
650
651 # create raw 5MB image
652 dd if=/dev/zero of=$raw_image bs=5M count=1
653
654 # create GPT image
655 sgdisk -a 1 -U $disk_uuid -n 1:$start_sector:+$num_sectors \
656 -c 1:FIP_A -t 1:$img_uuid $raw_image -u $img_bank_uuid
657
658 echo "write binary $bin at sector $start_sector"
659 dd if=$bin of=$raw_image bs=$sector_size seek=$start_sector \
660 count=$num_sectors conv=notrunc
661
662 archive_file "fip_gpt.bin"
663}
664
Fathi Boudra422bf772019-12-02 11:10:16 +0200665set +u