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