blob: 1e31c0be476545bed56fad429256cfdd11be3211 [file] [log] [blame]
Leonardo Sandoval9dfdd1b2020-08-06 17:08:11 -05001#!/usr/bin/env bash
Fathi Boudra422bf772019-12-02 11:10:16 +02002#
Zelalem219df412020-05-17 19:21:20 -05003# Copyright (c) 2019-2020, 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 Pandey3c435582020-07-15 12:14:26 +010026
Fathi Boudra422bf772019-12-02 11:10:16 +020027ns_bl1u_addr="${ns_bl1u_addr:-0x0beb8000}"
28fwu_fip_addr="${fwu_fip_addr:-0x08400000}"
29backup_fip_addr="${backup_fip_addr:-0x09000000}"
30romlib_addr="${romlib_addr:-0x03ff2000}"
31
32uboot32_fip_url="$linaro_release/fvp32-latest-busybox-uboot/fip.bin"
33
Alexei Fedorove405cc32020-09-30 18:13:55 +010034rootfs_url="$linaro_release/lt-vexpress64-openembedded_minimal-armv8-gcc-5.2_20170127-761.img.gz"
Fathi Boudra422bf772019-12-02 11:10:16 +020035
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -050036# Default FVP model variables
37default_model_dtb="fvp-base-gicv3-psci.dtb"
38
39# default to the fvp container containing most of the models and its corresponding base
40# directory
41default_model_name="fvp:fvp_arm_std_library_11.12_38"
42default_model_dir="/opt/model/FVP_ARM_Std_Library/models/Linux64_GCC-6.4"
43
44# This is intentionally black, so a the run config snippet MUST pass this the parameter
45# indicating the model's binary
46default_model_bin=""
47
Fathi Boudra422bf772019-12-02 11:10:16 +020048# FVP Kernel URLs
49declare -A fvp_kernels
50fvp_kernels=(
51[fvp-aarch32-zimage]="$linaro_release/fvp32-latest-busybox-uboot/Image"
52[fvp-busybox-uboot]="$linaro_release/fvp-latest-busybox-uboot/Image"
53[fvp-oe-uboot32]="$linaro_release/fvp32-latest-oe-uboot/Image"
54[fvp-oe-uboot]="$linaro_release/fvp-latest-oe-uboot/Image"
55[fvp-quad-busybox-uboot]="$tfa_downloads/quad_cluster/Image"
56)
57
Fathi Boudra422bf772019-12-02 11:10:16 +020058# FVP initrd URLs
59declare -A fvp_initrd_urls
60fvp_initrd_urls=(
61[aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img"
Fathi Boudra422bf772019-12-02 11:10:16 +020062[dummy-ramdisk]="$linaro_release/fvp-latest-oe-uboot/ramdisk.img"
63[dummy-ramdisk32]="$linaro_release/fvp32-latest-oe-uboot/ramdisk.img"
64[default]="$linaro_release/fvp-latest-busybox-uboot/ramdisk.img"
65)
66
Fathi Boudra422bf772019-12-02 11:10:16 +020067get_optee_bin() {
68 url="$jenkins_url/job/tf-optee-build/PLATFORM_FLAVOR=fvp,label=arch-dev/lastSuccessfulBuild/artifact/artefacts/tee.bin" \
Zelalem219df412020-05-17 19:21:20 -050069 saveas="bl32.bin" fetch_file
Fathi Boudra422bf772019-12-02 11:10:16 +020070 archive_file "bl32.bin"
71}
72
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +010073# For Measured Boot tests using a TA based on OPTEE, it is necessary to use a
74# specific build rather than the default one generated by Jenkins.
75get_ftpm_optee_bin() {
Javier Almansa Sobrinode647722020-10-08 19:17:44 +010076 url="$tfa_downloads/ftpm/optee/tee-header_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +010077 saveas="bl32.bin" fetch_file
78 archive_file "bl32.bin"
79
Javier Almansa Sobrinode647722020-10-08 19:17:44 +010080 url="$tfa_downloads/ftpm/optee/tee-pager_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +010081 saveas="bl32_extra1.bin" fetch_file
82 archive_file "bl32_extra1.bin"
83
Javier Almansa Sobrinode647722020-10-08 19:17:44 +010084 url="$tfa_downloads/ftpm/optee/tee-pageable_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +010085 saveas="bl32_extra2.bin" fetch_file
86 archive_file "bl32_extra2.bin"
87}
88
Fathi Boudra422bf772019-12-02 11:10:16 +020089get_uboot32_bin() {
90 local tmpdir="$(mktempdir)"
91
92 pushd "$tmpdir"
93 extract_fip "$uboot32_fip_url"
94 mv "nt-fw.bin" "uboot.bin"
95 archive_file "uboot.bin"
96 popd
97}
98
99get_uboot_bin() {
100 local uboot_url="$linaro_release/fvp-latest-busybox-uboot/bl33-uboot.bin"
101
102 url="$uboot_url" saveas="uboot.bin" fetch_file
103 archive_file "uboot.bin"
104}
105
106get_uefi_bin() {
Zelalem219df412020-05-17 19:21:20 -0500107 uefi_downloads="${uefi_downloads:-http://files.oss.arm.com/downloads/uefi}"
108 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 +0200109
110 url=$uefi_ci_bin_url saveas="uefi.bin" fetch_file
111 archive_file "uefi.bin"
112}
113
114get_kernel() {
115 local kernel_type="${kernel_type:?}"
116 local url="${fvp_kernels[$kernel_type]}"
117
118 url="${url:?}" saveas="kernel.bin" fetch_file
119 archive_file "kernel.bin"
120}
121
122get_initrd() {
123 local initrd_type="${initrd_type:?}"
124 local url="${fvp_initrd_urls[$initrd_type]}"
125
126 url="${url:?}" saveas="initrd.bin" fetch_file
127 archive_file "initrd.bin"
128}
129
130get_dtb() {
131 local dtb_type="${dtb_type:?}"
132 local dtb_url
133 local dtb_saveas="$workspace/dtb.bin"
Zelalem219df412020-05-17 19:21:20 -0500134 local cc="$(get_tf_opt CROSS_COMPILE)"
135 local pp_flags="-P -nostdinc -undef -x assembler-with-cpp"
Fathi Boudra422bf772019-12-02 11:10:16 +0200136
137 case "$dtb_type" in
138 "fvp-base-quad-cluster-gicv3-psci")
139 # Get the quad-cluster FDT from pdsw area
140 dtb_url="$tfa_downloads/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb"
141 url="$dtb_url" saveas="$dtb_saveas" fetch_file
142 ;;
143 "sgm775")
144 # Get the SGM775 FDT from pdsw area
145 dtb_url="$sgm_prebuilts/sgm775.dtb"
146 url="$dtb_url" saveas="$dtb_saveas" fetch_file
147 ;;
148 *)
Zelalem219df412020-05-17 19:21:20 -0500149 # Preprocess DTS file
150 ${cc}gcc -E ${pp_flags} -I"$tf_root/fdts" -I"$tf_root/include" \
151 -o "$workspace/${dtb_type}.pre.dts" \
152 "$tf_root/fdts/${dtb_type}.dts"
153 # Generate DTB file from DTS
Fathi Boudra422bf772019-12-02 11:10:16 +0200154 dtc -I dts -O dtb \
Zelalem219df412020-05-17 19:21:20 -0500155 "$workspace/${dtb_type}.pre.dts" -o "$dtb_saveas"
Fathi Boudra422bf772019-12-02 11:10:16 +0200156 esac
157
158 archive_file "$dtb_saveas"
159}
160
161get_rootfs() {
162 local tmpdir
163 local fs_base="$(echo $(basename $rootfs_url) | sed 's/\.gz$//')"
164 local cached="$project_filer/ci-files/$fs_base"
165
166 if upon "$jenkins_run" && [ -f "$cached" ]; then
167 # Job workspace is limited in size, and the root file system is
168 # quite large. This means, parallel runs of root file system
169 # tests could fail. So, for Jenkins runs, copy and use the root
170 # file system image from the $CI_SCRATCH location
171 local private="$CI_SCRATCH/$JOB_NAME-$BUILD_NUMBER"
172 mkdir -p "$private"
173 rm -f "$private/rootfs.bin"
174 url="$cached" saveas="$private/rootfs.bin" fetch_file
175 ln -s "$private/rootfs.bin" "$archive/rootfs.bin"
176 return
177 fi
178
179 tmpdir="$(mktempdir)"
180 pushd "$tmpdir"
181 url="$rootfs_url" saveas="rootfs.bin" fetch_file
182
183 # Possibly, the filesystem image we just downloaded is compressed.
184 # Decompress it if required.
185 if file "rootfs.bin" | grep -iq 'gzip compressed data'; then
186 echo "Decompressing root file system image rootfs.bin ..."
187 gunzip --stdout "rootfs.bin" > uncompressed_fs.bin
188 mv uncompressed_fs.bin "rootfs.bin"
189 fi
190
191 archive_file "rootfs.bin"
192 popd
193}
194
Zelalem219df412020-05-17 19:21:20 -0500195fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i"
196
Fathi Boudra422bf772019-12-02 11:10:16 +0200197fvp_romlib_runtime() {
198 local tmpdir="$(mktempdir)"
199
200 # Save BL1 and romlib binaries from original build
201 mv "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" "$tmpdir/romlib.bin"
202 mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin"
203
204 # Patch index file
Zelalem219df412020-05-17 19:21:20 -0500205 cp "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" "$fvp_romlib_jmptbl_backup"
206 sed -i '/fdt/ s/.$/&\ patch/' ${tf_root:?}/plat/arm/board/fvp/jmptbl.i
Fathi Boudra422bf772019-12-02 11:10:16 +0200207
208 # Rebuild with patched file
209 echo "Building patched romlib:"
210 build_tf
211
Fathi Boudra422bf772019-12-02 11:10:16 +0200212 # Retrieve original BL1 and romlib binaries
213 mv "$tmpdir/romlib.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin"
214 mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin"
215}
216
Zelalem219df412020-05-17 19:21:20 -0500217fvp_romlib_cleanup() {
218 # Restore original index
219 mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
220}
221
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500222
223fvp_gen_bin_url() {
224 local bin_mode="${bin_mode:?}"
225 local bin="${1:?}"
226
227 if upon "$jenkins_run"; then
228 echo "$jenkins_url/job/$JOB_NAME/$BUILD_NUMBER/artifact/artefacts/$bin_mode/$bin"
229 else
230 echo "file://$workspace/artefacts/$bin_mode/$bin"
231 fi
232}
233
234gen_fvp_yaml_template() {
235 local yaml_template_file="$workspace/fvp_template.yaml"
236
237 # must parameters for yaml generation
238 local payload_type="${payload_type:?}"
239
240 "$ci_root/script/gen_fvp_${payload_type}_yaml.sh" > "$yaml_template_file"
241
242 archive_file "$yaml_template_file"
243}
244
245gen_fvp_yaml() {
246 local yaml_template_file="$workspace/fvp_template.yaml"
247 local yaml_file="$workspace/fvp.yaml"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500248 local yaml_job_file="$workspace/job.yaml"
249 local lava_model_params="$workspace/lava_model_params"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500250
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500251 # this function expects a template, quit if it is not present
252 if [ ! -f "$yaml_template_file" ]; then
253 return
254 fi
255
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500256 # must parameters for yaml generation
257 local model="${model:?}"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500258
259 # optional parameters, defaults to globals
260 local model_name="${model_name:-$default_model_name}"
261 local model_dtb="${model_dtb:-$default_model_dtb}"
262 local model_dir="${model_dir:-$default_model_dir}"
263 local model_bin="${model_bin:-$default_model_bin}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500264
265 # general artefacts
266 bl1="$(fvp_gen_bin_url bl1.bin)"
267 fip="$(fvp_gen_bin_url fip.bin)"
268
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500269 dtb="$(fvp_gen_bin_url ${model_dtb})"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500270 image="$(fvp_gen_bin_url kernel.bin)"
271 ramdisk="$(fvp_gen_bin_url initrd.bin)"
272
Leonardo Sandoval44ac9aa2020-11-09 12:55:57 -0600273 # tftf's ns_bl[1|2]u.bin and el3_payload artefacts
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500274 ns_bl1u="$(fvp_gen_bin_url ns_bl1u.bin)"
275 ns_bl2u="$(fvp_gen_bin_url ns_bl2u.bin)"
Leonardo Sandoval44ac9aa2020-11-09 12:55:57 -0600276 el3_payload="$(fvp_gen_bin_url el3_payload.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500277
278 docker_registry="${docker_registry:-}"
279 docker_registry="$(docker_registry_append)"
280
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500281 docker_name="${docker_registry}$model_name"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500282
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500283 # generic version string
284 local version_string="\"Fast Models"' [^\\n]+'"\""
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500285
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500286 sed -e "s|\${ARMLMD_LICENSE_FILE}|${armlmd_license_file}|" \
287 -e "s|\${ACTIONS_DEPLOY_IMAGES_BL1}|${bl1}|" \
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500288 -e "s|\${ACTIONS_DEPLOY_IMAGES_FIP}|${fip}|" \
289 -e "s|\${ACTIONS_DEPLOY_IMAGES_DTB}|${dtb}|" \
290 -e "s|\${ACTIONS_DEPLOY_IMAGES_IMAGE}|${image}|" \
291 -e "s|\${ACTIONS_DEPLOY_IMAGES_RAMDISK}|${ramdisk}|" \
292 -e "s|\${ACTIONS_DEPLOY_IMAGES_NS_BL1U}|${ns_bl1u}|" \
293 -e "s|\${ACTIONS_DEPLOY_IMAGES_NS_BL2U}|${ns_bl2u}|" \
Leonardo Sandoval44ac9aa2020-11-09 12:55:57 -0600294 -e "s|\${ACTIONS_DEPLOY_IMAGES_EL3_PAYLOAD}|${el3_payload}|" \
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500295 -e "s|\${BOOT_DOCKER_NAME}|${docker_name}|" \
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500296 -e "s|\${BOOT_IMAGE_DIR}|${model_dir}|" \
297 -e "s|\${BOOT_IMAGE_BIN}|${model_bin}|" \
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500298 -e "s|\${BOOT_VERSION_STRING}|${version_string}|" \
299 < "$yaml_template_file" \
300 > "$yaml_file"
301
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500302 # LAVA expects 'macro' names for binaries, so replace them
303 sed -e "s|bl1.bin|{BL1}|" \
304 -e "s|fip.bin|{FIP}|" \
Leonardo Sandoval44ac9aa2020-11-09 12:55:57 -0600305 -e "s|ns_bl1u.bin|{NS_BL1U}|" \
306 -e "s|ns_bl2u.bin|{NS_BL2U}|" \
307 -e "s|el3_payload.bin|{EL3_PAYLOAD}|" \
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500308 -e "s|kernel.bin|{IMAGE}|" \
309 -e "s|initrd.bin|{RAMDISK}|" \
310 < "$archive/model_params" \
311 > "$lava_model_params"
312
313
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500314 # include the model parameters
315 while read -r line; do
316 if [ -n "$line" ]; then
317 yaml_line="- \"${line}\""
318 sed -i -e "/\${BOOT_ARGUMENTS}/i \ \ \ \ $yaml_line" "$yaml_file"
319 fi
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500320 done < "$lava_model_params"
321
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500322 sed -i -e '/\${BOOT_ARGUMENTS}/d' "$yaml_file"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500323 cp "$yaml_file" "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500324
325 archive_file "$yaml_file"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500326 archive_file "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500327}
328
329docker_registry_append() {
330 # if docker_registry is empty, just use local docker registry
331 [ -z "$docker_registry" ] && return
332
333 local last=-1
334 local last_char="${docker_registry:last}"
335
336 if [ "$last_char" != '/' ]; then
337 docker_registry="${docker_registry}/";
338 fi
339 echo "$docker_registry"
340}
341
Fathi Boudra422bf772019-12-02 11:10:16 +0200342set +u