blob: a4c40c4c42f1e12ff422135d8c932aef27c32082 [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 Gautierd1435742021-10-18 10:55:23 +020012STM32MP_EARLY_CONSOLE ?= 0
Yann Gautierb02dd492022-03-02 14:31:55 +010013STM32MP_UART_BAUDRATE ?= 115200
Yann Gautierd1435742021-10-18 10:55:23 +020014
Yann Gautier0ed7b2a2021-05-19 18:48:16 +020015# Allow TF-A to concatenate BL2 & BL32 binaries in a single file,
16# share DTB file between BL2 and BL32
17# If it is set to 0, then FIP is used
18STM32MP_USE_STM32IMAGE ?= 0
19
Yann Gautier5c1dab32019-04-17 15:12:58 +020020# Please don't increment this value without good understanding of
21# the monotonic counter
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
Yann Gautier3c7be342022-02-14 10:30:33 +010037TF_CFLAGS += -Wformat-signedness
Yann Gautier19cdaa82020-11-10 15:09:55 +010038
Yann Gautier4b0c72a2018-07-16 10:54:09 +020039# Not needed for Cortex-A7
40WORKAROUND_CVE_2017_5715:= 0
Bipin Ravicaa2e052022-02-23 23:45:50 -060041WORKAROUND_CVE_2022_23960:= 0
Yann Gautier4b0c72a2018-07-16 10:54:09 +020042
Sughosh Ganua1976842021-11-10 17:47:16 +053043ifeq (${PSA_FWU_SUPPORT},1)
44ifneq (${STM32MP_USE_STM32IMAGE},1)
45# Number of banks of updatable firmware
46NR_OF_FW_BANKS := 2
47NR_OF_IMAGES_IN_FW_BANK := 1
48
Yann Gautier8244e1d2018-10-15 09:36:58 +020049# Number of TF-A copies in the device
50STM32_TF_A_COPIES := 2
Sughosh Ganua1976842021-11-10 17:47:16 +053051STM32_BL33_PARTS_NUM := 2
52STM32_RUNTIME_PARTS_NUM := 4
53else
54$(error FWU Feature enabled only with FIP images)
55endif
56else
57# Number of TF-A copies in the device
58STM32_TF_A_COPIES := 2
Yann Gautier6916a442020-09-17 12:28:12 +020059STM32_BL33_PARTS_NUM := 1
Yann Gautierb3386f72019-04-19 09:41:01 +020060ifeq ($(AARCH32_SP),optee)
Yann Gautier6916a442020-09-17 12:28:12 +020061STM32_RUNTIME_PARTS_NUM := 3
Yann Gautier0ed7b2a2021-05-19 18:48:16 +020062else ifeq ($(STM32MP_USE_STM32IMAGE),1)
Yann Gautier6916a442020-09-17 12:28:12 +020063STM32_RUNTIME_PARTS_NUM := 0
Yann Gautier0ed7b2a2021-05-19 18:48:16 +020064else
65STM32_RUNTIME_PARTS_NUM := 1
Yann Gautierb3386f72019-04-19 09:41:01 +020066endif
Sughosh Ganua1976842021-11-10 17:47:16 +053067endif
Yann Gautier6916a442020-09-17 12:28:12 +020068PLAT_PARTITION_MAX_ENTRIES := $(shell echo $$(($(STM32_TF_A_COPIES) + \
69 $(STM32_BL33_PARTS_NUM) + \
70 $(STM32_RUNTIME_PARTS_NUM))))
Yann Gautier8244e1d2018-10-15 09:36:58 +020071
Nicolas Le Bayon3f42cad2019-09-03 09:52:05 +020072# Boot devices
73STM32MP_EMMC ?= 0
74STM32MP_SDMMC ?= 0
Lionel Debieve402a46b2019-11-04 12:28:15 +010075STM32MP_RAW_NAND ?= 0
Lionel Debieve186b0462019-09-24 18:30:12 +020076STM32MP_SPI_NAND ?= 0
Lionel Debievecb0dbc42019-09-25 09:11:31 +020077STM32MP_SPI_NOR ?= 0
Vyacheslav Yurkove43a0802021-06-04 10:10:51 +020078STM32MP_EMMC_BOOT ?= 0
Nicolas Le Bayon3f42cad2019-09-03 09:52:05 +020079
Patrick Delaunay9c5ee782021-07-06 14:07:56 +020080# Serial boot devices
81STM32MP_USB_PROGRAMMER ?= 0
Patrick Delaunaye50571b2021-10-28 13:48:52 +020082STM32MP_UART_PROGRAMMER ?= 0
Patrick Delaunay9c5ee782021-07-06 14:07:56 +020083
Yann Gautier5f400632020-02-12 09:30:49 +010084# Device tree
85DTB_FILE_NAME ?= stm32mp157c-ev1.dtb
Yann Gautier0ed7b2a2021-05-19 18:48:16 +020086ifeq ($(STM32MP_USE_STM32IMAGE),1)
87ifeq ($(AARCH32_SP),optee)
88BL2_DTSI := stm32mp15-bl2.dtsi
89FDT_SOURCES := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl2.dts,$(DTB_FILE_NAME)))
90else
Yann Gautier5f400632020-02-12 09:30:49 +010091FDT_SOURCES := $(addprefix fdts/, $(patsubst %.dtb,%.dts,$(DTB_FILE_NAME)))
Yann Gautier0ed7b2a2021-05-19 18:48:16 +020092endif
93else
94BL2_DTSI := stm32mp15-bl2.dtsi
95FDT_SOURCES := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl2.dts,$(DTB_FILE_NAME)))
96ifeq ($(AARCH32_SP),sp_min)
97BL32_DTSI := stm32mp15-bl32.dtsi
98FDT_SOURCES += $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl32.dts,$(DTB_FILE_NAME)))
99endif
100endif
Yann Gautierd82fca42021-03-09 10:42:02 +0100101
102$(eval DTC_V = $(shell $(DTC) -v | awk '{print $$NF}'))
103$(eval DTC_VERSION = $(shell printf "%d" $(shell echo ${DTC_V} | cut -d- -f1 | sed "s/\./0/g")))
Yann Gautier658775c2021-07-06 10:00:44 +0200104DTC_CPPFLAGS += ${INCLUDES}
Yann Gautier5f400632020-02-12 09:30:49 +0100105DTC_FLAGS += -Wno-unit_address_vs_reg
Yann Gautierd82fca42021-03-09 10:42:02 +0100106ifeq ($(shell test $(DTC_VERSION) -ge 10601; echo $$?),0)
107DTC_FLAGS += -Wno-interrupt_provider
108endif
Yann Gautier5f400632020-02-12 09:30:49 +0100109
110# Macros and rules to build TF binary
111STM32_TF_ELF_LDFLAGS := --hash-style=gnu --as-needed
112STM32_TF_STM32 := $(addprefix ${BUILD_PLAT}/tf-a-, $(patsubst %.dtb,%.stm32,$(DTB_FILE_NAME)))
113STM32_TF_LINKERFILE := ${BUILD_PLAT}/stm32mp1.ld
114
115ASFLAGS += -DBL2_BIN_PATH=\"${BUILD_PLAT}/bl2.bin\"
116ifeq ($(AARCH32_SP),sp_min)
117# BL32 is built only if using SP_MIN
118BL32_DEP := bl32
119ASFLAGS += -DBL32_BIN_PATH=\"${BUILD_PLAT}/bl32.bin\"
120endif
121
122# Variables for use with stm32image
123STM32IMAGEPATH ?= tools/stm32image
124STM32IMAGE ?= ${STM32IMAGEPATH}/stm32image${BIN_EXT}
Yann Gautiere56f53f2021-06-09 09:36:35 +0200125STM32IMAGE_SRC := ${STM32IMAGEPATH}/stm32image.c
Yann Gautier5f400632020-02-12 09:30:49 +0100126
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200127ifneq (${STM32MP_USE_STM32IMAGE},1)
128FIP_DEPS += dtbs
129STM32MP_HW_CONFIG := ${BL33_CFG}
Yann Gautier658775c2021-07-06 10:00:44 +0200130STM32MP_FW_CONFIG_NAME := $(patsubst %.dtb,%-fw-config.dtb,$(DTB_FILE_NAME))
131STM32MP_FW_CONFIG := ${BUILD_PLAT}/fdts/$(STM32MP_FW_CONFIG_NAME)
132ifneq (${AARCH32_SP},none)
133FDT_SOURCES += $(addprefix fdts/, $(patsubst %.dtb,%.dts,$(STM32MP_FW_CONFIG_NAME)))
134endif
135# Add the FW_CONFIG to FIP and specify the same to certtool
136$(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_FW_CONFIG},--fw-config))
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200137# Add the HW_CONFIG to FIP and specify the same to certtool
138$(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_HW_CONFIG},--hw-config))
139ifeq ($(AARCH32_SP),sp_min)
140STM32MP_TOS_FW_CONFIG := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl32.dtb,$(DTB_FILE_NAME)))
141$(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_TOS_FW_CONFIG},--tos-fw-config))
142else
143# Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images
144# in the FIP if the platform requires.
145ifneq ($(BL32_EXTRA1),)
146$(eval $(call TOOL_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1))
147endif
148ifneq ($(BL32_EXTRA2),)
149$(eval $(call TOOL_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2))
150endif
151endif
152endif
153
Yann Gautier5f400632020-02-12 09:30:49 +0100154# Enable flags for C files
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -0500155$(eval $(call assert_booleans,\
Yann Gautier5f400632020-02-12 09:30:49 +0100156 $(sort \
Yann Gautier27f589d2021-10-15 17:59:38 +0200157 PLAT_XLAT_TABLES_DYNAMIC \
Yann Gautier6d8c2442020-09-17 12:42:46 +0200158 STM32MP_DDR_32BIT_INTERFACE \
159 STM32MP_DDR_DUAL_AXI_PORT \
Yann Gautierd1435742021-10-18 10:55:23 +0200160 STM32MP_EARLY_CONSOLE \
Yann Gautier5f400632020-02-12 09:30:49 +0100161 STM32MP_EMMC \
Yann Gautier27f589d2021-10-15 17:59:38 +0200162 STM32MP_EMMC_BOOT \
Yann Gautier5f400632020-02-12 09:30:49 +0100163 STM32MP_RAW_NAND \
Yann Gautier27f589d2021-10-15 17:59:38 +0200164 STM32MP_SDMMC \
Yann Gautier5f400632020-02-12 09:30:49 +0100165 STM32MP_SPI_NAND \
166 STM32MP_SPI_NOR \
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200167 STM32MP_UART_PROGRAMMER \
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200168 STM32MP_USB_PROGRAMMER \
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200169 STM32MP_USE_STM32IMAGE \
Yann Gautier5f400632020-02-12 09:30:49 +0100170)))
171
172$(eval $(call assert_numerics,\
173 $(sort \
Yann Gautier5f400632020-02-12 09:30:49 +0100174 PLAT_PARTITION_MAX_ENTRIES \
Yann Gautier27f589d2021-10-15 17:59:38 +0200175 STM32_TF_A_COPIES \
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200176 STM32_TF_VERSION \
Yann Gautierb02dd492022-03-02 14:31:55 +0100177 STM32MP_UART_BAUDRATE \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -0500178)))
179
180$(eval $(call add_defines,\
Yann Gautier5f400632020-02-12 09:30:49 +0100181 $(sort \
Yann Gautier27f589d2021-10-15 17:59:38 +0200182 PLAT_PARTITION_MAX_ENTRIES \
183 PLAT_XLAT_TABLES_DYNAMIC \
184 STM32_TF_A_COPIES \
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200185 STM32_TF_VERSION \
Yann Gautier6d8c2442020-09-17 12:42:46 +0200186 STM32MP_DDR_32BIT_INTERFACE \
187 STM32MP_DDR_DUAL_AXI_PORT \
Yann Gautierd1435742021-10-18 10:55:23 +0200188 STM32MP_EARLY_CONSOLE \
Yann Gautier5f400632020-02-12 09:30:49 +0100189 STM32MP_EMMC \
Yann Gautier27f589d2021-10-15 17:59:38 +0200190 STM32MP_EMMC_BOOT \
Yann Gautier5f400632020-02-12 09:30:49 +0100191 STM32MP_RAW_NAND \
Yann Gautier27f589d2021-10-15 17:59:38 +0200192 STM32MP_SDMMC \
Yann Gautier5f400632020-02-12 09:30:49 +0100193 STM32MP_SPI_NAND \
194 STM32MP_SPI_NOR \
Yann Gautierb02dd492022-03-02 14:31:55 +0100195 STM32MP_UART_BAUDRATE \
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200196 STM32MP_UART_PROGRAMMER \
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200197 STM32MP_USB_PROGRAMMER \
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200198 STM32MP_USE_STM32IMAGE \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -0500199)))
Nicolas Le Bayon3f42cad2019-09-03 09:52:05 +0200200
Yann Gautier5f400632020-02-12 09:30:49 +0100201# Include paths and source files
Yann Gautieree8f5422019-02-14 11:13:25 +0100202PLAT_INCLUDES := -Iplat/st/common/include/
203PLAT_INCLUDES += -Iplat/st/stm32mp1/include/
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200204
Yann Gautier0dc92312021-10-29 17:04:17 +0200205ifeq (${STM32MP_USE_STM32IMAGE},1)
Chris Kaye9272152021-09-28 15:52:14 +0100206include common/fdt_wrappers.mk
Yann Gautier0dc92312021-10-29 17:04:17 +0200207else
208include lib/fconf/fconf.mk
209endif
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200210include lib/libfdt/libfdt.mk
211
Chris Kaye9272152021-09-28 15:52:14 +0100212PLAT_BL_COMMON_SOURCES := common/uuid.c \
Andre Przywaracc99f3f2020-03-26 12:51:21 +0000213 plat/st/common/stm32mp_common.c \
Yann Gautieree8f5422019-02-14 11:13:25 +0100214 plat/st/stm32mp1/stm32mp1_private.c
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200215
Julius Werner6b88b652018-11-27 17:50:28 -0800216PLAT_BL_COMMON_SOURCES += drivers/st/uart/aarch32/stm32_console.S
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200217
218ifneq (${ENABLE_STACK_PROTECTOR},0)
219PLAT_BL_COMMON_SOURCES += plat/st/stm32mp1/stm32mp1_stack_protector.c
220endif
221
222include lib/xlat_tables_v2/xlat_tables.mk
223PLAT_BL_COMMON_SOURCES += ${XLAT_TABLES_LIB_SRCS}
224
225PLAT_BL_COMMON_SOURCES += lib/cpus/aarch32/cortex_a7.S
226
Yann Gautier2c1fa282019-05-09 11:56:30 +0200227PLAT_BL_COMMON_SOURCES += drivers/arm/tzc/tzc400.c \
Gabriel Fernandez8aac3072020-10-13 09:36:25 +0200228 drivers/clk/clk.c \
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200229 drivers/delay_timer/delay_timer.c \
230 drivers/delay_timer/generic_delay_timer.c \
Nicolas Le Bayon97287cd2019-05-20 18:35:02 +0200231 drivers/st/bsec/bsec2.c \
Yann Gautier4d429472019-02-14 11:15:20 +0100232 drivers/st/clk/stm32mp_clkfunc.c \
Yann Gautier9aea69e2018-07-24 17:13:36 +0200233 drivers/st/clk/stm32mp1_clk.c \
Nicolas Le Bayon8ce825f2021-05-18 10:01:30 +0200234 drivers/st/ddr/stm32mp_ddr.c \
Yann Gautiercaf575b2018-07-24 17:18:19 +0200235 drivers/st/ddr/stm32mp1_ddr_helpers.c \
Yann Gautierd0ca7f42018-07-13 21:33:09 +0200236 drivers/st/gpio/stm32_gpio.c \
Yann Gautier113f31e2019-01-17 09:34:18 +0100237 drivers/st/i2c/stm32_i2c.c \
Yann Gautier091eab52019-06-04 18:06:34 +0200238 drivers/st/iwdg/stm32_iwdg.c \
Yann Gautiera45433b2019-01-16 18:31:00 +0100239 drivers/st/pmic/stm32mp_pmic.c \
240 drivers/st/pmic/stpmic1.c \
Yann Gautierb1279e72021-12-15 13:16:15 +0100241 drivers/st/regulator/regulator_core.c \
Pascal Pailletfc7b8052021-01-29 14:48:49 +0100242 drivers/st/regulator/regulator_fixed.c \
Yann Gautier9aea69e2018-07-24 17:13:36 +0200243 drivers/st/reset/stm32mp1_reset.c \
Yann Gautieree8f5422019-02-14 11:13:25 +0100244 plat/st/common/stm32mp_dt.c \
Yann Gautier091eab52019-06-04 18:06:34 +0200245 plat/st/stm32mp1/stm32mp1_dbgmcu.c \
Yann Gautiercaf575b2018-07-24 17:18:19 +0200246 plat/st/stm32mp1/stm32mp1_helper.S \
Yann Gautier3edc7c32019-05-20 19:17:08 +0200247 plat/st/stm32mp1/stm32mp1_syscfg.c
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200248
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200249ifneq (${STM32MP_USE_STM32IMAGE},1)
Yann Gautier0dc92312021-10-29 17:04:17 +0200250BL2_SOURCES += ${FCONF_SOURCES} ${FCONF_DYN_SOURCES}
251
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200252BL2_SOURCES += drivers/io/io_fip.c \
253 plat/st/common/bl2_io_storage.c \
Yann Gautier29f1f942021-07-13 18:07:41 +0200254 plat/st/common/stm32mp_fconf_io.c \
Lionel Debieve1dc5e2e2020-09-27 21:13:53 +0200255 plat/st/stm32mp1/plat_bl2_mem_params_desc.c \
256 plat/st/stm32mp1/stm32mp1_fconf_firewall.c
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200257else
Yann Gautier0dc92312021-10-29 17:04:17 +0200258BL2_SOURCES += ${FDT_WRAPPERS_SOURCES}
259
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200260BL2_SOURCES += drivers/io/io_dummy.c \
261 drivers/st/io/io_stm32image.c \
262 plat/st/common/bl2_stm32_io_storage.c \
Lionel Debieve1dc5e2e2020-09-27 21:13:53 +0200263 plat/st/stm32mp1/plat_bl2_stm32_mem_params_desc.c \
264 plat/st/stm32mp1/stm32mp1_security.c
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200265endif
266
Sughosh Ganua1976842021-11-10 17:47:16 +0530267ifeq (${PSA_FWU_SUPPORT},1)
268include lib/zlib/zlib.mk
269include drivers/fwu/fwu.mk
270
271BL2_SOURCES += $(ZLIB_SOURCES)
272endif
273
Yann Gautier8244e1d2018-10-15 09:36:58 +0200274BL2_SOURCES += drivers/io/io_block.c \
Lionel Debieve402a46b2019-11-04 12:28:15 +0100275 drivers/io/io_mtd.c \
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200276 drivers/io/io_storage.c \
Lionel Debieve7bd96f42019-09-03 12:22:23 +0200277 drivers/st/crypto/stm32_hash.c \
Lionel Debieve7bd96f42019-09-03 12:22:23 +0200278 plat/st/common/stm32mp_auth.c \
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200279 plat/st/stm32mp1/bl2_plat_setup.c
280
Nicolas Le Bayon3f42cad2019-09-03 09:52:05 +0200281ifneq ($(filter 1,${STM32MP_EMMC} ${STM32MP_SDMMC}),)
Yann Gautier8244e1d2018-10-15 09:36:58 +0200282BL2_SOURCES += drivers/mmc/mmc.c \
283 drivers/partition/gpt.c \
284 drivers/partition/partition.c \
285 drivers/st/io/io_mmc.c \
286 drivers/st/mmc/stm32_sdmmc2.c
Nicolas Le Bayon3f42cad2019-09-03 09:52:05 +0200287endif
Yann Gautier8244e1d2018-10-15 09:36:58 +0200288
Lionel Debieve402a46b2019-11-04 12:28:15 +0100289ifeq (${STM32MP_RAW_NAND},1)
290$(eval $(call add_define_val,NAND_ONFI_DETECT,1))
291BL2_SOURCES += drivers/mtd/nand/raw_nand.c \
292 drivers/st/fmc/stm32_fmc2_nand.c
293endif
294
Lionel Debieve186b0462019-09-24 18:30:12 +0200295ifeq (${STM32MP_SPI_NAND},1)
296BL2_SOURCES += drivers/mtd/nand/spi_nand.c
297endif
298
Lionel Debievecb0dbc42019-09-25 09:11:31 +0200299ifeq (${STM32MP_SPI_NOR},1)
300BL2_SOURCES += drivers/mtd/nor/spi_nor.c
301endif
302
303ifneq ($(filter 1,${STM32MP_SPI_NAND} ${STM32MP_SPI_NOR}),)
Lionel Debieve186b0462019-09-24 18:30:12 +0200304BL2_SOURCES += drivers/mtd/spi-mem/spi_mem.c \
305 drivers/st/spi/stm32_qspi.c
306endif
307
308ifneq ($(filter 1,${STM32MP_RAW_NAND} ${STM32MP_SPI_NAND}),)
Lionel Debievecb0dbc42019-09-25 09:11:31 +0200309BL2_SOURCES += drivers/mtd/nand/core.c
310endif
311
312ifneq ($(filter 1,${STM32MP_RAW_NAND} ${STM32MP_SPI_NAND} ${STM32MP_SPI_NOR}),)
313BL2_SOURCES += plat/st/stm32mp1/stm32mp1_boot_device.c
Lionel Debieve402a46b2019-11-04 12:28:15 +0100314endif
315
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200316ifneq ($(filter 1,${STM32MP_UART_PROGRAMMER} ${STM32MP_USB_PROGRAMMER}),)
317BL2_SOURCES += drivers/io/io_memmap.c
318endif
319
320ifeq (${STM32MP_UART_PROGRAMMER},1)
321BL2_SOURCES += drivers/st/uart/stm32_uart.c \
322 plat/st/common/stm32cubeprogrammer_uart.c
323endif
324
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200325ifeq (${STM32MP_USB_PROGRAMMER},1)
326#The DFU stack uses only one end point, reduce the USB stack footprint
327$(eval $(call add_define_val,CONFIG_USBD_EP_NB,1U))
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200328BL2_SOURCES += drivers/st/usb/stm32mp1_usb.c \
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200329 drivers/usb/usb_device.c \
330 plat/st/common/stm32cubeprogrammer_usb.c \
331 plat/st/common/usb_dfu.c \
332 plat/st/stm32mp1/stm32mp1_usb_dfu.c
333endif
334
Nicolas Le Bayon620ce332021-03-02 11:19:36 +0100335BL2_SOURCES += drivers/st/ddr/stm32mp_ddr_test.c \
336 drivers/st/ddr/stm32mp_ram.c \
Nicolas Le Bayon8ce825f2021-05-18 10:01:30 +0200337 drivers/st/ddr/stm32mp1_ddr.c \
Yann Gautiercaf575b2018-07-24 17:18:19 +0200338 drivers/st/ddr/stm32mp1_ram.c
339
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200340BL2_SOURCES += common/desc_image_load.c \
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200341 plat/st/stm32mp1/plat_image_load.c
342
Yann Gautierb3386f72019-04-19 09:41:01 +0200343BL2_SOURCES += lib/optee/optee_utils.c
Yann Gautierb3386f72019-04-19 09:41:01 +0200344
Yann Gautier5f400632020-02-12 09:30:49 +0100345# Compilation rules
Yann Gautiercc785d82020-11-09 11:16:10 +0100346.PHONY: check_dtc_version stm32image clean_stm32image check_boot_device
Yann Gautier761797d2018-07-16 14:34:50 +0200347.SUFFIXES:
348
Yann Gautier3f10a2f2020-09-18 10:21:29 +0200349all: check_dtc_version stm32image ${STM32_TF_STM32}
Yann Gautier761797d2018-07-16 14:34:50 +0200350
Yann Gautier761797d2018-07-16 14:34:50 +0200351distclean realclean clean: clean_stm32image
352
Yann Gautiercc785d82020-11-09 11:16:10 +0100353bl2: check_boot_device
354
355check_boot_device:
356 @if [ ${STM32MP_EMMC} != 1 ] && \
357 [ ${STM32MP_SDMMC} != 1 ] && \
358 [ ${STM32MP_RAW_NAND} != 1 ] && \
359 [ ${STM32MP_SPI_NAND} != 1 ] && \
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200360 [ ${STM32MP_SPI_NOR} != 1 ] && \
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200361 [ ${STM32MP_UART_PROGRAMMER} != 1 ] && \
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200362 [ ${STM32MP_USB_PROGRAMMER} != 1 ]; then \
Yann Gautiercc785d82020-11-09 11:16:10 +0100363 echo "No boot device driver is enabled"; \
364 false; \
365 fi
366
Yann Gautier3f10a2f2020-09-18 10:21:29 +0200367stm32image: ${STM32IMAGE}
368
369${STM32IMAGE}: ${STM32IMAGE_SRC}
Yann Gautier761797d2018-07-16 14:34:50 +0200370 ${Q}${MAKE} CPPFLAGS="" --no-print-directory -C ${STM32IMAGEPATH}
371
372clean_stm32image:
373 ${Q}${MAKE} --no-print-directory -C ${STM32IMAGEPATH} clean
374
375check_dtc_version:
Yann Gautier761797d2018-07-16 14:34:50 +0200376 @if [ ${DTC_VERSION} -lt 10404 ]; then \
377 echo "dtc version too old (${DTC_V}), you need at least version 1.4.4"; \
378 false; \
379 fi
380
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200381ifeq ($(STM32MP_USE_STM32IMAGE)-$(AARCH32_SP),1-sp_min)
Yann Gautier46f8e672020-09-18 10:32:37 +0200382${BUILD_PLAT}/stm32mp1-%.o: ${BUILD_PLAT}/fdts/%.dtb plat/st/stm32mp1/stm32mp1.S bl2 ${BL32_DEP}
383 @echo " AS stm32mp1.S"
384 ${Q}${AS} ${ASFLAGS} ${TF_CFLAGS} \
385 -DDTB_BIN_PATH=\"$<\" \
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200386 -c $(word 2,$^) -o $@
387else
388# Create DTB file for BL2
389${BUILD_PLAT}/fdts/%-bl2.dts: fdts/%.dts fdts/${BL2_DTSI} | ${BUILD_PLAT} fdt_dirs
390 @echo '#include "$(patsubst fdts/%,%,$<)"' > $@
391 @echo '#include "${BL2_DTSI}"' >> $@
392
393${BUILD_PLAT}/fdts/%-bl2.dtb: ${BUILD_PLAT}/fdts/%-bl2.dts
394
395ifeq ($(AARCH32_SP),sp_min)
396# Create DTB file for BL32
397${BUILD_PLAT}/fdts/%-bl32.dts: fdts/%.dts fdts/${BL32_DTSI} | ${BUILD_PLAT} fdt_dirs
398 @echo '#include "$(patsubst fdts/%,%,$<)"' > $@
399 @echo '#include "${BL32_DTSI}"' >> $@
400
401${BUILD_PLAT}/fdts/%-bl32.dtb: ${BUILD_PLAT}/fdts/%-bl32.dts
402endif
403
404${BUILD_PLAT}/stm32mp1-%.o: ${BUILD_PLAT}/fdts/%-bl2.dtb plat/st/stm32mp1/stm32mp1.S bl2
405 @echo " AS stm32mp1.S"
406 ${Q}${AS} ${ASFLAGS} ${TF_CFLAGS} \
407 -DDTB_BIN_PATH=\"$<\" \
Yann Gautier46f8e672020-09-18 10:32:37 +0200408 -c plat/st/stm32mp1/stm32mp1.S -o $@
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200409endif
Yann Gautier761797d2018-07-16 14:34:50 +0200410
Yann Gautier3ab157a2021-10-07 14:19:48 +0200411$(eval $(call MAKE_LD,${STM32_TF_LINKERFILE},plat/st/stm32mp1/stm32mp1.ld.S,bl2))
Yann Gautier761797d2018-07-16 14:34:50 +0200412
Yann Gautier46f8e672020-09-18 10:32:37 +0200413tf-a-%.elf: stm32mp1-%.o ${STM32_TF_LINKERFILE}
414 @echo " LDS $<"
415 ${Q}${LD} -o $@ ${STM32_TF_ELF_LDFLAGS} -Map=$(@:.elf=.map) --script ${STM32_TF_LINKERFILE} $<
Yann Gautier761797d2018-07-16 14:34:50 +0200416
Yann Gautier46f8e672020-09-18 10:32:37 +0200417tf-a-%.bin: tf-a-%.elf
418 ${Q}${OC} -O binary $< $@
419 @echo
420 @echo "Built $@ successfully"
421 @echo
Yann Gautier761797d2018-07-16 14:34:50 +0200422
Yann Gautier46f8e672020-09-18 10:32:37 +0200423tf-a-%.stm32: ${STM32IMAGE} tf-a-%.bin
424 @echo
425 @echo "Generate $@"
426 $(eval LOADADDR = $(shell cat $(@:.stm32=.map) | grep RAM | awk '{print $$2}'))
427 $(eval ENTRY = $(shell cat $(@:.stm32=.map) | grep "__BL2_IMAGE_START" | awk '{print $$1}'))
428 ${Q}${STM32IMAGE} -s $(word 2,$^) -d $@ \
429 -l $(LOADADDR) -e ${ENTRY} \
430 -v ${STM32_TF_VERSION}
431 @echo