1#
2# Copyright (c) 2015-2022, ARM Limited and Contributors. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
7ARM_CORTEX_A7		:=	yes
8ARM_WITH_NEON		:=	yes
9BL2_AT_EL3		:=	1
10USE_COHERENT_MEM	:=	0
11
12STM32MP_EARLY_CONSOLE	?=	0
13STM32MP_RECONFIGURE_CONSOLE ?=	0
14STM32MP_UART_BAUDRATE	?=	115200
15
16TRUSTED_BOARD_BOOT	?=	0
17STM32MP_USE_EXTERNAL_HEAP ?=	0
18
19# Use secure library from the ROM code for authentication
20STM32MP_CRYPTO_ROM_LIB	?=	0
21
22# Please don't increment this value without good understanding of
23# the monotonic counter
24STM32_TF_VERSION	?=	0
25
26# Enable dynamic memory mapping
27PLAT_XLAT_TABLES_DYNAMIC :=	1
28
29# Default Device tree
30DTB_FILE_NAME		?=	stm32mp157c-ev1.dtb
31
32STM32MP13		?=	0
33STM32MP15		?=	0
34
35ifeq ($(STM32MP13),1)
36ifeq ($(STM32MP15),1)
37$(error Cannot enable both flags STM32MP13 and STM32MP15)
38endif
39STM32MP13		:=	1
40STM32MP15		:=	0
41else ifeq ($(STM32MP15),1)
42STM32MP13		:=	0
43STM32MP15		:=	1
44else ifneq ($(findstring stm32mp13,$(DTB_FILE_NAME)),)
45STM32MP13		:=	1
46STM32MP15		:=	0
47else ifneq ($(findstring stm32mp15,$(DTB_FILE_NAME)),)
48STM32MP13		:=	0
49STM32MP15		:=	1
50endif
51
52ifeq ($(STM32MP13),1)
53# Will use SRAM2 as mbedtls heap
54STM32MP_USE_EXTERNAL_HEAP :=	1
55
56# DDR controller with single AXI port and 16-bit interface
57STM32MP_DDR_DUAL_AXI_PORT:=	0
58STM32MP_DDR_32BIT_INTERFACE:=	0
59
60ifeq (${TRUSTED_BOARD_BOOT},1)
61# PKA algo to include
62PKA_USE_NIST_P256	:=	1
63PKA_USE_BRAINPOOL_P256T1:=	1
64endif
65
66# STM32 image header version v2.0
67STM32_HEADER_VERSION_MAJOR:=	2
68STM32_HEADER_VERSION_MINOR:=	0
69endif
70
71ifeq ($(STM32MP15),1)
72# DDR controller with dual AXI port and 32-bit interface
73STM32MP_DDR_DUAL_AXI_PORT:=	1
74STM32MP_DDR_32BIT_INTERFACE:=	1
75
76# STM32 image header version v1.0
77STM32_HEADER_VERSION_MAJOR:=	1
78STM32_HEADER_VERSION_MINOR:=	0
79
80# Add OP-TEE reserved shared memory area in mapping
81STM32MP15_OPTEE_RSV_SHM	:=	1
82$(eval $(call add_defines,STM32MP15_OPTEE_RSV_SHM))
83
84STM32MP_CRYPTO_ROM_LIB :=	1
85
86# Decryption support
87ifneq ($(DECRYPTION_SUPPORT),none)
88$(error "DECRYPTION_SUPPORT not supported on STM32MP15")
89endif
90endif
91
92# STM32 image header binary type for BL2
93STM32_HEADER_BL2_BINARY_TYPE:=	0x10
94
95ifeq ($(AARCH32_SP),sp_min)
96# Disable Neon support: sp_min runtime may conflict with non-secure world
97TF_CFLAGS		+=	-mfloat-abi=soft
98endif
99
100TF_CFLAGS		+=	-Wsign-compare
101TF_CFLAGS		+=	-Wformat-signedness
102
103# Not needed for Cortex-A7
104WORKAROUND_CVE_2017_5715:=	0
105WORKAROUND_CVE_2022_23960:=	0
106
107# Number of TF-A copies in the device
108STM32_TF_A_COPIES		:=	2
109
110# PLAT_PARTITION_MAX_ENTRIES must take care of STM32_TF-A_COPIES and other partitions
111# such as metadata (2) to find all the FIP partitions (default is 2).
112PLAT_PARTITION_MAX_ENTRIES	:=	$(shell echo $$(($(STM32_TF_A_COPIES) + 4)))
113
114ifeq (${PSA_FWU_SUPPORT},1)
115# Number of banks of updatable firmware
116NR_OF_FW_BANKS			:=	2
117NR_OF_IMAGES_IN_FW_BANK		:=	1
118
119FWU_MAX_PART = $(shell echo $$(($(STM32_TF_A_COPIES) + 2 + $(NR_OF_FW_BANKS))))
120ifeq ($(shell test $(FWU_MAX_PART) -gt $(PLAT_PARTITION_MAX_ENTRIES); echo $$?),0)
121$(error "Required partition number is $(FWU_MAX_PART) where PLAT_PARTITION_MAX_ENTRIES is only \
122$(PLAT_PARTITION_MAX_ENTRIES)")
123endif
124endif
125
126ifeq ($(STM32MP13),1)
127STM32_HASH_VER		:=	4
128STM32_RNG_VER		:=	4
129else # Assuming STM32MP15
130STM32_HASH_VER		:=	2
131STM32_RNG_VER		:=	2
132endif
133
134# Boot devices
135STM32MP_EMMC		?=	0
136STM32MP_SDMMC		?=	0
137STM32MP_RAW_NAND	?=	0
138STM32MP_SPI_NAND	?=	0
139STM32MP_SPI_NOR		?=	0
140STM32MP_EMMC_BOOT	?=	0
141
142# Serial boot devices
143STM32MP_USB_PROGRAMMER	?=	0
144STM32MP_UART_PROGRAMMER	?=	0
145
146# Download load address for serial boot devices
147DWL_BUFFER_BASE 	?=	0xC7000000
148
149# Device tree
150ifeq ($(STM32MP13),1)
151BL2_DTSI		:=	stm32mp13-bl2.dtsi
152FDT_SOURCES		:=	$(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl2.dts,$(DTB_FILE_NAME)))
153else
154BL2_DTSI		:=	stm32mp15-bl2.dtsi
155FDT_SOURCES		:=	$(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl2.dts,$(DTB_FILE_NAME)))
156ifeq ($(AARCH32_SP),sp_min)
157BL32_DTSI		:=	stm32mp15-bl32.dtsi
158FDT_SOURCES		+=	$(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl32.dts,$(DTB_FILE_NAME)))
159endif
160endif
161
162$(eval DTC_V = $(shell $(DTC) -v | awk '{print $$NF}'))
163$(eval DTC_VERSION = $(shell printf "%d" $(shell echo ${DTC_V} | cut -d- -f1 | sed "s/\./0/g" | grep -o "[0-9]*")))
164DTC_CPPFLAGS		+=	${INCLUDES}
165DTC_FLAGS		+=	-Wno-unit_address_vs_reg
166ifeq ($(shell test $(DTC_VERSION) -ge 10601; echo $$?),0)
167DTC_FLAGS		+=	-Wno-interrupt_provider
168endif
169
170# Macros and rules to build TF binary
171STM32_TF_ELF_LDFLAGS	:=	--hash-style=gnu --as-needed
172STM32_TF_STM32		:=	$(addprefix ${BUILD_PLAT}/tf-a-, $(patsubst %.dtb,%.stm32,$(DTB_FILE_NAME)))
173STM32_TF_LINKERFILE	:=	${BUILD_PLAT}/stm32mp1.ld
174
175ASFLAGS			+= -DBL2_BIN_PATH=\"${BUILD_PLAT}/bl2.bin\"
176ifeq ($(AARCH32_SP),sp_min)
177# BL32 is built only if using SP_MIN
178BL32_DEP		:= bl32
179ASFLAGS			+= -DBL32_BIN_PATH=\"${BUILD_PLAT}/bl32.bin\"
180endif
181
182# Variables for use with stm32image
183STM32IMAGEPATH		?= tools/stm32image
184STM32IMAGE		?= ${STM32IMAGEPATH}/stm32image${BIN_EXT}
185STM32IMAGE_SRC		:= ${STM32IMAGEPATH}/stm32image.c
186
187FIP_DEPS		+=	dtbs
188STM32MP_HW_CONFIG	:=	${BL33_CFG}
189STM32MP_FW_CONFIG_NAME	:=	$(patsubst %.dtb,%-fw-config.dtb,$(DTB_FILE_NAME))
190STM32MP_FW_CONFIG	:=	${BUILD_PLAT}/fdts/$(STM32MP_FW_CONFIG_NAME)
191ifneq (${AARCH32_SP},none)
192FDT_SOURCES		+=	$(addprefix fdts/, $(patsubst %.dtb,%.dts,$(STM32MP_FW_CONFIG_NAME)))
193endif
194# Add the FW_CONFIG to FIP and specify the same to certtool
195$(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_FW_CONFIG},--fw-config))
196# Add the HW_CONFIG to FIP and specify the same to certtool
197$(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_HW_CONFIG},--hw-config))
198ifeq ($(GENERATE_COT),1)
199STM32MP_CFG_CERT	:=	$(BUILD_PLAT)/stm32mp_cfg_cert.crt
200# Add the STM32MP_CFG_CERT to FIP and specify the same to certtool
201$(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_CFG_CERT},--stm32mp-cfg-cert))
202endif
203ifeq ($(AARCH32_SP),sp_min)
204STM32MP_TOS_FW_CONFIG	:= $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl32.dtb,$(DTB_FILE_NAME)))
205$(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_TOS_FW_CONFIG},--tos-fw-config))
206else
207# Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images
208# in the FIP if the platform requires.
209ifneq ($(BL32_EXTRA1),)
210$(eval $(call TOOL_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1,,$(ENCRYPT_BL32)))
211endif
212ifneq ($(BL32_EXTRA2),)
213$(eval $(call TOOL_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2,,$(ENCRYPT_BL32)))
214endif
215endif
216
217# Enable flags for C files
218$(eval $(call assert_booleans,\
219	$(sort \
220		PKA_USE_BRAINPOOL_P256T1 \
221		PKA_USE_NIST_P256 \
222		PLAT_TBBR_IMG_DEF \
223		PLAT_XLAT_TABLES_DYNAMIC \
224		STM32MP_CRYPTO_ROM_LIB \
225		STM32MP_DDR_32BIT_INTERFACE \
226		STM32MP_DDR_DUAL_AXI_PORT \
227		STM32MP_EARLY_CONSOLE \
228		STM32MP_EMMC \
229		STM32MP_EMMC_BOOT \
230		STM32MP_RAW_NAND \
231		STM32MP_RECONFIGURE_CONSOLE \
232		STM32MP_SDMMC \
233		STM32MP_SPI_NAND \
234		STM32MP_SPI_NOR \
235		STM32MP_UART_PROGRAMMER \
236		STM32MP_USB_PROGRAMMER \
237		STM32MP_USE_EXTERNAL_HEAP \
238		STM32MP13 \
239		STM32MP15 \
240)))
241
242$(eval $(call assert_numerics,\
243	$(sort \
244		PLAT_PARTITION_MAX_ENTRIES \
245		STM32_HASH_VER \
246		STM32_HEADER_VERSION_MAJOR \
247		STM32_RNG_VER \
248		STM32_TF_A_COPIES \
249		STM32_TF_VERSION \
250		STM32MP_UART_BAUDRATE \
251)))
252
253$(eval $(call add_defines,\
254	$(sort \
255		DWL_BUFFER_BASE \
256		PKA_USE_BRAINPOOL_P256T1 \
257		PKA_USE_NIST_P256 \
258		PLAT_PARTITION_MAX_ENTRIES \
259		PLAT_TBBR_IMG_DEF \
260		PLAT_XLAT_TABLES_DYNAMIC \
261		STM32_HASH_VER \
262		STM32_HEADER_VERSION_MAJOR \
263		STM32_RNG_VER \
264		STM32_TF_A_COPIES \
265		STM32_TF_VERSION \
266		STM32MP_CRYPTO_ROM_LIB \
267		STM32MP_DDR_32BIT_INTERFACE \
268		STM32MP_DDR_DUAL_AXI_PORT \
269		STM32MP_EARLY_CONSOLE \
270		STM32MP_EMMC \
271		STM32MP_EMMC_BOOT \
272		STM32MP_RAW_NAND \
273		STM32MP_RECONFIGURE_CONSOLE \
274		STM32MP_SDMMC \
275		STM32MP_SPI_NAND \
276		STM32MP_SPI_NOR \
277		STM32MP_UART_BAUDRATE \
278		STM32MP_UART_PROGRAMMER \
279		STM32MP_USB_PROGRAMMER \
280		STM32MP_USE_EXTERNAL_HEAP \
281		STM32MP13 \
282		STM32MP15 \
283)))
284
285# Include paths and source files
286PLAT_INCLUDES		:=	-Iplat/st/common/include/
287PLAT_INCLUDES		+=	-Iplat/st/stm32mp1/include/
288
289include lib/fconf/fconf.mk
290include lib/libfdt/libfdt.mk
291
292PLAT_BL_COMMON_SOURCES	:=	common/uuid.c						\
293				plat/st/common/stm32mp_common.c				\
294				plat/st/stm32mp1/stm32mp1_private.c
295
296PLAT_BL_COMMON_SOURCES	+=	drivers/st/uart/aarch32/stm32_console.S
297
298ifneq (${ENABLE_STACK_PROTECTOR},0)
299PLAT_BL_COMMON_SOURCES	+=	plat/st/stm32mp1/stm32mp1_stack_protector.c
300endif
301
302include lib/xlat_tables_v2/xlat_tables.mk
303PLAT_BL_COMMON_SOURCES	+=	${XLAT_TABLES_LIB_SRCS}
304
305PLAT_BL_COMMON_SOURCES	+=	lib/cpus/aarch32/cortex_a7.S
306
307PLAT_BL_COMMON_SOURCES	+=	drivers/arm/tzc/tzc400.c				\
308				drivers/clk/clk.c					\
309				drivers/delay_timer/delay_timer.c			\
310				drivers/delay_timer/generic_delay_timer.c		\
311				drivers/st/bsec/bsec2.c					\
312				drivers/st/clk/stm32mp_clkfunc.c			\
313				drivers/st/ddr/stm32mp_ddr.c				\
314				drivers/st/ddr/stm32mp1_ddr_helpers.c			\
315				drivers/st/gpio/stm32_gpio.c				\
316				drivers/st/i2c/stm32_i2c.c				\
317				drivers/st/iwdg/stm32_iwdg.c				\
318				drivers/st/pmic/stm32mp_pmic.c				\
319				drivers/st/pmic/stpmic1.c				\
320				drivers/st/regulator/regulator_core.c			\
321				drivers/st/regulator/regulator_fixed.c			\
322				drivers/st/reset/stm32mp1_reset.c			\
323				plat/st/common/stm32mp_dt.c				\
324				plat/st/stm32mp1/stm32mp1_dbgmcu.c			\
325				plat/st/stm32mp1/stm32mp1_helper.S			\
326				plat/st/stm32mp1/stm32mp1_syscfg.c
327
328ifeq ($(STM32MP13),1)
329PLAT_BL_COMMON_SOURCES	+=	drivers/st/clk/clk-stm32-core.c				\
330				drivers/st/clk/clk-stm32mp13.c				\
331				drivers/st/crypto/stm32_rng.c
332else
333PLAT_BL_COMMON_SOURCES	+=	drivers/st/clk/stm32mp1_clk.c
334endif
335
336BL2_SOURCES		+=	${FCONF_SOURCES} ${FCONF_DYN_SOURCES}
337
338BL2_SOURCES		+=	drivers/io/io_fip.c					\
339				plat/st/common/bl2_io_storage.c				\
340				plat/st/common/stm32mp_fconf_io.c			\
341				plat/st/stm32mp1/plat_bl2_mem_params_desc.c		\
342				plat/st/stm32mp1/stm32mp1_fconf_firewall.c
343
344include lib/zlib/zlib.mk
345
346ifeq (${PSA_FWU_SUPPORT},1)
347include drivers/fwu/fwu.mk
348endif
349
350
351BL2_SOURCES		+=	$(ZLIB_SOURCES)
352
353BL2_SOURCES		+=	drivers/io/io_block.c					\
354				drivers/io/io_mtd.c					\
355				drivers/io/io_storage.c					\
356				drivers/st/crypto/stm32_hash.c				\
357				plat/st/stm32mp1/bl2_plat_setup.c
358
359ifneq (${DECRYPTION_SUPPORT},none)
360BL2_SOURCES		+=	drivers/io/io_encrypted.c
361endif
362
363ifeq (${TRUSTED_BOARD_BOOT},1)
364AUTH_SOURCES		:=	drivers/auth/auth_mod.c					\
365				drivers/auth/crypto_mod.c				\
366				drivers/auth/img_parser_mod.c
367
368ifeq (${GENERATE_COT},1)
369TFW_NVCTR_VAL		:=	0
370NTFW_NVCTR_VAL		:=	0
371KEY_SIZE		:=
372KEY_ALG			:=	ecdsa
373HASH_ALG		:=	sha256
374
375ifeq (${SAVE_KEYS},1)
376TRUSTED_WORLD_KEY	?=	${BUILD_PLAT}/trusted.pem
377NON_TRUSTED_WORLD_KEY	?=	${BUILD_PLAT}/non-trusted.pem
378BL32_KEY		?=	${BUILD_PLAT}/trusted_os.pem
379BL33_KEY		?=	${BUILD_PLAT}/non-trusted_os.pem
380endif
381
382endif
383TF_MBEDTLS_KEY_ALG 	:=	ecdsa
384MBEDTLS_CONFIG_FILE	?=	"<stm32mp1_mbedtls_config.h>"
385
386include drivers/auth/mbedtls/mbedtls_x509.mk
387
388COT_DESC_IN_DTB		:=	1
389AUTH_SOURCES		+=	lib/fconf/fconf_cot_getter.c				\
390				lib/fconf/fconf_tbbr_getter.c				\
391				plat/st/common/stm32mp_crypto_lib.c
392
393ifeq ($(STM32MP13),1)
394AUTH_SOURCES		+=	drivers/st/crypto/stm32_pka.c
395AUTH_SOURCES		+=	drivers/st/crypto/stm32_saes.c
396endif
397
398BL2_SOURCES		+=	$(AUTH_SOURCES)						\
399				plat/st/common/stm32mp_trusted_boot.c
400endif
401
402ifneq ($(filter 1,${STM32MP_EMMC} ${STM32MP_SDMMC}),)
403BL2_SOURCES		+=	drivers/mmc/mmc.c					\
404				drivers/partition/gpt.c					\
405				drivers/partition/partition.c				\
406				drivers/st/io/io_mmc.c					\
407				drivers/st/mmc/stm32_sdmmc2.c
408endif
409
410ifeq (${STM32MP_RAW_NAND},1)
411$(eval $(call add_define_val,NAND_ONFI_DETECT,1))
412BL2_SOURCES		+=	drivers/mtd/nand/raw_nand.c				\
413				drivers/st/fmc/stm32_fmc2_nand.c
414endif
415
416ifeq (${STM32MP_SPI_NAND},1)
417BL2_SOURCES		+=	drivers/mtd/nand/spi_nand.c
418endif
419
420ifeq (${STM32MP_SPI_NOR},1)
421ifneq (${STM32MP_FORCE_MTD_START_OFFSET},)
422$(eval $(call add_define_val,STM32MP_NOR_FIP_OFFSET,${STM32MP_FORCE_MTD_START_OFFSET}))
423endif
424BL2_SOURCES		+=	drivers/mtd/nor/spi_nor.c
425endif
426
427ifneq ($(filter 1,${STM32MP_SPI_NAND} ${STM32MP_SPI_NOR}),)
428BL2_SOURCES		+=	drivers/mtd/spi-mem/spi_mem.c				\
429				drivers/st/spi/stm32_qspi.c
430endif
431
432ifneq ($(filter 1,${STM32MP_RAW_NAND} ${STM32MP_SPI_NAND}),)
433ifneq (${STM32MP_FORCE_MTD_START_OFFSET},)
434$(eval $(call add_define_val,STM32MP_NAND_FIP_OFFSET,${STM32MP_FORCE_MTD_START_OFFSET}))
435endif
436BL2_SOURCES		+=	drivers/mtd/nand/core.c
437endif
438
439ifneq ($(filter 1,${STM32MP_RAW_NAND} ${STM32MP_SPI_NAND} ${STM32MP_SPI_NOR}),)
440BL2_SOURCES		+=	plat/st/stm32mp1/stm32mp1_boot_device.c
441endif
442
443ifneq ($(filter 1,${STM32MP_UART_PROGRAMMER} ${STM32MP_USB_PROGRAMMER}),)
444BL2_SOURCES		+=	drivers/io/io_memmap.c
445endif
446
447ifeq (${STM32MP_UART_PROGRAMMER},1)
448BL2_SOURCES		+=	drivers/st/uart/stm32_uart.c				\
449				plat/st/common/stm32cubeprogrammer_uart.c
450endif
451
452ifeq (${STM32MP_USB_PROGRAMMER},1)
453#The DFU stack uses only one end point, reduce the USB stack footprint
454$(eval $(call add_define_val,CONFIG_USBD_EP_NB,1U))
455BL2_SOURCES		+=	drivers/st/usb/stm32mp1_usb.c				\
456				drivers/usb/usb_device.c				\
457				plat/st/common/stm32cubeprogrammer_usb.c		\
458				plat/st/common/usb_dfu.c					\
459				plat/st/stm32mp1/stm32mp1_usb_dfu.c
460endif
461
462BL2_SOURCES		+=	drivers/st/ddr/stm32mp_ddr_test.c			\
463				drivers/st/ddr/stm32mp_ram.c				\
464				drivers/st/ddr/stm32mp1_ddr.c				\
465				drivers/st/ddr/stm32mp1_ram.c
466
467BL2_SOURCES		+=	common/desc_image_load.c				\
468				plat/st/stm32mp1/plat_image_load.c
469
470BL2_SOURCES		+=	lib/optee/optee_utils.c
471
472# Compilation rules
473.PHONY: check_dtc_version stm32image clean_stm32image check_boot_device
474.SUFFIXES:
475
476all: check_dtc_version stm32image ${STM32_TF_STM32}
477
478distclean realclean clean: clean_stm32image
479
480bl2: check_boot_device
481
482check_boot_device:
483	@if [ ${STM32MP_EMMC} != 1 ] && \
484	    [ ${STM32MP_SDMMC} != 1 ] && \
485	    [ ${STM32MP_RAW_NAND} != 1 ] && \
486	    [ ${STM32MP_SPI_NAND} != 1 ] && \
487	    [ ${STM32MP_SPI_NOR} != 1 ] && \
488	    [ ${STM32MP_UART_PROGRAMMER} != 1 ] && \
489	    [ ${STM32MP_USB_PROGRAMMER} != 1 ]; then \
490		echo "No boot device driver is enabled"; \
491		false; \
492	fi
493
494stm32image: ${STM32IMAGE}
495
496${STM32IMAGE}: ${STM32IMAGE_SRC}
497	${Q}${MAKE} CPPFLAGS="" --no-print-directory -C ${STM32IMAGEPATH}
498
499clean_stm32image:
500	${Q}${MAKE} --no-print-directory -C ${STM32IMAGEPATH} clean
501
502check_dtc_version:
503	@if [ ${DTC_VERSION} -lt 10404 ]; then \
504		echo "dtc version too old (${DTC_V}), you need at least version 1.4.4"; \
505		false; \
506	fi
507
508# Create DTB file for BL2
509${BUILD_PLAT}/fdts/%-bl2.dts: fdts/%.dts fdts/${BL2_DTSI} | ${BUILD_PLAT} fdt_dirs
510	@echo '#include "$(patsubst fdts/%,%,$<)"' > $@
511	@echo '#include "${BL2_DTSI}"' >> $@
512
513${BUILD_PLAT}/fdts/%-bl2.dtb: ${BUILD_PLAT}/fdts/%-bl2.dts
514
515ifeq ($(AARCH32_SP),sp_min)
516# Create DTB file for BL32
517${BUILD_PLAT}/fdts/%-bl32.dts: fdts/%.dts fdts/${BL32_DTSI} | ${BUILD_PLAT} fdt_dirs
518	@echo '#include "$(patsubst fdts/%,%,$<)"' > $@
519	@echo '#include "${BL32_DTSI}"' >> $@
520
521${BUILD_PLAT}/fdts/%-bl32.dtb: ${BUILD_PLAT}/fdts/%-bl32.dts
522endif
523
524${BUILD_PLAT}/stm32mp1-%.o: ${BUILD_PLAT}/fdts/%-bl2.dtb plat/st/stm32mp1/stm32mp1.S bl2
525	@echo "  AS      stm32mp1.S"
526	${Q}${AS} ${ASFLAGS} ${TF_CFLAGS} \
527		-DDTB_BIN_PATH=\"$<\" \
528		-c plat/st/stm32mp1/stm32mp1.S -o $@
529
530$(eval $(call MAKE_LD,${STM32_TF_LINKERFILE},plat/st/stm32mp1/stm32mp1.ld.S,bl2))
531
532tf-a-%.elf: stm32mp1-%.o ${STM32_TF_LINKERFILE}
533	@echo "  LDS     $<"
534	${Q}${LD} -o $@ ${STM32_TF_ELF_LDFLAGS} -Map=$(@:.elf=.map) --script ${STM32_TF_LINKERFILE} $<
535
536tf-a-%.bin: tf-a-%.elf
537	${Q}${OC} -O binary $< $@
538	@echo
539	@echo "Built $@ successfully"
540	@echo
541
542tf-a-%.stm32: ${STM32IMAGE} tf-a-%.bin
543	@echo
544	@echo "Generate $@"
545	$(eval LOADADDR = $(shell cat $(@:.stm32=.map) | grep RAM | awk '{print $$2}'))
546	$(eval ENTRY = $(shell cat $(@:.stm32=.map) | grep "__BL2_IMAGE_START" | awk '{print $$1}'))
547	${Q}${STM32IMAGE} -s $(word 2,$^) -d $@ \
548		-l $(LOADADDR) -e ${ENTRY} \
549		-v ${STM32_TF_VERSION} \
550		-m ${STM32_HEADER_VERSION_MAJOR} \
551		-n ${STM32_HEADER_VERSION_MINOR} \
552		-b ${STM32_HEADER_BL2_BINARY_TYPE}
553	@echo
554