blob: 445662fe488d28eed1df0c1f4cd5db2d408d5f33 [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 := 32
7override COMPILE_NS_KERNEL := 32
8override COMPILE_S_USER := 32
9override COMPILE_S_KERNEL := 32
Pascal Brandd6536da2015-09-01 10:38:43 +020010
Pascal Brandefe56592016-03-03 10:46:52 +010011-include common.mk
Joakim Bech427dd632015-05-04 15:52:33 +020012
13################################################################################
14# Paths to git projects and various binaries
15################################################################################
Joakim Bech427dd632015-05-04 15:52:33 +020016BIOS_QEMU_PATH ?= $(ROOT)/bios_qemu_tz_arm
Joakim Bech427dd632015-05-04 15:52:33 +020017QEMU_PATH ?= $(ROOT)/qemu
18
19SOC_TERM_PATH ?= $(ROOT)/soc_term
20
Pascal Brand070d9552015-09-01 15:33:22 +020021DEBUG = 1
Joakim Bech427dd632015-05-04 15:52:33 +020022
Joakim Bech427dd632015-05-04 15:52:33 +020023################################################################################
24# Targets
25################################################################################
Jerome Forissier2660ff22015-09-03 10:20:00 +020026all: bios-qemu qemu soc-term
Joakim Bech427dd632015-05-04 15:52:33 +020027all-clean: bios-qemu-clean busybox-clean linux-clean optee-os-clean \
Jerome Forissierf080b5a2015-08-07 16:18:57 +020028 optee-client-clean optee-linuxdriver-clean qemu-clean soc-term-clean \
29 check-clean
Joakim Bech427dd632015-05-04 15:52:33 +020030
31-include toolchain.mk
32
33################################################################################
34# QEMU
35################################################################################
36define bios-qemu-common
Jerome Forissier2660ff22015-09-03 10:20:00 +020037 +$(MAKE) -C $(BIOS_QEMU_PATH) \
38 CROSS_COMPILE=$(CROSS_COMPILE_NS_USER) \
Joakim Bech427dd632015-05-04 15:52:33 +020039 O=$(ROOT)/out/bios-qemu \
40 BIOS_NSEC_BLOB=$(LINUX_PATH)/arch/arm/boot/zImage \
41 BIOS_NSEC_ROOTFS=$(GEN_ROOTFS_PATH)/filesystem.cpio.gz \
42 BIOS_SECURE_BLOB=$(OPTEE_OS_BIN) \
43 PLATFORM_FLAVOR=virt
44endef
45
Jerome Forissier2660ff22015-09-03 10:20:00 +020046bios-qemu: update_rootfs optee-os
Joakim Bech427dd632015-05-04 15:52:33 +020047 $(call bios-qemu-common)
48
49bios-qemu-clean:
50 $(call bios-qemu-common) clean
51
52qemu:
Jorden Whitefield4b630422015-11-18 17:05:40 +000053 cd $(QEMU_PATH); ./configure --target-list=arm-softmmu --cc="$(CCACHE)gcc" --extra-cflags="-Wno-error"
Jerome Forissier2660ff22015-09-03 10:20:00 +020054 $(MAKE) -C $(QEMU_PATH)
Joakim Bech427dd632015-05-04 15:52:33 +020055
56qemu-clean:
Jerome Forissier2660ff22015-09-03 10:20:00 +020057 $(MAKE) -C $(QEMU_PATH) distclean
Joakim Bech427dd632015-05-04 15:52:33 +020058
59################################################################################
60# Busybox
61################################################################################
Pascal Brand440ef9c2015-09-08 16:01:58 +020062BUSYBOX_COMMON_TARGET = vexpress
63BUSYBOX_CLEAN_COMMON_TARGET = vexpress clean
Joakim Bech427dd632015-05-04 15:52:33 +020064
Pascal Brand440ef9c2015-09-08 16:01:58 +020065busybox: busybox-common
Joakim Bech427dd632015-05-04 15:52:33 +020066
Pascal Brand440ef9c2015-09-08 16:01:58 +020067busybox-clean: busybox-clean-common
68
69busybox-cleaner: busybox-cleaner-common
Joakim Bech427dd632015-05-04 15:52:33 +020070
71################################################################################
72# Linux kernel
73################################################################################
Jerome Forissiere1002382015-11-26 11:36:00 +010074LINUX_DEFCONFIG_COMMON_ARCH := arm
75LINUX_DEFCONFIG_COMMON_FILES := \
76 $(LINUX_PATH)/arch/arm/configs/vexpress_defconfig \
77 $(CURDIR)/kconfigs/qemu.conf
Joakim Bech427dd632015-05-04 15:52:33 +020078
79linux-defconfig: $(LINUX_PATH)/.config
80
Pascal Brande3d85982015-09-10 17:20:42 +020081LINUX_COMMON_FLAGS += ARCH=arm
Joakim Bech427dd632015-05-04 15:52:33 +020082
Pascal Brande3d85982015-09-10 17:20:42 +020083linux: linux-common
84
85linux-defconfig-clean: linux-defconfig-clean-common
86
87LINUX_CLEAN_COMMON_FLAGS += ARCH=arm
88
89linux-clean: linux-clean-common
90
91LINUX_CLEANER_COMMON_FLAGS += ARCH=arm
92
93linux-cleaner: linux-cleaner-common
Joakim Bech427dd632015-05-04 15:52:33 +020094
95################################################################################
96# OP-TEE
97################################################################################
Jerome Forissierae45fbf2015-09-04 09:40:17 +020098OPTEE_OS_COMMON_FLAGS += PLATFORM=vexpress-qemu_virt
99optee-os: optee-os-common
Joakim Bech427dd632015-05-04 15:52:33 +0200100
Jerome Forissierae45fbf2015-09-04 09:40:17 +0200101OPTEE_OS_CLEAN_COMMON_FLAGS += PLATFORM=vexpress-qemu_virt
102optee-os-clean: optee-os-clean-common
Joakim Bech427dd632015-05-04 15:52:33 +0200103
Pascal Brand070d9552015-09-01 15:33:22 +0200104optee-client: optee-client-common
Jerome Forissierae45fbf2015-09-04 09:40:17 +0200105
Pascal Brand070d9552015-09-01 15:33:22 +0200106optee-client-clean: optee-client-clean-common
Jerome Forissierae45fbf2015-09-04 09:40:17 +0200107
108OPTEE_LINUXDRIVER_COMMON_FLAGS += ARCH=arm
109optee-linuxdriver: optee-linuxdriver-common
110
111OPTEE_LINUXDRIVER_CLEAN_COMMON_FLAGS += ARCH=arm
Pascal Brand070d9552015-09-01 15:33:22 +0200112optee-linuxdriver-clean: optee-linuxdriver-clean-common
Joakim Bech427dd632015-05-04 15:52:33 +0200113
114################################################################################
115# Soc-term
116################################################################################
117soc-term:
Jerome Forissier2660ff22015-09-03 10:20:00 +0200118 $(MAKE) -C $(SOC_TERM_PATH)
Joakim Bech427dd632015-05-04 15:52:33 +0200119
120soc-term-clean:
Jerome Forissier2660ff22015-09-03 10:20:00 +0200121 $(MAKE) -C $(SOC_TERM_PATH) clean
Joakim Bech427dd632015-05-04 15:52:33 +0200122
123################################################################################
124# xtest / optee_test
125################################################################################
Jerome Forissierae45fbf2015-09-04 09:40:17 +0200126xtest: xtest-common
Joakim Bech427dd632015-05-04 15:52:33 +0200127
Jerome Forissierae45fbf2015-09-04 09:40:17 +0200128xtest-clean: xtest-clean-common
Pascal Brandeab35592015-07-10 15:07:02 +0200129
Jerome Forissierae45fbf2015-09-04 09:40:17 +0200130xtest-patch: xtest-patch-common
Pascal Brandeab35592015-07-10 15:07:02 +0200131
Joakim Bech427dd632015-05-04 15:52:33 +0200132################################################################################
133# Root FS
134################################################################################
135.PHONY: filelist-tee
Jerome Forissier2660ff22015-09-03 10:20:00 +0200136filelist-tee: xtest
Joakim Bech427dd632015-05-04 15:52:33 +0200137 @echo "# xtest / optee_test" > $(GEN_ROOTFS_FILELIST)
138 @find $(OPTEE_TEST_OUT_PATH) -type f -name "xtest" | sed 's/\(.*\)/file \/bin\/xtest \1 755 0 0/g' >> $(GEN_ROOTFS_FILELIST)
139 @echo "# TAs" >> $(GEN_ROOTFS_FILELIST)
140 @echo "dir /lib/optee_armtz 755 0 0" >> $(GEN_ROOTFS_FILELIST)
141 @find $(OPTEE_TEST_OUT_PATH) -name "*.ta" | \
142 sed 's/\(.*\)\/\(.*\)/file \/lib\/optee_armtz\/\2 \1\/\2 444 0 0/g' >> $(GEN_ROOTFS_FILELIST)
143 @echo "# Secure storage dig" >> $(GEN_ROOTFS_FILELIST)
144 @echo "dir /data 755 0 0" >> $(GEN_ROOTFS_FILELIST)
145 @echo "dir /data/tee 755 0 0" >> $(GEN_ROOTFS_FILELIST)
146 @echo "# OP-TEE device" >> $(GEN_ROOTFS_FILELIST)
147 @echo "dir /lib/modules 755 0 0" >> $(GEN_ROOTFS_FILELIST)
148 @echo "dir /lib/modules/$(call KERNEL_VERSION) 755 0 0" >> $(GEN_ROOTFS_FILELIST)
149 @echo "file /lib/modules/$(call KERNEL_VERSION)/optee.ko $(OPTEE_LINUXDRIVER_PATH)/core/optee.ko 755 0 0" >> $(GEN_ROOTFS_FILELIST)
150 @echo "file /lib/modules/$(call KERNEL_VERSION)/optee_armtz.ko $(OPTEE_LINUXDRIVER_PATH)/armtz/optee_armtz.ko 755 0 0" >> $(GEN_ROOTFS_FILELIST)
151 @echo "# OP-TEE Client" >> $(GEN_ROOTFS_FILELIST)
152 @echo "file /bin/tee-supplicant $(OPTEE_CLIENT_EXPORT)/bin/tee-supplicant 755 0 0" >> $(GEN_ROOTFS_FILELIST)
153 @echo "dir /lib/arm-linux-gnueabihf 755 0 0" >> $(GEN_ROOTFS_FILELIST)
154 @echo "file /lib/arm-linux-gnueabihf/libteec.so.1.0 $(OPTEE_CLIENT_EXPORT)/lib/libteec.so.1.0 755 0 0" >> $(GEN_ROOTFS_FILELIST)
155 @echo "slink /lib/arm-linux-gnueabihf/libteec.so.1 libteec.so.1.0 755 0 0" >> $(GEN_ROOTFS_FILELIST)
156 @echo "slink /lib/arm-linux-gnueabihf/libteec.so libteec.so.1 755 0 0" >> $(GEN_ROOTFS_FILELIST)
157
Jerome Forissier2660ff22015-09-03 10:20:00 +0200158update_rootfs: busybox optee-client optee-linuxdriver filelist-tee
Joakim Bech427dd632015-05-04 15:52:33 +0200159 cat $(GEN_ROOTFS_PATH)/filelist-final.txt $(GEN_ROOTFS_PATH)/filelist-tee.txt > $(GEN_ROOTFS_PATH)/filelist.tmp
160 cd $(GEN_ROOTFS_PATH); \
161 $(LINUX_PATH)/usr/gen_init_cpio $(GEN_ROOTFS_PATH)/filelist.tmp | gzip > $(GEN_ROOTFS_PATH)/filesystem.cpio.gz
162
163################################################################################
164# Run targets
165################################################################################
166define run-help
167 @echo "Run QEMU"
168 @echo QEMU is now waiting to start the execution
169 @echo Start execution with either a \'c\' followed by \<enter\> in the QEMU console or
170 @echo attach a debugger and continue from there.
171 @echo
172 @echo To run xtest paste the following on the serial 0 prompt
173 @echo modprobe optee_armtz
174 @echo sleep 0.1
175 @echo tee-supplicant\&
176 @echo sleep 0.1
177 @echo xtest
178 @echo
179 @echo To run a single test case replace the xtest command with for instance
180 @echo xtest 2001
181endef
182
SY Chiuc8d61452015-09-17 16:42:17 +0800183define launch-terminal
184 @nc -z 127.0.0.1 $(1) || \
Jerome Forissiere5425ff2015-10-27 13:34:49 +0100185 xterm -title $(2) -e $(BASH) -c "$(SOC_TERM_PATH)/soc_term $(1)" &
SY Chiuc8d61452015-09-17 16:42:17 +0800186endef
187
Peter Maydellc8bcc902015-10-29 16:31:52 +0000188define wait-for-ports
189 @while ! nc -z 127.0.0.1 $(1) || ! nc -z 127.0.0.1 $(2); do sleep 1; done
190endef
191
Joakim Bech427dd632015-05-04 15:52:33 +0200192.PHONY: run
193# This target enforces updating root fs etc
Jerome Forissierae45fbf2015-09-04 09:40:17 +0200194run: all
195 $(MAKE) run-only
Joakim Bech427dd632015-05-04 15:52:33 +0200196
197.PHONY: run-only
198run-only:
199 $(call run-help)
SY Chiuc8d61452015-09-17 16:42:17 +0800200 $(call launch-terminal,54320,"Normal World")
201 $(call launch-terminal,54321,"Secure World")
Peter Maydellc8bcc902015-10-29 16:31:52 +0000202 $(call wait-for-ports,54320,54321)
Joakim Bech427dd632015-05-04 15:52:33 +0200203 $(QEMU_PATH)/arm-softmmu/qemu-system-arm \
204 -nographic \
205 -serial tcp:localhost:54320 -serial tcp:localhost:54321 \
Victor Chong6f0c0eb2016-01-24 07:43:33 +0000206 -s -S -machine virt -machine secure=on -cpu cortex-a15 \
Joakim Bech427dd632015-05-04 15:52:33 +0200207 -m 1057 \
Peter Maydell635bbf62015-10-29 17:30:11 +0000208 -bios $(ROOT)/out/bios-qemu/bios.bin $(QEMU_EXTRA_ARGS)
Joakim Bech427dd632015-05-04 15:52:33 +0200209
Jerome Forissierf080b5a2015-08-07 16:18:57 +0200210
211ifneq ($(filter check,$(MAKECMDGOALS)),)
212CHECK_DEPS := all
213endif
214
Jerome Forissier7a9463c2015-08-20 10:53:48 +0200215check-args := --bios $(ROOT)/out/bios-qemu/bios.bin
216ifneq ($(TIMEOUT),)
217check-args += --timeout $(TIMEOUT)
218endif
219
Jerome Forissierf080b5a2015-08-07 16:18:57 +0200220check: $(CHECK_DEPS)
Jerome Forissier7a9463c2015-08-20 10:53:48 +0200221 expect qemu-check.exp -- $(check-args) || \
Jerome Forissier2660ff22015-09-03 10:20:00 +0200222 (if [ "$(DUMP_LOGS_ON_ERROR)" ]; then \
223 echo "== $$PWD/serial0.log:"; \
224 cat serial0.log; \
225 echo "== end of $$PWD/serial0.log:"; \
226 echo "== $$PWD/serial1.log:"; \
227 cat serial1.log; \
228 echo "== end of $$PWD/serial1.log:"; \
229 fi; false)
Jerome Forissierf080b5a2015-08-07 16:18:57 +0200230
231check-only: check
232
233check-clean:
234 rm -f serial0.log serial1.log