blob: 301f97c8fec840c81c88c63db85ecf493883db6c [file] [log] [blame]
Brad Bishopbec4ebc2022-08-03 09:55:16 -04001# TC0 specific TFA configuration
2
Patrick Williams8dd68482022-10-04 07:57:18 -05003# Intermediate SHA with 2.7 baseline version
4SRCREV_tfa = "e95abc4c01822ef43e9e874d63d6596dc0b57279"
5PV = "2.7+git${SRCPV}"
6
Brad Bishopbec4ebc2022-08-03 09:55:16 -04007DEPENDS += "scp-firmware util-linux-native gptfdisk-native"
8
9FILESEXTRAPATHS:prepend := "${THISDIR}/files/tc:"
10SRC_URI:append = " \
11 file://0001-plat-tc-Increase-maximum-BL2-size.patch \
12 file://0002-Makefile-add-trusty_sp_fw_config-build-option.patch \
13 file://0003-fix-plat-arm-increase-sp-max-image-size.patch \
14 file://0004-fix-plat-tc-increase-tc_tzc_dram1_size.patch \
15 file://0005-feat-plat-tc-add-spmc-manifest-with-trusty-sp.patch \
16 file://0006-feat-plat-tc-update-dts-with-trusty-compatible-strin.patch \
Patrick Williams8dd68482022-10-04 07:57:18 -050017 file://0007-feat-arm-tc-Update-trusty-load-address-in-dts-files.patch \
18 file://0008-feat-plat-tc-add-firmware-update-secure-partition.patch \
19 file://0009-feat-plat-tc-reserve-4-MB-for-stmm-communication-use.patch \
Brad Bishopbec4ebc2022-08-03 09:55:16 -040020 file://generate_metadata.py \
21 "
22
23COMPATIBLE_MACHINE = "(tc?)"
24
25TFA_PLATFORM = "tc"
26TFA_BUILD_TARGET = "all fip"
27TFA_UBOOT = "1"
28TFA_INSTALL_TARGET = "bl1 fip"
29TFA_MBEDTLS = "1"
30TFA_DEBUG = "1"
31
32TFA_SPD = "spmd"
33TFA_SPMD_SPM_AT_SEL2 = "1"
34
35TFA_TARGET_PLATFORM:tc0 = "0"
36TFA_TARGET_PLATFORM:tc1 = "1"
37
38EXTRA_OEMAKE += "TARGET_PLATFORM=${TFA_TARGET_PLATFORM}"
39
40# Set optee as SP. Set spmc manifest and sp layout file to optee
41DEPENDS += "optee-os"
42
43TFA_SP_LAYOUT_FILE = "${RECIPE_SYSROOT}/lib/firmware/sp_layout.json"
44TFA_ARM_SPMC_MANIFEST_DTS = "plat/arm/board/tc/fdts/tc_spmc_optee_sp_manifest.dts"
45
46EXTRA_OEMAKE += "SCP_BL2=${RECIPE_SYSROOT}/firmware/scp_ramfw.bin"
47EXTRA_OEMAKE += "TRUSTED_BOARD_BOOT=1 GENERATE_COT=1 ARM_ROTPK_LOCATION=devel_rsa \
48 ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem"
49EXTRA_OEMAKE += "PSA_FWU_SUPPORT=1 ARM_GPT_SUPPORT=1"
Patrick Williams8dd68482022-10-04 07:57:18 -050050EXTRA_OEMAKE += "CTX_INCLUDE_MTE_REGS=1"
Brad Bishopbec4ebc2022-08-03 09:55:16 -040051
52do_generate_gpt() {
53 gpt_image="${BUILD_DIR}/fip_gpt.bin"
54 fip_bin="${BUILD_DIR}/fip.bin"
55 # the FIP partition type is not standardized, so generate one
56 fip_type_uuid=`uuidgen --sha1 --namespace @dns --name "fip_type_uuid"`
57 # metadata partition type UUID, specified by the document:
58 # Platform Security Firmware Update for the A-profile Arm Architecture
59 # version: 1.0BET0
60 metadata_type_uuid="8a7a84a0-8387-40f6-ab41-a8b9a5a60d23"
61 location_uuid=`uuidgen`
62 FIP_A_uuid=`uuidgen`
63 FIP_B_uuid=`uuidgen`
64
65 # maximum FIP size 4MB. This is the current size of the FIP rounded up to an integer number of MB.
66 fip_max_size=4194304
67 fip_bin_size=$(stat -c %s $fip_bin)
68 if [ $fip_max_size -lt $fip_bin_size ]; then
69 bberror "FIP binary ($fip_bin_size bytes) is larger than the GPT partition ($fip_max_size bytes)"
70 fi
71
72 # maximum metadata size 512B. This is the current size of the metadata rounded up to an integer number of sectors.
73 metadata_max_size=512
74 metadata_file="${BUILD_DIR}/metadata.bin"
75 python3 ${WORKDIR}/generate_metadata.py --metadata_file $metadata_file \
76 --img_type_uuids $fip_type_uuid \
77 --location_uuids $location_uuid \
78 --img_uuids $FIP_A_uuid $FIP_B_uuid
79
80 # create GPT image. The GPT contains 2 FIP partitions: FIP_A and FIP_B, and 2 metadata partitions: FWU-Metadata and Bkup-FWU-Metadata.
81 # the GPT layout is the following:
82 # -----------------------
83 # Protective MBR
84 # -----------------------
85 # Primary GPT Header
86 # -----------------------
87 # FIP_A
88 # -----------------------
89 # FIP_B
90 # -----------------------
91 # FWU-Metadata
92 # -----------------------
93 # Bkup-FWU-Metadata
94 # -----------------------
95 # Secondary GPT Header
96 # -----------------------
97
98 sector_size=512
99 gpt_header_size=33 # valid only for 512-byte sectors
100 num_sectors_fip=`expr $fip_max_size / $sector_size`
101 num_sectors_metadata=`expr $metadata_max_size / $sector_size`
102 start_sector_1=`expr 1 + $gpt_header_size` # size of MBR is 1 sector
103 start_sector_2=`expr $start_sector_1 + $num_sectors_fip`
104 start_sector_3=`expr $start_sector_2 + $num_sectors_fip`
105 start_sector_4=`expr $start_sector_3 + $num_sectors_metadata`
106 num_sectors_gpt=`expr $start_sector_4 + $num_sectors_metadata + $gpt_header_size`
107 gpt_size=`expr $num_sectors_gpt \* $sector_size`
108
109 # create raw image
110 dd if=/dev/zero of=$gpt_image bs=$gpt_size count=1
111
112 # create the GPT layout
113 sgdisk $gpt_image \
114 --set-alignment 1 \
115 --disk-guid $location_uuid \
116 \
117 --new 1:$start_sector_1:+$num_sectors_fip \
118 --change-name 1:FIP_A \
119 --typecode 1:$fip_type_uuid \
120 --partition-guid 1:$FIP_A_uuid \
121 \
122 --new 2:$start_sector_2:+$num_sectors_fip \
123 --change-name 2:FIP_B \
124 --typecode 2:$fip_type_uuid \
125 --partition-guid 2:$FIP_B_uuid \
126 \
127 --new 3:$start_sector_3:+$num_sectors_metadata \
128 --change-name 3:FWU-Metadata \
129 --typecode 3:$metadata_type_uuid \
130 \
131 --new 4:$start_sector_4:+$num_sectors_metadata \
132 --change-name 4:Bkup-FWU-Metadata \
133 --typecode 4:$metadata_type_uuid
134
135 # populate the GPT partitions
136 dd if=$fip_bin of=$gpt_image bs=$sector_size seek=$start_sector_1 count=$num_sectors_fip conv=notrunc
137 dd if=$fip_bin of=$gpt_image bs=$sector_size seek=$start_sector_2 count=$num_sectors_fip conv=notrunc
138 dd if=$metadata_file of=$gpt_image bs=$sector_size seek=$start_sector_3 count=$num_sectors_metadata conv=notrunc
139 dd if=$metadata_file of=$gpt_image bs=$sector_size seek=$start_sector_4 count=$num_sectors_metadata conv=notrunc
140}
141
142addtask do_generate_gpt after do_compile before do_install
143
144do_install:append() {
145 install -m 0644 ${BUILD_DIR}/fip_gpt.bin ${D}/firmware/fip_gpt-tc.bin
146 ln -sf fip_gpt-tc.bin ${D}/firmware/fip_gpt.bin
147}