1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
#
# Copyright (c) 2015-2026, Arm Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
# Extra partitions used to find FIP, contains:
# metadata (2) and the FIP partitions (default is 2).
STM32_EXTRA_PARTS := 4
ifeq (${STM32MP_PSA_FWU_AB_SUPPORT},1)
# u-boot-env, bootfs-a, bootfs-b, vendorfs, rootfs-a and rootfs-b
STM32_EXTRA_PARTS := $(shell expr $(STM32_EXTRA_PARTS) + 6)
endif
include plat/st/common/common.mk
ARM_CORTEX_A7 := yes
USE_COHERENT_MEM := 0
# Default Device tree
DTB_FILE_NAME ?= stm32mp157c-ev1.dtb
STM32MP13 ?= 0
STM32MP15 ?= 0
STM32MP1X := 1
# Disable STM32MP2 flags
STM32MP21 := 0
STM32MP23 := 0
STM32MP25 := 0
STM32MP2X := 0
STM32MP_DDR_FIP_IO_STORAGE := 0
ifeq ($(STM32MP13),1)
ifeq ($(STM32MP15),1)
$(error Cannot enable both flags STM32MP13 and STM32MP15)
endif
STM32MP13 := 1
STM32MP15 := 0
else ifeq ($(STM32MP15),1)
STM32MP13 := 0
STM32MP15 := 1
else ifneq ($(findstring stm32mp13,$(DTB_FILE_NAME)),)
STM32MP13 := 1
STM32MP15 := 0
else ifneq ($(findstring stm32mp15,$(DTB_FILE_NAME)),)
STM32MP13 := 0
STM32MP15 := 1
endif
STM32MP_STPMIC1L ?= 0
ifeq ($(STM32MP13),1)
# Will use SRAM2 as mbedtls heap
STM32MP_USE_EXTERNAL_HEAP := 1
# DDR controller with single AXI port and 16-bit interface
STM32MP_DDR_DUAL_AXI_PORT:= 0
STM32MP_DDR_32BIT_INTERFACE:= 0
ifeq (${TRUSTED_BOARD_BOOT},1)
# PKA algo to include
PKA_USE_NIST_P256 := 1
PKA_USE_BRAINPOOL_P256T1:= 1
endif
# STM32 image header version v2.0
STM32_HEADER_VERSION_MAJOR:= 2
STM32_HEADER_VERSION_MINOR:= 0
endif
ifeq ($(STM32MP15),1)
# DDR controller with dual AXI port and 32-bit interface
STM32MP_DDR_DUAL_AXI_PORT:= 1
STM32MP_DDR_32BIT_INTERFACE:= 1
# STM32 image header version v1.0
STM32_HEADER_VERSION_MAJOR:= 1
STM32_HEADER_VERSION_MINOR:= 0
STM32MP_CRYPTO_ROM_LIB := 1
# Decryption support
ifneq ($(DECRYPTION_SUPPORT),none)
$(error "DECRYPTION_SUPPORT not supported on STM32MP15")
endif
endif
PKA_USE_NIST_P256 ?= 0
PKA_USE_NIST_P521 ?= 0
PKA_USE_BRAINPOOL_P256R1 ?= 0
PKA_USE_BRAINPOOL_P256T1 ?= 0
# Disable Neon support: runtime may conflict with non-secure world
TF_CFLAGS += -mfloat-abi=soft
# Not needed for Cortex-A7
WORKAROUND_CVE_2017_5715:= 0
WORKAROUND_CVE_2022_23960:= 0
ifeq ($(STM32MP13),1)
STM32_HASH_VER := 4
STM32_RNG_VER := 4
STM32_RNG_VER_MINOR := 2
else # Assuming STM32MP15
STM32_HASH_VER := 2
STM32_RNG_VER := 2
STM32_RNG_VER_MINOR := 1
endif
# Download load address for serial boot devices
DWL_BUFFER_BASE ?= 0xC7000000
# Device tree
ifeq ($(STM32MP13),1)
BL2_DTSI := stm32mp13-bl2.dtsi
FDT_SOURCES := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl2.dts,$(DTB_FILE_NAME)))
else
BL2_DTSI := stm32mp15-bl2.dtsi
FDT_SOURCES := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl2.dts,$(DTB_FILE_NAME)))
ifeq ($(AARCH32_SP),sp_min)
BL32_DTSI := stm32mp15-bl32.dtsi
FDT_SOURCES += $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl32.dts,$(DTB_FILE_NAME)))
endif
endif
sp_dts_name = $(patsubst %.dts,%$(if $(and \
$(wildcard $(patsubst %.dts,fdts/%-sp_min.dts,$(notdir $(1)))), \
$(filter-out %-sp_min.dts,$(notdir $(1))) \
),-sp_min).dts,$(notdir $(1)))
# Macros and rules to build TF binary
STM32_TF_STM32 := $(addprefix ${BUILD_PLAT}/tf-a-, $(patsubst %.dtb,%.stm32,$(DTB_FILE_NAME)))
STM32_LD_FILE := plat/st/stm32mp1/stm32mp1.ld.S
STM32_BINARY_MAPPING := plat/st/stm32mp1/stm32mp1.S
ifeq ($(AARCH32_SP),sp_min)
# BL32 is built only if using SP_MIN
BL32_DEP := bl32
ASFLAGS += -DBL32_BIN_PATH=\"${BUILD_PLAT}/bl32.bin\"
endif
STM32MP_FW_CONFIG_NAME := $(patsubst %.dtb,%-fw-config.dtb,$(DTB_FILE_NAME))
STM32MP_FW_CONFIG := ${BUILD_PLAT}/fdts/$(STM32MP_FW_CONFIG_NAME)
ifneq (${AARCH32_SP},none)
FDT_SOURCES += $(addprefix fdts/, $(patsubst %.dtb,%.dts,$(STM32MP_FW_CONFIG_NAME)))
endif
# Add the FW_CONFIG to FIP and specify the same to certtool
$(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_FW_CONFIG},--fw-config))
ifeq ($(GENERATE_COT),1)
STM32MP_CFG_CERT := $(BUILD_PLAT)/stm32mp_cfg_cert.crt
# Add the STM32MP_CFG_CERT to FIP and specify the same to certtool
$(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_CFG_CERT},--stm32mp-cfg-cert))
endif
ifeq ($(AARCH32_SP),sp_min)
STM32MP_TOS_FW_CONFIG := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl32.dtb,$(DTB_FILE_NAME)))
$(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_TOS_FW_CONFIG},--tos-fw-config))
endif
# Enable flags for C files
$(call assert_booleans,\
$(sort \
PKA_USE_BRAINPOOL_P256R1 \
PKA_USE_BRAINPOOL_P256T1 \
PKA_USE_NIST_P256 \
PKA_USE_NIST_P521 \
STM32MP_CRYPTO_ROM_LIB \
STM32MP_DDR_32BIT_INTERFACE \
STM32MP_DDR_DUAL_AXI_PORT \
STM32MP_DDR_FIP_IO_STORAGE \
STM32MP_STPMIC1L \
STM32MP_USE_EXTERNAL_HEAP \
STM32MP13 \
STM32MP15 \
STM32MP1X \
STM32MP21 \
STM32MP23 \
STM32MP25 \
STM32MP2X \
))
$(call assert_numerics,\
$(sort \
PLAT_PARTITION_MAX_ENTRIES \
STM32_HASH_VER \
STM32_HEADER_VERSION_MAJOR \
STM32_RNG_VER \
STM32_RNG_VER_MINOR \
STM32_TF_A_COPIES \
))
$(call add_defines,\
$(sort \
DWL_BUFFER_BASE \
PKA_USE_BRAINPOOL_P256R1 \
PKA_USE_BRAINPOOL_P256T1 \
PKA_USE_NIST_P256 \
PKA_USE_NIST_P521 \
PLAT_PARTITION_MAX_ENTRIES \
PLAT_TBBR_IMG_DEF \
STM32_HASH_VER \
STM32_HEADER_VERSION_MAJOR \
STM32_RNG_VER \
STM32_RNG_VER_MINOR \
STM32_TF_A_COPIES \
STM32MP_CRYPTO_ROM_LIB \
STM32MP_DDR_32BIT_INTERFACE \
STM32MP_DDR_DUAL_AXI_PORT \
STM32MP_DDR_FIP_IO_STORAGE \
STM32MP_STPMIC1L \
STM32MP_USE_EXTERNAL_HEAP \
STM32MP13 \
STM32MP15 \
STM32MP1X \
STM32MP21 \
STM32MP23 \
STM32MP25 \
STM32MP2X \
))
# Include paths and source files
PLAT_INCLUDES += -Iplat/st/stm32mp1/include/
PLAT_BL_COMMON_SOURCES += plat/st/stm32mp1/stm32mp1_private.c
PLAT_BL_COMMON_SOURCES += drivers/st/uart/aarch32/stm32_console.S
ifneq (${ENABLE_STACK_PROTECTOR},0)
PLAT_BL_COMMON_SOURCES += plat/st/stm32mp1/stm32mp1_stack_protector.c
endif
PLAT_BL_COMMON_SOURCES += lib/cpus/aarch32/cortex_a7.S
PLAT_BL_COMMON_SOURCES += drivers/arm/tzc/tzc400.c \
drivers/st/bsec/bsec2.c \
drivers/st/ddr/stm32mp1_ddr_helpers.c \
drivers/st/i2c/stm32_i2c.c \
drivers/st/iwdg/stm32_iwdg.c \
drivers/st/reset/stm32mp1_reset.c \
plat/st/stm32mp1/stm32mp1_dbgmcu.c \
plat/st/stm32mp1/stm32mp1_helper.S \
plat/st/stm32mp1/stm32mp1_syscfg.c
ifeq ($(STM32MP_STPMIC1L),1)
PLAT_BL_COMMON_SOURCES += drivers/st/pmic/stm32mp_pmic2.c \
drivers/st/pmic/stpmic2.c
else
PLAT_BL_COMMON_SOURCES += drivers/st/pmic/stm32mp_pmic.c \
drivers/st/pmic/stpmic1.c
endif
ifeq ($(STM32MP13),1)
PLAT_BL_COMMON_SOURCES += drivers/st/clk/clk-stm32-core.c \
drivers/st/clk/clk-stm32mp13.c \
drivers/st/crypto/stm32_rng.c
else
PLAT_BL_COMMON_SOURCES += drivers/st/clk/stm32mp1_clk.c
endif
BL2_SOURCES += plat/st/stm32mp1/plat_bl2_mem_params_desc.c \
plat/st/stm32mp1/stm32mp1_fconf_firewall.c
BL2_SOURCES += drivers/st/crypto/stm32_hash.c \
plat/st/stm32mp1/bl2_plat_setup.c
ifeq ($(STM32MP13),1)
BL2_SOURCES += drivers/st/mce/stm32_mce.c
endif
ifeq (${TRUSTED_BOARD_BOOT},1)
ifeq ($(STM32MP13),1)
BL2_SOURCES += drivers/st/crypto/stm32_pka.c
BL2_SOURCES += drivers/st/crypto/stm32_saes.c
endif
endif
ifneq ($(filter 1,${STM32MP_EMMC} ${STM32MP_SDMMC}),)
BL2_SOURCES += drivers/st/mmc/stm32_sdmmc2.c
endif
ifeq (${STM32MP_RAW_NAND},1)
BL2_SOURCES += drivers/st/fmc/stm32_fmc2_nand.c
endif
ifneq ($(filter 1,${STM32MP_SPI_NAND} ${STM32MP_SPI_NOR}),)
BL2_SOURCES += drivers/st/spi/stm32_qspi.c
endif
ifneq ($(filter 1,${STM32MP_RAW_NAND} ${STM32MP_SPI_NAND} ${STM32MP_SPI_NOR}),)
BL2_SOURCES += plat/st/stm32mp1/stm32mp1_boot_device.c
endif
ifeq (${STM32MP_UART_PROGRAMMER},1)
BL2_SOURCES += drivers/st/uart/stm32_uart.c
endif
ifeq (${STM32MP_USB_PROGRAMMER},1)
#The DFU stack uses only one end point, reduce the USB stack footprint
$(eval $(call add_define_val,CONFIG_USBD_EP_NB,1U))
BL2_SOURCES += drivers/st/usb/stm32mp1_usb.c \
plat/st/stm32mp1/stm32mp1_usb_dfu.c
endif
BL2_SOURCES += drivers/st/ddr/stm32mp1_ddr.c \
drivers/st/ddr/stm32mp1_ram.c
BL2_SOURCES += plat/st/stm32mp1/plat_ddr.c
ifeq ($(AARCH32_SP),sp_min)
# Create DTB file for BL32
${BUILD_PLAT}/fdts/%-bl32.dts: fdts/%.dts fdts/${BL32_DTSI} | $$(@D)/
$(q)echo '#include "$(call sp_dts_name,$(patsubst fdts/%,%,$<))"' > $@
$(q)echo '#include "${BL32_DTSI}"' >> $@
${BUILD_PLAT}/fdts/%-bl32.dtb: ${BUILD_PLAT}/fdts/%-bl32.dts | $$(@D)/
endif
include plat/st/common/common_rules.mk
|