blob: a8905341d5b8c36a00f8e54446e487c90aa4549d [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 Gautier0c0e1032021-04-01 19:31:46 +020027# Default Device tree
28DTB_FILE_NAME ?= stm32mp157c-ev1.dtb
29
30STM32MP13 ?= 0
31STM32MP15 ?= 0
32
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +010033ifeq ($(STM32MP13),1)
Yann Gautier0c0e1032021-04-01 19:31:46 +020034ifeq ($(STM32MP15),1)
35$(error Cannot enable both flags STM32MP13 and STM32MP15)
36endif
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +010037STM32MP13 := 1
38STM32MP15 := 0
Yann Gautier0c0e1032021-04-01 19:31:46 +020039else ifeq ($(STM32MP15),1)
40STM32MP13 := 0
41STM32MP15 := 1
42else ifneq ($(findstring stm32mp13,$(DTB_FILE_NAME)),)
43STM32MP13 := 1
44STM32MP15 := 0
45else ifneq ($(findstring stm32mp15,$(DTB_FILE_NAME)),)
46STM32MP13 := 0
47STM32MP15 := 1
48endif
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +010049
Yann Gautier0c0e1032021-04-01 19:31:46 +020050ifeq ($(STM32MP13),1)
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +010051# DDR controller with single AXI port and 16-bit interface
52STM32MP_DDR_DUAL_AXI_PORT:= 0
53STM32MP_DDR_32BIT_INTERFACE:= 0
54
55# STM32 image header version v2.0
56STM32_HEADER_VERSION_MAJOR:= 2
57STM32_HEADER_VERSION_MINOR:= 0
Yann Gautier0c0e1032021-04-01 19:31:46 +020058endif
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +010059
Yann Gautier0c0e1032021-04-01 19:31:46 +020060ifeq ($(STM32MP15),1)
Yann Gautier6d8c2442020-09-17 12:42:46 +020061# DDR controller with dual AXI port and 32-bit interface
62STM32MP_DDR_DUAL_AXI_PORT:= 1
63STM32MP_DDR_32BIT_INTERFACE:= 1
64
Nicolas Le Bayondfa46cc2019-11-18 17:13:42 +010065# STM32 image header version v1.0
66STM32_HEADER_VERSION_MAJOR:= 1
67STM32_HEADER_VERSION_MINOR:= 0
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +010068endif
Nicolas Le Bayondfa46cc2019-11-18 17:13:42 +010069
70# STM32 image header binary type for BL2
71STM32_HEADER_BL2_BINARY_TYPE:= 0x10
72
Etienne Carriereca651fb2020-04-10 18:51:54 +020073ifeq ($(AARCH32_SP),sp_min)
74# Disable Neon support: sp_min runtime may conflict with non-secure world
Yann Gautier46f8e672020-09-18 10:32:37 +020075TF_CFLAGS += -mfloat-abi=soft
Etienne Carriereca651fb2020-04-10 18:51:54 +020076endif
77
Yann Gautier19cdaa82020-11-10 15:09:55 +010078TF_CFLAGS += -Wsign-compare
Yann Gautier3c7be342022-02-14 10:30:33 +010079TF_CFLAGS += -Wformat-signedness
Yann Gautier19cdaa82020-11-10 15:09:55 +010080
Yann Gautier4b0c72a2018-07-16 10:54:09 +020081# Not needed for Cortex-A7
82WORKAROUND_CVE_2017_5715:= 0
Bipin Ravicaa2e052022-02-23 23:45:50 -060083WORKAROUND_CVE_2022_23960:= 0
Yann Gautier4b0c72a2018-07-16 10:54:09 +020084
Sughosh Ganua1976842021-11-10 17:47:16 +053085ifeq (${PSA_FWU_SUPPORT},1)
86ifneq (${STM32MP_USE_STM32IMAGE},1)
87# Number of banks of updatable firmware
88NR_OF_FW_BANKS := 2
89NR_OF_IMAGES_IN_FW_BANK := 1
90
Yann Gautier8244e1d2018-10-15 09:36:58 +020091# Number of TF-A copies in the device
92STM32_TF_A_COPIES := 2
Sughosh Ganua1976842021-11-10 17:47:16 +053093STM32_BL33_PARTS_NUM := 2
94STM32_RUNTIME_PARTS_NUM := 4
95else
96$(error FWU Feature enabled only with FIP images)
97endif
98else
99# Number of TF-A copies in the device
100STM32_TF_A_COPIES := 2
Yann Gautier6916a442020-09-17 12:28:12 +0200101STM32_BL33_PARTS_NUM := 1
Yann Gautierb3386f72019-04-19 09:41:01 +0200102ifeq ($(AARCH32_SP),optee)
Yann Gautier6916a442020-09-17 12:28:12 +0200103STM32_RUNTIME_PARTS_NUM := 3
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200104else ifeq ($(STM32MP_USE_STM32IMAGE),1)
Yann Gautier6916a442020-09-17 12:28:12 +0200105STM32_RUNTIME_PARTS_NUM := 0
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200106else
107STM32_RUNTIME_PARTS_NUM := 1
Yann Gautierb3386f72019-04-19 09:41:01 +0200108endif
Sughosh Ganua1976842021-11-10 17:47:16 +0530109endif
Yann Gautier6916a442020-09-17 12:28:12 +0200110PLAT_PARTITION_MAX_ENTRIES := $(shell echo $$(($(STM32_TF_A_COPIES) + \
111 $(STM32_BL33_PARTS_NUM) + \
112 $(STM32_RUNTIME_PARTS_NUM))))
Yann Gautier8244e1d2018-10-15 09:36:58 +0200113
Nicolas Le Bayon3f42cad2019-09-03 09:52:05 +0200114# Boot devices
115STM32MP_EMMC ?= 0
116STM32MP_SDMMC ?= 0
Lionel Debieve402a46b2019-11-04 12:28:15 +0100117STM32MP_RAW_NAND ?= 0
Lionel Debieve186b0462019-09-24 18:30:12 +0200118STM32MP_SPI_NAND ?= 0
Lionel Debievecb0dbc42019-09-25 09:11:31 +0200119STM32MP_SPI_NOR ?= 0
Vyacheslav Yurkove43a0802021-06-04 10:10:51 +0200120STM32MP_EMMC_BOOT ?= 0
Nicolas Le Bayon3f42cad2019-09-03 09:52:05 +0200121
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200122# Serial boot devices
123STM32MP_USB_PROGRAMMER ?= 0
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200124STM32MP_UART_PROGRAMMER ?= 0
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200125
Yann Gautier5f400632020-02-12 09:30:49 +0100126# Device tree
Yann Gautierf03dee52020-02-25 17:08:10 +0100127ifeq ($(STM32MP13),1)
Yann Gautierf03dee52020-02-25 17:08:10 +0100128BL2_DTSI := stm32mp13-bl2.dtsi
129FDT_SOURCES := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl2.dts,$(DTB_FILE_NAME)))
130else
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200131ifeq ($(STM32MP_USE_STM32IMAGE),1)
132ifeq ($(AARCH32_SP),optee)
133BL2_DTSI := stm32mp15-bl2.dtsi
134FDT_SOURCES := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl2.dts,$(DTB_FILE_NAME)))
135else
Yann Gautier5f400632020-02-12 09:30:49 +0100136FDT_SOURCES := $(addprefix fdts/, $(patsubst %.dtb,%.dts,$(DTB_FILE_NAME)))
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200137endif
138else
139BL2_DTSI := stm32mp15-bl2.dtsi
140FDT_SOURCES := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl2.dts,$(DTB_FILE_NAME)))
141ifeq ($(AARCH32_SP),sp_min)
142BL32_DTSI := stm32mp15-bl32.dtsi
143FDT_SOURCES += $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl32.dts,$(DTB_FILE_NAME)))
144endif
145endif
Yann Gautierf03dee52020-02-25 17:08:10 +0100146endif
Yann Gautierd82fca42021-03-09 10:42:02 +0100147
148$(eval DTC_V = $(shell $(DTC) -v | awk '{print $$NF}'))
Yann Gautier23ee3682022-03-28 13:37:01 +0200149$(eval DTC_VERSION = $(shell printf "%d" $(shell echo ${DTC_V} | cut -d- -f1 | sed "s/\./0/g" | grep -o [0-9]*)))
Yann Gautier658775c2021-07-06 10:00:44 +0200150DTC_CPPFLAGS += ${INCLUDES}
Yann Gautier5f400632020-02-12 09:30:49 +0100151DTC_FLAGS += -Wno-unit_address_vs_reg
Yann Gautierd82fca42021-03-09 10:42:02 +0100152ifeq ($(shell test $(DTC_VERSION) -ge 10601; echo $$?),0)
153DTC_FLAGS += -Wno-interrupt_provider
154endif
Yann Gautier5f400632020-02-12 09:30:49 +0100155
156# Macros and rules to build TF binary
157STM32_TF_ELF_LDFLAGS := --hash-style=gnu --as-needed
158STM32_TF_STM32 := $(addprefix ${BUILD_PLAT}/tf-a-, $(patsubst %.dtb,%.stm32,$(DTB_FILE_NAME)))
159STM32_TF_LINKERFILE := ${BUILD_PLAT}/stm32mp1.ld
160
161ASFLAGS += -DBL2_BIN_PATH=\"${BUILD_PLAT}/bl2.bin\"
162ifeq ($(AARCH32_SP),sp_min)
163# BL32 is built only if using SP_MIN
164BL32_DEP := bl32
165ASFLAGS += -DBL32_BIN_PATH=\"${BUILD_PLAT}/bl32.bin\"
166endif
167
168# Variables for use with stm32image
169STM32IMAGEPATH ?= tools/stm32image
170STM32IMAGE ?= ${STM32IMAGEPATH}/stm32image${BIN_EXT}
Yann Gautiere56f53f2021-06-09 09:36:35 +0200171STM32IMAGE_SRC := ${STM32IMAGEPATH}/stm32image.c
Yann Gautier5f400632020-02-12 09:30:49 +0100172
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200173ifneq (${STM32MP_USE_STM32IMAGE},1)
174FIP_DEPS += dtbs
175STM32MP_HW_CONFIG := ${BL33_CFG}
Yann Gautier658775c2021-07-06 10:00:44 +0200176STM32MP_FW_CONFIG_NAME := $(patsubst %.dtb,%-fw-config.dtb,$(DTB_FILE_NAME))
177STM32MP_FW_CONFIG := ${BUILD_PLAT}/fdts/$(STM32MP_FW_CONFIG_NAME)
178ifneq (${AARCH32_SP},none)
179FDT_SOURCES += $(addprefix fdts/, $(patsubst %.dtb,%.dts,$(STM32MP_FW_CONFIG_NAME)))
180endif
181# Add the FW_CONFIG to FIP and specify the same to certtool
182$(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_FW_CONFIG},--fw-config))
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200183# Add the HW_CONFIG to FIP and specify the same to certtool
184$(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_HW_CONFIG},--hw-config))
185ifeq ($(AARCH32_SP),sp_min)
186STM32MP_TOS_FW_CONFIG := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl32.dtb,$(DTB_FILE_NAME)))
187$(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_TOS_FW_CONFIG},--tos-fw-config))
188else
189# Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images
190# in the FIP if the platform requires.
191ifneq ($(BL32_EXTRA1),)
192$(eval $(call TOOL_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1))
193endif
194ifneq ($(BL32_EXTRA2),)
195$(eval $(call TOOL_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2))
196endif
197endif
198endif
199
Yann Gautier5f400632020-02-12 09:30:49 +0100200# Enable flags for C files
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -0500201$(eval $(call assert_booleans,\
Yann Gautier5f400632020-02-12 09:30:49 +0100202 $(sort \
Yann Gautier27f589d2021-10-15 17:59:38 +0200203 PLAT_XLAT_TABLES_DYNAMIC \
Yann Gautier6d8c2442020-09-17 12:42:46 +0200204 STM32MP_DDR_32BIT_INTERFACE \
205 STM32MP_DDR_DUAL_AXI_PORT \
Yann Gautierd1435742021-10-18 10:55:23 +0200206 STM32MP_EARLY_CONSOLE \
Yann Gautier5f400632020-02-12 09:30:49 +0100207 STM32MP_EMMC \
Yann Gautier27f589d2021-10-15 17:59:38 +0200208 STM32MP_EMMC_BOOT \
Yann Gautier5f400632020-02-12 09:30:49 +0100209 STM32MP_RAW_NAND \
Yann Gautier27f589d2021-10-15 17:59:38 +0200210 STM32MP_SDMMC \
Yann Gautier5f400632020-02-12 09:30:49 +0100211 STM32MP_SPI_NAND \
212 STM32MP_SPI_NOR \
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200213 STM32MP_UART_PROGRAMMER \
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200214 STM32MP_USB_PROGRAMMER \
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200215 STM32MP_USE_STM32IMAGE \
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +0100216 STM32MP13 \
217 STM32MP15 \
Yann Gautier5f400632020-02-12 09:30:49 +0100218)))
219
220$(eval $(call assert_numerics,\
221 $(sort \
Yann Gautier5f400632020-02-12 09:30:49 +0100222 PLAT_PARTITION_MAX_ENTRIES \
Yann Gautier27f589d2021-10-15 17:59:38 +0200223 STM32_TF_A_COPIES \
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200224 STM32_TF_VERSION \
Yann Gautierb02dd492022-03-02 14:31:55 +0100225 STM32MP_UART_BAUDRATE \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -0500226)))
227
228$(eval $(call add_defines,\
Yann Gautier5f400632020-02-12 09:30:49 +0100229 $(sort \
Yann Gautier27f589d2021-10-15 17:59:38 +0200230 PLAT_PARTITION_MAX_ENTRIES \
231 PLAT_XLAT_TABLES_DYNAMIC \
232 STM32_TF_A_COPIES \
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200233 STM32_TF_VERSION \
Yann Gautier6d8c2442020-09-17 12:42:46 +0200234 STM32MP_DDR_32BIT_INTERFACE \
235 STM32MP_DDR_DUAL_AXI_PORT \
Yann Gautierd1435742021-10-18 10:55:23 +0200236 STM32MP_EARLY_CONSOLE \
Yann Gautier5f400632020-02-12 09:30:49 +0100237 STM32MP_EMMC \
Yann Gautier27f589d2021-10-15 17:59:38 +0200238 STM32MP_EMMC_BOOT \
Yann Gautier5f400632020-02-12 09:30:49 +0100239 STM32MP_RAW_NAND \
Yann Gautier27f589d2021-10-15 17:59:38 +0200240 STM32MP_SDMMC \
Yann Gautier5f400632020-02-12 09:30:49 +0100241 STM32MP_SPI_NAND \
242 STM32MP_SPI_NOR \
Yann Gautierb02dd492022-03-02 14:31:55 +0100243 STM32MP_UART_BAUDRATE \
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200244 STM32MP_UART_PROGRAMMER \
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200245 STM32MP_USB_PROGRAMMER \
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200246 STM32MP_USE_STM32IMAGE \
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +0100247 STM32MP13 \
248 STM32MP15 \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -0500249)))
Nicolas Le Bayon3f42cad2019-09-03 09:52:05 +0200250
Yann Gautier5f400632020-02-12 09:30:49 +0100251# Include paths and source files
Yann Gautieree8f5422019-02-14 11:13:25 +0100252PLAT_INCLUDES := -Iplat/st/common/include/
253PLAT_INCLUDES += -Iplat/st/stm32mp1/include/
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200254
Yann Gautier0dc92312021-10-29 17:04:17 +0200255ifeq (${STM32MP_USE_STM32IMAGE},1)
Chris Kaye9272152021-09-28 15:52:14 +0100256include common/fdt_wrappers.mk
Yann Gautier0dc92312021-10-29 17:04:17 +0200257else
258include lib/fconf/fconf.mk
259endif
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200260include lib/libfdt/libfdt.mk
261
Chris Kaye9272152021-09-28 15:52:14 +0100262PLAT_BL_COMMON_SOURCES := common/uuid.c \
Andre Przywaracc99f3f2020-03-26 12:51:21 +0000263 plat/st/common/stm32mp_common.c \
Yann Gautieree8f5422019-02-14 11:13:25 +0100264 plat/st/stm32mp1/stm32mp1_private.c
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200265
Julius Werner6b88b652018-11-27 17:50:28 -0800266PLAT_BL_COMMON_SOURCES += drivers/st/uart/aarch32/stm32_console.S
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200267
268ifneq (${ENABLE_STACK_PROTECTOR},0)
269PLAT_BL_COMMON_SOURCES += plat/st/stm32mp1/stm32mp1_stack_protector.c
270endif
271
272include lib/xlat_tables_v2/xlat_tables.mk
273PLAT_BL_COMMON_SOURCES += ${XLAT_TABLES_LIB_SRCS}
274
275PLAT_BL_COMMON_SOURCES += lib/cpus/aarch32/cortex_a7.S
276
Yann Gautier2c1fa282019-05-09 11:56:30 +0200277PLAT_BL_COMMON_SOURCES += drivers/arm/tzc/tzc400.c \
Gabriel Fernandez8aac3072020-10-13 09:36:25 +0200278 drivers/clk/clk.c \
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200279 drivers/delay_timer/delay_timer.c \
280 drivers/delay_timer/generic_delay_timer.c \
Nicolas Le Bayon97287cd2019-05-20 18:35:02 +0200281 drivers/st/bsec/bsec2.c \
Yann Gautier4d429472019-02-14 11:15:20 +0100282 drivers/st/clk/stm32mp_clkfunc.c \
Nicolas Le Bayon8ce825f2021-05-18 10:01:30 +0200283 drivers/st/ddr/stm32mp_ddr.c \
Yann Gautiercaf575b2018-07-24 17:18:19 +0200284 drivers/st/ddr/stm32mp1_ddr_helpers.c \
Yann Gautierd0ca7f42018-07-13 21:33:09 +0200285 drivers/st/gpio/stm32_gpio.c \
Yann Gautier113f31e2019-01-17 09:34:18 +0100286 drivers/st/i2c/stm32_i2c.c \
Yann Gautier091eab52019-06-04 18:06:34 +0200287 drivers/st/iwdg/stm32_iwdg.c \
Yann Gautiera45433b2019-01-16 18:31:00 +0100288 drivers/st/pmic/stm32mp_pmic.c \
289 drivers/st/pmic/stpmic1.c \
Yann Gautierb1279e72021-12-15 13:16:15 +0100290 drivers/st/regulator/regulator_core.c \
Pascal Pailletfc7b8052021-01-29 14:48:49 +0100291 drivers/st/regulator/regulator_fixed.c \
Yann Gautier9aea69e2018-07-24 17:13:36 +0200292 drivers/st/reset/stm32mp1_reset.c \
Yann Gautieree8f5422019-02-14 11:13:25 +0100293 plat/st/common/stm32mp_dt.c \
Yann Gautier091eab52019-06-04 18:06:34 +0200294 plat/st/stm32mp1/stm32mp1_dbgmcu.c \
Yann Gautiercaf575b2018-07-24 17:18:19 +0200295 plat/st/stm32mp1/stm32mp1_helper.S \
Yann Gautier3edc7c32019-05-20 19:17:08 +0200296 plat/st/stm32mp1/stm32mp1_syscfg.c
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200297
Gabriel Fernandez1308d752020-03-11 11:30:34 +0100298ifeq ($(STM32MP13),1)
299PLAT_BL_COMMON_SOURCES += drivers/st/clk/clk-stm32-core.c \
300 drivers/st/clk/clk-stm32mp13.c
301else
302PLAT_BL_COMMON_SOURCES += drivers/st/clk/stm32mp1_clk.c
303endif
304
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200305ifneq (${STM32MP_USE_STM32IMAGE},1)
Yann Gautier0dc92312021-10-29 17:04:17 +0200306BL2_SOURCES += ${FCONF_SOURCES} ${FCONF_DYN_SOURCES}
307
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200308BL2_SOURCES += drivers/io/io_fip.c \
309 plat/st/common/bl2_io_storage.c \
Yann Gautier29f1f942021-07-13 18:07:41 +0200310 plat/st/common/stm32mp_fconf_io.c \
Lionel Debieve1dc5e2e2020-09-27 21:13:53 +0200311 plat/st/stm32mp1/plat_bl2_mem_params_desc.c \
312 plat/st/stm32mp1/stm32mp1_fconf_firewall.c
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200313else
Yann Gautier0dc92312021-10-29 17:04:17 +0200314BL2_SOURCES += ${FDT_WRAPPERS_SOURCES}
315
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200316BL2_SOURCES += drivers/io/io_dummy.c \
317 drivers/st/io/io_stm32image.c \
318 plat/st/common/bl2_stm32_io_storage.c \
Lionel Debieve1dc5e2e2020-09-27 21:13:53 +0200319 plat/st/stm32mp1/plat_bl2_stm32_mem_params_desc.c \
320 plat/st/stm32mp1/stm32mp1_security.c
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200321endif
322
Sughosh Ganua1976842021-11-10 17:47:16 +0530323ifeq (${PSA_FWU_SUPPORT},1)
324include lib/zlib/zlib.mk
325include drivers/fwu/fwu.mk
326
327BL2_SOURCES += $(ZLIB_SOURCES)
328endif
329
Yann Gautier8244e1d2018-10-15 09:36:58 +0200330BL2_SOURCES += drivers/io/io_block.c \
Lionel Debieve402a46b2019-11-04 12:28:15 +0100331 drivers/io/io_mtd.c \
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200332 drivers/io/io_storage.c \
Lionel Debieve7bd96f42019-09-03 12:22:23 +0200333 drivers/st/crypto/stm32_hash.c \
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200334 plat/st/stm32mp1/bl2_plat_setup.c
335
Yann Gautiercc5f89a2020-02-12 09:36:23 +0100336
337ifeq ($(STM32MP15),1)
338BL2_SOURCES += plat/st/common/stm32mp_auth.c
339endif
340
Nicolas Le Bayon3f42cad2019-09-03 09:52:05 +0200341ifneq ($(filter 1,${STM32MP_EMMC} ${STM32MP_SDMMC}),)
Yann Gautier8244e1d2018-10-15 09:36:58 +0200342BL2_SOURCES += drivers/mmc/mmc.c \
343 drivers/partition/gpt.c \
344 drivers/partition/partition.c \
345 drivers/st/io/io_mmc.c \
346 drivers/st/mmc/stm32_sdmmc2.c
Nicolas Le Bayon3f42cad2019-09-03 09:52:05 +0200347endif
Yann Gautier8244e1d2018-10-15 09:36:58 +0200348
Lionel Debieve402a46b2019-11-04 12:28:15 +0100349ifeq (${STM32MP_RAW_NAND},1)
350$(eval $(call add_define_val,NAND_ONFI_DETECT,1))
351BL2_SOURCES += drivers/mtd/nand/raw_nand.c \
352 drivers/st/fmc/stm32_fmc2_nand.c
353endif
354
Lionel Debieve186b0462019-09-24 18:30:12 +0200355ifeq (${STM32MP_SPI_NAND},1)
356BL2_SOURCES += drivers/mtd/nand/spi_nand.c
357endif
358
Lionel Debievecb0dbc42019-09-25 09:11:31 +0200359ifeq (${STM32MP_SPI_NOR},1)
360BL2_SOURCES += drivers/mtd/nor/spi_nor.c
361endif
362
363ifneq ($(filter 1,${STM32MP_SPI_NAND} ${STM32MP_SPI_NOR}),)
Lionel Debieve186b0462019-09-24 18:30:12 +0200364BL2_SOURCES += drivers/mtd/spi-mem/spi_mem.c \
365 drivers/st/spi/stm32_qspi.c
366endif
367
368ifneq ($(filter 1,${STM32MP_RAW_NAND} ${STM32MP_SPI_NAND}),)
Lionel Debievecb0dbc42019-09-25 09:11:31 +0200369BL2_SOURCES += drivers/mtd/nand/core.c
370endif
371
372ifneq ($(filter 1,${STM32MP_RAW_NAND} ${STM32MP_SPI_NAND} ${STM32MP_SPI_NOR}),)
373BL2_SOURCES += plat/st/stm32mp1/stm32mp1_boot_device.c
Lionel Debieve402a46b2019-11-04 12:28:15 +0100374endif
375
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200376ifneq ($(filter 1,${STM32MP_UART_PROGRAMMER} ${STM32MP_USB_PROGRAMMER}),)
377BL2_SOURCES += drivers/io/io_memmap.c
378endif
379
380ifeq (${STM32MP_UART_PROGRAMMER},1)
381BL2_SOURCES += drivers/st/uart/stm32_uart.c \
382 plat/st/common/stm32cubeprogrammer_uart.c
383endif
384
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200385ifeq (${STM32MP_USB_PROGRAMMER},1)
386#The DFU stack uses only one end point, reduce the USB stack footprint
387$(eval $(call add_define_val,CONFIG_USBD_EP_NB,1U))
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200388BL2_SOURCES += drivers/st/usb/stm32mp1_usb.c \
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200389 drivers/usb/usb_device.c \
390 plat/st/common/stm32cubeprogrammer_usb.c \
391 plat/st/common/usb_dfu.c \
392 plat/st/stm32mp1/stm32mp1_usb_dfu.c
393endif
394
Nicolas Le Bayon620ce332021-03-02 11:19:36 +0100395BL2_SOURCES += drivers/st/ddr/stm32mp_ddr_test.c \
396 drivers/st/ddr/stm32mp_ram.c \
Nicolas Le Bayon8ce825f2021-05-18 10:01:30 +0200397 drivers/st/ddr/stm32mp1_ddr.c \
Yann Gautiercaf575b2018-07-24 17:18:19 +0200398 drivers/st/ddr/stm32mp1_ram.c
399
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200400BL2_SOURCES += common/desc_image_load.c \
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200401 plat/st/stm32mp1/plat_image_load.c
402
Yann Gautierb3386f72019-04-19 09:41:01 +0200403BL2_SOURCES += lib/optee/optee_utils.c
Yann Gautierb3386f72019-04-19 09:41:01 +0200404
Yann Gautier5f400632020-02-12 09:30:49 +0100405# Compilation rules
Yann Gautiercc785d82020-11-09 11:16:10 +0100406.PHONY: check_dtc_version stm32image clean_stm32image check_boot_device
Yann Gautier761797d2018-07-16 14:34:50 +0200407.SUFFIXES:
408
Yann Gautier3f10a2f2020-09-18 10:21:29 +0200409all: check_dtc_version stm32image ${STM32_TF_STM32}
Yann Gautier761797d2018-07-16 14:34:50 +0200410
Yann Gautier761797d2018-07-16 14:34:50 +0200411distclean realclean clean: clean_stm32image
412
Yann Gautiercc785d82020-11-09 11:16:10 +0100413bl2: check_boot_device
414
415check_boot_device:
416 @if [ ${STM32MP_EMMC} != 1 ] && \
417 [ ${STM32MP_SDMMC} != 1 ] && \
418 [ ${STM32MP_RAW_NAND} != 1 ] && \
419 [ ${STM32MP_SPI_NAND} != 1 ] && \
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200420 [ ${STM32MP_SPI_NOR} != 1 ] && \
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200421 [ ${STM32MP_UART_PROGRAMMER} != 1 ] && \
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200422 [ ${STM32MP_USB_PROGRAMMER} != 1 ]; then \
Yann Gautiercc785d82020-11-09 11:16:10 +0100423 echo "No boot device driver is enabled"; \
424 false; \
425 fi
426
Yann Gautier3f10a2f2020-09-18 10:21:29 +0200427stm32image: ${STM32IMAGE}
428
429${STM32IMAGE}: ${STM32IMAGE_SRC}
Yann Gautier761797d2018-07-16 14:34:50 +0200430 ${Q}${MAKE} CPPFLAGS="" --no-print-directory -C ${STM32IMAGEPATH}
431
432clean_stm32image:
433 ${Q}${MAKE} --no-print-directory -C ${STM32IMAGEPATH} clean
434
435check_dtc_version:
Yann Gautier761797d2018-07-16 14:34:50 +0200436 @if [ ${DTC_VERSION} -lt 10404 ]; then \
437 echo "dtc version too old (${DTC_V}), you need at least version 1.4.4"; \
438 false; \
439 fi
440
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200441ifeq ($(STM32MP_USE_STM32IMAGE)-$(AARCH32_SP),1-sp_min)
Yann Gautier46f8e672020-09-18 10:32:37 +0200442${BUILD_PLAT}/stm32mp1-%.o: ${BUILD_PLAT}/fdts/%.dtb plat/st/stm32mp1/stm32mp1.S bl2 ${BL32_DEP}
443 @echo " AS stm32mp1.S"
444 ${Q}${AS} ${ASFLAGS} ${TF_CFLAGS} \
445 -DDTB_BIN_PATH=\"$<\" \
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200446 -c $(word 2,$^) -o $@
447else
448# Create DTB file for BL2
449${BUILD_PLAT}/fdts/%-bl2.dts: fdts/%.dts fdts/${BL2_DTSI} | ${BUILD_PLAT} fdt_dirs
450 @echo '#include "$(patsubst fdts/%,%,$<)"' > $@
451 @echo '#include "${BL2_DTSI}"' >> $@
452
453${BUILD_PLAT}/fdts/%-bl2.dtb: ${BUILD_PLAT}/fdts/%-bl2.dts
454
455ifeq ($(AARCH32_SP),sp_min)
456# Create DTB file for BL32
457${BUILD_PLAT}/fdts/%-bl32.dts: fdts/%.dts fdts/${BL32_DTSI} | ${BUILD_PLAT} fdt_dirs
458 @echo '#include "$(patsubst fdts/%,%,$<)"' > $@
459 @echo '#include "${BL32_DTSI}"' >> $@
460
461${BUILD_PLAT}/fdts/%-bl32.dtb: ${BUILD_PLAT}/fdts/%-bl32.dts
462endif
463
464${BUILD_PLAT}/stm32mp1-%.o: ${BUILD_PLAT}/fdts/%-bl2.dtb plat/st/stm32mp1/stm32mp1.S bl2
465 @echo " AS stm32mp1.S"
466 ${Q}${AS} ${ASFLAGS} ${TF_CFLAGS} \
467 -DDTB_BIN_PATH=\"$<\" \
Yann Gautier46f8e672020-09-18 10:32:37 +0200468 -c plat/st/stm32mp1/stm32mp1.S -o $@
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200469endif
Yann Gautier761797d2018-07-16 14:34:50 +0200470
Yann Gautier3ab157a2021-10-07 14:19:48 +0200471$(eval $(call MAKE_LD,${STM32_TF_LINKERFILE},plat/st/stm32mp1/stm32mp1.ld.S,bl2))
Yann Gautier761797d2018-07-16 14:34:50 +0200472
Yann Gautier46f8e672020-09-18 10:32:37 +0200473tf-a-%.elf: stm32mp1-%.o ${STM32_TF_LINKERFILE}
474 @echo " LDS $<"
475 ${Q}${LD} -o $@ ${STM32_TF_ELF_LDFLAGS} -Map=$(@:.elf=.map) --script ${STM32_TF_LINKERFILE} $<
Yann Gautier761797d2018-07-16 14:34:50 +0200476
Yann Gautier46f8e672020-09-18 10:32:37 +0200477tf-a-%.bin: tf-a-%.elf
478 ${Q}${OC} -O binary $< $@
479 @echo
480 @echo "Built $@ successfully"
481 @echo
Yann Gautier761797d2018-07-16 14:34:50 +0200482
Yann Gautier46f8e672020-09-18 10:32:37 +0200483tf-a-%.stm32: ${STM32IMAGE} tf-a-%.bin
484 @echo
485 @echo "Generate $@"
486 $(eval LOADADDR = $(shell cat $(@:.stm32=.map) | grep RAM | awk '{print $$2}'))
487 $(eval ENTRY = $(shell cat $(@:.stm32=.map) | grep "__BL2_IMAGE_START" | awk '{print $$1}'))
488 ${Q}${STM32IMAGE} -s $(word 2,$^) -d $@ \
489 -l $(LOADADDR) -e ${ENTRY} \
Nicolas Le Bayondfa46cc2019-11-18 17:13:42 +0100490 -v ${STM32_TF_VERSION} \
491 -m ${STM32_HEADER_VERSION_MAJOR} \
492 -n ${STM32_HEADER_VERSION_MINOR} \
493 -b ${STM32_HEADER_BL2_BINARY_TYPE}
Yann Gautier46f8e672020-09-18 10:32:37 +0200494 @echo