blob: 2072877ea8cafa0a60e842464c3b48ef021cd28d [file] [log] [blame]
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +00001#
Abhi Singhc4c9e2b2024-11-06 11:11:11 -06002# Copyright (c) 2013-2025, Arm Limited and Contributors. All rights reserved.
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +00003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
Antonio Nino Diaz5341b422018-10-19 00:57:16 +01007include lib/libfdt/libfdt.mk
8include lib/xlat_tables_v2/xlat_tables.mk
9
Andre Przywara4f2b9842019-07-09 14:32:11 +010010PLAT_INCLUDES := -Iplat/rpi/common/include \
Abhi Singh6dfcf4e2024-11-07 16:40:57 -060011 -Iplat/rpi/rpi3/include \
12 -Iinclude/lib/libfdt
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000013
Julius Werner985ee0b2018-11-27 17:50:28 -080014PLAT_BL_COMMON_SOURCES := drivers/ti/uart/aarch64/16550_console.S \
Andre Przywara5e6d8212020-03-10 12:34:56 +000015 drivers/arm/pl011/aarch64/pl011_console.S \
Andre Przywara29e8c462020-03-11 16:33:53 +000016 drivers/gpio/gpio.c \
17 drivers/delay_timer/delay_timer.c \
18 drivers/rpi3/gpio/rpi3_gpio.c \
Andre Przywara07aa0c72020-03-12 14:20:04 +000019 plat/rpi/common/aarch64/plat_helpers.S \
Andre Przywara4f2b9842019-07-09 14:32:11 +010020 plat/rpi/common/rpi3_common.c \
Mario Bălănicăb5029782023-12-01 04:59:43 +020021 plat/rpi/common/rpi3_console_dual.c \
Antonio Nino Diaz5341b422018-10-19 00:57:16 +010022 ${XLAT_TABLES_LIB_SRCS}
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000023
Abhi Singhc4c9e2b2024-11-06 11:11:11 -060024ifeq (${MEASURED_BOOT},1)
25MEASURED_BOOT_MK := drivers/measured_boot/event_log/event_log.mk
26$(info Including ${MEASURED_BOOT_MK})
27include ${MEASURED_BOOT_MK}
28
29PLAT_BL_COMMON_SOURCES += ${EVENT_LOG_SOURCES}
30
31BL1_SOURCES += plat/rpi/rpi3/rpi3_bl1_mboot.c
Abhi Singh6dfcf4e2024-11-07 16:40:57 -060032BL2_SOURCES += plat/rpi/rpi3/rpi3_bl2_mboot.c \
33 plat/rpi/rpi3/rpi3_dyn_cfg_helpers.c \
34 common/fdt_wrappers.c \
35 common/fdt_fixup.c
Abhi Singhc4c9e2b2024-11-06 11:11:11 -060036
37CRYPTO_SOURCES := drivers/auth/crypto_mod.c
38
39BL1_SOURCES += ${CRYPTO_SOURCES}
40BL2_SOURCES += ${CRYPTO_SOURCES}
41
42include drivers/auth/mbedtls/mbedtls_crypto.mk
43
44endif
45
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000046BL1_SOURCES += drivers/io/io_fip.c \
47 drivers/io/io_memmap.c \
48 drivers/io/io_storage.c \
Abhi.Singh11dff592024-08-29 11:31:44 -050049 drivers/delay_timer/generic_delay_timer.c \
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000050 lib/cpus/aarch64/cortex_a53.S \
51 plat/common/aarch64/platform_mp_stack.S \
Andre Przywaraab13add2019-07-09 11:18:59 +010052 plat/rpi/rpi3/rpi3_bl1_setup.c \
Andre Przywara4f2b9842019-07-09 14:32:11 +010053 plat/rpi/common/rpi3_io_storage.c \
Andre Przywarac0031182019-07-09 13:54:56 +010054 drivers/rpi3/mailbox/rpi3_mbox.c \
55 plat/rpi/rpi3/rpi_mbox_board.c
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000056
57BL2_SOURCES += common/desc_image_load.c \
58 drivers/io/io_fip.c \
59 drivers/io/io_memmap.c \
60 drivers/io/io_storage.c \
Ying-Chun Liu (PaulLiu)2be86dd2019-01-22 03:27:55 +080061 drivers/delay_timer/generic_delay_timer.c \
Ying-Chun Liu (PaulLiu)968377f2019-01-30 04:20:38 +080062 drivers/io/io_block.c \
63 drivers/mmc/mmc.c \
64 drivers/rpi3/sdhost/rpi3_sdhost.c \
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000065 plat/common/aarch64/platform_mp_stack.S \
Andre Przywaraab13add2019-07-09 11:18:59 +010066 plat/rpi/rpi3/aarch64/rpi3_bl2_mem_params_desc.c \
67 plat/rpi/rpi3/rpi3_bl2_setup.c \
Andre Przywara4f2b9842019-07-09 14:32:11 +010068 plat/rpi/common/rpi3_image_load.c \
69 plat/rpi/common/rpi3_io_storage.c
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000070
71BL31_SOURCES += lib/cpus/aarch64/cortex_a53.S \
Madhukar Pappireddy07f867b2023-08-03 14:29:40 -050072 plat/common/plat_gicv2.c \
Antonio Nino Diaz941a6242018-08-17 14:25:08 +010073 plat/common/plat_psci_common.c \
Andre Przywaraab13add2019-07-09 11:18:59 +010074 plat/rpi/rpi3/rpi3_bl31_setup.c \
Andre Przywara4f2b9842019-07-09 14:32:11 +010075 plat/rpi/common/rpi3_pm.c \
76 plat/rpi/common/rpi3_topology.c \
Antonio Nino Diaz5341b422018-10-19 00:57:16 +010077 ${LIBFDT_SRCS}
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000078
79# Tune compiler for Cortex-A53
Chris Kay8620bd02023-12-04 09:55:50 +000080ifeq ($($(ARCH)-cc-id),arm-clang)
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000081 TF_CFLAGS_aarch64 += -mcpu=cortex-a53
Chris Kay8620bd02023-12-04 09:55:50 +000082else ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000083 TF_CFLAGS_aarch64 += -mcpu=cortex-a53
84else
85 TF_CFLAGS_aarch64 += -mtune=cortex-a53
86endif
87
Antonio Nino Diaz64fe3432018-07-12 08:58:38 +010088# Platform Makefile target
89# ------------------------
90
91RPI3_BL1_PAD_BIN := ${BUILD_PLAT}/bl1_pad.bin
92RPI3_ARMSTUB8_BIN := ${BUILD_PLAT}/armstub8.bin
93
94# Add new default target when compiling this platform
95all: armstub
96
97# This target concatenates BL1 and the FIP so that the base addresses match the
98# ones defined in the memory map
99armstub: bl1 fip
Chris Kay7c4e1ee2024-05-02 17:52:37 +0000100 $(s)echo " CAT $@"
101 $(q)cp ${BUILD_PLAT}/bl1.bin ${RPI3_BL1_PAD_BIN}
102 $(q)truncate --size=131072 ${RPI3_BL1_PAD_BIN}
103 $(q)cat ${RPI3_BL1_PAD_BIN} ${BUILD_PLAT}/fip.bin > ${RPI3_ARMSTUB8_BIN}
104 $(s)echo
105 $(s)echo "Built $@ successfully"
106 $(s)echo
Antonio Nino Diaz64fe3432018-07-12 08:58:38 +0100107
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +0000108# Build config flags
109# ------------------
110
111# Enable all errata workarounds for Cortex-A53
112ERRATA_A53_826319 := 1
113ERRATA_A53_835769 := 1
114ERRATA_A53_836870 := 1
115ERRATA_A53_843419 := 1
116ERRATA_A53_855873 := 1
117
Dimitris Papastamos383c8082018-01-24 16:41:14 +0000118WORKAROUND_CVE_2017_5715 := 0
119
Antonio Nino Diaz1aad9322018-07-13 15:26:49 +0100120# Disable stack protector by default
121ENABLE_STACK_PROTECTOR := 0
122
Antonio Nino Diaz98967fb2018-07-13 20:19:21 +0100123# Reset to BL31 isn't supported
124RESET_TO_BL31 := 0
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +0000125
126# Have different sections for code and rodata
127SEPARATE_CODE_AND_RODATA := 1
128
129# Use Coherent memory
130USE_COHERENT_MEM := 1
131
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +0000132# Platform build flags
133# --------------------
134
135# BL33 images are in AArch64 by default
136RPI3_BL33_IN_AARCH32 := 0
137
Antonio Nino Diaz76c944a2018-07-15 12:32:32 +0100138# Assume that BL33 isn't the Linux kernel by default
139RPI3_DIRECT_LINUX_BOOT := 0
140
Pete Batard6d5c61d2018-11-13 13:14:26 +0000141# UART to use at runtime. -1 means the runtime UART is disabled.
142# Any other value means the default UART will be used.
Pete Batard4dcf1fa2018-11-15 22:29:59 +0000143RPI3_RUNTIME_UART := -1
144
145# Use normal memory mapping for ROM, FIP, SRAM and DRAM
146RPI3_USE_UEFI_MAP := 0
Pete Batard6d5c61d2018-11-13 13:14:26 +0000147
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +0000148# BL32 location
149RPI3_BL32_RAM_LOCATION := tdram
150ifeq (${RPI3_BL32_RAM_LOCATION}, tsram)
151 RPI3_BL32_RAM_LOCATION_ID = SEC_SRAM_ID
152else ifeq (${RPI3_BL32_RAM_LOCATION}, tdram)
153 RPI3_BL32_RAM_LOCATION_ID = SEC_DRAM_ID
154else
155 $(error "Unsupported RPI3_BL32_RAM_LOCATION value")
156endif
157
158# Process platform flags
159# ----------------------
160
161$(eval $(call add_define,RPI3_BL32_RAM_LOCATION_ID))
162$(eval $(call add_define,RPI3_BL33_IN_AARCH32))
Antonio Nino Diaz76c944a2018-07-15 12:32:32 +0100163$(eval $(call add_define,RPI3_DIRECT_LINUX_BOOT))
Igor Opaniukeabbdaf2019-01-16 23:59:41 +0200164ifdef RPI3_PRELOADED_DTB_BASE
Antonio Nino Diaz76c944a2018-07-15 12:32:32 +0100165$(eval $(call add_define,RPI3_PRELOADED_DTB_BASE))
Igor Opaniukeabbdaf2019-01-16 23:59:41 +0200166endif
Pete Batard6d5c61d2018-11-13 13:14:26 +0000167$(eval $(call add_define,RPI3_RUNTIME_UART))
Pete Batard4dcf1fa2018-11-15 22:29:59 +0000168$(eval $(call add_define,RPI3_USE_UEFI_MAP))
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +0000169
170# Verify build config
171# -------------------
Antonio Nino Diaz76c944a2018-07-15 12:32:32 +0100172#
173ifneq (${RPI3_DIRECT_LINUX_BOOT}, 0)
174 ifndef RPI3_PRELOADED_DTB_BASE
175 $(error Error: RPI3_PRELOADED_DTB_BASE needed if RPI3_DIRECT_LINUX_BOOT=1)
176 endif
177endif
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +0000178
Antonio Nino Diaz98967fb2018-07-13 20:19:21 +0100179ifneq (${RESET_TO_BL31}, 0)
180 $(error Error: rpi3 needs RESET_TO_BL31=0)
181endif
182
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +0000183ifeq (${ARCH},aarch32)
184 $(error Error: AArch32 not supported on rpi3)
185endif
Ying-Chun Liu (PaulLiu)7812aba2018-06-10 02:00:27 +0800186
Antonio Nino Diaz1aad9322018-07-13 15:26:49 +0100187ifneq ($(ENABLE_STACK_PROTECTOR), 0)
Andre Przywara990ab782019-07-09 14:29:24 +0100188PLAT_BL_COMMON_SOURCES += drivers/rpi3/rng/rpi3_rng.c \
Andre Przywara4f2b9842019-07-09 14:32:11 +0100189 plat/rpi/common/rpi3_stack_protector.c
Antonio Nino Diaz1aad9322018-07-13 15:26:49 +0100190endif
191
Ying-Chun Liu (PaulLiu)7812aba2018-06-10 02:00:27 +0800192ifeq (${SPD},opteed)
193BL2_SOURCES += \
194 lib/optee/optee_utils.c
195endif
196
197# Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images
198# in the FIP if the platform requires.
199ifneq ($(BL32_EXTRA1),)
200$(eval $(call TOOL_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1))
201endif
202ifneq ($(BL32_EXTRA2),)
203$(eval $(call TOOL_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2))
204endif
Ying-Chun Liu (PaulLiu)14368492018-07-04 02:26:48 +0800205
206ifneq (${TRUSTED_BOARD_BOOT},0)
207
208 include drivers/auth/mbedtls/mbedtls_crypto.mk
209 include drivers/auth/mbedtls/mbedtls_x509.mk
210
Ying-Chun Liu (PaulLiu)14368492018-07-04 02:26:48 +0800211 AUTH_SOURCES := drivers/auth/auth_mod.c \
212 drivers/auth/crypto_mod.c \
213 drivers/auth/img_parser_mod.c \
Manish V Badarkhead43c492020-05-16 16:36:39 +0100214 drivers/auth/tbbr/tbbr_cot_common.c
Ying-Chun Liu (PaulLiu)14368492018-07-04 02:26:48 +0800215
Ying-Chun Liu (PaulLiu)14368492018-07-04 02:26:48 +0800216 BL1_SOURCES += ${AUTH_SOURCES} \
217 bl1/tbbr/tbbr_img_desc.c \
218 plat/common/tbbr/plat_tbbr.c \
Andre Przywara4f2b9842019-07-09 14:32:11 +0100219 plat/rpi/common/rpi3_trusted_boot.c \
Manish V Badarkhead43c492020-05-16 16:36:39 +0100220 plat/rpi/common/rpi3_rotpk.S \
221 drivers/auth/tbbr/tbbr_cot_bl1.c
Ying-Chun Liu (PaulLiu)14368492018-07-04 02:26:48 +0800222
223 BL2_SOURCES += ${AUTH_SOURCES} \
224 plat/common/tbbr/plat_tbbr.c \
Andre Przywara4f2b9842019-07-09 14:32:11 +0100225 plat/rpi/common/rpi3_trusted_boot.c \
Manish V Badarkhead43c492020-05-16 16:36:39 +0100226 plat/rpi/common/rpi3_rotpk.S \
227 drivers/auth/tbbr/tbbr_cot_bl2.c
Ying-Chun Liu (PaulLiu)14368492018-07-04 02:26:48 +0800228
229 ROT_KEY = $(BUILD_PLAT)/rot_key.pem
230 ROTPK_HASH = $(BUILD_PLAT)/rotpk_sha256.bin
231
232 $(eval $(call add_define_val,ROTPK_HASH,'"$(ROTPK_HASH)"'))
233
234 $(BUILD_PLAT)/bl1/rpi3_rotpk.o: $(ROTPK_HASH)
235 $(BUILD_PLAT)/bl2/rpi3_rotpk.o: $(ROTPK_HASH)
236
237 certificates: $(ROT_KEY)
238
Chris Kay7a957592024-11-12 12:47:15 +0000239 $(ROT_KEY): | $$(@D)/
Chris Kay7c4e1ee2024-05-02 17:52:37 +0000240 $(s)echo " OPENSSL $@"
241 $(q)${OPENSSL_BIN_PATH}/openssl genrsa 2048 > $@ 2>/dev/null
Ying-Chun Liu (PaulLiu)14368492018-07-04 02:26:48 +0800242
Chris Kay7a957592024-11-12 12:47:15 +0000243 $(ROTPK_HASH): $(ROT_KEY) | $$(@D)/
Chris Kay7c4e1ee2024-05-02 17:52:37 +0000244 $(s)echo " OPENSSL $@"
245 $(q)${OPENSSL_BIN_PATH}/openssl rsa -in $< -pubout -outform DER 2>/dev/null |\
Salome Thirote95abc42022-07-14 16:14:15 +0100246 ${OPENSSL_BIN_PATH}/openssl dgst -sha256 -binary > $@ 2>/dev/null
Ying-Chun Liu (PaulLiu)14368492018-07-04 02:26:48 +0800247endif