blob: db96de821173ca513a33ad5cccf9e0d0db0f2403 [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
13PLAT_BL_COMMON_SOURCES := drivers/console/aarch64/console.S \
14 drivers/ti/uart/aarch64/16550_console.S \
Antonio Nino Diazf96582a2018-10-19 00:57:16 +010015 plat/rpi3/rpi3_common.c \
16 ${XLAT_TABLES_LIB_SRCS}
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000017
18BL1_SOURCES += drivers/io/io_fip.c \
19 drivers/io/io_memmap.c \
20 drivers/io/io_storage.c \
21 lib/cpus/aarch64/cortex_a53.S \
22 plat/common/aarch64/platform_mp_stack.S \
23 plat/rpi3/aarch64/plat_helpers.S \
24 plat/rpi3/rpi3_bl1_setup.c \
Antonio Nino Diazecf34712018-07-12 13:38:53 +010025 plat/rpi3/rpi3_io_storage.c \
26 plat/rpi3/rpi3_mbox.c
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000027
28BL2_SOURCES += common/desc_image_load.c \
29 drivers/io/io_fip.c \
30 drivers/io/io_memmap.c \
31 drivers/io/io_storage.c \
32 plat/common/aarch64/platform_mp_stack.S \
33 plat/rpi3/aarch64/plat_helpers.S \
34 plat/rpi3/aarch64/rpi3_bl2_mem_params_desc.c \
35 plat/rpi3/rpi3_bl2_setup.c \
36 plat/rpi3/rpi3_image_load.c \
37 plat/rpi3/rpi3_io_storage.c
38
39BL31_SOURCES += lib/cpus/aarch64/cortex_a53.S \
Antonio Nino Diaz83d8c792018-08-17 14:25:08 +010040 plat/common/plat_psci_common.c \
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000041 plat/rpi3/aarch64/plat_helpers.S \
42 plat/rpi3/rpi3_bl31_setup.c \
43 plat/rpi3/rpi3_pm.c \
Antonio Nino Diazf96582a2018-10-19 00:57:16 +010044 plat/rpi3/rpi3_topology.c \
45 ${LIBFDT_SRCS}
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000046
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 Diaz4b7059d2018-07-13 15:26:49 +010088# Disable stack protector by default
89ENABLE_STACK_PROTECTOR := 0
90
Antonio Nino Diazdf0bb5a2018-07-13 20:19:21 +010091# Reset to BL31 isn't supported
92RESET_TO_BL31 := 0
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000093
94# Have different sections for code and rodata
95SEPARATE_CODE_AND_RODATA := 1
96
97# Use Coherent memory
98USE_COHERENT_MEM := 1
99
Antonio Nino Diaz1f470022018-03-27 09:39:47 +0100100# Use multi console API
101MULTI_CONSOLE_API := 1
102
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000103# Platform build flags
104# --------------------
105
106# BL33 images are in AArch64 by default
107RPI3_BL33_IN_AARCH32 := 0
108
Antonio Nino Diazf8b36cc2018-07-15 12:32:32 +0100109# Assume that BL33 isn't the Linux kernel by default
110RPI3_DIRECT_LINUX_BOOT := 0
111
Pete Batardc9acd6c2018-11-13 13:14:26 +0000112# UART to use at runtime. -1 means the runtime UART is disabled.
113# Any other value means the default UART will be used.
Pete Batardf820cad2018-11-15 22:29:59 +0000114RPI3_RUNTIME_UART := -1
115
116# Use normal memory mapping for ROM, FIP, SRAM and DRAM
117RPI3_USE_UEFI_MAP := 0
Pete Batardc9acd6c2018-11-13 13:14:26 +0000118
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000119# BL32 location
120RPI3_BL32_RAM_LOCATION := tdram
121ifeq (${RPI3_BL32_RAM_LOCATION}, tsram)
122 RPI3_BL32_RAM_LOCATION_ID = SEC_SRAM_ID
123else ifeq (${RPI3_BL32_RAM_LOCATION}, tdram)
124 RPI3_BL32_RAM_LOCATION_ID = SEC_DRAM_ID
125else
126 $(error "Unsupported RPI3_BL32_RAM_LOCATION value")
127endif
128
129# Process platform flags
130# ----------------------
131
132$(eval $(call add_define,RPI3_BL32_RAM_LOCATION_ID))
133$(eval $(call add_define,RPI3_BL33_IN_AARCH32))
Antonio Nino Diazf8b36cc2018-07-15 12:32:32 +0100134$(eval $(call add_define,RPI3_DIRECT_LINUX_BOOT))
135$(eval $(call add_define,RPI3_PRELOADED_DTB_BASE))
Pete Batardc9acd6c2018-11-13 13:14:26 +0000136$(eval $(call add_define,RPI3_RUNTIME_UART))
Pete Batardf820cad2018-11-15 22:29:59 +0000137$(eval $(call add_define,RPI3_USE_UEFI_MAP))
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000138
139# Verify build config
140# -------------------
Antonio Nino Diazf8b36cc2018-07-15 12:32:32 +0100141#
142ifneq (${RPI3_DIRECT_LINUX_BOOT}, 0)
143 ifndef RPI3_PRELOADED_DTB_BASE
144 $(error Error: RPI3_PRELOADED_DTB_BASE needed if RPI3_DIRECT_LINUX_BOOT=1)
145 endif
146endif
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000147
Antonio Nino Diaz1f470022018-03-27 09:39:47 +0100148ifneq (${MULTI_CONSOLE_API}, 1)
149 $(error Error: rpi3 needs MULTI_CONSOLE_API=1)
150endif
151
Antonio Nino Diazdf0bb5a2018-07-13 20:19:21 +0100152ifneq (${RESET_TO_BL31}, 0)
153 $(error Error: rpi3 needs RESET_TO_BL31=0)
154endif
155
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000156ifeq (${ARCH},aarch32)
157 $(error Error: AArch32 not supported on rpi3)
158endif
Ying-Chun Liu (PaulLiu)d9f76e62018-06-10 02:00:27 +0800159
Antonio Nino Diaz4b7059d2018-07-13 15:26:49 +0100160ifneq ($(ENABLE_STACK_PROTECTOR), 0)
161PLAT_BL_COMMON_SOURCES += plat/rpi3/rpi3_rng.c \
162 plat/rpi3/rpi3_stack_protector.c
163endif
164
Ying-Chun Liu (PaulLiu)d9f76e62018-06-10 02:00:27 +0800165ifeq (${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
Ying-Chun Liu (PaulLiu)9128df62018-07-04 02:26:48 +0800178
179ifneq (${TRUSTED_BOARD_BOOT},0)
180
181 include drivers/auth/mbedtls/mbedtls_crypto.mk
182 include drivers/auth/mbedtls/mbedtls_x509.mk
183
Ying-Chun Liu (PaulLiu)9128df62018-07-04 02:26:48 +0800184 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 PLAT_INCLUDES += -Iinclude/bl1/tbbr
190
191 BL1_SOURCES += ${AUTH_SOURCES} \
192 bl1/tbbr/tbbr_img_desc.c \
193 plat/common/tbbr/plat_tbbr.c \
194 plat/rpi3/rpi3_trusted_boot.c \
195 plat/rpi3/rpi3_rotpk.S
196
197 BL2_SOURCES += ${AUTH_SOURCES} \
198 plat/common/tbbr/plat_tbbr.c \
199 plat/rpi3/rpi3_trusted_boot.c \
200 plat/rpi3/rpi3_rotpk.S
201
202 ROT_KEY = $(BUILD_PLAT)/rot_key.pem
203 ROTPK_HASH = $(BUILD_PLAT)/rotpk_sha256.bin
204
205 $(eval $(call add_define_val,ROTPK_HASH,'"$(ROTPK_HASH)"'))
206
207 $(BUILD_PLAT)/bl1/rpi3_rotpk.o: $(ROTPK_HASH)
208 $(BUILD_PLAT)/bl2/rpi3_rotpk.o: $(ROTPK_HASH)
209
210 certificates: $(ROT_KEY)
211
212 $(ROT_KEY):
213 @echo " OPENSSL $@"
214 $(Q)openssl genrsa 2048 > $@ 2>/dev/null
215
216 $(ROTPK_HASH): $(ROT_KEY)
217 @echo " OPENSSL $@"
218 $(Q)openssl rsa -in $< -pubout -outform DER 2>/dev/null |\
219 openssl dgst -sha256 -binary > $@ 2>/dev/null
220endif