blob: 7eecf3040742565926a62b2b88b261dd6b9d47e2 [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 Gautier6e49b7f2022-09-13 13:59:48 +020013STM32MP_RECONFIGURE_CONSOLE ?= 0
Yann Gautierb02dd492022-03-02 14:31:55 +010014STM32MP_UART_BAUDRATE ?= 115200
Yann Gautierd1435742021-10-18 10:55:23 +020015
Lionel Debieve13a668d2022-10-05 16:47:03 +020016TRUSTED_BOARD_BOOT ?= 0
17STM32MP_USE_EXTERNAL_HEAP ?= 0
18
Lionel Debievefd02b802022-10-05 16:16:50 +020019# Use secure library from the ROM code for authentication
20STM32MP_CRYPTO_ROM_LIB ?= 0
21
Yann Gautier5c1dab32019-04-17 15:12:58 +020022# Please don't increment this value without good understanding of
23# the monotonic counter
Yann Gautier4b0c72a2018-07-16 10:54:09 +020024STM32_TF_VERSION ?= 0
25
Yann Gautiera55169b2020-01-10 18:18:59 +010026# Enable dynamic memory mapping
27PLAT_XLAT_TABLES_DYNAMIC := 1
Yann Gautiera55169b2020-01-10 18:18:59 +010028
Yann Gautier0c0e1032021-04-01 19:31:46 +020029# Default Device tree
30DTB_FILE_NAME ?= stm32mp157c-ev1.dtb
31
32STM32MP13 ?= 0
33STM32MP15 ?= 0
34
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +010035ifeq ($(STM32MP13),1)
Yann Gautier0c0e1032021-04-01 19:31:46 +020036ifeq ($(STM32MP15),1)
37$(error Cannot enable both flags STM32MP13 and STM32MP15)
38endif
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +010039STM32MP13 := 1
40STM32MP15 := 0
Yann Gautier0c0e1032021-04-01 19:31:46 +020041else 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
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +010051
Yann Gautier0c0e1032021-04-01 19:31:46 +020052ifeq ($(STM32MP13),1)
Lionel Debieve13a668d2022-10-05 16:47:03 +020053# Will use SRAM2 as mbedtls heap
54STM32MP_USE_EXTERNAL_HEAP := 1
55
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +010056# DDR controller with single AXI port and 16-bit interface
57STM32MP_DDR_DUAL_AXI_PORT:= 0
58STM32MP_DDR_32BIT_INTERFACE:= 0
59
Lionel Debieve13a668d2022-10-05 16:47:03 +020060ifeq (${TRUSTED_BOARD_BOOT},1)
61# PKA algo to include
62PKA_USE_NIST_P256 := 1
63PKA_USE_BRAINPOOL_P256T1:= 1
64endif
65
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +010066# STM32 image header version v2.0
67STM32_HEADER_VERSION_MAJOR:= 2
68STM32_HEADER_VERSION_MINOR:= 0
Yann Gautier0c0e1032021-04-01 19:31:46 +020069endif
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +010070
Yann Gautier0c0e1032021-04-01 19:31:46 +020071ifeq ($(STM32MP15),1)
Yann Gautier6d8c2442020-09-17 12:42:46 +020072# DDR controller with dual AXI port and 32-bit interface
73STM32MP_DDR_DUAL_AXI_PORT:= 1
74STM32MP_DDR_32BIT_INTERFACE:= 1
75
Nicolas Le Bayondfa46cc2019-11-18 17:13:42 +010076# STM32 image header version v1.0
77STM32_HEADER_VERSION_MAJOR:= 1
78STM32_HEADER_VERSION_MINOR:= 0
Yann Gautierbc9f0fd2022-06-30 11:33:27 +020079
80# Add OP-TEE reserved shared memory area in mapping
81STM32MP15_OPTEE_RSV_SHM := 1
82$(eval $(call add_defines,STM32MP15_OPTEE_RSV_SHM))
Lionel Debievefd02b802022-10-05 16:16:50 +020083
84STM32MP_CRYPTO_ROM_LIB := 1
Lionel Debieve5adcd502022-10-05 16:51:12 +020085
86# Decryption support
87ifneq ($(DECRYPTION_SUPPORT),none)
88$(error "DECRYPTION_SUPPORT not supported on STM32MP15")
89endif
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +010090endif
Nicolas Le Bayondfa46cc2019-11-18 17:13:42 +010091
92# STM32 image header binary type for BL2
93STM32_HEADER_BL2_BINARY_TYPE:= 0x10
94
Etienne Carriereca651fb2020-04-10 18:51:54 +020095ifeq ($(AARCH32_SP),sp_min)
96# Disable Neon support: sp_min runtime may conflict with non-secure world
Yann Gautier46f8e672020-09-18 10:32:37 +020097TF_CFLAGS += -mfloat-abi=soft
Etienne Carriereca651fb2020-04-10 18:51:54 +020098endif
99
Yann Gautier19cdaa82020-11-10 15:09:55 +0100100TF_CFLAGS += -Wsign-compare
Yann Gautier3c7be342022-02-14 10:30:33 +0100101TF_CFLAGS += -Wformat-signedness
Yann Gautier19cdaa82020-11-10 15:09:55 +0100102
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200103# Not needed for Cortex-A7
104WORKAROUND_CVE_2017_5715:= 0
Bipin Ravicaa2e052022-02-23 23:45:50 -0600105WORKAROUND_CVE_2022_23960:= 0
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200106
Yann Gautierc7465912022-06-30 15:21:19 +0200107# 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
Sughosh Ganua1976842021-11-10 17:47:16 +0530114ifeq (${PSA_FWU_SUPPORT},1)
Sughosh Ganua1976842021-11-10 17:47:16 +0530115# Number of banks of updatable firmware
116NR_OF_FW_BANKS := 2
117NR_OF_IMAGES_IN_FW_BANK := 1
118
Yann Gautierc7465912022-06-30 15:21:19 +0200119FWU_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)")
Sughosh Ganua1976842021-11-10 17:47:16 +0530123endif
Sughosh Ganua1976842021-11-10 17:47:16 +0530124endif
Yann Gautier8244e1d2018-10-15 09:36:58 +0200125
Nicolas Toromanoff5d3ade02020-12-22 13:54:51 +0100126ifeq ($(STM32MP13),1)
127STM32_HASH_VER := 4
Nicolas Le Bayon5c66fab2020-12-02 16:23:49 +0100128STM32_RNG_VER := 4
Nicolas Toromanoff5d3ade02020-12-22 13:54:51 +0100129else # Assuming STM32MP15
130STM32_HASH_VER := 2
Nicolas Le Bayon5c66fab2020-12-02 16:23:49 +0100131STM32_RNG_VER := 2
Nicolas Toromanoff5d3ade02020-12-22 13:54:51 +0100132endif
133
Nicolas Le Bayon3f42cad2019-09-03 09:52:05 +0200134# Boot devices
135STM32MP_EMMC ?= 0
136STM32MP_SDMMC ?= 0
Lionel Debieve402a46b2019-11-04 12:28:15 +0100137STM32MP_RAW_NAND ?= 0
Lionel Debieve186b0462019-09-24 18:30:12 +0200138STM32MP_SPI_NAND ?= 0
Lionel Debievecb0dbc42019-09-25 09:11:31 +0200139STM32MP_SPI_NOR ?= 0
Vyacheslav Yurkove43a0802021-06-04 10:10:51 +0200140STM32MP_EMMC_BOOT ?= 0
Nicolas Le Bayon3f42cad2019-09-03 09:52:05 +0200141
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200142# Serial boot devices
143STM32MP_USB_PROGRAMMER ?= 0
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200144STM32MP_UART_PROGRAMMER ?= 0
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200145
Patrick Delaunay4c66e0a2022-03-15 11:20:56 +0100146# Download load address for serial boot devices
147DWL_BUFFER_BASE ?= 0xC7000000
148
Yann Gautier5f400632020-02-12 09:30:49 +0100149# Device tree
Yann Gautierf03dee52020-02-25 17:08:10 +0100150ifeq ($(STM32MP13),1)
Yann Gautierf03dee52020-02-25 17:08:10 +0100151BL2_DTSI := stm32mp13-bl2.dtsi
152FDT_SOURCES := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl2.dts,$(DTB_FILE_NAME)))
153else
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200154BL2_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
Yann Gautierd82fca42021-03-09 10:42:02 +0100161
162$(eval DTC_V = $(shell $(DTC) -v | awk '{print $$NF}'))
Yann Gautierfb153372022-04-22 13:12:37 +0200163$(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 +0200164DTC_CPPFLAGS += ${INCLUDES}
Yann Gautier5f400632020-02-12 09:30:49 +0100165DTC_FLAGS += -Wno-unit_address_vs_reg
Yann Gautierd82fca42021-03-09 10:42:02 +0100166ifeq ($(shell test $(DTC_VERSION) -ge 10601; echo $$?),0)
167DTC_FLAGS += -Wno-interrupt_provider
168endif
Yann Gautier5f400632020-02-12 09:30:49 +0100169
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}
Yann Gautiere56f53f2021-06-09 09:36:35 +0200185STM32IMAGE_SRC := ${STM32IMAGEPATH}/stm32image.c
Yann Gautier5f400632020-02-12 09:30:49 +0100186
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200187FIP_DEPS += dtbs
188STM32MP_HW_CONFIG := ${BL33_CFG}
Yann Gautier658775c2021-07-06 10:00:44 +0200189STM32MP_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))
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200196# Add the HW_CONFIG to FIP and specify the same to certtool
197$(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_HW_CONFIG},--hw-config))
Lionel Debieve13a668d2022-10-05 16:47:03 +0200198ifeq ($(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
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200203ifeq ($(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),)
Lionel Debieve5adcd502022-10-05 16:51:12 +0200210$(eval $(call TOOL_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1,,$(ENCRYPT_BL32)))
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200211endif
212ifneq ($(BL32_EXTRA2),)
Lionel Debieve5adcd502022-10-05 16:51:12 +0200213$(eval $(call TOOL_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2,,$(ENCRYPT_BL32)))
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200214endif
215endif
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200216
Yann Gautier5f400632020-02-12 09:30:49 +0100217# Enable flags for C files
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -0500218$(eval $(call assert_booleans,\
Yann Gautier5f400632020-02-12 09:30:49 +0100219 $(sort \
Lionel Debieve13a668d2022-10-05 16:47:03 +0200220 PKA_USE_BRAINPOOL_P256T1 \
221 PKA_USE_NIST_P256 \
222 PLAT_TBBR_IMG_DEF \
Yann Gautier27f589d2021-10-15 17:59:38 +0200223 PLAT_XLAT_TABLES_DYNAMIC \
Lionel Debievefd02b802022-10-05 16:16:50 +0200224 STM32MP_CRYPTO_ROM_LIB \
Yann Gautier6d8c2442020-09-17 12:42:46 +0200225 STM32MP_DDR_32BIT_INTERFACE \
226 STM32MP_DDR_DUAL_AXI_PORT \
Yann Gautierd1435742021-10-18 10:55:23 +0200227 STM32MP_EARLY_CONSOLE \
Yann Gautier5f400632020-02-12 09:30:49 +0100228 STM32MP_EMMC \
Yann Gautier27f589d2021-10-15 17:59:38 +0200229 STM32MP_EMMC_BOOT \
Yann Gautier5f400632020-02-12 09:30:49 +0100230 STM32MP_RAW_NAND \
Yann Gautier6e49b7f2022-09-13 13:59:48 +0200231 STM32MP_RECONFIGURE_CONSOLE \
Yann Gautier27f589d2021-10-15 17:59:38 +0200232 STM32MP_SDMMC \
Yann Gautier5f400632020-02-12 09:30:49 +0100233 STM32MP_SPI_NAND \
234 STM32MP_SPI_NOR \
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200235 STM32MP_UART_PROGRAMMER \
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200236 STM32MP_USB_PROGRAMMER \
Lionel Debieve13a668d2022-10-05 16:47:03 +0200237 STM32MP_USE_EXTERNAL_HEAP \
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +0100238 STM32MP13 \
239 STM32MP15 \
Yann Gautier5f400632020-02-12 09:30:49 +0100240)))
241
242$(eval $(call assert_numerics,\
243 $(sort \
Yann Gautier5f400632020-02-12 09:30:49 +0100244 PLAT_PARTITION_MAX_ENTRIES \
Nicolas Toromanoff5d3ade02020-12-22 13:54:51 +0100245 STM32_HASH_VER \
Lionel Debieve13a668d2022-10-05 16:47:03 +0200246 STM32_HEADER_VERSION_MAJOR \
Nicolas Le Bayon5c66fab2020-12-02 16:23:49 +0100247 STM32_RNG_VER \
Yann Gautier27f589d2021-10-15 17:59:38 +0200248 STM32_TF_A_COPIES \
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200249 STM32_TF_VERSION \
Yann Gautierb02dd492022-03-02 14:31:55 +0100250 STM32MP_UART_BAUDRATE \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -0500251)))
252
253$(eval $(call add_defines,\
Yann Gautier5f400632020-02-12 09:30:49 +0100254 $(sort \
Patrick Delaunay4c66e0a2022-03-15 11:20:56 +0100255 DWL_BUFFER_BASE \
Lionel Debieve13a668d2022-10-05 16:47:03 +0200256 PKA_USE_BRAINPOOL_P256T1 \
257 PKA_USE_NIST_P256 \
Yann Gautier27f589d2021-10-15 17:59:38 +0200258 PLAT_PARTITION_MAX_ENTRIES \
Lionel Debieve13a668d2022-10-05 16:47:03 +0200259 PLAT_TBBR_IMG_DEF \
Yann Gautier27f589d2021-10-15 17:59:38 +0200260 PLAT_XLAT_TABLES_DYNAMIC \
Nicolas Toromanoff5d3ade02020-12-22 13:54:51 +0100261 STM32_HASH_VER \
Lionel Debieve13a668d2022-10-05 16:47:03 +0200262 STM32_HEADER_VERSION_MAJOR \
Nicolas Le Bayon5c66fab2020-12-02 16:23:49 +0100263 STM32_RNG_VER \
Yann Gautier27f589d2021-10-15 17:59:38 +0200264 STM32_TF_A_COPIES \
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200265 STM32_TF_VERSION \
Lionel Debievefd02b802022-10-05 16:16:50 +0200266 STM32MP_CRYPTO_ROM_LIB \
Yann Gautier6d8c2442020-09-17 12:42:46 +0200267 STM32MP_DDR_32BIT_INTERFACE \
268 STM32MP_DDR_DUAL_AXI_PORT \
Yann Gautierd1435742021-10-18 10:55:23 +0200269 STM32MP_EARLY_CONSOLE \
Yann Gautier5f400632020-02-12 09:30:49 +0100270 STM32MP_EMMC \
Yann Gautier27f589d2021-10-15 17:59:38 +0200271 STM32MP_EMMC_BOOT \
Yann Gautier5f400632020-02-12 09:30:49 +0100272 STM32MP_RAW_NAND \
Yann Gautier6e49b7f2022-09-13 13:59:48 +0200273 STM32MP_RECONFIGURE_CONSOLE \
Yann Gautier27f589d2021-10-15 17:59:38 +0200274 STM32MP_SDMMC \
Yann Gautier5f400632020-02-12 09:30:49 +0100275 STM32MP_SPI_NAND \
276 STM32MP_SPI_NOR \
Yann Gautierb02dd492022-03-02 14:31:55 +0100277 STM32MP_UART_BAUDRATE \
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200278 STM32MP_UART_PROGRAMMER \
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200279 STM32MP_USB_PROGRAMMER \
Lionel Debieve13a668d2022-10-05 16:47:03 +0200280 STM32MP_USE_EXTERNAL_HEAP \
Sebastien Pasdeloup94389ef2020-12-18 11:50:40 +0100281 STM32MP13 \
282 STM32MP15 \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -0500283)))
Nicolas Le Bayon3f42cad2019-09-03 09:52:05 +0200284
Yann Gautier5f400632020-02-12 09:30:49 +0100285# Include paths and source files
Yann Gautieree8f5422019-02-14 11:13:25 +0100286PLAT_INCLUDES := -Iplat/st/common/include/
287PLAT_INCLUDES += -Iplat/st/stm32mp1/include/
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200288
Yann Gautier0dc92312021-10-29 17:04:17 +0200289include lib/fconf/fconf.mk
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200290include lib/libfdt/libfdt.mk
291
Chris Kaye9272152021-09-28 15:52:14 +0100292PLAT_BL_COMMON_SOURCES := common/uuid.c \
Andre Przywaracc99f3f2020-03-26 12:51:21 +0000293 plat/st/common/stm32mp_common.c \
Yann Gautieree8f5422019-02-14 11:13:25 +0100294 plat/st/stm32mp1/stm32mp1_private.c
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200295
Julius Werner6b88b652018-11-27 17:50:28 -0800296PLAT_BL_COMMON_SOURCES += drivers/st/uart/aarch32/stm32_console.S
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200297
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
Yann Gautier2c1fa282019-05-09 11:56:30 +0200307PLAT_BL_COMMON_SOURCES += drivers/arm/tzc/tzc400.c \
Gabriel Fernandez8aac3072020-10-13 09:36:25 +0200308 drivers/clk/clk.c \
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200309 drivers/delay_timer/delay_timer.c \
310 drivers/delay_timer/generic_delay_timer.c \
Nicolas Le Bayon97287cd2019-05-20 18:35:02 +0200311 drivers/st/bsec/bsec2.c \
Yann Gautier4d429472019-02-14 11:15:20 +0100312 drivers/st/clk/stm32mp_clkfunc.c \
Nicolas Le Bayon8ce825f2021-05-18 10:01:30 +0200313 drivers/st/ddr/stm32mp_ddr.c \
Yann Gautiercaf575b2018-07-24 17:18:19 +0200314 drivers/st/ddr/stm32mp1_ddr_helpers.c \
Yann Gautierd0ca7f42018-07-13 21:33:09 +0200315 drivers/st/gpio/stm32_gpio.c \
Yann Gautier113f31e2019-01-17 09:34:18 +0100316 drivers/st/i2c/stm32_i2c.c \
Yann Gautier091eab52019-06-04 18:06:34 +0200317 drivers/st/iwdg/stm32_iwdg.c \
Yann Gautiera45433b2019-01-16 18:31:00 +0100318 drivers/st/pmic/stm32mp_pmic.c \
319 drivers/st/pmic/stpmic1.c \
Yann Gautierb1279e72021-12-15 13:16:15 +0100320 drivers/st/regulator/regulator_core.c \
Pascal Pailletfc7b8052021-01-29 14:48:49 +0100321 drivers/st/regulator/regulator_fixed.c \
Yann Gautier9aea69e2018-07-24 17:13:36 +0200322 drivers/st/reset/stm32mp1_reset.c \
Yann Gautieree8f5422019-02-14 11:13:25 +0100323 plat/st/common/stm32mp_dt.c \
Yann Gautier091eab52019-06-04 18:06:34 +0200324 plat/st/stm32mp1/stm32mp1_dbgmcu.c \
Yann Gautiercaf575b2018-07-24 17:18:19 +0200325 plat/st/stm32mp1/stm32mp1_helper.S \
Yann Gautier3edc7c32019-05-20 19:17:08 +0200326 plat/st/stm32mp1/stm32mp1_syscfg.c
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200327
Gabriel Fernandez1308d752020-03-11 11:30:34 +0100328ifeq ($(STM32MP13),1)
329PLAT_BL_COMMON_SOURCES += drivers/st/clk/clk-stm32-core.c \
Nicolas Le Bayon5c66fab2020-12-02 16:23:49 +0100330 drivers/st/clk/clk-stm32mp13.c \
331 drivers/st/crypto/stm32_rng.c
Gabriel Fernandez1308d752020-03-11 11:30:34 +0100332else
333PLAT_BL_COMMON_SOURCES += drivers/st/clk/stm32mp1_clk.c
334endif
335
Yann Gautier0dc92312021-10-29 17:04:17 +0200336BL2_SOURCES += ${FCONF_SOURCES} ${FCONF_DYN_SOURCES}
337
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200338BL2_SOURCES += drivers/io/io_fip.c \
339 plat/st/common/bl2_io_storage.c \
Yann Gautier29f1f942021-07-13 18:07:41 +0200340 plat/st/common/stm32mp_fconf_io.c \
Lionel Debieve1dc5e2e2020-09-27 21:13:53 +0200341 plat/st/stm32mp1/plat_bl2_mem_params_desc.c \
342 plat/st/stm32mp1/stm32mp1_fconf_firewall.c
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200343
Sughosh Ganua1976842021-11-10 17:47:16 +0530344include lib/zlib/zlib.mk
Rohit Nerf9f72d92022-05-18 00:55:02 -0700345
346ifeq (${PSA_FWU_SUPPORT},1)
Sughosh Ganua1976842021-11-10 17:47:16 +0530347include drivers/fwu/fwu.mk
Rohit Nerf9f72d92022-05-18 00:55:02 -0700348endif
349
Sughosh Ganua1976842021-11-10 17:47:16 +0530350
351BL2_SOURCES += $(ZLIB_SOURCES)
Sughosh Ganua1976842021-11-10 17:47:16 +0530352
Yann Gautier8244e1d2018-10-15 09:36:58 +0200353BL2_SOURCES += drivers/io/io_block.c \
Lionel Debieve402a46b2019-11-04 12:28:15 +0100354 drivers/io/io_mtd.c \
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200355 drivers/io/io_storage.c \
Lionel Debieve7bd96f42019-09-03 12:22:23 +0200356 drivers/st/crypto/stm32_hash.c \
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200357 plat/st/stm32mp1/bl2_plat_setup.c
358
Lionel Debieve5adcd502022-10-05 16:51:12 +0200359ifneq (${DECRYPTION_SUPPORT},none)
360BL2_SOURCES += drivers/io/io_encrypted.c
361endif
362
Lionel Debieve13a668d2022-10-05 16:47:03 +0200363ifeq (${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
Nicolas Le Bayon3f42cad2019-09-03 09:52:05 +0200402ifneq ($(filter 1,${STM32MP_EMMC} ${STM32MP_SDMMC}),)
Yann Gautier8244e1d2018-10-15 09:36:58 +0200403BL2_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
Nicolas Le Bayon3f42cad2019-09-03 09:52:05 +0200408endif
Yann Gautier8244e1d2018-10-15 09:36:58 +0200409
Lionel Debieve402a46b2019-11-04 12:28:15 +0100410ifeq (${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
Lionel Debieve186b0462019-09-24 18:30:12 +0200416ifeq (${STM32MP_SPI_NAND},1)
417BL2_SOURCES += drivers/mtd/nand/spi_nand.c
418endif
419
Lionel Debievecb0dbc42019-09-25 09:11:31 +0200420ifeq (${STM32MP_SPI_NOR},1)
Lionel Debieveaf199382021-01-13 07:59:59 +0100421ifneq (${STM32MP_FORCE_MTD_START_OFFSET},)
422$(eval $(call add_define_val,STM32MP_NOR_FIP_OFFSET,${STM32MP_FORCE_MTD_START_OFFSET}))
423endif
Lionel Debievecb0dbc42019-09-25 09:11:31 +0200424BL2_SOURCES += drivers/mtd/nor/spi_nor.c
425endif
426
427ifneq ($(filter 1,${STM32MP_SPI_NAND} ${STM32MP_SPI_NOR}),)
Lionel Debieve186b0462019-09-24 18:30:12 +0200428BL2_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}),)
Lionel Debieveaf199382021-01-13 07:59:59 +0100433ifneq (${STM32MP_FORCE_MTD_START_OFFSET},)
434$(eval $(call add_define_val,STM32MP_NAND_FIP_OFFSET,${STM32MP_FORCE_MTD_START_OFFSET}))
435endif
Lionel Debievecb0dbc42019-09-25 09:11:31 +0200436BL2_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
Lionel Debieve402a46b2019-11-04 12:28:15 +0100441endif
442
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200443ifneq ($(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
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200452ifeq (${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))
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200455BL2_SOURCES += drivers/st/usb/stm32mp1_usb.c \
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200456 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
Nicolas Le Bayon620ce332021-03-02 11:19:36 +0100462BL2_SOURCES += drivers/st/ddr/stm32mp_ddr_test.c \
463 drivers/st/ddr/stm32mp_ram.c \
Nicolas Le Bayon8ce825f2021-05-18 10:01:30 +0200464 drivers/st/ddr/stm32mp1_ddr.c \
Yann Gautiercaf575b2018-07-24 17:18:19 +0200465 drivers/st/ddr/stm32mp1_ram.c
466
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200467BL2_SOURCES += common/desc_image_load.c \
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200468 plat/st/stm32mp1/plat_image_load.c
469
Yann Gautierb3386f72019-04-19 09:41:01 +0200470BL2_SOURCES += lib/optee/optee_utils.c
Yann Gautierb3386f72019-04-19 09:41:01 +0200471
Yann Gautier5f400632020-02-12 09:30:49 +0100472# Compilation rules
Yann Gautiercc785d82020-11-09 11:16:10 +0100473.PHONY: check_dtc_version stm32image clean_stm32image check_boot_device
Yann Gautier761797d2018-07-16 14:34:50 +0200474.SUFFIXES:
475
Yann Gautier3f10a2f2020-09-18 10:21:29 +0200476all: check_dtc_version stm32image ${STM32_TF_STM32}
Yann Gautier761797d2018-07-16 14:34:50 +0200477
Yann Gautier761797d2018-07-16 14:34:50 +0200478distclean realclean clean: clean_stm32image
479
Yann Gautiercc785d82020-11-09 11:16:10 +0100480bl2: 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 ] && \
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200487 [ ${STM32MP_SPI_NOR} != 1 ] && \
Patrick Delaunaye50571b2021-10-28 13:48:52 +0200488 [ ${STM32MP_UART_PROGRAMMER} != 1 ] && \
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200489 [ ${STM32MP_USB_PROGRAMMER} != 1 ]; then \
Yann Gautiercc785d82020-11-09 11:16:10 +0100490 echo "No boot device driver is enabled"; \
491 false; \
492 fi
493
Yann Gautier3f10a2f2020-09-18 10:21:29 +0200494stm32image: ${STM32IMAGE}
495
496${STM32IMAGE}: ${STM32IMAGE_SRC}
Yann Gautier761797d2018-07-16 14:34:50 +0200497 ${Q}${MAKE} CPPFLAGS="" --no-print-directory -C ${STM32IMAGEPATH}
498
499clean_stm32image:
500 ${Q}${MAKE} --no-print-directory -C ${STM32IMAGEPATH} clean
501
502check_dtc_version:
Yann Gautier761797d2018-07-16 14:34:50 +0200503 @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
Yann Gautier0ed7b2a2021-05-19 18:48:16 +0200508# 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=\"$<\" \
Yann Gautier46f8e672020-09-18 10:32:37 +0200528 -c plat/st/stm32mp1/stm32mp1.S -o $@
Yann Gautier761797d2018-07-16 14:34:50 +0200529
Yann Gautier3ab157a2021-10-07 14:19:48 +0200530$(eval $(call MAKE_LD,${STM32_TF_LINKERFILE},plat/st/stm32mp1/stm32mp1.ld.S,bl2))
Yann Gautier761797d2018-07-16 14:34:50 +0200531
Yann Gautier46f8e672020-09-18 10:32:37 +0200532tf-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} $<
Yann Gautier761797d2018-07-16 14:34:50 +0200535
Yann Gautier46f8e672020-09-18 10:32:37 +0200536tf-a-%.bin: tf-a-%.elf
537 ${Q}${OC} -O binary $< $@
538 @echo
539 @echo "Built $@ successfully"
540 @echo
Yann Gautier761797d2018-07-16 14:34:50 +0200541
Yann Gautier46f8e672020-09-18 10:32:37 +0200542tf-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} \
Nicolas Le Bayondfa46cc2019-11-18 17:13:42 +0100549 -v ${STM32_TF_VERSION} \
550 -m ${STM32_HEADER_VERSION_MAJOR} \
551 -n ${STM32_HEADER_VERSION_MINOR} \
552 -b ${STM32_HEADER_BL2_BINARY_TYPE}
Yann Gautier46f8e672020-09-18 10:32:37 +0200553 @echo