forked from OP-TEE/build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqemu.mk
215 lines (174 loc) · 6.59 KB
/
qemu.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
################################################################################
# Following variables defines how the NS_USER (Non Secure User - Client
# Application), NS_KERNEL (Non Secure Kernel), S_KERNEL (Secure Kernel) and
# S_USER (Secure User - TA) are compiled
################################################################################
override COMPILE_NS_USER := 32
override COMPILE_NS_KERNEL := 32
override COMPILE_S_USER := 32
override COMPILE_S_KERNEL := 32
include common.mk
################################################################################
# Paths to git projects and various binaries
################################################################################
ARM_TF_PATH ?= $(ROOT)/arm-trusted-firmware
BINARIES_PATH ?= $(ROOT)/out/bin
U-BOOT_PATH ?= $(ROOT)/u-boot
QEMU_PATH ?= $(ROOT)/qemu
SOC_TERM_PATH ?= $(ROOT)/soc_term
DEBUG = 1
################################################################################
# Targets
################################################################################
all: arm-tf u-boot buildroot linux optee-os qemu soc-term
clean: arm-tf-clean u-boot-clean buildroot-clean linux-clean optee-os-clean \
qemu-clean soc-term-clean check-clean
include toolchain.mk
################################################################################
# ARM Trusted Firmware
################################################################################
ARM_TF_EXPORTS ?= \
CROSS_COMPILE="$(CCACHE)$(AARCH32_CROSS_COMPILE)"
ARM_TF_DEBUG ?= $(DEBUG)
ifeq ($(ARM_TF_DEBUG),0)
ARM_TF_LOGLVL ?= 30
ARM_TF_OUT = $(ARM_TF_PATH)/build/qemu/release
else
ARM_TF_LOGLVL ?= 50
ARM_TF_OUT = $(ARM_TF_PATH)/build/qemu/debug
endif
ARM_TF_FLAGS ?= \
BL32=$(OPTEE_OS_HEADER_V2_BIN) \
BL32_EXTRA1=$(OPTEE_OS_PAGER_V2_BIN) \
BL32_EXTRA2=$(OPTEE_OS_PAGEABLE_V2_BIN) \
BL33=$(ROOT)/u-boot/u-boot.bin \
ARM_ARCH_MAJOR=7 \
ARCH=aarch32 \
PLAT=qemu \
DEBUG=$(ARM_TF_DEBUG) \
ENABLE_ASSERTIONS=$(ARM_TF_DEBUG) \
LOG_LEVEL=$(ARM_TF_LOGLVL) \
MULTI_CONSOLE_API=0 \
ARM_TSP_RAM_LOCATION=tdram \
BL32_RAM_LOCATION=tdram \
AARCH32_SP=optee
arm-tf: optee-os u-boot
$(ARM_TF_EXPORTS) $(MAKE) -C $(ARM_TF_PATH) $(ARM_TF_FLAGS) all fip
mkdir -p $(BINARIES_PATH)
ln -sf $(ARM_TF_OUT)/bl1.bin $(BINARIES_PATH)
ln -sf $(ARM_TF_OUT)/bl2.bin $(BINARIES_PATH)
ln -sf $(OPTEE_OS_HEADER_V2_BIN) $(BINARIES_PATH)/bl32.bin
ln -sf $(OPTEE_OS_PAGER_V2_BIN) $(BINARIES_PATH)/bl32_extra1.bin
ln -sf $(OPTEE_OS_PAGEABLE_V2_BIN) $(BINARIES_PATH)/bl32_extra2.bin
ln -sf $(ROOT)/u-boot/u-boot.bin $(BINARIES_PATH)/bl33.bin
arm-tf-clean:
$(ARM_TF_EXPORTS) $(MAKE) -C $(ARM_TF_PATH) $(ARM_TF_FLAGS) clean
################################################################################
# QEMU
################################################################################
qemu:
cd $(QEMU_PATH); ./configure --target-list=arm-softmmu\
$(QEMU_CONFIGURE_PARAMS_COMMON)
$(MAKE) -C $(QEMU_PATH)
qemu-clean:
$(MAKE) -C $(QEMU_PATH) distclean
################################################################################
# U-boot
################################################################################
U-BOOT_EXPORTS ?= CROSS_COMPILE="$(CCACHE)$(AARCH32_CROSS_COMPILE)"
U-BOOT_DEFCONFIG_FILES := \
$(U-BOOT_PATH)/configs/qemu_arm_defconfig \
$(ROOT)/build/kconfigs/u-boot_qemu_virt_v7.conf
.PHONY: u-boot
u-boot:
cd $(U-BOOT_PATH) && \
scripts/kconfig/merge_config.sh $(U-BOOT_DEFCONFIG_FILES)
$(U-BOOT_EXPORTS) $(MAKE) -C $(U-BOOT_PATH) all
.PHONY: u-boot-clean
u-boot-clean:
$(U-BOOT_EXPORTS) $(MAKE) -C $(U-BOOT_PATH) clean
.PHONY: u-boot-cscope
u-boot-cscope:
$(U-BOOT_EXPORTS) $(MAKE) -C $(U-BOOT_PATH) cscope
################################################################################
# Linux kernel
################################################################################
LINUX_DEFCONFIG_COMMON_ARCH := arm
LINUX_DEFCONFIG_COMMON_FILES := \
$(LINUX_PATH)/arch/arm/configs/vexpress_defconfig \
$(CURDIR)/kconfigs/qemu.conf
linux-defconfig: $(LINUX_PATH)/.config
LINUX_COMMON_FLAGS += ARCH=arm
linux: linux-common
mkdir -p $(BINARIES_PATH)
ln -sf $(LINUX_PATH)/arch/arm/boot/zImage $(BINARIES_PATH)
linux-defconfig-clean: linux-defconfig-clean-common
LINUX_CLEAN_COMMON_FLAGS += ARCH=arm
linux-clean: linux-clean-common
LINUX_CLEANER_COMMON_FLAGS += ARCH=arm
linux-cleaner: linux-cleaner-common
################################################################################
# OP-TEE
################################################################################
OPTEE_OS_COMMON_FLAGS += PLATFORM=vexpress-qemu_virt
optee-os: optee-os-common
OPTEE_OS_CLEAN_COMMON_FLAGS += PLATFORM=vexpress-qemu_virt
optee-os-clean: optee-os-clean-common
optee-client: optee-client-common
optee-client-clean: optee-client-clean-common
################################################################################
# Soc-term
################################################################################
soc-term:
$(MAKE) -C $(SOC_TERM_PATH)
soc-term-clean:
$(MAKE) -C $(SOC_TERM_PATH) clean
################################################################################
# Run targets
################################################################################
.PHONY: run
# This target enforces updating root fs etc
run: all
ln -sf $(ROOT)/out-br/images/rootfs.cpio.gz $(BINARIES_PATH)/
$(MAKE) run-only
QEMU_SMP ?= 1
.PHONY: run-only
run-only:
$(call check-terminal)
$(call run-help)
$(call launch-terminal,54320,"Normal World")
$(call launch-terminal,54321,"Secure World")
$(call wait-for-ports,54320,54321)
(cd $(BINARIES_PATH) && $(QEMU_PATH)/arm-softmmu/qemu-system-arm \
-nographic \
-serial tcp:localhost:54320 -serial tcp:localhost:54321 \
-smp $(QEMU_SMP) \
-s -S -machine virt -machine secure=on -cpu cortex-a15 \
-d unimp -semihosting-config enable,target=native \
-m 1057 \
-bios bl1.bin \
$(QEMU_EXTRA_ARGS) )
ifneq ($(filter check,$(MAKECMDGOALS)),)
CHECK_DEPS := all
endif
check-args := --bios $(BINARIES_PATH)/bl1.bin
ifneq ($(TIMEOUT),)
check-args += --timeout $(TIMEOUT)
endif
check: $(CHECK_DEPS)
ln -sf $(ROOT)/out-br/images/rootfs.cpio.gz $(BINARIES_PATH)/
cd $(BINARIES_PATH) && \
export QEMU=$(ROOT)/qemu/arm-softmmu/qemu-system-arm && \
export QEMU_SMP=$(QEMU_SMP) && \
expect $(ROOT)/build/qemu-check.exp -- $(check-args) || \
(if [ "$(DUMP_LOGS_ON_ERROR)" ]; then \
echo "== $$PWD/serial0.log:"; \
cat serial0.log; \
echo "== end of $$PWD/serial0.log:"; \
echo "== $$PWD/serial1.log:"; \
cat serial1.log; \
echo "== end of $$PWD/serial1.log:"; \
fi; false)
check-only: check
check-clean:
rm -f serial0.log serial1.log