blob: 8147bc6c87fa5dbb809e8b4ef2c509d600eeeff2 [file] [log] [blame]
Balint Dobszayd777a3e2020-07-15 15:53:05 +02001DTS ?= optee_ffa
2DTS_PATH ?= $(BUILD_PATH)/fvp
3USE_FVP_BASE_PLAT ?= 1
4
Balint Dobszayd520b002021-03-29 18:54:30 +02005# Use "embedded" or "fip"
6SP_PACKAGING_METHOD ?= embedded
7
Balint Dobszayd777a3e2020-07-15 15:53:05 +02008OPTEE_OS_COMMON_EXTRA_FLAGS += CFG_CORE_SEL1_SPMC=y CFG_CORE_FFA=y
9OPTEE_OS_COMMON_EXTRA_FLAGS += CFG_WITH_SP=y
Gyorgy Szingf3a67122021-06-28 17:47:14 +020010OPTEE_OS_COMMON_EXTRA_FLAGS += CFG_CORE_HEAP_SIZE=131072
Balint Dobszayd777a3e2020-07-15 15:53:05 +020011OPTEE_OS_COMMON_EXTRA_FLAGS += O=out/arm
Jelle Selsd58d0272021-06-04 10:36:22 +020012SP_EVENT_LOG ?=y
13ifeq (y,$(SP_EVENT_LOG))
14TF_A_FLAGS ?= \
15 ARM_TSP_RAM_LOCATION=tdram \
16 BL32=$(OPTEE_OS_PAGER_V2_BIN) \
17 BL33=$(EDK2_BIN) \
18 DEBUG=0 \
19 PLAT=fvp \
20 SPMD_SPM_AT_SEL2=0 \
21 MBEDTLS_DIR=$(ROOT)/mbedtls \
22 ARM_ROTPK_LOCATION=devel_rsa \
23 ARM_TSP_RAM_LOCATION=tdram \
24 FVP_USE_GIC_DRIVER=FVP_GICV3 \
25 GENERATE_COT=1 \
26 MEASURED_BOOT=1 \
27 PLAT=fvp \
28 ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem \
29 TPM_HASH_ALG=sha256 \
30 TRUSTED_BOARD_BOOT=1 \
31 EVENT_LOG_LEVEL=20 \
32 BL2_optee=y \
33 SPD=spmd
34else
Balint Dobszayd777a3e2020-07-15 15:53:05 +020035TF_A_FLAGS ?= \
36 ARM_TSP_RAM_LOCATION=tdram \
37 BL32=$(OPTEE_OS_PAGER_V2_BIN) \
38 BL33=$(EDK2_BIN) \
39 DEBUG=$(DEBUG) \
40 PLAT=fvp \
41 SPD=spmd \
42 SPMD_SPM_AT_SEL2=0
Jelle Selsd58d0272021-06-04 10:36:22 +020043endif
Balint Dobszayd777a3e2020-07-15 15:53:05 +020044include fvp.mk
Gyorgy Szing0a5029d2020-11-06 00:33:49 +010045
Jelle Selsd58d0272021-06-04 10:36:22 +020046TF_A_FLAGS+=ARM_SPMC_MANIFEST_DTS=$(CURDIR)/fvp/spmc_manifest.dts
Gyorgy Szing0a5029d2020-11-06 00:33:49 +010047TS_INSTALL_PREFIX:=$(CURDIR)/../out-ts
48
49# Add machinery allowing to build secure partitions from Trusted Services.
50#
Jelle Selse6f96332022-01-19 15:45:37 +010051# build-sp <sp-name>,<uuid>,<TS build flags>
Gyorgy Szing0a5029d2020-11-06 00:33:49 +010052# <sp name> The name of the SP.
53#
54# When called build and clean targets for the SP will be defined as:
55#
56# ffa-<sp name>-sp - Build the SP with cmake, and include the SP
57# export makefile to make the SP binary part
58# of the OP-TEE OS image.
59# ffa-<sp name>-sp-clean - run make clean on the cmake project
60# ffa-<sp name>-sp-realclean - remove all cmake output
61#
Balint Dobszayd520b002021-03-29 18:54:30 +020062# To run these for each SP in one step, the "ffa-sp-all", "ffa-sp-all-clean" and
63# "ffa-sp-all-realclean" targets are defined.
64#
Gyorgy Szing0a5029d2020-11-06 00:33:49 +010065# The build and the clean target are added to the dependency tree of common
66# op-tee targets.
67#
Jelle Selse6f96332022-01-19 15:45:37 +010068#example:
69#$(eval $(call build-sp,crypto,d9df52d5-16a2-4bb2-9aa4-d26d3b84e8c0, -DTS_PLATFORM=ts/mock))
70#This wil build the crypto_sp with the mock platorm as it backend.
71#Don't add spaces between the ',' and the uuid and name.
Gyorgy Szing0a5029d2020-11-06 00:33:49 +010072
Balint Dobszayd520b002021-03-29 18:54:30 +020073.PHONY: ffa-sp-all
74.PHONY: ffa-sp-all-clean
75.PHONY: ffa-sp-all-realclean
76
77optee-os-common: ffa-sp-all
78optee-os-clean: ffa-sp-all-clean
79
80ffa-sp-all-realclean:
81 rm -rf $(TS_INSTALL_PREFIX)/opteesp
82
Balint Dobszayd520b002021-03-29 18:54:30 +020083# If FIP packaging method is selected, TF-A requires a number of config options:
84# - ARM_BL2_SP_LIST_DTS: This file will be included into the TB_FW_CONFIG DT
85# of TF-A. It contains the UUID and load address of SP
86# packages present in the FIP, BL2 will load them based
87# on this information.
88# - ARM_SPMC_MANIFEST_DTS: Contains information about the SPMC: consumed by the
89# SPMD at SPMC init. And about the SP packages: the
90# SPMC can only know where the packages were loaded by
91# BL2 based on this file.
92# - SP_LAYOUT_FILE: JSON file which describes the corresponding SP image
93# and SP manifest DT pairs, TF-A will create the SP
94# packages based on this. However, the TS build
95# provides a separate JSON file for each SP. A Python
96# snippet is used to merge these JSONs into one file.
97ifeq (fip, $(SP_PACKAGING_METHOD))
Jelle Selse6f96332022-01-19 15:45:37 +010098define include_sp
99 TS_SP_JSON_LIST+=${TS_INSTALL_PREFIX}/opteesp/json/$1.json
100endef
Balint Dobszayd520b002021-03-29 18:54:30 +0200101SP_LAYOUT_FILE := $(TS_INSTALL_PREFIX)/opteesp/json/sp_layout.json
102
103TF_A_FLAGS+=SP_LAYOUT_FILE=$(SP_LAYOUT_FILE)
104TF_A_FLAGS+=ARM_BL2_SP_LIST_DTS=$(CURDIR)/fvp/bl2_sp_images.dtsi
Balint Dobszayd520b002021-03-29 18:54:30 +0200105OPTEE_OS_COMMON_EXTRA_FLAGS+=CFG_FIP_SP=y
106
107MERGE_JSON_PY := import json, sys
108MERGE_JSON_PY += \ncombined = {}
109MERGE_JSON_PY += \nfor path in sys.stdin.read().split():
110MERGE_JSON_PY += \n with open(path) as f:
111MERGE_JSON_PY += \n current = json.load(f)
112MERGE_JSON_PY += \n combined = {**combined, **current}
113MERGE_JSON_PY += \nprint(json.dumps(combined, indent=4))
114
115$(SP_LAYOUT_FILE): ffa-sp-all
116 @echo $(TS_SP_JSON_LIST) | python3 -c "$$(echo -e '$(MERGE_JSON_PY)')" > $(SP_LAYOUT_FILE)
117
118.PHONY: ffa-sp-layout-clean
119ffa-sp-layout-clean:
120 @rm -f $(SP_LAYOUT_FILE)
121
122arm-tf: $(SP_LAYOUT_FILE)
123ffa-sp-all-clean: ffa-sp-layout-clean
124endif
Balint Dobszay77001092021-02-15 13:52:55 +0100125
Balint Dobszay5c7c0582021-04-13 13:02:22 +0200126# If embedded packaging method is selected, the SP manifest files from TS have
127# to be merged into a common DTS file, which is passed to OP-TEE as the embedded
128# DT file. For each SP a dtsi file is exported from TS, which contains a single
129# node, representing that SP.
130# The TS_SP_DTSI_LIST parameter contains a line like this for each SP:
131#
132# #include "<absolute_path_to_dtsi>/<sp_uuid>.dtsi"
133#
134ifeq (embedded, $(SP_PACKAGING_METHOD))
Jelle Selse6f96332022-01-19 15:45:37 +0100135define include_sp
136 OPTEE_OS_COMMON_EXTRA_FLAGS+=EARLY_TA_PATHS+=${TS_INSTALL_PREFIX}/opteesp/bin/$1.stripped.elf
137 TS_SP_DTSI_LIST+="\\n\#include \"${TS_INSTALL_PREFIX}/opteesp/manifest/$1.dtsi\""
138endef
139
Balint Dobszay5c7c0582021-04-13 13:02:22 +0200140SP_MANIFEST_FILE := $(OUT_PATH)/sp_manifest.dts
141OPTEE_OS_COMMON_EXTRA_FLAGS+=CFG_EMBED_DTB_SOURCE_FILE=$(SP_MANIFEST_FILE)
142
143$(SP_MANIFEST_FILE): ffa-sp-all
144 @echo -e "/dts-v1/;\n/ {$(TS_SP_DTSI_LIST)\n};" > $(SP_MANIFEST_FILE)
145
Jelle Selse6f96332022-01-19 15:45:37 +0100146optee-os-common: $(SP_MANIFEST_FILE)
147
Balint Dobszay5c7c0582021-04-13 13:02:22 +0200148.PHONY: ffa-sp-manifest-clean
149ffa-sp-manifest-clean:
150 @rm -f $(SP_MANIFEST_FILE)
Balint Dobszay5c7c0582021-04-13 13:02:22 +0200151ffa-sp-all-clean: ffa-sp-manifest-clean
152endif
153
Jelle Selse6f96332022-01-19 15:45:37 +0100154define build-sp
155.PHONY: ffa-$1-sp
156ffa-$1-sp:
157 $(eval $(call include_sp,$2))
158 CROSS_COMPILE="$$(AARCH64_CROSS_COMPILE)" cmake -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$${TS_INSTALL_PREFIX} \
159 -S $$(CURDIR)/../trusted-services/deployments/$1/opteesp -B $$(CURDIR)/../ts-build/$1 $3
160 cmake --build $$(CURDIR)/../ts-build/$1 -- -j$$(nproc)
161 cmake --install $$(CURDIR)/../ts-build/$1
162
163.PHONY: ffa-$1-sp-clean
164ffa-$1-sp-clean:
165 cmake --build $$(CURDIR)/../ts-build/$1 -- clean -j$$(nproc)
166
167.PHONY: ffa-$1-sp-realclean
168ffa-$1-sp-realclean:
169 rm -rf $$(CURDIR)/../ts-build/$1
170
171ffa-sp-all: ffa-$1-sp
172ffa-sp-all-clean: ffa-$1-sp-clean
173ffa-sp-all-realclean: ffa-$1-sp-realclean
174endef
175
176$(eval $(call build-sp,internal-trusted-storage,dc1eef48-b17a-4ccf-ac8b-dfcff7711b14, ))
177$(eval $(call build-sp,protected-storage,751bf801-3dde-4768-a514-0f10aeed1790, ))
178$(eval $(call build-sp,crypto,d9df52d5-16a2-4bb2-9aa4-d26d3b84e8c0, ))
179$(eval $(call build-sp,attestation,a1baf155-8876-4695-8f7c-54955e8db974, ))
180$(eval $(call build-sp,smm-gateway,ed32d533-99e6-4209-9cc0-2d72cdd998a7, ))
181
182.PHONY: sp_uuid_list
183sp_uuid_list: $(SHARED_DIR)/sp_uuid_list.txt
184
185.PHONY: sp_uuid_list_clean
186sp_uuid_list_clean:
187 rm -rf $(SHARED_DIR)/sp_uuid_list.txt
188
189ffa-sp-all-clean: sp_uuid_list_clean
190
191$(SHARED_DIR)/sp_uuid_list.txt: ffa-sp-all
Balint Dobszay1cd203b2021-04-28 13:24:12 +0200192 find $(TS_INSTALL_PREFIX)/opteesp/bin -name "[0-9a-f-]*.elf" -type f | \
193 sed -n "s@.*/\(.*\).stripped.elf@\1@gp" | tr '\n' ',' | \
194 head -c -1 > $(SHARED_DIR)/sp_uuid_list.txt
Gyorgy Szing7d8a64b2020-11-10 15:54:01 +0100195
Jelle Selse6f96332022-01-19 15:45:37 +0100196# Add targets to build the "arm_ffa_user" Linux Kernel module.
197arm_ffa_user: sp_uuid_list linux
198 $(eval ROOT:=$(CURDIR)/..)
199 make -C $(CURDIR)/../linux_poc $(LINUX_COMMON_FLAGS) install
200
Gyorgy Szing7d8a64b2020-11-10 15:54:01 +0100201arm_ffa_user_clean:
202 make -C $(CURDIR)/../linux_poc clean
203
204all: arm_ffa_user