blob: 26d361031df539d7e972418e36351e763269be2d [file] [log] [blame]
Pascal Brandefe56592016-03-03 10:46:52 +01001################################################################################
2# Following variables defines how the NS_USER (Non Secure User - Client
3# Application), NS_KERNEL (Non Secure Kernel), S_KERNEL (Secure Kernel) and
4# S_USER (Secure User - TA) are compiled
5################################################################################
6override COMPILE_NS_USER := 64
7override COMPILE_NS_KERNEL := 64
8override COMPILE_S_USER := 32
9override COMPILE_S_KERNEL := 64
Pascal Brandd6536da2015-09-01 10:38:43 +020010
Pascal Brandefe56592016-03-03 10:46:52 +010011-include common.mk
SY Chiuddd3d822015-07-21 10:10:01 +080012
13################################################################################
14# Paths to git projects and various binaries
15################################################################################
SY Chiuddd3d822015-07-21 10:10:01 +080016MTK_TOOLS_PATH ?= $(ROOT)/mtk_tools
17
18################################################################################
SY Chiuddd3d822015-07-21 10:10:01 +080019# Targets
20################################################################################
21all: linux optee-os optee-client optee-linuxdriver xtest
James Kungb66c1302015-12-23 01:59:16 +080022all-clean: linux-clean busybox-clean optee-os-clean \
SY Chiuddd3d822015-07-21 10:10:01 +080023 optee-client-clean optee-linuxdriver-clean
24
25
26-include toolchain.mk
27
28################################################################################
29# Busybox
30################################################################################
Pascal Brand440ef9c2015-09-08 16:01:58 +020031BUSYBOX_COMMON_TARGET = mt8173-evb
32BUSYBOX_CLEAN_COMMON_TARGET = mt8173-evb clean
SY Chiuddd3d822015-07-21 10:10:01 +080033
Pascal Brand440ef9c2015-09-08 16:01:58 +020034busybox: busybox-common
35
36busybox-clean: busybox-clean-common
37
38busybox-cleaner: busybox-cleaner-common
SY Chiuddd3d822015-07-21 10:10:01 +080039
40################################################################################
41# Linux kernel
42################################################################################
Jerome Forissiere1002382015-11-26 11:36:00 +010043LINUX_DEFCONFIG_COMMON_ARCH := arm64
44LINUX_DEFCONFIG_COMMON_FILES := \
45 $(LINUX_PATH)/arch/arm64/configs/defconfig \
46 $(CURDIR)/kconfigs/mediatek.conf
47
SY Chiuddd3d822015-07-21 10:10:01 +080048linux-defconfig: $(LINUX_PATH)/.config
SY Chiuddd3d822015-07-21 10:10:01 +080049
Pascal Brande3d85982015-09-10 17:20:42 +020050LINUX_COMMON_FLAGS += ARCH=arm64
51
52linux: linux-common
53
54linux-defconfig-clean: linux-defconfig-clean-common
55
56LINUX_CLEAN_COMMON_FLAGS += ARCH=arm64
57
58linux-clean: linux-clean-common
59
60LINUX_CLEANER_COMMON_FLAGS += ARCH=arm64
61
62linux-cleaner: linux-cleaner-common
SY Chiuddd3d822015-07-21 10:10:01 +080063
64################################################################################
65# OP-TEE
66################################################################################
Pascal Brandefe56592016-03-03 10:46:52 +010067OPTEE_OS_COMMON_FLAGS += PLATFORM=mediatek-mt8173
Jerome Forissierae45fbf2015-09-04 09:40:17 +020068optee-os: optee-os-common
SY Chiuddd3d822015-07-21 10:10:01 +080069
Pascal Brandefe56592016-03-03 10:46:52 +010070OPTEE_OS_CLEAN_COMMON_FLAGS += PLATFORM=mediatek-mt8173
Jerome Forissierae45fbf2015-09-04 09:40:17 +020071optee-os-clean: optee-os-clean-common
SY Chiuddd3d822015-07-21 10:10:01 +080072
Pascal Brand070d9552015-09-01 15:33:22 +020073optee-client: optee-client-common
Jerome Forissierae45fbf2015-09-04 09:40:17 +020074
Pascal Brand070d9552015-09-01 15:33:22 +020075optee-client-clean: optee-client-clean-common
SY Chiuddd3d822015-07-21 10:10:01 +080076
Jerome Forissierae45fbf2015-09-04 09:40:17 +020077OPTEE_LINUXDRIVER_COMMON_FLAGS += ARCH=arm64
78optee-linuxdriver: optee-linuxdriver-common
79
80OPTEE_LINUXDRIVER_CLEAN_COMMON_FLAGS += ARCH=arm64
Pascal Brand070d9552015-09-01 15:33:22 +020081optee-linuxdriver-clean: optee-linuxdriver-clean-common
SY Chiuddd3d822015-07-21 10:10:01 +080082
83################################################################################
84# xtest / optee_test
85################################################################################
Pascal Brandd6536da2015-09-01 10:38:43 +020086xtest: xtest-common
87xtest-clean: xtest-clean-common
88xtest-patch: xtest-patch-common
SY Chiuddd3d822015-07-21 10:10:01 +080089
90################################################################################
91# Root FS
92################################################################################
93.PHONY: filelist-tee
94filelist-tee:
95 @echo "# xtest / optee_test" > $(GEN_ROOTFS_FILELIST)
96 @find $(OPTEE_TEST_OUT_PATH) -type f -name "xtest" | sed 's/\(.*\)/file \/bin\/xtest \1 755 0 0/g' >> $(GEN_ROOTFS_FILELIST)
97 @echo "# TAs" >> $(GEN_ROOTFS_FILELIST)
98 @echo "dir /lib/optee_armtz 755 0 0" >> $(GEN_ROOTFS_FILELIST)
99 @find $(OPTEE_TEST_OUT_PATH) -name "*.ta" | \
100 sed 's/\(.*\)\/\(.*\)/file \/lib\/optee_armtz\/\2 \1\/\2 444 0 0/g' >> $(GEN_ROOTFS_FILELIST)
101 @echo "# Secure storage dig" >> $(GEN_ROOTFS_FILELIST)
102 @echo "dir /data 755 0 0" >> $(GEN_ROOTFS_FILELIST)
103 @echo "dir /data/tee 755 0 0" >> $(GEN_ROOTFS_FILELIST)
104 @echo "# OP-TEE device" >> $(GEN_ROOTFS_FILELIST)
105 @echo "dir /lib/modules 755 0 0" >> $(GEN_ROOTFS_FILELIST)
106 @echo "dir /lib/modules/$(call KERNEL_VERSION) 755 0 0" >> $(GEN_ROOTFS_FILELIST)
107 @echo "file /lib/modules/$(call KERNEL_VERSION)/optee.ko $(OPTEE_LINUXDRIVER_PATH)/core/optee.ko 755 0 0" >> $(GEN_ROOTFS_FILELIST)
108 @echo "file /lib/modules/$(call KERNEL_VERSION)/optee_armtz.ko $(OPTEE_LINUXDRIVER_PATH)/armtz/optee_armtz.ko 755 0 0" >> $(GEN_ROOTFS_FILELIST)
109 @echo "# OP-TEE Client" >> $(GEN_ROOTFS_FILELIST)
110 @echo "file /bin/tee-supplicant $(OPTEE_CLIENT_EXPORT)/bin/tee-supplicant 755 0 0" >> $(GEN_ROOTFS_FILELIST)
111 @echo "dir /lib/aarch64-linux-gnu 755 0 0" >> $(GEN_ROOTFS_FILELIST)
112 @echo "file /lib/aarch64-linux-gnu/libteec.so.1.0 $(OPTEE_CLIENT_EXPORT)/lib/libteec.so.1.0 755 0 0" >> $(GEN_ROOTFS_FILELIST)
113 @echo "slink /lib/aarch64-linux-gnu/libteec.so.1 libteec.so.1.0 755 0 0" >> $(GEN_ROOTFS_FILELIST)
114 @echo "slink /lib/aarch64-linux-gnu/libteec.so libteec.so.1 755 0 0" >> $(GEN_ROOTFS_FILELIST)
115
116update_rootfs: busybox optee-client optee-linuxdriver xtest filelist-tee
117 cat $(GEN_ROOTFS_PATH)/filelist-final.txt $(GEN_ROOTFS_PATH)/filelist-tee.txt > $(GEN_ROOTFS_PATH)/filelist.tmp
118 cd $(GEN_ROOTFS_PATH); \
119 $(LINUX_PATH)/usr/gen_init_cpio $(GEN_ROOTFS_PATH)/filelist.tmp | gzip > $(GEN_ROOTFS_PATH)/filesystem.cpio.gz
120
121################################################################################
122# Image Tools
123################################################################################
124.PHONY: build_image flash_image run
125build-image: update_rootfs optee-os
126 cd $(MTK_TOOLS_PATH); \
127 ./build_trustzone.sh $(OPTEE_OS_BIN); \
128 ./build_bootimg.sh $(LINUX_PATH) $(GEN_ROOTFS_PATH)/filesystem.cpio.gz
129
130flash-image: build-image
131 @echo "Please press reset button ..."
132 @cd $(MTK_TOOLS_PATH); \
133 ./fastboot flash boot ./boot.img; \
134 ./fastboot flash TEE1 ./trustzone.bin
135 @echo "Please press reset button again..."
136
137run: flash-image