blob: 5545a9503495aec0191f99dd35b764e1de966eb9 [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}"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060045fvp_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 -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"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060087[neoverse_n2]=";;;"
88[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]=";;;"
96)
97
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -050098
Fathi Boudra422bf772019-12-02 11:10:16 +020099# FVP Kernel URLs
100declare -A fvp_kernels
101fvp_kernels=(
102[fvp-aarch32-zimage]="$linaro_release/fvp32-latest-busybox-uboot/Image"
103[fvp-busybox-uboot]="$linaro_release/fvp-latest-busybox-uboot/Image"
104[fvp-oe-uboot32]="$linaro_release/fvp32-latest-oe-uboot/Image"
105[fvp-oe-uboot]="$linaro_release/fvp-latest-oe-uboot/Image"
106[fvp-quad-busybox-uboot]="$tfa_downloads/quad_cluster/Image"
107)
108
Fathi Boudra422bf772019-12-02 11:10:16 +0200109# FVP initrd URLs
110declare -A fvp_initrd_urls
111fvp_initrd_urls=(
112[aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img"
Fathi Boudra422bf772019-12-02 11:10:16 +0200113[dummy-ramdisk]="$linaro_release/fvp-latest-oe-uboot/ramdisk.img"
114[dummy-ramdisk32]="$linaro_release/fvp32-latest-oe-uboot/ramdisk.img"
115[default]="$linaro_release/fvp-latest-busybox-uboot/ramdisk.img"
116)
117
Fathi Boudra422bf772019-12-02 11:10:16 +0200118get_optee_bin() {
Sandrine Bailleux25ff2942021-02-25 14:00:10 +0100119 url="$tfa_downloads/optee/tee.bin" \
120 saveas="bl32.bin" fetch_file
Fathi Boudra422bf772019-12-02 11:10:16 +0200121 archive_file "bl32.bin"
122}
123
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100124# For Measured Boot tests using a TA based on OPTEE, it is necessary to use a
125# specific build rather than the default one generated by Jenkins.
126get_ftpm_optee_bin() {
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100127 url="$tfa_downloads/ftpm/optee/tee-header_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100128 saveas="bl32.bin" fetch_file
129 archive_file "bl32.bin"
130
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100131 url="$tfa_downloads/ftpm/optee/tee-pager_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100132 saveas="bl32_extra1.bin" fetch_file
133 archive_file "bl32_extra1.bin"
134
Leonardo Sandovalda5f78d2021-03-18 11:09:30 -0600135 # tee-pageable_v2.bin is just a empty file, named as bl32_extra2.bin,
136 # so just create the file
137 touch "bl32_extra2.bin"
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100138 archive_file "bl32_extra2.bin"
139}
140
Fathi Boudra422bf772019-12-02 11:10:16 +0200141get_uboot32_bin() {
142 local tmpdir="$(mktempdir)"
143
144 pushd "$tmpdir"
145 extract_fip "$uboot32_fip_url"
146 mv "nt-fw.bin" "uboot.bin"
147 archive_file "uboot.bin"
148 popd
149}
150
151get_uboot_bin() {
152 local uboot_url="$linaro_release/fvp-latest-busybox-uboot/bl33-uboot.bin"
153
154 url="$uboot_url" saveas="uboot.bin" fetch_file
155 archive_file "uboot.bin"
156}
157
158get_uefi_bin() {
Zelalem219df412020-05-17 19:21:20 -0500159 uefi_downloads="${uefi_downloads:-http://files.oss.arm.com/downloads/uefi}"
160 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 +0200161
162 url=$uefi_ci_bin_url saveas="uefi.bin" fetch_file
163 archive_file "uefi.bin"
164}
165
166get_kernel() {
167 local kernel_type="${kernel_type:?}"
168 local url="${fvp_kernels[$kernel_type]}"
169
170 url="${url:?}" saveas="kernel.bin" fetch_file
171 archive_file "kernel.bin"
172}
173
174get_initrd() {
175 local initrd_type="${initrd_type:?}"
176 local url="${fvp_initrd_urls[$initrd_type]}"
177
178 url="${url:?}" saveas="initrd.bin" fetch_file
179 archive_file "initrd.bin"
180}
181
182get_dtb() {
183 local dtb_type="${dtb_type:?}"
184 local dtb_url
185 local dtb_saveas="$workspace/dtb.bin"
Zelalem219df412020-05-17 19:21:20 -0500186 local cc="$(get_tf_opt CROSS_COMPILE)"
187 local pp_flags="-P -nostdinc -undef -x assembler-with-cpp"
Fathi Boudra422bf772019-12-02 11:10:16 +0200188
189 case "$dtb_type" in
190 "fvp-base-quad-cluster-gicv3-psci")
191 # Get the quad-cluster FDT from pdsw area
192 dtb_url="$tfa_downloads/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb"
193 url="$dtb_url" saveas="$dtb_saveas" fetch_file
194 ;;
Fathi Boudra422bf772019-12-02 11:10:16 +0200195 *)
Zelalem219df412020-05-17 19:21:20 -0500196 # Preprocess DTS file
197 ${cc}gcc -E ${pp_flags} -I"$tf_root/fdts" -I"$tf_root/include" \
198 -o "$workspace/${dtb_type}.pre.dts" \
199 "$tf_root/fdts/${dtb_type}.dts"
200 # Generate DTB file from DTS
Fathi Boudra422bf772019-12-02 11:10:16 +0200201 dtc -I dts -O dtb \
Zelalem219df412020-05-17 19:21:20 -0500202 "$workspace/${dtb_type}.pre.dts" -o "$dtb_saveas"
Fathi Boudra422bf772019-12-02 11:10:16 +0200203 esac
204
205 archive_file "$dtb_saveas"
206}
207
208get_rootfs() {
209 local tmpdir
210 local fs_base="$(echo $(basename $rootfs_url) | sed 's/\.gz$//')"
211 local cached="$project_filer/ci-files/$fs_base"
212
213 if upon "$jenkins_run" && [ -f "$cached" ]; then
214 # Job workspace is limited in size, and the root file system is
215 # quite large. This means, parallel runs of root file system
216 # tests could fail. So, for Jenkins runs, copy and use the root
217 # file system image from the $CI_SCRATCH location
218 local private="$CI_SCRATCH/$JOB_NAME-$BUILD_NUMBER"
219 mkdir -p "$private"
220 rm -f "$private/rootfs.bin"
221 url="$cached" saveas="$private/rootfs.bin" fetch_file
222 ln -s "$private/rootfs.bin" "$archive/rootfs.bin"
223 return
224 fi
225
226 tmpdir="$(mktempdir)"
227 pushd "$tmpdir"
228 url="$rootfs_url" saveas="rootfs.bin" fetch_file
229
230 # Possibly, the filesystem image we just downloaded is compressed.
231 # Decompress it if required.
232 if file "rootfs.bin" | grep -iq 'gzip compressed data'; then
233 echo "Decompressing root file system image rootfs.bin ..."
234 gunzip --stdout "rootfs.bin" > uncompressed_fs.bin
235 mv uncompressed_fs.bin "rootfs.bin"
236 fi
237
238 archive_file "rootfs.bin"
239 popd
240}
241
Zelalem219df412020-05-17 19:21:20 -0500242fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i"
243
Fathi Boudra422bf772019-12-02 11:10:16 +0200244fvp_romlib_runtime() {
245 local tmpdir="$(mktempdir)"
246
247 # Save BL1 and romlib binaries from original build
248 mv "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" "$tmpdir/romlib.bin"
249 mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin"
250
251 # Patch index file
Zelalem219df412020-05-17 19:21:20 -0500252 cp "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" "$fvp_romlib_jmptbl_backup"
253 sed -i '/fdt/ s/.$/&\ patch/' ${tf_root:?}/plat/arm/board/fvp/jmptbl.i
Fathi Boudra422bf772019-12-02 11:10:16 +0200254
255 # Rebuild with patched file
256 echo "Building patched romlib:"
257 build_tf
258
Fathi Boudra422bf772019-12-02 11:10:16 +0200259 # Retrieve original BL1 and romlib binaries
260 mv "$tmpdir/romlib.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin"
261 mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin"
262}
263
Zelalem219df412020-05-17 19:21:20 -0500264fvp_romlib_cleanup() {
265 # Restore original index
266 mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
267}
268
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500269
270fvp_gen_bin_url() {
271 local bin_mode="${bin_mode:?}"
272 local bin="${1:?}"
273
274 if upon "$jenkins_run"; then
275 echo "$jenkins_url/job/$JOB_NAME/$BUILD_NUMBER/artifact/artefacts/$bin_mode/$bin"
276 else
277 echo "file://$workspace/artefacts/$bin_mode/$bin"
278 fi
279}
280
281gen_fvp_yaml_template() {
282 local yaml_template_file="$workspace/fvp_template.yaml"
283
284 # must parameters for yaml generation
285 local payload_type="${payload_type:?}"
286
287 "$ci_root/script/gen_fvp_${payload_type}_yaml.sh" > "$yaml_template_file"
288
289 archive_file "$yaml_template_file"
290}
291
292gen_fvp_yaml() {
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600293 local model="${model:?}"
294
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500295 local yaml_template_file="$workspace/fvp_template.yaml"
296 local yaml_file="$workspace/fvp.yaml"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500297 local yaml_job_file="$workspace/job.yaml"
298 local lava_model_params="$workspace/lava_model_params"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500299
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500300 # this function expects a template, quit if it is not present
301 if [ ! -f "$yaml_template_file" ]; then
302 return
303 fi
304
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600305 local model_params="${fvp_models[$model]}"
306 local model_name="$(echo "${model_params}" | awk -F ';' '{print $1}')"
307 local model_dir="$(echo "${model_params}" | awk -F ';' '{print $2}')"
308 local model_bin="$(echo "${model_params}" | awk -F ';' '{print $3}')"
309
310 # model params are required for correct yaml creation, quit if empty
311 if [ -z "${model_name}" ]; then
312 echo "FVP model param 'model_name' variable empty, yaml not produced"
313 return
314 elif [ -z "${model_dir}" ]; then
315 echo "FVP model param 'model_dir' variable empty, yaml not produced"
316 return
317 elif [ -z "${model_bin}" ]; then
318 echo "FVP model param 'model_bin' variable empty, yaml not produced"
319 return
320 fi
321
322 echo "FVP model params: model_name=$model_name model_dir=$model_dir model_bin=$model_bin"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500323
324 # optional parameters, defaults to globals
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500325 local model_dtb="${model_dtb:-$default_model_dtb}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500326
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600327 # possible artefacts
328 backup_fip="$(fvp_gen_bin_url backup_fip.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500329 bl1="$(fvp_gen_bin_url bl1.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600330 bl2="$(fvp_gen_bin_url bl2.bin)"
331 bl31="$(fvp_gen_bin_url bl31.bin)"
332 bl32="$(fvp_gen_bin_url bl32.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600333 busybox="$(fvp_gen_bin_url busybox.bin.gz)"
334 cactus_primary="$(fvp_gen_bin_url cactus-primary.pkg)"
335 cactus_secondary="$(fvp_gen_bin_url cactus-secondary.pkg)"
336 cactus_tertiary="$(fvp_gen_bin_url cactus-tertiary.pkg)"
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500337 coverage_trace_plugin="${coverage_trace_plugin}"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500338 dtb="$(fvp_gen_bin_url ${model_dtb})"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600339 el3_payload="$(fvp_gen_bin_url el3_payload.bin)"
340 fip="$(fvp_gen_bin_url fip.bin)"
Leonardo Sandovalcc52beb2021-05-05 19:05:31 -0500341 fip_gpt="$(fvp_gen_bin_url fip_gpt.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600342 fwu_fip="$(fvp_gen_bin_url fwu_fip.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600343 generic_trace="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/GenericTrace.so"
344 hafnium="$(fvp_gen_bin_url hafnium.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500345 image="$(fvp_gen_bin_url kernel.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600346 mcp_rom="$(fvp_gen_bin_url mcp_rom.bin)"
347 mcp_rom_hyphen="$(fvp_gen_bin_url mcp-rom.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500348 ns_bl1u="$(fvp_gen_bin_url ns_bl1u.bin)"
349 ns_bl2u="$(fvp_gen_bin_url ns_bl2u.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600350 ramdisk="$(fvp_gen_bin_url initrd.bin)"
351 romlib="$(fvp_gen_bin_url romlib.bin)"
352 rootfs="$(fvp_gen_bin_url rootfs.bin.gz)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600353 secure_hafnium="$(fvp_gen_bin_url secure_hafnium.bin)"
354 scp_ram="$(fvp_gen_bin_url scp_ram.bin)"
355 scp_ram_hyphen="$(fvp_gen_bin_url scp-ram.bin)"
356 scp_rom="$(fvp_gen_bin_url scp_rom.bin)"
357 scp_rom_hyphen="$(fvp_gen_bin_url scp-rom.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600358 spm="$(fvp_gen_bin_url spm.bin)"
359 tftf="$(fvp_gen_bin_url tftf.bin)"
360 tmp="$(fvp_gen_bin_url tmp.bin)"
361 uboot="$(fvp_gen_bin_url uboot.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500362
363 docker_registry="${docker_registry:-}"
364 docker_registry="$(docker_registry_append)"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500365 docker_name="${docker_registry}$model_name"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600366 prompt1='/ #'
367 prompt2='root@genericarmv8:~#'
368 version_string="\"Fast Models"' [^\\n]+'"\""
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500369
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500370 test_config="${TEST_CONFIG}"
371
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600372 # arrays that relates variables and template macros
373 # NOTE: any addition on these arrays, requires an addition in the
374 # fvp templates
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500375 declare -A metadata_macros
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600376 declare -A yaml_macros
377 declare -A artefacts_macros
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500378 metadata_macros=(
379 [test_config]="{TEST_CONFIG}"
380 )
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600381 yaml_macros=(
382 [armlmd_license_file]="{ARMLMD_LICENSE_FILE}"
383 [docker_name]="{BOOT_DOCKER_NAME}"
384 [model]="{MODEL}"
385 [model_bin]="{BOOT_IMAGE_BIN}"
386 [model_dir]="{BOOT_IMAGE_DIR}"
387 [prompt1]="{PROMPT1}"
388 [prompt2]="{PROMPT2}"
389 [version_string]="{BOOT_VERSION_STRING}"
390 )
391 artefacts_macros=(
392 [backup_fip]="{BACKUP_FIP}"
393 [bl1]="{BL1}"
394 [bl2]="{BL2}"
395 [bl31]="{BL31}"
396 [bl32]="{BL32}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600397 [cactus_primary]="{CACTUS_PRIMARY}"
398 [cactus_secondary]="{CACTUS_SECONDARY}"
399 [cactus_tertiary]="{CACTUS_TERTIARY}"
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500400 [coverage_trace_plugin]="{COVERAGE_TRACE_PLUGIN}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600401 [busybox]="{BUSYBOX}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600402 [dtb]="{DTB}"
403 [el3_payload]="{EL3_PAYLOAD}"
Leonardo Sandovalcc52beb2021-05-05 19:05:31 -0500404 [fip_gpt]="{FIP_GPT}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600405 [fwu_fip]="{FWU_FIP}"
406 [fip]="{FIP}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600407 [generic_trace]="{GENERIC_TRACE}"
408 [hafnium]="{HAFNIUM}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600409 [image]="{IMAGE}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600410 [mcp_rom]="{MCP_ROM}"
411 [mcp_rom_hyphen]="{MCP_ROM_HYPHEN}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600412 [ns_bl1u]="{NS_BL1U}"
413 [ns_bl2u]="{NS_BL2U}"
414 [ramdisk]="{RAMDISK}"
415 [romlib]="{ROMLIB}"
416 [rootfs]="{ROOTFS}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600417 [secure_hafnium]="{SECURE_HAFNIUM}"
418 [scp_ram]="{SCP_RAM}"
419 [scp_ram_hyphen]="{SCP_RAM_HYPHEN}"
420 [scp_rom]="{SCP_ROM}"
421 [scp_rom_hyphen]="{SCP_ROM_HYPHEN}"
422 [spm]="{SPM}"
423 [tftf]="{TFTF}"
424 [tmp]="{TMP}"
425 [uboot]="{UBOOT}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600426 )
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500427
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600428 # templates cover all possible artefacts, but model parameters may
429 # not required all, i.e. romlib.bin, so delete those irrelevant from
430 # the template
431 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600432 # there are artefacts where deletion is handled in special case, so treat them accordingly
433 case "$m" in
434 busybox)
435 # besides the macro removal, remove the compression field
436 if ! grep -q "${m}.bin" "$archive/model_params"; then
437 sed -i "/$m:\$/d" "${yaml_template_file}"
438 sed -i "/url: ${artefacts_macros[$m]}\$/,/compression: gz\$/d" "${yaml_template_file}"
439 fi
440 ;;
441 cactus_primary)
442 # cactus packages have a hyphen, not an underscore
443 if ! grep -E -q "cactus-primary.pkg" "$archive/model_params"; then
444 sed -i "/$m:\$/d" "${yaml_template_file}"
445 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
446 fi
447 ;;
448 cactus_secondary)
449 # cactus packages have a hyphen, not an underscore
450 if ! grep -E -q "cactus-secondary.pkg" "$archive/model_params"; then
451 sed -i "/$m:\$/d" "${yaml_template_file}"
452 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
453 fi
454 ;;
455 cactus_tertiary)
456 # cactus packages have a hyphen, not an underscore
457 if ! grep -E -q "cactus-tertiary.pkg" "$archive/model_params"; then
458 sed -i "/$m:\$/d" "${yaml_template_file}"
459 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
460 fi
461 ;;
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500462 coverage_trace_plugin)
463 if ! grep -q "coverage_trace.so" "$archive/model_params"; then
464 sed -i "/$m:\$/d" "${yaml_template_file}"
465 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
466 fi
467 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600468 dtb)
469 # dtb can come in different names, i.e. dtb.bin, manifest.dtb,
470 # so handle with regex
471 if ! grep -E -q "=.*dtb.*@" "$archive/model_params"; then
472 sed -i "/$m:\$/d" "${yaml_template_file}"
473 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
474 fi
475 ;;
476 generic_trace)
477 # the image (Linux Kernel) is named as kernel.bin
478 if ! grep -q "GenericTrace.so" "$archive/model_params"; then
479 sed -i "/$m:\$/d" "${yaml_template_file}"
480 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
481 fi
482 ;;
483 image)
484 # the image (Linux Kernel) is named as kernel.bin
485 if ! grep -q "kernel.bin" "$archive/model_params"; then
486 sed -i "/$m:\$/d" "${yaml_template_file}"
487 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
488 fi
489 ;;
490 mcp_rom_hyphen)
491 # mcp rom is either present as mcp-rom or mcp_rom, handle the former case
492 if ! grep -q "mcp-rom.bin" "$archive/model_params"; then
493 sed -i "/$m:\$/d" "${yaml_template_file}"
494 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
495 fi
496 ;;
497 ramdisk)
498 # ramdisk is named initrd and is present with to extensions: bin or img
499 if ! grep -E -q "initrd.bin|initrd.img" "$archive/model_params"; then
500 sed -i "/$m:\$/d" "${yaml_template_file}"
501 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
502 fi
503 ;;
504 rootfs)
505 # besides the macro removal, remove the compression field
506 if ! grep -q "rootfs.bin" "$archive/model_params"; then
507 sed -i "/$m:\$/d" "${yaml_template_file}"
508 sed -i "/url: ${artefacts_macros[$m]}\$/,/compression: gz\$/d" "${yaml_template_file}"
509 fi
510 ;;
511 scp_ram_hyphen)
512 # scp ram is either present as scp-ram or scp_ram, handle the former case
513 if ! grep -q "scp-ram.bin" "$archive/model_params"; then
514 sed -i "/$m:\$/d" "${yaml_template_file}"
515 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
516 fi
517 ;;
518 scp_rom_hyphen)
519 # scp rom is either present as scp-rom or scp_rom, handle the former case
520 if ! grep -q "scp-rom.bin" "$archive/model_params"; then
521 sed -i "/$m:\$/d" "${yaml_template_file}"
522 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
523 fi
524 ;;
525 *)
526 if ! grep -q "${m}.bin" "$archive/model_params"; then
527 sed -i "/$m:\$/d" "${yaml_template_file}"
528 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
529 fi
530 ;;
531 esac
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600532 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500533
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600534 # copied files are the working files
535 cp "${yaml_template_file}" "${yaml_file}"
536 cp "$archive/model_params" "$lava_model_params"
537
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500538 # replace metadata macros with real values
539 for m in "${!metadata_macros[@]}"; do
540 sed -i -e "s|${metadata_macros[$m]}|${!m}|" "$yaml_file"
541 done
542
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600543 # replace yaml macros with real values
544 for m in "${!yaml_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600545 sed -i -e "s|${yaml_macros[$m]}|${!m}|" "$yaml_file"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600546 done
547
548 # replace artefact macros with real values
549 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600550 sed -i -e "s|${artefacts_macros[$m]}|${!m}|" "$yaml_file"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600551 done
552
553 # LAVA expects parameters as 'macros', i.e. {X} instead of x.bin, so
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600554 # replace them. As in the macro removal above, handle special cases for several
555 # artefacts
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600556 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600557 case "$m" in
558 dtb)
559 sed -i -e "s|=.*dtb.*@|=${artefacts_macros[$m]}@|" "$lava_model_params"
560 ;;
561 cactus_primary)
562 sed -i -e "s|=cactus-primary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
563 ;;
564 cactus_secondary)
565 sed -i -e "s|=cactus-secondary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
566 ;;
567 cactus_tertiary)
568 sed -i -e "s|=cactus-tertiary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
569 ;;
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500570 coverage_trace_plugin)
571 sed -i -e "s|--plugin .*coverage_trace.so|--plugin ${artefacts_macros[$m]}|" "$lava_model_params"
572 sed -i -e "s|--plugin=.*coverage_trace.so|--plugin=${artefacts_macros[$m]}|" "$lava_model_params"
573 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600574 generic_trace)
575 sed -i -e "s|--plugin .*GenericTrace.so|--plugin ${artefacts_macros[$m]}|" "$lava_model_params"
576 sed -i -e "s|--plugin=.*GenericTrace.so|--plugin=${artefacts_macros[$m]}|" "$lava_model_params"
577 ;;
578 image)
579 sed -i -e "s|=kernel.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
580 ;;
581 mcp_rom_hyphen)
582 sed -i -e "s|=mcp-rom.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
583 ;;
584 ramdisk)
585 sed -i -e "s|=initrd.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
586 sed -i -e "s|=initrd.img|=${artefacts_macros[$m]}|" "$lava_model_params"
587 ;;
588 scp_ram_hyphen)
589 sed -i -e "s|=scp-ram.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
590 ;;
591 scp_rom_hyphen)
592 sed -i -e "s|=scp-rom.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
593 ;;
594 tmp | hafnium | secure_hafnium)
595 sed -i -e "s|=.*/${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
596 ;;
597 *)
598 sed -i -e "s|=${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
599 ;;
600 esac
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600601 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500602
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500603 # include the model parameters
604 while read -r line; do
605 if [ -n "$line" ]; then
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600606 yaml_line="- \"${line}\""
607 sed -i -e "/{BOOT_ARGUMENTS}/i \ \ \ \ $yaml_line" "$yaml_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500608 fi
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500609 done < "$lava_model_params"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600610 sed -i -e '/{BOOT_ARGUMENTS}/d' "$yaml_file"
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500611
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500612 # Append expect commands into the job definition through test-interactive commands
613 gen_fvp_yaml_expect >> "$yaml_file"
614
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600615 # create job.yaml
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500616 cp "$yaml_file" "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500617
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600618 # archive both yamls
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500619 archive_file "$yaml_file"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500620 archive_file "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500621}
622
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500623gen_fvp_yaml_expect() {
624 # Loop through all uarts expect files
625 run_root="$archive/run"
626 for expect_file in $(find $run_root -name expect); do
627
628 # TODO: currently, only handle UART 0
629 case $expect_file in
630 *uart0* )
631 uart_number=uart0
632 ;;
633 *)
634 continue
635 ;;
636 esac
637
638 # Array containing expect strings and populated during run config execution
639 expect_string=()
640
641 # Get the real name of the expect file
642 expect_file=$(cat $expect_file)
643
644 # Source the run_config enviroment variables
645 env=$run_root/$uart_number/env
646 if [ -e $env ]; then
647 source $env
648 fi
649
650 # Get all expect strings
651 expect_file=$ci_root/lava-expect/${expect_file}
652 source $expect_file
653
654 # Append the corresponding test-interactive commands
655 if [ ${#expect_string[@]} -gt 0 ]; then
656
657 cat << EOF
658- test:
659 timeout:
660 minutes: 15
661 interactive:
662EOF
663 for key in "${!expect_string[@]}"; do
664
665 # Expect strings have the format '<prompt>;<successes>;<failures>', so use these
666 # arrays to store them separately
667 prompts=()
668 successes=()
669 failures=()
670 commands=()
671
672 # Parse expect string values and split into the arrays
673 for es in "${expect_string[@]}"; do
674 prompts+=("$(echo "${es}" | awk -F ';' '{print $1}')")
675 successes+=("$(echo "${es}" | awk -F ';' '{print $2}')")
676 failures+=("$(echo "${es}" | awk -F ';' '{print $3}')")
677 commands+=("$(echo "${es}" | awk -F ';' '{print $4}')")
678 done
679
680 OLD_IFS=$IFS; IFS=$'@'
681
682 if [[ -n "${prompts[$key]}" && -n "${successes[$key]}" && -n "${failures[$key]}" ]]; then
683 cat << EOF
684 - name: ${uart_number}_${key}
685 prompts: ['${prompts[$key]}']
686 script:
687 - name: result
688 command: ${commands[$key]}
689EOF
690 cat << EOF
691 successes:
692EOF
693 for s in ${successes[$key]}; do
694 cat <<EOF
695 - message: '$s'
696EOF
697 done
698 cat << EOF
699 failures:
700EOF
701 for f in ${failures[$key]}; do
702 cat <<EOF
703 - message: '$f'
704EOF
705 done
706 elif [[ -n "${prompts[$key]}" && -n "${successes[$key]}" ]]; then
707 cat << EOF
708 - name: ${uart_number}_${key}
709 prompts: ['${prompts[$key]}']
710 script:
711 - name: result
712 command: ${commands[$key]}
713 successes:
714EOF
715 for s in ${successes[$key]}; do
716 cat <<EOF
717 - message: '$s'
718EOF
719 done
720 elif [[ -n "${prompts[$key]}" && -n "${failures[$key]}" ]]; then
721 cat << EOF
722 - name: ${uart_number}_${key}
723 prompts: ['${prompts[$key]}']
724 script:
725 - name: result
726 command: ${commands[$key]}
727 failures:
728EOF
729 for f in ${failures[$key]}; do
730 cat <<EOF
731 - message: '$f'
732EOF
733 done
734
735 else
736 cat << EOF
737 - name: ${uart_number}_${key}
738 prompts: ['${prompts[$key]}']
739 script:
740 - name: result
741 command: ${commands[$key]}
742EOF
743 fi
744 IFS=$OLD_IFS
745 done
746 fi
747 done
748}
749
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500750docker_registry_append() {
751 # if docker_registry is empty, just use local docker registry
752 [ -z "$docker_registry" ] && return
753
754 local last=-1
755 local last_char="${docker_registry:last}"
756
757 if [ "$last_char" != '/' ]; then
758 docker_registry="${docker_registry}/";
759 fi
760 echo "$docker_registry"
761}
762
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000763# generate GPT image and archive it
764gen_gpt_bin() {
765 raw_image="fip_gpt.bin"
766 img_uuid="FB90808A-BA9A-4D42-B9A2-A7A937144AEE"
767 img_bank_uuid=`uuidgen`
768 disk_uuid=`uuidgen`
769 bin="${1:?}"
770
771 # maximum FIP size 2MB
772 fip_max_size=2097152
773 start_sector=34
774 sector_size=512
775 num_sectors=$(($fip_max_size/$sector_size))
776 bin_size=$(stat -c %s $bin)
777
778 if [[ $fip_max_size -lt $bin_size ]]
779 then
780 echo "FIP binary ($bin_size bytes) larger than max partition 1"
781 "size ($fip_max_size byte)"
782 return
783 fi
784
785 # create raw 5MB image
786 dd if=/dev/zero of=$raw_image bs=5M count=1
787
788 # create GPT image
789 sgdisk -a 1 -U $disk_uuid -n 1:$start_sector:+$num_sectors \
790 -c 1:FIP_A -t 1:$img_uuid $raw_image -u $img_bank_uuid
791
792 echo "write binary $bin at sector $start_sector"
793 dd if=$bin of=$raw_image bs=$sector_size seek=$start_sector \
794 count=$num_sectors conv=notrunc
795
796 archive_file "fip_gpt.bin"
797}
798
Fathi Boudra422bf772019-12-02 11:10:16 +0200799set +u