blob: 7125bda83a01e4644d2044ff89f35c35aeacccdd [file] [log] [blame]
Matt Maf37a7012016-07-08 10:02:23 +08001################################################################################
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 := 64
9override COMPILE_S_KERNEL := 64
10
11-include common.mk
12
13################################################################################
14# Paths to git projects and various binaries
15################################################################################
16ARM_TF_PATH ?= $(ROOT)/arm-trusted-firmware
17
18EDK2_PATH ?= $(ROOT)/edk2
19EDK2_BIN ?= $(EDK2_PATH)/QEMU_EFI.fd
20
21QEMU_PATH ?= $(ROOT)/qemu
22
23SOC_TERM_PATH ?= $(ROOT)/soc_term
24STRACE_PATH ?= $(ROOT)/strace
25
26DEBUG = 1
27
28################################################################################
29# Targets
30################################################################################
31all: arm-tf qemu soc-term linux strace update_rootfs
32all-clean: arm-tf-clean busybox-clean linux-clean \
33 optee-os-clean optee-client-clean qemu-clean \
34 soc-term-clean check-clean strace-clean
35
36-include toolchain.mk
37
38################################################################################
39# ARM Trusted Firmware
40################################################################################
41ARM_TF_EXPORTS ?= \
42 CFLAGS="-O0 -gdwarf-2" \
43 CROSS_COMPILE="$(CCACHE)$(AARCH64_CROSS_COMPILE)"
44
45ARM_TF_FLAGS ?= \
46 BL32=$(OPTEE_OS_BIN) \
47 BL33=$(EDK2_BIN) \
48 ARM_TSP_RAM_LOCATION=tdram \
49 PLAT=qemu \
50 DEBUG=0 \
51 LOG_LEVEL=50 \
52 ERROR_DEPRECATED=1 \
53 BL32_RAM_LOCATION=tdram \
54 SPD=opteed
55
56arm-tf: optee-os edk2
57 $(ARM_TF_EXPORTS) $(MAKE) -C $(ARM_TF_PATH) $(ARM_TF_FLAGS) all fip
58
59arm-tf-clean:
60 $(ARM_TF_EXPORTS) $(MAKE) -C $(ARM_TF_PATH) $(ARM_TF_FLAGS) clean
61
62# FIXME: This is just too rough, we should build this just as we're doing for
63# FVP.
64edk2: optee-os
65ifeq ("$(wildcard $(EDK2_BIN))","")
66 mkdir -p $(EDK2_PATH)
67 wget -O $(EDK2_BIN) \
Jens Wiklander4acd3292016-10-05 18:47:35 +020068 http://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/716/QEMU-KERNEL-AARCH64/RELEASE_GCC49/QEMU_EFI.fd
Matt Maf37a7012016-07-08 10:02:23 +080069endif
70 mkdir -p $(ARM_TF_PATH)/build/qemu/release
71 ln -sf $(OPTEE_OS_BIN) $(ARM_TF_PATH)/build/qemu/release/bl32.bin
72 ln -sf $(EDK2_BIN) $(ARM_TF_PATH)/build/qemu/release/bl33.bin
73
74################################################################################
75# QEMU
76################################################################################
77qemu:
78 cd $(QEMU_PATH); ./configure --target-list=aarch64-softmmu --cc="$(CCACHE)gcc" --extra-cflags="-Wno-error"
79 $(MAKE) -C $(QEMU_PATH)
80
81qemu-clean:
82 $(MAKE) -C $(QEMU_PATH) distclean
83
84################################################################################
85# Busybox
86################################################################################
87BUSYBOX_COMMON_TARGET = fvp
88BUSYBOX_CLEAN_COMMON_TARGET = fvp clean
89BUSYBOX_COMMON_CCDIR = $(AARCH64_PATH)
90
91busybox: busybox-common
92
93busybox-clean: busybox-clean-common
94
95busybox-cleaner: busybox-cleaner-common
96
97################################################################################
98# Linux kernel
99################################################################################
100LINUX_DEFCONFIG_COMMON_ARCH := arm64
101LINUX_DEFCONFIG_COMMON_FILES := \
102 $(LINUX_PATH)/arch/arm64/configs/defconfig \
103 $(CURDIR)/kconfigs/qemu.conf
104
105linux-defconfig: $(LINUX_PATH)/.config
106
107LINUX_COMMON_FLAGS += ARCH=arm64
108
109linux: linux-common
110
111linux-defconfig-clean: linux-defconfig-clean-common
112
113LINUX_CLEAN_COMMON_FLAGS += ARCH=arm64
114
115linux-clean: linux-clean-common
116
117LINUX_CLEANER_COMMON_FLAGS += ARCH=arm64
118
119linux-cleaner: linux-cleaner-common
120
121################################################################################
122# OP-TEE
123################################################################################
124OPTEE_OS_COMMON_FLAGS += PLATFORM=vexpress-qemu_armv8a CFG_ARM64_core=y \
Etienne Carrierecc23f6b2016-10-21 10:16:00 +0200125 DEBUG=0 CFG_PM_DEBUG=0
Matt Maf37a7012016-07-08 10:02:23 +0800126optee-os: optee-os-common
127
128OPTEE_OS_CLEAN_COMMON_FLAGS += PLATFORM=vexpress-qemu_armv8a
129optee-os-clean: optee-os-clean-common
130
131optee-client: optee-client-common
132
133optee-client-clean: optee-client-clean-common
134
135################################################################################
136# Soc-term
137################################################################################
138soc-term:
139 $(MAKE) -C $(SOC_TERM_PATH)
140
141soc-term-clean:
142 $(MAKE) -C $(SOC_TERM_PATH) clean
143
144################################################################################
145# xtest / optee_test
146################################################################################
147xtest: xtest-common
148
149xtest-clean: xtest-clean-common
150
151xtest-patch: xtest-patch-common
152
153################################################################################
Victor Chong8519bcf2016-07-15 08:43:03 +0100154# hello_world
155################################################################################
156helloworld: helloworld-common
157
158helloworld-clean: helloworld-clean-common
159
160################################################################################
Matt Maf37a7012016-07-08 10:02:23 +0800161# strace
162################################################################################
163strace:
164ifneq ("$(wildcard $(STRACE_PATH))","")
165 cd $(STRACE_PATH) && \
166 ./bootstrap && \
167 ./configure --host=aarch64-linux-gnu CC=$(CROSS_COMPILE_NS_USER)gcc && \
168 CC=$(CROSS_COMPILE_NS_USER)gcc $(MAKE)
169endif
170
171strace-clean:
172ifneq ("$(wildcard $(STRACE_PATH))","")
173 CC=$(CROSS_COMPILE_NS_USER)gcc \
174 $(MAKE) -C $(STRACE_PATH) clean && \
175 rm -f $(STRACE_PATH)/Makefile $(STRACE_PATH)/configure
176endif
177
178################################################################################
179# Root FS
180################################################################################
Etienne Carriere5e113512016-10-21 10:13:57 +0200181filelist-tee: filelist-tee-common
Matt Maf37a7012016-07-08 10:02:23 +0800182ifneq ("$(wildcard $(STRACE_PATH)/strace)","")
183 @echo "file /bin/strace $(STRACE_PATH)/strace 755 0 0" >> $(GEN_ROOTFS_FILELIST)
184endif
185
Etienne Carriere5e113512016-10-21 10:13:57 +0200186update_rootfs: update_rootfs-common
Matt Maf37a7012016-07-08 10:02:23 +0800187
188################################################################################
189# Run targets
190################################################################################
191define run-help
192 @echo "Run QEMU"
193 @echo QEMU is now waiting to start the execution
194 @echo Start execution with either a \'c\' followed by \<enter\> in the QEMU console or
195 @echo attach a debugger and continue from there.
196 @echo
197 @echo To run xtest paste the following on the serial 0 prompt
198 @echo tee-supplicant\&
199 @echo sleep 0.1
200 @echo xtest
201 @echo
202 @echo To run a single test case replace the xtest command with for instance
203 @echo xtest 2001
204endef
205
206define launch-terminal
207 @nc -z 127.0.0.1 $(1) || \
208 xterm -title $(2) -e $(BASH) -c "$(SOC_TERM_PATH)/soc_term $(1)" &
209endef
210
211define wait-for-ports
212 @while ! nc -z 127.0.0.1 $(1) || ! nc -z 127.0.0.1 $(2); do sleep 1; done
213endef
214
215.PHONY: run
216# This target enforces updating root fs etc
217run: all
218 $(MAKE) run-only
219
220.PHONY: run-only
221run-only:
222 $(call run-help)
223 $(call launch-terminal,54320,"Normal World")
224 $(call launch-terminal,54321,"Secure World")
225 $(call wait-for-ports,54320,54321)
226 cd $(ARM_TF_PATH)/build/qemu/release && \
227 $(QEMU_PATH)/aarch64-softmmu/qemu-system-aarch64 \
228 -nographic \
229 -serial tcp:localhost:54320 -serial tcp:localhost:54321 \
230 -machine virt,secure=on -cpu cortex-a57 -m 1057 -bios $(ARM_TF_PATH)/build/qemu/release/bl1.bin \
231 -semihosting -d unimp \
232 -initrd $(GEN_ROOTFS_PATH)/filesystem.cpio.gz \
233 -kernel $(LINUX_PATH)/arch/arm64/boot/Image \
234 -append 'console=ttyAMA0,38400 keep_bootcon root=/dev/vda2'
235
236ifneq ($(filter check,$(MAKECMDGOALS)),)
237CHECK_DEPS := all
238endif
239
240ifneq ($(TIMEOUT),)
241check-args := --timeout $(TIMEOUT)
242endif
243
244check: $(CHECK_DEPS)
245 expect qemu-check.exp -- $(check-args) || \
246 (if [ "$(DUMP_LOGS_ON_ERROR)" ]; then \
247 echo "== $$PWD/serial0.log:"; \
248 cat serial0.log; \
249 echo "== end of $$PWD/serial0.log:"; \
250 echo "== $$PWD/serial1.log:"; \
251 cat serial1.log; \
252 echo "== end of $$PWD/serial1.log:"; \
253 fi; false)
254
255check-only: check
256
257check-clean:
258 rm -f serial0.log serial1.log