-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
117 lines (97 loc) · 2.73 KB
/
Makefile
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
DEBUG ?= 1
NPROC ?= $(shell nproc)
ROOT ?= $(shell pwd)
all: buildroot u-boot linux tfa tee client
clean: clean_tfa clean_linux clean_u-boot clean_tee clean_buildroot
# Green TEE
.PHONY: tee
tee:
cd tee/ && make
clean_tee:
cd tee/ && make clean
# U-Boot
.PHONY: u-boot
u-boot:
cd u-boot && make qemu_arm64_defconfig && make -j$(NPROC)
clean_u-boot:
cd u-boot && make clean
# ARM Trusted Firmware
TFA_FLAGS ?= \
CROSS_COMPILE=aarch64-linux-gnu- \
PLAT=qemu \
BL33=$(ROOT)/u-boot/u-boot.bin \
DEBUG=$(DEBUG) \
LOG_LEVEL=40 \
ARM_LINUX_KERNEL_AS_BL33=0 \
QEMU_USE_GIC_DRIVER=QEMU_GICV3 \
BL32_RAM_LOCATION=tdram \
BL32=$(ROOT)/tee/build/tee.bin \
-j$(NPROC) \
SPD=green_teed
ifeq ($(DEBUG),1)
TFA_BUILD_PATH=arm-trusted-firmware/build/qemu/debug/
else
TFA_BUILD_PATH=arm-trusted-firmware/build/qemu/release/
endif
tfa: linux u-boot tee
cd arm-trusted-firmware && make $(TFA_FLAGS) all fip
cp $(TFA_BUILD_PATH)/qemu_fw.bios $(TFA_BUILD_PATH)/../
clean_tfa:
rm -f $(TFA_BUILD_PATH)/../qemu_fw.bios
cd arm-trusted-firmware && make clean
# Buildroot
.PHONY: buildroot
buildroot:
cd buildroot/ && make qemu_aarch64_virt_defconfig && make -j$(NPROC)
clean_buildroot:
cd buildroot/ && make clean
# Linux Kernel
LINUX_FLAGS ?= \
ARCH=arm64 \
CROSS_COMPILE=aarch64-linux-gnu- \
-j$(NPROC)
.PHONY: linux
linux: buildroot
cp configs/linux_config linux/.config
cd linux && make $(LINUX_FLAGS) Image
cp buildroot/output/images/rootfs.ext4 linux/
clean_linux:
cd linux && make clean
rm -f linux/rootfs.ext4
# Client
.PHONY: client
client: linux
cd client && make
sudo sh mount_client.sh
clean_client:
cd client && make clean
sudo sh clean_client.sh
# Run
QEMU_ARGS ?= \
-nographic \
-kernel linux/arch/arm64/boot/Image \
-cpu max \
-smp 6 \
-machine virt,secure=on,gic-version=3 \
-bios $(TFA_BUILD_PATH)/../qemu_fw.bios \
-drive file=linux/rootfs.ext4,if=none,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 \
-m 2G \
-append "rootwait nokaslr root=/dev/vda init=/sbin/init console=ttyAMA0" \
-serial mon:stdio \
-serial tcp:localhost:12345
run:
qemu-system-aarch64 $(QEMU_ARGS)
debug:
qemu-system-aarch64 $(QEMU_ARGS) -s -S
GDB_ARGS ?= \
-ex "set confirm off" \
-ex "add-symbol-file arm-trusted-firmware/build/qemu/debug/bl1/bl1.elf" \
-ex "add-symbol-file arm-trusted-firmware/build/qemu/debug/bl2/bl2.elf" \
-ex "add-symbol-file arm-trusted-firmware/build/qemu/debug/bl31/bl31.elf" \
-ex "add-symbol-file linux/vmlinux" \
-ex "add-symbol-file tee/build/tee.elf" \
-ex "target remote localhost:1234"
gdb:
gdb-multiarch $(GDB_ARGS)
nc:
nc -l 12345 -k