blob: a21a7709a3d042a865d881e587e533d4a5a1783a [file] [log] [blame]
Antonio Nino Diazae6779e2017-11-06 14:49:04 +00001#
Andre Przywara93de78c2019-07-09 14:29:24 +01002# Copyright (c) 2013-2019, 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
Andre Przywara4ea3bd32019-07-09 14:32:11 +010010PLAT_INCLUDES := -Iplat/rpi/common/include \
11 -Iplat/rpi/rpi3/include
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000012
Julius Werner6b88b652018-11-27 17:50:28 -080013PLAT_BL_COMMON_SOURCES := drivers/ti/uart/aarch64/16550_console.S \
Andre Przywara4ea3bd32019-07-09 14:32:11 +010014 plat/rpi/common/rpi3_common.c \
Antonio Nino Diazf96582a2018-10-19 00:57:16 +010015 ${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 \
Andre Przywarab2262462019-07-09 11:18:59 +010022 plat/rpi/rpi3/aarch64/plat_helpers.S \
23 plat/rpi/rpi3/rpi3_bl1_setup.c \
Andre Przywara4ea3bd32019-07-09 14:32:11 +010024 plat/rpi/common/rpi3_io_storage.c \
Andre Przywara05862fc2019-07-09 13:54:56 +010025 drivers/rpi3/mailbox/rpi3_mbox.c \
26 plat/rpi/rpi3/rpi_mbox_board.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 \
Ying-Chun Liu (PaulLiu)34527382019-01-22 03:27:55 +080032 drivers/gpio/gpio.c \
33 drivers/delay_timer/delay_timer.c \
34 drivers/delay_timer/generic_delay_timer.c \
35 drivers/rpi3/gpio/rpi3_gpio.c \
Ying-Chun Liu (PaulLiu)de6f2f42019-01-30 04:20:38 +080036 drivers/io/io_block.c \
37 drivers/mmc/mmc.c \
38 drivers/rpi3/sdhost/rpi3_sdhost.c \
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000039 plat/common/aarch64/platform_mp_stack.S \
Andre Przywarab2262462019-07-09 11:18:59 +010040 plat/rpi/rpi3/aarch64/plat_helpers.S \
41 plat/rpi/rpi3/aarch64/rpi3_bl2_mem_params_desc.c \
42 plat/rpi/rpi3/rpi3_bl2_setup.c \
Andre Przywara4ea3bd32019-07-09 14:32:11 +010043 plat/rpi/common/rpi3_image_load.c \
44 plat/rpi/common/rpi3_io_storage.c
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000045
46BL31_SOURCES += lib/cpus/aarch64/cortex_a53.S \
Antonio Nino Diaz83d8c792018-08-17 14:25:08 +010047 plat/common/plat_psci_common.c \
Andre Przywarab2262462019-07-09 11:18:59 +010048 plat/rpi/rpi3/aarch64/plat_helpers.S \
49 plat/rpi/rpi3/rpi3_bl31_setup.c \
Andre Przywara4ea3bd32019-07-09 14:32:11 +010050 plat/rpi/common/rpi3_pm.c \
51 plat/rpi/common/rpi3_topology.c \
Antonio Nino Diazf96582a2018-10-19 00:57:16 +010052 ${LIBFDT_SRCS}
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000053
54# Tune compiler for Cortex-A53
55ifeq ($(notdir $(CC)),armclang)
56 TF_CFLAGS_aarch64 += -mcpu=cortex-a53
57else ifneq ($(findstring clang,$(notdir $(CC))),)
58 TF_CFLAGS_aarch64 += -mcpu=cortex-a53
59else
60 TF_CFLAGS_aarch64 += -mtune=cortex-a53
61endif
62
Antonio Nino Diazdfe895d2018-07-12 08:58:38 +010063# Platform Makefile target
64# ------------------------
65
66RPI3_BL1_PAD_BIN := ${BUILD_PLAT}/bl1_pad.bin
67RPI3_ARMSTUB8_BIN := ${BUILD_PLAT}/armstub8.bin
68
69# Add new default target when compiling this platform
70all: armstub
71
72# This target concatenates BL1 and the FIP so that the base addresses match the
73# ones defined in the memory map
74armstub: bl1 fip
75 @echo " CAT $@"
76 ${Q}cp ${BUILD_PLAT}/bl1.bin ${RPI3_BL1_PAD_BIN}
77 ${Q}truncate --size=131072 ${RPI3_BL1_PAD_BIN}
78 ${Q}cat ${RPI3_BL1_PAD_BIN} ${BUILD_PLAT}/fip.bin > ${RPI3_ARMSTUB8_BIN}
79 @${ECHO_BLANK_LINE}
80 @echo "Built $@ successfully"
81 @${ECHO_BLANK_LINE}
82
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000083# Build config flags
84# ------------------
85
86# Enable all errata workarounds for Cortex-A53
87ERRATA_A53_826319 := 1
88ERRATA_A53_835769 := 1
89ERRATA_A53_836870 := 1
90ERRATA_A53_843419 := 1
91ERRATA_A53_855873 := 1
92
Dimitris Papastamos8e5bd5e2018-01-24 16:41:14 +000093WORKAROUND_CVE_2017_5715 := 0
94
Antonio Nino Diaz4b7059d2018-07-13 15:26:49 +010095# Disable stack protector by default
96ENABLE_STACK_PROTECTOR := 0
97
Antonio Nino Diazdf0bb5a2018-07-13 20:19:21 +010098# Reset to BL31 isn't supported
99RESET_TO_BL31 := 0
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000100
101# Have different sections for code and rodata
102SEPARATE_CODE_AND_RODATA := 1
103
104# Use Coherent memory
105USE_COHERENT_MEM := 1
106
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000107# Platform build flags
108# --------------------
109
110# BL33 images are in AArch64 by default
111RPI3_BL33_IN_AARCH32 := 0
112
Antonio Nino Diazf8b36cc2018-07-15 12:32:32 +0100113# Assume that BL33 isn't the Linux kernel by default
114RPI3_DIRECT_LINUX_BOOT := 0
115
Pete Batardc9acd6c2018-11-13 13:14:26 +0000116# UART to use at runtime. -1 means the runtime UART is disabled.
117# Any other value means the default UART will be used.
Pete Batardf820cad2018-11-15 22:29:59 +0000118RPI3_RUNTIME_UART := -1
119
120# Use normal memory mapping for ROM, FIP, SRAM and DRAM
121RPI3_USE_UEFI_MAP := 0
Pete Batardc9acd6c2018-11-13 13:14:26 +0000122
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000123# BL32 location
124RPI3_BL32_RAM_LOCATION := tdram
125ifeq (${RPI3_BL32_RAM_LOCATION}, tsram)
126 RPI3_BL32_RAM_LOCATION_ID = SEC_SRAM_ID
127else ifeq (${RPI3_BL32_RAM_LOCATION}, tdram)
128 RPI3_BL32_RAM_LOCATION_ID = SEC_DRAM_ID
129else
130 $(error "Unsupported RPI3_BL32_RAM_LOCATION value")
131endif
132
133# Process platform flags
134# ----------------------
135
136$(eval $(call add_define,RPI3_BL32_RAM_LOCATION_ID))
137$(eval $(call add_define,RPI3_BL33_IN_AARCH32))
Antonio Nino Diazf8b36cc2018-07-15 12:32:32 +0100138$(eval $(call add_define,RPI3_DIRECT_LINUX_BOOT))
Igor Opaniuk02016b22019-01-16 23:59:41 +0200139ifdef RPI3_PRELOADED_DTB_BASE
Antonio Nino Diazf8b36cc2018-07-15 12:32:32 +0100140$(eval $(call add_define,RPI3_PRELOADED_DTB_BASE))
Igor Opaniuk02016b22019-01-16 23:59:41 +0200141endif
Pete Batardc9acd6c2018-11-13 13:14:26 +0000142$(eval $(call add_define,RPI3_RUNTIME_UART))
Pete Batardf820cad2018-11-15 22:29:59 +0000143$(eval $(call add_define,RPI3_USE_UEFI_MAP))
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000144
145# Verify build config
146# -------------------
Antonio Nino Diazf8b36cc2018-07-15 12:32:32 +0100147#
148ifneq (${RPI3_DIRECT_LINUX_BOOT}, 0)
149 ifndef RPI3_PRELOADED_DTB_BASE
150 $(error Error: RPI3_PRELOADED_DTB_BASE needed if RPI3_DIRECT_LINUX_BOOT=1)
151 endif
152endif
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000153
Antonio Nino Diazdf0bb5a2018-07-13 20:19:21 +0100154ifneq (${RESET_TO_BL31}, 0)
155 $(error Error: rpi3 needs RESET_TO_BL31=0)
156endif
157
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000158ifeq (${ARCH},aarch32)
159 $(error Error: AArch32 not supported on rpi3)
160endif
Ying-Chun Liu (PaulLiu)d9f76e62018-06-10 02:00:27 +0800161
Antonio Nino Diaz4b7059d2018-07-13 15:26:49 +0100162ifneq ($(ENABLE_STACK_PROTECTOR), 0)
Andre Przywara93de78c2019-07-09 14:29:24 +0100163PLAT_BL_COMMON_SOURCES += drivers/rpi3/rng/rpi3_rng.c \
Andre Przywara4ea3bd32019-07-09 14:32:11 +0100164 plat/rpi/common/rpi3_stack_protector.c
Antonio Nino Diaz4b7059d2018-07-13 15:26:49 +0100165endif
166
Ying-Chun Liu (PaulLiu)d9f76e62018-06-10 02:00:27 +0800167ifeq (${SPD},opteed)
168BL2_SOURCES += \
169 lib/optee/optee_utils.c
170endif
171
172# Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images
173# in the FIP if the platform requires.
174ifneq ($(BL32_EXTRA1),)
175$(eval $(call TOOL_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1))
176endif
177ifneq ($(BL32_EXTRA2),)
178$(eval $(call TOOL_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2))
179endif
Ying-Chun Liu (PaulLiu)9128df62018-07-04 02:26:48 +0800180
181ifneq (${TRUSTED_BOARD_BOOT},0)
182
183 include drivers/auth/mbedtls/mbedtls_crypto.mk
184 include drivers/auth/mbedtls/mbedtls_x509.mk
185
Ying-Chun Liu (PaulLiu)9128df62018-07-04 02:26:48 +0800186 AUTH_SOURCES := drivers/auth/auth_mod.c \
187 drivers/auth/crypto_mod.c \
188 drivers/auth/img_parser_mod.c \
189 drivers/auth/tbbr/tbbr_cot.c
190
Ying-Chun Liu (PaulLiu)9128df62018-07-04 02:26:48 +0800191 BL1_SOURCES += ${AUTH_SOURCES} \
192 bl1/tbbr/tbbr_img_desc.c \
193 plat/common/tbbr/plat_tbbr.c \
Andre Przywara4ea3bd32019-07-09 14:32:11 +0100194 plat/rpi/common/rpi3_trusted_boot.c \
195 plat/rpi/common/rpi3_rotpk.S
Ying-Chun Liu (PaulLiu)9128df62018-07-04 02:26:48 +0800196
197 BL2_SOURCES += ${AUTH_SOURCES} \
198 plat/common/tbbr/plat_tbbr.c \
Andre Przywara4ea3bd32019-07-09 14:32:11 +0100199 plat/rpi/common/rpi3_trusted_boot.c \
200 plat/rpi/common/rpi3_rotpk.S
Ying-Chun Liu (PaulLiu)9128df62018-07-04 02:26:48 +0800201
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