-
Notifications
You must be signed in to change notification settings - Fork 221
/
versal2.mk
172 lines (132 loc) · 5.7 KB
/
versal2.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
################################################################################
# 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 := 64
override COMPILE_NS_KERNEL := 64
override COMPILE_S_USER := 64
override COMPILE_S_KERNEL := 64
# Network support related packages:
BR2_PACKAGE_DHCPCD ?= y
BR2_PACKAGE_ETHTOOL ?= y
BR2_PACKAGE_XINETD ?= y
# SSH Packages :
BR2_PACKAGE_OPENSSH ?= y
BR2_PACKAGE_OPENSSH_SERVER ?= y
BR2_PACKAGE_OPENSSH_KEY_UTILS ?= y
# Openssl binary
BR2_PACKAGE_LIBOPENSSL_BIN ?= y
BR2_PACKAGE_LIBP11 ?= y
PLATFORM = AMD Versal Gen 2
OPTEE_OS_PLATFORM = versal2
OPTEE_OS_COMMON_EXTRA_FLAGS ?= CFG_PKCS11_TA=y CFG_USER_TA_TARGET_pkcs11=ta_arm64 O=out/arm
################################################################################
# Paths to git projects and various binaries
################################################################################
TF_A_PATH ?= $(ROOT)/arm-trusted-firmware
U-BOOT_PATH ?= $(ROOT)/u-boot-xlnx
LINUX_PATH ?= $(ROOT)/linux-xlnx
include common.mk
BINARIES_PATH ?= $(ROOT)/out/bin
TF_A_ELF ?= $(TF_A_PATH)/build/$(OPTEE_OS_PLATFORM)/release/bl31/bl31.elf
OPTEE_OS_ELF ?= $(OPTEE_OS_PATH)/out/arm/core/tee.elf
U-BOOT_ELF ?= $(U-BOOT_PATH)/u-boot.elf
U-BOOT_DTB ?= $(U-BOOT_PATH)/arch/arm/dts/versal2-*.dtb
MKIMAGE_PATH ?= $(U-BOOT_PATH)/tools
LINUX_IMAGE ?= $(LINUX_PATH)/arch/arm64/boot/Image
ROOTFS_GZ ?= $(ROOT)/out-br/images/rootfs.cpio.gz
ROOTFS_SIGN ?= $(BINARIES_PATH)/rootfs.cpio.gz.u-boot
################################################################################
# Targets
################################################################################
all: tfa optee-os dtbo u-boot linux buildroot buildroot_mkimg
clean: tfa-clean optee-os-clean dtbo-clean u-boot-clean linux-clean buildroot-clean
$(BINARIES_PATH):
mkdir -p $@
include toolchain.mk
################################################################################
# ARM Trusted Firmware
################################################################################
TF_A_EXPORTS = CROSS_COMPILE="$(CCACHE)$(AARCH64_CROSS_COMPILE)"
TF_A_FLAGS = PLAT=versal2 CONSOLE=pl011 RESET_TO_BL31=1 SPD=opteed DEBUG=0 \
MEM_BASE=0x1600000 MEM_SIZE=0x200000 \
XILINX_OF_BOARD_DTB_ADDR=0x1000 \
BL32_MEM_BASE=0x1800000 BL32_MEM_SIZE=0x8000000
tfa:
$(TF_A_EXPORTS) $(MAKE) -C $(TF_A_PATH) $(TF_A_FLAGS) bl31
mkdir -p $(BINARIES_PATH)
cp $(TF_A_ELF) $(BINARIES_PATH)
tfa-clean:
$(TF_A_EXPORTS) $(MAKE) -C $(TF_A_PATH) $(TF_A_FLAGS) clean
################################################################################
# OP-TEE
################################################################################
OPTEE_OS_COMMON_FLAGS += CFG_TEE_CORE_LOG_LEVEL=2 CFG_TEE_TA_LOG_LEVEL=2
optee-os: optee-os-common
mkdir -p $(BINARIES_PATH)
cp $(OPTEE_OS_ELF) $(BINARIES_PATH)
optee-os-clean: optee-os-clean-common
rm -rf ${OPTEE_OS_PATH}/out/
################################################################################
# U-Boot
################################################################################
U-BOOT_EXPORTS = CROSS_COMPILE="$(CCACHE)$(AARCH64_CROSS_COMPILE)"
U-BOOT_DEFCONFIG_COMMON_FILES := $(U-BOOT_PATH)/configs/amd_versal2_virt_defconfig \
$(BUILD_PATH)/kconfigs/u-boot_versal2.conf
u-boot-defconfig: $(U-BOOT_DEFCONFIG_COMMON_FILES)
cd $(U-BOOT_PATH) && \
ARCH=arm64 \
scripts/kconfig/merge_config.sh $(U-BOOT_DEFCONFIG_COMMON_FILES)
u-boot: u-boot-defconfig
$(U-BOOT_EXPORTS) $(MAKE) -C $(U-BOOT_PATH)
mkdir -p $(BINARIES_PATH)
cp $(U-BOOT_ELF) $(BINARIES_PATH)
u-boot-defconfig-clean:
rm -f $(U-BOOT_PATH)/.config
u-boot-clean: u-boot-defconfig-clean
$(U-BOOT_EXPORTS) $(MAKE) -C $(U-BOOT_PATH) clean
###############################################################################
# Device-Tree
###############################################################################
dtbo: u-boot
mkdir -p $(BINARIES_PATH)
${LINUX_PATH}/scripts/dtc/dtc -@ -I dts \
-O dtb -o $(BINARIES_PATH)/versal2-memory-reservation.dtbo \
$(BUILD_PATH)/versal2/versal2-memory-reservation.dtso
@$(foreach dtb,$(wildcard $(U-BOOT_DTB)), \
${LINUX_PATH}/scripts/dtc/fdtoverlay -i $(dtb) \
-o $(dtb) $(BINARIES_PATH)/versal2-memory-reservation.dtbo ; \
echo "Applied overlay to $(dtb)";)
cp $(U-BOOT_DTB) $(BINARIES_PATH)
dtbo-clean:
rm -f $(BINARIES_PATH)/versal2-memory-reservation.dtbo
################################################################################
# Linux kernel
################################################################################
LINUX_DEFCONFIG_COMMON_ARCH := arm64
LINUX_DEFCONFIG_COMMON_FILES := \
$(LINUX_PATH)/arch/arm64/configs/xilinx_defconfig \
$(BUILD_PATH)/kconfigs/versal2.conf
linux-defconfig: $(LINUX_PATH)/.config
LINUX_COMMON_FLAGS += ARCH=arm64
linux: linux-common
mkdir -p $(BINARIES_PATH)
cp $(LINUX_IMAGE) $(BINARIES_PATH)
linux-defconfig-clean: linux-defconfig-clean-common
LINUX_CLEAN_COMMON_FLAGS += ARCH=arm64
linux-clean: linux-clean-common
LINUX_CLEANER_COMMON_FLAGS += ARCH=arm64
linux-cleaner: linux-cleaner-common
################################################################################
# Buildroot
################################################################################
BR2_TARGET_GENERIC_ISSUE ?= "OP-TEE embedded distrib for $(PLATFORM)"
BR2_TARGET_ROOTFS_EXT2 ?= y
BR2_PACKAGE_BUSYBOX_WATCHDOG ?= y
buildroot_mkimg: buildroot
mkdir -p $(BINARIES_PATH)
$(MKIMAGE_PATH)/mkimage -A arm \
-T ramdisk \
-C gzip \
-d $(ROOTFS_GZ) $(ROOTFS_SIGN)