Repository navigation
Expand file tree
/
Copy pathfvp_utils.sh
More file actions
706 lines (631 loc) · 27.7 KB
/
Copy pathfvp_utils.sh
File metadata and controls
706 lines (631 loc) · 27.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
#!/usr/bin/env bash
#
# Copyright (c) 2020-2026, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
set -u
bl1_addr="${bl1_addr:-0x0}"
bl31_addr="${bl31_addr:-0x04001000}"
bl32_addr="${bl32_addr:-0x04003000}"
bl33_addr="${bl33_addr:-0x88000000}"
dtb_addr="${dtb_addr:-0x82000000}"
fip_addr="${fip_addr:-0x08000000}"
initrd_addr="${initrd_addr:-0x84000000}"
kernel_addr="${kernel_addr:-0x80080000}"
boot_script_addr="${boot_script_addr:-0x8fb00000}"
el3_payload_addr="${el3_payload_addr:-0x80000000}"
# SPM requires following addresses for RESET_TO_BL31 case
spm_addr="${spm_addr:-0x6000000}"
spmc_manifest_addr="${spmc_addr:-0x0403f000}"
sp1_addr="${sp1_addr:-0x7000000}"
sp2_addr="${sp2_addr:-0x7100000}"
sp3_addr="${sp3_addr:-0x7200000}"
sp4_addr="${sp4_addr:-0x7600000}"
# SPM out directories
export spm_secure_out_dir="${spm_secure_out_dir:-secure_aem_v8a_fvp_vhe_clang}"
export spm_non_secure_out_dir="${spm_non_secure_out_dir:-aem_v8a_fvp_vhe_clang}"
ns_bl1u_addr="${ns_bl1u_addr:-0x0beb8000}"
fwu_fip_addr="${fwu_fip_addr:-0x08400000}"
backup_fip_addr="${backup_fip_addr:-0x09000000}"
romlib_addr="${romlib_addr:-0x03ff2000}"
uefi_ci_bin_url="${DOWNLOAD_SERVER_TF_A_URL}/drtm/FVP_AARCH64_EFI.fd"
uboot32_fip_url="$linaro_release/fvp32-latest-busybox-uboot/fip.bin"
optee_version="4.9.0"
# OP-TEE binaries can be bumped using the script in
# script/release/update-optee.sh.
if [[ "$test_config" == *handoff* ]]; then
if [[ "$test_config" == *-lts-v2.14* ]]; then
optee_version="4.7.0"
# These configs predate the later handoff binary refresh on `master`.
optee_path="${DOWNLOAD_SERVER_TF_A_URL}/optee/${optee_version}/handoff"
uboot_url="${DOWNLOAD_SERVER_TF_A_URL}/handoff/fvp/u-boot.bin"
else
optee_path="${DOWNLOAD_SERVER_TF_A_URL}/optee/${optee_version}/handoff"
uboot_url="${DOWNLOAD_SERVER_TF_A_URL}/handoff/fvp/u-boot-89d1016b2a0.bin"
fi
else
optee_path="$DOWNLOAD_SERVER_TF_A_URL/optee/${optee_version}"
uboot_url="${DOWNLOAD_SERVER_TF_A_URL}/linux_boot/fvp/u-boot.bin"
fi
uboot_script_url="${DOWNLOAD_SERVER_TF_A_URL}/linux_boot/fvp/boot.scr"
rootfs_url="${DOWNLOAD_SERVER_TF_A_URL}/linux_boot/fvp/rootfs.ext4"
# Default FVP model variables
default_model_dtb="dtb.bin"
# FVP containers and model paths
fvp_base_revc_aemva="fvp:fvp_base_revc_aemva_${model_version}_${model_build}_linux_x86;/opt/model/FVP_Base_RevC_AEMvA_${model_version}_${model_build}/bin"
fvp_base_revc_aemva_gicv5="fvp:fvp_base_revc_aemva_gicv5_${model_version}_${model_build}_linux_x86;/opt/model/FVP_Base_RevC_AEMvA_GICv5_${model_version}_${model_build}/bin"
fvp_arm_std_library="fvp:fvp_arm_std_library_${model_version}_${model_build};/opt/model/FVP_ARM_Std_Library_${model_version}_${model_build}"
# FVP associate array, run_config are keys and fvp container parameters are the values
# Container parameters syntax: <model name>;<model dir>;<model bin>
# FIXMEs: fix those ;;; values with real values
declare -A fvp_models
fvp_models=(
[base-aemva-revb]="${fvp_arm_std_library};FVP_Base_AEMvA-AEMvA"
[base-aemva]="${fvp_base_revc_aemva};FVP_Base_RevC-2xAEMvA"
[base-aemva-gicv5]="${fvp_base_revc_aemva_gicv5};FVP_Base_RevC-2xAEMvA_GICV5"
[cortex-a32x4]="${fvp_arm_std_library};FVP_Base_Cortex-A32"
[cortex-a35x4]="${fvp_arm_std_library};FVP_Base_Cortex-A35"
[cortex-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A53"
[cortex-a55x4]="${fvp_arm_std_library};FVP_Base_Cortex-A55"
[cortex-a57x1-a53x1]="${fvp_arm_std_library};FVP_Base_Cortex-A57x1-A53x1"
[cortex-a57x2-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x2-A53x4"
[cortex-a57x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57"
[cortex-a57x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4-A53x4"
[cortex-a65aex8]="${fvp_arm_std_library};FVP_Base_Cortex-A65AE"
[cortex-a65x4]="${fvp_arm_std_library};FVP_Base_Cortex-A65"
[cortex-a72x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72"
[cortex-a73x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73"
[cortex-a73x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4-A53x4"
[cortex-a75x4]="${fvp_arm_std_library};FVP_Base_Cortex-A75"
[cortex-a76aex4]="${fvp_arm_std_library};FVP_Base_Cortex-A76AE"
[cortex-a76x4]="${fvp_arm_std_library};FVP_Base_Cortex-A76"
[cortex-a77x4]="${fvp_arm_std_library};FVP_Base_Cortex-A77"
[cortex-a78x4]="${fvp_arm_std_library};FVP_Base_Cortex-A78"
[cortex-a78aex4]="${fvp_arm_std_library};FVP_Base_Cortex-A78AE"
[cortex-a78cx4]="${fvp_arm_std_library};FVP_Base_Cortex-A78C"
[cortex-x2]="${fvp_arm_std_library};FVP_Base_Cortex-X2"
[cortex-x4]="${fvp_arm_std_library};FVP_Base_Cortex-X4"
[cortex-x925]="${fvp_arm_std_library};FVP_Base_Cortex-X925"
[cortex-a710x8]="${fvp_arm_std_library};FVP_Base_Cortex-A710"
[neoverse_e1]="${fvp_arm_std_library};FVP_Base_Neoverse-E1"
[neoverse_n1]="${fvp_arm_std_library};FVP_Base_Neoverse-N1"
[neoverse_n2]="${fvp_arm_std_library};FVP_Base_Neoverse-N2"
[neoverse-v1x4]="${fvp_arm_std_library};FVP_Base_Neoverse-V1"
[c1-ultra]="${fvp_arm_std_library};FVP_Base_C1-Ultra"
[c1-pro]="${fvp_arm_std_library};FVP_Base_C1-Pro"
[c1-premium]="${fvp_arm_std_library};FVP_Base_C1-Premium"
[c1-nano]="${fvp_arm_std_library};FVP_Base_C1-Nano"
[c1-pro+ultra]="${fvp_arm_std_library};FVP_Base_C1-Pro+C1-Ultra"
[tc4]="${fvp_arm_std_library};FVP_RD_LUMEX_1"
)
# FVP Kernel URLs
declare -A kernel_list
kernel_list=(
[fvp-aarch32-zimage]="$linaro_release/fvp32-latest-busybox-uboot/Image"
[fvp-busybox-uboot]="$linaro_release/fvp-latest-busybox-uboot/Image"
[fvp-oe-uboot32]="$linaro_release/fvp32-latest-oe-uboot/Image"
[fvp-oe-uboot]="$linaro_release/fvp-latest-oe-uboot/Image"
[fvp-quad-busybox-uboot]="$DOWNLOAD_SERVER_TF_A_URL/quad_cluster/Image"
)
# FVP initrd URLs
declare -A initrd_list
initrd_list=(
[aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img"
[dummy-ramdisk]="$linaro_release/fvp-latest-oe-uboot/ramdisk.img"
[dummy-ramdisk32]="$linaro_release/fvp32-latest-oe-uboot/ramdisk.img"
[default]="$linaro_release/fvp-latest-busybox-uboot/ramdisk.img"
)
# For Measured Boot tests using a TA based on OPTEE, it is necessary to use a
# specific build rather than the default one generated by Jenkins.
get_ftpm_optee_bin() {
url="$DOWNLOAD_SERVER_TF_A_URL/ftpm/optee/tee-header_v2.bin" \
saveas="bl32.bin" fetch_file
archive_file "bl32.bin"
url="$DOWNLOAD_SERVER_TF_A_URL/ftpm/optee/tee-pager_v2.bin" \
saveas="bl32_extra1.bin" fetch_file
archive_file "bl32_extra1.bin"
# tee-pageable_v2.bin is just a empty file, named as bl32_extra2.bin,
# so just create the file
touch "bl32_extra2.bin"
archive_file "bl32_extra2.bin"
}
get_dtb() {
local dtb_type="${dtb_type:?}"
local dtb_url
local dtb_saveas="$archive/dtb.bin"
local cc="$(get_tf_opt CROSS_COMPILE)"
local pp_flags="-P -nostdinc -undef -x assembler-with-cpp"
case "$dtb_type" in
"fvp-base-quad-cluster-gicv3-psci")
# Get the quad-cluster FDT from pdsw area
dtb_url="$DOWNLOAD_SERVER_TF_A_URL/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb"
url="$dtb_url" saveas="$dtb_saveas" fetch_file
;;
*)
# Preprocess DTS file
${cc}gcc -E ${pp_flags} -I"$tf_root/fdts" -I"$tf_root/include" \
-o "$archive/${dtb_type}.pre.dts" \
"$tf_root/fdts/${dtb_type}.dts"
# Generate DTB file from DTS
dtc -I dts -O dtb \
"$archive/${dtb_type}.pre.dts" -o "$dtb_saveas"
esac
archive_file "$dtb_saveas"
}
get_rootfs() {
local tmpdir
tmpdir="$(mktempdir)"
pushd "$tmpdir"
url="$rootfs_url" saveas="rootfs.bin" fetch_file
# Possibly, the filesystem image we just downloaded is compressed.
# Decompress it if required.
if file "rootfs.bin" | grep -iq 'gzip compressed data'; then
echo "Decompressing root file system image rootfs.bin ..."
gunzip --stdout "rootfs.bin" > uncompressed_fs.bin
mv uncompressed_fs.bin "rootfs.bin"
fi
archive_file "rootfs.bin"
popd
}
# Generates the final YAML-based LAVA job definition from a template file.
#
# The job definition template is expanded with visibility of all variables that
# are available from within the function, including those with local scope.
gen_fvp_yaml() {
local model="${model:?}"
local yaml_template_file="$workspace/fvp_template.yaml"
local yaml_file="$workspace/fvp.yaml"
local yaml_job_file="$workspace/job.yaml"
local lava_model_params="$workspace/lava_model_params"
local model_params="${fvp_models[$model]}"
local model_name="$(echo "${model_params}" | awk -F ';' '{print $1}')"
local model_dir="$(echo "${model_params}" | awk -F ';' '{print $2}')"
local model_bin="$(echo "${model_params}" | awk -F ';' '{print $3}')"
if upon "$local_ci"; then
set_model_path "$model_bin"
fi
# this function expects a template, fail if it is not present
if [ ! -f "$yaml_template_file" ]; then
echo "ERROR: gen_fvp_yaml: template $yaml_template_file not available."
exit 1
fi
# model params are required for correct yaml creation, quit if empty
if [ -z "${model_name}" ]; then
echo "FVP model param 'model_name' variable empty, yaml not produced"
return
elif [ -z "${model_dir}" ]; then
echo "FVP model param 'model_dir' variable empty, yaml not produced"
return
elif [ -z "${model_bin}" ]; then
echo "FVP model param 'model_bin' variable empty, yaml not produced"
return
fi
echo "FVP model params: model_name=$model_name model_dir=$model_dir model_bin=$model_bin"
# optional parameters, defaults to globals
local model_dtb="${model_dtb:-$default_model_dtb}"
if [ -n "${GERRIT_CHANGE_NUMBER}" ]; then
local gerrit_url="https://review.trustedfirmware.org/c/${GERRIT_CHANGE_NUMBER}/${GERRIT_PATCHSET_NUMBER}"
elif [ -n "${GERRIT_REFSPEC}" ]; then
local gerrit_url=$(echo ${GERRIT_REFSPEC} |
awk -F/ '{print "https://review.trustedfirmware.org/c/" $4 "/" $5}')
fi
docker_registry="${docker_registry:-}"
docker_registry="$(docker_registry_append)"
docker_name="${docker_registry}$model_name"
prompt1='/ #'
prompt2='root@genericarmv8:~#'
version_string="\"Fast Models"' [^\\n]+'"\""
test_config="${TEST_CONFIG}"
declare -A fvp_artefact_filters=(
[backup_fip]="backup_fip.bin"
[bl1]="bl1.bin"
[bl2]="bl2.bin"
[bl31]="bl31.bin"
[bl32]="bl32.bin"
[busybox]="busybox.bin"
[boot_script]="boot_script.bin"
[cactus_primary]="cactus-primary.pkg"
[cactus_secondary]="cactus-secondary.pkg"
[cactus_tertiary]="cactus-tertiary.pkg"
[coverage_trace_plugin]="coverage_trace.so"
[dtb]="dtb.bin"
[el3_payload]="el3_payload.bin"
[flash0]="flash0"
[flash1]="flash1"
[fip_gpt]="fip_gpt.bin"
[fip]="fip.bin"
[fvp_spmc_manifest_dtb]="=fvp_spmc_manifest.dtb"
[fwu_fip]="fwu_fip.bin"
[hafnium]="hafnium.bin"
[image]="kernel.bin"
[ivy]="ivy.pkg"
[manifest_dtb]="=manifest.dtb"
[mcp_fw]="mcp_fw.bin"
[mcp_ram]="mcp_ram.bin"
[mcp_rom_hyphen]="mcp-rom.bin"
[mcp_rom]="mcp_rom.bin"
[ns_bl1u]="ns_bl1u.bin"
[ns_bl2u]="ns_bl2u.bin"
[ramdisk]="initrd.bin|initrd.img"
[romlib]="romlib.bin"
[rootfs]="rootfs.bin"
[host_flash_fip]="host_flash_fip.bin"
[rse_flash]="rse_flash.bin"
[rse_rom]="rse_rom.bin"
[rse_encrypted_cm_provisioning_bundle_0]="rse_encrypted_cm_provisioning_bundle_0.bin"
[rse_encrypted_dm_provisioning_bundle]="rse_encrypted_dm_provisioning_bundle.bin"
[rse_combined_provisioning_message]="rse_combined_provisioning_message.bin"
[scp_fw]="scp_fw.bin"
[scp_ram_hyphen]="scp-ram.bin"
[scp_ram]="scp_ram.bin"
[scp_rom_hyphen]="scp-rom.bin"
[scp_rom]="scp_rom.bin"
[secure_hafnium]="secure_hafnium.bin"
[spm]="spm.bin"
[tc_fitimage]="tc_fitimage.bin"
[tftf]="tftf.bin"
[tl]="tl.bin"
[tmp]="tmp.bin"
[uboot]="uboot.bin"
[gicv5_config]="gicv5_config.yaml"
)
declare -A fvp_artefact_urls=(
[backup_fip]="$(gen_bin_url backup_fip.bin)"
[bl1]="$(gen_bin_url bl1.bin)"
[bl2]="$(gen_bin_url bl2.bin)"
[bl31]="$(gen_bin_url bl31.bin)"
[bl32]="$(gen_bin_url bl32.bin)"
[busybox]="$(gen_bin_url busybox.bin.gz)"
[boot_script]="$(gen_bin_url boot_script.bin)"
[cactus_primary]="$(gen_bin_url cactus-primary.pkg)"
[cactus_secondary]="$(gen_bin_url cactus-secondary.pkg)"
[cactus_tertiary]="$(gen_bin_url cactus-tertiary.pkg)"
[coverage_trace_plugin]="$(gen_cc_url)"
[dtb]="$(gen_bin_url ${model_dtb})"
[el3_payload]="$(gen_bin_url el3_payload.bin)"
[flash0]="$(gen_bin_url flash0)"
[flash1]="$(gen_bin_url flash1)"
[fip]="$(gen_bin_url fip.bin)"
[fip_gpt]="$(gen_bin_url fip_gpt.bin)"
[fvp_spmc_manifest_dtb]="$(gen_bin_url fvp_spmc_manifest.dtb)"
[fwu_fip]="$(gen_bin_url fwu_fip.bin)"
[hafnium]="$(gen_bin_url hafnium.bin)"
[image]="$(gen_bin_url kernel.bin)"
[ivy]="$(gen_bin_url ivy.pkg)"
[manifest_dtb]="$(gen_bin_url manifest.dtb)"
[mcp_fw]="$(gen_bin_url mcp_fw.bin)"
[mcp_ram]="$(gen_bin_url mcp_ram.bin)"
[mcp_rom]="$(gen_bin_url mcp_rom.bin)"
[mcp_rom_hyphen]="$(gen_bin_url mcp-rom.bin)"
[ns_bl1u]="$(gen_bin_url ns_bl1u.bin)"
[ns_bl2u]="$(gen_bin_url ns_bl2u.bin)"
[ramdisk]="$(gen_bin_url initrd.bin)"
[romlib]="$(gen_bin_url romlib.bin)"
[rootfs]="$(gen_bin_url rootfs.bin.gz)"
[host_flash_fip]="$(gen_bin_url host_flash_fip.bin)"
[rse_flash]="$(gen_bin_url rse_flash.bin)"
[rse_rom]="$(gen_bin_url rse_rom.bin)"
[rse_encrypted_cm_provisioning_bundle_0]="$(gen_bin_url rse_encrypted_cm_provisioning_bundle_0.bin)"
[rse_encrypted_dm_provisioning_bundle]="$(gen_bin_url rse_encrypted_dm_provisioning_bundle.bin)"
[rse_combined_provisioning_message]="$(gen_bin_url rse_combined_provisioning_message.bin)"
[secure_hafnium]="$(gen_bin_url secure_hafnium.bin)"
[scp_fw]="$(gen_bin_url scp_fw.bin)"
[scp_ram]="$(gen_bin_url scp_ram.bin)"
[scp_ram_hyphen]="$(gen_bin_url scp-ram.bin)"
[scp_rom]="$(gen_bin_url scp_rom.bin)"
[scp_rom_hyphen]="$(gen_bin_url scp-rom.bin)"
[spm]="$(gen_bin_url spm.bin)"
[tc_fitimage]="$(gen_bin_url tc_fitimage.bin)"
[tftf]="$(gen_bin_url tftf.bin)"
[tl]="$(gen_bin_url tl.bin)"
[tmp]="$(gen_bin_url tmp.bin)"
[uboot]="$(gen_bin_url uboot.bin)"
[gicv5_config]="$(gen_bin_url gicv5_config.yaml)"
)
# In LAVA we don't provide the paths to the artefacts directly, but instead
# use macros of the form `{XYZ}`. This is a list of regular expression
# replacements to run on the model parameters file before we add them to the
# LAVA job definition.
declare -A fvp_artefact_macros=(
["[= ]backup_fip.bin"]="={BACKUP_FIP}"
["[= ]bl1.bin"]="={BL1}"
["[= ]bl2.bin"]="={BL2}"
["[= ]bl31.bin"]="={BL31}"
["[= ]bl32.bin"]="={BL32}"
["[= ]boot_script.bin"]="={BOOT_SCRIPT}"
["[= ]cactus-primary.pkg"]="={CACTUS_PRIMARY}"
["[= ]cactus-secondary.pkg"]="={CACTUS_SECONDARY}"
["[= ]cactus-tertiary.pkg"]="={CACTUS_TERTIARY}"
["[= ].*coverage_trace.so"]="={COVERAGE_TRACE_PLUGIN}"
["[= ]fvp_spmc_manifest.dtb"]="={FVP_SPMC_MANIFEST_DTB}"
["[= ]busybox.bin"]="={BUSYBOX}"
["[= ]dtb.bin"]="={DTB}"
["[= ]el3_payload.bin"]="={EL3_PAYLOAD}"
["[= ]flash0"]="={FLASH0}"
["[= ]flash1"]="={FLASH1}"
["[= ]fip_gpt.bin"]="={FIP_GPT}"
["[= ]fwu_fip.bin"]="={FWU_FIP}"
["[= ]fip.bin"]="={FIP}"
["[= ].*/hafnium.bin"]="={HAFNIUM}"
["[= ]kernel.bin"]="={IMAGE}"
["[= ]ivy.pkg"]="={IVY}"
["[= ]manifest.dtb"]="={MANIFEST_DTB}"
["[= ]mcp_fw.bin"]="={MCP_FW}"
["[= ]mcp_ram.bin"]="={MCP_RAM}"
["[= ]mcp_rom.bin"]="={MCP_ROM}"
["[= ]mcp-rom.bin"]="={MCP_ROM_HYPHEN}"
["[= ]ns_bl1u.bin"]="={NS_BL1U}"
["[= ]ns_bl2u.bin"]="={NS_BL2U}"
["[= ]initrd.bin"]="={RAMDISK}"
["[= ]initrd.img"]="={RAMDISK}"
["[= ]romlib.bin"]="={ROMLIB}"
["[= ]rootfs.bin"]="={ROOTFS}"
["[= ]host_flash_fip.bin"]="={HOST_FLASH_FIP}"
["[= ]rse_flash.bin"]="={RSE_FLASH}"
["[= ]rse_rom.bin"]="={RSE_ROM}"
["[= ]rse_encrypted_cm_provisioning_bundle_0.bin"]="={RSE_ENCRYPTED_CM_PROVISIONING_BUNDLE_0}"
["[= ]rse_encrypted_dm_provisioning_bundle.bin"]="={RSE_ENCRYPTED_DM_PROVISIONING_BUNDLE}"
["[= ]rse_combined_provisioning_message.bin"]="={RSE_COMBINED_PROVISIONING_MESSAGE}"
["[= ].*/secure_hafnium.bin"]="={SECURE_HAFNIUM}"
["[= ]scp_fw.bin"]="={SCP_FW}"
["[= ]scp_ram.bin"]="={SCP_RAM}"
["[= ]scp-ram.bin"]="={SCP_RAM_HYPHEN}"
["[= ]scp_rom.bin"]="={SCP_ROM}"
["[= ]scp-rom.bin"]="={SCP_ROM_HYPHEN}"
["[= ]spm.bin"]="={SPM}"
["[= ]tc_fitimage.bin"]="={TC_FITIMAGE}"
["[= ]tftf.bin"]="={TFTF}"
["[= ]tl.bin"]="={TL}"
["[= ].*/tmp.bin"]="={TMP}"
["[= ]uboot.bin"]="={UBOOT}"
["gicv5_config_file=[^\\n]*gicv5_config\\.yaml"]="gicv5_config_file={GICV5_CONFIG}"
)
declare -a fvp_artefacts
filter_artefacts fvp_artefacts fvp_artefact_filters
lava_model_params="${lava_model_params}" \
gen_lava_model_params fvp_artefact_macros
yaml_template_file="$yaml_template_file" \
yaml_file="$yaml_file" \
yaml_job_file="$yaml_job_file" \
gen_lava_job_def fvp_artefacts fvp_artefact_urls
}
docker_registry_append() {
# if docker_registry is empty, just use local docker registry
[ -z "$docker_registry" ] && return
local last=-1
local last_char="${docker_registry:last}"
if [ "$last_char" != '/' ]; then
docker_registry="${docker_registry}/";
fi
echo "$docker_registry"
}
# generate GPT image and archive it
gen_gpt_bin() {
fip_bin="$1"
bl2_fip_bin="$(dirname "$fip_bin")/bl2_$(basename "$fip_bin")"
gpt_image="fip_gpt.bin"
# the FIP partition type is not standardized, so generate one
fip_type_uuid=`uuidgen --sha1 --namespace @dns --name "fip_type_uuid"`
# metadata partition type UUID, specified by the document:
# Platform Security Firmware Update for the A-profile Arm Architecture
# version: 1.0BET0
metadata_type_uuid="8a7a84a0-8387-40f6-ab41-a8b9a5a60d23"
location_uuid=`uuidgen`
FIP_A_uuid=`uuidgen`
FIP_B_uuid=`uuidgen`
private_metadata_uuid=`uuidgen`
fip_max_size=$2
partition_alignment=${3:-1}
fip_bin_size=$(stat -c %s $fip_bin)
if [ $fip_max_size -lt $fip_bin_size ]; then
bberror "fip.bin ($fip_bin_size bytes) is larger than the GPT partition ($fip_max_size bytes)"
fi
has_bl2_fip=0
if [ -f "$bl2_fip_bin" ]; then
has_bl2_fip=1
echo "BL2 FIP detected: $bl2_fip_bin"
bl2_fip_type_uuid=$(uuidgen --sha1 --namespace @dns --name "bl2_fip_type_uuid")
bl2_fip_bin_size=$(stat -c %s $bl2_fip_bin)
FIP_BL2_uuid=$(uuidgen)
bl2_fip_max_size=$fip_max_size
if [ $bl2_fip_max_size -lt $bl2_fip_bin_size ]; then
bberror "bl2_fip.bin ($bl2_fip_bin_size bytes) is larger than the GPT partition ($bl2_fip_max_size bytes)"
fi
else
echo "No BL2 FIP found. Proceeding without it."
fi
# maximum metadata size 512B.
# This is the current size of the metadata rounded up to an integer number of sectors.
metadata_max_size=512
metadata_file="metadata.bin"
# private metadata maximum size is the same as for the normal metadata
private_metadata_max_size=512
# generate_fwu_metadata.py --metadata_file <file> \
# --image_data "[(image_type_uuid, location_uuid, [image_uuid1, image_uuid2,...])]"
python3 $ci_root/generate_fwu_metadata.py --metadata_file $metadata_file \
--image_data "[('$fip_type_uuid', '$location_uuid', ['$FIP_A_uuid', '$FIP_B_uuid'])]"
# create GPT image. If BL2_FIP does not exists, the GPT contains 1 FIP partition: FIP_A.
# the GPT layout is the following:
#
# +----------------------+
# LBA0 | Protective MBR |
# ------------------------
# LBA1 | Primary GPT Header |
# ------------------------
# LBA34| FIP_A |
# ------------------------
# | FIP_B |
# ------------------------
# | FWU-Metadata |
# ------------------------
# | Bkup-FWU-Metadata |
# ------------------------
# | private_metadata_1 |
# ------------------------
# LBA-1| Secondary GPT Header |
# +----------------------+
# create GPT image. If BL2_FIP exists, The GPT contains 2 FIP partitions: FIP_BL2 and FIP_A.
# the GPT layout is the following:
#
# +----------------------+
# LBA0 | Protective MBR |
# ------------------------
# LBA1 | Primary GPT Header |
# ------------------------
# LBA34| FIP_BL2 |
# ------------------------
# | FIP_A |
# ------------------------
# | FIP_B |
# ------------------------
# | FWU-Metadata |
# ------------------------
# | Bkup-FWU-Metadata |
# ------------------------
# | private_metadata_1 |
# ------------------------
# LBA-1| Secondary GPT Header |
# +----------------------+
sector_size=512 # in bytes
gpt_header_size=33 # in sectors
num_sectors_fip=`expr $fip_max_size / $sector_size`
num_sectors_metadata=`expr $metadata_max_size / $sector_size`
num_sectors_private_metadata=`expr $private_metadata_max_size / $sector_size`
start_sector_1=`expr 1 + $gpt_header_size` # size of MBR is 1 sector
if [ "$has_bl2_fip" -eq 1 ]; then
num_sectors_bl2_fip=$(expr $bl2_fip_max_size / $sector_size)
start_sector_2=`expr $start_sector_1 + $num_sectors_bl2_fip`
start_sector_3=`expr $start_sector_2 + $num_sectors_fip`
start_sector_4=`expr $start_sector_3 + $num_sectors_fip`
start_sector_5=`expr $start_sector_4 + $num_sectors_metadata`
start_sector_6=`expr $start_sector_5 + $num_sectors_metadata`
num_sectors_gpt=`expr $start_sector_6 + $num_sectors_private_metadata + $gpt_header_size`
gpt_size=`expr $num_sectors_gpt \* $sector_size`
# create raw image
dd if=/dev/zero of=$gpt_image bs=$gpt_size count=1
sgdisk $gpt_image \
--set-alignment $partition_alignment \
--disk-guid $location_uuid \
\
--new 1:$start_sector_1:+$num_sectors_bl2_fip \
--change-name 1:FIP_BL2 \
--typecode 1:$bl2_fip_type_uuid \
--partition-guid 1:$FIP_BL2_uuid \
\
--new 2:$start_sector_2:+$num_sectors_fip \
--change-name 2:FIP_A \
--typecode 2:$fip_type_uuid \
--partition-guid 2:$FIP_A_uuid \
\
--new 3:$start_sector_3:+$num_sectors_fip \
--change-name 3:FIP_B \
--typecode 3:$fip_type_uuid \
--partition-guid 3:$FIP_B_uuid \
\
--new 4:$start_sector_4:+$num_sectors_metadata \
--change-name 4:FWU-Metadata \
--typecode 4:$metadata_type_uuid \
\
--new 5:$start_sector_5:+$num_sectors_metadata \
--change-name 5:Bkup-FWU-Metadata \
--typecode 5:$metadata_type_uuid \
\
--new 6:$start_sector_6:+$num_sectors_private_metadata \
--change-name 6:private_metadata_1 \
--typecode 6:$private_metadata_uuid
else
start_sector_2=`expr $start_sector_1 + $num_sectors_fip`
start_sector_3=`expr $start_sector_2 + $num_sectors_fip`
start_sector_4=`expr $start_sector_3 + $num_sectors_metadata`
start_sector_5=`expr $start_sector_4 + $num_sectors_metadata`
num_sectors_gpt=`expr $start_sector_5 + $num_sectors_private_metadata + $gpt_header_size`
gpt_size=`expr $num_sectors_gpt \* $sector_size`
# create raw image
dd if=/dev/zero of=$gpt_image bs=$gpt_size count=1
sgdisk $gpt_image \
--set-alignment $partition_alignment \
--disk-guid $location_uuid \
\
--new 1:$start_sector_1:+$num_sectors_fip \
--change-name 1:FIP_A \
--typecode 1:$fip_type_uuid \
--partition-guid 1:$FIP_A_uuid \
\
--new 2:$start_sector_2:+$num_sectors_fip \
--change-name 2:FIP_B \
--typecode 2:$fip_type_uuid \
--partition-guid 2:$FIP_B_uuid \
\
--new 3:$start_sector_3:+$num_sectors_metadata \
--change-name 3:FWU-Metadata \
--typecode 3:$metadata_type_uuid \
\
--new 4:$start_sector_4:+$num_sectors_metadata \
--change-name 4:Bkup-FWU-Metadata \
--typecode 4:$metadata_type_uuid \
\
--new 5:$start_sector_5:+$num_sectors_private_metadata \
--change-name 5:private_metadata_1 \
--typecode 5:$private_metadata_uuid
fi
# populate the GPT partitions
if [ "$has_bl2_fip" -eq 1 ]; then
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
fi
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
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
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
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
echo "Built $gpt_image"
archive_file "$gpt_image"
}
#corrupt GPT image header and archive it
corrupt_gpt_bin() {
bin="${1:?}"
corrupt_data=$2
# Check if parameters are provided
if [ -z "$bin" ] || [ -z "$corrupt_data" ]; then
echo "Usage: corrupt_gpt_bin <bin> <corrupt_data>"
return 1
fi
case "$corrupt_data" in
"header")
# Primary GPT header is present in LBA-1 second block after MBR
# empty the primary GPT header forcing to use backup GPT header
# and backup GPT entries.
seek=1
count=1
;;
"partition-entries")
# GPT partition entry array is present in LBA-2 through LBA-34
# blocks empty the GPT partition entry array forcing to use backup
# GPT header and backup GPT entries.
seek=2
count=32
;;
"fwu-metadata")
# Get the LBA number for the FWU metadata. Size of which is always
# 1 sector (512 bytes).
seek=$(gdisk -l $bin | grep " FWU-Metadata$" | awk '{print $2}')
count=1
;;
"mbr")
seek=0
count=1
;;
"secondary-header")
# Secondary GPT header is present in LBA-1 last block before the
# end of the GPT image.
seek=$(( $(gdisk -l "$bin" | awk '/^Disk .* sectors,/ {print $3; exit}') - 1 ))
count=1
;;
*)
echo "Invalid $corrupt_data. Use 'header', 'partition-entries', 'fwu-metadata' or 'mbr', 'fwu-metadata' or 'secondary-header'."
return 1
;;
esac
# Use parameters in the dd command
dd if=/dev/zero of=$bin bs=512 seek=$seek count=$count conv=notrunc
}
set +u