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