blob: 6c7f2e9ce7b539278e4b9027b40529040063fe8c [file] [log] [blame]
Leonardo Sandoval9dfdd1b2020-08-06 17:08:11 -05001#!/usr/bin/env bash
Fathi Boudra422bf772019-12-02 11:10:16 +02002#
Rupinderjit Singh385f17d2022-07-18 20:28:10 +01003# Copyright (c) 2020-2022, 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}"
Maksims Svecovs284a50d2021-11-02 11:09:47 +000045fvp_arm_std_library="fvp:fvp_arm_std_library_${model_version}_${model_build};/opt/model/FVP_ARM_Std_Library/FVP_Base"
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}"
johpow01936638d2021-11-08 18:22:24 -060048fvp_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 -050049
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060050# FVP associate array, run_config are keys and fvp container parameters are the values
51# Container parameters syntax: <model name>;<model dir>;<model bin>
52# FIXMEs: fix those ;;; values with real values
53
54declare -A fvp_models
55fvp_models=(
56[base-aemv8a-quad]=";;;"
57[base-aemv8a-revb]=";;;"
58[base-aemv8a-latest-revb]=";;;"
59[base-aemva]=";;;"
Manish V Badarkhee4783832021-02-22 14:36:56 +000060[base-aemv8a-gic600ae]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060061[foundationv8]="${foundation_platform};Foundation_Platform"
laurenw-armf414aba2021-04-26 15:58:56 -050062[base-aemv8a]="${fvp_base_revc_2xaemva};FVP_Base_RevC-2xAEMvA"
johpow01936638d2021-11-08 18:22:24 -060063[baser-aemv8r]=";;;"
laurenw-arm35faeaa2021-05-03 14:28:17 -050064[cortex-a32x4]="${fvp_arm_std_library_11_12};FVP_Base_Cortex-A32x4"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060065[cortex-a35x4]="${fvp_arm_std_library};FVP_Base_Cortex-A35x4"
66[cortex-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A53x4"
Leonardo Sandoval95f896b2021-02-22 10:16:29 -060067[cortex-a55x4-a75x4]="${fvp_arm_std_library};FVP_Base_Cortex-A55x4+Cortex-A75x4"
68[cortex-a55x4-a76x2]="${fvp_arm_std_library};FVP_Base_Cortex-A55x4+Cortex-A76x2"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060069[cortex-a57x1-a53x1]="${fvp_arm_std_library};FVP_Base_Cortex-A57x1-A53x1"
70[cortex-a57x2-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x2-A53x4"
71[cortex-a57x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4"
72[cortex-a57x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4-A53x4"
73[cortex-a65aex8]="${fvp_arm_std_library};FVP_Base_Cortex-A65AEx8"
74[cortex-a65x4]="${fvp_arm_std_library};FVP_Base_Cortex-A65x4"
75[cortex-a72x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72x4"
76[cortex-a72x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72x4-A53x4"
77[cortex-a73x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4"
78[cortex-a73x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4-A53x4"
79[cortex-a75x4]="${fvp_arm_std_library};FVP_Base_Cortex-A75x4"
80[cortex-a76aex4]="${fvp_arm_std_library};FVP_Base_Cortex-A76AEx4"
81[cortex-a76aex2]="${fvp_arm_std_library};FVP_Base_Cortex-A76AEx2"
82[cortex-a76x4]="${fvp_arm_std_library};FVP_Base_Cortex-A76x4"
83[cortex-a77x4]="${fvp_arm_std_library};FVP_Base_Cortex-A77x4"
84[cortex-a78x4]="${fvp_arm_std_library};FVP_Base_Cortex-A78x4"
laurenw-arm06c4a192022-07-12 14:55:28 -050085[cortex-a78cx4]="${fvp_arm_std_library};FVP_Base_Cortex-A78Cx4"
johpow011008edc2022-02-01 18:50:33 -060086[cortex-x2]="${fvp_arm_std_library};FVP_Base_Cortex-X2x4"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060087[neoverse_e1x1]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x1"
88[neoverse_e1x2]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x2"
89[neoverse_e1x4]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x4"
Leonardo Sandoval54f1ade2021-06-26 19:20:48 -050090[neoverse_n1]="${fvp_arm_std_library};FVP_Base_Neoverse-N1x4"
Maksims Svecovsd10c1b92021-10-06 10:25:40 +010091[neoverse_n2]="${fvp_arm_std_library_11_12};FVP_Base_Neoverse-N1x4"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060092[neoverse-v1x4]=";;;"
Manish V Badarkhecbed15e2021-07-02 09:34:53 +010093[cortexa710x4]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060094[css-rdv1]=";;;"
95[css-rde1edge]=";;;"
96[css-rdn1edge]=";;;"
97[css-rdn1edgex2]=";;;"
98[css-sgi575]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060099[tc0]=";;;"
Usama Arifcba711d2021-08-04 15:53:42 +0100100[tc1]=";;;"
Rupinderjit Singh385f17d2022-07-18 20:28:10 +0100101[tc2]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600102)
103
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500104
Fathi Boudra422bf772019-12-02 11:10:16 +0200105# FVP Kernel URLs
106declare -A fvp_kernels
107fvp_kernels=(
108[fvp-aarch32-zimage]="$linaro_release/fvp32-latest-busybox-uboot/Image"
109[fvp-busybox-uboot]="$linaro_release/fvp-latest-busybox-uboot/Image"
110[fvp-oe-uboot32]="$linaro_release/fvp32-latest-oe-uboot/Image"
111[fvp-oe-uboot]="$linaro_release/fvp-latest-oe-uboot/Image"
112[fvp-quad-busybox-uboot]="$tfa_downloads/quad_cluster/Image"
113)
114
Fathi Boudra422bf772019-12-02 11:10:16 +0200115# FVP initrd URLs
116declare -A fvp_initrd_urls
117fvp_initrd_urls=(
118[aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img"
Fathi Boudra422bf772019-12-02 11:10:16 +0200119[dummy-ramdisk]="$linaro_release/fvp-latest-oe-uboot/ramdisk.img"
120[dummy-ramdisk32]="$linaro_release/fvp32-latest-oe-uboot/ramdisk.img"
121[default]="$linaro_release/fvp-latest-busybox-uboot/ramdisk.img"
122)
123
Fathi Boudra422bf772019-12-02 11:10:16 +0200124get_optee_bin() {
Sandrine Bailleux25ff2942021-02-25 14:00:10 +0100125 url="$tfa_downloads/optee/tee.bin" \
126 saveas="bl32.bin" fetch_file
Fathi Boudra422bf772019-12-02 11:10:16 +0200127 archive_file "bl32.bin"
128}
129
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100130# For Measured Boot tests using a TA based on OPTEE, it is necessary to use a
131# specific build rather than the default one generated by Jenkins.
132get_ftpm_optee_bin() {
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100133 url="$tfa_downloads/ftpm/optee/tee-header_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100134 saveas="bl32.bin" fetch_file
135 archive_file "bl32.bin"
136
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100137 url="$tfa_downloads/ftpm/optee/tee-pager_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100138 saveas="bl32_extra1.bin" fetch_file
139 archive_file "bl32_extra1.bin"
140
Leonardo Sandovalda5f78d2021-03-18 11:09:30 -0600141 # tee-pageable_v2.bin is just a empty file, named as bl32_extra2.bin,
142 # so just create the file
143 touch "bl32_extra2.bin"
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100144 archive_file "bl32_extra2.bin"
145}
146
Fathi Boudra422bf772019-12-02 11:10:16 +0200147get_uboot32_bin() {
148 local tmpdir="$(mktempdir)"
149
150 pushd "$tmpdir"
151 extract_fip "$uboot32_fip_url"
152 mv "nt-fw.bin" "uboot.bin"
153 archive_file "uboot.bin"
154 popd
155}
156
157get_uboot_bin() {
158 local uboot_url="$linaro_release/fvp-latest-busybox-uboot/bl33-uboot.bin"
159
160 url="$uboot_url" saveas="uboot.bin" fetch_file
161 archive_file "uboot.bin"
162}
163
164get_uefi_bin() {
Zelalem219df412020-05-17 19:21:20 -0500165 uefi_downloads="${uefi_downloads:-http://files.oss.arm.com/downloads/uefi}"
166 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 +0200167
168 url=$uefi_ci_bin_url saveas="uefi.bin" fetch_file
169 archive_file "uefi.bin"
170}
171
172get_kernel() {
173 local kernel_type="${kernel_type:?}"
174 local url="${fvp_kernels[$kernel_type]}"
175
176 url="${url:?}" saveas="kernel.bin" fetch_file
177 archive_file "kernel.bin"
178}
179
180get_initrd() {
181 local initrd_type="${initrd_type:?}"
182 local url="${fvp_initrd_urls[$initrd_type]}"
183
184 url="${url:?}" saveas="initrd.bin" fetch_file
185 archive_file "initrd.bin"
186}
187
188get_dtb() {
189 local dtb_type="${dtb_type:?}"
190 local dtb_url
191 local dtb_saveas="$workspace/dtb.bin"
Zelalem219df412020-05-17 19:21:20 -0500192 local cc="$(get_tf_opt CROSS_COMPILE)"
193 local pp_flags="-P -nostdinc -undef -x assembler-with-cpp"
Fathi Boudra422bf772019-12-02 11:10:16 +0200194
195 case "$dtb_type" in
196 "fvp-base-quad-cluster-gicv3-psci")
197 # Get the quad-cluster FDT from pdsw area
198 dtb_url="$tfa_downloads/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb"
199 url="$dtb_url" saveas="$dtb_saveas" fetch_file
200 ;;
Fathi Boudra422bf772019-12-02 11:10:16 +0200201 *)
Zelalem219df412020-05-17 19:21:20 -0500202 # Preprocess DTS file
203 ${cc}gcc -E ${pp_flags} -I"$tf_root/fdts" -I"$tf_root/include" \
204 -o "$workspace/${dtb_type}.pre.dts" \
205 "$tf_root/fdts/${dtb_type}.dts"
206 # Generate DTB file from DTS
Fathi Boudra422bf772019-12-02 11:10:16 +0200207 dtc -I dts -O dtb \
Zelalem219df412020-05-17 19:21:20 -0500208 "$workspace/${dtb_type}.pre.dts" -o "$dtb_saveas"
Fathi Boudra422bf772019-12-02 11:10:16 +0200209 esac
210
211 archive_file "$dtb_saveas"
212}
213
214get_rootfs() {
215 local tmpdir
216 local fs_base="$(echo $(basename $rootfs_url) | sed 's/\.gz$//')"
217 local cached="$project_filer/ci-files/$fs_base"
218
219 if upon "$jenkins_run" && [ -f "$cached" ]; then
220 # Job workspace is limited in size, and the root file system is
221 # quite large. This means, parallel runs of root file system
222 # tests could fail. So, for Jenkins runs, copy and use the root
223 # file system image from the $CI_SCRATCH location
224 local private="$CI_SCRATCH/$JOB_NAME-$BUILD_NUMBER"
225 mkdir -p "$private"
226 rm -f "$private/rootfs.bin"
227 url="$cached" saveas="$private/rootfs.bin" fetch_file
228 ln -s "$private/rootfs.bin" "$archive/rootfs.bin"
229 return
230 fi
231
232 tmpdir="$(mktempdir)"
233 pushd "$tmpdir"
234 url="$rootfs_url" saveas="rootfs.bin" fetch_file
235
236 # Possibly, the filesystem image we just downloaded is compressed.
237 # Decompress it if required.
238 if file "rootfs.bin" | grep -iq 'gzip compressed data'; then
239 echo "Decompressing root file system image rootfs.bin ..."
240 gunzip --stdout "rootfs.bin" > uncompressed_fs.bin
241 mv uncompressed_fs.bin "rootfs.bin"
242 fi
243
244 archive_file "rootfs.bin"
245 popd
246}
247
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200248fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i"
249
Fathi Boudra422bf772019-12-02 11:10:16 +0200250fvp_romlib_runtime() {
251 local tmpdir="$(mktempdir)"
252
253 # Save BL1 and romlib binaries from original build
254 mv "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" "$tmpdir/romlib.bin"
255 mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin"
256
257 # Patch index file
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200258 cp "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" "$fvp_romlib_jmptbl_backup"
259 sed -i '/fdt/ s/.$/&\ patch/' ${tf_root:?}/plat/arm/board/fvp/jmptbl.i
Fathi Boudra422bf772019-12-02 11:10:16 +0200260
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200261 # Rebuild with patched file
262 echo "Building patched romlib:"
263 build_tf
Fathi Boudra422bf772019-12-02 11:10:16 +0200264
Fathi Boudra422bf772019-12-02 11:10:16 +0200265 # Retrieve original BL1 and romlib binaries
266 mv "$tmpdir/romlib.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin"
267 mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin"
268}
269
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200270fvp_romlib_cleanup() {
271 # Restore original index
272 mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
273}
274
275
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500276fvp_gen_bin_url() {
277 local bin_mode="${bin_mode:?}"
278 local bin="${1:?}"
279
280 if upon "$jenkins_run"; then
281 echo "$jenkins_url/job/$JOB_NAME/$BUILD_NUMBER/artifact/artefacts/$bin_mode/$bin"
282 else
283 echo "file://$workspace/artefacts/$bin_mode/$bin"
284 fi
285}
286
Chris Kayfbbf1322022-10-05 13:13:32 +0100287# Generates the template for YAML-based LAVA job definitions from a file
288# corresponding to the currently-selected payload, e.g.:
289#
290# - `lava-templates/fvp-linux.yaml`
291# - `lava-templates/fvp-tftf.yaml`
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500292gen_fvp_yaml_template() {
Chris Kayfbbf1322022-10-05 13:13:32 +0100293 local yaml_template_file="${workspace}/fvp_template.yaml"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500294
Chris Kayc9523b12022-10-10 18:32:20 +0100295 cp "${ci_root}/script/lava-templates/fvp-${payload_type:?}.yaml" \
296 "${yaml_template_file}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500297
Chris Kayfbbf1322022-10-05 13:13:32 +0100298 archive_file "${yaml_template_file}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500299}
300
Chris Kayc9523b12022-10-10 18:32:20 +0100301# Generates the final YAML-based LAVA job definition from a template file.
302#
303# The job definition template is expanded with visibility of all variables that
304# are available from within the function, including those with local scope.
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500305gen_fvp_yaml() {
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600306 local model="${model:?}"
307
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500308 local yaml_template_file="$workspace/fvp_template.yaml"
309 local yaml_file="$workspace/fvp.yaml"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500310 local yaml_job_file="$workspace/job.yaml"
311 local lava_model_params="$workspace/lava_model_params"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500312
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500313 # this function expects a template, quit if it is not present
314 if [ ! -f "$yaml_template_file" ]; then
315 return
316 fi
317
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600318 local model_params="${fvp_models[$model]}"
319 local model_name="$(echo "${model_params}" | awk -F ';' '{print $1}')"
320 local model_dir="$(echo "${model_params}" | awk -F ';' '{print $2}')"
321 local model_bin="$(echo "${model_params}" | awk -F ';' '{print $3}')"
322
323 # model params are required for correct yaml creation, quit if empty
324 if [ -z "${model_name}" ]; then
325 echo "FVP model param 'model_name' variable empty, yaml not produced"
326 return
327 elif [ -z "${model_dir}" ]; then
328 echo "FVP model param 'model_dir' variable empty, yaml not produced"
329 return
330 elif [ -z "${model_bin}" ]; then
331 echo "FVP model param 'model_bin' variable empty, yaml not produced"
332 return
333 fi
334
335 echo "FVP model params: model_name=$model_name model_dir=$model_dir model_bin=$model_bin"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500336
337 # optional parameters, defaults to globals
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500338 local model_dtb="${model_dtb:-$default_model_dtb}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500339
Chris Kayc9523b12022-10-10 18:32:20 +0100340 if [ -n "${GERRIT_CHANGE_NUMBER}" ]; then
341 local gerrit_url="https://review.trustedfirmware.org/c/${GERRIT_CHANGE_NUMBER}/${GERRIT_PATCHSET_NUMBER}"
342 elif [ -n "${GERRIT_REFSPEC}" ]; then
343 local gerrit_url=$(echo ${GERRIT_REFSPEC} |
344 awk -F/ '{print "https://review.trustedfirmware.org/c/" $4 "/" $5}')
345 fi
346
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600347 # possible artefacts
348 backup_fip="$(fvp_gen_bin_url backup_fip.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500349 bl1="$(fvp_gen_bin_url bl1.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600350 bl2="$(fvp_gen_bin_url bl2.bin)"
351 bl31="$(fvp_gen_bin_url bl31.bin)"
352 bl32="$(fvp_gen_bin_url bl32.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600353 busybox="$(fvp_gen_bin_url busybox.bin.gz)"
354 cactus_primary="$(fvp_gen_bin_url cactus-primary.pkg)"
355 cactus_secondary="$(fvp_gen_bin_url cactus-secondary.pkg)"
356 cactus_tertiary="$(fvp_gen_bin_url cactus-tertiary.pkg)"
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500357 coverage_trace_plugin="${coverage_trace_plugin}"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500358 dtb="$(fvp_gen_bin_url ${model_dtb})"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600359 el3_payload="$(fvp_gen_bin_url el3_payload.bin)"
360 fip="$(fvp_gen_bin_url fip.bin)"
Leonardo Sandovalcc52beb2021-05-05 19:05:31 -0500361 fip_gpt="$(fvp_gen_bin_url fip_gpt.bin)"
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600362 fvp_spmc_manifest_dtb="$(fvp_gen_bin_url fvp_spmc_manifest.dtb)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600363 fwu_fip="$(fvp_gen_bin_url fwu_fip.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600364 generic_trace="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/GenericTrace.so"
365 hafnium="$(fvp_gen_bin_url hafnium.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500366 image="$(fvp_gen_bin_url kernel.bin)"
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600367 ivy="$(fvp_gen_bin_url ivy.pkg)"
368 manifest_dtb="$(fvp_gen_bin_url manifest.dtb)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600369 mcp_rom="$(fvp_gen_bin_url mcp_rom.bin)"
370 mcp_rom_hyphen="$(fvp_gen_bin_url mcp-rom.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500371 ns_bl1u="$(fvp_gen_bin_url ns_bl1u.bin)"
372 ns_bl2u="$(fvp_gen_bin_url ns_bl2u.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600373 ramdisk="$(fvp_gen_bin_url initrd.bin)"
374 romlib="$(fvp_gen_bin_url romlib.bin)"
375 rootfs="$(fvp_gen_bin_url rootfs.bin.gz)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600376 secure_hafnium="$(fvp_gen_bin_url secure_hafnium.bin)"
377 scp_ram="$(fvp_gen_bin_url scp_ram.bin)"
378 scp_ram_hyphen="$(fvp_gen_bin_url scp-ram.bin)"
379 scp_rom="$(fvp_gen_bin_url scp_rom.bin)"
380 scp_rom_hyphen="$(fvp_gen_bin_url scp-rom.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600381 spm="$(fvp_gen_bin_url spm.bin)"
382 tftf="$(fvp_gen_bin_url tftf.bin)"
383 tmp="$(fvp_gen_bin_url tmp.bin)"
384 uboot="$(fvp_gen_bin_url uboot.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500385
386 docker_registry="${docker_registry:-}"
387 docker_registry="$(docker_registry_append)"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500388 docker_name="${docker_registry}$model_name"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600389 prompt1='/ #'
390 prompt2='root@genericarmv8:~#'
391 version_string="\"Fast Models"' [^\\n]+'"\""
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500392
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500393 test_config="${TEST_CONFIG}"
394
Chris Kay4eb9ded2022-10-10 15:51:40 +0100395 declare -A artefact_filters=(
396 [backup_fip]="backup_fip.bin"
397 [bl1]="bl1.bin"
398 [bl2]="bl2.bin"
399 [bl31]="bl31.bin"
400 [bl32]="bl32.bin"
401 [busybox]="busybox.bin"
402 [cactus_primary]="cactus-primary.pkg"
403 [cactus_secondary]="cactus-secondary.pkg"
404 [cactus_tertiary]="cactus-tertiary.pkg"
405 [coverage_trace_plugin]="coverage_trace.so"
406 [dtb]="dtb.bin"
407 [el3_payload]="el3_payload.bin"
408 [fip_gpt]="fip_gpt.bin"
409 [fip]="fip.bin"
410 [fvp_spmc_manifest_dtb]="=fvp_spmc_manifest.dtb"
411 [fwu_fip]="fwu_fip.bin"
412 [generic_trace]="GenericTrace.so"
413 [hafnium]="hafnium.bin"
414 [image]="kernel.bin"
415 [ivy]="ivy.pkg"
416 [manifest_dtb]="=manifest.dtb"
417 [mcp_rom_hyphen]="mcp-rom.bin"
418 [mcp_rom]="mcp_rom.bin"
419 [ns_bl1u]="ns_bl1u.bin"
420 [ns_bl2u]="ns_bl2u.bin"
421 [ramdisk]="initrd.bin|initrd.img"
422 [romlib]="romlib.bin"
423 [rootfs]="rootfs.bin"
424 [scp_ram_hyphen]="scp-ram.bin"
425 [scp_ram]="scp_ram.bin"
426 [scp_rom_hyphen]="scp-rom.bin"
427 [scp_rom]="scp_rom.bin"
428 [secure_hafnium]="secure_hafnium.bin"
429 [spm]="spm.bin"
430 [tftf]="tftf.bin"
431 [tmp]="tmp.bin"
432 [uboot]="uboot.bin"
433 )
434
Chris Kay5d550d82022-10-12 17:20:31 +0100435 # In LAVA we don't provide the paths to the artefacts directly, but instead
436 # use macros of the form `{XYZ}`. This is a list of regular expression
437 # replacements to run on the model parameters file before we add them to the
438 # LAVA job definition.
439 declare -A artefact_macros=(
440 ["[= ]backup_fip.bin"]="={BACKUP_FIP}"
441 ["[= ]bl1.bin"]="={BL1}"
442 ["[= ]bl2.bin"]="={BL2}"
443 ["[= ]bl31.bin"]="={BL31}"
444 ["[= ]bl32.bin"]="={BL32}"
445 ["[= ]cactus-primary.pkg"]="={CACTUS_PRIMARY}"
446 ["[= ]cactus-secondary.pkg"]="={CACTUS_SECONDARY}"
447 ["[= ]cactus-tertiary.pkg"]="={CACTUS_TERTIARY}"
448 ["[= ].*coverage_trace.so"]="={COVERAGE_TRACE_PLUGIN}"
449 ["[= ]fvp_spmc_manifest.dtb"]="={FVP_SPMC_MANIFEST_DTB}"
450 ["[= ]busybox.bin"]="={BUSYBOX}"
451 ["[= ]dtb.bin"]="={DTB}"
452 ["[= ]el3_payload.bin"]="={EL3_PAYLOAD}"
453 ["[= ]fip_gpt.bin"]="={FIP_GPT}"
454 ["[= ]fwu_fip.bin"]="={FWU_FIP}"
455 ["[= ]fip.bin"]="={FIP}"
456 ["[= ].*GenericTrace.so"]="={GENERIC_TRACE}"
457 ["[= ].*/hafnium.bin"]="={HAFNIUM}"
458 ["[= ]kernel.bin"]="={IMAGE}"
459 ["[= ]ivy.pkg"]="={IVY}"
460 ["[= ]manifest.dtb"]="={MANIFEST_DTB}"
461 ["[= ]mcp-rom.bin"]="={MCP_ROM}"
462 ["[= ]mcp_rom_hyphen.bin"]="={MCP_ROM_HYPHEN}"
463 ["[= ]ns_bl1u.bin"]="={NS_BL1U}"
464 ["[= ]ns_bl2u.bin"]="={NS_BL2U}"
465 ["[= ]initrd.bin"]="={RAMDISK}"
466 ["[= ]initrd.img"]="={RAMDISK}"
467 ["[= ]romlib.bin"]="={ROMLIB}"
468 ["[= ]rootfs.bin"]="={ROOTFS}"
469 ["[= ].*/secure_hafnium.bin"]="={SECURE_HAFNIUM}"
470 ["[= ]scp_ram.bin"]="={SCP_RAM}"
471 ["[= ]scp-ram.bin"]="={SCP_RAM_HYPHEN}"
472 ["[= ]scp_rom.bin"]="={SCP_ROM}"
473 ["[= ]scp-rom.bin"]="={SCP_ROM_HYPHEN}"
474 ["[= ]spm.bin"]="={SPM}"
475 ["[= ]tftf.bin"]="={TFTF}"
476 ["[= ].*/tmp.bin"]="={TMP}"
477 ["[= ]uboot.bin"]="={UBOOT}"
478 )
479
Chris Kay4eb9ded2022-10-10 15:51:40 +0100480 declare -a artefacts=()
481
482 for artefact in "${!artefact_filters[@]}"; do
483 if grep -E -q "${artefact_filters[${artefact}]}" "${archive}/model_params"; then
484 artefacts+=("${artefact}")
485 fi
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600486 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500487
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600488 # copied files are the working files
Chris Kayc9523b12022-10-10 18:32:20 +0100489 expand_template "${yaml_template_file}" > "${yaml_file}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600490 cp "$archive/model_params" "$lava_model_params"
491
Chris Kayf07d3392022-10-26 15:42:48 +0100492 # Ensure braces in the FVP model parameters are not accidentally interpreted
493 # as LAVA macros.
494 sed -i -e 's/{/{{/g' "${lava_model_params}"
495 sed -i -e 's/}/}}/g' "${lava_model_params}"
496
Chris Kay5d550d82022-10-12 17:20:31 +0100497 # LAVA expects FVP binary paths as macros, i.e. `{X}` instead of `x.bin`, so
498 # replace the file paths in our pre-generated model parameters.
499 for regex in "${!artefact_macros[@]}"; do
500 sed -i -e "s!${regex}!${artefact_macros[${regex}]}!" \
501 "${lava_model_params}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600502 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500503
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500504 # include the model parameters
505 while read -r line; do
506 if [ -n "$line" ]; then
Chris Kay60df24d2022-10-04 17:35:06 +0100507 yaml_line="- $(echo "${line}" | jq -R .)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600508 sed -i -e "/{BOOT_ARGUMENTS}/i \ \ \ \ $yaml_line" "$yaml_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500509 fi
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500510 done < "$lava_model_params"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600511 sed -i -e '/{BOOT_ARGUMENTS}/d' "$yaml_file"
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500512
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500513 # Append expect commands into the job definition through test-interactive commands
514 gen_fvp_yaml_expect >> "$yaml_file"
515
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600516 # create job.yaml
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500517 cp "$yaml_file" "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500518
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600519 # archive both yamls
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500520 archive_file "$yaml_file"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500521 archive_file "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500522}
523
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500524gen_fvp_yaml_expect() {
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500525
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500526 run_root="$archive/run"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500527
528 # Loop through all uarts expect files
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500529 for expect_file in $(find $run_root -name expect); do
530
531 # TODO: currently, only handle UART 0
532 case $expect_file in
533 *uart0* )
534 uart_number=uart0
535 ;;
536 *)
537 continue
538 ;;
539 esac
540
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500541 # Array containing "interactive" or "monitor" expect strings and populated during run config execution.
542 # Interactive expect scripts are converted into LAVA Interactive Test Actions (see
543 # https://tf.validation.linaro.org/static/docs/v2/interactive.html#writing-tests-interactive) and
544 # monitor expect scripts are converted into LAVA Monitor Test Actions (see
545 # https://validation.linaro.org/static/docs/v2/actions-test.html#monitor)
546 #
547 # Interactive Expect strings have the format 'i;<prompt>;<succeses>;<failures>;<commands>'
548 # where multiple successes or failures or commands are separated by @
549 #
550 # Monitor Expect strings have the format 'm;<start>;<end>;<patterns>'
551 # where multiple patterns are separated by @
552 #
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500553 expect_string=()
554
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500555 # Get the real name of the expect file
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500556 expect_file=$(cat $expect_file)
557
558 # Source the run_config enviroment variables
559 env=$run_root/$uart_number/env
560 if [ -e $env ]; then
561 source $env
562 fi
563
564 # Get all expect strings
Paul Sokolovskyeece6f72021-12-01 15:04:29 +0300565 expect_file=$ci_root/expect-lava/${expect_file}
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500566 source $expect_file
567
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500568
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500569 if [ ${#expect_string[@]} -gt 0 ]; then
570
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500571 # expect loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500572 for key in "${!expect_string[@]}"; do
573
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500574 # single raw expect string
575 es="${expect_string[${key}]}"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500576
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500577 # action type: either m or i
578 action="$(echo "${es}" | awk -F ';' '{print $1}')"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500579
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500580 if [ "${action}" = "m" ]; then
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500581
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500582 start="$(echo "${es}" | awk -F ';' '{print $2}')"
583 end="$(echo "${es}" | awk -F ';' '{print $3}')"
584 patterns="$(echo "${es}" | awk -F ';' '{print $4}')"
585
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500586 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500587- test:
588 monitors:
589 - name: tests
590 start: '${start}'
591 end: '${end}'
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500592EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500593 # Patterns are separated by '@'
594 OLD_IFS=$IFS; IFS=$'@'
595 for p in ${patterns}; do
596 cat << EOF
597 pattern: '$p'
598EOF
599 done
600 IFS=$OLD_IFS
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500601 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500602 fixupdict:
603 PASS: pass
604 FAIL: fail
605EOF
606 fi # end of monitor action
607
608 if [ "${action}" = "i" ]; then
609
610 prompts="$(echo "${es}" | awk -F ';' '{print $2}')"
611 successes="$(echo "${es}" | awk -F ';' '{print $3}')"
612 failures="$(echo "${es}" | awk -F ';' '{print $4}')"
613 commands="$(echo "${es}" | awk -F ';' '{print $5}')"
614
615 cat << EOF
616- test:
617 interactive:
618EOF
619 OLD_IFS=$IFS; IFS=$'@'
620
621 if [[ -n "${prompts}" && -n "${successes}" && -n "${failures}" ]]; then
622 cat << EOF
623 - name: interactive_${uart_number}_${key}
624 prompts: ['${prompts}']
625 script:
626EOF
627 if [ -z "${commands}" ]; then
628 cat <<EOF
629 - name: interactive_command_${uart_number}_${key}
630 command:
631EOF
632 else
633 for c in ${commands}; do
634 cat <<EOF
635 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300636 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500637EOF
638 done
639 fi
640 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500641 successes:
642EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500643 for s in ${successes}; do
644 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500645 - message: '$s'
646EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500647 done
648 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500649 failures:
650EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500651 for f in ${failures}; do
652 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500653 - message: '$f'
654EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500655 done
656 elif [[ -n "${prompts}" && -n "${successes}" ]]; then
657 cat << EOF
658 - name: interactive_${uart_number}_${key}
659 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500660 script:
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500661EOF
662
663 if [ -z "${commands}" ]; then
664 cat <<EOF
665 - name: interactive_command_${uart_number}_${key}
666 command:
667EOF
668 else
669 for c in ${commands}; do
670 cat <<EOF
671 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300672 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500673EOF
674 done
675 fi
676 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500677 successes:
678EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500679 for s in ${successes}; do
680 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500681 - message: '$s'
682EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500683 done
684
685 elif [[ -n "${prompts}" && -n "${failures}" ]]; then
686 cat << EOF
687 - name: interactive_${uart_number}_${key}
688 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500689 script:
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500690EOF
691 if [ -z "${commands}" ]; then
692 cat <<EOF
693 - name: interactive_command_${uart_number}_${key}
694 command:
695EOF
696 else
697 for c in ${commands}; do
698 cat <<EOF
699 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300700 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500701EOF
702 done
703 fi
704 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500705 failures:
706EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500707 for f in ${failures}; do
708 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500709 - message: '$f'
710EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500711 done
712 else
713 cat << EOF
714 - name: interactive_${uart_number}_${key}
715 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500716 script:
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500717EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500718 if [ -z "${commands}" ]; then
719 cat <<EOF
720 - name: interactive_command_${uart_number}_${key}
721 command:
722EOF
723 else
724 for c in ${commands}; do
725 cat <<EOF
726 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300727 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500728EOF
729 done
730 fi
731 fi
732
733 IFS=$OLD_IFS
734 fi # end of interactive action
735
736 done # end of expect loop
737
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500738 fi
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500739 done # end of uart loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500740}
741
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500742docker_registry_append() {
743 # if docker_registry is empty, just use local docker registry
744 [ -z "$docker_registry" ] && return
745
746 local last=-1
747 local last_char="${docker_registry:last}"
748
749 if [ "$last_char" != '/' ]; then
750 docker_registry="${docker_registry}/";
751 fi
752 echo "$docker_registry"
753}
754
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000755# generate GPT image and archive it
756gen_gpt_bin() {
757 raw_image="fip_gpt.bin"
758 img_uuid="FB90808A-BA9A-4D42-B9A2-A7A937144AEE"
759 img_bank_uuid=`uuidgen`
760 disk_uuid=`uuidgen`
761 bin="${1:?}"
762
763 # maximum FIP size 2MB
764 fip_max_size=2097152
765 start_sector=34
766 sector_size=512
767 num_sectors=$(($fip_max_size/$sector_size))
768 bin_size=$(stat -c %s $bin)
769
770 if [[ $fip_max_size -lt $bin_size ]]
771 then
772 echo "FIP binary ($bin_size bytes) larger than max partition 1"
773 "size ($fip_max_size byte)"
774 return
775 fi
776
777 # create raw 5MB image
778 dd if=/dev/zero of=$raw_image bs=5M count=1
779
780 # create GPT image
781 sgdisk -a 1 -U $disk_uuid -n 1:$start_sector:+$num_sectors \
782 -c 1:FIP_A -t 1:$img_uuid $raw_image -u $img_bank_uuid
783
784 echo "write binary $bin at sector $start_sector"
785 dd if=$bin of=$raw_image bs=$sector_size seek=$start_sector \
786 count=$num_sectors conv=notrunc
787
788 archive_file "fip_gpt.bin"
789}
790
Fathi Boudra422bf772019-12-02 11:10:16 +0200791set +u