Antonio Nino Diaz | ae6779e | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 1 | # |
Chris Kay | 523e864 | 2023-12-04 12:03:51 +0000 | [diff] [blame] | 2 | # Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved. |
Antonio Nino Diaz | ae6779e | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | |
Antonio Nino Diaz | f96582a | 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 | 4ea3bd3 | 2019-07-09 14:32:11 +0100 | [diff] [blame] | 10 | PLAT_INCLUDES := -Iplat/rpi/common/include \ |
| 11 | -Iplat/rpi/rpi3/include |
Antonio Nino Diaz | ae6779e | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 12 | |
Julius Werner | 6b88b65 | 2018-11-27 17:50:28 -0800 | [diff] [blame] | 13 | PLAT_BL_COMMON_SOURCES := drivers/ti/uart/aarch64/16550_console.S \ |
Andre Przywara | 9ba6bb0 | 2020-03-10 12:34:56 +0000 | [diff] [blame] | 14 | drivers/arm/pl011/aarch64/pl011_console.S \ |
Andre Przywara | 9e4815a | 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 | 98e4856 | 2020-03-12 14:20:04 +0000 | [diff] [blame] | 18 | plat/rpi/common/aarch64/plat_helpers.S \ |
Andre Przywara | 4ea3bd3 | 2019-07-09 14:32:11 +0100 | [diff] [blame] | 19 | plat/rpi/common/rpi3_common.c \ |
Mario Bălănică | c258e4c | 2023-12-01 04:59:43 +0200 | [diff] [blame] | 20 | plat/rpi/common/rpi3_console_dual.c \ |
Antonio Nino Diaz | f96582a | 2018-10-19 00:57:16 +0100 | [diff] [blame] | 21 | ${XLAT_TABLES_LIB_SRCS} |
Antonio Nino Diaz | ae6779e | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 22 | |
| 23 | BL1_SOURCES += drivers/io/io_fip.c \ |
| 24 | drivers/io/io_memmap.c \ |
| 25 | drivers/io/io_storage.c \ |
| 26 | lib/cpus/aarch64/cortex_a53.S \ |
| 27 | plat/common/aarch64/platform_mp_stack.S \ |
Andre Przywara | b226246 | 2019-07-09 11:18:59 +0100 | [diff] [blame] | 28 | plat/rpi/rpi3/rpi3_bl1_setup.c \ |
Andre Przywara | 4ea3bd3 | 2019-07-09 14:32:11 +0100 | [diff] [blame] | 29 | plat/rpi/common/rpi3_io_storage.c \ |
Andre Przywara | 05862fc | 2019-07-09 13:54:56 +0100 | [diff] [blame] | 30 | drivers/rpi3/mailbox/rpi3_mbox.c \ |
| 31 | plat/rpi/rpi3/rpi_mbox_board.c |
Antonio Nino Diaz | ae6779e | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 32 | |
| 33 | BL2_SOURCES += common/desc_image_load.c \ |
| 34 | drivers/io/io_fip.c \ |
| 35 | drivers/io/io_memmap.c \ |
| 36 | drivers/io/io_storage.c \ |
Ying-Chun Liu (PaulLiu) | 3452738 | 2019-01-22 03:27:55 +0800 | [diff] [blame] | 37 | drivers/delay_timer/generic_delay_timer.c \ |
Ying-Chun Liu (PaulLiu) | de6f2f4 | 2019-01-30 04:20:38 +0800 | [diff] [blame] | 38 | drivers/io/io_block.c \ |
| 39 | drivers/mmc/mmc.c \ |
| 40 | drivers/rpi3/sdhost/rpi3_sdhost.c \ |
Antonio Nino Diaz | ae6779e | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 41 | plat/common/aarch64/platform_mp_stack.S \ |
Andre Przywara | b226246 | 2019-07-09 11:18:59 +0100 | [diff] [blame] | 42 | plat/rpi/rpi3/aarch64/rpi3_bl2_mem_params_desc.c \ |
| 43 | plat/rpi/rpi3/rpi3_bl2_setup.c \ |
Andre Przywara | 4ea3bd3 | 2019-07-09 14:32:11 +0100 | [diff] [blame] | 44 | plat/rpi/common/rpi3_image_load.c \ |
| 45 | plat/rpi/common/rpi3_io_storage.c |
Antonio Nino Diaz | ae6779e | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 46 | |
| 47 | BL31_SOURCES += lib/cpus/aarch64/cortex_a53.S \ |
Madhukar Pappireddy | 81e4687 | 2023-08-03 14:29:40 -0500 | [diff] [blame] | 48 | plat/common/plat_gicv2.c \ |
Antonio Nino Diaz | 83d8c79 | 2018-08-17 14:25:08 +0100 | [diff] [blame] | 49 | plat/common/plat_psci_common.c \ |
Andre Przywara | b226246 | 2019-07-09 11:18:59 +0100 | [diff] [blame] | 50 | plat/rpi/rpi3/rpi3_bl31_setup.c \ |
Andre Przywara | 4ea3bd3 | 2019-07-09 14:32:11 +0100 | [diff] [blame] | 51 | plat/rpi/common/rpi3_pm.c \ |
| 52 | plat/rpi/common/rpi3_topology.c \ |
Antonio Nino Diaz | f96582a | 2018-10-19 00:57:16 +0100 | [diff] [blame] | 53 | ${LIBFDT_SRCS} |
Antonio Nino Diaz | ae6779e | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 54 | |
| 55 | # Tune compiler for Cortex-A53 |
Chris Kay | cfba645 | 2023-12-04 09:55:50 +0000 | [diff] [blame] | 56 | ifeq ($($(ARCH)-cc-id),arm-clang) |
Antonio Nino Diaz | ae6779e | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 57 | TF_CFLAGS_aarch64 += -mcpu=cortex-a53 |
Chris Kay | cfba645 | 2023-12-04 09:55:50 +0000 | [diff] [blame] | 58 | else ifneq ($(filter %-clang,$($(ARCH)-cc-id)),) |
Antonio Nino Diaz | ae6779e | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 59 | TF_CFLAGS_aarch64 += -mcpu=cortex-a53 |
| 60 | else |
| 61 | TF_CFLAGS_aarch64 += -mtune=cortex-a53 |
| 62 | endif |
| 63 | |
Antonio Nino Diaz | dfe895d | 2018-07-12 08:58:38 +0100 | [diff] [blame] | 64 | # Platform Makefile target |
| 65 | # ------------------------ |
| 66 | |
| 67 | RPI3_BL1_PAD_BIN := ${BUILD_PLAT}/bl1_pad.bin |
| 68 | RPI3_ARMSTUB8_BIN := ${BUILD_PLAT}/armstub8.bin |
| 69 | |
| 70 | # Add new default target when compiling this platform |
| 71 | all: armstub |
| 72 | |
| 73 | # This target concatenates BL1 and the FIP so that the base addresses match the |
| 74 | # ones defined in the memory map |
| 75 | armstub: bl1 fip |
| 76 | @echo " CAT $@" |
| 77 | ${Q}cp ${BUILD_PLAT}/bl1.bin ${RPI3_BL1_PAD_BIN} |
| 78 | ${Q}truncate --size=131072 ${RPI3_BL1_PAD_BIN} |
| 79 | ${Q}cat ${RPI3_BL1_PAD_BIN} ${BUILD_PLAT}/fip.bin > ${RPI3_ARMSTUB8_BIN} |
| 80 | @${ECHO_BLANK_LINE} |
| 81 | @echo "Built $@ successfully" |
| 82 | @${ECHO_BLANK_LINE} |
| 83 | |
Antonio Nino Diaz | ae6779e | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 84 | # Build config flags |
| 85 | # ------------------ |
| 86 | |
| 87 | # Enable all errata workarounds for Cortex-A53 |
| 88 | ERRATA_A53_826319 := 1 |
| 89 | ERRATA_A53_835769 := 1 |
| 90 | ERRATA_A53_836870 := 1 |
| 91 | ERRATA_A53_843419 := 1 |
| 92 | ERRATA_A53_855873 := 1 |
| 93 | |
Dimitris Papastamos | 8e5bd5e | 2018-01-24 16:41:14 +0000 | [diff] [blame] | 94 | WORKAROUND_CVE_2017_5715 := 0 |
| 95 | |
Antonio Nino Diaz | 4b7059d | 2018-07-13 15:26:49 +0100 | [diff] [blame] | 96 | # Disable stack protector by default |
| 97 | ENABLE_STACK_PROTECTOR := 0 |
| 98 | |
Antonio Nino Diaz | df0bb5a | 2018-07-13 20:19:21 +0100 | [diff] [blame] | 99 | # Reset to BL31 isn't supported |
| 100 | RESET_TO_BL31 := 0 |
Antonio Nino Diaz | ae6779e | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 101 | |
| 102 | # Have different sections for code and rodata |
| 103 | SEPARATE_CODE_AND_RODATA := 1 |
| 104 | |
| 105 | # Use Coherent memory |
| 106 | USE_COHERENT_MEM := 1 |
| 107 | |
Antonio Nino Diaz | ae6779e | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 108 | # Platform build flags |
| 109 | # -------------------- |
| 110 | |
| 111 | # BL33 images are in AArch64 by default |
| 112 | RPI3_BL33_IN_AARCH32 := 0 |
| 113 | |
Antonio Nino Diaz | f8b36cc | 2018-07-15 12:32:32 +0100 | [diff] [blame] | 114 | # Assume that BL33 isn't the Linux kernel by default |
| 115 | RPI3_DIRECT_LINUX_BOOT := 0 |
| 116 | |
Pete Batard | c9acd6c | 2018-11-13 13:14:26 +0000 | [diff] [blame] | 117 | # UART to use at runtime. -1 means the runtime UART is disabled. |
| 118 | # Any other value means the default UART will be used. |
Pete Batard | f820cad | 2018-11-15 22:29:59 +0000 | [diff] [blame] | 119 | RPI3_RUNTIME_UART := -1 |
| 120 | |
| 121 | # Use normal memory mapping for ROM, FIP, SRAM and DRAM |
| 122 | RPI3_USE_UEFI_MAP := 0 |
Pete Batard | c9acd6c | 2018-11-13 13:14:26 +0000 | [diff] [blame] | 123 | |
Antonio Nino Diaz | ae6779e | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 124 | # BL32 location |
| 125 | RPI3_BL32_RAM_LOCATION := tdram |
| 126 | ifeq (${RPI3_BL32_RAM_LOCATION}, tsram) |
| 127 | RPI3_BL32_RAM_LOCATION_ID = SEC_SRAM_ID |
| 128 | else ifeq (${RPI3_BL32_RAM_LOCATION}, tdram) |
| 129 | RPI3_BL32_RAM_LOCATION_ID = SEC_DRAM_ID |
| 130 | else |
| 131 | $(error "Unsupported RPI3_BL32_RAM_LOCATION value") |
| 132 | endif |
| 133 | |
| 134 | # Process platform flags |
| 135 | # ---------------------- |
| 136 | |
| 137 | $(eval $(call add_define,RPI3_BL32_RAM_LOCATION_ID)) |
| 138 | $(eval $(call add_define,RPI3_BL33_IN_AARCH32)) |
Antonio Nino Diaz | f8b36cc | 2018-07-15 12:32:32 +0100 | [diff] [blame] | 139 | $(eval $(call add_define,RPI3_DIRECT_LINUX_BOOT)) |
Igor Opaniuk | 02016b2 | 2019-01-16 23:59:41 +0200 | [diff] [blame] | 140 | ifdef RPI3_PRELOADED_DTB_BASE |
Antonio Nino Diaz | f8b36cc | 2018-07-15 12:32:32 +0100 | [diff] [blame] | 141 | $(eval $(call add_define,RPI3_PRELOADED_DTB_BASE)) |
Igor Opaniuk | 02016b2 | 2019-01-16 23:59:41 +0200 | [diff] [blame] | 142 | endif |
Pete Batard | c9acd6c | 2018-11-13 13:14:26 +0000 | [diff] [blame] | 143 | $(eval $(call add_define,RPI3_RUNTIME_UART)) |
Pete Batard | f820cad | 2018-11-15 22:29:59 +0000 | [diff] [blame] | 144 | $(eval $(call add_define,RPI3_USE_UEFI_MAP)) |
Antonio Nino Diaz | ae6779e | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 145 | |
| 146 | # Verify build config |
| 147 | # ------------------- |
Antonio Nino Diaz | f8b36cc | 2018-07-15 12:32:32 +0100 | [diff] [blame] | 148 | # |
| 149 | ifneq (${RPI3_DIRECT_LINUX_BOOT}, 0) |
| 150 | ifndef RPI3_PRELOADED_DTB_BASE |
| 151 | $(error Error: RPI3_PRELOADED_DTB_BASE needed if RPI3_DIRECT_LINUX_BOOT=1) |
| 152 | endif |
| 153 | endif |
Antonio Nino Diaz | ae6779e | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 154 | |
Antonio Nino Diaz | df0bb5a | 2018-07-13 20:19:21 +0100 | [diff] [blame] | 155 | ifneq (${RESET_TO_BL31}, 0) |
| 156 | $(error Error: rpi3 needs RESET_TO_BL31=0) |
| 157 | endif |
| 158 | |
Antonio Nino Diaz | ae6779e | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 159 | ifeq (${ARCH},aarch32) |
| 160 | $(error Error: AArch32 not supported on rpi3) |
| 161 | endif |
Ying-Chun Liu (PaulLiu) | d9f76e6 | 2018-06-10 02:00:27 +0800 | [diff] [blame] | 162 | |
Antonio Nino Diaz | 4b7059d | 2018-07-13 15:26:49 +0100 | [diff] [blame] | 163 | ifneq ($(ENABLE_STACK_PROTECTOR), 0) |
Andre Przywara | 93de78c | 2019-07-09 14:29:24 +0100 | [diff] [blame] | 164 | PLAT_BL_COMMON_SOURCES += drivers/rpi3/rng/rpi3_rng.c \ |
Andre Przywara | 4ea3bd3 | 2019-07-09 14:32:11 +0100 | [diff] [blame] | 165 | plat/rpi/common/rpi3_stack_protector.c |
Antonio Nino Diaz | 4b7059d | 2018-07-13 15:26:49 +0100 | [diff] [blame] | 166 | endif |
| 167 | |
Ying-Chun Liu (PaulLiu) | d9f76e6 | 2018-06-10 02:00:27 +0800 | [diff] [blame] | 168 | ifeq (${SPD},opteed) |
| 169 | BL2_SOURCES += \ |
| 170 | lib/optee/optee_utils.c |
| 171 | endif |
| 172 | |
| 173 | # Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images |
| 174 | # in the FIP if the platform requires. |
| 175 | ifneq ($(BL32_EXTRA1),) |
| 176 | $(eval $(call TOOL_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1)) |
| 177 | endif |
| 178 | ifneq ($(BL32_EXTRA2),) |
| 179 | $(eval $(call TOOL_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2)) |
| 180 | endif |
Ying-Chun Liu (PaulLiu) | 9128df6 | 2018-07-04 02:26:48 +0800 | [diff] [blame] | 181 | |
| 182 | ifneq (${TRUSTED_BOARD_BOOT},0) |
| 183 | |
| 184 | include drivers/auth/mbedtls/mbedtls_crypto.mk |
| 185 | include drivers/auth/mbedtls/mbedtls_x509.mk |
| 186 | |
Ying-Chun Liu (PaulLiu) | 9128df6 | 2018-07-04 02:26:48 +0800 | [diff] [blame] | 187 | AUTH_SOURCES := drivers/auth/auth_mod.c \ |
| 188 | drivers/auth/crypto_mod.c \ |
| 189 | drivers/auth/img_parser_mod.c \ |
Manish V Badarkhe | 043fd62 | 2020-05-16 16:36:39 +0100 | [diff] [blame] | 190 | drivers/auth/tbbr/tbbr_cot_common.c |
Ying-Chun Liu (PaulLiu) | 9128df6 | 2018-07-04 02:26:48 +0800 | [diff] [blame] | 191 | |
Ying-Chun Liu (PaulLiu) | 9128df6 | 2018-07-04 02:26:48 +0800 | [diff] [blame] | 192 | BL1_SOURCES += ${AUTH_SOURCES} \ |
| 193 | bl1/tbbr/tbbr_img_desc.c \ |
| 194 | plat/common/tbbr/plat_tbbr.c \ |
Andre Przywara | 4ea3bd3 | 2019-07-09 14:32:11 +0100 | [diff] [blame] | 195 | plat/rpi/common/rpi3_trusted_boot.c \ |
Manish V Badarkhe | 043fd62 | 2020-05-16 16:36:39 +0100 | [diff] [blame] | 196 | plat/rpi/common/rpi3_rotpk.S \ |
| 197 | drivers/auth/tbbr/tbbr_cot_bl1.c |
Ying-Chun Liu (PaulLiu) | 9128df6 | 2018-07-04 02:26:48 +0800 | [diff] [blame] | 198 | |
| 199 | BL2_SOURCES += ${AUTH_SOURCES} \ |
| 200 | plat/common/tbbr/plat_tbbr.c \ |
Andre Przywara | 4ea3bd3 | 2019-07-09 14:32:11 +0100 | [diff] [blame] | 201 | plat/rpi/common/rpi3_trusted_boot.c \ |
Manish V Badarkhe | 043fd62 | 2020-05-16 16:36:39 +0100 | [diff] [blame] | 202 | plat/rpi/common/rpi3_rotpk.S \ |
| 203 | drivers/auth/tbbr/tbbr_cot_bl2.c |
Ying-Chun Liu (PaulLiu) | 9128df6 | 2018-07-04 02:26:48 +0800 | [diff] [blame] | 204 | |
| 205 | ROT_KEY = $(BUILD_PLAT)/rot_key.pem |
| 206 | ROTPK_HASH = $(BUILD_PLAT)/rotpk_sha256.bin |
| 207 | |
| 208 | $(eval $(call add_define_val,ROTPK_HASH,'"$(ROTPK_HASH)"')) |
| 209 | |
| 210 | $(BUILD_PLAT)/bl1/rpi3_rotpk.o: $(ROTPK_HASH) |
| 211 | $(BUILD_PLAT)/bl2/rpi3_rotpk.o: $(ROTPK_HASH) |
| 212 | |
| 213 | certificates: $(ROT_KEY) |
| 214 | |
Manish V Badarkhe | d8c877f | 2020-09-03 16:54:47 +0100 | [diff] [blame] | 215 | $(ROT_KEY): | $(BUILD_PLAT) |
Ying-Chun Liu (PaulLiu) | 9128df6 | 2018-07-04 02:26:48 +0800 | [diff] [blame] | 216 | @echo " OPENSSL $@" |
Salome Thirot | 0b35da3 | 2022-07-14 16:14:15 +0100 | [diff] [blame] | 217 | $(Q)${OPENSSL_BIN_PATH}/openssl genrsa 2048 > $@ 2>/dev/null |
Ying-Chun Liu (PaulLiu) | 9128df6 | 2018-07-04 02:26:48 +0800 | [diff] [blame] | 218 | |
| 219 | $(ROTPK_HASH): $(ROT_KEY) |
| 220 | @echo " OPENSSL $@" |
Salome Thirot | 0b35da3 | 2022-07-14 16:14:15 +0100 | [diff] [blame] | 221 | $(Q)${OPENSSL_BIN_PATH}/openssl rsa -in $< -pubout -outform DER 2>/dev/null |\ |
| 222 | ${OPENSSL_BIN_PATH}/openssl dgst -sha256 -binary > $@ 2>/dev/null |
Ying-Chun Liu (PaulLiu) | 9128df6 | 2018-07-04 02:26:48 +0800 | [diff] [blame] | 223 | endif |