blob: dfc5cd7c6dd1454939a56c4a77e4eebec90e1e08 [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
10OPTEE_OS_COMMON_EXTRA_FLAGS += O=out/arm
11
12TF_A_FLAGS ?= \
13 ARM_TSP_RAM_LOCATION=tdram \
14 BL32=$(OPTEE_OS_PAGER_V2_BIN) \
15 BL33=$(EDK2_BIN) \
16 DEBUG=$(DEBUG) \
17 PLAT=fvp \
18 SPD=spmd \
19 SPMD_SPM_AT_SEL2=0
20
21include fvp.mk
Gyorgy Szing0a5029d2020-11-06 00:33:49 +010022
23TS_INSTALL_PREFIX:=$(CURDIR)/../out-ts
24
25# Add machinery allowing to build secure partitions from Trusted Services.
26#
27# build-sp <sp-name>
28# <sp name> The name of the SP.
29#
30# When called build and clean targets for the SP will be defined as:
31#
32# ffa-<sp name>-sp - Build the SP with cmake, and include the SP
33# export makefile to make the SP binary part
34# of the OP-TEE OS image.
35# ffa-<sp name>-sp-clean - run make clean on the cmake project
36# ffa-<sp name>-sp-realclean - remove all cmake output
37#
Balint Dobszayd520b002021-03-29 18:54:30 +020038# To run these for each SP in one step, the "ffa-sp-all", "ffa-sp-all-clean" and
39# "ffa-sp-all-realclean" targets are defined.
40#
Gyorgy Szing0a5029d2020-11-06 00:33:49 +010041# The build and the clean target are added to the dependency tree of common
42# op-tee targets.
43#
44
Balint Dobszayd520b002021-03-29 18:54:30 +020045.PHONY: ffa-sp-all
46.PHONY: ffa-sp-all-clean
47.PHONY: ffa-sp-all-realclean
48
49optee-os-common: ffa-sp-all
50optee-os-clean: ffa-sp-all-clean
51
52ffa-sp-all-realclean:
53 rm -rf $(TS_INSTALL_PREFIX)/opteesp
54
Gyorgy Szing0a5029d2020-11-06 00:33:49 +010055define build-sp
56.PHONY: ffa-$1-sp
57ffa-$1-sp: ffa-$1-sp-build
Balint Dobszay77001092021-02-15 13:52:55 +010058 $$(eval include $${TS_INSTALL_PREFIX}/opteesp/lib/make/$1.mk)
Gyorgy Szing0a5029d2020-11-06 00:33:49 +010059
60.PHONY: ffa-$1-sp-build
61ffa-$1-sp-build: optee-os-spdevkit
62 CROSS_COMPILE="$$(AARCH64_CROSS_COMPILE)" cmake -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$${TS_INSTALL_PREFIX} \
63 -DSP_DEV_KIT_DIR=$$(CURDIR)/../optee_os/out/arm/export-sp_arm64 \
64 -S $$(CURDIR)/../trusted-services/deployments/$1/opteesp -B $$(CURDIR)/../ts-build/$1
65 cmake --build $$(CURDIR)/../ts-build/$1 -- -j$$(nproc)
66 cmake --install $$(CURDIR)/../ts-build/$1
67
68.PHONY: ffa-$1-sp-clean
69ffa-$1-sp-clean:
70 cmake --build $$(CURDIR)/../ts-build/$1 -- clean -j$$(nproc)
71
Balint Dobszayd520b002021-03-29 18:54:30 +020072.PHONY: ffa-$1-sp-realclean
Gyorgy Szing0a5029d2020-11-06 00:33:49 +010073ffa-$1-sp-realclean:
74 rm -rf $$(CURDIR)/../ts-build/$1
75
Balint Dobszayd520b002021-03-29 18:54:30 +020076ffa-sp-all: ffa-$1-sp
77ffa-sp-all-clean: ffa-$1-sp-clean
78ffa-sp-all-realclean: ffa-$1-sp-realclean
Gyorgy Szing0a5029d2020-11-06 00:33:49 +010079endef
80
81$(eval $(call build-sp,secure-storage))
82$(eval $(call build-sp,crypto))
83
Balint Dobszayd520b002021-03-29 18:54:30 +020084# If FIP packaging method is selected, TF-A requires a number of config options:
85# - ARM_BL2_SP_LIST_DTS: This file will be included into the TB_FW_CONFIG DT
86# of TF-A. It contains the UUID and load address of SP
87# packages present in the FIP, BL2 will load them based
88# on this information.
89# - ARM_SPMC_MANIFEST_DTS: Contains information about the SPMC: consumed by the
90# SPMD at SPMC init. And about the SP packages: the
91# SPMC can only know where the packages were loaded by
92# BL2 based on this file.
93# - SP_LAYOUT_FILE: JSON file which describes the corresponding SP image
94# and SP manifest DT pairs, TF-A will create the SP
95# packages based on this. However, the TS build
96# provides a separate JSON file for each SP. A Python
97# snippet is used to merge these JSONs into one file.
98ifeq (fip, $(SP_PACKAGING_METHOD))
99SP_LAYOUT_FILE := $(TS_INSTALL_PREFIX)/opteesp/json/sp_layout.json
100
101TF_A_FLAGS+=SP_LAYOUT_FILE=$(SP_LAYOUT_FILE)
102TF_A_FLAGS+=ARM_BL2_SP_LIST_DTS=$(CURDIR)/fvp/bl2_sp_images.dtsi
103TF_A_FLAGS+=ARM_SPMC_MANIFEST_DTS=$(CURDIR)/fvp/spmc_manifest.dts
104OPTEE_OS_COMMON_EXTRA_FLAGS+=CFG_FIP_SP=y
105
106MERGE_JSON_PY := import json, sys
107MERGE_JSON_PY += \ncombined = {}
108MERGE_JSON_PY += \nfor path in sys.stdin.read().split():
109MERGE_JSON_PY += \n with open(path) as f:
110MERGE_JSON_PY += \n current = json.load(f)
111MERGE_JSON_PY += \n combined = {**combined, **current}
112MERGE_JSON_PY += \nprint(json.dumps(combined, indent=4))
113
114$(SP_LAYOUT_FILE): ffa-sp-all
115 @echo $(TS_SP_JSON_LIST) | python3 -c "$$(echo -e '$(MERGE_JSON_PY)')" > $(SP_LAYOUT_FILE)
116
117.PHONY: ffa-sp-layout-clean
118ffa-sp-layout-clean:
119 @rm -f $(SP_LAYOUT_FILE)
120
121arm-tf: $(SP_LAYOUT_FILE)
122ffa-sp-all-clean: ffa-sp-layout-clean
123endif
Balint Dobszay77001092021-02-15 13:52:55 +0100124
Balint Dobszay5c7c0582021-04-13 13:02:22 +0200125# If embedded packaging method is selected, the SP manifest files from TS have
126# to be merged into a common DTS file, which is passed to OP-TEE as the embedded
127# DT file. For each SP a dtsi file is exported from TS, which contains a single
128# node, representing that SP.
129# The TS_SP_DTSI_LIST parameter contains a line like this for each SP:
130#
131# #include "<absolute_path_to_dtsi>/<sp_uuid>.dtsi"
132#
133ifeq (embedded, $(SP_PACKAGING_METHOD))
134SP_MANIFEST_FILE := $(OUT_PATH)/sp_manifest.dts
135OPTEE_OS_COMMON_EXTRA_FLAGS+=CFG_EMBED_DTB_SOURCE_FILE=$(SP_MANIFEST_FILE)
136
137$(SP_MANIFEST_FILE): ffa-sp-all
138 @echo -e "/dts-v1/;\n/ {$(TS_SP_DTSI_LIST)\n};" > $(SP_MANIFEST_FILE)
139
140.PHONY: ffa-sp-manifest-clean
141ffa-sp-manifest-clean:
142 @rm -f $(SP_MANIFEST_FILE)
143
144optee-os-common: $(SP_MANIFEST_FILE)
145ffa-sp-all-clean: ffa-sp-manifest-clean
146endif
147
Gyorgy Szing7d8a64b2020-11-10 15:54:01 +0100148# Add targets to build the "arm_ffa_user" Linux Kernel module.
149arm_ffa_user: linux
150 $(eval ROOT:=$(CURDIR)/..)
151 make -C $(CURDIR)/../linux_poc $(LINUX_COMMON_FLAGS) install
Balint Dobszay1cd203b2021-04-28 13:24:12 +0200152 find $(TS_INSTALL_PREFIX)/opteesp/bin -name "[0-9a-f-]*.elf" -type f | \
153 sed -n "s@.*/\(.*\).stripped.elf@\1@gp" | tr '\n' ',' | \
154 head -c -1 > $(SHARED_DIR)/sp_uuid_list.txt
Gyorgy Szing7d8a64b2020-11-10 15:54:01 +0100155
156arm_ffa_user_clean:
157 make -C $(CURDIR)/../linux_poc clean
158
159all: arm_ffa_user