Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 1 | # |
Abhi Singh | c4c9e2b | 2024-11-06 11:11:11 -0600 | [diff] [blame^] | 2 | # Copyright (c) 2013-2025, Arm Limited and Contributors. All rights reserved. |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | |
Antonio Nino Diaz | 5341b42 | 2018-10-19 00:57:16 +0100 | [diff] [blame] | 7 | include lib/libfdt/libfdt.mk |
| 8 | include lib/xlat_tables_v2/xlat_tables.mk |
| 9 | |
Andre Przywara | 4f2b984 | 2019-07-09 14:32:11 +0100 | [diff] [blame] | 10 | PLAT_INCLUDES := -Iplat/rpi/common/include \ |
| 11 | -Iplat/rpi/rpi3/include |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 12 | |
Julius Werner | 985ee0b | 2018-11-27 17:50:28 -0800 | [diff] [blame] | 13 | PLAT_BL_COMMON_SOURCES := drivers/ti/uart/aarch64/16550_console.S \ |
Andre Przywara | 5e6d821 | 2020-03-10 12:34:56 +0000 | [diff] [blame] | 14 | drivers/arm/pl011/aarch64/pl011_console.S \ |
Andre Przywara | 29e8c46 | 2020-03-11 16:33:53 +0000 | [diff] [blame] | 15 | drivers/gpio/gpio.c \ |
| 16 | drivers/delay_timer/delay_timer.c \ |
| 17 | drivers/rpi3/gpio/rpi3_gpio.c \ |
Andre Przywara | 07aa0c7 | 2020-03-12 14:20:04 +0000 | [diff] [blame] | 18 | plat/rpi/common/aarch64/plat_helpers.S \ |
Andre Przywara | 4f2b984 | 2019-07-09 14:32:11 +0100 | [diff] [blame] | 19 | plat/rpi/common/rpi3_common.c \ |
Mario Bălănică | b502978 | 2023-12-01 04:59:43 +0200 | [diff] [blame] | 20 | plat/rpi/common/rpi3_console_dual.c \ |
Antonio Nino Diaz | 5341b42 | 2018-10-19 00:57:16 +0100 | [diff] [blame] | 21 | ${XLAT_TABLES_LIB_SRCS} |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 22 | |
Abhi Singh | c4c9e2b | 2024-11-06 11:11:11 -0600 | [diff] [blame^] | 23 | ifeq (${MEASURED_BOOT},1) |
| 24 | MEASURED_BOOT_MK := drivers/measured_boot/event_log/event_log.mk |
| 25 | $(info Including ${MEASURED_BOOT_MK}) |
| 26 | include ${MEASURED_BOOT_MK} |
| 27 | |
| 28 | PLAT_BL_COMMON_SOURCES += ${EVENT_LOG_SOURCES} |
| 29 | |
| 30 | BL1_SOURCES += plat/rpi/rpi3/rpi3_bl1_mboot.c |
| 31 | BL2_SOURCES += plat/rpi/rpi3/rpi3_bl2_mboot.c |
| 32 | |
| 33 | CRYPTO_SOURCES := drivers/auth/crypto_mod.c |
| 34 | |
| 35 | BL1_SOURCES += ${CRYPTO_SOURCES} |
| 36 | BL2_SOURCES += ${CRYPTO_SOURCES} |
| 37 | |
| 38 | include drivers/auth/mbedtls/mbedtls_crypto.mk |
| 39 | |
| 40 | endif |
| 41 | |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 42 | BL1_SOURCES += drivers/io/io_fip.c \ |
| 43 | drivers/io/io_memmap.c \ |
| 44 | drivers/io/io_storage.c \ |
Abhi.Singh | 11dff59 | 2024-08-29 11:31:44 -0500 | [diff] [blame] | 45 | drivers/delay_timer/generic_delay_timer.c \ |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 46 | lib/cpus/aarch64/cortex_a53.S \ |
| 47 | plat/common/aarch64/platform_mp_stack.S \ |
Andre Przywara | ab13add | 2019-07-09 11:18:59 +0100 | [diff] [blame] | 48 | plat/rpi/rpi3/rpi3_bl1_setup.c \ |
Andre Przywara | 4f2b984 | 2019-07-09 14:32:11 +0100 | [diff] [blame] | 49 | plat/rpi/common/rpi3_io_storage.c \ |
Andre Przywara | c003118 | 2019-07-09 13:54:56 +0100 | [diff] [blame] | 50 | drivers/rpi3/mailbox/rpi3_mbox.c \ |
| 51 | plat/rpi/rpi3/rpi_mbox_board.c |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 52 | |
| 53 | BL2_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) | 2be86dd | 2019-01-22 03:27:55 +0800 | [diff] [blame] | 57 | drivers/delay_timer/generic_delay_timer.c \ |
Ying-Chun Liu (PaulLiu) | 968377f | 2019-01-30 04:20:38 +0800 | [diff] [blame] | 58 | drivers/io/io_block.c \ |
| 59 | drivers/mmc/mmc.c \ |
| 60 | drivers/rpi3/sdhost/rpi3_sdhost.c \ |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 61 | plat/common/aarch64/platform_mp_stack.S \ |
Andre Przywara | ab13add | 2019-07-09 11:18:59 +0100 | [diff] [blame] | 62 | plat/rpi/rpi3/aarch64/rpi3_bl2_mem_params_desc.c \ |
| 63 | plat/rpi/rpi3/rpi3_bl2_setup.c \ |
Andre Przywara | 4f2b984 | 2019-07-09 14:32:11 +0100 | [diff] [blame] | 64 | plat/rpi/common/rpi3_image_load.c \ |
| 65 | plat/rpi/common/rpi3_io_storage.c |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 66 | |
| 67 | BL31_SOURCES += lib/cpus/aarch64/cortex_a53.S \ |
Madhukar Pappireddy | 07f867b | 2023-08-03 14:29:40 -0500 | [diff] [blame] | 68 | plat/common/plat_gicv2.c \ |
Antonio Nino Diaz | 941a624 | 2018-08-17 14:25:08 +0100 | [diff] [blame] | 69 | plat/common/plat_psci_common.c \ |
Andre Przywara | ab13add | 2019-07-09 11:18:59 +0100 | [diff] [blame] | 70 | plat/rpi/rpi3/rpi3_bl31_setup.c \ |
Andre Przywara | 4f2b984 | 2019-07-09 14:32:11 +0100 | [diff] [blame] | 71 | plat/rpi/common/rpi3_pm.c \ |
| 72 | plat/rpi/common/rpi3_topology.c \ |
Antonio Nino Diaz | 5341b42 | 2018-10-19 00:57:16 +0100 | [diff] [blame] | 73 | ${LIBFDT_SRCS} |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 74 | |
| 75 | # Tune compiler for Cortex-A53 |
Chris Kay | 8620bd0 | 2023-12-04 09:55:50 +0000 | [diff] [blame] | 76 | ifeq ($($(ARCH)-cc-id),arm-clang) |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 77 | TF_CFLAGS_aarch64 += -mcpu=cortex-a53 |
Chris Kay | 8620bd0 | 2023-12-04 09:55:50 +0000 | [diff] [blame] | 78 | else ifneq ($(filter %-clang,$($(ARCH)-cc-id)),) |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 79 | TF_CFLAGS_aarch64 += -mcpu=cortex-a53 |
| 80 | else |
| 81 | TF_CFLAGS_aarch64 += -mtune=cortex-a53 |
| 82 | endif |
| 83 | |
Antonio Nino Diaz | 64fe343 | 2018-07-12 08:58:38 +0100 | [diff] [blame] | 84 | # Platform Makefile target |
| 85 | # ------------------------ |
| 86 | |
| 87 | RPI3_BL1_PAD_BIN := ${BUILD_PLAT}/bl1_pad.bin |
| 88 | RPI3_ARMSTUB8_BIN := ${BUILD_PLAT}/armstub8.bin |
| 89 | |
| 90 | # Add new default target when compiling this platform |
| 91 | all: armstub |
| 92 | |
| 93 | # This target concatenates BL1 and the FIP so that the base addresses match the |
| 94 | # ones defined in the memory map |
| 95 | armstub: bl1 fip |
Chris Kay | 7c4e1ee | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 96 | $(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 Diaz | 64fe343 | 2018-07-12 08:58:38 +0100 | [diff] [blame] | 103 | |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 104 | # Build config flags |
| 105 | # ------------------ |
| 106 | |
| 107 | # Enable all errata workarounds for Cortex-A53 |
| 108 | ERRATA_A53_826319 := 1 |
| 109 | ERRATA_A53_835769 := 1 |
| 110 | ERRATA_A53_836870 := 1 |
| 111 | ERRATA_A53_843419 := 1 |
| 112 | ERRATA_A53_855873 := 1 |
| 113 | |
Dimitris Papastamos | 383c808 | 2018-01-24 16:41:14 +0000 | [diff] [blame] | 114 | WORKAROUND_CVE_2017_5715 := 0 |
| 115 | |
Antonio Nino Diaz | 1aad932 | 2018-07-13 15:26:49 +0100 | [diff] [blame] | 116 | # Disable stack protector by default |
| 117 | ENABLE_STACK_PROTECTOR := 0 |
| 118 | |
Antonio Nino Diaz | 98967fb | 2018-07-13 20:19:21 +0100 | [diff] [blame] | 119 | # Reset to BL31 isn't supported |
| 120 | RESET_TO_BL31 := 0 |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 121 | |
| 122 | # Have different sections for code and rodata |
| 123 | SEPARATE_CODE_AND_RODATA := 1 |
| 124 | |
| 125 | # Use Coherent memory |
| 126 | USE_COHERENT_MEM := 1 |
| 127 | |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 128 | # Platform build flags |
| 129 | # -------------------- |
| 130 | |
| 131 | # BL33 images are in AArch64 by default |
| 132 | RPI3_BL33_IN_AARCH32 := 0 |
| 133 | |
Antonio Nino Diaz | 76c944a | 2018-07-15 12:32:32 +0100 | [diff] [blame] | 134 | # Assume that BL33 isn't the Linux kernel by default |
| 135 | RPI3_DIRECT_LINUX_BOOT := 0 |
| 136 | |
Pete Batard | 6d5c61d | 2018-11-13 13:14:26 +0000 | [diff] [blame] | 137 | # UART to use at runtime. -1 means the runtime UART is disabled. |
| 138 | # Any other value means the default UART will be used. |
Pete Batard | 4dcf1fa | 2018-11-15 22:29:59 +0000 | [diff] [blame] | 139 | RPI3_RUNTIME_UART := -1 |
| 140 | |
| 141 | # Use normal memory mapping for ROM, FIP, SRAM and DRAM |
| 142 | RPI3_USE_UEFI_MAP := 0 |
Pete Batard | 6d5c61d | 2018-11-13 13:14:26 +0000 | [diff] [blame] | 143 | |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 144 | # BL32 location |
| 145 | RPI3_BL32_RAM_LOCATION := tdram |
| 146 | ifeq (${RPI3_BL32_RAM_LOCATION}, tsram) |
| 147 | RPI3_BL32_RAM_LOCATION_ID = SEC_SRAM_ID |
| 148 | else ifeq (${RPI3_BL32_RAM_LOCATION}, tdram) |
| 149 | RPI3_BL32_RAM_LOCATION_ID = SEC_DRAM_ID |
| 150 | else |
| 151 | $(error "Unsupported RPI3_BL32_RAM_LOCATION value") |
| 152 | endif |
| 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 Diaz | 76c944a | 2018-07-15 12:32:32 +0100 | [diff] [blame] | 159 | $(eval $(call add_define,RPI3_DIRECT_LINUX_BOOT)) |
Igor Opaniuk | eabbdaf | 2019-01-16 23:59:41 +0200 | [diff] [blame] | 160 | ifdef RPI3_PRELOADED_DTB_BASE |
Antonio Nino Diaz | 76c944a | 2018-07-15 12:32:32 +0100 | [diff] [blame] | 161 | $(eval $(call add_define,RPI3_PRELOADED_DTB_BASE)) |
Igor Opaniuk | eabbdaf | 2019-01-16 23:59:41 +0200 | [diff] [blame] | 162 | endif |
Pete Batard | 6d5c61d | 2018-11-13 13:14:26 +0000 | [diff] [blame] | 163 | $(eval $(call add_define,RPI3_RUNTIME_UART)) |
Pete Batard | 4dcf1fa | 2018-11-15 22:29:59 +0000 | [diff] [blame] | 164 | $(eval $(call add_define,RPI3_USE_UEFI_MAP)) |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 165 | |
| 166 | # Verify build config |
| 167 | # ------------------- |
Antonio Nino Diaz | 76c944a | 2018-07-15 12:32:32 +0100 | [diff] [blame] | 168 | # |
| 169 | ifneq (${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 |
| 173 | endif |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 174 | |
Antonio Nino Diaz | 98967fb | 2018-07-13 20:19:21 +0100 | [diff] [blame] | 175 | ifneq (${RESET_TO_BL31}, 0) |
| 176 | $(error Error: rpi3 needs RESET_TO_BL31=0) |
| 177 | endif |
| 178 | |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 179 | ifeq (${ARCH},aarch32) |
| 180 | $(error Error: AArch32 not supported on rpi3) |
| 181 | endif |
Ying-Chun Liu (PaulLiu) | 7812aba | 2018-06-10 02:00:27 +0800 | [diff] [blame] | 182 | |
Antonio Nino Diaz | 1aad932 | 2018-07-13 15:26:49 +0100 | [diff] [blame] | 183 | ifneq ($(ENABLE_STACK_PROTECTOR), 0) |
Andre Przywara | 990ab78 | 2019-07-09 14:29:24 +0100 | [diff] [blame] | 184 | PLAT_BL_COMMON_SOURCES += drivers/rpi3/rng/rpi3_rng.c \ |
Andre Przywara | 4f2b984 | 2019-07-09 14:32:11 +0100 | [diff] [blame] | 185 | plat/rpi/common/rpi3_stack_protector.c |
Antonio Nino Diaz | 1aad932 | 2018-07-13 15:26:49 +0100 | [diff] [blame] | 186 | endif |
| 187 | |
Ying-Chun Liu (PaulLiu) | 7812aba | 2018-06-10 02:00:27 +0800 | [diff] [blame] | 188 | ifeq (${SPD},opteed) |
| 189 | BL2_SOURCES += \ |
| 190 | lib/optee/optee_utils.c |
| 191 | endif |
| 192 | |
| 193 | # Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images |
| 194 | # in the FIP if the platform requires. |
| 195 | ifneq ($(BL32_EXTRA1),) |
| 196 | $(eval $(call TOOL_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1)) |
| 197 | endif |
| 198 | ifneq ($(BL32_EXTRA2),) |
| 199 | $(eval $(call TOOL_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2)) |
| 200 | endif |
Ying-Chun Liu (PaulLiu) | 1436849 | 2018-07-04 02:26:48 +0800 | [diff] [blame] | 201 | |
| 202 | ifneq (${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) | 1436849 | 2018-07-04 02:26:48 +0800 | [diff] [blame] | 207 | AUTH_SOURCES := drivers/auth/auth_mod.c \ |
| 208 | drivers/auth/crypto_mod.c \ |
| 209 | drivers/auth/img_parser_mod.c \ |
Manish V Badarkhe | ad43c49 | 2020-05-16 16:36:39 +0100 | [diff] [blame] | 210 | drivers/auth/tbbr/tbbr_cot_common.c |
Ying-Chun Liu (PaulLiu) | 1436849 | 2018-07-04 02:26:48 +0800 | [diff] [blame] | 211 | |
Ying-Chun Liu (PaulLiu) | 1436849 | 2018-07-04 02:26:48 +0800 | [diff] [blame] | 212 | BL1_SOURCES += ${AUTH_SOURCES} \ |
| 213 | bl1/tbbr/tbbr_img_desc.c \ |
| 214 | plat/common/tbbr/plat_tbbr.c \ |
Andre Przywara | 4f2b984 | 2019-07-09 14:32:11 +0100 | [diff] [blame] | 215 | plat/rpi/common/rpi3_trusted_boot.c \ |
Manish V Badarkhe | ad43c49 | 2020-05-16 16:36:39 +0100 | [diff] [blame] | 216 | plat/rpi/common/rpi3_rotpk.S \ |
| 217 | drivers/auth/tbbr/tbbr_cot_bl1.c |
Ying-Chun Liu (PaulLiu) | 1436849 | 2018-07-04 02:26:48 +0800 | [diff] [blame] | 218 | |
| 219 | BL2_SOURCES += ${AUTH_SOURCES} \ |
| 220 | plat/common/tbbr/plat_tbbr.c \ |
Andre Przywara | 4f2b984 | 2019-07-09 14:32:11 +0100 | [diff] [blame] | 221 | plat/rpi/common/rpi3_trusted_boot.c \ |
Manish V Badarkhe | ad43c49 | 2020-05-16 16:36:39 +0100 | [diff] [blame] | 222 | plat/rpi/common/rpi3_rotpk.S \ |
| 223 | drivers/auth/tbbr/tbbr_cot_bl2.c |
Ying-Chun Liu (PaulLiu) | 1436849 | 2018-07-04 02:26:48 +0800 | [diff] [blame] | 224 | |
| 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 Kay | 7a95759 | 2024-11-12 12:47:15 +0000 | [diff] [blame] | 235 | $(ROT_KEY): | $$(@D)/ |
Chris Kay | 7c4e1ee | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 236 | $(s)echo " OPENSSL $@" |
| 237 | $(q)${OPENSSL_BIN_PATH}/openssl genrsa 2048 > $@ 2>/dev/null |
Ying-Chun Liu (PaulLiu) | 1436849 | 2018-07-04 02:26:48 +0800 | [diff] [blame] | 238 | |
Chris Kay | 7a95759 | 2024-11-12 12:47:15 +0000 | [diff] [blame] | 239 | $(ROTPK_HASH): $(ROT_KEY) | $$(@D)/ |
Chris Kay | 7c4e1ee | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 240 | $(s)echo " OPENSSL $@" |
| 241 | $(q)${OPENSSL_BIN_PATH}/openssl rsa -in $< -pubout -outform DER 2>/dev/null |\ |
Salome Thirot | e95abc4 | 2022-07-14 16:14:15 +0100 | [diff] [blame] | 242 | ${OPENSSL_BIN_PATH}/openssl dgst -sha256 -binary > $@ 2>/dev/null |
Ying-Chun Liu (PaulLiu) | 1436849 | 2018-07-04 02:26:48 +0800 | [diff] [blame] | 243 | endif |