blob: 5678b907dbae2db4d794325ccd674fc9495ed7b2 [file] [log] [blame]
Leonardo Sandoval9dfdd1b2020-08-06 17:08:11 -05001#!/usr/bin/env bash
Fathi Boudra422bf772019-12-02 11:10:16 +02002#
Harrison Mutaie5122542023-03-27 13:14:18 +01003# Copyright (c) 2020-2023, 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
J-Alves12d796c2023-02-27 10:30:58 +000028export spm_secure_out_dir="${spm_secure_out_dir:-secure_aem_v8a_fvp_vhe_clang}"
29export spm_non_secure_out_dir="${spm_non_secure_out_dir:-aem_v8a_fvp_vhe_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
Harrison Mutai6f4fd6c2023-03-27 13:22:41 +010036uefi_downloads="${uefi_downloads:-http://files.oss.arm.com/downloads/uefi}"
37uefi_ci_bin_url="${uefi_ci_bin_url:-$uefi_downloads/Artifacts/Linux/github/fvp/static/DEBUG_GCC5/FVP_AARCH64_EFI.fd}"
38
Fathi Boudra422bf772019-12-02 11:10:16 +020039uboot32_fip_url="$linaro_release/fvp32-latest-busybox-uboot/fip.bin"
Harrison Mutai6f4fd6c2023-03-27 13:22:41 +010040uboot_url="$linaro_release/fvp-latest-busybox-uboot/bl33-uboot.bin"
Fathi Boudra422bf772019-12-02 11:10:16 +020041
Alexei Fedorove405cc32020-09-30 18:13:55 +010042rootfs_url="$linaro_release/lt-vexpress64-openembedded_minimal-armv8-gcc-5.2_20170127-761.img.gz"
Fathi Boudra422bf772019-12-02 11:10:16 +020043
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -050044# Default FVP model variables
Leonardo Sandovale1460662021-05-27 16:05:38 -050045default_model_dtb="dtb.bin"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -050046
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060047# FVP containers and model paths
laurenw-armafdc3bc2022-09-14 15:31:42 -050048fvp_arm_std_library_11_17="fvp:fvp_arm_std_library_${model_version_11_17}_${model_build_11_17};/opt/model/FVP_ARM_Std_Library/FVP_Base"
Govindraj Raja5adcd7d2024-06-04 14:50:28 -050049
Maksims Svecovs284a50d2021-11-02 11:09:47 +000050fvp_arm_std_library="fvp:fvp_arm_std_library_${model_version}_${model_build};/opt/model/FVP_ARM_Std_Library/FVP_Base"
laurenw-armafdc3bc2022-09-14 15:31:42 -050051fvp_base_aemva="fvp:fvp_base_aemva_${model_version}_${model_build};/opt/model/FVP_Base_AEMvA/models/${model_flavour}"
laurenw-armf414aba2021-04-26 15:58:56 -050052fvp_base_revc_2xaemva="fvp:fvp_base_revc-2xaemva_${model_version}_${model_build};/opt/model/Base_RevC_AEMvA_pkg/models/${model_flavour}"
laurenw-armafdc3bc2022-09-14 15:31:42 -050053fvp_base_aemv8a_gic600ae="fvp:fvp_base_aemv8a-gic600ae_${model_version_11_17}_${model_build_11_17};/opt/model/FVP_Base_AEMv8A-GIC600AE_pkg/models/${model_flavour_11_17}"
Govindraj Raja5adcd7d2024-06-04 14:50:28 -050054fvp_base_aemv8a_aemv8a_aemv8a_aemv8a_ccn502="fvp:fvp_base_aemv8a-aemv8a-aemv8a-aemv8a-ccn502_${model_version}_${model_build};/opt/model/FVP_Base_AEMv8A-AEMv8A-AEMv8A-AEMv8A-CCN502_pkg/models/${model_flavour}"
johpow01936638d2021-11-08 18:22:24 -060055fvp_base_aemv8r="fvp:fvp_base_aemv8r_${model_version}_${model_build};/opt/model/AEMv8R_base_pkg/models/${model_flavour}"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -050056
Manish V Badarkhef65f9a32022-11-04 10:07:19 +000057# CSS model list
58fvp_morello="fvp:fvp_morello_0.11_33;/opt/model/FVP_Morello/models/Linux64_GCC-6.4"
Chris Kay363b9342023-07-26 17:58:15 +010059fvp_rd_e1_edge="fvp:fvp_rd_e1_edge_${model_version}_${model_build};/opt/model/FVP_RD_E1_edge/models/${model_flavour}"
60fvp_rd_n1_edge="fvp:fvp_rd_n1_edge_${model_version}_${model_build};/opt/model/FVP_RD_N1_edge/models/${model_flavour}"
61fvp_rd_v1="fvp:fvp_rd_v1_${model_version}_${model_build};/opt/model/FVP_RD_V1/models/${model_flavour}"
62fvp_tc1="fvp:fvp_tc1_${model_version}_${model_build};/opt/model/FVP_TC1/models/${model_flavour}"
Manish V Badarkhec6e8e1d2023-03-18 10:25:53 +000063fvp_tc2="fvp:fvp_tc2_11.20_24;/opt/model/FVP_TC2/models/${model_flavour}"
Manish V Badarkhef65f9a32022-11-04 10:07:19 +000064
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060065# FVP associate array, run_config are keys and fvp container parameters are the values
66# Container parameters syntax: <model name>;<model dir>;<model bin>
67# FIXMEs: fix those ;;; values with real values
68
69declare -A fvp_models
70fvp_models=(
Manish V Badarkhe253a1602022-11-09 09:22:44 +000071[base-aemv8a-quad]="${fvp_base_aemv8a_aemv8a_aemv8a_aemv8a_ccn502};FVP_Base_AEMv8A-AEMv8A-AEMv8A-AEMv8A-CCN502"
laurenw-armafdc3bc2022-09-14 15:31:42 -050072[base-aemv8a-revb]="${fvp_arm_std_library};FVP_Base_AEMvA-AEMvA"
73[base-aemv8a-latest-revb]="${fvp_arm_std_library};FVP_Base_AEMvA-AEMvA"
Manish V Badarkhe253a1602022-11-09 09:22:44 +000074[base-aemva]="${fvp_base_aemva};FVP_Base_AEMvA"
75[base-aemv8a-gic600ae]="${fvp_base_aemv8a_gic600ae};FVP_Base_AEMv8A-GIC600AE"
laurenw-armf414aba2021-04-26 15:58:56 -050076[base-aemv8a]="${fvp_base_revc_2xaemva};FVP_Base_RevC-2xAEMvA"
Olivier Deprez32ebd7f2024-04-18 12:25:42 +020077[cortex-a32x4]="${fvp_arm_std_library};FVP_Base_Cortex-A32x4"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060078[cortex-a35x4]="${fvp_arm_std_library};FVP_Base_Cortex-A35x4"
79[cortex-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A53x4"
laurenw-armafdc3bc2022-09-14 15:31:42 -050080[cortex-a55x4]="${fvp_arm_std_library};FVP_Base_Cortex-A55"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060081[cortex-a57x1-a53x1]="${fvp_arm_std_library};FVP_Base_Cortex-A57x1-A53x1"
82[cortex-a57x2-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x2-A53x4"
83[cortex-a57x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4"
84[cortex-a57x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4-A53x4"
laurenw-armafdc3bc2022-09-14 15:31:42 -050085[cortex-a65aex8]="${fvp_arm_std_library};FVP_Base_Cortex-A65AE"
86[cortex-a65x4]="${fvp_arm_std_library};FVP_Base_Cortex-A65"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060087[cortex-a72x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72x4"
88[cortex-a72x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72x4-A53x4"
89[cortex-a73x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4"
90[cortex-a73x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4-A53x4"
laurenw-armafdc3bc2022-09-14 15:31:42 -050091[cortex-a75x4]="${fvp_arm_std_library};FVP_Base_Cortex-A75"
92[cortex-a76aex4]="${fvp_arm_std_library};FVP_Base_Cortex-A76AE"
93[cortex-a76aex2]="${fvp_arm_std_library};FVP_Base_Cortex-A76AE"
94[cortex-a76x4]="${fvp_arm_std_library};FVP_Base_Cortex-A76"
95[cortex-a77x4]="${fvp_arm_std_library};FVP_Base_Cortex-A77"
96[cortex-a78x4]="${fvp_arm_std_library};FVP_Base_Cortex-A78"
Juan Pablo Conded52a4752023-03-21 14:52:10 -050097[cortex-a78aex4]="${fvp_arm_std_library};FVP_Base_Cortex-A78AE"
laurenw-armafdc3bc2022-09-14 15:31:42 -050098[cortex-a78cx4]="${fvp_arm_std_library};FVP_Base_Cortex-A78C"
Govindraj Raja5adcd7d2024-06-04 14:50:28 -050099[cortex-x2]="${fvp_arm_std_library};FVP_Base_Cortex-X2"
100[cortex-a710]="${fvp_arm_std_library};FVP_Base_Cortex-A710"
laurenw-armafdc3bc2022-09-14 15:31:42 -0500101[neoverse_e1x1]="${fvp_arm_std_library};FVP_Base_Neoverse-E1"
102[neoverse_e1x2]="${fvp_arm_std_library};FVP_Base_Neoverse-E1"
103[neoverse_e1x4]="${fvp_arm_std_library};FVP_Base_Neoverse-E1"
104[neoverse_n1]="${fvp_arm_std_library};FVP_Base_Neoverse-N1"
Govindraj Raja5adcd7d2024-06-04 14:50:28 -0500105[neoverse_n2]="${fvp_arm_std_library};FVP_Base_Neoverse-N2"
laurenw-armafdc3bc2022-09-14 15:31:42 -0500106[neoverse-v1x4]="${fvp_arm_std_library};FVP_Base_Neoverse-V1"
Manish V Badarkhef65f9a32022-11-04 10:07:19 +0000107[morello]="${fvp_morello};FVP_Morello"
108[css-rde1edge]="${fvp_rd_e1_edge};FVP_RD_E1_edge"
109[css-rdn1edgex2]="${fvp_rd_n1_edge};FVP_RD_N1_edge_dual"
110[css-rdv1]="${fvp_rd_v1};FVP_RD_V1"
Manish V Badarkhef65f9a32022-11-04 10:07:19 +0000111[tc1]="${fvp_tc1};FVP_TC1"
112[tc2]="${fvp_tc2};FVP_TC2"
Divin Rajb0071052023-07-04 14:35:07 +0100113[baser-aemv8r]="${fvp_base_aemv8r};FVP_BaseR_AEMv8R"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600114)
115
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500116
Fathi Boudra422bf772019-12-02 11:10:16 +0200117# FVP Kernel URLs
Harrison Mutai6f4fd6c2023-03-27 13:22:41 +0100118declare -A kernel_list
119kernel_list=(
Fathi Boudra422bf772019-12-02 11:10:16 +0200120[fvp-aarch32-zimage]="$linaro_release/fvp32-latest-busybox-uboot/Image"
121[fvp-busybox-uboot]="$linaro_release/fvp-latest-busybox-uboot/Image"
122[fvp-oe-uboot32]="$linaro_release/fvp32-latest-oe-uboot/Image"
123[fvp-oe-uboot]="$linaro_release/fvp-latest-oe-uboot/Image"
124[fvp-quad-busybox-uboot]="$tfa_downloads/quad_cluster/Image"
125)
126
Fathi Boudra422bf772019-12-02 11:10:16 +0200127# FVP initrd URLs
Harrison Mutai6f4fd6c2023-03-27 13:22:41 +0100128declare -A initrd_list
129initrd_list=(
Fathi Boudra422bf772019-12-02 11:10:16 +0200130[aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img"
Fathi Boudra422bf772019-12-02 11:10:16 +0200131[dummy-ramdisk]="$linaro_release/fvp-latest-oe-uboot/ramdisk.img"
132[dummy-ramdisk32]="$linaro_release/fvp32-latest-oe-uboot/ramdisk.img"
133[default]="$linaro_release/fvp-latest-busybox-uboot/ramdisk.img"
134)
135
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100136# For Measured Boot tests using a TA based on OPTEE, it is necessary to use a
137# specific build rather than the default one generated by Jenkins.
138get_ftpm_optee_bin() {
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100139 url="$tfa_downloads/ftpm/optee/tee-header_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100140 saveas="bl32.bin" fetch_file
141 archive_file "bl32.bin"
142
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100143 url="$tfa_downloads/ftpm/optee/tee-pager_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100144 saveas="bl32_extra1.bin" fetch_file
145 archive_file "bl32_extra1.bin"
146
Leonardo Sandovalda5f78d2021-03-18 11:09:30 -0600147 # tee-pageable_v2.bin is just a empty file, named as bl32_extra2.bin,
148 # so just create the file
149 touch "bl32_extra2.bin"
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100150 archive_file "bl32_extra2.bin"
151}
152
Fathi Boudra422bf772019-12-02 11:10:16 +0200153get_dtb() {
154 local dtb_type="${dtb_type:?}"
155 local dtb_url
156 local dtb_saveas="$workspace/dtb.bin"
Zelalem219df412020-05-17 19:21:20 -0500157 local cc="$(get_tf_opt CROSS_COMPILE)"
158 local pp_flags="-P -nostdinc -undef -x assembler-with-cpp"
Fathi Boudra422bf772019-12-02 11:10:16 +0200159
160 case "$dtb_type" in
161 "fvp-base-quad-cluster-gicv3-psci")
162 # Get the quad-cluster FDT from pdsw area
163 dtb_url="$tfa_downloads/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb"
164 url="$dtb_url" saveas="$dtb_saveas" fetch_file
165 ;;
Fathi Boudra422bf772019-12-02 11:10:16 +0200166 *)
Zelalem219df412020-05-17 19:21:20 -0500167 # Preprocess DTS file
168 ${cc}gcc -E ${pp_flags} -I"$tf_root/fdts" -I"$tf_root/include" \
169 -o "$workspace/${dtb_type}.pre.dts" \
170 "$tf_root/fdts/${dtb_type}.dts"
171 # Generate DTB file from DTS
Fathi Boudra422bf772019-12-02 11:10:16 +0200172 dtc -I dts -O dtb \
Zelalem219df412020-05-17 19:21:20 -0500173 "$workspace/${dtb_type}.pre.dts" -o "$dtb_saveas"
Fathi Boudra422bf772019-12-02 11:10:16 +0200174 esac
175
176 archive_file "$dtb_saveas"
177}
178
179get_rootfs() {
180 local tmpdir
181 local fs_base="$(echo $(basename $rootfs_url) | sed 's/\.gz$//')"
182 local cached="$project_filer/ci-files/$fs_base"
183
184 if upon "$jenkins_run" && [ -f "$cached" ]; then
185 # Job workspace is limited in size, and the root file system is
186 # quite large. This means, parallel runs of root file system
187 # tests could fail. So, for Jenkins runs, copy and use the root
188 # file system image from the $CI_SCRATCH location
189 local private="$CI_SCRATCH/$JOB_NAME-$BUILD_NUMBER"
190 mkdir -p "$private"
191 rm -f "$private/rootfs.bin"
192 url="$cached" saveas="$private/rootfs.bin" fetch_file
193 ln -s "$private/rootfs.bin" "$archive/rootfs.bin"
194 return
195 fi
196
197 tmpdir="$(mktempdir)"
198 pushd "$tmpdir"
199 url="$rootfs_url" saveas="rootfs.bin" fetch_file
200
201 # Possibly, the filesystem image we just downloaded is compressed.
202 # Decompress it if required.
203 if file "rootfs.bin" | grep -iq 'gzip compressed data'; then
204 echo "Decompressing root file system image rootfs.bin ..."
205 gunzip --stdout "rootfs.bin" > uncompressed_fs.bin
206 mv uncompressed_fs.bin "rootfs.bin"
207 fi
208
209 archive_file "rootfs.bin"
210 popd
211}
212
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200213fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i"
214
Fathi Boudra422bf772019-12-02 11:10:16 +0200215fvp_romlib_runtime() {
216 local tmpdir="$(mktempdir)"
217
218 # Save BL1 and romlib binaries from original build
219 mv "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" "$tmpdir/romlib.bin"
220 mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin"
221
222 # Patch index file
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200223 cp "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" "$fvp_romlib_jmptbl_backup"
224 sed -i '/fdt/ s/.$/&\ patch/' ${tf_root:?}/plat/arm/board/fvp/jmptbl.i
Fathi Boudra422bf772019-12-02 11:10:16 +0200225
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200226 # Rebuild with patched file
227 echo "Building patched romlib:"
228 build_tf
Fathi Boudra422bf772019-12-02 11:10:16 +0200229
Fathi Boudra422bf772019-12-02 11:10:16 +0200230 # Retrieve original BL1 and romlib binaries
231 mv "$tmpdir/romlib.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin"
232 mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin"
233}
234
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200235fvp_romlib_cleanup() {
236 # Restore original index
237 mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
238}
239
240
Chris Kayc9523b12022-10-10 18:32:20 +0100241# Generates the final YAML-based LAVA job definition from a template file.
242#
243# The job definition template is expanded with visibility of all variables that
244# are available from within the function, including those with local scope.
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500245gen_fvp_yaml() {
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600246 local model="${model:?}"
247
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500248 local yaml_template_file="$workspace/fvp_template.yaml"
249 local yaml_file="$workspace/fvp.yaml"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500250 local yaml_job_file="$workspace/job.yaml"
251 local lava_model_params="$workspace/lava_model_params"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500252
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500253 # this function expects a template, quit if it is not present
254 if [ ! -f "$yaml_template_file" ]; then
Paul Sokolovskya3c5a4c2023-01-24 18:33:58 +0700255 echo "warning: gen_fvp_yaml: template $yaml_template_file not available, skipping generating LAVA job"
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500256 return
257 fi
258
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600259 local model_params="${fvp_models[$model]}"
260 local model_name="$(echo "${model_params}" | awk -F ';' '{print $1}')"
261 local model_dir="$(echo "${model_params}" | awk -F ';' '{print $2}')"
262 local model_bin="$(echo "${model_params}" | awk -F ';' '{print $3}')"
263
264 # model params are required for correct yaml creation, quit if empty
265 if [ -z "${model_name}" ]; then
266 echo "FVP model param 'model_name' variable empty, yaml not produced"
267 return
268 elif [ -z "${model_dir}" ]; then
269 echo "FVP model param 'model_dir' variable empty, yaml not produced"
270 return
271 elif [ -z "${model_bin}" ]; then
272 echo "FVP model param 'model_bin' variable empty, yaml not produced"
273 return
274 fi
275
276 echo "FVP model params: model_name=$model_name model_dir=$model_dir model_bin=$model_bin"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500277
278 # optional parameters, defaults to globals
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500279 local model_dtb="${model_dtb:-$default_model_dtb}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500280
Chris Kayc9523b12022-10-10 18:32:20 +0100281 if [ -n "${GERRIT_CHANGE_NUMBER}" ]; then
282 local gerrit_url="https://review.trustedfirmware.org/c/${GERRIT_CHANGE_NUMBER}/${GERRIT_PATCHSET_NUMBER}"
283 elif [ -n "${GERRIT_REFSPEC}" ]; then
284 local gerrit_url=$(echo ${GERRIT_REFSPEC} |
285 awk -F/ '{print "https://review.trustedfirmware.org/c/" $4 "/" $5}')
286 fi
287
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500288 docker_registry="${docker_registry:-}"
289 docker_registry="$(docker_registry_append)"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500290 docker_name="${docker_registry}$model_name"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600291 prompt1='/ #'
292 prompt2='root@genericarmv8:~#'
293 version_string="\"Fast Models"' [^\\n]+'"\""
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500294
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500295 test_config="${TEST_CONFIG}"
296
Harrison Mutaia6d6e682023-03-27 13:20:33 +0100297 declare -A fvp_artefact_filters=(
Chris Kay4eb9ded2022-10-10 15:51:40 +0100298 [backup_fip]="backup_fip.bin"
299 [bl1]="bl1.bin"
300 [bl2]="bl2.bin"
301 [bl31]="bl31.bin"
302 [bl32]="bl32.bin"
303 [busybox]="busybox.bin"
304 [cactus_primary]="cactus-primary.pkg"
305 [cactus_secondary]="cactus-secondary.pkg"
306 [cactus_tertiary]="cactus-tertiary.pkg"
307 [coverage_trace_plugin]="coverage_trace.so"
308 [dtb]="dtb.bin"
309 [el3_payload]="el3_payload.bin"
Manish V Badarkhedbb9cb12022-11-16 12:30:41 +0000310 [ete_trace]="libete-plugin.so"
311 [etm_trace]="ETMv4ExamplePlugin.so"
Chris Kay4eb9ded2022-10-10 15:51:40 +0100312 [fip_gpt]="fip_gpt.bin"
313 [fip]="fip.bin"
314 [fvp_spmc_manifest_dtb]="=fvp_spmc_manifest.dtb"
315 [fwu_fip]="fwu_fip.bin"
316 [generic_trace]="GenericTrace.so"
317 [hafnium]="hafnium.bin"
318 [image]="kernel.bin"
319 [ivy]="ivy.pkg"
320 [manifest_dtb]="=manifest.dtb"
Chris Kayfbdd0142022-11-08 12:24:30 +0000321 [mcp_fw]="mcp_fw.bin"
Manish V Badarkhe18c59782022-11-09 10:14:48 +0000322 [mcp_ram]="mcp_ram.bin"
Chris Kay4eb9ded2022-10-10 15:51:40 +0100323 [mcp_rom_hyphen]="mcp-rom.bin"
324 [mcp_rom]="mcp_rom.bin"
325 [ns_bl1u]="ns_bl1u.bin"
326 [ns_bl2u]="ns_bl2u.bin"
327 [ramdisk]="initrd.bin|initrd.img"
328 [romlib]="romlib.bin"
329 [rootfs]="rootfs.bin"
laurenw-arm60de2742023-03-08 10:50:15 -0600330 [host_flash_fip]="host_flash_fip.bin"
Manish V Badarkhe93093dd2022-11-09 10:29:27 +0000331 [rss_rom]="rss_rom.bin"
Chris Kayfbdd0142022-11-08 12:24:30 +0000332 [scp_fw]="scp_fw.bin"
Chris Kay4eb9ded2022-10-10 15:51:40 +0100333 [scp_ram_hyphen]="scp-ram.bin"
334 [scp_ram]="scp_ram.bin"
335 [scp_rom_hyphen]="scp-rom.bin"
336 [scp_rom]="scp_rom.bin"
337 [secure_hafnium]="secure_hafnium.bin"
338 [spm]="spm.bin"
339 [tftf]="tftf.bin"
340 [tmp]="tmp.bin"
341 [uboot]="uboot.bin"
342 )
343
Harrison Mutaia6d6e682023-03-27 13:20:33 +0100344 declare -A fvp_artefact_urls=(
Harrison Mutaie5122542023-03-27 13:14:18 +0100345 [backup_fip]="$(gen_bin_url backup_fip.bin)"
346 [bl1]="$(gen_bin_url bl1.bin)"
347 [bl2]="$(gen_bin_url bl2.bin)"
348 [bl31]="$(gen_bin_url bl31.bin)"
349 [bl32]="$(gen_bin_url bl32.bin)"
350 [busybox]="$(gen_bin_url busybox.bin.gz)"
351 [cactus_primary]="$(gen_bin_url cactus-primary.pkg)"
352 [cactus_secondary]="$(gen_bin_url cactus-secondary.pkg)"
353 [cactus_tertiary]="$(gen_bin_url cactus-tertiary.pkg)"
Chris Kayc14743a2022-10-13 11:33:26 +0100354 [coverage_trace_plugin]="${coverage_trace_plugin}"
Harrison Mutaie5122542023-03-27 13:14:18 +0100355 [dtb]="$(gen_bin_url ${model_dtb})"
356 [el3_payload]="$(gen_bin_url el3_payload.bin)"
Manish V Badarkhedbb9cb12022-11-16 12:30:41 +0000357 [ete_trace]="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/libete-plugin.so"
358 [etm_trace]="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/ETMv4ExamplePlugin.so"
Harrison Mutaie5122542023-03-27 13:14:18 +0100359 [fip]="$(gen_bin_url fip.bin)"
360 [fip_gpt]="$(gen_bin_url fip_gpt.bin)"
361 [fvp_spmc_manifest_dtb]="$(gen_bin_url fvp_spmc_manifest.dtb)"
362 [fwu_fip]="$(gen_bin_url fwu_fip.bin)"
Chris Kayc14743a2022-10-13 11:33:26 +0100363 [generic_trace]="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/GenericTrace.so"
Harrison Mutaie5122542023-03-27 13:14:18 +0100364 [hafnium]="$(gen_bin_url hafnium.bin)"
365 [image]="$(gen_bin_url kernel.bin)"
366 [ivy]="$(gen_bin_url ivy.pkg)"
367 [manifest_dtb]="$(gen_bin_url manifest.dtb)"
368 [mcp_fw]="$(gen_bin_url mcp_fw.bin)"
369 [mcp_ram]="$(gen_bin_url mcp_ram.bin)"
370 [mcp_rom]="$(gen_bin_url mcp_rom.bin)"
371 [mcp_rom_hyphen]="$(gen_bin_url mcp-rom.bin)"
372 [ns_bl1u]="$(gen_bin_url ns_bl1u.bin)"
373 [ns_bl2u]="$(gen_bin_url ns_bl2u.bin)"
374 [ramdisk]="$(gen_bin_url initrd.bin)"
375 [romlib]="$(gen_bin_url romlib.bin)"
376 [rootfs]="$(gen_bin_url rootfs.bin.gz)"
377 [host_flash_fip]="$(gen_bin_url host_flash_fip.bin)"
378 [rss_rom]="$(gen_bin_url rss_rom.bin)"
379 [secure_hafnium]="$(gen_bin_url secure_hafnium.bin)"
380 [scp_fw]="$(gen_bin_url scp_fw.bin)"
381 [scp_ram]="$(gen_bin_url scp_ram.bin)"
382 [scp_ram_hyphen]="$(gen_bin_url scp-ram.bin)"
383 [scp_rom]="$(gen_bin_url scp_rom.bin)"
384 [scp_rom_hyphen]="$(gen_bin_url scp-rom.bin)"
385 [spm]="$(gen_bin_url spm.bin)"
386 [tftf]="$(gen_bin_url tftf.bin)"
387 [tmp]="$(gen_bin_url tmp.bin)"
388 [uboot]="$(gen_bin_url uboot.bin)"
Chris Kayc14743a2022-10-13 11:33:26 +0100389 )
390
Chris Kay5d550d82022-10-12 17:20:31 +0100391 # In LAVA we don't provide the paths to the artefacts directly, but instead
392 # use macros of the form `{XYZ}`. This is a list of regular expression
393 # replacements to run on the model parameters file before we add them to the
394 # LAVA job definition.
Harrison Mutaia6d6e682023-03-27 13:20:33 +0100395 declare -A fvp_artefact_macros=(
Chris Kay5d550d82022-10-12 17:20:31 +0100396 ["[= ]backup_fip.bin"]="={BACKUP_FIP}"
397 ["[= ]bl1.bin"]="={BL1}"
398 ["[= ]bl2.bin"]="={BL2}"
399 ["[= ]bl31.bin"]="={BL31}"
400 ["[= ]bl32.bin"]="={BL32}"
401 ["[= ]cactus-primary.pkg"]="={CACTUS_PRIMARY}"
402 ["[= ]cactus-secondary.pkg"]="={CACTUS_SECONDARY}"
403 ["[= ]cactus-tertiary.pkg"]="={CACTUS_TERTIARY}"
404 ["[= ].*coverage_trace.so"]="={COVERAGE_TRACE_PLUGIN}"
405 ["[= ]fvp_spmc_manifest.dtb"]="={FVP_SPMC_MANIFEST_DTB}"
406 ["[= ]busybox.bin"]="={BUSYBOX}"
407 ["[= ]dtb.bin"]="={DTB}"
408 ["[= ]el3_payload.bin"]="={EL3_PAYLOAD}"
Manish V Badarkhedbb9cb12022-11-16 12:30:41 +0000409 ["[= ].*libete-plugin.so"]="={ETE_TRACE}"
410 ["[= ].*ETMv4ExamplePlugin.so"]="={ETM_TRACE}"
Chris Kay5d550d82022-10-12 17:20:31 +0100411 ["[= ]fip_gpt.bin"]="={FIP_GPT}"
412 ["[= ]fwu_fip.bin"]="={FWU_FIP}"
413 ["[= ]fip.bin"]="={FIP}"
414 ["[= ].*GenericTrace.so"]="={GENERIC_TRACE}"
415 ["[= ].*/hafnium.bin"]="={HAFNIUM}"
416 ["[= ]kernel.bin"]="={IMAGE}"
417 ["[= ]ivy.pkg"]="={IVY}"
418 ["[= ]manifest.dtb"]="={MANIFEST_DTB}"
Chris Kayfbdd0142022-11-08 12:24:30 +0000419 ["[= ]mcp_fw.bin"]="={MCP_FW}"
Manish V Badarkhe18c59782022-11-09 10:14:48 +0000420 ["[= ]mcp_ram.bin"]="={MCP_RAM}"
Chris Kayef9cc802022-11-08 12:11:58 +0000421 ["[= ]mcp_rom.bin"]="={MCP_ROM}"
422 ["[= ]mcp-rom.bin"]="={MCP_ROM_HYPHEN}"
Chris Kay5d550d82022-10-12 17:20:31 +0100423 ["[= ]ns_bl1u.bin"]="={NS_BL1U}"
424 ["[= ]ns_bl2u.bin"]="={NS_BL2U}"
425 ["[= ]initrd.bin"]="={RAMDISK}"
426 ["[= ]initrd.img"]="={RAMDISK}"
427 ["[= ]romlib.bin"]="={ROMLIB}"
428 ["[= ]rootfs.bin"]="={ROOTFS}"
laurenw-arm60de2742023-03-08 10:50:15 -0600429 ["[= ]host_flash_fip.bin"]="={HOST_FLASH_FIP}"
Manish V Badarkhe93093dd2022-11-09 10:29:27 +0000430 ["[= ]rss_rom.bin"]="={RSS_ROM}"
Chris Kay5d550d82022-10-12 17:20:31 +0100431 ["[= ].*/secure_hafnium.bin"]="={SECURE_HAFNIUM}"
Chris Kayfbdd0142022-11-08 12:24:30 +0000432 ["[= ]scp_fw.bin"]="={SCP_FW}"
Chris Kay5d550d82022-10-12 17:20:31 +0100433 ["[= ]scp_ram.bin"]="={SCP_RAM}"
434 ["[= ]scp-ram.bin"]="={SCP_RAM_HYPHEN}"
435 ["[= ]scp_rom.bin"]="={SCP_ROM}"
436 ["[= ]scp-rom.bin"]="={SCP_ROM_HYPHEN}"
437 ["[= ]spm.bin"]="={SPM}"
438 ["[= ]tftf.bin"]="={TFTF}"
439 ["[= ].*/tmp.bin"]="={TMP}"
440 ["[= ]uboot.bin"]="={UBOOT}"
441 )
442
Harrison Mutaia6d6e682023-03-27 13:20:33 +0100443 declare -a fvp_artefacts
444 filter_artefacts fvp_artefacts fvp_artefact_filters
Chris Kay4eb9ded2022-10-10 15:51:40 +0100445
Harrison Mutaia6d6e682023-03-27 13:20:33 +0100446 lava_model_params="${lava_model_params}" \
447 gen_lava_model_params fvp_artefact_macros
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500448
Harrison Mutaia6d6e682023-03-27 13:20:33 +0100449 yaml_template_file="$yaml_template_file" \
450 yaml_file="$yaml_file" \
451 yaml_job_file="$yaml_job_file" \
452 gen_lava_job_def fvp_artefacts fvp_artefact_urls
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500453}
454
455docker_registry_append() {
456 # if docker_registry is empty, just use local docker registry
457 [ -z "$docker_registry" ] && return
458
459 local last=-1
460 local last_char="${docker_registry:last}"
461
462 if [ "$last_char" != '/' ]; then
463 docker_registry="${docker_registry}/";
464 fi
465 echo "$docker_registry"
466}
467
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000468# generate GPT image and archive it
469gen_gpt_bin() {
470 raw_image="fip_gpt.bin"
471 img_uuid="FB90808A-BA9A-4D42-B9A2-A7A937144AEE"
472 img_bank_uuid=`uuidgen`
473 disk_uuid=`uuidgen`
474 bin="${1:?}"
475
476 # maximum FIP size 2MB
477 fip_max_size=2097152
478 start_sector=34
479 sector_size=512
480 num_sectors=$(($fip_max_size/$sector_size))
481 bin_size=$(stat -c %s $bin)
482
483 if [[ $fip_max_size -lt $bin_size ]]
484 then
Manish V Badarkhe3640b062022-11-16 11:36:36 +0000485 echo "FIP binary ($bin_size bytes) larger than max partition 1" \
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000486 "size ($fip_max_size byte)"
487 return
488 fi
489
490 # create raw 5MB image
491 dd if=/dev/zero of=$raw_image bs=5M count=1
492
493 # create GPT image
494 sgdisk -a 1 -U $disk_uuid -n 1:$start_sector:+$num_sectors \
495 -c 1:FIP_A -t 1:$img_uuid $raw_image -u $img_bank_uuid
496
497 echo "write binary $bin at sector $start_sector"
498 dd if=$bin of=$raw_image bs=$sector_size seek=$start_sector \
499 count=$num_sectors conv=notrunc
500
501 archive_file "fip_gpt.bin"
502}
503
Govindraj Raja67501732023-09-22 16:27:06 -0500504#corrupt GPT image header and archive it
505corrupt_gpt_bin() {
506 bin="${1:?}"
507
508 # Primary GPT header is present in LBA-1 second block after MBR
509 # empty the primary GPT header forcing to use backup GPT header
510 # and backup GPT entries.
511 dd if=/dev/zero of=$bin bs=512 seek=1 count=1 conv=notrunc
512}
513
Fathi Boudra422bf772019-12-02 11:10:16 +0200514set +u