blob: 1d93983a8b8fba484384f629cb69d26abb8baa15 [file] [log] [blame]
Yann Gautier4b0c72a2018-07-16 10:54:09 +02001#
Govindraj Raja3191ac42023-01-23 13:11:12 +00002# Copyright (c) 2015-2023, ARM Limited and Contributors. All rights reserved.
Yann Gautier4b0c72a2018-07-16 10:54:09 +02003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
Yann Gautierdbe63ac2022-03-16 19:03:20 +01007include plat/st/common/common.mk
8
Yann Gautier4b0c72a2018-07-16 10:54:09 +02009ARM_CORTEX_A7 := yes
10ARM_WITH_NEON := yes
Yann Gautier4b0c72a2018-07-16 10:54:09 +020011USE_COHERENT_MEM := 0
12
Yann Gautier0c0e1032021-04-01 19:31:46 +020013# Default Device tree
14DTB_FILE_NAME ?= stm32mp157c-ev1.dtb
15
16STM32MP13 ?= 0
17STM32MP15 ?= 0
18
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +010019ifeq ($(STM32MP13),1)
Yann Gautier0c0e1032021-04-01 19:31:46 +020020ifeq ($(STM32MP15),1)
21$(error Cannot enable both flags STM32MP13 and STM32MP15)
22endif
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +010023STM32MP13 := 1
24STM32MP15 := 0
Yann Gautier0c0e1032021-04-01 19:31:46 +020025else ifeq ($(STM32MP15),1)
26STM32MP13 := 0
27STM32MP15 := 1
28else ifneq ($(findstring stm32mp13,$(DTB_FILE_NAME)),)
29STM32MP13 := 1
30STM32MP15 := 0
31else ifneq ($(findstring stm32mp15,$(DTB_FILE_NAME)),)
32STM32MP13 := 0
33STM32MP15 := 1
34endif
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +010035
Yann Gautier0c0e1032021-04-01 19:31:46 +020036ifeq ($(STM32MP13),1)
Lionel Debieve13a668d2022-10-05 16:47:03 +020037# Will use SRAM2 as mbedtls heap
38STM32MP_USE_EXTERNAL_HEAP := 1
39
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +010040# DDR controller with single AXI port and 16-bit interface
41STM32MP_DDR_DUAL_AXI_PORT:= 0
42STM32MP_DDR_32BIT_INTERFACE:= 0
43
Lionel Debieve13a668d2022-10-05 16:47:03 +020044ifeq (${TRUSTED_BOARD_BOOT},1)
45# PKA algo to include
46PKA_USE_NIST_P256 := 1
47PKA_USE_BRAINPOOL_P256T1:= 1
48endif
49
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +010050# STM32 image header version v2.0
51STM32_HEADER_VERSION_MAJOR:= 2
52STM32_HEADER_VERSION_MINOR:= 0
Yann Gautier0c0e1032021-04-01 19:31:46 +020053endif
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +010054
Yann Gautier0c0e1032021-04-01 19:31:46 +020055ifeq ($(STM32MP15),1)
Yann Gautier6d8c2442020-09-17 12:42:46 +020056# DDR controller with dual AXI port and 32-bit interface
57STM32MP_DDR_DUAL_AXI_PORT:= 1
58STM32MP_DDR_32BIT_INTERFACE:= 1
59
Nicolas Le Bayondfa46cc2019-11-18 17:13:42 +010060# STM32 image header version v1.0
61STM32_HEADER_VERSION_MAJOR:= 1
62STM32_HEADER_VERSION_MINOR:= 0
Yann Gautierbc9f0fd2022-06-30 11:33:27 +020063
64# Add OP-TEE reserved shared memory area in mapping
65STM32MP15_OPTEE_RSV_SHM := 1
66$(eval $(call add_defines,STM32MP15_OPTEE_RSV_SHM))
Lionel Debievefd02b802022-10-05 16:16:50 +020067
68STM32MP_CRYPTO_ROM_LIB := 1
Lionel Debieve5adcd502022-10-05 16:51:12 +020069
70# Decryption support
71ifneq ($(DECRYPTION_SUPPORT),none)
72$(error "DECRYPTION_SUPPORT not supported on STM32MP15")
73endif
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +010074endif
Nicolas Le Bayondfa46cc2019-11-18 17:13:42 +010075
Etienne Carriereca651fb2020-04-10 18:51:54 +020076ifeq ($(AARCH32_SP),sp_min)
77# Disable Neon support: sp_min runtime may conflict with non-secure world
Yann Gautier46f8e672020-09-18 10:32:37 +020078TF_CFLAGS += -mfloat-abi=soft
Etienne Carriereca651fb2020-04-10 18:51:54 +020079endif
80
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
Yann Gautierc7465912022-06-30 15:21:19 +020085# Number of TF-A copies in the device
86STM32_TF_A_COPIES := 2
87
88# PLAT_PARTITION_MAX_ENTRIES must take care of STM32_TF-A_COPIES and other partitions
89# such as metadata (2) to find all the FIP partitions (default is 2).
90PLAT_PARTITION_MAX_ENTRIES := $(shell echo $$(($(STM32_TF_A_COPIES) + 4)))
91
Sughosh Ganua1976842021-11-10 17:47:16 +053092ifeq (${PSA_FWU_SUPPORT},1)
Sughosh Ganua1976842021-11-10 17:47:16 +053093# Number of banks of updatable firmware
94NR_OF_FW_BANKS := 2
95NR_OF_IMAGES_IN_FW_BANK := 1
96
Yann Gautierc7465912022-06-30 15:21:19 +020097FWU_MAX_PART = $(shell echo $$(($(STM32_TF_A_COPIES) + 2 + $(NR_OF_FW_BANKS))))
98ifeq ($(shell test $(FWU_MAX_PART) -gt $(PLAT_PARTITION_MAX_ENTRIES); echo $$?),0)
99$(error "Required partition number is $(FWU_MAX_PART) where PLAT_PARTITION_MAX_ENTRIES is only \
100$(PLAT_PARTITION_MAX_ENTRIES)")
Sughosh Ganua1976842021-11-10 17:47:16 +0530101endif
Sughosh Ganua1976842021-11-10 17:47:16 +0530102endif
Yann Gautier8244e1d2018-10-15 09:36:58 +0200103
Nicolas Toromanoff5d3ade02020-12-22 13:54:51 +0100104ifeq ($(STM32MP13),1)
105STM32_HASH_VER := 4
Nicolas Le Bayon5c66fab2020-12-02 16:23:49 +0100106STM32_RNG_VER := 4
Nicolas Toromanoff5d3ade02020-12-22 13:54:51 +0100107else # Assuming STM32MP15
108STM32_HASH_VER := 2
Nicolas Le Bayon5c66fab2020-12-02 16:23:49 +0100109STM32_RNG_VER := 2
Nicolas Toromanoff5d3ade02020-12-22 13:54:51 +0100110endif
111
Patrick Delaunay4c66e0a2022-03-15 11:20:56 +0100112# Download load address for serial boot devices
113DWL_BUFFER_BASE ?= 0xC7000000
114
Yann Gautier5f400632020-02-12 09:30:49 +0100115# Device tree
Yann Gautierf03dee52020-02-25 17:08:10 +0100116ifeq ($(STM32MP13),1)
Yann Gautierf03dee52020-02-25 17:08:10 +0100117BL2_DTSI := stm32mp13-bl2.dtsi
118FDT_SOURCES := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl2.dts,$(DTB_FILE_NAME)))
119else
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200120BL2_DTSI := stm32mp15-bl2.dtsi
121FDT_SOURCES := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl2.dts,$(DTB_FILE_NAME)))
122ifeq ($(AARCH32_SP),sp_min)
123BL32_DTSI := stm32mp15-bl32.dtsi
124FDT_SOURCES += $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl32.dts,$(DTB_FILE_NAME)))
125endif
Yann Gautierd82fca42021-03-09 10:42:02 +0100126endif
Yann Gautier5f400632020-02-12 09:30:49 +0100127
128# Macros and rules to build TF binary
Yann Gautier5f400632020-02-12 09:30:49 +0100129STM32_TF_STM32 := $(addprefix ${BUILD_PLAT}/tf-a-, $(patsubst %.dtb,%.stm32,$(DTB_FILE_NAME)))
Yann Gautierdbe63ac2022-03-16 19:03:20 +0100130STM32_LD_FILE := plat/st/stm32mp1/stm32mp1.ld.S
131STM32_BINARY_MAPPING := plat/st/stm32mp1/stm32mp1.S
Yann Gautier5f400632020-02-12 09:30:49 +0100132
Yann Gautier5f400632020-02-12 09:30:49 +0100133ifeq ($(AARCH32_SP),sp_min)
134# BL32 is built only if using SP_MIN
135BL32_DEP := bl32
136ASFLAGS += -DBL32_BIN_PATH=\"${BUILD_PLAT}/bl32.bin\"
137endif
138
Yann Gautier658775c2021-07-06 10:00:44 +0200139STM32MP_FW_CONFIG_NAME := $(patsubst %.dtb,%-fw-config.dtb,$(DTB_FILE_NAME))
140STM32MP_FW_CONFIG := ${BUILD_PLAT}/fdts/$(STM32MP_FW_CONFIG_NAME)
141ifneq (${AARCH32_SP},none)
142FDT_SOURCES += $(addprefix fdts/, $(patsubst %.dtb,%.dts,$(STM32MP_FW_CONFIG_NAME)))
143endif
144# Add the FW_CONFIG to FIP and specify the same to certtool
145$(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_FW_CONFIG},--fw-config))
Lionel Debieve13a668d2022-10-05 16:47:03 +0200146ifeq ($(GENERATE_COT),1)
147STM32MP_CFG_CERT := $(BUILD_PLAT)/stm32mp_cfg_cert.crt
148# Add the STM32MP_CFG_CERT to FIP and specify the same to certtool
149$(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_CFG_CERT},--stm32mp-cfg-cert))
150endif
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200151ifeq ($(AARCH32_SP),sp_min)
152STM32MP_TOS_FW_CONFIG := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl32.dtb,$(DTB_FILE_NAME)))
153$(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_TOS_FW_CONFIG},--tos-fw-config))
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200154endif
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200155
Yann Gautier5f400632020-02-12 09:30:49 +0100156# Enable flags for C files
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -0500157$(eval $(call assert_booleans,\
Yann Gautier5f400632020-02-12 09:30:49 +0100158 $(sort \
Lionel Debieve13a668d2022-10-05 16:47:03 +0200159 PKA_USE_BRAINPOOL_P256T1 \
160 PKA_USE_NIST_P256 \
161 PLAT_TBBR_IMG_DEF \
Lionel Debievefd02b802022-10-05 16:16:50 +0200162 STM32MP_CRYPTO_ROM_LIB \
Yann Gautier6d8c2442020-09-17 12:42:46 +0200163 STM32MP_DDR_32BIT_INTERFACE \
164 STM32MP_DDR_DUAL_AXI_PORT \
Lionel Debieve13a668d2022-10-05 16:47:03 +0200165 STM32MP_USE_EXTERNAL_HEAP \
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +0100166 STM32MP13 \
167 STM32MP15 \
Yann Gautier5f400632020-02-12 09:30:49 +0100168)))
169
170$(eval $(call assert_numerics,\
171 $(sort \
Yann Gautier5f400632020-02-12 09:30:49 +0100172 PLAT_PARTITION_MAX_ENTRIES \
Nicolas Toromanoff5d3ade02020-12-22 13:54:51 +0100173 STM32_HASH_VER \
Lionel Debieve13a668d2022-10-05 16:47:03 +0200174 STM32_HEADER_VERSION_MAJOR \
Nicolas Le Bayon5c66fab2020-12-02 16:23:49 +0100175 STM32_RNG_VER \
Yann Gautier27f589d2021-10-15 17:59:38 +0200176 STM32_TF_A_COPIES \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -0500177)))
178
179$(eval $(call add_defines,\
Yann Gautier5f400632020-02-12 09:30:49 +0100180 $(sort \
Patrick Delaunay4c66e0a2022-03-15 11:20:56 +0100181 DWL_BUFFER_BASE \
Lionel Debieve13a668d2022-10-05 16:47:03 +0200182 PKA_USE_BRAINPOOL_P256T1 \
183 PKA_USE_NIST_P256 \
Yann Gautier27f589d2021-10-15 17:59:38 +0200184 PLAT_PARTITION_MAX_ENTRIES \
Lionel Debieve13a668d2022-10-05 16:47:03 +0200185 PLAT_TBBR_IMG_DEF \
Nicolas Toromanoff5d3ade02020-12-22 13:54:51 +0100186 STM32_HASH_VER \
Lionel Debieve13a668d2022-10-05 16:47:03 +0200187 STM32_HEADER_VERSION_MAJOR \
Nicolas Le Bayon5c66fab2020-12-02 16:23:49 +0100188 STM32_RNG_VER \
Yann Gautier27f589d2021-10-15 17:59:38 +0200189 STM32_TF_A_COPIES \
Lionel Debievefd02b802022-10-05 16:16:50 +0200190 STM32MP_CRYPTO_ROM_LIB \
Yann Gautier6d8c2442020-09-17 12:42:46 +0200191 STM32MP_DDR_32BIT_INTERFACE \
192 STM32MP_DDR_DUAL_AXI_PORT \
Lionel Debieve13a668d2022-10-05 16:47:03 +0200193 STM32MP_USE_EXTERNAL_HEAP \
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +0100194 STM32MP13 \
195 STM32MP15 \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -0500196)))
Nicolas Le Bayon3f42cad2019-09-03 09:52:05 +0200197
Yann Gautier5f400632020-02-12 09:30:49 +0100198# Include paths and source files
Yann Gautieree8f5422019-02-14 11:13:25 +0100199PLAT_INCLUDES += -Iplat/st/stm32mp1/include/
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200200
Yann Gautierdbe63ac2022-03-16 19:03:20 +0100201PLAT_BL_COMMON_SOURCES += plat/st/stm32mp1/stm32mp1_private.c
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200202
Julius Werner6b88b652018-11-27 17:50:28 -0800203PLAT_BL_COMMON_SOURCES += drivers/st/uart/aarch32/stm32_console.S
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200204
205ifneq (${ENABLE_STACK_PROTECTOR},0)
206PLAT_BL_COMMON_SOURCES += plat/st/stm32mp1/stm32mp1_stack_protector.c
207endif
208
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200209PLAT_BL_COMMON_SOURCES += lib/cpus/aarch32/cortex_a7.S
210
Yann Gautier2c1fa282019-05-09 11:56:30 +0200211PLAT_BL_COMMON_SOURCES += drivers/arm/tzc/tzc400.c \
Nicolas Le Bayon97287cd2019-05-20 18:35:02 +0200212 drivers/st/bsec/bsec2.c \
Yann Gautiercaf575b2018-07-24 17:18:19 +0200213 drivers/st/ddr/stm32mp1_ddr_helpers.c \
Yann Gautier113f31e2019-01-17 09:34:18 +0100214 drivers/st/i2c/stm32_i2c.c \
Yann Gautier091eab52019-06-04 18:06:34 +0200215 drivers/st/iwdg/stm32_iwdg.c \
Yann Gautiera45433b2019-01-16 18:31:00 +0100216 drivers/st/pmic/stm32mp_pmic.c \
217 drivers/st/pmic/stpmic1.c \
Yann Gautier9aea69e2018-07-24 17:13:36 +0200218 drivers/st/reset/stm32mp1_reset.c \
Yann Gautier091eab52019-06-04 18:06:34 +0200219 plat/st/stm32mp1/stm32mp1_dbgmcu.c \
Yann Gautiercaf575b2018-07-24 17:18:19 +0200220 plat/st/stm32mp1/stm32mp1_helper.S \
Yann Gautier3edc7c32019-05-20 19:17:08 +0200221 plat/st/stm32mp1/stm32mp1_syscfg.c
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200222
Gabriel Fernandez1308d752020-03-11 11:30:34 +0100223ifeq ($(STM32MP13),1)
224PLAT_BL_COMMON_SOURCES += drivers/st/clk/clk-stm32-core.c \
Nicolas Le Bayon5c66fab2020-12-02 16:23:49 +0100225 drivers/st/clk/clk-stm32mp13.c \
226 drivers/st/crypto/stm32_rng.c
Gabriel Fernandez1308d752020-03-11 11:30:34 +0100227else
228PLAT_BL_COMMON_SOURCES += drivers/st/clk/stm32mp1_clk.c
229endif
230
Yann Gautierdbe63ac2022-03-16 19:03:20 +0100231BL2_SOURCES += plat/st/stm32mp1/plat_bl2_mem_params_desc.c \
Lionel Debieve1dc5e2e2020-09-27 21:13:53 +0200232 plat/st/stm32mp1/stm32mp1_fconf_firewall.c
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200233
Rohit Nerf9f72d92022-05-18 00:55:02 -0700234ifeq (${PSA_FWU_SUPPORT},1)
Sughosh Ganua1976842021-11-10 17:47:16 +0530235include drivers/fwu/fwu.mk
Rohit Nerf9f72d92022-05-18 00:55:02 -0700236endif
237
Yann Gautierdbe63ac2022-03-16 19:03:20 +0100238BL2_SOURCES += drivers/st/crypto/stm32_hash.c \
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200239 plat/st/stm32mp1/bl2_plat_setup.c
240
Lionel Debieve13a668d2022-10-05 16:47:03 +0200241ifeq (${TRUSTED_BOARD_BOOT},1)
Lionel Debieve13a668d2022-10-05 16:47:03 +0200242ifeq ($(STM32MP13),1)
Yann Gautierdbe63ac2022-03-16 19:03:20 +0100243BL2_SOURCES += drivers/st/crypto/stm32_pka.c
244BL2_SOURCES += drivers/st/crypto/stm32_saes.c
Lionel Debieve13a668d2022-10-05 16:47:03 +0200245endif
Lionel Debieve13a668d2022-10-05 16:47:03 +0200246endif
247
Nicolas Le Bayon3f42cad2019-09-03 09:52:05 +0200248ifneq ($(filter 1,${STM32MP_EMMC} ${STM32MP_SDMMC}),)
Yann Gautierdbe63ac2022-03-16 19:03:20 +0100249BL2_SOURCES += drivers/st/mmc/stm32_sdmmc2.c
Nicolas Le Bayon3f42cad2019-09-03 09:52:05 +0200250endif
Yann Gautier8244e1d2018-10-15 09:36:58 +0200251
Lionel Debieve402a46b2019-11-04 12:28:15 +0100252ifeq (${STM32MP_RAW_NAND},1)
Yann Gautierdbe63ac2022-03-16 19:03:20 +0100253BL2_SOURCES += drivers/st/fmc/stm32_fmc2_nand.c
Lionel Debieve186b0462019-09-24 18:30:12 +0200254endif
255
Lionel Debievecb0dbc42019-09-25 09:11:31 +0200256ifneq ($(filter 1,${STM32MP_SPI_NAND} ${STM32MP_SPI_NOR}),)
Yann Gautierdbe63ac2022-03-16 19:03:20 +0100257BL2_SOURCES += drivers/st/spi/stm32_qspi.c
Lionel Debievecb0dbc42019-09-25 09:11:31 +0200258endif
259
260ifneq ($(filter 1,${STM32MP_RAW_NAND} ${STM32MP_SPI_NAND} ${STM32MP_SPI_NOR}),)
261BL2_SOURCES += plat/st/stm32mp1/stm32mp1_boot_device.c
Lionel Debieve402a46b2019-11-04 12:28:15 +0100262endif
263
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200264ifeq (${STM32MP_UART_PROGRAMMER},1)
Yann Gautierdbe63ac2022-03-16 19:03:20 +0100265BL2_SOURCES += drivers/st/uart/stm32_uart.c
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200266endif
267
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200268ifeq (${STM32MP_USB_PROGRAMMER},1)
269#The DFU stack uses only one end point, reduce the USB stack footprint
270$(eval $(call add_define_val,CONFIG_USBD_EP_NB,1U))
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200271BL2_SOURCES += drivers/st/usb/stm32mp1_usb.c \
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200272 plat/st/stm32mp1/stm32mp1_usb_dfu.c
273endif
274
Yann Gautierdbe63ac2022-03-16 19:03:20 +0100275BL2_SOURCES += drivers/st/ddr/stm32mp1_ddr.c \
Yann Gautiercaf575b2018-07-24 17:18:19 +0200276 drivers/st/ddr/stm32mp1_ram.c
277
Yann Gautierdbe63ac2022-03-16 19:03:20 +0100278BL2_SOURCES += plat/st/stm32mp1/plat_image_load.c
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200279
280ifeq ($(AARCH32_SP),sp_min)
281# Create DTB file for BL32
282${BUILD_PLAT}/fdts/%-bl32.dts: fdts/%.dts fdts/${BL32_DTSI} | ${BUILD_PLAT} fdt_dirs
283 @echo '#include "$(patsubst fdts/%,%,$<)"' > $@
284 @echo '#include "${BL32_DTSI}"' >> $@
285
286${BUILD_PLAT}/fdts/%-bl32.dtb: ${BUILD_PLAT}/fdts/%-bl32.dts
287endif
288
Yann Gautierdbe63ac2022-03-16 19:03:20 +0100289include plat/st/common/common_rules.mk