blob: 46c139eac43f1ea7f725605b523e236fdc2de3dc [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
Antonio Nino Diazf96582a2018-10-19 00:57:16 +01007include lib/libfdt/libfdt.mk
8include lib/xlat_tables_v2/xlat_tables.mk
9
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000010PLAT_INCLUDES := -Iinclude/common/tbbr \
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000011 -Iplat/rpi3/include
12
Julius Werner6b88b652018-11-27 17:50:28 -080013PLAT_BL_COMMON_SOURCES := drivers/ti/uart/aarch64/16550_console.S \
Antonio Nino Diazf96582a2018-10-19 00:57:16 +010014 plat/rpi3/rpi3_common.c \
15 ${XLAT_TABLES_LIB_SRCS}
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000016
17BL1_SOURCES += drivers/io/io_fip.c \
18 drivers/io/io_memmap.c \
19 drivers/io/io_storage.c \
20 lib/cpus/aarch64/cortex_a53.S \
21 plat/common/aarch64/platform_mp_stack.S \
22 plat/rpi3/aarch64/plat_helpers.S \
23 plat/rpi3/rpi3_bl1_setup.c \
Antonio Nino Diazecf34712018-07-12 13:38:53 +010024 plat/rpi3/rpi3_io_storage.c \
25 plat/rpi3/rpi3_mbox.c
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000026
27BL2_SOURCES += common/desc_image_load.c \
28 drivers/io/io_fip.c \
29 drivers/io/io_memmap.c \
30 drivers/io/io_storage.c \
31 plat/common/aarch64/platform_mp_stack.S \
32 plat/rpi3/aarch64/plat_helpers.S \
33 plat/rpi3/aarch64/rpi3_bl2_mem_params_desc.c \
34 plat/rpi3/rpi3_bl2_setup.c \
35 plat/rpi3/rpi3_image_load.c \
36 plat/rpi3/rpi3_io_storage.c
37
38BL31_SOURCES += lib/cpus/aarch64/cortex_a53.S \
Antonio Nino Diaz83d8c792018-08-17 14:25:08 +010039 plat/common/plat_psci_common.c \
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000040 plat/rpi3/aarch64/plat_helpers.S \
41 plat/rpi3/rpi3_bl31_setup.c \
42 plat/rpi3/rpi3_pm.c \
Antonio Nino Diazf96582a2018-10-19 00:57:16 +010043 plat/rpi3/rpi3_topology.c \
44 ${LIBFDT_SRCS}
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000045
46# Tune compiler for Cortex-A53
47ifeq ($(notdir $(CC)),armclang)
48 TF_CFLAGS_aarch64 += -mcpu=cortex-a53
49else ifneq ($(findstring clang,$(notdir $(CC))),)
50 TF_CFLAGS_aarch64 += -mcpu=cortex-a53
51else
52 TF_CFLAGS_aarch64 += -mtune=cortex-a53
53endif
54
Antonio Nino Diazdfe895d2018-07-12 08:58:38 +010055# Platform Makefile target
56# ------------------------
57
58RPI3_BL1_PAD_BIN := ${BUILD_PLAT}/bl1_pad.bin
59RPI3_ARMSTUB8_BIN := ${BUILD_PLAT}/armstub8.bin
60
61# Add new default target when compiling this platform
62all: armstub
63
64# This target concatenates BL1 and the FIP so that the base addresses match the
65# ones defined in the memory map
66armstub: bl1 fip
67 @echo " CAT $@"
68 ${Q}cp ${BUILD_PLAT}/bl1.bin ${RPI3_BL1_PAD_BIN}
69 ${Q}truncate --size=131072 ${RPI3_BL1_PAD_BIN}
70 ${Q}cat ${RPI3_BL1_PAD_BIN} ${BUILD_PLAT}/fip.bin > ${RPI3_ARMSTUB8_BIN}
71 @${ECHO_BLANK_LINE}
72 @echo "Built $@ successfully"
73 @${ECHO_BLANK_LINE}
74
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000075# Build config flags
76# ------------------
77
78# Enable all errata workarounds for Cortex-A53
79ERRATA_A53_826319 := 1
80ERRATA_A53_835769 := 1
81ERRATA_A53_836870 := 1
82ERRATA_A53_843419 := 1
83ERRATA_A53_855873 := 1
84
Dimitris Papastamos8e5bd5e2018-01-24 16:41:14 +000085WORKAROUND_CVE_2017_5715 := 0
86
Antonio Nino Diaz4b7059d2018-07-13 15:26:49 +010087# Disable stack protector by default
88ENABLE_STACK_PROTECTOR := 0
89
Antonio Nino Diazdf0bb5a2018-07-13 20:19:21 +010090# Reset to BL31 isn't supported
91RESET_TO_BL31 := 0
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000092
93# Have different sections for code and rodata
94SEPARATE_CODE_AND_RODATA := 1
95
96# Use Coherent memory
97USE_COHERENT_MEM := 1
98
Antonio Nino Diaz1f470022018-03-27 09:39:47 +010099# Use multi console API
100MULTI_CONSOLE_API := 1
101
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000102# Platform build flags
103# --------------------
104
105# BL33 images are in AArch64 by default
106RPI3_BL33_IN_AARCH32 := 0
107
Antonio Nino Diazf8b36cc2018-07-15 12:32:32 +0100108# Assume that BL33 isn't the Linux kernel by default
109RPI3_DIRECT_LINUX_BOOT := 0
110
Pete Batardc9acd6c2018-11-13 13:14:26 +0000111# UART to use at runtime. -1 means the runtime UART is disabled.
112# Any other value means the default UART will be used.
Pete Batardf820cad2018-11-15 22:29:59 +0000113RPI3_RUNTIME_UART := -1
114
115# Use normal memory mapping for ROM, FIP, SRAM and DRAM
116RPI3_USE_UEFI_MAP := 0
Pete Batardc9acd6c2018-11-13 13:14:26 +0000117
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))
Pete Batardc9acd6c2018-11-13 13:14:26 +0000135$(eval $(call add_define,RPI3_RUNTIME_UART))
Pete Batardf820cad2018-11-15 22:29:59 +0000136$(eval $(call add_define,RPI3_USE_UEFI_MAP))
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
Antonio Nino Diaz1f470022018-03-27 09:39:47 +0100147ifneq (${MULTI_CONSOLE_API}, 1)
148 $(error Error: rpi3 needs MULTI_CONSOLE_API=1)
149endif
150
Antonio Nino Diazdf0bb5a2018-07-13 20:19:21 +0100151ifneq (${RESET_TO_BL31}, 0)
152 $(error Error: rpi3 needs RESET_TO_BL31=0)
153endif
154
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000155ifeq (${ARCH},aarch32)
156 $(error Error: AArch32 not supported on rpi3)
157endif
Ying-Chun Liu (PaulLiu)d9f76e62018-06-10 02:00:27 +0800158
Antonio Nino Diaz4b7059d2018-07-13 15:26:49 +0100159ifneq ($(ENABLE_STACK_PROTECTOR), 0)
160PLAT_BL_COMMON_SOURCES += plat/rpi3/rpi3_rng.c \
161 plat/rpi3/rpi3_stack_protector.c
162endif
163
Ying-Chun Liu (PaulLiu)d9f76e62018-06-10 02:00:27 +0800164ifeq (${SPD},opteed)
165BL2_SOURCES += \
166 lib/optee/optee_utils.c
167endif
168
169# Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images
170# in the FIP if the platform requires.
171ifneq ($(BL32_EXTRA1),)
172$(eval $(call TOOL_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1))
173endif
174ifneq ($(BL32_EXTRA2),)
175$(eval $(call TOOL_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2))
176endif
Ying-Chun Liu (PaulLiu)9128df62018-07-04 02:26:48 +0800177
178ifneq (${TRUSTED_BOARD_BOOT},0)
179
180 include drivers/auth/mbedtls/mbedtls_crypto.mk
181 include drivers/auth/mbedtls/mbedtls_x509.mk
182
Ying-Chun Liu (PaulLiu)9128df62018-07-04 02:26:48 +0800183 AUTH_SOURCES := drivers/auth/auth_mod.c \
184 drivers/auth/crypto_mod.c \
185 drivers/auth/img_parser_mod.c \
186 drivers/auth/tbbr/tbbr_cot.c
187
188 PLAT_INCLUDES += -Iinclude/bl1/tbbr
189
190 BL1_SOURCES += ${AUTH_SOURCES} \
191 bl1/tbbr/tbbr_img_desc.c \
192 plat/common/tbbr/plat_tbbr.c \
193 plat/rpi3/rpi3_trusted_boot.c \
194 plat/rpi3/rpi3_rotpk.S
195
196 BL2_SOURCES += ${AUTH_SOURCES} \
197 plat/common/tbbr/plat_tbbr.c \
198 plat/rpi3/rpi3_trusted_boot.c \
199 plat/rpi3/rpi3_rotpk.S
200
201 ROT_KEY = $(BUILD_PLAT)/rot_key.pem
202 ROTPK_HASH = $(BUILD_PLAT)/rotpk_sha256.bin
203
204 $(eval $(call add_define_val,ROTPK_HASH,'"$(ROTPK_HASH)"'))
205
206 $(BUILD_PLAT)/bl1/rpi3_rotpk.o: $(ROTPK_HASH)
207 $(BUILD_PLAT)/bl2/rpi3_rotpk.o: $(ROTPK_HASH)
208
209 certificates: $(ROT_KEY)
210
211 $(ROT_KEY):
212 @echo " OPENSSL $@"
213 $(Q)openssl genrsa 2048 > $@ 2>/dev/null
214
215 $(ROTPK_HASH): $(ROT_KEY)
216 @echo " OPENSSL $@"
217 $(Q)openssl rsa -in $< -pubout -outform DER 2>/dev/null |\
218 openssl dgst -sha256 -binary > $@ 2>/dev/null
219endif