blob: d082cd26487a86baef1404592c587ee55795a995 [file] [log] [blame]
Leonardo Sandoval9dfdd1b2020-08-06 17:08:11 -05001#!/usr/bin/env bash
Fathi Boudra422bf772019-12-02 11:10:16 +02002#
Govindraj Raja1d208f72025-02-11 12:20:32 -06003# Copyright (c) 2020-2025, 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}"
Harrison Mutai3dcd1fe2025-03-24 13:19:29 +000018boot_script_addr="${boot_script_addr:-0x8fb00000}"
Fathi Boudra422bf772019-12-02 11:10:16 +020019el3_payload_addr="${el3_payload_addr:-0x80000000}"
20
Manish Pandey3c435582020-07-15 12:14:26 +010021# SPM requires following addresses for RESET_TO_BL31 case
22spm_addr="${spm_addr:-0x6000000}"
23spmc_manifest_addr="${spmc_addr:-0x0403f000}"
24sp1_addr="${sp1_addr:-0x7000000}"
25sp2_addr="${sp2_addr:-0x7100000}"
Olivier Deprez0b834092020-08-21 08:36:01 +020026sp3_addr="${sp3_addr:-0x7200000}"
Olivier Deprezdd9ed332021-07-02 12:07:17 +020027sp4_addr="${sp4_addr:-0x7600000}"
Manish Pandey1e7be852020-11-09 16:04:48 +000028# SPM out directories
J-Alves12d796c2023-02-27 10:30:58 +000029export spm_secure_out_dir="${spm_secure_out_dir:-secure_aem_v8a_fvp_vhe_clang}"
30export spm_non_secure_out_dir="${spm_non_secure_out_dir:-aem_v8a_fvp_vhe_clang}"
Manish Pandey3c435582020-07-15 12:14:26 +010031
Fathi Boudra422bf772019-12-02 11:10:16 +020032ns_bl1u_addr="${ns_bl1u_addr:-0x0beb8000}"
33fwu_fip_addr="${fwu_fip_addr:-0x08400000}"
34backup_fip_addr="${backup_fip_addr:-0x09000000}"
35romlib_addr="${romlib_addr:-0x03ff2000}"
36
Harrison Mutai6f4fd6c2023-03-27 13:22:41 +010037uefi_downloads="${uefi_downloads:-http://files.oss.arm.com/downloads/uefi}"
38uefi_ci_bin_url="${uefi_ci_bin_url:-$uefi_downloads/Artifacts/Linux/github/fvp/static/DEBUG_GCC5/FVP_AARCH64_EFI.fd}"
39
Fathi Boudra422bf772019-12-02 11:10:16 +020040uboot32_fip_url="$linaro_release/fvp32-latest-busybox-uboot/fip.bin"
Harrison Mutai3dcd1fe2025-03-24 13:19:29 +000041if [[ "$test_config" == *handoff* ]]; then
Harrison Mutai6eb2c7f2025-05-06 10:01:11 +000042 optee_path=$tfa_downloads/optee/handoff/4.6.0
Harrison Mutai3dcd1fe2025-03-24 13:19:29 +000043 uboot_url="${tfa_downloads}/handoff/fvp/u-boot.bin"
44else
Harrison Mutai6eb2c7f2025-05-06 10:01:11 +000045 optee_version="4.5.0"
46
47 optee_path=$tfa_downloads/optee/${optee_version}
Harrison Mutai00a29472024-11-04 10:16:31 +000048 uboot_url="${tfa_downloads}/linux_boot/fvp/u-boot.bin"
Harrison Mutai3dcd1fe2025-03-24 13:19:29 +000049fi
50uboot_script_url="${tfa_downloads}/linux_boot/fvp/boot.scr"
Fathi Boudra422bf772019-12-02 11:10:16 +020051
Harrison Mutai00a29472024-11-04 10:16:31 +000052rootfs_url="${tfa_downloads}/linux_boot/fvp/rootfs.ext4"
Fathi Boudra422bf772019-12-02 11:10:16 +020053
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -050054# Default FVP model variables
Leonardo Sandovale1460662021-05-27 16:05:38 -050055default_model_dtb="dtb.bin"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -050056
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060057# FVP containers and model paths
Maksims Svecovs284a50d2021-11-02 11:09:47 +000058fvp_arm_std_library="fvp:fvp_arm_std_library_${model_version}_${model_build};/opt/model/FVP_ARM_Std_Library/FVP_Base"
Govindraj Raja7d80d932025-06-30 14:25:38 -050059fvp_base_revc_2xaemva="fvp:fvp_base_revc-2xaemva_${model_version}_${model_build}_linux64;/opt/model/Base_RevC_AEMvA_pkg/models/${model_flavour}"
Govindraj Rajafa86cf62025-02-19 14:55:48 -060060fvp_rd_1_ae="fvp:fvp_rd_1_ae_${model_version}_${model_build};/opt/model/FVP_RD_1_AE/models/${model_flavour}"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -050061
Manish V Badarkhef65f9a32022-11-04 10:07:19 +000062# CSS model list
Govindraj Rajafa86cf62025-02-19 14:55:48 -060063fvp_tc4="fvp:fvp_tc4_${model_version}_${model_build};/opt/model/FVP_TC4/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=(
laurenw-armafdc3bc2022-09-14 15:31:42 -050071[base-aemv8a-revb]="${fvp_arm_std_library};FVP_Base_AEMvA-AEMvA"
Manish Pandeya60d8072024-03-11 09:58:53 +000072[base-aemva]="${fvp_base_revc_2xaemva};FVP_Base_RevC-2xAEMvA"
laurenw-armf414aba2021-04-26 15:58:56 -050073[base-aemv8a]="${fvp_base_revc_2xaemva};FVP_Base_RevC-2xAEMvA"
Govindraj Rajafa86cf62025-02-19 14:55:48 -060074[cortex-a32x4]="${fvp_arm_std_library};FVP_Base_Cortex-A32"
75[cortex-a35x4]="${fvp_arm_std_library};FVP_Base_Cortex-A35"
76[cortex-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A53"
laurenw-armafdc3bc2022-09-14 15:31:42 -050077[cortex-a55x4]="${fvp_arm_std_library};FVP_Base_Cortex-A55"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060078[cortex-a57x1-a53x1]="${fvp_arm_std_library};FVP_Base_Cortex-A57x1-A53x1"
79[cortex-a57x2-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x2-A53x4"
Govindraj Rajafa86cf62025-02-19 14:55:48 -060080[cortex-a57x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060081[cortex-a57x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4-A53x4"
Govindraj Rajafa86cf62025-02-19 14:55:48 -060082[cortex-a65aex8]="${fvp_arm_std_library};FVP_Base_Cortex-A65AE"
83[cortex-a65x4]="${fvp_arm_std_library};FVP_Base_Cortex-A65"
84[cortex-a72x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72"
85[cortex-a73x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060086[cortex-a73x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4-A53x4"
laurenw-armafdc3bc2022-09-14 15:31:42 -050087[cortex-a75x4]="${fvp_arm_std_library};FVP_Base_Cortex-A75"
88[cortex-a76aex4]="${fvp_arm_std_library};FVP_Base_Cortex-A76AE"
laurenw-armafdc3bc2022-09-14 15:31:42 -050089[cortex-a76x4]="${fvp_arm_std_library};FVP_Base_Cortex-A76"
90[cortex-a77x4]="${fvp_arm_std_library};FVP_Base_Cortex-A77"
91[cortex-a78x4]="${fvp_arm_std_library};FVP_Base_Cortex-A78"
Juan Pablo Conded52a4752023-03-21 14:52:10 -050092[cortex-a78aex4]="${fvp_arm_std_library};FVP_Base_Cortex-A78AE"
laurenw-armafdc3bc2022-09-14 15:31:42 -050093[cortex-a78cx4]="${fvp_arm_std_library};FVP_Base_Cortex-A78C"
Govindraj Raja8962c452024-06-04 14:50:28 -050094[cortex-x2]="${fvp_arm_std_library};FVP_Base_Cortex-X2"
Govindraj Raja1d208f72025-02-11 12:20:32 -060095[cortex-x4]="${fvp_arm_std_library};FVP_Base_Cortex-X4"
96[cortex-x925]="${fvp_arm_std_library};FVP_Base_Cortex-X925"
Govindraj Raja268a2be2024-07-01 14:31:31 -050097[cortex-a710x8]="${fvp_arm_std_library};FVP_Base_Cortex-A710"
Govindraj Rajafa86cf62025-02-19 14:55:48 -060098[neoverse_e1]="${fvp_arm_std_library};FVP_Base_Neoverse-E1"
laurenw-armafdc3bc2022-09-14 15:31:42 -050099[neoverse_n1]="${fvp_arm_std_library};FVP_Base_Neoverse-N1"
Govindraj Raja8962c452024-06-04 14:50:28 -0500100[neoverse_n2]="${fvp_arm_std_library};FVP_Base_Neoverse-N2"
laurenw-armafdc3bc2022-09-14 15:31:42 -0500101[neoverse-v1x4]="${fvp_arm_std_library};FVP_Base_Neoverse-V1"
Icen Zeyadab68a5612024-11-08 07:35:44 +0000102[tc4]="${fvp_tc4};FVP_TC4"
Divin Raj5eb69482024-10-02 11:36:04 +0100103[rd1ae]="${fvp_rd_1_ae};FVP_RD_1_AE"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600104)
105
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500106
Fathi Boudra422bf772019-12-02 11:10:16 +0200107# FVP Kernel URLs
Harrison Mutai6f4fd6c2023-03-27 13:22:41 +0100108declare -A kernel_list
109kernel_list=(
Fathi Boudra422bf772019-12-02 11:10:16 +0200110[fvp-aarch32-zimage]="$linaro_release/fvp32-latest-busybox-uboot/Image"
111[fvp-busybox-uboot]="$linaro_release/fvp-latest-busybox-uboot/Image"
112[fvp-oe-uboot32]="$linaro_release/fvp32-latest-oe-uboot/Image"
113[fvp-oe-uboot]="$linaro_release/fvp-latest-oe-uboot/Image"
114[fvp-quad-busybox-uboot]="$tfa_downloads/quad_cluster/Image"
115)
116
Fathi Boudra422bf772019-12-02 11:10:16 +0200117# FVP initrd URLs
Harrison Mutai6f4fd6c2023-03-27 13:22:41 +0100118declare -A initrd_list
119initrd_list=(
Fathi Boudra422bf772019-12-02 11:10:16 +0200120[aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img"
Fathi Boudra422bf772019-12-02 11:10:16 +0200121[dummy-ramdisk]="$linaro_release/fvp-latest-oe-uboot/ramdisk.img"
122[dummy-ramdisk32]="$linaro_release/fvp32-latest-oe-uboot/ramdisk.img"
123[default]="$linaro_release/fvp-latest-busybox-uboot/ramdisk.img"
124)
125
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100126# For Measured Boot tests using a TA based on OPTEE, it is necessary to use a
127# specific build rather than the default one generated by Jenkins.
128get_ftpm_optee_bin() {
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100129 url="$tfa_downloads/ftpm/optee/tee-header_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100130 saveas="bl32.bin" fetch_file
131 archive_file "bl32.bin"
132
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100133 url="$tfa_downloads/ftpm/optee/tee-pager_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100134 saveas="bl32_extra1.bin" fetch_file
135 archive_file "bl32_extra1.bin"
136
Leonardo Sandovalda5f78d2021-03-18 11:09:30 -0600137 # tee-pageable_v2.bin is just a empty file, named as bl32_extra2.bin,
138 # so just create the file
139 touch "bl32_extra2.bin"
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100140 archive_file "bl32_extra2.bin"
141}
142
Fathi Boudra422bf772019-12-02 11:10:16 +0200143get_dtb() {
144 local dtb_type="${dtb_type:?}"
145 local dtb_url
Boyan Karatotev802cec12025-08-01 13:07:42 +0100146 local dtb_saveas="$archive/dtb.bin"
Zelalem219df412020-05-17 19:21:20 -0500147 local cc="$(get_tf_opt CROSS_COMPILE)"
148 local pp_flags="-P -nostdinc -undef -x assembler-with-cpp"
Fathi Boudra422bf772019-12-02 11:10:16 +0200149
150 case "$dtb_type" in
151 "fvp-base-quad-cluster-gicv3-psci")
152 # Get the quad-cluster FDT from pdsw area
153 dtb_url="$tfa_downloads/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb"
154 url="$dtb_url" saveas="$dtb_saveas" fetch_file
155 ;;
Fathi Boudra422bf772019-12-02 11:10:16 +0200156 *)
Zelalem219df412020-05-17 19:21:20 -0500157 # Preprocess DTS file
158 ${cc}gcc -E ${pp_flags} -I"$tf_root/fdts" -I"$tf_root/include" \
Boyan Karatotev802cec12025-08-01 13:07:42 +0100159 -o "$archive/${dtb_type}.pre.dts" \
Zelalem219df412020-05-17 19:21:20 -0500160 "$tf_root/fdts/${dtb_type}.dts"
161 # Generate DTB file from DTS
Fathi Boudra422bf772019-12-02 11:10:16 +0200162 dtc -I dts -O dtb \
Boyan Karatotev802cec12025-08-01 13:07:42 +0100163 "$archive/${dtb_type}.pre.dts" -o "$dtb_saveas"
Fathi Boudra422bf772019-12-02 11:10:16 +0200164 esac
165
166 archive_file "$dtb_saveas"
167}
168
169get_rootfs() {
170 local tmpdir
171 local fs_base="$(echo $(basename $rootfs_url) | sed 's/\.gz$//')"
172 local cached="$project_filer/ci-files/$fs_base"
173
174 if upon "$jenkins_run" && [ -f "$cached" ]; then
175 # Job workspace is limited in size, and the root file system is
176 # quite large. This means, parallel runs of root file system
177 # tests could fail. So, for Jenkins runs, copy and use the root
178 # file system image from the $CI_SCRATCH location
179 local private="$CI_SCRATCH/$JOB_NAME-$BUILD_NUMBER"
180 mkdir -p "$private"
181 rm -f "$private/rootfs.bin"
182 url="$cached" saveas="$private/rootfs.bin" fetch_file
183 ln -s "$private/rootfs.bin" "$archive/rootfs.bin"
184 return
185 fi
186
187 tmpdir="$(mktempdir)"
188 pushd "$tmpdir"
189 url="$rootfs_url" saveas="rootfs.bin" fetch_file
190
191 # Possibly, the filesystem image we just downloaded is compressed.
192 # Decompress it if required.
193 if file "rootfs.bin" | grep -iq 'gzip compressed data'; then
194 echo "Decompressing root file system image rootfs.bin ..."
195 gunzip --stdout "rootfs.bin" > uncompressed_fs.bin
196 mv uncompressed_fs.bin "rootfs.bin"
197 fi
198
199 archive_file "rootfs.bin"
200 popd
201}
202
Chris Kayc9523b12022-10-10 18:32:20 +0100203# Generates the final YAML-based LAVA job definition from a template file.
204#
205# The job definition template is expanded with visibility of all variables that
206# are available from within the function, including those with local scope.
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500207gen_fvp_yaml() {
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600208 local model="${model:?}"
209
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500210 local yaml_template_file="$workspace/fvp_template.yaml"
211 local yaml_file="$workspace/fvp.yaml"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500212 local yaml_job_file="$workspace/job.yaml"
213 local lava_model_params="$workspace/lava_model_params"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500214
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500215 # this function expects a template, quit if it is not present
216 if [ ! -f "$yaml_template_file" ]; then
Paul Sokolovskya3c5a4c2023-01-24 18:33:58 +0700217 echo "warning: gen_fvp_yaml: template $yaml_template_file not available, skipping generating LAVA job"
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500218 return
219 fi
220
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600221 local model_params="${fvp_models[$model]}"
222 local model_name="$(echo "${model_params}" | awk -F ';' '{print $1}')"
223 local model_dir="$(echo "${model_params}" | awk -F ';' '{print $2}')"
224 local model_bin="$(echo "${model_params}" | awk -F ';' '{print $3}')"
225
226 # model params are required for correct yaml creation, quit if empty
227 if [ -z "${model_name}" ]; then
228 echo "FVP model param 'model_name' variable empty, yaml not produced"
229 return
230 elif [ -z "${model_dir}" ]; then
231 echo "FVP model param 'model_dir' variable empty, yaml not produced"
232 return
233 elif [ -z "${model_bin}" ]; then
234 echo "FVP model param 'model_bin' variable empty, yaml not produced"
235 return
236 fi
237
238 echo "FVP model params: model_name=$model_name model_dir=$model_dir model_bin=$model_bin"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500239
240 # optional parameters, defaults to globals
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500241 local model_dtb="${model_dtb:-$default_model_dtb}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500242
Chris Kayc9523b12022-10-10 18:32:20 +0100243 if [ -n "${GERRIT_CHANGE_NUMBER}" ]; then
244 local gerrit_url="https://review.trustedfirmware.org/c/${GERRIT_CHANGE_NUMBER}/${GERRIT_PATCHSET_NUMBER}"
245 elif [ -n "${GERRIT_REFSPEC}" ]; then
246 local gerrit_url=$(echo ${GERRIT_REFSPEC} |
247 awk -F/ '{print "https://review.trustedfirmware.org/c/" $4 "/" $5}')
248 fi
249
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500250 docker_registry="${docker_registry:-}"
251 docker_registry="$(docker_registry_append)"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500252 docker_name="${docker_registry}$model_name"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600253 prompt1='/ #'
254 prompt2='root@genericarmv8:~#'
255 version_string="\"Fast Models"' [^\\n]+'"\""
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500256
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500257 test_config="${TEST_CONFIG}"
258
Harrison Mutaia6d6e682023-03-27 13:20:33 +0100259 declare -A fvp_artefact_filters=(
Chris Kay4eb9ded2022-10-10 15:51:40 +0100260 [backup_fip]="backup_fip.bin"
261 [bl1]="bl1.bin"
262 [bl2]="bl2.bin"
263 [bl31]="bl31.bin"
264 [bl32]="bl32.bin"
265 [busybox]="busybox.bin"
Harrison Mutai3dcd1fe2025-03-24 13:19:29 +0000266 [boot_script]="boot_script.bin"
Chris Kay4eb9ded2022-10-10 15:51:40 +0100267 [cactus_primary]="cactus-primary.pkg"
268 [cactus_secondary]="cactus-secondary.pkg"
269 [cactus_tertiary]="cactus-tertiary.pkg"
270 [coverage_trace_plugin]="coverage_trace.so"
271 [dtb]="dtb.bin"
272 [el3_payload]="el3_payload.bin"
273 [fip_gpt]="fip_gpt.bin"
274 [fip]="fip.bin"
275 [fvp_spmc_manifest_dtb]="=fvp_spmc_manifest.dtb"
276 [fwu_fip]="fwu_fip.bin"
Chris Kay4eb9ded2022-10-10 15:51:40 +0100277 [hafnium]="hafnium.bin"
278 [image]="kernel.bin"
279 [ivy]="ivy.pkg"
280 [manifest_dtb]="=manifest.dtb"
Chris Kayfbdd0142022-11-08 12:24:30 +0000281 [mcp_fw]="mcp_fw.bin"
Manish V Badarkhe18c59782022-11-09 10:14:48 +0000282 [mcp_ram]="mcp_ram.bin"
Chris Kay4eb9ded2022-10-10 15:51:40 +0100283 [mcp_rom_hyphen]="mcp-rom.bin"
284 [mcp_rom]="mcp_rom.bin"
285 [ns_bl1u]="ns_bl1u.bin"
286 [ns_bl2u]="ns_bl2u.bin"
287 [ramdisk]="initrd.bin|initrd.img"
288 [romlib]="romlib.bin"
289 [rootfs]="rootfs.bin"
laurenw-arm60de2742023-03-08 10:50:15 -0600290 [host_flash_fip]="host_flash_fip.bin"
Divin Raj5eb69482024-10-02 11:36:04 +0100291 [rse_flash]="rse_flash.bin"
David Vinczed8ed5622024-02-23 17:00:12 +0100292 [rse_rom]="rse_rom.bin"
293 [rse_encrypted_cm_provisioning_bundle_0]="rse_encrypted_cm_provisioning_bundle_0.bin"
294 [rse_encrypted_dm_provisioning_bundle]="rse_encrypted_dm_provisioning_bundle.bin"
Chris Kayfbdd0142022-11-08 12:24:30 +0000295 [scp_fw]="scp_fw.bin"
Chris Kay4eb9ded2022-10-10 15:51:40 +0100296 [scp_ram_hyphen]="scp-ram.bin"
297 [scp_ram]="scp_ram.bin"
298 [scp_rom_hyphen]="scp-rom.bin"
299 [scp_rom]="scp_rom.bin"
300 [secure_hafnium]="secure_hafnium.bin"
301 [spm]="spm.bin"
Manish V Badarkhe9589d402024-01-29 16:46:41 +0000302 [tc_fitimage]="tc_fitimage.bin"
Chris Kay4eb9ded2022-10-10 15:51:40 +0100303 [tftf]="tftf.bin"
Harrison Mutai3ad377a2024-05-20 15:28:52 +0000304 [tl]="tl.bin"
Chris Kay4eb9ded2022-10-10 15:51:40 +0100305 [tmp]="tmp.bin"
306 [uboot]="uboot.bin"
307 )
308
Harrison Mutaia6d6e682023-03-27 13:20:33 +0100309 declare -A fvp_artefact_urls=(
Harrison Mutaie5122542023-03-27 13:14:18 +0100310 [backup_fip]="$(gen_bin_url backup_fip.bin)"
311 [bl1]="$(gen_bin_url bl1.bin)"
312 [bl2]="$(gen_bin_url bl2.bin)"
313 [bl31]="$(gen_bin_url bl31.bin)"
314 [bl32]="$(gen_bin_url bl32.bin)"
315 [busybox]="$(gen_bin_url busybox.bin.gz)"
Harrison Mutai3dcd1fe2025-03-24 13:19:29 +0000316 [boot_script]="$(gen_bin_url boot_script.bin)"
Harrison Mutaie5122542023-03-27 13:14:18 +0100317 [cactus_primary]="$(gen_bin_url cactus-primary.pkg)"
318 [cactus_secondary]="$(gen_bin_url cactus-secondary.pkg)"
319 [cactus_tertiary]="$(gen_bin_url cactus-tertiary.pkg)"
Thaddeus Gonzalez-Serna211688c2025-03-21 19:12:37 -0500320 [coverage_trace_plugin]="$(gen_cc_url)"
Harrison Mutaie5122542023-03-27 13:14:18 +0100321 [dtb]="$(gen_bin_url ${model_dtb})"
322 [el3_payload]="$(gen_bin_url el3_payload.bin)"
Harrison Mutaie5122542023-03-27 13:14:18 +0100323 [fip]="$(gen_bin_url fip.bin)"
324 [fip_gpt]="$(gen_bin_url fip_gpt.bin)"
325 [fvp_spmc_manifest_dtb]="$(gen_bin_url fvp_spmc_manifest.dtb)"
326 [fwu_fip]="$(gen_bin_url fwu_fip.bin)"
Harrison Mutaie5122542023-03-27 13:14:18 +0100327 [hafnium]="$(gen_bin_url hafnium.bin)"
328 [image]="$(gen_bin_url kernel.bin)"
329 [ivy]="$(gen_bin_url ivy.pkg)"
330 [manifest_dtb]="$(gen_bin_url manifest.dtb)"
331 [mcp_fw]="$(gen_bin_url mcp_fw.bin)"
332 [mcp_ram]="$(gen_bin_url mcp_ram.bin)"
333 [mcp_rom]="$(gen_bin_url mcp_rom.bin)"
334 [mcp_rom_hyphen]="$(gen_bin_url mcp-rom.bin)"
335 [ns_bl1u]="$(gen_bin_url ns_bl1u.bin)"
336 [ns_bl2u]="$(gen_bin_url ns_bl2u.bin)"
337 [ramdisk]="$(gen_bin_url initrd.bin)"
338 [romlib]="$(gen_bin_url romlib.bin)"
339 [rootfs]="$(gen_bin_url rootfs.bin.gz)"
340 [host_flash_fip]="$(gen_bin_url host_flash_fip.bin)"
Divin Raj5eb69482024-10-02 11:36:04 +0100341 [rse_flash]="$(gen_bin_url rse_flash.bin)"
David Vinczed8ed5622024-02-23 17:00:12 +0100342 [rse_rom]="$(gen_bin_url rse_rom.bin)"
343 [rse_encrypted_cm_provisioning_bundle_0]="$(gen_bin_url rse_encrypted_cm_provisioning_bundle_0.bin)"
344 [rse_encrypted_dm_provisioning_bundle]="$(gen_bin_url rse_encrypted_dm_provisioning_bundle.bin)"
Harrison Mutaie5122542023-03-27 13:14:18 +0100345 [secure_hafnium]="$(gen_bin_url secure_hafnium.bin)"
346 [scp_fw]="$(gen_bin_url scp_fw.bin)"
347 [scp_ram]="$(gen_bin_url scp_ram.bin)"
348 [scp_ram_hyphen]="$(gen_bin_url scp-ram.bin)"
349 [scp_rom]="$(gen_bin_url scp_rom.bin)"
350 [scp_rom_hyphen]="$(gen_bin_url scp-rom.bin)"
351 [spm]="$(gen_bin_url spm.bin)"
Manish V Badarkhe9589d402024-01-29 16:46:41 +0000352 [tc_fitimage]="$(gen_bin_url tc_fitimage.bin)"
Harrison Mutaie5122542023-03-27 13:14:18 +0100353 [tftf]="$(gen_bin_url tftf.bin)"
Harrison Mutai3ad377a2024-05-20 15:28:52 +0000354 [tl]="$(gen_bin_url tl.bin)"
Harrison Mutaie5122542023-03-27 13:14:18 +0100355 [tmp]="$(gen_bin_url tmp.bin)"
356 [uboot]="$(gen_bin_url uboot.bin)"
Chris Kayc14743a2022-10-13 11:33:26 +0100357 )
358
Chris Kay5d550d82022-10-12 17:20:31 +0100359 # In LAVA we don't provide the paths to the artefacts directly, but instead
360 # use macros of the form `{XYZ}`. This is a list of regular expression
361 # replacements to run on the model parameters file before we add them to the
362 # LAVA job definition.
Harrison Mutaia6d6e682023-03-27 13:20:33 +0100363 declare -A fvp_artefact_macros=(
Chris Kay5d550d82022-10-12 17:20:31 +0100364 ["[= ]backup_fip.bin"]="={BACKUP_FIP}"
365 ["[= ]bl1.bin"]="={BL1}"
366 ["[= ]bl2.bin"]="={BL2}"
367 ["[= ]bl31.bin"]="={BL31}"
368 ["[= ]bl32.bin"]="={BL32}"
Harrison Mutai3dcd1fe2025-03-24 13:19:29 +0000369 ["[= ]boot_script.bin"]="={BOOT_SCRIPT}"
Chris Kay5d550d82022-10-12 17:20:31 +0100370 ["[= ]cactus-primary.pkg"]="={CACTUS_PRIMARY}"
371 ["[= ]cactus-secondary.pkg"]="={CACTUS_SECONDARY}"
372 ["[= ]cactus-tertiary.pkg"]="={CACTUS_TERTIARY}"
373 ["[= ].*coverage_trace.so"]="={COVERAGE_TRACE_PLUGIN}"
374 ["[= ]fvp_spmc_manifest.dtb"]="={FVP_SPMC_MANIFEST_DTB}"
375 ["[= ]busybox.bin"]="={BUSYBOX}"
376 ["[= ]dtb.bin"]="={DTB}"
377 ["[= ]el3_payload.bin"]="={EL3_PAYLOAD}"
378 ["[= ]fip_gpt.bin"]="={FIP_GPT}"
379 ["[= ]fwu_fip.bin"]="={FWU_FIP}"
380 ["[= ]fip.bin"]="={FIP}"
Chris Kay5d550d82022-10-12 17:20:31 +0100381 ["[= ].*/hafnium.bin"]="={HAFNIUM}"
382 ["[= ]kernel.bin"]="={IMAGE}"
383 ["[= ]ivy.pkg"]="={IVY}"
384 ["[= ]manifest.dtb"]="={MANIFEST_DTB}"
Chris Kayfbdd0142022-11-08 12:24:30 +0000385 ["[= ]mcp_fw.bin"]="={MCP_FW}"
Manish V Badarkhe18c59782022-11-09 10:14:48 +0000386 ["[= ]mcp_ram.bin"]="={MCP_RAM}"
Chris Kayef9cc802022-11-08 12:11:58 +0000387 ["[= ]mcp_rom.bin"]="={MCP_ROM}"
388 ["[= ]mcp-rom.bin"]="={MCP_ROM_HYPHEN}"
Chris Kay5d550d82022-10-12 17:20:31 +0100389 ["[= ]ns_bl1u.bin"]="={NS_BL1U}"
390 ["[= ]ns_bl2u.bin"]="={NS_BL2U}"
391 ["[= ]initrd.bin"]="={RAMDISK}"
392 ["[= ]initrd.img"]="={RAMDISK}"
393 ["[= ]romlib.bin"]="={ROMLIB}"
394 ["[= ]rootfs.bin"]="={ROOTFS}"
laurenw-arm60de2742023-03-08 10:50:15 -0600395 ["[= ]host_flash_fip.bin"]="={HOST_FLASH_FIP}"
Divin Raj5eb69482024-10-02 11:36:04 +0100396 ["[= ]rse_flash.bin"]="={RSE_FLASH}"
David Vinczed8ed5622024-02-23 17:00:12 +0100397 ["[= ]rse_rom.bin"]="={RSE_ROM}"
398 ["[= ]rse_encrypted_cm_provisioning_bundle_0.bin"]="={RSE_ENCRYPTED_CM_PROVISIONING_BUNDLE_0}"
399 ["[= ]rse_encrypted_dm_provisioning_bundle.bin"]="={RSE_ENCRYPTED_DM_PROVISIONING_BUNDLE}"
Chris Kay5d550d82022-10-12 17:20:31 +0100400 ["[= ].*/secure_hafnium.bin"]="={SECURE_HAFNIUM}"
Chris Kayfbdd0142022-11-08 12:24:30 +0000401 ["[= ]scp_fw.bin"]="={SCP_FW}"
Chris Kay5d550d82022-10-12 17:20:31 +0100402 ["[= ]scp_ram.bin"]="={SCP_RAM}"
403 ["[= ]scp-ram.bin"]="={SCP_RAM_HYPHEN}"
404 ["[= ]scp_rom.bin"]="={SCP_ROM}"
405 ["[= ]scp-rom.bin"]="={SCP_ROM_HYPHEN}"
406 ["[= ]spm.bin"]="={SPM}"
Manish V Badarkhe9589d402024-01-29 16:46:41 +0000407 ["[= ]tc_fitimage.bin"]="={TC_FITIMAGE}"
Chris Kay5d550d82022-10-12 17:20:31 +0100408 ["[= ]tftf.bin"]="={TFTF}"
Harrison Mutai3ad377a2024-05-20 15:28:52 +0000409 ["[= ]tl.bin"]="={TL}"
Chris Kay5d550d82022-10-12 17:20:31 +0100410 ["[= ].*/tmp.bin"]="={TMP}"
411 ["[= ]uboot.bin"]="={UBOOT}"
412 )
413
Harrison Mutaia6d6e682023-03-27 13:20:33 +0100414 declare -a fvp_artefacts
415 filter_artefacts fvp_artefacts fvp_artefact_filters
Chris Kay4eb9ded2022-10-10 15:51:40 +0100416
Harrison Mutaia6d6e682023-03-27 13:20:33 +0100417 lava_model_params="${lava_model_params}" \
418 gen_lava_model_params fvp_artefact_macros
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500419
Harrison Mutaia6d6e682023-03-27 13:20:33 +0100420 yaml_template_file="$yaml_template_file" \
421 yaml_file="$yaml_file" \
422 yaml_job_file="$yaml_job_file" \
423 gen_lava_job_def fvp_artefacts fvp_artefact_urls
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500424}
425
426docker_registry_append() {
427 # if docker_registry is empty, just use local docker registry
428 [ -z "$docker_registry" ] && return
429
430 local last=-1
431 local last_char="${docker_registry:last}"
432
433 if [ "$last_char" != '/' ]; then
434 docker_registry="${docker_registry}/";
435 fi
436 echo "$docker_registry"
437}
438
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000439# generate GPT image and archive it
440gen_gpt_bin() {
Manish V Badarkhe048c9682024-01-22 10:11:49 +0000441 fip_bin="$1"
Xialin Liu33fc9812025-06-26 16:18:07 -0500442 bl2_fip_bin="$(dirname "$fip_bin")/bl2_$(basename "$fip_bin")"
Manish V Badarkhe048c9682024-01-22 10:11:49 +0000443 gpt_image="fip_gpt.bin"
444 # the FIP partition type is not standardized, so generate one
445 fip_type_uuid=`uuidgen --sha1 --namespace @dns --name "fip_type_uuid"`
Manish V Badarkhe02bcfb12024-01-25 14:14:31 +0000446 # metadata partition type UUID, specified by the document:
447 # Platform Security Firmware Update for the A-profile Arm Architecture
448 # version: 1.0BET0
449 metadata_type_uuid="8a7a84a0-8387-40f6-ab41-a8b9a5a60d23"
Manish V Badarkhe048c9682024-01-22 10:11:49 +0000450 location_uuid=`uuidgen`
451 FIP_A_uuid=`uuidgen`
452 FIP_B_uuid=`uuidgen`
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000453
Manish V Badarkhe048c9682024-01-22 10:11:49 +0000454 fip_max_size=$2
Manish V Badarkhee79bc952024-01-25 14:34:37 +0000455 partition_alignment=${3:-1}
Manish V Badarkhe048c9682024-01-22 10:11:49 +0000456 fip_bin_size=$(stat -c %s $fip_bin)
457 if [ $fip_max_size -lt $fip_bin_size ]; then
458 bberror "fip.bin ($fip_bin_size bytes) is larger than the GPT partition ($fip_max_size bytes)"
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000459 fi
460
Xialin Liu33fc9812025-06-26 16:18:07 -0500461 has_bl2_fip=0
462 if [ -f "$bl2_fip_bin" ]; then
463 has_bl2_fip=1
464 echo "BL2 FIP detected: $bl2_fip_bin"
465
466 bl2_fip_type_uuid=$(uuidgen --sha1 --namespace @dns --name "bl2_fip_type_uuid")
467 bl2_fip_bin_size=$(stat -c %s $bl2_fip_bin)
468 FIP_BL2_uuid=$(uuidgen)
469 bl2_fip_max_size=$fip_max_size
470
471 if [ $bl2_fip_max_size -lt $bl2_fip_bin_size ]; then
472 bberror "bl2_fip.bin ($bl2_fip_bin_size bytes) is larger than the GPT partition ($bl2_fip_max_size bytes)"
473 fi
474
475 else
476 echo "No BL2 FIP found. Proceeding without it."
477 fi
478
Manish V Badarkhe02bcfb12024-01-25 14:14:31 +0000479 # maximum metadata size 512B.
480 # This is the current size of the metadata rounded up to an integer number of sectors.
481 metadata_max_size=512
482 metadata_file="metadata.bin"
483
484 # generate_fwu_metadata.py --metadata_file <file> \
485 # --image_data "[(image_type_uuid, location_uuid, [image_uuid1, image_uuid2,...])]"
486 python3 $ci_root/generate_fwu_metadata.py --metadata_file $metadata_file \
487 --image_data "[('$fip_type_uuid', '$location_uuid', ['$FIP_A_uuid', '$FIP_B_uuid'])]"
488
Xialin Liu33fc9812025-06-26 16:18:07 -0500489 # create GPT image. If BL2_FIP does not exists, the GPT contains 1 FIP partition: FIP_A.
Manish V Badarkhe048c9682024-01-22 10:11:49 +0000490 # the GPT layout is the following:
491 #
492 # +----------------------+
493 # LBA0 | Protective MBR |
494 # ------------------------
495 # LBA1 | Primary GPT Header |
496 # ------------------------
497 # LBA34| FIP_A |
498 # ------------------------
Manish V Badarkhe02bcfb12024-01-25 14:14:31 +0000499 # | FIP_B |
500 # ------------------------
501 # | FWU-Metadata |
502 # ------------------------
503 # | Bkup-FWU-Metadata |
504 # ------------------------
Manish V Badarkhe048c9682024-01-22 10:11:49 +0000505 # LBA-1| Secondary GPT Header |
506 # +----------------------+
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000507
Xialin Liu33fc9812025-06-26 16:18:07 -0500508 # create GPT image. If BL2_FIP exists, The GPT contains 2 FIP partitions: FIP_BL2 and FIP_A.
509 # the GPT layout is the following:
510 #
511 # +----------------------+
512 # LBA0 | Protective MBR |
513 # ------------------------
514 # LBA1 | Primary GPT Header |
515 # ------------------------
516 # LBA34| FIP_BL2 |
517 # ------------------------
518 # | FIP_A |
519 # ------------------------
520 # | FIP_B |
521 # ------------------------
522 # | FWU-Metadata |
523 # ------------------------
524 # | Bkup-FWU-Metadata |
525 # ------------------------
526 # LBA-1| Secondary GPT Header |
527 # +----------------------+
528
Manish V Badarkhe048c9682024-01-22 10:11:49 +0000529 sector_size=512 # in bytes
530 gpt_header_size=33 # in sectors
531 num_sectors_fip=`expr $fip_max_size / $sector_size`
Manish V Badarkhe02bcfb12024-01-25 14:14:31 +0000532 num_sectors_metadata=`expr $metadata_max_size / $sector_size`
Xialin Liu33fc9812025-06-26 16:18:07 -0500533
Manish V Badarkhe048c9682024-01-22 10:11:49 +0000534 start_sector_1=`expr 1 + $gpt_header_size` # size of MBR is 1 sector
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000535
Xialin Liu33fc9812025-06-26 16:18:07 -0500536 if [ "$has_bl2_fip" -eq 1 ]; then
537 num_sectors_bl2_fip=$(expr $bl2_fip_max_size / $sector_size)
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000538
Xialin Liu33fc9812025-06-26 16:18:07 -0500539 start_sector_2=`expr $start_sector_1 + $num_sectors_bl2_fip`
540 start_sector_3=`expr $start_sector_2 + $num_sectors_fip`
541 start_sector_4=`expr $start_sector_3 + $num_sectors_fip`
542 start_sector_5=`expr $start_sector_4 + $num_sectors_metadata`
543 num_sectors_gpt=`expr $start_sector_5 + $num_sectors_metadata + $gpt_header_size`
544 gpt_size=`expr $num_sectors_gpt \* $sector_size`
545
546 # create raw image
547 dd if=/dev/zero of=$gpt_image bs=$gpt_size count=1
548
549 sgdisk $gpt_image \
550 --set-alignment $partition_alignment \
551 --disk-guid $location_uuid \
552 \
553 --new 1:$start_sector_1:+$num_sectors_bl2_fip \
554 --change-name 1:FIP_BL2 \
555 --typecode 1:$bl2_fip_type_uuid \
556 --partition-guid 1:$FIP_BL2_uuid \
557 \
558 --new 2:$start_sector_2:+$num_sectors_fip \
559 --change-name 2:FIP_A \
560 --typecode 2:$fip_type_uuid \
561 --partition-guid 2:$FIP_A_uuid \
562 \
563 --new 3:$start_sector_3:+$num_sectors_fip \
564 --change-name 3:FIP_B \
565 --typecode 3:$fip_type_uuid \
566 --partition-guid 3:$FIP_B_uuid \
567 \
568 --new 4:$start_sector_4:+$num_sectors_metadata \
569 --change-name 4:FWU-Metadata \
570 --typecode 4:$metadata_type_uuid \
571 \
572 --new 5:$start_sector_5:+$num_sectors_metadata \
573 --change-name 5:Bkup-FWU-Metadata \
574 --typecode 5:$metadata_type_uuid
575
576 else
577 start_sector_2=`expr $start_sector_1 + $num_sectors_fip`
578 start_sector_3=`expr $start_sector_2 + $num_sectors_fip`
579 start_sector_4=`expr $start_sector_3 + $num_sectors_metadata`
580 num_sectors_gpt=`expr $start_sector_4 + $num_sectors_metadata + $gpt_header_size`
581 gpt_size=`expr $num_sectors_gpt \* $sector_size`
582
583 # create raw image
584 dd if=/dev/zero of=$gpt_image bs=$gpt_size count=1
585
586 sgdisk $gpt_image \
587 --set-alignment $partition_alignment \
588 --disk-guid $location_uuid \
589 \
590 --new 1:$start_sector_1:+$num_sectors_fip \
591 --change-name 1:FIP_A \
592 --typecode 1:$fip_type_uuid \
593 --partition-guid 1:$FIP_A_uuid \
594 \
595 --new 2:$start_sector_2:+$num_sectors_fip \
596 --change-name 2:FIP_B \
597 --typecode 2:$fip_type_uuid \
598 --partition-guid 2:$FIP_B_uuid \
599 \
600 --new 3:$start_sector_3:+$num_sectors_metadata \
601 --change-name 3:FWU-Metadata \
602 --typecode 3:$metadata_type_uuid \
603 \
604 --new 4:$start_sector_4:+$num_sectors_metadata \
605 --change-name 4:Bkup-FWU-Metadata \
606 --typecode 4:$metadata_type_uuid
607
608 fi
Manish V Badarkhe048c9682024-01-22 10:11:49 +0000609
610 # populate the GPT partitions
Xialin Liu33fc9812025-06-26 16:18:07 -0500611 if [ "$has_bl2_fip" -eq 1 ]; then
612 dd if=$bl2_fip_bin of=$gpt_image bs=$sector_size seek=$(gdisk -l $gpt_image | grep " FIP_BL2$" | awk '{print $2}') count=$num_sectors_bl2_fip conv=notrunc
613 fi
Manish V Badarkhe048c9682024-01-22 10:11:49 +0000614 dd if=$fip_bin of=$gpt_image bs=$sector_size seek=$(gdisk -l $gpt_image | grep " FIP_A$" | awk '{print $2}') count=$num_sectors_fip conv=notrunc
Manish V Badarkhe02bcfb12024-01-25 14:14:31 +0000615 dd if=$fip_bin of=$gpt_image bs=$sector_size seek=$(gdisk -l $gpt_image | grep " FIP_B$" | awk '{print $2}') count=$num_sectors_fip conv=notrunc
616 dd if=$metadata_file of=$gpt_image bs=$sector_size seek=$(gdisk -l $gpt_image | grep " FWU-Metadata$" | awk '{print $2}') count=$num_sectors_metadata conv=notrunc
617 dd if=$metadata_file of=$gpt_image bs=$sector_size seek=$(gdisk -l $gpt_image | grep " Bkup-FWU-Metadata$" | awk '{print $2}') count=$num_sectors_metadata conv=notrunc
Manish V Badarkhe048c9682024-01-22 10:11:49 +0000618
619 echo "Built $gpt_image"
620
621 archive_file "$gpt_image"
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000622}
623
Govindraj Raja67501732023-09-22 16:27:06 -0500624#corrupt GPT image header and archive it
625corrupt_gpt_bin() {
626 bin="${1:?}"
laurenw-arm2c6665f2024-02-09 16:08:34 -0600627 corrupt_data=$2
Govindraj Raja67501732023-09-22 16:27:06 -0500628
laurenw-arm2c6665f2024-02-09 16:08:34 -0600629 # Check if parameters are provided
630 if [ -z "$bin" ] || [ -z "$corrupt_data" ]; then
631 echo "Usage: corrupt_gpt_bin <bin> <corrupt_data>"
632 return 1
633 fi
634
635 case "$corrupt_data" in
636 "header")
637 # Primary GPT header is present in LBA-1 second block after MBR
638 # empty the primary GPT header forcing to use backup GPT header
639 # and backup GPT entries.
640 seek=1
641 count=1
642 ;;
643 "partition-entries")
644 # GPT partition entry array is present in LBA-2 through LBA-34
645 # blocks empty the GPT partition entry array forcing to use backup
646 # GPT header and backup GPT entries.
647 seek=2
648 count=32
649 ;;
Manish V Badarkheb473c402024-02-14 16:50:08 +0000650 "fwu-metadata")
651 # Get the LBA number for the FWU metadata. Size of which is always
652 # 1 sector (512 bytes).
653 seek=$(gdisk -l $bin | grep " FWU-Metadata$" | awk '{print $2}')
654 count=1
655 ;;
Xialin Liu2d0a3032025-07-10 16:02:22 -0500656 "mbr")
657 seek=0
658 count=1
659 ;;
Xialin Liu67229612025-07-10 14:58:05 -0500660 "secondary-header")
661 # Secondary GPT header is present in LBA-1 last block before the
662 # end of the GPT image.
663 # Secondary GPT header is located after the backup FWU metadata,
664 # which is 1 sector in size.
665 seek=$(( $(gdisk -l "$bin" | grep " Bkup-FWU-Metadata$" | awk '{print $2}') + 1 ))
666 count=1
667 ;;
laurenw-arm2c6665f2024-02-09 16:08:34 -0600668 *)
Xialin Liu67229612025-07-10 14:58:05 -0500669 echo "Invalid $corrupt_data. Use 'header', 'partition-entries', 'fwu-metadata' or 'mbr', 'fwu-metadata' or 'secondary-header'."
laurenw-arm2c6665f2024-02-09 16:08:34 -0600670 return 1
671 ;;
672 esac
673
674 # Use parameters in the dd command
675 dd if=/dev/zero of=$bin bs=512 seek=$seek count=$count conv=notrunc
Govindraj Raja67501732023-09-22 16:27:06 -0500676}
677
Fathi Boudra422bf772019-12-02 11:10:16 +0200678set +u