blob: 5fb2ae379e1b01389e1ec6d408f8b32b18dade24 [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
36# FVP Kernel URLs
37declare -A fvp_kernels
38fvp_kernels=(
39[fvp-aarch32-zimage]="$linaro_release/fvp32-latest-busybox-uboot/Image"
40[fvp-busybox-uboot]="$linaro_release/fvp-latest-busybox-uboot/Image"
41[fvp-oe-uboot32]="$linaro_release/fvp32-latest-oe-uboot/Image"
42[fvp-oe-uboot]="$linaro_release/fvp-latest-oe-uboot/Image"
43[fvp-quad-busybox-uboot]="$tfa_downloads/quad_cluster/Image"
44)
45
Fathi Boudra422bf772019-12-02 11:10:16 +020046# FVP initrd URLs
47declare -A fvp_initrd_urls
48fvp_initrd_urls=(
49[aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img"
Fathi Boudra422bf772019-12-02 11:10:16 +020050[dummy-ramdisk]="$linaro_release/fvp-latest-oe-uboot/ramdisk.img"
51[dummy-ramdisk32]="$linaro_release/fvp32-latest-oe-uboot/ramdisk.img"
52[default]="$linaro_release/fvp-latest-busybox-uboot/ramdisk.img"
53)
54
Fathi Boudra422bf772019-12-02 11:10:16 +020055get_optee_bin() {
56 url="$jenkins_url/job/tf-optee-build/PLATFORM_FLAVOR=fvp,label=arch-dev/lastSuccessfulBuild/artifact/artefacts/tee.bin" \
Zelalem219df412020-05-17 19:21:20 -050057 saveas="bl32.bin" fetch_file
Fathi Boudra422bf772019-12-02 11:10:16 +020058 archive_file "bl32.bin"
59}
60
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +010061# For Measured Boot tests using a TA based on OPTEE, it is necessary to use a
62# specific build rather than the default one generated by Jenkins.
63get_ftpm_optee_bin() {
Javier Almansa Sobrinode647722020-10-08 19:17:44 +010064 url="$tfa_downloads/ftpm/optee/tee-header_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +010065 saveas="bl32.bin" fetch_file
66 archive_file "bl32.bin"
67
Javier Almansa Sobrinode647722020-10-08 19:17:44 +010068 url="$tfa_downloads/ftpm/optee/tee-pager_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +010069 saveas="bl32_extra1.bin" fetch_file
70 archive_file "bl32_extra1.bin"
71
Javier Almansa Sobrinode647722020-10-08 19:17:44 +010072 url="$tfa_downloads/ftpm/optee/tee-pageable_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +010073 saveas="bl32_extra2.bin" fetch_file
74 archive_file "bl32_extra2.bin"
75}
76
Fathi Boudra422bf772019-12-02 11:10:16 +020077get_uboot32_bin() {
78 local tmpdir="$(mktempdir)"
79
80 pushd "$tmpdir"
81 extract_fip "$uboot32_fip_url"
82 mv "nt-fw.bin" "uboot.bin"
83 archive_file "uboot.bin"
84 popd
85}
86
87get_uboot_bin() {
88 local uboot_url="$linaro_release/fvp-latest-busybox-uboot/bl33-uboot.bin"
89
90 url="$uboot_url" saveas="uboot.bin" fetch_file
91 archive_file "uboot.bin"
92}
93
94get_uefi_bin() {
Zelalem219df412020-05-17 19:21:20 -050095 uefi_downloads="${uefi_downloads:-http://files.oss.arm.com/downloads/uefi}"
96 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 +020097
98 url=$uefi_ci_bin_url saveas="uefi.bin" fetch_file
99 archive_file "uefi.bin"
100}
101
102get_kernel() {
103 local kernel_type="${kernel_type:?}"
104 local url="${fvp_kernels[$kernel_type]}"
105
106 url="${url:?}" saveas="kernel.bin" fetch_file
107 archive_file "kernel.bin"
108}
109
110get_initrd() {
111 local initrd_type="${initrd_type:?}"
112 local url="${fvp_initrd_urls[$initrd_type]}"
113
114 url="${url:?}" saveas="initrd.bin" fetch_file
115 archive_file "initrd.bin"
116}
117
118get_dtb() {
119 local dtb_type="${dtb_type:?}"
120 local dtb_url
121 local dtb_saveas="$workspace/dtb.bin"
Zelalem219df412020-05-17 19:21:20 -0500122 local cc="$(get_tf_opt CROSS_COMPILE)"
123 local pp_flags="-P -nostdinc -undef -x assembler-with-cpp"
Fathi Boudra422bf772019-12-02 11:10:16 +0200124
125 case "$dtb_type" in
126 "fvp-base-quad-cluster-gicv3-psci")
127 # Get the quad-cluster FDT from pdsw area
128 dtb_url="$tfa_downloads/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb"
129 url="$dtb_url" saveas="$dtb_saveas" fetch_file
130 ;;
131 "sgm775")
132 # Get the SGM775 FDT from pdsw area
133 dtb_url="$sgm_prebuilts/sgm775.dtb"
134 url="$dtb_url" saveas="$dtb_saveas" fetch_file
135 ;;
136 *)
Zelalem219df412020-05-17 19:21:20 -0500137 # Preprocess DTS file
138 ${cc}gcc -E ${pp_flags} -I"$tf_root/fdts" -I"$tf_root/include" \
139 -o "$workspace/${dtb_type}.pre.dts" \
140 "$tf_root/fdts/${dtb_type}.dts"
141 # Generate DTB file from DTS
Fathi Boudra422bf772019-12-02 11:10:16 +0200142 dtc -I dts -O dtb \
Zelalem219df412020-05-17 19:21:20 -0500143 "$workspace/${dtb_type}.pre.dts" -o "$dtb_saveas"
Fathi Boudra422bf772019-12-02 11:10:16 +0200144 esac
145
146 archive_file "$dtb_saveas"
147}
148
149get_rootfs() {
150 local tmpdir
151 local fs_base="$(echo $(basename $rootfs_url) | sed 's/\.gz$//')"
152 local cached="$project_filer/ci-files/$fs_base"
153
154 if upon "$jenkins_run" && [ -f "$cached" ]; then
155 # Job workspace is limited in size, and the root file system is
156 # quite large. This means, parallel runs of root file system
157 # tests could fail. So, for Jenkins runs, copy and use the root
158 # file system image from the $CI_SCRATCH location
159 local private="$CI_SCRATCH/$JOB_NAME-$BUILD_NUMBER"
160 mkdir -p "$private"
161 rm -f "$private/rootfs.bin"
162 url="$cached" saveas="$private/rootfs.bin" fetch_file
163 ln -s "$private/rootfs.bin" "$archive/rootfs.bin"
164 return
165 fi
166
167 tmpdir="$(mktempdir)"
168 pushd "$tmpdir"
169 url="$rootfs_url" saveas="rootfs.bin" fetch_file
170
171 # Possibly, the filesystem image we just downloaded is compressed.
172 # Decompress it if required.
173 if file "rootfs.bin" | grep -iq 'gzip compressed data'; then
174 echo "Decompressing root file system image rootfs.bin ..."
175 gunzip --stdout "rootfs.bin" > uncompressed_fs.bin
176 mv uncompressed_fs.bin "rootfs.bin"
177 fi
178
179 archive_file "rootfs.bin"
180 popd
181}
182
Zelalem219df412020-05-17 19:21:20 -0500183fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i"
184
Fathi Boudra422bf772019-12-02 11:10:16 +0200185fvp_romlib_runtime() {
186 local tmpdir="$(mktempdir)"
187
188 # Save BL1 and romlib binaries from original build
189 mv "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" "$tmpdir/romlib.bin"
190 mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin"
191
192 # Patch index file
Zelalem219df412020-05-17 19:21:20 -0500193 cp "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" "$fvp_romlib_jmptbl_backup"
194 sed -i '/fdt/ s/.$/&\ patch/' ${tf_root:?}/plat/arm/board/fvp/jmptbl.i
Fathi Boudra422bf772019-12-02 11:10:16 +0200195
196 # Rebuild with patched file
197 echo "Building patched romlib:"
198 build_tf
199
Fathi Boudra422bf772019-12-02 11:10:16 +0200200 # Retrieve original BL1 and romlib binaries
201 mv "$tmpdir/romlib.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin"
202 mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin"
203}
204
Zelalem219df412020-05-17 19:21:20 -0500205fvp_romlib_cleanup() {
206 # Restore original index
207 mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
208}
209
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500210
211fvp_gen_bin_url() {
212 local bin_mode="${bin_mode:?}"
213 local bin="${1:?}"
214
215 if upon "$jenkins_run"; then
216 echo "$jenkins_url/job/$JOB_NAME/$BUILD_NUMBER/artifact/artefacts/$bin_mode/$bin"
217 else
218 echo "file://$workspace/artefacts/$bin_mode/$bin"
219 fi
220}
221
222gen_fvp_yaml_template() {
223 local yaml_template_file="$workspace/fvp_template.yaml"
224
225 # must parameters for yaml generation
226 local payload_type="${payload_type:?}"
227
228 "$ci_root/script/gen_fvp_${payload_type}_yaml.sh" > "$yaml_template_file"
229
230 archive_file "$yaml_template_file"
231}
232
233gen_fvp_yaml() {
234 local yaml_template_file="$workspace/fvp_template.yaml"
235 local yaml_file="$workspace/fvp.yaml"
236
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500237 # this function expects a template, quit if it is not present
238 if [ ! -f "$yaml_template_file" ]; then
239 return
240 fi
241
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500242 # must parameters for yaml generation
243 local model="${model:?}"
244 local dtb="${dtb:?}"
245 local container_name="${container_name:?}"
246 local container_model_params="${container_model_params:?}"
247 local container_entrypoint="${container_entrypoint:?}"
248 local archive="${archive:?}"
249
250 # general artefacts
251 bl1="$(fvp_gen_bin_url bl1.bin)"
252 fip="$(fvp_gen_bin_url fip.bin)"
253
254 # linux artefacts
255 dtb="$(fvp_gen_bin_url $dtb)"
256 image="$(fvp_gen_bin_url kernel.bin)"
257 ramdisk="$(fvp_gen_bin_url initrd.bin)"
258
259 # tftf's ns_bl[1|2]u.bin artefacts
260 ns_bl1u="$(fvp_gen_bin_url ns_bl1u.bin)"
261 ns_bl2u="$(fvp_gen_bin_url ns_bl2u.bin)"
262
263 docker_registry="${docker_registry:-}"
264 docker_registry="$(docker_registry_append)"
265
266 docker_name="${docker_registry}$container_name"
267
268 version_string="\"ARM ${model}"' [^\\n]+'"\""
269
270 sed -e "s|\${ACTIONS_DEPLOY_IMAGES_BL1}|${bl1}|" \
271 -e "s|\${ACTIONS_DEPLOY_IMAGES_FIP}|${fip}|" \
272 -e "s|\${ACTIONS_DEPLOY_IMAGES_DTB}|${dtb}|" \
273 -e "s|\${ACTIONS_DEPLOY_IMAGES_IMAGE}|${image}|" \
274 -e "s|\${ACTIONS_DEPLOY_IMAGES_RAMDISK}|${ramdisk}|" \
275 -e "s|\${ACTIONS_DEPLOY_IMAGES_NS_BL1U}|${ns_bl1u}|" \
276 -e "s|\${ACTIONS_DEPLOY_IMAGES_NS_BL2U}|${ns_bl2u}|" \
277 -e "s|\${BOOT_DOCKER_NAME}|${docker_name}|" \
278 -e "s|\${BOOT_IMAGE}|${container_entrypoint}|" \
279 -e "s|\${BOOT_VERSION_STRING}|${version_string}|" \
280 < "$yaml_template_file" \
281 > "$yaml_file"
282
283 # include the model parameters
284 while read -r line; do
285 if [ -n "$line" ]; then
286 yaml_line="- \"${line}\""
287 sed -i -e "/\${BOOT_ARGUMENTS}/i \ \ \ \ $yaml_line" "$yaml_file"
288 fi
289 done < "$archive/model_params"
290 sed -i -e '/\${BOOT_ARGUMENTS}/d' "$yaml_file"
291
292 archive_file "$yaml_file"
293}
294
295docker_registry_append() {
296 # if docker_registry is empty, just use local docker registry
297 [ -z "$docker_registry" ] && return
298
299 local last=-1
300 local last_char="${docker_registry:last}"
301
302 if [ "$last_char" != '/' ]; then
303 docker_registry="${docker_registry}/";
304 fi
305 echo "$docker_registry"
306}
307
Fathi Boudra422bf772019-12-02 11:10:16 +0200308set +u