blob: a999e8c128e64440b98a6eb456a06c28906d24a8 [file] [log] [blame]
Yann Gautier4b0c72a2018-07-16 10:54:09 +02001#
Yann Gautier6d8c2442020-09-17 12:42:46 +02002# Copyright (c) 2015-2022, ARM Limited and Contributors. All rights reserved.
Yann Gautier4b0c72a2018-07-16 10:54:09 +02003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
7ARM_CORTEX_A7 := yes
8ARM_WITH_NEON := yes
Yann Gautier4b0c72a2018-07-16 10:54:09 +02009BL2_AT_EL3 := 1
Yann Gautier4b0c72a2018-07-16 10:54:09 +020010USE_COHERENT_MEM := 0
11
Yann Gautier0ed7b2a2021-05-19 18:48:16 +020012# Allow TF-A to concatenate BL2 & BL32 binaries in a single file,
13# share DTB file between BL2 and BL32
14# If it is set to 0, then FIP is used
15STM32MP_USE_STM32IMAGE ?= 0
16
17ifneq ($(STM32MP_USE_STM32IMAGE),1)
Yann Gautierdca61542021-02-10 18:19:23 +010018ENABLE_PIE := 1
Yann Gautier230bf912021-09-15 11:30:25 +020019BL2_IN_XIP_MEM := 1
Yann Gautier0ed7b2a2021-05-19 18:48:16 +020020endif
Yann Gautierdca61542021-02-10 18:19:23 +010021
Yann Gautier4b0c72a2018-07-16 10:54:09 +020022STM32_TF_VERSION ?= 0
23
Yann Gautiera55169b2020-01-10 18:18:59 +010024# Enable dynamic memory mapping
25PLAT_XLAT_TABLES_DYNAMIC := 1
Yann Gautiera55169b2020-01-10 18:18:59 +010026
Yann Gautier6d8c2442020-09-17 12:42:46 +020027# DDR controller with dual AXI port and 32-bit interface
28STM32MP_DDR_DUAL_AXI_PORT:= 1
29STM32MP_DDR_32BIT_INTERFACE:= 1
30
Etienne Carriereca651fb2020-04-10 18:51:54 +020031ifeq ($(AARCH32_SP),sp_min)
32# Disable Neon support: sp_min runtime may conflict with non-secure world
Yann Gautier46f8e672020-09-18 10:32:37 +020033TF_CFLAGS += -mfloat-abi=soft
Etienne Carriereca651fb2020-04-10 18:51:54 +020034endif
35
Yann Gautier19cdaa82020-11-10 15:09:55 +010036TF_CFLAGS += -Wsign-compare
37
Yann Gautier4b0c72a2018-07-16 10:54:09 +020038# Not needed for Cortex-A7
39WORKAROUND_CVE_2017_5715:= 0
40
Sughosh Ganua1976842021-11-10 17:47:16 +053041ifeq (${PSA_FWU_SUPPORT},1)
42ifneq (${STM32MP_USE_STM32IMAGE},1)
43# Number of banks of updatable firmware
44NR_OF_FW_BANKS := 2
45NR_OF_IMAGES_IN_FW_BANK := 1
46
Yann Gautier8244e1d2018-10-15 09:36:58 +020047# Number of TF-A copies in the device
48STM32_TF_A_COPIES := 2
Sughosh Ganua1976842021-11-10 17:47:16 +053049STM32_BL33_PARTS_NUM := 2
50STM32_RUNTIME_PARTS_NUM := 4
51else
52$(error FWU Feature enabled only with FIP images)
53endif
54else
55# Number of TF-A copies in the device
56STM32_TF_A_COPIES := 2
Yann Gautier6916a442020-09-17 12:28:12 +020057STM32_BL33_PARTS_NUM := 1
Yann Gautierb3386f72019-04-19 09:41:01 +020058ifeq ($(AARCH32_SP),optee)
Yann Gautier6916a442020-09-17 12:28:12 +020059STM32_RUNTIME_PARTS_NUM := 3
Yann Gautier0ed7b2a2021-05-19 18:48:16 +020060else ifeq ($(STM32MP_USE_STM32IMAGE),1)
Yann Gautier6916a442020-09-17 12:28:12 +020061STM32_RUNTIME_PARTS_NUM := 0
Yann Gautier0ed7b2a2021-05-19 18:48:16 +020062else
63STM32_RUNTIME_PARTS_NUM := 1
Yann Gautierb3386f72019-04-19 09:41:01 +020064endif
Sughosh Ganua1976842021-11-10 17:47:16 +053065endif
Yann Gautier6916a442020-09-17 12:28:12 +020066PLAT_PARTITION_MAX_ENTRIES := $(shell echo $$(($(STM32_TF_A_COPIES) + \
67 $(STM32_BL33_PARTS_NUM) + \
68 $(STM32_RUNTIME_PARTS_NUM))))
Yann Gautier8244e1d2018-10-15 09:36:58 +020069
Nicolas Le Bayon3f42cad2019-09-03 09:52:05 +020070# Boot devices
71STM32MP_EMMC ?= 0
72STM32MP_SDMMC ?= 0
Lionel Debieve402a46b2019-11-04 12:28:15 +010073STM32MP_RAW_NAND ?= 0
Lionel Debieve186b0462019-09-24 18:30:12 +020074STM32MP_SPI_NAND ?= 0
Lionel Debievecb0dbc42019-09-25 09:11:31 +020075STM32MP_SPI_NOR ?= 0
Vyacheslav Yurkove43a0802021-06-04 10:10:51 +020076STM32MP_EMMC_BOOT ?= 0
Nicolas Le Bayon3f42cad2019-09-03 09:52:05 +020077
Patrick Delaunay9c5ee782021-07-06 14:07:56 +020078# Serial boot devices
79STM32MP_USB_PROGRAMMER ?= 0
Patrick Delaunaye50571b2021-10-28 13:48:52 +020080STM32MP_UART_PROGRAMMER ?= 0
Patrick Delaunay9c5ee782021-07-06 14:07:56 +020081
Yann Gautier5f400632020-02-12 09:30:49 +010082# Device tree
83DTB_FILE_NAME ?= stm32mp157c-ev1.dtb
Yann Gautier0ed7b2a2021-05-19 18:48:16 +020084ifeq ($(STM32MP_USE_STM32IMAGE),1)
85ifeq ($(AARCH32_SP),optee)
86BL2_DTSI := stm32mp15-bl2.dtsi
87FDT_SOURCES := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl2.dts,$(DTB_FILE_NAME)))
88else
Yann Gautier5f400632020-02-12 09:30:49 +010089FDT_SOURCES := $(addprefix fdts/, $(patsubst %.dtb,%.dts,$(DTB_FILE_NAME)))
Yann Gautier0ed7b2a2021-05-19 18:48:16 +020090endif
91else
92BL2_DTSI := stm32mp15-bl2.dtsi
93FDT_SOURCES := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl2.dts,$(DTB_FILE_NAME)))
94ifeq ($(AARCH32_SP),sp_min)
95BL32_DTSI := stm32mp15-bl32.dtsi
96FDT_SOURCES += $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl32.dts,$(DTB_FILE_NAME)))
97endif
98endif
Yann Gautierd82fca42021-03-09 10:42:02 +010099
100$(eval DTC_V = $(shell $(DTC) -v | awk '{print $$NF}'))
101$(eval DTC_VERSION = $(shell printf "%d" $(shell echo ${DTC_V} | cut -d- -f1 | sed "s/\./0/g")))
Yann Gautier658775c2021-07-06 10:00:44 +0200102DTC_CPPFLAGS += ${INCLUDES}
Yann Gautier5f400632020-02-12 09:30:49 +0100103DTC_FLAGS += -Wno-unit_address_vs_reg
Yann Gautierd82fca42021-03-09 10:42:02 +0100104ifeq ($(shell test $(DTC_VERSION) -ge 10601; echo $$?),0)
105DTC_FLAGS += -Wno-interrupt_provider
106endif
Yann Gautier5f400632020-02-12 09:30:49 +0100107
108# Macros and rules to build TF binary
109STM32_TF_ELF_LDFLAGS := --hash-style=gnu --as-needed
110STM32_TF_STM32 := $(addprefix ${BUILD_PLAT}/tf-a-, $(patsubst %.dtb,%.stm32,$(DTB_FILE_NAME)))
111STM32_TF_LINKERFILE := ${BUILD_PLAT}/stm32mp1.ld
112
113ASFLAGS += -DBL2_BIN_PATH=\"${BUILD_PLAT}/bl2.bin\"
114ifeq ($(AARCH32_SP),sp_min)
115# BL32 is built only if using SP_MIN
116BL32_DEP := bl32
117ASFLAGS += -DBL32_BIN_PATH=\"${BUILD_PLAT}/bl32.bin\"
118endif
119
120# Variables for use with stm32image
121STM32IMAGEPATH ?= tools/stm32image
122STM32IMAGE ?= ${STM32IMAGEPATH}/stm32image${BIN_EXT}
Yann Gautiere56f53f2021-06-09 09:36:35 +0200123STM32IMAGE_SRC := ${STM32IMAGEPATH}/stm32image.c
Yann Gautier5f400632020-02-12 09:30:49 +0100124
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200125ifneq (${STM32MP_USE_STM32IMAGE},1)
126FIP_DEPS += dtbs
127STM32MP_HW_CONFIG := ${BL33_CFG}
Yann Gautier658775c2021-07-06 10:00:44 +0200128STM32MP_FW_CONFIG_NAME := $(patsubst %.dtb,%-fw-config.dtb,$(DTB_FILE_NAME))
129STM32MP_FW_CONFIG := ${BUILD_PLAT}/fdts/$(STM32MP_FW_CONFIG_NAME)
130ifneq (${AARCH32_SP},none)
131FDT_SOURCES += $(addprefix fdts/, $(patsubst %.dtb,%.dts,$(STM32MP_FW_CONFIG_NAME)))
132endif
133# Add the FW_CONFIG to FIP and specify the same to certtool
134$(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_FW_CONFIG},--fw-config))
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200135# Add the HW_CONFIG to FIP and specify the same to certtool
136$(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_HW_CONFIG},--hw-config))
137ifeq ($(AARCH32_SP),sp_min)
138STM32MP_TOS_FW_CONFIG := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl32.dtb,$(DTB_FILE_NAME)))
139$(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_TOS_FW_CONFIG},--tos-fw-config))
140else
141# Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images
142# in the FIP if the platform requires.
143ifneq ($(BL32_EXTRA1),)
144$(eval $(call TOOL_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1))
145endif
146ifneq ($(BL32_EXTRA2),)
147$(eval $(call TOOL_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2))
148endif
149endif
150endif
151
Yann Gautier5f400632020-02-12 09:30:49 +0100152# Enable flags for C files
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -0500153$(eval $(call assert_booleans,\
Yann Gautier5f400632020-02-12 09:30:49 +0100154 $(sort \
Yann Gautier27f589d2021-10-15 17:59:38 +0200155 PLAT_XLAT_TABLES_DYNAMIC \
Yann Gautier6d8c2442020-09-17 12:42:46 +0200156 STM32MP_DDR_32BIT_INTERFACE \
157 STM32MP_DDR_DUAL_AXI_PORT \
Yann Gautier5f400632020-02-12 09:30:49 +0100158 STM32MP_EMMC \
Yann Gautier27f589d2021-10-15 17:59:38 +0200159 STM32MP_EMMC_BOOT \
Yann Gautier5f400632020-02-12 09:30:49 +0100160 STM32MP_RAW_NAND \
Yann Gautier27f589d2021-10-15 17:59:38 +0200161 STM32MP_SDMMC \
Yann Gautier5f400632020-02-12 09:30:49 +0100162 STM32MP_SPI_NAND \
163 STM32MP_SPI_NOR \
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200164 STM32MP_UART_PROGRAMMER \
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200165 STM32MP_USB_PROGRAMMER \
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200166 STM32MP_USE_STM32IMAGE \
Yann Gautier5f400632020-02-12 09:30:49 +0100167)))
168
169$(eval $(call assert_numerics,\
170 $(sort \
Yann Gautier5f400632020-02-12 09:30:49 +0100171 PLAT_PARTITION_MAX_ENTRIES \
Yann Gautier27f589d2021-10-15 17:59:38 +0200172 STM32_TF_A_COPIES \
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200173 STM32_TF_VERSION \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -0500174)))
175
176$(eval $(call add_defines,\
Yann Gautier5f400632020-02-12 09:30:49 +0100177 $(sort \
Yann Gautier27f589d2021-10-15 17:59:38 +0200178 PLAT_PARTITION_MAX_ENTRIES \
179 PLAT_XLAT_TABLES_DYNAMIC \
180 STM32_TF_A_COPIES \
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200181 STM32_TF_VERSION \
Yann Gautier6d8c2442020-09-17 12:42:46 +0200182 STM32MP_DDR_32BIT_INTERFACE \
183 STM32MP_DDR_DUAL_AXI_PORT \
Yann Gautier5f400632020-02-12 09:30:49 +0100184 STM32MP_EMMC \
Yann Gautier27f589d2021-10-15 17:59:38 +0200185 STM32MP_EMMC_BOOT \
Yann Gautier5f400632020-02-12 09:30:49 +0100186 STM32MP_RAW_NAND \
Yann Gautier27f589d2021-10-15 17:59:38 +0200187 STM32MP_SDMMC \
Yann Gautier5f400632020-02-12 09:30:49 +0100188 STM32MP_SPI_NAND \
189 STM32MP_SPI_NOR \
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200190 STM32MP_UART_PROGRAMMER \
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200191 STM32MP_USB_PROGRAMMER \
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200192 STM32MP_USE_STM32IMAGE \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -0500193)))
Nicolas Le Bayon3f42cad2019-09-03 09:52:05 +0200194
Yann Gautier5f400632020-02-12 09:30:49 +0100195# Include paths and source files
Yann Gautieree8f5422019-02-14 11:13:25 +0100196PLAT_INCLUDES := -Iplat/st/common/include/
197PLAT_INCLUDES += -Iplat/st/stm32mp1/include/
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200198
Yann Gautier0dc92312021-10-29 17:04:17 +0200199ifeq (${STM32MP_USE_STM32IMAGE},1)
Chris Kaye9272152021-09-28 15:52:14 +0100200include common/fdt_wrappers.mk
Yann Gautier0dc92312021-10-29 17:04:17 +0200201else
202include lib/fconf/fconf.mk
203endif
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200204include lib/libfdt/libfdt.mk
205
Chris Kaye9272152021-09-28 15:52:14 +0100206PLAT_BL_COMMON_SOURCES := common/uuid.c \
Andre Przywaracc99f3f2020-03-26 12:51:21 +0000207 plat/st/common/stm32mp_common.c \
Yann Gautieree8f5422019-02-14 11:13:25 +0100208 plat/st/stm32mp1/stm32mp1_private.c
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200209
Julius Werner6b88b652018-11-27 17:50:28 -0800210PLAT_BL_COMMON_SOURCES += drivers/st/uart/aarch32/stm32_console.S
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200211
212ifneq (${ENABLE_STACK_PROTECTOR},0)
213PLAT_BL_COMMON_SOURCES += plat/st/stm32mp1/stm32mp1_stack_protector.c
214endif
215
216include lib/xlat_tables_v2/xlat_tables.mk
217PLAT_BL_COMMON_SOURCES += ${XLAT_TABLES_LIB_SRCS}
218
219PLAT_BL_COMMON_SOURCES += lib/cpus/aarch32/cortex_a7.S
220
Yann Gautier2c1fa282019-05-09 11:56:30 +0200221PLAT_BL_COMMON_SOURCES += drivers/arm/tzc/tzc400.c \
Gabriel Fernandez8aac3072020-10-13 09:36:25 +0200222 drivers/clk/clk.c \
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200223 drivers/delay_timer/delay_timer.c \
224 drivers/delay_timer/generic_delay_timer.c \
Yann Gautier36a1e4b2019-01-17 14:52:47 +0100225 drivers/st/bsec/bsec.c \
Yann Gautier4d429472019-02-14 11:15:20 +0100226 drivers/st/clk/stm32mp_clkfunc.c \
Yann Gautier9aea69e2018-07-24 17:13:36 +0200227 drivers/st/clk/stm32mp1_clk.c \
Nicolas Le Bayon8ce825f2021-05-18 10:01:30 +0200228 drivers/st/ddr/stm32mp_ddr.c \
Yann Gautiercaf575b2018-07-24 17:18:19 +0200229 drivers/st/ddr/stm32mp1_ddr_helpers.c \
Yann Gautierd0ca7f42018-07-13 21:33:09 +0200230 drivers/st/gpio/stm32_gpio.c \
Yann Gautier113f31e2019-01-17 09:34:18 +0100231 drivers/st/i2c/stm32_i2c.c \
Yann Gautier091eab52019-06-04 18:06:34 +0200232 drivers/st/iwdg/stm32_iwdg.c \
Yann Gautiera45433b2019-01-16 18:31:00 +0100233 drivers/st/pmic/stm32mp_pmic.c \
234 drivers/st/pmic/stpmic1.c \
Yann Gautierb1279e72021-12-15 13:16:15 +0100235 drivers/st/regulator/regulator_core.c \
Pascal Pailletfc7b8052021-01-29 14:48:49 +0100236 drivers/st/regulator/regulator_fixed.c \
Yann Gautier9aea69e2018-07-24 17:13:36 +0200237 drivers/st/reset/stm32mp1_reset.c \
Yann Gautieree8f5422019-02-14 11:13:25 +0100238 plat/st/common/stm32mp_dt.c \
Yann Gautier091eab52019-06-04 18:06:34 +0200239 plat/st/stm32mp1/stm32mp1_dbgmcu.c \
Yann Gautiercaf575b2018-07-24 17:18:19 +0200240 plat/st/stm32mp1/stm32mp1_helper.S \
Yann Gautier3edc7c32019-05-20 19:17:08 +0200241 plat/st/stm32mp1/stm32mp1_syscfg.c
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200242
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200243ifneq (${STM32MP_USE_STM32IMAGE},1)
Yann Gautier0dc92312021-10-29 17:04:17 +0200244BL2_SOURCES += ${FCONF_SOURCES} ${FCONF_DYN_SOURCES}
245
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200246BL2_SOURCES += drivers/io/io_fip.c \
247 plat/st/common/bl2_io_storage.c \
Yann Gautier29f1f942021-07-13 18:07:41 +0200248 plat/st/common/stm32mp_fconf_io.c \
Lionel Debieve1dc5e2e2020-09-27 21:13:53 +0200249 plat/st/stm32mp1/plat_bl2_mem_params_desc.c \
250 plat/st/stm32mp1/stm32mp1_fconf_firewall.c
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200251else
Yann Gautier0dc92312021-10-29 17:04:17 +0200252BL2_SOURCES += ${FDT_WRAPPERS_SOURCES}
253
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200254BL2_SOURCES += drivers/io/io_dummy.c \
255 drivers/st/io/io_stm32image.c \
256 plat/st/common/bl2_stm32_io_storage.c \
Lionel Debieve1dc5e2e2020-09-27 21:13:53 +0200257 plat/st/stm32mp1/plat_bl2_stm32_mem_params_desc.c \
258 plat/st/stm32mp1/stm32mp1_security.c
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200259endif
260
Sughosh Ganua1976842021-11-10 17:47:16 +0530261ifeq (${PSA_FWU_SUPPORT},1)
262include lib/zlib/zlib.mk
263include drivers/fwu/fwu.mk
264
265BL2_SOURCES += $(ZLIB_SOURCES)
266endif
267
Yann Gautier8244e1d2018-10-15 09:36:58 +0200268BL2_SOURCES += drivers/io/io_block.c \
Lionel Debieve402a46b2019-11-04 12:28:15 +0100269 drivers/io/io_mtd.c \
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200270 drivers/io/io_storage.c \
Lionel Debieve7bd96f42019-09-03 12:22:23 +0200271 drivers/st/crypto/stm32_hash.c \
Lionel Debieve7bd96f42019-09-03 12:22:23 +0200272 plat/st/common/stm32mp_auth.c \
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200273 plat/st/stm32mp1/bl2_plat_setup.c
274
Nicolas Le Bayon3f42cad2019-09-03 09:52:05 +0200275ifneq ($(filter 1,${STM32MP_EMMC} ${STM32MP_SDMMC}),)
Yann Gautier8244e1d2018-10-15 09:36:58 +0200276BL2_SOURCES += drivers/mmc/mmc.c \
277 drivers/partition/gpt.c \
278 drivers/partition/partition.c \
279 drivers/st/io/io_mmc.c \
280 drivers/st/mmc/stm32_sdmmc2.c
Nicolas Le Bayon3f42cad2019-09-03 09:52:05 +0200281endif
Yann Gautier8244e1d2018-10-15 09:36:58 +0200282
Lionel Debieve402a46b2019-11-04 12:28:15 +0100283ifeq (${STM32MP_RAW_NAND},1)
284$(eval $(call add_define_val,NAND_ONFI_DETECT,1))
285BL2_SOURCES += drivers/mtd/nand/raw_nand.c \
286 drivers/st/fmc/stm32_fmc2_nand.c
287endif
288
Lionel Debieve186b0462019-09-24 18:30:12 +0200289ifeq (${STM32MP_SPI_NAND},1)
290BL2_SOURCES += drivers/mtd/nand/spi_nand.c
291endif
292
Lionel Debievecb0dbc42019-09-25 09:11:31 +0200293ifeq (${STM32MP_SPI_NOR},1)
294BL2_SOURCES += drivers/mtd/nor/spi_nor.c
295endif
296
297ifneq ($(filter 1,${STM32MP_SPI_NAND} ${STM32MP_SPI_NOR}),)
Lionel Debieve186b0462019-09-24 18:30:12 +0200298BL2_SOURCES += drivers/mtd/spi-mem/spi_mem.c \
299 drivers/st/spi/stm32_qspi.c
300endif
301
302ifneq ($(filter 1,${STM32MP_RAW_NAND} ${STM32MP_SPI_NAND}),)
Lionel Debievecb0dbc42019-09-25 09:11:31 +0200303BL2_SOURCES += drivers/mtd/nand/core.c
304endif
305
306ifneq ($(filter 1,${STM32MP_RAW_NAND} ${STM32MP_SPI_NAND} ${STM32MP_SPI_NOR}),)
307BL2_SOURCES += plat/st/stm32mp1/stm32mp1_boot_device.c
Lionel Debieve402a46b2019-11-04 12:28:15 +0100308endif
309
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200310ifneq ($(filter 1,${STM32MP_UART_PROGRAMMER} ${STM32MP_USB_PROGRAMMER}),)
311BL2_SOURCES += drivers/io/io_memmap.c
312endif
313
314ifeq (${STM32MP_UART_PROGRAMMER},1)
315BL2_SOURCES += drivers/st/uart/stm32_uart.c \
316 plat/st/common/stm32cubeprogrammer_uart.c
317endif
318
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200319ifeq (${STM32MP_USB_PROGRAMMER},1)
320#The DFU stack uses only one end point, reduce the USB stack footprint
321$(eval $(call add_define_val,CONFIG_USBD_EP_NB,1U))
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200322BL2_SOURCES += drivers/st/usb/stm32mp1_usb.c \
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200323 drivers/usb/usb_device.c \
324 plat/st/common/stm32cubeprogrammer_usb.c \
325 plat/st/common/usb_dfu.c \
326 plat/st/stm32mp1/stm32mp1_usb_dfu.c
327endif
328
Nicolas Le Bayon620ce332021-03-02 11:19:36 +0100329BL2_SOURCES += drivers/st/ddr/stm32mp_ddr_test.c \
330 drivers/st/ddr/stm32mp_ram.c \
Nicolas Le Bayon8ce825f2021-05-18 10:01:30 +0200331 drivers/st/ddr/stm32mp1_ddr.c \
Yann Gautiercaf575b2018-07-24 17:18:19 +0200332 drivers/st/ddr/stm32mp1_ram.c
333
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200334BL2_SOURCES += common/desc_image_load.c \
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200335 plat/st/stm32mp1/plat_image_load.c
336
Yann Gautierb3386f72019-04-19 09:41:01 +0200337BL2_SOURCES += lib/optee/optee_utils.c
Yann Gautierb3386f72019-04-19 09:41:01 +0200338
Yann Gautier5f400632020-02-12 09:30:49 +0100339# Compilation rules
Yann Gautiercc785d82020-11-09 11:16:10 +0100340.PHONY: check_dtc_version stm32image clean_stm32image check_boot_device
Yann Gautier761797d2018-07-16 14:34:50 +0200341.SUFFIXES:
342
Yann Gautier3f10a2f2020-09-18 10:21:29 +0200343all: check_dtc_version stm32image ${STM32_TF_STM32}
Yann Gautier761797d2018-07-16 14:34:50 +0200344
Yann Gautier761797d2018-07-16 14:34:50 +0200345distclean realclean clean: clean_stm32image
346
Yann Gautiercc785d82020-11-09 11:16:10 +0100347bl2: check_boot_device
348
349check_boot_device:
350 @if [ ${STM32MP_EMMC} != 1 ] && \
351 [ ${STM32MP_SDMMC} != 1 ] && \
352 [ ${STM32MP_RAW_NAND} != 1 ] && \
353 [ ${STM32MP_SPI_NAND} != 1 ] && \
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200354 [ ${STM32MP_SPI_NOR} != 1 ] && \
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200355 [ ${STM32MP_UART_PROGRAMMER} != 1 ] && \
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200356 [ ${STM32MP_USB_PROGRAMMER} != 1 ]; then \
Yann Gautiercc785d82020-11-09 11:16:10 +0100357 echo "No boot device driver is enabled"; \
358 false; \
359 fi
360
Yann Gautier3f10a2f2020-09-18 10:21:29 +0200361stm32image: ${STM32IMAGE}
362
363${STM32IMAGE}: ${STM32IMAGE_SRC}
Yann Gautier761797d2018-07-16 14:34:50 +0200364 ${Q}${MAKE} CPPFLAGS="" --no-print-directory -C ${STM32IMAGEPATH}
365
366clean_stm32image:
367 ${Q}${MAKE} --no-print-directory -C ${STM32IMAGEPATH} clean
368
369check_dtc_version:
Yann Gautier761797d2018-07-16 14:34:50 +0200370 @if [ ${DTC_VERSION} -lt 10404 ]; then \
371 echo "dtc version too old (${DTC_V}), you need at least version 1.4.4"; \
372 false; \
373 fi
374
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200375ifeq ($(STM32MP_USE_STM32IMAGE)-$(AARCH32_SP),1-sp_min)
Yann Gautier46f8e672020-09-18 10:32:37 +0200376${BUILD_PLAT}/stm32mp1-%.o: ${BUILD_PLAT}/fdts/%.dtb plat/st/stm32mp1/stm32mp1.S bl2 ${BL32_DEP}
377 @echo " AS stm32mp1.S"
378 ${Q}${AS} ${ASFLAGS} ${TF_CFLAGS} \
379 -DDTB_BIN_PATH=\"$<\" \
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200380 -c $(word 2,$^) -o $@
381else
382# Create DTB file for BL2
383${BUILD_PLAT}/fdts/%-bl2.dts: fdts/%.dts fdts/${BL2_DTSI} | ${BUILD_PLAT} fdt_dirs
384 @echo '#include "$(patsubst fdts/%,%,$<)"' > $@
385 @echo '#include "${BL2_DTSI}"' >> $@
386
387${BUILD_PLAT}/fdts/%-bl2.dtb: ${BUILD_PLAT}/fdts/%-bl2.dts
388
389ifeq ($(AARCH32_SP),sp_min)
390# Create DTB file for BL32
391${BUILD_PLAT}/fdts/%-bl32.dts: fdts/%.dts fdts/${BL32_DTSI} | ${BUILD_PLAT} fdt_dirs
392 @echo '#include "$(patsubst fdts/%,%,$<)"' > $@
393 @echo '#include "${BL32_DTSI}"' >> $@
394
395${BUILD_PLAT}/fdts/%-bl32.dtb: ${BUILD_PLAT}/fdts/%-bl32.dts
396endif
397
398${BUILD_PLAT}/stm32mp1-%.o: ${BUILD_PLAT}/fdts/%-bl2.dtb plat/st/stm32mp1/stm32mp1.S bl2
399 @echo " AS stm32mp1.S"
400 ${Q}${AS} ${ASFLAGS} ${TF_CFLAGS} \
401 -DDTB_BIN_PATH=\"$<\" \
Yann Gautier46f8e672020-09-18 10:32:37 +0200402 -c plat/st/stm32mp1/stm32mp1.S -o $@
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200403endif
Yann Gautier761797d2018-07-16 14:34:50 +0200404
Yann Gautier3ab157a2021-10-07 14:19:48 +0200405$(eval $(call MAKE_LD,${STM32_TF_LINKERFILE},plat/st/stm32mp1/stm32mp1.ld.S,bl2))
Yann Gautier761797d2018-07-16 14:34:50 +0200406
Yann Gautier46f8e672020-09-18 10:32:37 +0200407tf-a-%.elf: stm32mp1-%.o ${STM32_TF_LINKERFILE}
408 @echo " LDS $<"
409 ${Q}${LD} -o $@ ${STM32_TF_ELF_LDFLAGS} -Map=$(@:.elf=.map) --script ${STM32_TF_LINKERFILE} $<
Yann Gautier761797d2018-07-16 14:34:50 +0200410
Yann Gautier46f8e672020-09-18 10:32:37 +0200411tf-a-%.bin: tf-a-%.elf
412 ${Q}${OC} -O binary $< $@
413 @echo
414 @echo "Built $@ successfully"
415 @echo
Yann Gautier761797d2018-07-16 14:34:50 +0200416
Yann Gautier46f8e672020-09-18 10:32:37 +0200417tf-a-%.stm32: ${STM32IMAGE} tf-a-%.bin
418 @echo
419 @echo "Generate $@"
420 $(eval LOADADDR = $(shell cat $(@:.stm32=.map) | grep RAM | awk '{print $$2}'))
421 $(eval ENTRY = $(shell cat $(@:.stm32=.map) | grep "__BL2_IMAGE_START" | awk '{print $$1}'))
422 ${Q}${STM32IMAGE} -s $(word 2,$^) -d $@ \
423 -l $(LOADADDR) -e ${ENTRY} \
424 -v ${STM32_TF_VERSION}
425 @echo