blob: d6d0d56ceffcfc7823914f34d779a5a8d16199e1 [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 \
Antonio Nino Diazae6779e2017-11-06 14:49:04 +00008 -Iplat/rpi3/include
9
10PLAT_BL_COMMON_SOURCES := drivers/console/aarch64/console.S \
11 drivers/ti/uart/aarch64/16550_console.S \
12 plat/rpi3/rpi3_common.c
13
14BL1_SOURCES += drivers/io/io_fip.c \
15 drivers/io/io_memmap.c \
16 drivers/io/io_storage.c \
17 lib/cpus/aarch64/cortex_a53.S \
18 plat/common/aarch64/platform_mp_stack.S \
19 plat/rpi3/aarch64/plat_helpers.S \
20 plat/rpi3/rpi3_bl1_setup.c \
Antonio Nino Diazecf34712018-07-12 13:38:53 +010021 plat/rpi3/rpi3_io_storage.c \
22 plat/rpi3/rpi3_mbox.c
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000023
24BL2_SOURCES += common/desc_image_load.c \
25 drivers/io/io_fip.c \
26 drivers/io/io_memmap.c \
27 drivers/io/io_storage.c \
28 plat/common/aarch64/platform_mp_stack.S \
29 plat/rpi3/aarch64/plat_helpers.S \
30 plat/rpi3/aarch64/rpi3_bl2_mem_params_desc.c \
31 plat/rpi3/rpi3_bl2_setup.c \
32 plat/rpi3/rpi3_image_load.c \
33 plat/rpi3/rpi3_io_storage.c
34
35BL31_SOURCES += lib/cpus/aarch64/cortex_a53.S \
Antonio Nino Diaz83d8c792018-08-17 14:25:08 +010036 plat/common/plat_psci_common.c \
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000037 plat/rpi3/aarch64/plat_helpers.S \
38 plat/rpi3/rpi3_bl31_setup.c \
39 plat/rpi3/rpi3_pm.c \
40 plat/rpi3/rpi3_topology.c
41
42# Translation tables library
43include lib/xlat_tables_v2/xlat_tables.mk
44
45PLAT_BL_COMMON_SOURCES += ${XLAT_TABLES_LIB_SRCS}
46
47# Tune compiler for Cortex-A53
48ifeq ($(notdir $(CC)),armclang)
49 TF_CFLAGS_aarch64 += -mcpu=cortex-a53
50else ifneq ($(findstring clang,$(notdir $(CC))),)
51 TF_CFLAGS_aarch64 += -mcpu=cortex-a53
52else
53 TF_CFLAGS_aarch64 += -mtune=cortex-a53
54endif
55
Antonio Nino Diazdfe895d2018-07-12 08:58:38 +010056# Platform Makefile target
57# ------------------------
58
59RPI3_BL1_PAD_BIN := ${BUILD_PLAT}/bl1_pad.bin
60RPI3_ARMSTUB8_BIN := ${BUILD_PLAT}/armstub8.bin
61
62# Add new default target when compiling this platform
63all: armstub
64
65# This target concatenates BL1 and the FIP so that the base addresses match the
66# ones defined in the memory map
67armstub: bl1 fip
68 @echo " CAT $@"
69 ${Q}cp ${BUILD_PLAT}/bl1.bin ${RPI3_BL1_PAD_BIN}
70 ${Q}truncate --size=131072 ${RPI3_BL1_PAD_BIN}
71 ${Q}cat ${RPI3_BL1_PAD_BIN} ${BUILD_PLAT}/fip.bin > ${RPI3_ARMSTUB8_BIN}
72 @${ECHO_BLANK_LINE}
73 @echo "Built $@ successfully"
74 @${ECHO_BLANK_LINE}
75
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000076# Build config flags
77# ------------------
78
79# Enable all errata workarounds for Cortex-A53
80ERRATA_A53_826319 := 1
81ERRATA_A53_835769 := 1
82ERRATA_A53_836870 := 1
83ERRATA_A53_843419 := 1
84ERRATA_A53_855873 := 1
85
Dimitris Papastamos8e5bd5e2018-01-24 16:41:14 +000086WORKAROUND_CVE_2017_5715 := 0
87
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000088# Disable the PSCI platform compatibility layer by default
89ENABLE_PLAT_COMPAT := 0
90
Antonio Nino Diaz4b7059d2018-07-13 15:26:49 +010091# Disable stack protector by default
92ENABLE_STACK_PROTECTOR := 0
93
Antonio Nino Diazdf0bb5a2018-07-13 20:19:21 +010094# Reset to BL31 isn't supported
95RESET_TO_BL31 := 0
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000096
97# Have different sections for code and rodata
98SEPARATE_CODE_AND_RODATA := 1
99
100# Use Coherent memory
101USE_COHERENT_MEM := 1
102
103# Enable new version of image loading
104LOAD_IMAGE_V2 := 1
105
Antonio Nino Diaz1f470022018-03-27 09:39:47 +0100106# Use multi console API
107MULTI_CONSOLE_API := 1
108
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000109# Platform build flags
110# --------------------
111
112# BL33 images are in AArch64 by default
113RPI3_BL33_IN_AARCH32 := 0
114
Antonio Nino Diazf8b36cc2018-07-15 12:32:32 +0100115# Assume that BL33 isn't the Linux kernel by default
116RPI3_DIRECT_LINUX_BOOT := 0
117
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000118# BL32 location
119RPI3_BL32_RAM_LOCATION := tdram
120ifeq (${RPI3_BL32_RAM_LOCATION}, tsram)
121 RPI3_BL32_RAM_LOCATION_ID = SEC_SRAM_ID
122else ifeq (${RPI3_BL32_RAM_LOCATION}, tdram)
123 RPI3_BL32_RAM_LOCATION_ID = SEC_DRAM_ID
124else
125 $(error "Unsupported RPI3_BL32_RAM_LOCATION value")
126endif
127
128# Process platform flags
129# ----------------------
130
131$(eval $(call add_define,RPI3_BL32_RAM_LOCATION_ID))
132$(eval $(call add_define,RPI3_BL33_IN_AARCH32))
Antonio Nino Diazf8b36cc2018-07-15 12:32:32 +0100133$(eval $(call add_define,RPI3_DIRECT_LINUX_BOOT))
134$(eval $(call add_define,RPI3_PRELOADED_DTB_BASE))
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000135
136# Verify build config
137# -------------------
Antonio Nino Diazf8b36cc2018-07-15 12:32:32 +0100138#
139ifneq (${RPI3_DIRECT_LINUX_BOOT}, 0)
140 ifndef RPI3_PRELOADED_DTB_BASE
141 $(error Error: RPI3_PRELOADED_DTB_BASE needed if RPI3_DIRECT_LINUX_BOOT=1)
142 endif
143endif
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000144
145ifneq (${LOAD_IMAGE_V2}, 1)
146 $(error Error: rpi3 needs LOAD_IMAGE_V2=1)
147endif
148
Antonio Nino Diaz1f470022018-03-27 09:39:47 +0100149ifneq (${MULTI_CONSOLE_API}, 1)
150 $(error Error: rpi3 needs MULTI_CONSOLE_API=1)
151endif
152
Antonio Nino Diazdf0bb5a2018-07-13 20:19:21 +0100153ifneq (${RESET_TO_BL31}, 0)
154 $(error Error: rpi3 needs RESET_TO_BL31=0)
155endif
156
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000157ifeq (${ARCH},aarch32)
158 $(error Error: AArch32 not supported on rpi3)
159endif
Ying-Chun Liu (PaulLiu)d9f76e62018-06-10 02:00:27 +0800160
Antonio Nino Diaz4b7059d2018-07-13 15:26:49 +0100161ifneq ($(ENABLE_STACK_PROTECTOR), 0)
162PLAT_BL_COMMON_SOURCES += plat/rpi3/rpi3_rng.c \
163 plat/rpi3/rpi3_stack_protector.c
164endif
165
Ying-Chun Liu (PaulLiu)d9f76e62018-06-10 02:00:27 +0800166ifeq (${SPD},opteed)
167BL2_SOURCES += \
168 lib/optee/optee_utils.c
169endif
170
171# Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images
172# in the FIP if the platform requires.
173ifneq ($(BL32_EXTRA1),)
174$(eval $(call TOOL_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1))
175endif
176ifneq ($(BL32_EXTRA2),)
177$(eval $(call TOOL_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2))
178endif
Ying-Chun Liu (PaulLiu)9128df62018-07-04 02:26:48 +0800179
180ifneq (${TRUSTED_BOARD_BOOT},0)
181
182 include drivers/auth/mbedtls/mbedtls_crypto.mk
183 include drivers/auth/mbedtls/mbedtls_x509.mk
184
185 USE_TBBR_DEFS := 1
186
187 AUTH_SOURCES := drivers/auth/auth_mod.c \
188 drivers/auth/crypto_mod.c \
189 drivers/auth/img_parser_mod.c \
190 drivers/auth/tbbr/tbbr_cot.c
191
192 PLAT_INCLUDES += -Iinclude/bl1/tbbr
193
194 BL1_SOURCES += ${AUTH_SOURCES} \
195 bl1/tbbr/tbbr_img_desc.c \
196 plat/common/tbbr/plat_tbbr.c \
197 plat/rpi3/rpi3_trusted_boot.c \
198 plat/rpi3/rpi3_rotpk.S
199
200 BL2_SOURCES += ${AUTH_SOURCES} \
201 plat/common/tbbr/plat_tbbr.c \
202 plat/rpi3/rpi3_trusted_boot.c \
203 plat/rpi3/rpi3_rotpk.S
204
205 ROT_KEY = $(BUILD_PLAT)/rot_key.pem
206 ROTPK_HASH = $(BUILD_PLAT)/rotpk_sha256.bin
207
208 $(eval $(call add_define_val,ROTPK_HASH,'"$(ROTPK_HASH)"'))
209
210 $(BUILD_PLAT)/bl1/rpi3_rotpk.o: $(ROTPK_HASH)
211 $(BUILD_PLAT)/bl2/rpi3_rotpk.o: $(ROTPK_HASH)
212
213 certificates: $(ROT_KEY)
214
215 $(ROT_KEY):
216 @echo " OPENSSL $@"
217 $(Q)openssl genrsa 2048 > $@ 2>/dev/null
218
219 $(ROTPK_HASH): $(ROT_KEY)
220 @echo " OPENSSL $@"
221 $(Q)openssl rsa -in $< -pubout -outform DER 2>/dev/null |\
222 openssl dgst -sha256 -binary > $@ 2>/dev/null
223endif