forked from OP-TEE/build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fvp.mk
197 lines (155 loc) · 7.56 KB
/
fvp.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
DEBUG ?= 1
-include common.mk
################################################################################
# Mandatory definition to use common.mk
################################################################################
CROSS_COMPILE_NS_USER ?= "$(CCACHE)$(AARCH64_CROSS_COMPILE)"
CROSS_COMPILE_NS_KERNEL ?= "$(CCACHE)$(AARCH64_CROSS_COMPILE)"
CROSS_COMPILE_S_USER ?= "$(CCACHE)$(AARCH32_CROSS_COMPILE)"
CROSS_COMPILE_S_KERNEL ?= "$(CCACHE)$(AARCH32_CROSS_COMPILE)"
OPTEE_OS_BIN ?= $(OPTEE_OS_PATH)/out/arm-plat-vexpress/core/tee.bin
OPTEE_OS_TA_DEV_KIT_DIR ?= $(OPTEE_OS_PATH)/out/arm-plat-vexpress/export-user_ta
################################################################################
# Paths to git projects and various binaries
################################################################################
ARM_TF_PATH ?= $(ROOT)/arm-trusted-firmware
EDK2_PATH ?= $(ROOT)/edk2
EDK2_BIN ?= $(EDK2_PATH)/Build/ArmVExpress-FVP-AArch64/RELEASE_GCC49/FV/FVP_AARCH64_EFI.fd
FOUNDATION_PATH ?= $(ROOT)/Foundation_Platformpkg
ifeq ($(wildcard $(FOUNDATION_PATH)),)
$(error $(FOUNDATION_PATH) does not exist)
endif
################################################################################
# Targets
################################################################################
all: arm-tf edk2 linux optee-os optee-client optee-linuxdriver generate-dtb xtest
all-clean: arm-tf-clean busybox-clean edk2-clean optee-os-clean \
optee-client-clean optee-linuxdriver-clean
-include toolchain.mk
################################################################################
# ARM Trusted Firmware
################################################################################
ARM_TF_EXPORTS ?= \
CFLAGS="-O0 -gdwarf-2" \
CROSS_COMPILE="$(CCACHE)$(AARCH64_NONE_CROSS_COMPILE)"
ARM_TF_FLAGS ?= \
BL32=$(OPTEE_OS_BIN) \
BL33=$(EDK2_BIN) \
DEBUG=0 \
FVP_TSP_RAM_LOCATION=tdram \
FVP_SHARED_DATA_LOCATION=tdram \
PLAT=fvp \
SPD=opteed
arm-tf: optee-os edk2
$(ARM_TF_EXPORTS) $(MAKE) -C $(ARM_TF_PATH) $(ARM_TF_FLAGS) all fip
arm-tf-clean:
$(ARM_TF_EXPORTS) $(MAKE) -C $(ARM_TF_PATH) $(ARM_TF_FLAGS) clean
################################################################################
# Busybox
################################################################################
BUSYBOX_COMMON_TARGET = fvp-aarch64
BUSYBOX_CLEAN_COMMON_TARGET = fvp-aarch64 clean
BUSYBOX_COMMON_CCDIR = $(AARCH64_PATH)
busybox: busybox-common
busybox-clean: busybox-clean-common
busybox-cleaner: busybox-cleaner-common
################################################################################
# EDK2 / Tianocore
################################################################################
define edk2-call
GCC49_AARCH64_PREFIX=$(AARCH64_NONE_CROSS_COMPILE) \
$(MAKE) -j1 -C $(EDK2_PATH) \
-f ArmPlatformPkg/Scripts/Makefile EDK2_ARCH=AARCH64 \
EDK2_DSC=ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc \
EDK2_TOOLCHAIN=GCC49 EDK2_BUILD=RELEASE \
EDK2_MACROS="-n 6 -D ARM_FOUNDATION_FVP=1"
endef
edk2: edk2-common
edk2-clean: edk2-clean-common
################################################################################
# Linux kernel
################################################################################
$(LINUX_PATH)/.config:
# Temporary fix until we have the driver integrated in the kernel
sed -i '/config ARM64$$/a select DMA_SHARED_BUFFER' $(LINUX_PATH)/arch/arm64/Kconfig;
make -C $(LINUX_PATH) ARCH=arm64 defconfig
linux-defconfig: $(LINUX_PATH)/.config
LINUX_COMMON_FLAGS += ARCH=arm64
linux: linux-common
linux-defconfig-clean: linux-defconfig-clean-common
LINUX_CLEAN_COMMON_FLAGS += ARCH=arm64
linux-clean: linux-clean-common
LINUX_CLEANER_COMMON_FLAGS += ARCH=arm64
linux-cleaner: linux-cleaner-common
################################################################################
# OP-TEE
################################################################################
OPTEE_OS_COMMON_FLAGS += PLATFORM=vexpress-fvp
optee-os: optee-os-common
OPTEE_OS_CLEAN_COMMON_FLAGS += PLATFORM=vexpress-fvp
optee-os-clean: optee-os-clean-common
optee-client: optee-client-common
optee-client-clean: optee-client-clean-common
OPTEE_LINUXDRIVER_COMMON_FLAGS += ARCH=arm64
optee-linuxdriver: optee-linuxdriver-common
OPTEE_LINUXDRIVER_CLEAN_COMMON_FLAGS += ARCH=arm64
optee-linuxdriver-clean: optee-linuxdriver-clean-common
generate-dtb: linux
$(LINUX_PATH)/scripts/dtc/dtc \
-O dtb \
-o $(FOUNDATION_PATH)/fdt.dtb \
-b 0 \
-i . $(OPTEE_LINUXDRIVER_PATH)/fdts/fvp-foundation-gicv2-psci.dts
################################################################################
# xtest / optee_test
################################################################################
xtest: xtest-common
xtest-clean: xtest-clean-common
xtest-patch: xtest-patch-common
################################################################################
# Root FS
################################################################################
.PHONY: filelist-tee
filelist-tee:
@echo "# xtest / optee_test" > $(GEN_ROOTFS_FILELIST)
@find $(OPTEE_TEST_OUT_PATH) -type f -name "xtest" | sed 's/\(.*\)/file \/bin\/xtest \1 755 0 0/g' >> $(GEN_ROOTFS_FILELIST)
@echo "# TAs" >> $(GEN_ROOTFS_FILELIST)
@echo "dir /lib/optee_armtz 755 0 0" >> $(GEN_ROOTFS_FILELIST)
@find $(OPTEE_TEST_OUT_PATH) -name "*.ta" | \
sed 's/\(.*\)\/\(.*\)/file \/lib\/optee_armtz\/\2 \1\/\2 444 0 0/g' >> $(GEN_ROOTFS_FILELIST)
@echo "# Secure storage dig" >> $(GEN_ROOTFS_FILELIST)
@echo "dir /data 755 0 0" >> $(GEN_ROOTFS_FILELIST)
@echo "dir /data/tee 755 0 0" >> $(GEN_ROOTFS_FILELIST)
@echo "# OP-TEE device" >> $(GEN_ROOTFS_FILELIST)
@echo "dir /lib/modules 755 0 0" >> $(GEN_ROOTFS_FILELIST)
@echo "dir /lib/modules/$(call KERNEL_VERSION) 755 0 0" >> $(GEN_ROOTFS_FILELIST)
@echo "file /lib/modules/$(call KERNEL_VERSION)/optee.ko $(OPTEE_LINUXDRIVER_PATH)/core/optee.ko 755 0 0" >> $(GEN_ROOTFS_FILELIST)
@echo "file /lib/modules/$(call KERNEL_VERSION)/optee_armtz.ko $(OPTEE_LINUXDRIVER_PATH)/armtz/optee_armtz.ko 755 0 0" >> $(GEN_ROOTFS_FILELIST)
@echo "# OP-TEE Client" >> $(GEN_ROOTFS_FILELIST)
@echo "file /bin/tee-supplicant $(OPTEE_CLIENT_EXPORT)/bin/tee-supplicant 755 0 0" >> $(GEN_ROOTFS_FILELIST)
@echo "dir /lib/aarch64-linux-gnu 755 0 0" >> $(GEN_ROOTFS_FILELIST)
@echo "file /lib/aarch64-linux-gnu/libteec.so.1.0 $(OPTEE_CLIENT_EXPORT)/lib/libteec.so.1.0 755 0 0" >> $(GEN_ROOTFS_FILELIST)
@echo "slink /lib/aarch64-linux-gnu/libteec.so.1 libteec.so.1.0 755 0 0" >> $(GEN_ROOTFS_FILELIST)
@echo "slink /lib/aarch64-linux-gnu/libteec.so libteec.so.1 755 0 0" >> $(GEN_ROOTFS_FILELIST)
update_rootfs: busybox optee-client optee-linuxdriver xtest filelist-tee
cat $(GEN_ROOTFS_PATH)/filelist-final.txt $(GEN_ROOTFS_PATH)/filelist-tee.txt > $(GEN_ROOTFS_PATH)/filelist.tmp
cd $(GEN_ROOTFS_PATH); \
$(LINUX_PATH)/usr/gen_init_cpio $(GEN_ROOTFS_PATH)/filelist.tmp | gzip > $(GEN_ROOTFS_PATH)/filesystem.cpio.gz
################################################################################
# Run targets
################################################################################
# This target enforces updating root fs etc
run: all
$(MAKE) update_rootfs
$(MAKE) run-only
run-only:
@ln -sf $(LINUX_PATH)/arch/arm64/boot/Image $(FOUNDATION_PATH)
@ln -sf $(GEN_ROOTFS_PATH)/filesystem.cpio.gz $(FOUNDATION_PATH)
@cd $(FOUNDATION_PATH); \
$(FOUNDATION_PATH)/models/Linux64_GCC-4.1/Foundation_Platform \
--cores=4 \
--secure-memory \
--visualization \
--gicv3 \
--data="$(ARM_TF_PATH)/build/fvp/release/bl1.bin"@0x0 \
--data="$(ARM_TF_PATH)/build/fvp/release/fip.bin"@0x8000000