blob: ef8b78151d7ad8541e97f2bd66db97d0bc3875f5 [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
144 @echo "Run QEMU"
145 @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 xtest paste the following on the serial 0 prompt
Joakim Bech427dd632015-05-04 15:52:33 +0200150 @echo tee-supplicant\&
151 @echo sleep 0.1
152 @echo xtest
153 @echo
154 @echo To run a single test case replace the xtest command with for instance
Etienne Carriereba038a52016-10-21 10:16:34 +0200155 @echo xtest 1004
Joakim Bech427dd632015-05-04 15:52:33 +0200156endef
157
SY Chiuc8d61452015-09-17 16:42:17 +0800158define launch-terminal
159 @nc -z 127.0.0.1 $(1) || \
Jerome Forissiere5425ff2015-10-27 13:34:49 +0100160 xterm -title $(2) -e $(BASH) -c "$(SOC_TERM_PATH)/soc_term $(1)" &
SY Chiuc8d61452015-09-17 16:42:17 +0800161endef
162
Peter Maydellc8bcc902015-10-29 16:31:52 +0000163define wait-for-ports
164 @while ! nc -z 127.0.0.1 $(1) || ! nc -z 127.0.0.1 $(2); do sleep 1; done
165endef
166
Joakim Bech427dd632015-05-04 15:52:33 +0200167.PHONY: run
168# This target enforces updating root fs etc
Jerome Forissierae45fbf2015-09-04 09:40:17 +0200169run: all
170 $(MAKE) run-only
Joakim Bech427dd632015-05-04 15:52:33 +0200171
172.PHONY: run-only
173run-only:
174 $(call run-help)
SY Chiuc8d61452015-09-17 16:42:17 +0800175 $(call launch-terminal,54320,"Normal World")
176 $(call launch-terminal,54321,"Secure World")
Peter Maydellc8bcc902015-10-29 16:31:52 +0000177 $(call wait-for-ports,54320,54321)
Joakim Bech427dd632015-05-04 15:52:33 +0200178 $(QEMU_PATH)/arm-softmmu/qemu-system-arm \
179 -nographic \
180 -serial tcp:localhost:54320 -serial tcp:localhost:54321 \
Victor Chong6f0c0eb2016-01-24 07:43:33 +0000181 -s -S -machine virt -machine secure=on -cpu cortex-a15 \
Joakim Bech427dd632015-05-04 15:52:33 +0200182 -m 1057 \
Igor Opaniuk97d05292016-10-26 14:46:14 +0300183 -bios $(ROOT)/out/bios-qemu/bios.bin \
184 $(QEMU_EXTRA_ARGS)
Joakim Bech427dd632015-05-04 15:52:33 +0200185
Jerome Forissierf080b5a2015-08-07 16:18:57 +0200186
187ifneq ($(filter check,$(MAKECMDGOALS)),)
188CHECK_DEPS := all
189endif
190
Jerome Forissier7a9463c2015-08-20 10:53:48 +0200191check-args := --bios $(ROOT)/out/bios-qemu/bios.bin
192ifneq ($(TIMEOUT),)
193check-args += --timeout $(TIMEOUT)
194endif
195
Jerome Forissierf080b5a2015-08-07 16:18:57 +0200196check: $(CHECK_DEPS)
Jerome Forissier7a9463c2015-08-20 10:53:48 +0200197 expect qemu-check.exp -- $(check-args) || \
Jerome Forissier2660ff22015-09-03 10:20:00 +0200198 (if [ "$(DUMP_LOGS_ON_ERROR)" ]; then \
199 echo "== $$PWD/serial0.log:"; \
200 cat serial0.log; \
201 echo "== end of $$PWD/serial0.log:"; \
202 echo "== $$PWD/serial1.log:"; \
203 cat serial1.log; \
204 echo "== end of $$PWD/serial1.log:"; \
205 fi; false)
Jerome Forissierf080b5a2015-08-07 16:18:57 +0200206
207check-only: check
208
209check-clean:
210 rm -f serial0.log serial1.log