Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 1 | # |
Antonio Nino Diaz | e0f21f6 | 2018-03-27 09:39:47 +0100 | [diff] [blame] | 2 | # Copyright (c) 2013-2018, 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 | |
Antonio Nino Diaz | 8e7b27a | 2018-12-17 17:49:35 +0000 | [diff] [blame] | 10 | PLAT_INCLUDES := -Iplat/rpi3/include |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 11 | |
Julius Werner | 985ee0b | 2018-11-27 17:50:28 -0800 | [diff] [blame] | 12 | PLAT_BL_COMMON_SOURCES := drivers/ti/uart/aarch64/16550_console.S \ |
Antonio Nino Diaz | 5341b42 | 2018-10-19 00:57:16 +0100 | [diff] [blame] | 13 | plat/rpi3/rpi3_common.c \ |
| 14 | ${XLAT_TABLES_LIB_SRCS} |
Antonio Nino Diaz | d83c1db | 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 | 4f2f66a | 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 | d83c1db | 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) | 2be86dd | 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 \ |
Ying-Chun Liu (PaulLiu) | 968377f | 2019-01-30 04:20:38 +0800 | [diff] [blame] | 34 | drivers/io/io_block.c \ |
| 35 | drivers/mmc/mmc.c \ |
| 36 | drivers/rpi3/sdhost/rpi3_sdhost.c \ |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 37 | plat/common/aarch64/platform_mp_stack.S \ |
| 38 | plat/rpi3/aarch64/plat_helpers.S \ |
| 39 | plat/rpi3/aarch64/rpi3_bl2_mem_params_desc.c \ |
| 40 | plat/rpi3/rpi3_bl2_setup.c \ |
| 41 | plat/rpi3/rpi3_image_load.c \ |
| 42 | plat/rpi3/rpi3_io_storage.c |
| 43 | |
| 44 | BL31_SOURCES += lib/cpus/aarch64/cortex_a53.S \ |
Antonio Nino Diaz | 941a624 | 2018-08-17 14:25:08 +0100 | [diff] [blame] | 45 | plat/common/plat_psci_common.c \ |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 46 | plat/rpi3/aarch64/plat_helpers.S \ |
| 47 | plat/rpi3/rpi3_bl31_setup.c \ |
| 48 | plat/rpi3/rpi3_pm.c \ |
Antonio Nino Diaz | 5341b42 | 2018-10-19 00:57:16 +0100 | [diff] [blame] | 49 | plat/rpi3/rpi3_topology.c \ |
| 50 | ${LIBFDT_SRCS} |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 51 | |
| 52 | # Tune compiler for Cortex-A53 |
| 53 | ifeq ($(notdir $(CC)),armclang) |
| 54 | TF_CFLAGS_aarch64 += -mcpu=cortex-a53 |
| 55 | else ifneq ($(findstring clang,$(notdir $(CC))),) |
| 56 | TF_CFLAGS_aarch64 += -mcpu=cortex-a53 |
| 57 | else |
| 58 | TF_CFLAGS_aarch64 += -mtune=cortex-a53 |
| 59 | endif |
| 60 | |
Antonio Nino Diaz | 64fe343 | 2018-07-12 08:58:38 +0100 | [diff] [blame] | 61 | # Platform Makefile target |
| 62 | # ------------------------ |
| 63 | |
| 64 | RPI3_BL1_PAD_BIN := ${BUILD_PLAT}/bl1_pad.bin |
| 65 | RPI3_ARMSTUB8_BIN := ${BUILD_PLAT}/armstub8.bin |
| 66 | |
| 67 | # Add new default target when compiling this platform |
| 68 | all: armstub |
| 69 | |
| 70 | # This target concatenates BL1 and the FIP so that the base addresses match the |
| 71 | # ones defined in the memory map |
| 72 | armstub: bl1 fip |
| 73 | @echo " CAT $@" |
| 74 | ${Q}cp ${BUILD_PLAT}/bl1.bin ${RPI3_BL1_PAD_BIN} |
| 75 | ${Q}truncate --size=131072 ${RPI3_BL1_PAD_BIN} |
| 76 | ${Q}cat ${RPI3_BL1_PAD_BIN} ${BUILD_PLAT}/fip.bin > ${RPI3_ARMSTUB8_BIN} |
| 77 | @${ECHO_BLANK_LINE} |
| 78 | @echo "Built $@ successfully" |
| 79 | @${ECHO_BLANK_LINE} |
| 80 | |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 81 | # Build config flags |
| 82 | # ------------------ |
| 83 | |
| 84 | # Enable all errata workarounds for Cortex-A53 |
| 85 | ERRATA_A53_826319 := 1 |
| 86 | ERRATA_A53_835769 := 1 |
| 87 | ERRATA_A53_836870 := 1 |
| 88 | ERRATA_A53_843419 := 1 |
| 89 | ERRATA_A53_855873 := 1 |
| 90 | |
Dimitris Papastamos | 383c808 | 2018-01-24 16:41:14 +0000 | [diff] [blame] | 91 | WORKAROUND_CVE_2017_5715 := 0 |
| 92 | |
Antonio Nino Diaz | 1aad932 | 2018-07-13 15:26:49 +0100 | [diff] [blame] | 93 | # Disable stack protector by default |
| 94 | ENABLE_STACK_PROTECTOR := 0 |
| 95 | |
Antonio Nino Diaz | 98967fb | 2018-07-13 20:19:21 +0100 | [diff] [blame] | 96 | # Reset to BL31 isn't supported |
| 97 | RESET_TO_BL31 := 0 |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 98 | |
| 99 | # Have different sections for code and rodata |
| 100 | SEPARATE_CODE_AND_RODATA := 1 |
| 101 | |
| 102 | # Use Coherent memory |
| 103 | USE_COHERENT_MEM := 1 |
| 104 | |
Antonio Nino Diaz | e0f21f6 | 2018-03-27 09:39:47 +0100 | [diff] [blame] | 105 | # Use multi console API |
| 106 | MULTI_CONSOLE_API := 1 |
| 107 | |
Antonio Nino Diaz | d83c1db | 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 | 76c944a | 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 | 6d5c61d | 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 | 4dcf1fa | 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 | 6d5c61d | 2018-11-13 13:14:26 +0000 | [diff] [blame] | 123 | |
Antonio Nino Diaz | d83c1db | 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 | 76c944a | 2018-07-15 12:32:32 +0100 | [diff] [blame] | 139 | $(eval $(call add_define,RPI3_DIRECT_LINUX_BOOT)) |
Igor Opaniuk | eabbdaf | 2019-01-16 23:59:41 +0200 | [diff] [blame] | 140 | ifdef RPI3_PRELOADED_DTB_BASE |
Antonio Nino Diaz | 76c944a | 2018-07-15 12:32:32 +0100 | [diff] [blame] | 141 | $(eval $(call add_define,RPI3_PRELOADED_DTB_BASE)) |
Igor Opaniuk | eabbdaf | 2019-01-16 23:59:41 +0200 | [diff] [blame] | 142 | endif |
Pete Batard | 6d5c61d | 2018-11-13 13:14:26 +0000 | [diff] [blame] | 143 | $(eval $(call add_define,RPI3_RUNTIME_UART)) |
Pete Batard | 4dcf1fa | 2018-11-15 22:29:59 +0000 | [diff] [blame] | 144 | $(eval $(call add_define,RPI3_USE_UEFI_MAP)) |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 145 | |
| 146 | # Verify build config |
| 147 | # ------------------- |
Antonio Nino Diaz | 76c944a | 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 | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 154 | |
Antonio Nino Diaz | e0f21f6 | 2018-03-27 09:39:47 +0100 | [diff] [blame] | 155 | ifneq (${MULTI_CONSOLE_API}, 1) |
| 156 | $(error Error: rpi3 needs MULTI_CONSOLE_API=1) |
| 157 | endif |
| 158 | |
Antonio Nino Diaz | 98967fb | 2018-07-13 20:19:21 +0100 | [diff] [blame] | 159 | ifneq (${RESET_TO_BL31}, 0) |
| 160 | $(error Error: rpi3 needs RESET_TO_BL31=0) |
| 161 | endif |
| 162 | |
Antonio Nino Diaz | d83c1db | 2017-11-06 14:49:04 +0000 | [diff] [blame] | 163 | ifeq (${ARCH},aarch32) |
| 164 | $(error Error: AArch32 not supported on rpi3) |
| 165 | endif |
Ying-Chun Liu (PaulLiu) | 7812aba | 2018-06-10 02:00:27 +0800 | [diff] [blame] | 166 | |
Antonio Nino Diaz | 1aad932 | 2018-07-13 15:26:49 +0100 | [diff] [blame] | 167 | ifneq ($(ENABLE_STACK_PROTECTOR), 0) |
| 168 | PLAT_BL_COMMON_SOURCES += plat/rpi3/rpi3_rng.c \ |
| 169 | plat/rpi3/rpi3_stack_protector.c |
| 170 | endif |
| 171 | |
Ying-Chun Liu (PaulLiu) | 7812aba | 2018-06-10 02:00:27 +0800 | [diff] [blame] | 172 | ifeq (${SPD},opteed) |
| 173 | BL2_SOURCES += \ |
| 174 | lib/optee/optee_utils.c |
| 175 | endif |
| 176 | |
| 177 | # Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images |
| 178 | # in the FIP if the platform requires. |
| 179 | ifneq ($(BL32_EXTRA1),) |
| 180 | $(eval $(call TOOL_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1)) |
| 181 | endif |
| 182 | ifneq ($(BL32_EXTRA2),) |
| 183 | $(eval $(call TOOL_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2)) |
| 184 | endif |
Ying-Chun Liu (PaulLiu) | 1436849 | 2018-07-04 02:26:48 +0800 | [diff] [blame] | 185 | |
| 186 | ifneq (${TRUSTED_BOARD_BOOT},0) |
| 187 | |
| 188 | include drivers/auth/mbedtls/mbedtls_crypto.mk |
| 189 | include drivers/auth/mbedtls/mbedtls_x509.mk |
| 190 | |
Ying-Chun Liu (PaulLiu) | 1436849 | 2018-07-04 02:26:48 +0800 | [diff] [blame] | 191 | AUTH_SOURCES := drivers/auth/auth_mod.c \ |
| 192 | drivers/auth/crypto_mod.c \ |
| 193 | drivers/auth/img_parser_mod.c \ |
| 194 | drivers/auth/tbbr/tbbr_cot.c |
| 195 | |
Ying-Chun Liu (PaulLiu) | 1436849 | 2018-07-04 02:26:48 +0800 | [diff] [blame] | 196 | BL1_SOURCES += ${AUTH_SOURCES} \ |
| 197 | bl1/tbbr/tbbr_img_desc.c \ |
| 198 | plat/common/tbbr/plat_tbbr.c \ |
| 199 | plat/rpi3/rpi3_trusted_boot.c \ |
| 200 | plat/rpi3/rpi3_rotpk.S |
| 201 | |
| 202 | BL2_SOURCES += ${AUTH_SOURCES} \ |
| 203 | plat/common/tbbr/plat_tbbr.c \ |
| 204 | plat/rpi3/rpi3_trusted_boot.c \ |
| 205 | plat/rpi3/rpi3_rotpk.S |
| 206 | |
| 207 | ROT_KEY = $(BUILD_PLAT)/rot_key.pem |
| 208 | ROTPK_HASH = $(BUILD_PLAT)/rotpk_sha256.bin |
| 209 | |
| 210 | $(eval $(call add_define_val,ROTPK_HASH,'"$(ROTPK_HASH)"')) |
| 211 | |
| 212 | $(BUILD_PLAT)/bl1/rpi3_rotpk.o: $(ROTPK_HASH) |
| 213 | $(BUILD_PLAT)/bl2/rpi3_rotpk.o: $(ROTPK_HASH) |
| 214 | |
| 215 | certificates: $(ROT_KEY) |
| 216 | |
| 217 | $(ROT_KEY): |
| 218 | @echo " OPENSSL $@" |
| 219 | $(Q)openssl genrsa 2048 > $@ 2>/dev/null |
| 220 | |
| 221 | $(ROTPK_HASH): $(ROT_KEY) |
| 222 | @echo " OPENSSL $@" |
| 223 | $(Q)openssl rsa -in $< -pubout -outform DER 2>/dev/null |\ |
| 224 | openssl dgst -sha256 -binary > $@ 2>/dev/null |
| 225 | endif |