forked from OP-TEE/build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qemu.mk
222 lines (181 loc) · 6.97 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
216
217
218
219
220
221
222
################################################################################
# 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
BR2_ROOTFS_OVERLAY = $(ROOT)/build/br-ext/board/qemu/overlay
BR2_ROOTFS_POST_BUILD_SCRIPT = $(ROOT)/build/br-ext/board/qemu/post-build.sh
BR2_ROOTFS_POST_SCRIPT_ARGS = "$(QEMU_VIRTFS_AUTOMOUNT) $(QEMU_VIRTFS_MOUNTPOINT) $(QEMU_PSS_AUTOMOUNT)"
OPTEE_OS_PLATFORM = vexpress-qemu_virt
include common.mk
################################################################################
# Paths to git projects and various binaries
################################################################################
TF_A_PATH ?= $(ROOT)/trusted-firmware-a
BINARIES_PATH ?= $(ROOT)/out/bin
U-BOOT_PATH ?= $(ROOT)/u-boot
QEMU_PATH ?= $(ROOT)/qemu
QEMU_BUILD ?= $(QEMU_PATH)/build
DEBUG = 1
################################################################################
# Targets
################################################################################
all: arm-tf u-boot buildroot linux optee-os qemu
clean: arm-tf-clean u-boot-clean buildroot-clean linux-clean optee-os-clean \
qemu-clean check-clean
include toolchain.mk
################################################################################
# ARM Trusted Firmware
################################################################################
TF_A_EXPORTS ?= \
CROSS_COMPILE="$(CCACHE)$(AARCH32_CROSS_COMPILE)"
TF_A_DEBUG ?= $(DEBUG)
ifeq ($(TF_A_DEBUG),0)
TF_A_LOGLVL ?= 30
TF_A_OUT = $(TF_A_PATH)/build/qemu/release
else
TF_A_LOGLVL ?= 50
TF_A_OUT = $(TF_A_PATH)/build/qemu/debug
endif
TF_A_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 \
ARM_TSP_RAM_LOCATION=tdram \
BL32_RAM_LOCATION=tdram \
AARCH32_SP=optee \
DEBUG=$(TF_A_DEBUG) \
LOG_LEVEL=$(TF_A_LOGLVL) \
arm-tf: optee-os u-boot
$(TF_A_EXPORTS) $(MAKE) -C $(TF_A_PATH) $(TF_A_FLAGS) all fip
mkdir -p $(BINARIES_PATH)
ln -sf $(TF_A_OUT)/bl1.bin $(BINARIES_PATH)
ln -sf $(TF_A_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:
$(TF_A_EXPORTS) $(MAKE) -C $(TF_A_PATH) $(TF_A_FLAGS) clean
################################################################################
# QEMU
################################################################################
$(QEMU_BUILD)/config-host.mak:
cd $(QEMU_PATH); ./configure --target-list=arm-softmmu\
$(QEMU_CONFIGURE_PARAMS_COMMON)
qemu: $(QEMU_BUILD)/config-host.mak
$(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_COMMON_TARGETS += zImage
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: optee-os-common
optee-os-clean: optee-os-clean-common
################################################################################
# Run targets
################################################################################
.PHONY: run
# This target enforces updating root fs etc
run: all
$(MAKE) run-only
QEMU_SMP ?= 2
QEMU_MEM ?= 1057
QEMU_BASE_ARGS = -nographic
QEMU_BASE_ARGS += -smp $(QEMU_SMP)
QEMU_BASE_ARGS += -d unimp -semihosting-config enable=on,target=native
QEMU_BASE_ARGS += -m $(QEMU_MEM)
QEMU_BASE_ARGS += -bios bl1.bin
QEMU_BASE_ARGS += -machine virt,secure=on -cpu cortex-a15
QEMU_BASE_ARGS += $(QEMU_EXTRA_ARGS)
QEMU_RUN_ARGS = $(QEMU_BASE_ARGS)
QEMU_RUN_ARGS += $(QEMU_RUN_ARGS_COMMON)
QEMU_RUN_ARGS += -s -S -serial tcp:127.0.0.1:$(QEMU_NW_PORT) -serial tcp:127.0.0.1:$(QEMU_SW_PORT)
.PHONY: run-only
run-only:
ln -sf $(ROOT)/out-br/images/rootfs.cpio.gz $(BINARIES_PATH)/
$(call check-terminal)
$(call run-help)
$(call launch-terminal,$(QEMU_NW_PORT),"Normal World")
$(call launch-terminal,$(QEMU_SW_PORT),"Secure World")
$(call wait-for-ports,$(QEMU_NW_PORT),$(QEMU_SW_PORT))
cd $(BINARIES_PATH) && $(QEMU_BUILD)/arm-softmmu/qemu-system-arm \
$(QEMU_RUN_ARGS)
ifneq ($(filter check,$(MAKECMDGOALS)),)
CHECK_DEPS := all
endif
check-args := --bios $(BINARIES_PATH)/bl1.bin
ifneq ($(TIMEOUT),)
check-args += --timeout $(TIMEOUT)
endif
ifneq ($(CHECK_TESTS),)
check-args += --tests $(CHECK_TESTS)
endif
ifneq ($(XTEST_ARGS),)
check-args += --xtest-args "$(XTEST_ARGS)"
endif
QEMU_CHECK_ARGS = $(QEMU_BASE_ARGS)
QEMU_CHECK_ARGS += -monitor none
QEMU_CHECK_ARGS += -serial stdio -serial file:serial1.log
check: $(CHECK_DEPS)
ln -sf $(ROOT)/out-br/images/rootfs.cpio.gz $(BINARIES_PATH)/
cd $(BINARIES_PATH) && \
export QEMU=$(QEMU_BUILD)/arm-softmmu/qemu-system-arm && \
export QEMU_CHECK_ARGS="$(QEMU_CHECK_ARGS)" && \
export XEN_BOOT=n && \
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