blob: 7ed13669d36ea74f0a25f6f314a11557f357da4f [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 \
11 -Iplat/rpi/rpi3/include
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000012
Julius Werner985ee0b2018-11-27 17:50:28 -080013PLAT_BL_COMMON_SOURCES := drivers/ti/uart/aarch64/16550_console.S \
Andre Przywara5e6d8212020-03-10 12:34:56 +000014 drivers/arm/pl011/aarch64/pl011_console.S \
Andre Przywara29e8c462020-03-11 16:33:53 +000015 drivers/gpio/gpio.c \
16 drivers/delay_timer/delay_timer.c \
17 drivers/rpi3/gpio/rpi3_gpio.c \
Andre Przywara07aa0c72020-03-12 14:20:04 +000018 plat/rpi/common/aarch64/plat_helpers.S \
Andre Przywara4f2b9842019-07-09 14:32:11 +010019 plat/rpi/common/rpi3_common.c \
Mario Bălănicăb5029782023-12-01 04:59:43 +020020 plat/rpi/common/rpi3_console_dual.c \
Antonio Nino Diaz5341b422018-10-19 00:57:16 +010021 ${XLAT_TABLES_LIB_SRCS}
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000022
Abhi Singhc4c9e2b2024-11-06 11:11:11 -060023ifeq (${MEASURED_BOOT},1)
24MEASURED_BOOT_MK := drivers/measured_boot/event_log/event_log.mk
25$(info Including ${MEASURED_BOOT_MK})
26include ${MEASURED_BOOT_MK}
27
28PLAT_BL_COMMON_SOURCES += ${EVENT_LOG_SOURCES}
29
30BL1_SOURCES += plat/rpi/rpi3/rpi3_bl1_mboot.c
31BL2_SOURCES += plat/rpi/rpi3/rpi3_bl2_mboot.c
32
33CRYPTO_SOURCES := drivers/auth/crypto_mod.c
34
35BL1_SOURCES += ${CRYPTO_SOURCES}
36BL2_SOURCES += ${CRYPTO_SOURCES}
37
38include drivers/auth/mbedtls/mbedtls_crypto.mk
39
40endif
41
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000042BL1_SOURCES += drivers/io/io_fip.c \
43 drivers/io/io_memmap.c \
44 drivers/io/io_storage.c \
Abhi.Singh11dff592024-08-29 11:31:44 -050045 drivers/delay_timer/generic_delay_timer.c \
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000046 lib/cpus/aarch64/cortex_a53.S \
47 plat/common/aarch64/platform_mp_stack.S \
Andre Przywaraab13add2019-07-09 11:18:59 +010048 plat/rpi/rpi3/rpi3_bl1_setup.c \
Andre Przywara4f2b9842019-07-09 14:32:11 +010049 plat/rpi/common/rpi3_io_storage.c \
Andre Przywarac0031182019-07-09 13:54:56 +010050 drivers/rpi3/mailbox/rpi3_mbox.c \
51 plat/rpi/rpi3/rpi_mbox_board.c
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000052
53BL2_SOURCES += common/desc_image_load.c \
54 drivers/io/io_fip.c \
55 drivers/io/io_memmap.c \
56 drivers/io/io_storage.c \
Ying-Chun Liu (PaulLiu)2be86dd2019-01-22 03:27:55 +080057 drivers/delay_timer/generic_delay_timer.c \
Ying-Chun Liu (PaulLiu)968377f2019-01-30 04:20:38 +080058 drivers/io/io_block.c \
59 drivers/mmc/mmc.c \
60 drivers/rpi3/sdhost/rpi3_sdhost.c \
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000061 plat/common/aarch64/platform_mp_stack.S \
Andre Przywaraab13add2019-07-09 11:18:59 +010062 plat/rpi/rpi3/aarch64/rpi3_bl2_mem_params_desc.c \
63 plat/rpi/rpi3/rpi3_bl2_setup.c \
Andre Przywara4f2b9842019-07-09 14:32:11 +010064 plat/rpi/common/rpi3_image_load.c \
65 plat/rpi/common/rpi3_io_storage.c
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000066
67BL31_SOURCES += lib/cpus/aarch64/cortex_a53.S \
Madhukar Pappireddy07f867b2023-08-03 14:29:40 -050068 plat/common/plat_gicv2.c \
Antonio Nino Diaz941a6242018-08-17 14:25:08 +010069 plat/common/plat_psci_common.c \
Andre Przywaraab13add2019-07-09 11:18:59 +010070 plat/rpi/rpi3/rpi3_bl31_setup.c \
Andre Przywara4f2b9842019-07-09 14:32:11 +010071 plat/rpi/common/rpi3_pm.c \
72 plat/rpi/common/rpi3_topology.c \
Antonio Nino Diaz5341b422018-10-19 00:57:16 +010073 ${LIBFDT_SRCS}
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000074
75# Tune compiler for Cortex-A53
Chris Kay8620bd02023-12-04 09:55:50 +000076ifeq ($($(ARCH)-cc-id),arm-clang)
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000077 TF_CFLAGS_aarch64 += -mcpu=cortex-a53
Chris Kay8620bd02023-12-04 09:55:50 +000078else ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +000079 TF_CFLAGS_aarch64 += -mcpu=cortex-a53
80else
81 TF_CFLAGS_aarch64 += -mtune=cortex-a53
82endif
83
Antonio Nino Diaz64fe3432018-07-12 08:58:38 +010084# Platform Makefile target
85# ------------------------
86
87RPI3_BL1_PAD_BIN := ${BUILD_PLAT}/bl1_pad.bin
88RPI3_ARMSTUB8_BIN := ${BUILD_PLAT}/armstub8.bin
89
90# Add new default target when compiling this platform
91all: armstub
92
93# This target concatenates BL1 and the FIP so that the base addresses match the
94# ones defined in the memory map
95armstub: bl1 fip
Chris Kay7c4e1ee2024-05-02 17:52:37 +000096 $(s)echo " CAT $@"
97 $(q)cp ${BUILD_PLAT}/bl1.bin ${RPI3_BL1_PAD_BIN}
98 $(q)truncate --size=131072 ${RPI3_BL1_PAD_BIN}
99 $(q)cat ${RPI3_BL1_PAD_BIN} ${BUILD_PLAT}/fip.bin > ${RPI3_ARMSTUB8_BIN}
100 $(s)echo
101 $(s)echo "Built $@ successfully"
102 $(s)echo
Antonio Nino Diaz64fe3432018-07-12 08:58:38 +0100103
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +0000104# Build config flags
105# ------------------
106
107# Enable all errata workarounds for Cortex-A53
108ERRATA_A53_826319 := 1
109ERRATA_A53_835769 := 1
110ERRATA_A53_836870 := 1
111ERRATA_A53_843419 := 1
112ERRATA_A53_855873 := 1
113
Dimitris Papastamos383c8082018-01-24 16:41:14 +0000114WORKAROUND_CVE_2017_5715 := 0
115
Antonio Nino Diaz1aad9322018-07-13 15:26:49 +0100116# Disable stack protector by default
117ENABLE_STACK_PROTECTOR := 0
118
Antonio Nino Diaz98967fb2018-07-13 20:19:21 +0100119# Reset to BL31 isn't supported
120RESET_TO_BL31 := 0
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +0000121
122# Have different sections for code and rodata
123SEPARATE_CODE_AND_RODATA := 1
124
125# Use Coherent memory
126USE_COHERENT_MEM := 1
127
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +0000128# Platform build flags
129# --------------------
130
131# BL33 images are in AArch64 by default
132RPI3_BL33_IN_AARCH32 := 0
133
Antonio Nino Diaz76c944a2018-07-15 12:32:32 +0100134# Assume that BL33 isn't the Linux kernel by default
135RPI3_DIRECT_LINUX_BOOT := 0
136
Pete Batard6d5c61d2018-11-13 13:14:26 +0000137# UART to use at runtime. -1 means the runtime UART is disabled.
138# Any other value means the default UART will be used.
Pete Batard4dcf1fa2018-11-15 22:29:59 +0000139RPI3_RUNTIME_UART := -1
140
141# Use normal memory mapping for ROM, FIP, SRAM and DRAM
142RPI3_USE_UEFI_MAP := 0
Pete Batard6d5c61d2018-11-13 13:14:26 +0000143
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +0000144# BL32 location
145RPI3_BL32_RAM_LOCATION := tdram
146ifeq (${RPI3_BL32_RAM_LOCATION}, tsram)
147 RPI3_BL32_RAM_LOCATION_ID = SEC_SRAM_ID
148else ifeq (${RPI3_BL32_RAM_LOCATION}, tdram)
149 RPI3_BL32_RAM_LOCATION_ID = SEC_DRAM_ID
150else
151 $(error "Unsupported RPI3_BL32_RAM_LOCATION value")
152endif
153
154# Process platform flags
155# ----------------------
156
157$(eval $(call add_define,RPI3_BL32_RAM_LOCATION_ID))
158$(eval $(call add_define,RPI3_BL33_IN_AARCH32))
Antonio Nino Diaz76c944a2018-07-15 12:32:32 +0100159$(eval $(call add_define,RPI3_DIRECT_LINUX_BOOT))
Igor Opaniukeabbdaf2019-01-16 23:59:41 +0200160ifdef RPI3_PRELOADED_DTB_BASE
Antonio Nino Diaz76c944a2018-07-15 12:32:32 +0100161$(eval $(call add_define,RPI3_PRELOADED_DTB_BASE))
Igor Opaniukeabbdaf2019-01-16 23:59:41 +0200162endif
Pete Batard6d5c61d2018-11-13 13:14:26 +0000163$(eval $(call add_define,RPI3_RUNTIME_UART))
Pete Batard4dcf1fa2018-11-15 22:29:59 +0000164$(eval $(call add_define,RPI3_USE_UEFI_MAP))
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +0000165
166# Verify build config
167# -------------------
Antonio Nino Diaz76c944a2018-07-15 12:32:32 +0100168#
169ifneq (${RPI3_DIRECT_LINUX_BOOT}, 0)
170 ifndef RPI3_PRELOADED_DTB_BASE
171 $(error Error: RPI3_PRELOADED_DTB_BASE needed if RPI3_DIRECT_LINUX_BOOT=1)
172 endif
173endif
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +0000174
Antonio Nino Diaz98967fb2018-07-13 20:19:21 +0100175ifneq (${RESET_TO_BL31}, 0)
176 $(error Error: rpi3 needs RESET_TO_BL31=0)
177endif
178
Antonio Nino Diazd83c1db2017-11-06 14:49:04 +0000179ifeq (${ARCH},aarch32)
180 $(error Error: AArch32 not supported on rpi3)
181endif
Ying-Chun Liu (PaulLiu)7812aba2018-06-10 02:00:27 +0800182
Antonio Nino Diaz1aad9322018-07-13 15:26:49 +0100183ifneq ($(ENABLE_STACK_PROTECTOR), 0)
Andre Przywara990ab782019-07-09 14:29:24 +0100184PLAT_BL_COMMON_SOURCES += drivers/rpi3/rng/rpi3_rng.c \
Andre Przywara4f2b9842019-07-09 14:32:11 +0100185 plat/rpi/common/rpi3_stack_protector.c
Antonio Nino Diaz1aad9322018-07-13 15:26:49 +0100186endif
187
Ying-Chun Liu (PaulLiu)7812aba2018-06-10 02:00:27 +0800188ifeq (${SPD},opteed)
189BL2_SOURCES += \
190 lib/optee/optee_utils.c
191endif
192
193# Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images
194# in the FIP if the platform requires.
195ifneq ($(BL32_EXTRA1),)
196$(eval $(call TOOL_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1))
197endif
198ifneq ($(BL32_EXTRA2),)
199$(eval $(call TOOL_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2))
200endif
Ying-Chun Liu (PaulLiu)14368492018-07-04 02:26:48 +0800201
202ifneq (${TRUSTED_BOARD_BOOT},0)
203
204 include drivers/auth/mbedtls/mbedtls_crypto.mk
205 include drivers/auth/mbedtls/mbedtls_x509.mk
206
Ying-Chun Liu (PaulLiu)14368492018-07-04 02:26:48 +0800207 AUTH_SOURCES := drivers/auth/auth_mod.c \
208 drivers/auth/crypto_mod.c \
209 drivers/auth/img_parser_mod.c \
Manish V Badarkhead43c492020-05-16 16:36:39 +0100210 drivers/auth/tbbr/tbbr_cot_common.c
Ying-Chun Liu (PaulLiu)14368492018-07-04 02:26:48 +0800211
Ying-Chun Liu (PaulLiu)14368492018-07-04 02:26:48 +0800212 BL1_SOURCES += ${AUTH_SOURCES} \
213 bl1/tbbr/tbbr_img_desc.c \
214 plat/common/tbbr/plat_tbbr.c \
Andre Przywara4f2b9842019-07-09 14:32:11 +0100215 plat/rpi/common/rpi3_trusted_boot.c \
Manish V Badarkhead43c492020-05-16 16:36:39 +0100216 plat/rpi/common/rpi3_rotpk.S \
217 drivers/auth/tbbr/tbbr_cot_bl1.c
Ying-Chun Liu (PaulLiu)14368492018-07-04 02:26:48 +0800218
219 BL2_SOURCES += ${AUTH_SOURCES} \
220 plat/common/tbbr/plat_tbbr.c \
Andre Przywara4f2b9842019-07-09 14:32:11 +0100221 plat/rpi/common/rpi3_trusted_boot.c \
Manish V Badarkhead43c492020-05-16 16:36:39 +0100222 plat/rpi/common/rpi3_rotpk.S \
223 drivers/auth/tbbr/tbbr_cot_bl2.c
Ying-Chun Liu (PaulLiu)14368492018-07-04 02:26:48 +0800224
225 ROT_KEY = $(BUILD_PLAT)/rot_key.pem
226 ROTPK_HASH = $(BUILD_PLAT)/rotpk_sha256.bin
227
228 $(eval $(call add_define_val,ROTPK_HASH,'"$(ROTPK_HASH)"'))
229
230 $(BUILD_PLAT)/bl1/rpi3_rotpk.o: $(ROTPK_HASH)
231 $(BUILD_PLAT)/bl2/rpi3_rotpk.o: $(ROTPK_HASH)
232
233 certificates: $(ROT_KEY)
234
Chris Kay7a957592024-11-12 12:47:15 +0000235 $(ROT_KEY): | $$(@D)/
Chris Kay7c4e1ee2024-05-02 17:52:37 +0000236 $(s)echo " OPENSSL $@"
237 $(q)${OPENSSL_BIN_PATH}/openssl genrsa 2048 > $@ 2>/dev/null
Ying-Chun Liu (PaulLiu)14368492018-07-04 02:26:48 +0800238
Chris Kay7a957592024-11-12 12:47:15 +0000239 $(ROTPK_HASH): $(ROT_KEY) | $$(@D)/
Chris Kay7c4e1ee2024-05-02 17:52:37 +0000240 $(s)echo " OPENSSL $@"
241 $(q)${OPENSSL_BIN_PATH}/openssl rsa -in $< -pubout -outform DER 2>/dev/null |\
Salome Thirote95abc42022-07-14 16:14:15 +0100242 ${OPENSSL_BIN_PATH}/openssl dgst -sha256 -binary > $@ 2>/dev/null
Ying-Chun Liu (PaulLiu)14368492018-07-04 02:26:48 +0800243endif