blob: 559f31634822b395d7863b7ee9cc5ce4daf8a96b [file] [log] [blame]
Antonio Nino Diazae6779e2017-11-06 14:49:04 +00001#
Antonio Nino Diaz1f470022018-03-27 09:39:47 +01002# Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
Antonio Nino Diazae6779e2017-11-06 14:49:04 +00003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
Antonio Nino Diazf96582a2018-10-19 00:57:16 +01007include lib/libfdt/libfdt.mk
8include lib/xlat_tables_v2/xlat_tables.mk
9
Antonio Nino Diazb3fc02c2018-12-17 17:49:35 +000010PLAT_INCLUDES := -Iplat/rpi3/include
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000011
Julius Werner6b88b652018-11-27 17:50:28 -080012PLAT_BL_COMMON_SOURCES := drivers/ti/uart/aarch64/16550_console.S \
Antonio Nino Diazf96582a2018-10-19 00:57:16 +010013 plat/rpi3/rpi3_common.c \
14 ${XLAT_TABLES_LIB_SRCS}
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000015
16BL1_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 Diazecf34712018-07-12 13:38:53 +010023 plat/rpi3/rpi3_io_storage.c \
24 plat/rpi3/rpi3_mbox.c
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000025
26BL2_SOURCES += common/desc_image_load.c \
27 drivers/io/io_fip.c \
28 drivers/io/io_memmap.c \
29 drivers/io/io_storage.c \
30 plat/common/aarch64/platform_mp_stack.S \
31 plat/rpi3/aarch64/plat_helpers.S \
32 plat/rpi3/aarch64/rpi3_bl2_mem_params_desc.c \
33 plat/rpi3/rpi3_bl2_setup.c \
34 plat/rpi3/rpi3_image_load.c \
35 plat/rpi3/rpi3_io_storage.c
36
37BL31_SOURCES += lib/cpus/aarch64/cortex_a53.S \
Antonio Nino Diaz83d8c792018-08-17 14:25:08 +010038 plat/common/plat_psci_common.c \
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000039 plat/rpi3/aarch64/plat_helpers.S \
40 plat/rpi3/rpi3_bl31_setup.c \
41 plat/rpi3/rpi3_pm.c \
Antonio Nino Diazf96582a2018-10-19 00:57:16 +010042 plat/rpi3/rpi3_topology.c \
43 ${LIBFDT_SRCS}
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000044
45# Tune compiler for Cortex-A53
46ifeq ($(notdir $(CC)),armclang)
47 TF_CFLAGS_aarch64 += -mcpu=cortex-a53
48else ifneq ($(findstring clang,$(notdir $(CC))),)
49 TF_CFLAGS_aarch64 += -mcpu=cortex-a53
50else
51 TF_CFLAGS_aarch64 += -mtune=cortex-a53
52endif
53
Antonio Nino Diazdfe895d2018-07-12 08:58:38 +010054# Platform Makefile target
55# ------------------------
56
57RPI3_BL1_PAD_BIN := ${BUILD_PLAT}/bl1_pad.bin
58RPI3_ARMSTUB8_BIN := ${BUILD_PLAT}/armstub8.bin
59
60# Add new default target when compiling this platform
61all: armstub
62
63# This target concatenates BL1 and the FIP so that the base addresses match the
64# ones defined in the memory map
65armstub: bl1 fip
66 @echo " CAT $@"
67 ${Q}cp ${BUILD_PLAT}/bl1.bin ${RPI3_BL1_PAD_BIN}
68 ${Q}truncate --size=131072 ${RPI3_BL1_PAD_BIN}
69 ${Q}cat ${RPI3_BL1_PAD_BIN} ${BUILD_PLAT}/fip.bin > ${RPI3_ARMSTUB8_BIN}
70 @${ECHO_BLANK_LINE}
71 @echo "Built $@ successfully"
72 @${ECHO_BLANK_LINE}
73
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000074# Build config flags
75# ------------------
76
77# Enable all errata workarounds for Cortex-A53
78ERRATA_A53_826319 := 1
79ERRATA_A53_835769 := 1
80ERRATA_A53_836870 := 1
81ERRATA_A53_843419 := 1
82ERRATA_A53_855873 := 1
83
Dimitris Papastamos8e5bd5e2018-01-24 16:41:14 +000084WORKAROUND_CVE_2017_5715 := 0
85
Antonio Nino Diaz4b7059d2018-07-13 15:26:49 +010086# Disable stack protector by default
87ENABLE_STACK_PROTECTOR := 0
88
Antonio Nino Diazdf0bb5a2018-07-13 20:19:21 +010089# Reset to BL31 isn't supported
90RESET_TO_BL31 := 0
Antonio Nino Diazae6779e2017-11-06 14:49:04 +000091
92# Have different sections for code and rodata
93SEPARATE_CODE_AND_RODATA := 1
94
95# Use Coherent memory
96USE_COHERENT_MEM := 1
97
Antonio Nino Diaz1f470022018-03-27 09:39:47 +010098# Use multi console API
99MULTI_CONSOLE_API := 1
100
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000101# Platform build flags
102# --------------------
103
104# BL33 images are in AArch64 by default
105RPI3_BL33_IN_AARCH32 := 0
106
Antonio Nino Diazf8b36cc2018-07-15 12:32:32 +0100107# Assume that BL33 isn't the Linux kernel by default
108RPI3_DIRECT_LINUX_BOOT := 0
109
Pete Batardc9acd6c2018-11-13 13:14:26 +0000110# UART to use at runtime. -1 means the runtime UART is disabled.
111# Any other value means the default UART will be used.
Pete Batardf820cad2018-11-15 22:29:59 +0000112RPI3_RUNTIME_UART := -1
113
114# Use normal memory mapping for ROM, FIP, SRAM and DRAM
115RPI3_USE_UEFI_MAP := 0
Pete Batardc9acd6c2018-11-13 13:14:26 +0000116
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000117# BL32 location
118RPI3_BL32_RAM_LOCATION := tdram
119ifeq (${RPI3_BL32_RAM_LOCATION}, tsram)
120 RPI3_BL32_RAM_LOCATION_ID = SEC_SRAM_ID
121else ifeq (${RPI3_BL32_RAM_LOCATION}, tdram)
122 RPI3_BL32_RAM_LOCATION_ID = SEC_DRAM_ID
123else
124 $(error "Unsupported RPI3_BL32_RAM_LOCATION value")
125endif
126
127# Process platform flags
128# ----------------------
129
130$(eval $(call add_define,RPI3_BL32_RAM_LOCATION_ID))
131$(eval $(call add_define,RPI3_BL33_IN_AARCH32))
Antonio Nino Diazf8b36cc2018-07-15 12:32:32 +0100132$(eval $(call add_define,RPI3_DIRECT_LINUX_BOOT))
133$(eval $(call add_define,RPI3_PRELOADED_DTB_BASE))
Pete Batardc9acd6c2018-11-13 13:14:26 +0000134$(eval $(call add_define,RPI3_RUNTIME_UART))
Pete Batardf820cad2018-11-15 22:29:59 +0000135$(eval $(call add_define,RPI3_USE_UEFI_MAP))
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000136
137# Verify build config
138# -------------------
Antonio Nino Diazf8b36cc2018-07-15 12:32:32 +0100139#
140ifneq (${RPI3_DIRECT_LINUX_BOOT}, 0)
141 ifndef RPI3_PRELOADED_DTB_BASE
142 $(error Error: RPI3_PRELOADED_DTB_BASE needed if RPI3_DIRECT_LINUX_BOOT=1)
143 endif
144endif
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000145
Antonio Nino Diaz1f470022018-03-27 09:39:47 +0100146ifneq (${MULTI_CONSOLE_API}, 1)
147 $(error Error: rpi3 needs MULTI_CONSOLE_API=1)
148endif
149
Antonio Nino Diazdf0bb5a2018-07-13 20:19:21 +0100150ifneq (${RESET_TO_BL31}, 0)
151 $(error Error: rpi3 needs RESET_TO_BL31=0)
152endif
153
Antonio Nino Diazae6779e2017-11-06 14:49:04 +0000154ifeq (${ARCH},aarch32)
155 $(error Error: AArch32 not supported on rpi3)
156endif
Ying-Chun Liu (PaulLiu)d9f76e62018-06-10 02:00:27 +0800157
Antonio Nino Diaz4b7059d2018-07-13 15:26:49 +0100158ifneq ($(ENABLE_STACK_PROTECTOR), 0)
159PLAT_BL_COMMON_SOURCES += plat/rpi3/rpi3_rng.c \
160 plat/rpi3/rpi3_stack_protector.c
161endif
162
Ying-Chun Liu (PaulLiu)d9f76e62018-06-10 02:00:27 +0800163ifeq (${SPD},opteed)
164BL2_SOURCES += \
165 lib/optee/optee_utils.c
166endif
167
168# Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images
169# in the FIP if the platform requires.
170ifneq ($(BL32_EXTRA1),)
171$(eval $(call TOOL_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1))
172endif
173ifneq ($(BL32_EXTRA2),)
174$(eval $(call TOOL_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2))
175endif
Ying-Chun Liu (PaulLiu)9128df62018-07-04 02:26:48 +0800176
177ifneq (${TRUSTED_BOARD_BOOT},0)
178
179 include drivers/auth/mbedtls/mbedtls_crypto.mk
180 include drivers/auth/mbedtls/mbedtls_x509.mk
181
Ying-Chun Liu (PaulLiu)9128df62018-07-04 02:26:48 +0800182 AUTH_SOURCES := drivers/auth/auth_mod.c \
183 drivers/auth/crypto_mod.c \
184 drivers/auth/img_parser_mod.c \
185 drivers/auth/tbbr/tbbr_cot.c
186
Ying-Chun Liu (PaulLiu)9128df62018-07-04 02:26:48 +0800187 BL1_SOURCES += ${AUTH_SOURCES} \
188 bl1/tbbr/tbbr_img_desc.c \
189 plat/common/tbbr/plat_tbbr.c \
190 plat/rpi3/rpi3_trusted_boot.c \
191 plat/rpi3/rpi3_rotpk.S
192
193 BL2_SOURCES += ${AUTH_SOURCES} \
194 plat/common/tbbr/plat_tbbr.c \
195 plat/rpi3/rpi3_trusted_boot.c \
196 plat/rpi3/rpi3_rotpk.S
197
198 ROT_KEY = $(BUILD_PLAT)/rot_key.pem
199 ROTPK_HASH = $(BUILD_PLAT)/rotpk_sha256.bin
200
201 $(eval $(call add_define_val,ROTPK_HASH,'"$(ROTPK_HASH)"'))
202
203 $(BUILD_PLAT)/bl1/rpi3_rotpk.o: $(ROTPK_HASH)
204 $(BUILD_PLAT)/bl2/rpi3_rotpk.o: $(ROTPK_HASH)
205
206 certificates: $(ROT_KEY)
207
208 $(ROT_KEY):
209 @echo " OPENSSL $@"
210 $(Q)openssl genrsa 2048 > $@ 2>/dev/null
211
212 $(ROTPK_HASH): $(ROT_KEY)
213 @echo " OPENSSL $@"
214 $(Q)openssl rsa -in $< -pubout -outform DER 2>/dev/null |\
215 openssl dgst -sha256 -binary > $@ 2>/dev/null
216endif