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