blob: f1019ab1b608f564bf60f01e7a7a1edff1c52af0 [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 \
Jens Wiklandera6d968c2016-01-28 18:35:11 +010028 optee-client-clean qemu-clean soc-term-clean check-clean
Joakim Bech427dd632015-05-04 15:52:33 +020029
30-include toolchain.mk
31
32################################################################################
33# QEMU
34################################################################################
35define bios-qemu-common
Jerome Forissier2660ff22015-09-03 10:20:00 +020036 +$(MAKE) -C $(BIOS_QEMU_PATH) \
37 CROSS_COMPILE=$(CROSS_COMPILE_NS_USER) \
Joakim Bech427dd632015-05-04 15:52:33 +020038 O=$(ROOT)/out/bios-qemu \
39 BIOS_NSEC_BLOB=$(LINUX_PATH)/arch/arm/boot/zImage \
40 BIOS_NSEC_ROOTFS=$(GEN_ROOTFS_PATH)/filesystem.cpio.gz \
41 BIOS_SECURE_BLOB=$(OPTEE_OS_BIN) \
42 PLATFORM_FLAVOR=virt
43endef
44
Jerome Forissier2660ff22015-09-03 10:20:00 +020045bios-qemu: update_rootfs optee-os
Joakim Bech427dd632015-05-04 15:52:33 +020046 $(call bios-qemu-common)
47
48bios-qemu-clean:
49 $(call bios-qemu-common) clean
50
51qemu:
Igor Opaniuk97d05292016-10-26 14:46:14 +030052 cd $(QEMU_PATH); ./configure --target-list=arm-softmmu\
53 $(QEMU_CONFIGURE_PARAMS_COMMON)
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
Joakim Bech427dd632015-05-04 15:52:33 +0200108################################################################################
109# Soc-term
110################################################################################
111soc-term:
Jerome Forissier2660ff22015-09-03 10:20:00 +0200112 $(MAKE) -C $(SOC_TERM_PATH)
Joakim Bech427dd632015-05-04 15:52:33 +0200113
114soc-term-clean:
Jerome Forissier2660ff22015-09-03 10:20:00 +0200115 $(MAKE) -C $(SOC_TERM_PATH) clean
Joakim Bech427dd632015-05-04 15:52:33 +0200116
117################################################################################
118# xtest / optee_test
119################################################################################
Jerome Forissierae45fbf2015-09-04 09:40:17 +0200120xtest: xtest-common
Joakim Bech427dd632015-05-04 15:52:33 +0200121
Jerome Forissierae45fbf2015-09-04 09:40:17 +0200122xtest-clean: xtest-clean-common
Pascal Brandeab35592015-07-10 15:07:02 +0200123
Jerome Forissierae45fbf2015-09-04 09:40:17 +0200124xtest-patch: xtest-patch-common
Pascal Brandeab35592015-07-10 15:07:02 +0200125
Joakim Bech427dd632015-05-04 15:52:33 +0200126################################################################################
Victor Chong8519bcf2016-07-15 08:43:03 +0100127# hello_world
128################################################################################
129helloworld: helloworld-common
130
131helloworld-clean: helloworld-clean-common
132
133################################################################################
Joakim Bech427dd632015-05-04 15:52:33 +0200134# Root FS
135################################################################################
Etienne Carriere5e113512016-10-21 10:13:57 +0200136filelist-tee: filelist-tee-common
Joakim Bech427dd632015-05-04 15:52:33 +0200137
Etienne Carriere5e113512016-10-21 10:13:57 +0200138update_rootfs: update_rootfs-common
Joakim Bech427dd632015-05-04 15:52:33 +0200139
140################################################################################
141# Run targets
142################################################################################
143define run-help
Joakim Bech427dd632015-05-04 15:52:33 +0200144 @echo
Jerome Forissierd6970872017-01-31 15:16:21 +0100145 @echo \* QEMU is now waiting to start the execution
146 @echo \* Start execution with either a \'c\' followed by \<enter\> in the QEMU console or
147 @echo \* attach a debugger and continue from there.
148 @echo \*
149 @echo \* To run OP-TEE tests, use the xtest command in the \'Normal World\' terminal
150 @echo \* Enter \'xtest -h\' for help.
Joakim Bech427dd632015-05-04 15:52:33 +0200151 @echo
Joakim Bech427dd632015-05-04 15:52:33 +0200152endef
153
SY Chiuc8d61452015-09-17 16:42:17 +0800154define launch-terminal
155 @nc -z 127.0.0.1 $(1) || \
Jerome Forissiere5425ff2015-10-27 13:34:49 +0100156 xterm -title $(2) -e $(BASH) -c "$(SOC_TERM_PATH)/soc_term $(1)" &
SY Chiuc8d61452015-09-17 16:42:17 +0800157endef
158
Peter Maydellc8bcc902015-10-29 16:31:52 +0000159define wait-for-ports
160 @while ! nc -z 127.0.0.1 $(1) || ! nc -z 127.0.0.1 $(2); do sleep 1; done
161endef
162
Joakim Bech427dd632015-05-04 15:52:33 +0200163.PHONY: run
164# This target enforces updating root fs etc
Jerome Forissierae45fbf2015-09-04 09:40:17 +0200165run: all
166 $(MAKE) run-only
Joakim Bech427dd632015-05-04 15:52:33 +0200167
168.PHONY: run-only
169run-only:
170 $(call run-help)
SY Chiuc8d61452015-09-17 16:42:17 +0800171 $(call launch-terminal,54320,"Normal World")
172 $(call launch-terminal,54321,"Secure World")
Peter Maydellc8bcc902015-10-29 16:31:52 +0000173 $(call wait-for-ports,54320,54321)
Joakim Bech427dd632015-05-04 15:52:33 +0200174 $(QEMU_PATH)/arm-softmmu/qemu-system-arm \
175 -nographic \
176 -serial tcp:localhost:54320 -serial tcp:localhost:54321 \
Victor Chong6f0c0eb2016-01-24 07:43:33 +0000177 -s -S -machine virt -machine secure=on -cpu cortex-a15 \
Joakim Bech427dd632015-05-04 15:52:33 +0200178 -m 1057 \
Igor Opaniuk97d05292016-10-26 14:46:14 +0300179 -bios $(ROOT)/out/bios-qemu/bios.bin \
180 $(QEMU_EXTRA_ARGS)
Joakim Bech427dd632015-05-04 15:52:33 +0200181
Jerome Forissierf080b5a2015-08-07 16:18:57 +0200182
183ifneq ($(filter check,$(MAKECMDGOALS)),)
184CHECK_DEPS := all
185endif
186
Jerome Forissier7a9463c2015-08-20 10:53:48 +0200187check-args := --bios $(ROOT)/out/bios-qemu/bios.bin
188ifneq ($(TIMEOUT),)
189check-args += --timeout $(TIMEOUT)
190endif
191
Jerome Forissierf080b5a2015-08-07 16:18:57 +0200192check: $(CHECK_DEPS)
Jerome Forissier7a9463c2015-08-20 10:53:48 +0200193 expect qemu-check.exp -- $(check-args) || \
Jerome Forissier2660ff22015-09-03 10:20:00 +0200194 (if [ "$(DUMP_LOGS_ON_ERROR)" ]; then \
195 echo "== $$PWD/serial0.log:"; \
196 cat serial0.log; \
197 echo "== end of $$PWD/serial0.log:"; \
198 echo "== $$PWD/serial1.log:"; \
199 cat serial1.log; \
200 echo "== end of $$PWD/serial1.log:"; \
201 fi; false)
Jerome Forissierf080b5a2015-08-07 16:18:57 +0200202
203check-only: check
204
205check-clean:
206 rm -f serial0.log serial1.log