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