blob: 4276c84f8841057916af11df9e09d1801dbf585e [file] [log] [blame]
Antonio Nino Diazae6779e2017-11-06 14:49:04 +00001#
Antonio Nino Diaz1f470022018-03-27 09:39:47 +01002# Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
Antonio Nino Diazae6779e2017-11-06 14:49:04 +00003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
7PLAT_INCLUDES := -Iinclude/common/tbbr \
8 -Iinclude/plat/arm/common/ \
9 -Iinclude/plat/arm/common/aarch64/ \
10 -Iplat/rpi3/include
11
12PLAT_BL_COMMON_SOURCES := drivers/console/aarch64/console.S \
13 drivers/ti/uart/aarch64/16550_console.S \
14 plat/rpi3/rpi3_common.c
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/rpi3/aarch64/plat_helpers.S \
22 plat/rpi3/rpi3_bl1_setup.c \
Antonio Nino Diazecf34712018-07-12 13:38:53 +010023 plat/rpi3/rpi3_io_storage.c \
24 plat/rpi3/rpi3_mbox.c
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000025
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 plat/common/aarch64/platform_mp_stack.S \
31 plat/rpi3/aarch64/plat_helpers.S \
32 plat/rpi3/aarch64/rpi3_bl2_mem_params_desc.c \
33 plat/rpi3/rpi3_bl2_setup.c \
34 plat/rpi3/rpi3_image_load.c \
35 plat/rpi3/rpi3_io_storage.c
36
37BL31_SOURCES += lib/cpus/aarch64/cortex_a53.S \
38 plat/common/aarch64/plat_psci_common.c \
39 plat/rpi3/aarch64/plat_helpers.S \
40 plat/rpi3/rpi3_bl31_setup.c \
41 plat/rpi3/rpi3_pm.c \
42 plat/rpi3/rpi3_topology.c
43
44# Translation tables library
45include lib/xlat_tables_v2/xlat_tables.mk
46
47PLAT_BL_COMMON_SOURCES += ${XLAT_TABLES_LIB_SRCS}
48
49# Tune compiler for Cortex-A53
50ifeq ($(notdir $(CC)),armclang)
51 TF_CFLAGS_aarch64 += -mcpu=cortex-a53
52else ifneq ($(findstring clang,$(notdir $(CC))),)
53 TF_CFLAGS_aarch64 += -mcpu=cortex-a53
54else
55 TF_CFLAGS_aarch64 += -mtune=cortex-a53
56endif
57
Antonio Nino Diazdfe895d2018-07-12 08:58:38 +010058# Platform Makefile target
59# ------------------------
60
61RPI3_BL1_PAD_BIN := ${BUILD_PLAT}/bl1_pad.bin
62RPI3_ARMSTUB8_BIN := ${BUILD_PLAT}/armstub8.bin
63
64# Add new default target when compiling this platform
65all: armstub
66
67# This target concatenates BL1 and the FIP so that the base addresses match the
68# ones defined in the memory map
69armstub: bl1 fip
70 @echo " CAT $@"
71 ${Q}cp ${BUILD_PLAT}/bl1.bin ${RPI3_BL1_PAD_BIN}
72 ${Q}truncate --size=131072 ${RPI3_BL1_PAD_BIN}
73 ${Q}cat ${RPI3_BL1_PAD_BIN} ${BUILD_PLAT}/fip.bin > ${RPI3_ARMSTUB8_BIN}
74 @${ECHO_BLANK_LINE}
75 @echo "Built $@ successfully"
76 @${ECHO_BLANK_LINE}
77
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000078# Build config flags
79# ------------------
80
81# Enable all errata workarounds for Cortex-A53
82ERRATA_A53_826319 := 1
83ERRATA_A53_835769 := 1
84ERRATA_A53_836870 := 1
85ERRATA_A53_843419 := 1
86ERRATA_A53_855873 := 1
87
Dimitris Papastamos8e5bd5e2018-01-24 16:41:14 +000088WORKAROUND_CVE_2017_5715 := 0
89
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000090# Disable the PSCI platform compatibility layer by default
91ENABLE_PLAT_COMPAT := 0
92
Antonio Nino Diaz4b7059d2018-07-13 15:26:49 +010093# Disable stack protector by default
94ENABLE_STACK_PROTECTOR := 0
95
Antonio Nino Diazdf0bb5a2018-07-13 20:19:21 +010096# Reset to BL31 isn't supported
97RESET_TO_BL31 := 0
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000098
99# Have different sections for code and rodata
100SEPARATE_CODE_AND_RODATA := 1
101
102# Use Coherent memory
103USE_COHERENT_MEM := 1
104
105# Enable new version of image loading
106LOAD_IMAGE_V2 := 1
107
Antonio Nino Diaz1f470022018-03-27 09:39:47 +0100108# Use multi console API
109MULTI_CONSOLE_API := 1
110
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000111# Platform build flags
112# --------------------
113
114# BL33 images are in AArch64 by default
115RPI3_BL33_IN_AARCH32 := 0
116
Antonio Nino Diazf8b36cc2018-07-15 12:32:32 +0100117# Assume that BL33 isn't the Linux kernel by default
118RPI3_DIRECT_LINUX_BOOT := 0
119
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000120# BL32 location
121RPI3_BL32_RAM_LOCATION := tdram
122ifeq (${RPI3_BL32_RAM_LOCATION}, tsram)
123 RPI3_BL32_RAM_LOCATION_ID = SEC_SRAM_ID
124else ifeq (${RPI3_BL32_RAM_LOCATION}, tdram)
125 RPI3_BL32_RAM_LOCATION_ID = SEC_DRAM_ID
126else
127 $(error "Unsupported RPI3_BL32_RAM_LOCATION value")
128endif
129
130# Process platform flags
131# ----------------------
132
133$(eval $(call add_define,RPI3_BL32_RAM_LOCATION_ID))
134$(eval $(call add_define,RPI3_BL33_IN_AARCH32))
Antonio Nino Diazf8b36cc2018-07-15 12:32:32 +0100135$(eval $(call add_define,RPI3_DIRECT_LINUX_BOOT))
136$(eval $(call add_define,RPI3_PRELOADED_DTB_BASE))
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000137
138# Verify build config
139# -------------------
Antonio Nino Diazf8b36cc2018-07-15 12:32:32 +0100140#
141ifneq (${RPI3_DIRECT_LINUX_BOOT}, 0)
142 ifndef RPI3_PRELOADED_DTB_BASE
143 $(error Error: RPI3_PRELOADED_DTB_BASE needed if RPI3_DIRECT_LINUX_BOOT=1)
144 endif
145endif
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000146
147ifneq (${LOAD_IMAGE_V2}, 1)
148 $(error Error: rpi3 needs LOAD_IMAGE_V2=1)
149endif
150
Antonio Nino Diaz1f470022018-03-27 09:39:47 +0100151ifneq (${MULTI_CONSOLE_API}, 1)
152 $(error Error: rpi3 needs MULTI_CONSOLE_API=1)
153endif
154
Antonio Nino Diazdf0bb5a2018-07-13 20:19:21 +0100155ifneq (${RESET_TO_BL31}, 0)
156 $(error Error: rpi3 needs RESET_TO_BL31=0)
157endif
158
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000159ifeq (${ARCH},aarch32)
160 $(error Error: AArch32 not supported on rpi3)
161endif
Ying-Chun Liu (PaulLiu)d9f76e62018-06-10 02:00:27 +0800162
Antonio Nino Diaz4b7059d2018-07-13 15:26:49 +0100163ifneq ($(ENABLE_STACK_PROTECTOR), 0)
164PLAT_BL_COMMON_SOURCES += plat/rpi3/rpi3_rng.c \
165 plat/rpi3/rpi3_stack_protector.c
166endif
167
Ying-Chun Liu (PaulLiu)d9f76e62018-06-10 02:00:27 +0800168ifeq (${SPD},opteed)
169BL2_SOURCES += \
170 lib/optee/optee_utils.c
171endif
172
173# Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images
174# in the FIP if the platform requires.
175ifneq ($(BL32_EXTRA1),)
176$(eval $(call TOOL_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1))
177endif
178ifneq ($(BL32_EXTRA2),)
179$(eval $(call TOOL_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2))
180endif
Ying-Chun Liu (PaulLiu)9128df62018-07-04 02:26:48 +0800181
182ifneq (${TRUSTED_BOARD_BOOT},0)
183
184 include drivers/auth/mbedtls/mbedtls_crypto.mk
185 include drivers/auth/mbedtls/mbedtls_x509.mk
186
187 USE_TBBR_DEFS := 1
188
189 AUTH_SOURCES := drivers/auth/auth_mod.c \
190 drivers/auth/crypto_mod.c \
191 drivers/auth/img_parser_mod.c \
192 drivers/auth/tbbr/tbbr_cot.c
193
194 PLAT_INCLUDES += -Iinclude/bl1/tbbr
195
196 BL1_SOURCES += ${AUTH_SOURCES} \
197 bl1/tbbr/tbbr_img_desc.c \
198 plat/common/tbbr/plat_tbbr.c \
199 plat/rpi3/rpi3_trusted_boot.c \
200 plat/rpi3/rpi3_rotpk.S
201
202 BL2_SOURCES += ${AUTH_SOURCES} \
203 plat/common/tbbr/plat_tbbr.c \
204 plat/rpi3/rpi3_trusted_boot.c \
205 plat/rpi3/rpi3_rotpk.S
206
207 ROT_KEY = $(BUILD_PLAT)/rot_key.pem
208 ROTPK_HASH = $(BUILD_PLAT)/rotpk_sha256.bin
209
210 $(eval $(call add_define_val,ROTPK_HASH,'"$(ROTPK_HASH)"'))
211
212 $(BUILD_PLAT)/bl1/rpi3_rotpk.o: $(ROTPK_HASH)
213 $(BUILD_PLAT)/bl2/rpi3_rotpk.o: $(ROTPK_HASH)
214
215 certificates: $(ROT_KEY)
216
217 $(ROT_KEY):
218 @echo " OPENSSL $@"
219 $(Q)openssl genrsa 2048 > $@ 2>/dev/null
220
221 $(ROTPK_HASH): $(ROT_KEY)
222 @echo " OPENSSL $@"
223 $(Q)openssl rsa -in $< -pubout -outform DER 2>/dev/null |\
224 openssl dgst -sha256 -binary > $@ 2>/dev/null
225endif