blob: 025dac95da7bfef6ab2c5cfa7cf8cd49e4cec5e7 [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:
Jorden Whitefield4b630422015-11-18 17:05:40 +000052 cd $(QEMU_PATH); ./configure --target-list=arm-softmmu --cc="$(CCACHE)gcc" --extra-cflags="-Wno-error"
Jerome Forissier2660ff22015-09-03 10:20:00 +020053 $(MAKE) -C $(QEMU_PATH)
Joakim Bech427dd632015-05-04 15:52:33 +020054
55qemu-clean:
Jerome Forissier2660ff22015-09-03 10:20:00 +020056 $(MAKE) -C $(QEMU_PATH) distclean
Joakim Bech427dd632015-05-04 15:52:33 +020057
58################################################################################
59# Busybox
60################################################################################
Pascal Brand440ef9c2015-09-08 16:01:58 +020061BUSYBOX_COMMON_TARGET = vexpress
62BUSYBOX_CLEAN_COMMON_TARGET = vexpress clean
Joakim Bech427dd632015-05-04 15:52:33 +020063
Pascal Brand440ef9c2015-09-08 16:01:58 +020064busybox: busybox-common
Joakim Bech427dd632015-05-04 15:52:33 +020065
Pascal Brand440ef9c2015-09-08 16:01:58 +020066busybox-clean: busybox-clean-common
67
68busybox-cleaner: busybox-cleaner-common
Joakim Bech427dd632015-05-04 15:52:33 +020069
70################################################################################
71# Linux kernel
72################################################################################
Jerome Forissiere1002382015-11-26 11:36:00 +010073LINUX_DEFCONFIG_COMMON_ARCH := arm
74LINUX_DEFCONFIG_COMMON_FILES := \
75 $(LINUX_PATH)/arch/arm/configs/vexpress_defconfig \
76 $(CURDIR)/kconfigs/qemu.conf
Joakim Bech427dd632015-05-04 15:52:33 +020077
78linux-defconfig: $(LINUX_PATH)/.config
79
Pascal Brande3d85982015-09-10 17:20:42 +020080LINUX_COMMON_FLAGS += ARCH=arm
Joakim Bech427dd632015-05-04 15:52:33 +020081
Pascal Brande3d85982015-09-10 17:20:42 +020082linux: linux-common
83
84linux-defconfig-clean: linux-defconfig-clean-common
85
86LINUX_CLEAN_COMMON_FLAGS += ARCH=arm
87
88linux-clean: linux-clean-common
89
90LINUX_CLEANER_COMMON_FLAGS += ARCH=arm
91
92linux-cleaner: linux-cleaner-common
Joakim Bech427dd632015-05-04 15:52:33 +020093
94################################################################################
95# OP-TEE
96################################################################################
Jerome Forissierae45fbf2015-09-04 09:40:17 +020097OPTEE_OS_COMMON_FLAGS += PLATFORM=vexpress-qemu_virt
98optee-os: optee-os-common
Joakim Bech427dd632015-05-04 15:52:33 +020099
Jerome Forissierae45fbf2015-09-04 09:40:17 +0200100OPTEE_OS_CLEAN_COMMON_FLAGS += PLATFORM=vexpress-qemu_virt
101optee-os-clean: optee-os-clean-common
Joakim Bech427dd632015-05-04 15:52:33 +0200102
Pascal Brand070d9552015-09-01 15:33:22 +0200103optee-client: optee-client-common
Jerome Forissierae45fbf2015-09-04 09:40:17 +0200104
Pascal Brand070d9552015-09-01 15:33:22 +0200105optee-client-clean: optee-client-clean-common
Jerome Forissierae45fbf2015-09-04 09:40:17 +0200106
Joakim Bech427dd632015-05-04 15:52:33 +0200107################################################################################
108# Soc-term
109################################################################################
110soc-term:
Jerome Forissier2660ff22015-09-03 10:20:00 +0200111 $(MAKE) -C $(SOC_TERM_PATH)
Joakim Bech427dd632015-05-04 15:52:33 +0200112
113soc-term-clean:
Jerome Forissier2660ff22015-09-03 10:20:00 +0200114 $(MAKE) -C $(SOC_TERM_PATH) clean
Joakim Bech427dd632015-05-04 15:52:33 +0200115
116################################################################################
117# xtest / optee_test
118################################################################################
Jerome Forissierae45fbf2015-09-04 09:40:17 +0200119xtest: xtest-common
Joakim Bech427dd632015-05-04 15:52:33 +0200120
Jerome Forissierae45fbf2015-09-04 09:40:17 +0200121xtest-clean: xtest-clean-common
Pascal Brandeab35592015-07-10 15:07:02 +0200122
Jerome Forissierae45fbf2015-09-04 09:40:17 +0200123xtest-patch: xtest-patch-common
Pascal Brandeab35592015-07-10 15:07:02 +0200124
Joakim Bech427dd632015-05-04 15:52:33 +0200125################################################################################
Victor Chong8519bcf2016-07-15 08:43:03 +0100126# hello_world
127################################################################################
128helloworld: helloworld-common
129
130helloworld-clean: helloworld-clean-common
131
132################################################################################
Joakim Bech427dd632015-05-04 15:52:33 +0200133# Root FS
134################################################################################
Etienne Carriere5e113512016-10-21 10:13:57 +0200135filelist-tee: filelist-tee-common
Joakim Bech427dd632015-05-04 15:52:33 +0200136
Etienne Carriere5e113512016-10-21 10:13:57 +0200137update_rootfs: update_rootfs-common
Joakim Bech427dd632015-05-04 15:52:33 +0200138
139################################################################################
140# Run targets
141################################################################################
142define run-help
143 @echo "Run QEMU"
144 @echo QEMU is now waiting to start the execution
145 @echo Start execution with either a \'c\' followed by \<enter\> in the QEMU console or
146 @echo attach a debugger and continue from there.
147 @echo
148 @echo To run xtest paste the following on the serial 0 prompt
Joakim Bech427dd632015-05-04 15:52:33 +0200149 @echo tee-supplicant\&
150 @echo sleep 0.1
151 @echo xtest
152 @echo
153 @echo To run a single test case replace the xtest command with for instance
Etienne Carriereba038a52016-10-21 10:16:34 +0200154 @echo xtest 1004
Joakim Bech427dd632015-05-04 15:52:33 +0200155endef
156
SY Chiuc8d61452015-09-17 16:42:17 +0800157define launch-terminal
158 @nc -z 127.0.0.1 $(1) || \
Jerome Forissiere5425ff2015-10-27 13:34:49 +0100159 xterm -title $(2) -e $(BASH) -c "$(SOC_TERM_PATH)/soc_term $(1)" &
SY Chiuc8d61452015-09-17 16:42:17 +0800160endef
161
Peter Maydellc8bcc902015-10-29 16:31:52 +0000162define wait-for-ports
163 @while ! nc -z 127.0.0.1 $(1) || ! nc -z 127.0.0.1 $(2); do sleep 1; done
164endef
165
Joakim Bech427dd632015-05-04 15:52:33 +0200166.PHONY: run
167# This target enforces updating root fs etc
Jerome Forissierae45fbf2015-09-04 09:40:17 +0200168run: all
169 $(MAKE) run-only
Joakim Bech427dd632015-05-04 15:52:33 +0200170
171.PHONY: run-only
172run-only:
173 $(call run-help)
SY Chiuc8d61452015-09-17 16:42:17 +0800174 $(call launch-terminal,54320,"Normal World")
175 $(call launch-terminal,54321,"Secure World")
Peter Maydellc8bcc902015-10-29 16:31:52 +0000176 $(call wait-for-ports,54320,54321)
Joakim Bech427dd632015-05-04 15:52:33 +0200177 $(QEMU_PATH)/arm-softmmu/qemu-system-arm \
178 -nographic \
179 -serial tcp:localhost:54320 -serial tcp:localhost:54321 \
Victor Chong6f0c0eb2016-01-24 07:43:33 +0000180 -s -S -machine virt -machine secure=on -cpu cortex-a15 \
Joakim Bech427dd632015-05-04 15:52:33 +0200181 -m 1057 \
Peter Maydell635bbf62015-10-29 17:30:11 +0000182 -bios $(ROOT)/out/bios-qemu/bios.bin $(QEMU_EXTRA_ARGS)
Joakim Bech427dd632015-05-04 15:52:33 +0200183
Jerome Forissierf080b5a2015-08-07 16:18:57 +0200184
185ifneq ($(filter check,$(MAKECMDGOALS)),)
186CHECK_DEPS := all
187endif
188
Jerome Forissier7a9463c2015-08-20 10:53:48 +0200189check-args := --bios $(ROOT)/out/bios-qemu/bios.bin
190ifneq ($(TIMEOUT),)
191check-args += --timeout $(TIMEOUT)
192endif
193
Jerome Forissierf080b5a2015-08-07 16:18:57 +0200194check: $(CHECK_DEPS)
Jerome Forissier7a9463c2015-08-20 10:53:48 +0200195 expect qemu-check.exp -- $(check-args) || \
Jerome Forissier2660ff22015-09-03 10:20:00 +0200196 (if [ "$(DUMP_LOGS_ON_ERROR)" ]; then \
197 echo "== $$PWD/serial0.log:"; \
198 cat serial0.log; \
199 echo "== end of $$PWD/serial0.log:"; \
200 echo "== $$PWD/serial1.log:"; \
201 cat serial1.log; \
202 echo "== end of $$PWD/serial1.log:"; \
203 fi; false)
Jerome Forissierf080b5a2015-08-07 16:18:57 +0200204
205check-only: check
206
207check-clean:
208 rm -f serial0.log serial1.log