Balint Dobszay | d777a3e | 2020-07-15 15:53:05 +0200 | [diff] [blame] | 1 | DTS ?= optee_ffa |
| 2 | DTS_PATH ?= $(BUILD_PATH)/fvp |
| 3 | USE_FVP_BASE_PLAT ?= 1 |
| 4 | |
Balint Dobszay | d520b00 | 2021-03-29 18:54:30 +0200 | [diff] [blame] | 5 | # Use "embedded" or "fip" |
| 6 | SP_PACKAGING_METHOD ?= embedded |
| 7 | |
Balint Dobszay | d777a3e | 2020-07-15 15:53:05 +0200 | [diff] [blame] | 8 | OPTEE_OS_COMMON_EXTRA_FLAGS += CFG_CORE_SEL1_SPMC=y CFG_CORE_FFA=y |
| 9 | OPTEE_OS_COMMON_EXTRA_FLAGS += CFG_WITH_SP=y |
| 10 | OPTEE_OS_COMMON_EXTRA_FLAGS += O=out/arm |
| 11 | |
| 12 | TF_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 | |
| 21 | include fvp.mk |
Gyorgy Szing | 0a5029d | 2020-11-06 00:33:49 +0100 | [diff] [blame] | 22 | |
| 23 | TS_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 Dobszay | d520b00 | 2021-03-29 18:54:30 +0200 | [diff] [blame] | 38 | # 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 Szing | 0a5029d | 2020-11-06 00:33:49 +0100 | [diff] [blame] | 41 | # The build and the clean target are added to the dependency tree of common |
| 42 | # op-tee targets. |
| 43 | # |
| 44 | |
Balint Dobszay | d520b00 | 2021-03-29 18:54:30 +0200 | [diff] [blame] | 45 | .PHONY: ffa-sp-all |
| 46 | .PHONY: ffa-sp-all-clean |
| 47 | .PHONY: ffa-sp-all-realclean |
| 48 | |
| 49 | optee-os-common: ffa-sp-all |
| 50 | optee-os-clean: ffa-sp-all-clean |
| 51 | |
| 52 | ffa-sp-all-realclean: |
| 53 | rm -rf $(TS_INSTALL_PREFIX)/opteesp |
| 54 | |
Gyorgy Szing | 0a5029d | 2020-11-06 00:33:49 +0100 | [diff] [blame] | 55 | define build-sp |
| 56 | .PHONY: ffa-$1-sp |
| 57 | ffa-$1-sp: ffa-$1-sp-build |
Balint Dobszay | 7700109 | 2021-02-15 13:52:55 +0100 | [diff] [blame] | 58 | $$(eval include $${TS_INSTALL_PREFIX}/opteesp/lib/make/$1.mk) |
Gyorgy Szing | 0a5029d | 2020-11-06 00:33:49 +0100 | [diff] [blame] | 59 | |
| 60 | .PHONY: ffa-$1-sp-build |
| 61 | ffa-$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 |
| 69 | ffa-$1-sp-clean: |
| 70 | cmake --build $$(CURDIR)/../ts-build/$1 -- clean -j$$(nproc) |
| 71 | |
Balint Dobszay | d520b00 | 2021-03-29 18:54:30 +0200 | [diff] [blame] | 72 | .PHONY: ffa-$1-sp-realclean |
Gyorgy Szing | 0a5029d | 2020-11-06 00:33:49 +0100 | [diff] [blame] | 73 | ffa-$1-sp-realclean: |
| 74 | rm -rf $$(CURDIR)/../ts-build/$1 |
| 75 | |
Balint Dobszay | d520b00 | 2021-03-29 18:54:30 +0200 | [diff] [blame] | 76 | ffa-sp-all: ffa-$1-sp |
| 77 | ffa-sp-all-clean: ffa-$1-sp-clean |
| 78 | ffa-sp-all-realclean: ffa-$1-sp-realclean |
Gyorgy Szing | 0a5029d | 2020-11-06 00:33:49 +0100 | [diff] [blame] | 79 | endef |
| 80 | |
| 81 | $(eval $(call build-sp,secure-storage)) |
| 82 | $(eval $(call build-sp,crypto)) |
| 83 | |
Balint Dobszay | d520b00 | 2021-03-29 18:54:30 +0200 | [diff] [blame] | 84 | # 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. |
| 98 | ifeq (fip, $(SP_PACKAGING_METHOD)) |
| 99 | SP_LAYOUT_FILE := $(TS_INSTALL_PREFIX)/opteesp/json/sp_layout.json |
| 100 | |
| 101 | TF_A_FLAGS+=SP_LAYOUT_FILE=$(SP_LAYOUT_FILE) |
| 102 | TF_A_FLAGS+=ARM_BL2_SP_LIST_DTS=$(CURDIR)/fvp/bl2_sp_images.dtsi |
| 103 | TF_A_FLAGS+=ARM_SPMC_MANIFEST_DTS=$(CURDIR)/fvp/spmc_manifest.dts |
| 104 | OPTEE_OS_COMMON_EXTRA_FLAGS+=CFG_FIP_SP=y |
| 105 | |
| 106 | MERGE_JSON_PY := import json, sys |
| 107 | MERGE_JSON_PY += \ncombined = {} |
| 108 | MERGE_JSON_PY += \nfor path in sys.stdin.read().split(): |
| 109 | MERGE_JSON_PY += \n with open(path) as f: |
| 110 | MERGE_JSON_PY += \n current = json.load(f) |
| 111 | MERGE_JSON_PY += \n combined = {**combined, **current} |
| 112 | MERGE_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 |
| 118 | ffa-sp-layout-clean: |
| 119 | @rm -f $(SP_LAYOUT_FILE) |
| 120 | |
| 121 | arm-tf: $(SP_LAYOUT_FILE) |
| 122 | ffa-sp-all-clean: ffa-sp-layout-clean |
| 123 | endif |
Balint Dobszay | 7700109 | 2021-02-15 13:52:55 +0100 | [diff] [blame] | 124 | |
Balint Dobszay | 5c7c058 | 2021-04-13 13:02:22 +0200 | [diff] [blame] | 125 | # 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 | # |
| 133 | ifeq (embedded, $(SP_PACKAGING_METHOD)) |
| 134 | SP_MANIFEST_FILE := $(OUT_PATH)/sp_manifest.dts |
| 135 | OPTEE_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 |
| 141 | ffa-sp-manifest-clean: |
| 142 | @rm -f $(SP_MANIFEST_FILE) |
| 143 | |
| 144 | optee-os-common: $(SP_MANIFEST_FILE) |
| 145 | ffa-sp-all-clean: ffa-sp-manifest-clean |
| 146 | endif |
| 147 | |
Gyorgy Szing | 7d8a64b | 2020-11-10 15:54:01 +0100 | [diff] [blame] | 148 | # Add targets to build the "arm_ffa_user" Linux Kernel module. |
| 149 | arm_ffa_user: linux |
| 150 | $(eval ROOT:=$(CURDIR)/..) |
| 151 | make -C $(CURDIR)/../linux_poc $(LINUX_COMMON_FLAGS) install |
Balint Dobszay | 1cd203b | 2021-04-28 13:24:12 +0200 | [diff] [blame^] | 152 | 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 Szing | 7d8a64b | 2020-11-10 15:54:01 +0100 | [diff] [blame] | 155 | |
| 156 | arm_ffa_user_clean: |
| 157 | make -C $(CURDIR)/../linux_poc clean |
| 158 | |
| 159 | all: arm_ffa_user |