xref: /rk3399_ARM-atf/plat/rpi/rpi3/platform.mk (revision ab13addd845e596fb5fba51da8d0f672cdf35eff)
1#
2# Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
7include lib/libfdt/libfdt.mk
8include lib/xlat_tables_v2/xlat_tables.mk
9
10PLAT_INCLUDES		:=	-Iplat/rpi/rpi3/include
11
12PLAT_BL_COMMON_SOURCES	:=	drivers/ti/uart/aarch64/16550_console.S	\
13				plat/rpi/rpi3/rpi3_common.c		\
14				${XLAT_TABLES_LIB_SRCS}
15
16BL1_SOURCES		+=	drivers/io/io_fip.c			\
17				drivers/io/io_memmap.c			\
18				drivers/io/io_storage.c			\
19				lib/cpus/aarch64/cortex_a53.S		\
20				plat/common/aarch64/platform_mp_stack.S	\
21				plat/rpi/rpi3/aarch64/plat_helpers.S	\
22				plat/rpi/rpi3/rpi3_bl1_setup.c		\
23				plat/rpi/rpi3/rpi3_io_storage.c		\
24				plat/rpi/rpi3/rpi3_mbox.c
25
26BL2_SOURCES		+=	common/desc_image_load.c		\
27				drivers/io/io_fip.c			\
28				drivers/io/io_memmap.c			\
29				drivers/io/io_storage.c			\
30				drivers/gpio/gpio.c			\
31				drivers/delay_timer/delay_timer.c	\
32				drivers/delay_timer/generic_delay_timer.c \
33				drivers/rpi3/gpio/rpi3_gpio.c		\
34				drivers/io/io_block.c			\
35				drivers/mmc/mmc.c			\
36				drivers/rpi3/sdhost/rpi3_sdhost.c	\
37				plat/common/aarch64/platform_mp_stack.S	\
38				plat/rpi/rpi3/aarch64/plat_helpers.S	\
39				plat/rpi/rpi3/aarch64/rpi3_bl2_mem_params_desc.c \
40				plat/rpi/rpi3/rpi3_bl2_setup.c		\
41				plat/rpi/rpi3/rpi3_image_load.c		\
42				plat/rpi/rpi3/rpi3_io_storage.c
43
44BL31_SOURCES		+=	lib/cpus/aarch64/cortex_a53.S		\
45				plat/common/plat_psci_common.c		\
46				plat/rpi/rpi3/aarch64/plat_helpers.S	\
47				plat/rpi/rpi3/rpi3_bl31_setup.c		\
48				plat/rpi/rpi3/rpi3_pm.c			\
49				plat/rpi/rpi3/rpi3_topology.c		\
50				${LIBFDT_SRCS}
51
52# Tune compiler for Cortex-A53
53ifeq ($(notdir $(CC)),armclang)
54    TF_CFLAGS_aarch64	+=	-mcpu=cortex-a53
55else ifneq ($(findstring clang,$(notdir $(CC))),)
56    TF_CFLAGS_aarch64	+=	-mcpu=cortex-a53
57else
58    TF_CFLAGS_aarch64	+=	-mtune=cortex-a53
59endif
60
61# Platform Makefile target
62# ------------------------
63
64RPI3_BL1_PAD_BIN	:=	${BUILD_PLAT}/bl1_pad.bin
65RPI3_ARMSTUB8_BIN	:=	${BUILD_PLAT}/armstub8.bin
66
67# Add new default target when compiling this platform
68all: armstub
69
70# This target concatenates BL1 and the FIP so that the base addresses match the
71# ones defined in the memory map
72armstub: bl1 fip
73	@echo "  CAT     $@"
74	${Q}cp ${BUILD_PLAT}/bl1.bin ${RPI3_BL1_PAD_BIN}
75	${Q}truncate --size=131072 ${RPI3_BL1_PAD_BIN}
76	${Q}cat ${RPI3_BL1_PAD_BIN} ${BUILD_PLAT}/fip.bin > ${RPI3_ARMSTUB8_BIN}
77	@${ECHO_BLANK_LINE}
78	@echo "Built $@ successfully"
79	@${ECHO_BLANK_LINE}
80
81# Build config flags
82# ------------------
83
84# Enable all errata workarounds for Cortex-A53
85ERRATA_A53_826319		:= 1
86ERRATA_A53_835769		:= 1
87ERRATA_A53_836870		:= 1
88ERRATA_A53_843419		:= 1
89ERRATA_A53_855873		:= 1
90
91WORKAROUND_CVE_2017_5715	:= 0
92
93# Disable stack protector by default
94ENABLE_STACK_PROTECTOR	 	:= 0
95
96# Reset to BL31 isn't supported
97RESET_TO_BL31			:= 0
98
99# Have different sections for code and rodata
100SEPARATE_CODE_AND_RODATA	:= 1
101
102# Use Coherent memory
103USE_COHERENT_MEM		:= 1
104
105# Platform build flags
106# --------------------
107
108# BL33 images are in AArch64 by default
109RPI3_BL33_IN_AARCH32		:= 0
110
111# Assume that BL33 isn't the Linux kernel by default
112RPI3_DIRECT_LINUX_BOOT		:= 0
113
114# UART to use at runtime. -1 means the runtime UART is disabled.
115# Any other value means the default UART will be used.
116RPI3_RUNTIME_UART		:= -1
117
118# Use normal memory mapping for ROM, FIP, SRAM and DRAM
119RPI3_USE_UEFI_MAP		:= 0
120
121# BL32 location
122RPI3_BL32_RAM_LOCATION	:= tdram
123ifeq (${RPI3_BL32_RAM_LOCATION}, tsram)
124  RPI3_BL32_RAM_LOCATION_ID = SEC_SRAM_ID
125else ifeq (${RPI3_BL32_RAM_LOCATION}, tdram)
126  RPI3_BL32_RAM_LOCATION_ID = SEC_DRAM_ID
127else
128  $(error "Unsupported RPI3_BL32_RAM_LOCATION value")
129endif
130
131# Process platform flags
132# ----------------------
133
134$(eval $(call add_define,RPI3_BL32_RAM_LOCATION_ID))
135$(eval $(call add_define,RPI3_BL33_IN_AARCH32))
136$(eval $(call add_define,RPI3_DIRECT_LINUX_BOOT))
137ifdef RPI3_PRELOADED_DTB_BASE
138$(eval $(call add_define,RPI3_PRELOADED_DTB_BASE))
139endif
140$(eval $(call add_define,RPI3_RUNTIME_UART))
141$(eval $(call add_define,RPI3_USE_UEFI_MAP))
142
143# Verify build config
144# -------------------
145#
146ifneq (${RPI3_DIRECT_LINUX_BOOT}, 0)
147  ifndef RPI3_PRELOADED_DTB_BASE
148    $(error Error: RPI3_PRELOADED_DTB_BASE needed if RPI3_DIRECT_LINUX_BOOT=1)
149  endif
150endif
151
152ifneq (${RESET_TO_BL31}, 0)
153  $(error Error: rpi3 needs RESET_TO_BL31=0)
154endif
155
156ifeq (${ARCH},aarch32)
157  $(error Error: AArch32 not supported on rpi3)
158endif
159
160ifneq ($(ENABLE_STACK_PROTECTOR), 0)
161PLAT_BL_COMMON_SOURCES	+=	plat/rpi/rpi3/rpi3_rng.c		\
162				plat/rpi/rpi3/rpi3_stack_protector.c
163endif
164
165ifeq (${SPD},opteed)
166BL2_SOURCES	+=							\
167		lib/optee/optee_utils.c
168endif
169
170# Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images
171# in the FIP if the platform requires.
172ifneq ($(BL32_EXTRA1),)
173$(eval $(call TOOL_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1))
174endif
175ifneq ($(BL32_EXTRA2),)
176$(eval $(call TOOL_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2))
177endif
178
179ifneq (${TRUSTED_BOARD_BOOT},0)
180
181    include drivers/auth/mbedtls/mbedtls_crypto.mk
182    include drivers/auth/mbedtls/mbedtls_x509.mk
183
184    AUTH_SOURCES	:=	drivers/auth/auth_mod.c			\
185				drivers/auth/crypto_mod.c		\
186				drivers/auth/img_parser_mod.c		\
187				drivers/auth/tbbr/tbbr_cot.c
188
189    BL1_SOURCES		+=	${AUTH_SOURCES}				\
190				bl1/tbbr/tbbr_img_desc.c		\
191				plat/common/tbbr/plat_tbbr.c		\
192				plat/rpi/rpi3/rpi3_trusted_boot.c     	\
193				plat/rpi/rpi3/rpi3_rotpk.S
194
195    BL2_SOURCES		+=	${AUTH_SOURCES}				\
196				plat/common/tbbr/plat_tbbr.c		\
197				plat/rpi/rpi3/rpi3_trusted_boot.c     	\
198				plat/rpi/rpi3/rpi3_rotpk.S
199
200    ROT_KEY             = $(BUILD_PLAT)/rot_key.pem
201    ROTPK_HASH          = $(BUILD_PLAT)/rotpk_sha256.bin
202
203    $(eval $(call add_define_val,ROTPK_HASH,'"$(ROTPK_HASH)"'))
204
205    $(BUILD_PLAT)/bl1/rpi3_rotpk.o: $(ROTPK_HASH)
206    $(BUILD_PLAT)/bl2/rpi3_rotpk.o: $(ROTPK_HASH)
207
208    certificates: $(ROT_KEY)
209
210    $(ROT_KEY):
211	@echo "  OPENSSL $@"
212	$(Q)openssl genrsa 2048 > $@ 2>/dev/null
213
214    $(ROTPK_HASH): $(ROT_KEY)
215	@echo "  OPENSSL $@"
216	$(Q)openssl rsa -in $< -pubout -outform DER 2>/dev/null |\
217	openssl dgst -sha256 -binary > $@ 2>/dev/null
218endif
219