blob: b60482e920e0d4bde5bf5d41657491be3dd66a9b [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 Singh4f9894d2024-11-07 17:39:38 -060024ifeq (${DISCRETE_TPM},1)
25TPM2_MK := drivers/tpm/tpm2.mk
26$(info Including ${TPM2_MK})
27include ${TPM2_MK}
28endif
29
30ifeq (${TPM_INTERFACE},FIFO_SPI)
31PLAT_BL_COMMON_SOURCES += drivers/gpio/gpio_spi.c \
32 drivers/tpm/tpm2_slb9670/slb9670_gpio.c
33endif
34
Abhi Singhc4c9e2b2024-11-06 11:11:11 -060035ifeq (${MEASURED_BOOT},1)
36MEASURED_BOOT_MK := drivers/measured_boot/event_log/event_log.mk
37$(info Including ${MEASURED_BOOT_MK})
38include ${MEASURED_BOOT_MK}
39
Abhi Singh4f9894d2024-11-07 17:39:38 -060040PLAT_BL_COMMON_SOURCES += $(TPM2_SOURCES) \
41 ${EVENT_LOG_SOURCES}
Abhi Singhc4c9e2b2024-11-06 11:11:11 -060042
43BL1_SOURCES += plat/rpi/rpi3/rpi3_bl1_mboot.c
Abhi Singh6dfcf4e2024-11-07 16:40:57 -060044BL2_SOURCES += plat/rpi/rpi3/rpi3_bl2_mboot.c \
45 plat/rpi/rpi3/rpi3_dyn_cfg_helpers.c \
46 common/fdt_wrappers.c \
47 common/fdt_fixup.c
Abhi Singhc4c9e2b2024-11-06 11:11:11 -060048
49CRYPTO_SOURCES := drivers/auth/crypto_mod.c
50
51BL1_SOURCES += ${CRYPTO_SOURCES}
52BL2_SOURCES += ${CRYPTO_SOURCES}
53
54include drivers/auth/mbedtls/mbedtls_crypto.mk
55
56endif
57
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000058BL1_SOURCES += drivers/io/io_fip.c \
59 drivers/io/io_memmap.c \
60 drivers/io/io_storage.c \
Abhi.Singh11dff592024-08-29 11:31:44 -050061 drivers/delay_timer/generic_delay_timer.c \
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000062 lib/cpus/aarch64/cortex_a53.S \
63 plat/common/aarch64/platform_mp_stack.S \
Andre Przywaraab13add2019-07-09 11:18:59 +010064 plat/rpi/rpi3/rpi3_bl1_setup.c \
Andre Przywara4f2b9842019-07-09 14:32:11 +010065 plat/rpi/common/rpi3_io_storage.c \
Andre Przywarac0031182019-07-09 13:54:56 +010066 drivers/rpi3/mailbox/rpi3_mbox.c \
67 plat/rpi/rpi3/rpi_mbox_board.c
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000068
69BL2_SOURCES += common/desc_image_load.c \
70 drivers/io/io_fip.c \
71 drivers/io/io_memmap.c \
72 drivers/io/io_storage.c \
Ying-Chun Liu (PaulLiu)2be86dd2019-01-22 03:27:55 +080073 drivers/delay_timer/generic_delay_timer.c \
Ying-Chun Liu (PaulLiu)968377f2019-01-30 04:20:38 +080074 drivers/io/io_block.c \
75 drivers/mmc/mmc.c \
76 drivers/rpi3/sdhost/rpi3_sdhost.c \
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000077 plat/common/aarch64/platform_mp_stack.S \
Andre Przywaraab13add2019-07-09 11:18:59 +010078 plat/rpi/rpi3/aarch64/rpi3_bl2_mem_params_desc.c \
79 plat/rpi/rpi3/rpi3_bl2_setup.c \
Andre Przywara4f2b9842019-07-09 14:32:11 +010080 plat/rpi/common/rpi3_image_load.c \
81 plat/rpi/common/rpi3_io_storage.c
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000082
83BL31_SOURCES += lib/cpus/aarch64/cortex_a53.S \
Madhukar Pappireddy07f867b2023-08-03 14:29:40 -050084 plat/common/plat_gicv2.c \
Antonio Nino Diaz941a6242018-08-17 14:25:08 +010085 plat/common/plat_psci_common.c \
Andre Przywaraab13add2019-07-09 11:18:59 +010086 plat/rpi/rpi3/rpi3_bl31_setup.c \
Andre Przywara4f2b9842019-07-09 14:32:11 +010087 plat/rpi/common/rpi3_pm.c \
88 plat/rpi/common/rpi3_topology.c \
Antonio Nino Diaz5341b422018-10-19 00:57:16 +010089 ${LIBFDT_SRCS}
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000090
91# Tune compiler for Cortex-A53
Chris Kay8620bd02023-12-04 09:55:50 +000092ifeq ($($(ARCH)-cc-id),arm-clang)
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000093 TF_CFLAGS_aarch64 += -mcpu=cortex-a53
Chris Kay8620bd02023-12-04 09:55:50 +000094else ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000095 TF_CFLAGS_aarch64 += -mcpu=cortex-a53
96else
97 TF_CFLAGS_aarch64 += -mtune=cortex-a53
98endif
99
Antonio Nino Diaz64fe3432018-07-12 08:58:38 +0100100# Platform Makefile target
101# ------------------------
102
103RPI3_BL1_PAD_BIN := ${BUILD_PLAT}/bl1_pad.bin
104RPI3_ARMSTUB8_BIN := ${BUILD_PLAT}/armstub8.bin
105
106# Add new default target when compiling this platform
107all: armstub
108
109# This target concatenates BL1 and the FIP so that the base addresses match the
110# ones defined in the memory map
111armstub: bl1 fip
Chris Kay7c4e1ee2024-05-02 17:52:37 +0000112 $(s)echo " CAT $@"
113 $(q)cp ${BUILD_PLAT}/bl1.bin ${RPI3_BL1_PAD_BIN}
114 $(q)truncate --size=131072 ${RPI3_BL1_PAD_BIN}
115 $(q)cat ${RPI3_BL1_PAD_BIN} ${BUILD_PLAT}/fip.bin > ${RPI3_ARMSTUB8_BIN}
116 $(s)echo
117 $(s)echo "Built $@ successfully"
118 $(s)echo
Antonio Nino Diaz64fe3432018-07-12 08:58:38 +0100119
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +0000120# Build config flags
121# ------------------
122
123# Enable all errata workarounds for Cortex-A53
124ERRATA_A53_826319 := 1
125ERRATA_A53_835769 := 1
126ERRATA_A53_836870 := 1
127ERRATA_A53_843419 := 1
128ERRATA_A53_855873 := 1
129
Dimitris Papastamos383c8082018-01-24 16:41:14 +0000130WORKAROUND_CVE_2017_5715 := 0
131
Antonio Nino Diaz1aad9322018-07-13 15:26:49 +0100132# Disable stack protector by default
133ENABLE_STACK_PROTECTOR := 0
134
Antonio Nino Diaz98967fb2018-07-13 20:19:21 +0100135# Reset to BL31 isn't supported
136RESET_TO_BL31 := 0
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +0000137
138# Have different sections for code and rodata
139SEPARATE_CODE_AND_RODATA := 1
140
141# Use Coherent memory
142USE_COHERENT_MEM := 1
143
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +0000144# Platform build flags
145# --------------------
146
147# BL33 images are in AArch64 by default
148RPI3_BL33_IN_AARCH32 := 0
149
Antonio Nino Diaz76c944a2018-07-15 12:32:32 +0100150# Assume that BL33 isn't the Linux kernel by default
151RPI3_DIRECT_LINUX_BOOT := 0
152
Pete Batard6d5c61d2018-11-13 13:14:26 +0000153# UART to use at runtime. -1 means the runtime UART is disabled.
154# Any other value means the default UART will be used.
Pete Batard4dcf1fa2018-11-15 22:29:59 +0000155RPI3_RUNTIME_UART := -1
156
157# Use normal memory mapping for ROM, FIP, SRAM and DRAM
158RPI3_USE_UEFI_MAP := 0
Pete Batard6d5c61d2018-11-13 13:14:26 +0000159
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +0000160# BL32 location
161RPI3_BL32_RAM_LOCATION := tdram
162ifeq (${RPI3_BL32_RAM_LOCATION}, tsram)
163 RPI3_BL32_RAM_LOCATION_ID = SEC_SRAM_ID
164else ifeq (${RPI3_BL32_RAM_LOCATION}, tdram)
165 RPI3_BL32_RAM_LOCATION_ID = SEC_DRAM_ID
166else
167 $(error "Unsupported RPI3_BL32_RAM_LOCATION value")
168endif
169
170# Process platform flags
171# ----------------------
172
173$(eval $(call add_define,RPI3_BL32_RAM_LOCATION_ID))
174$(eval $(call add_define,RPI3_BL33_IN_AARCH32))
Antonio Nino Diaz76c944a2018-07-15 12:32:32 +0100175$(eval $(call add_define,RPI3_DIRECT_LINUX_BOOT))
Igor Opaniukeabbdaf2019-01-16 23:59:41 +0200176ifdef RPI3_PRELOADED_DTB_BASE
Antonio Nino Diaz76c944a2018-07-15 12:32:32 +0100177$(eval $(call add_define,RPI3_PRELOADED_DTB_BASE))
Igor Opaniukeabbdaf2019-01-16 23:59:41 +0200178endif
Pete Batard6d5c61d2018-11-13 13:14:26 +0000179$(eval $(call add_define,RPI3_RUNTIME_UART))
Pete Batard4dcf1fa2018-11-15 22:29:59 +0000180$(eval $(call add_define,RPI3_USE_UEFI_MAP))
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +0000181
182# Verify build config
183# -------------------
Antonio Nino Diaz76c944a2018-07-15 12:32:32 +0100184#
185ifneq (${RPI3_DIRECT_LINUX_BOOT}, 0)
186 ifndef RPI3_PRELOADED_DTB_BASE
187 $(error Error: RPI3_PRELOADED_DTB_BASE needed if RPI3_DIRECT_LINUX_BOOT=1)
188 endif
189endif
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +0000190
Antonio Nino Diaz98967fb2018-07-13 20:19:21 +0100191ifneq (${RESET_TO_BL31}, 0)
192 $(error Error: rpi3 needs RESET_TO_BL31=0)
193endif
194
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +0000195ifeq (${ARCH},aarch32)
196 $(error Error: AArch32 not supported on rpi3)
197endif
Ying-Chun Liu (PaulLiu)7812aba2018-06-10 02:00:27 +0800198
Antonio Nino Diaz1aad9322018-07-13 15:26:49 +0100199ifneq ($(ENABLE_STACK_PROTECTOR), 0)
Andre Przywara990ab782019-07-09 14:29:24 +0100200PLAT_BL_COMMON_SOURCES += drivers/rpi3/rng/rpi3_rng.c \
Andre Przywara4f2b9842019-07-09 14:32:11 +0100201 plat/rpi/common/rpi3_stack_protector.c
Antonio Nino Diaz1aad9322018-07-13 15:26:49 +0100202endif
203
Ying-Chun Liu (PaulLiu)7812aba2018-06-10 02:00:27 +0800204ifeq (${SPD},opteed)
205BL2_SOURCES += \
206 lib/optee/optee_utils.c
207endif
208
209# Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images
210# in the FIP if the platform requires.
211ifneq ($(BL32_EXTRA1),)
212$(eval $(call TOOL_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1))
213endif
214ifneq ($(BL32_EXTRA2),)
215$(eval $(call TOOL_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2))
216endif
Ying-Chun Liu (PaulLiu)14368492018-07-04 02:26:48 +0800217
218ifneq (${TRUSTED_BOARD_BOOT},0)
219
220 include drivers/auth/mbedtls/mbedtls_crypto.mk
221 include drivers/auth/mbedtls/mbedtls_x509.mk
222
Lauren Wehrmeister142ee342025-04-30 13:23:02 -0500223 AUTH_MK := drivers/auth/auth.mk
224 $(info Including ${AUTH_MK})
225 include ${AUTH_MK}
226
227 AUTH_SOURCES += drivers/auth/tbbr/tbbr_cot_common.c
Ying-Chun Liu (PaulLiu)14368492018-07-04 02:26:48 +0800228
Ying-Chun Liu (PaulLiu)14368492018-07-04 02:26:48 +0800229 BL1_SOURCES += ${AUTH_SOURCES} \
230 bl1/tbbr/tbbr_img_desc.c \
231 plat/common/tbbr/plat_tbbr.c \
Andre Przywara4f2b9842019-07-09 14:32:11 +0100232 plat/rpi/common/rpi3_trusted_boot.c \
Manish V Badarkhead43c492020-05-16 16:36:39 +0100233 plat/rpi/common/rpi3_rotpk.S \
234 drivers/auth/tbbr/tbbr_cot_bl1.c
Ying-Chun Liu (PaulLiu)14368492018-07-04 02:26:48 +0800235
236 BL2_SOURCES += ${AUTH_SOURCES} \
237 plat/common/tbbr/plat_tbbr.c \
Andre Przywara4f2b9842019-07-09 14:32:11 +0100238 plat/rpi/common/rpi3_trusted_boot.c \
Manish V Badarkhead43c492020-05-16 16:36:39 +0100239 plat/rpi/common/rpi3_rotpk.S \
240 drivers/auth/tbbr/tbbr_cot_bl2.c
Ying-Chun Liu (PaulLiu)14368492018-07-04 02:26:48 +0800241
242 ROT_KEY = $(BUILD_PLAT)/rot_key.pem
243 ROTPK_HASH = $(BUILD_PLAT)/rotpk_sha256.bin
244
245 $(eval $(call add_define_val,ROTPK_HASH,'"$(ROTPK_HASH)"'))
246
247 $(BUILD_PLAT)/bl1/rpi3_rotpk.o: $(ROTPK_HASH)
248 $(BUILD_PLAT)/bl2/rpi3_rotpk.o: $(ROTPK_HASH)
249
250 certificates: $(ROT_KEY)
251
Chris Kay7a957592024-11-12 12:47:15 +0000252 $(ROT_KEY): | $$(@D)/
Chris Kay7c4e1ee2024-05-02 17:52:37 +0000253 $(s)echo " OPENSSL $@"
254 $(q)${OPENSSL_BIN_PATH}/openssl genrsa 2048 > $@ 2>/dev/null
Ying-Chun Liu (PaulLiu)14368492018-07-04 02:26:48 +0800255
Chris Kay7a957592024-11-12 12:47:15 +0000256 $(ROTPK_HASH): $(ROT_KEY) | $$(@D)/
Chris Kay7c4e1ee2024-05-02 17:52:37 +0000257 $(s)echo " OPENSSL $@"
258 $(q)${OPENSSL_BIN_PATH}/openssl rsa -in $< -pubout -outform DER 2>/dev/null |\
Salome Thirote95abc42022-07-14 16:14:15 +0100259 ${OPENSSL_BIN_PATH}/openssl dgst -sha256 -binary > $@ 2>/dev/null
Ying-Chun Liu (PaulLiu)14368492018-07-04 02:26:48 +0800260endif