blob: e139b492465990d61f95a7eeb0d3568b17f5b052 [file] [log] [blame]
Antonio Nino Diazae6779e2017-11-06 14:49:04 +00001#
Chris Kay523e8642023-12-04 12:03:51 +00002# Copyright (c) 2013-2024, 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 Przywara9ba6bb02020-03-10 12:34:56 +000014 drivers/arm/pl011/aarch64/pl011_console.S \
Andre Przywara9e4815a2020-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 Przywara98e48562020-03-12 14:20:04 +000018 plat/rpi/common/aarch64/plat_helpers.S \
Andre Przywara4ea3bd32019-07-09 14:32:11 +010019 plat/rpi/common/rpi3_common.c \
Mario Bălănicăc258e4c2023-12-01 04:59:43 +020020 plat/rpi/common/rpi3_console_dual.c \
Antonio Nino Diazf96582a2018-10-19 00:57:16 +010021 ${XLAT_TABLES_LIB_SRCS}
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000022
23BL1_SOURCES += drivers/io/io_fip.c \
24 drivers/io/io_memmap.c \
25 drivers/io/io_storage.c \
Abhi.Singh14292862024-08-29 11:31:44 -050026 drivers/delay_timer/generic_delay_timer.c \
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000027 lib/cpus/aarch64/cortex_a53.S \
28 plat/common/aarch64/platform_mp_stack.S \
Andre Przywarab2262462019-07-09 11:18:59 +010029 plat/rpi/rpi3/rpi3_bl1_setup.c \
Andre Przywara4ea3bd32019-07-09 14:32:11 +010030 plat/rpi/common/rpi3_io_storage.c \
Andre Przywara05862fc2019-07-09 13:54:56 +010031 drivers/rpi3/mailbox/rpi3_mbox.c \
32 plat/rpi/rpi3/rpi_mbox_board.c
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000033
34BL2_SOURCES += common/desc_image_load.c \
35 drivers/io/io_fip.c \
36 drivers/io/io_memmap.c \
37 drivers/io/io_storage.c \
Ying-Chun Liu (PaulLiu)34527382019-01-22 03:27:55 +080038 drivers/delay_timer/generic_delay_timer.c \
Ying-Chun Liu (PaulLiu)de6f2f42019-01-30 04:20:38 +080039 drivers/io/io_block.c \
40 drivers/mmc/mmc.c \
41 drivers/rpi3/sdhost/rpi3_sdhost.c \
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000042 plat/common/aarch64/platform_mp_stack.S \
Andre Przywarab2262462019-07-09 11:18:59 +010043 plat/rpi/rpi3/aarch64/rpi3_bl2_mem_params_desc.c \
44 plat/rpi/rpi3/rpi3_bl2_setup.c \
Andre Przywara4ea3bd32019-07-09 14:32:11 +010045 plat/rpi/common/rpi3_image_load.c \
46 plat/rpi/common/rpi3_io_storage.c
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000047
48BL31_SOURCES += lib/cpus/aarch64/cortex_a53.S \
Madhukar Pappireddy81e46872023-08-03 14:29:40 -050049 plat/common/plat_gicv2.c \
Antonio Nino Diaz83d8c792018-08-17 14:25:08 +010050 plat/common/plat_psci_common.c \
Andre Przywarab2262462019-07-09 11:18:59 +010051 plat/rpi/rpi3/rpi3_bl31_setup.c \
Andre Przywara4ea3bd32019-07-09 14:32:11 +010052 plat/rpi/common/rpi3_pm.c \
53 plat/rpi/common/rpi3_topology.c \
Antonio Nino Diazf96582a2018-10-19 00:57:16 +010054 ${LIBFDT_SRCS}
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000055
56# Tune compiler for Cortex-A53
Chris Kaycfba6452023-12-04 09:55:50 +000057ifeq ($($(ARCH)-cc-id),arm-clang)
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000058 TF_CFLAGS_aarch64 += -mcpu=cortex-a53
Chris Kaycfba6452023-12-04 09:55:50 +000059else ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000060 TF_CFLAGS_aarch64 += -mcpu=cortex-a53
61else
62 TF_CFLAGS_aarch64 += -mtune=cortex-a53
63endif
64
Antonio Nino Diazdfe895d2018-07-12 08:58:38 +010065# Platform Makefile target
66# ------------------------
67
68RPI3_BL1_PAD_BIN := ${BUILD_PLAT}/bl1_pad.bin
69RPI3_ARMSTUB8_BIN := ${BUILD_PLAT}/armstub8.bin
70
71# Add new default target when compiling this platform
72all: armstub
73
74# This target concatenates BL1 and the FIP so that the base addresses match the
75# ones defined in the memory map
76armstub: bl1 fip
Chris Kay1870c722024-05-02 17:52:37 +000077 $(s)echo " CAT $@"
78 $(q)cp ${BUILD_PLAT}/bl1.bin ${RPI3_BL1_PAD_BIN}
79 $(q)truncate --size=131072 ${RPI3_BL1_PAD_BIN}
80 $(q)cat ${RPI3_BL1_PAD_BIN} ${BUILD_PLAT}/fip.bin > ${RPI3_ARMSTUB8_BIN}
81 $(s)echo
82 $(s)echo "Built $@ successfully"
83 $(s)echo
Antonio Nino Diazdfe895d2018-07-12 08:58:38 +010084
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000085# Build config flags
86# ------------------
87
88# Enable all errata workarounds for Cortex-A53
89ERRATA_A53_826319 := 1
90ERRATA_A53_835769 := 1
91ERRATA_A53_836870 := 1
92ERRATA_A53_843419 := 1
93ERRATA_A53_855873 := 1
94
Dimitris Papastamos8e5bd5e2018-01-24 16:41:14 +000095WORKAROUND_CVE_2017_5715 := 0
96
Antonio Nino Diaz4b7059d2018-07-13 15:26:49 +010097# Disable stack protector by default
98ENABLE_STACK_PROTECTOR := 0
99
Antonio Nino Diazdf0bb5a2018-07-13 20:19:21 +0100100# Reset to BL31 isn't supported
101RESET_TO_BL31 := 0
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000102
103# Have different sections for code and rodata
104SEPARATE_CODE_AND_RODATA := 1
105
106# Use Coherent memory
107USE_COHERENT_MEM := 1
108
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000109# Platform build flags
110# --------------------
111
112# BL33 images are in AArch64 by default
113RPI3_BL33_IN_AARCH32 := 0
114
Antonio Nino Diazf8b36cc2018-07-15 12:32:32 +0100115# Assume that BL33 isn't the Linux kernel by default
116RPI3_DIRECT_LINUX_BOOT := 0
117
Pete Batardc9acd6c2018-11-13 13:14:26 +0000118# UART to use at runtime. -1 means the runtime UART is disabled.
119# Any other value means the default UART will be used.
Pete Batardf820cad2018-11-15 22:29:59 +0000120RPI3_RUNTIME_UART := -1
121
122# Use normal memory mapping for ROM, FIP, SRAM and DRAM
123RPI3_USE_UEFI_MAP := 0
Pete Batardc9acd6c2018-11-13 13:14:26 +0000124
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000125# BL32 location
126RPI3_BL32_RAM_LOCATION := tdram
127ifeq (${RPI3_BL32_RAM_LOCATION}, tsram)
128 RPI3_BL32_RAM_LOCATION_ID = SEC_SRAM_ID
129else ifeq (${RPI3_BL32_RAM_LOCATION}, tdram)
130 RPI3_BL32_RAM_LOCATION_ID = SEC_DRAM_ID
131else
132 $(error "Unsupported RPI3_BL32_RAM_LOCATION value")
133endif
134
135# Process platform flags
136# ----------------------
137
138$(eval $(call add_define,RPI3_BL32_RAM_LOCATION_ID))
139$(eval $(call add_define,RPI3_BL33_IN_AARCH32))
Antonio Nino Diazf8b36cc2018-07-15 12:32:32 +0100140$(eval $(call add_define,RPI3_DIRECT_LINUX_BOOT))
Igor Opaniuk02016b22019-01-16 23:59:41 +0200141ifdef RPI3_PRELOADED_DTB_BASE
Antonio Nino Diazf8b36cc2018-07-15 12:32:32 +0100142$(eval $(call add_define,RPI3_PRELOADED_DTB_BASE))
Igor Opaniuk02016b22019-01-16 23:59:41 +0200143endif
Pete Batardc9acd6c2018-11-13 13:14:26 +0000144$(eval $(call add_define,RPI3_RUNTIME_UART))
Pete Batardf820cad2018-11-15 22:29:59 +0000145$(eval $(call add_define,RPI3_USE_UEFI_MAP))
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000146
147# Verify build config
148# -------------------
Antonio Nino Diazf8b36cc2018-07-15 12:32:32 +0100149#
150ifneq (${RPI3_DIRECT_LINUX_BOOT}, 0)
151 ifndef RPI3_PRELOADED_DTB_BASE
152 $(error Error: RPI3_PRELOADED_DTB_BASE needed if RPI3_DIRECT_LINUX_BOOT=1)
153 endif
154endif
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000155
Antonio Nino Diazdf0bb5a2018-07-13 20:19:21 +0100156ifneq (${RESET_TO_BL31}, 0)
157 $(error Error: rpi3 needs RESET_TO_BL31=0)
158endif
159
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000160ifeq (${ARCH},aarch32)
161 $(error Error: AArch32 not supported on rpi3)
162endif
Ying-Chun Liu (PaulLiu)d9f76e62018-06-10 02:00:27 +0800163
Antonio Nino Diaz4b7059d2018-07-13 15:26:49 +0100164ifneq ($(ENABLE_STACK_PROTECTOR), 0)
Andre Przywara93de78c2019-07-09 14:29:24 +0100165PLAT_BL_COMMON_SOURCES += drivers/rpi3/rng/rpi3_rng.c \
Andre Przywara4ea3bd32019-07-09 14:32:11 +0100166 plat/rpi/common/rpi3_stack_protector.c
Antonio Nino Diaz4b7059d2018-07-13 15:26:49 +0100167endif
168
Ying-Chun Liu (PaulLiu)d9f76e62018-06-10 02:00:27 +0800169ifeq (${SPD},opteed)
170BL2_SOURCES += \
171 lib/optee/optee_utils.c
172endif
173
174# Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images
175# in the FIP if the platform requires.
176ifneq ($(BL32_EXTRA1),)
177$(eval $(call TOOL_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1))
178endif
179ifneq ($(BL32_EXTRA2),)
180$(eval $(call TOOL_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2))
181endif
Ying-Chun Liu (PaulLiu)9128df62018-07-04 02:26:48 +0800182
183ifneq (${TRUSTED_BOARD_BOOT},0)
184
185 include drivers/auth/mbedtls/mbedtls_crypto.mk
186 include drivers/auth/mbedtls/mbedtls_x509.mk
187
Ying-Chun Liu (PaulLiu)9128df62018-07-04 02:26:48 +0800188 AUTH_SOURCES := drivers/auth/auth_mod.c \
189 drivers/auth/crypto_mod.c \
190 drivers/auth/img_parser_mod.c \
Manish V Badarkhe043fd622020-05-16 16:36:39 +0100191 drivers/auth/tbbr/tbbr_cot_common.c
Ying-Chun Liu (PaulLiu)9128df62018-07-04 02:26:48 +0800192
Ying-Chun Liu (PaulLiu)9128df62018-07-04 02:26:48 +0800193 BL1_SOURCES += ${AUTH_SOURCES} \
194 bl1/tbbr/tbbr_img_desc.c \
195 plat/common/tbbr/plat_tbbr.c \
Andre Przywara4ea3bd32019-07-09 14:32:11 +0100196 plat/rpi/common/rpi3_trusted_boot.c \
Manish V Badarkhe043fd622020-05-16 16:36:39 +0100197 plat/rpi/common/rpi3_rotpk.S \
198 drivers/auth/tbbr/tbbr_cot_bl1.c
Ying-Chun Liu (PaulLiu)9128df62018-07-04 02:26:48 +0800199
200 BL2_SOURCES += ${AUTH_SOURCES} \
201 plat/common/tbbr/plat_tbbr.c \
Andre Przywara4ea3bd32019-07-09 14:32:11 +0100202 plat/rpi/common/rpi3_trusted_boot.c \
Manish V Badarkhe043fd622020-05-16 16:36:39 +0100203 plat/rpi/common/rpi3_rotpk.S \
204 drivers/auth/tbbr/tbbr_cot_bl2.c
Ying-Chun Liu (PaulLiu)9128df62018-07-04 02:26:48 +0800205
206 ROT_KEY = $(BUILD_PLAT)/rot_key.pem
207 ROTPK_HASH = $(BUILD_PLAT)/rotpk_sha256.bin
208
209 $(eval $(call add_define_val,ROTPK_HASH,'"$(ROTPK_HASH)"'))
210
211 $(BUILD_PLAT)/bl1/rpi3_rotpk.o: $(ROTPK_HASH)
212 $(BUILD_PLAT)/bl2/rpi3_rotpk.o: $(ROTPK_HASH)
213
214 certificates: $(ROT_KEY)
215
Manish V Badarkhed8c877f2020-09-03 16:54:47 +0100216 $(ROT_KEY): | $(BUILD_PLAT)
Chris Kay1870c722024-05-02 17:52:37 +0000217 $(s)echo " OPENSSL $@"
218 $(q)${OPENSSL_BIN_PATH}/openssl genrsa 2048 > $@ 2>/dev/null
Ying-Chun Liu (PaulLiu)9128df62018-07-04 02:26:48 +0800219
220 $(ROTPK_HASH): $(ROT_KEY)
Chris Kay1870c722024-05-02 17:52:37 +0000221 $(s)echo " OPENSSL $@"
222 $(q)${OPENSSL_BIN_PATH}/openssl rsa -in $< -pubout -outform DER 2>/dev/null |\
Salome Thirot0b35da32022-07-14 16:14:15 +0100223 ${OPENSSL_BIN_PATH}/openssl dgst -sha256 -binary > $@ 2>/dev/null
Ying-Chun Liu (PaulLiu)9128df62018-07-04 02:26:48 +0800224endif