platform.mk 6.71 KB
Newer Older
1
#
2
# Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved.
3
4
5
6
7
8
9
10
11
12
13
#
# SPDX-License-Identifier: BSD-3-Clause
#

ARM_CORTEX_A7		:=	yes
ARM_WITH_NEON		:=	yes
BL2_AT_EL3		:=	1
USE_COHERENT_MEM	:=	0

STM32_TF_VERSION	?=	0

14
15
16
17
18
# Enable dynamic memory mapping
PLAT_XLAT_TABLES_DYNAMIC :=	1
$(eval $(call assert_boolean,PLAT_XLAT_TABLES_DYNAMIC))
$(eval $(call add_define,PLAT_XLAT_TABLES_DYNAMIC))

19
20
21
# Not needed for Cortex-A7
WORKAROUND_CVE_2017_5715:=	0

22
23
24
# Number of TF-A copies in the device
STM32_TF_A_COPIES		:=	2
$(eval $(call add_define,STM32_TF_A_COPIES))
Yann Gautier's avatar
Yann Gautier committed
25
26
27
ifeq ($(AARCH32_SP),optee)
PLAT_PARTITION_MAX_ENTRIES	:=	$(shell echo $$(($(STM32_TF_A_COPIES) + 4)))
else
28
PLAT_PARTITION_MAX_ENTRIES	:=	$(shell echo $$(($(STM32_TF_A_COPIES) + 1)))
Yann Gautier's avatar
Yann Gautier committed
29
endif
30
31
$(eval $(call add_define,PLAT_PARTITION_MAX_ENTRIES))

32
33
34
# Boot devices
STM32MP_EMMC		?=	0
STM32MP_SDMMC		?=	0
35
STM32MP_RAW_NAND	?=	0
36
STM32MP_SPI_NAND	?=	0
37
STM32MP_SPI_NOR		?=	0
38

39
ifeq ($(filter 1,${STM32MP_EMMC} ${STM32MP_SDMMC} ${STM32MP_RAW_NAND} \
40
	${STM32MP_SPI_NAND} ${STM32MP_SPI_NOR}),)
41
42
43
44
45
$(error "No boot device driver is enabled")
endif

$(eval $(call assert_boolean,STM32MP_EMMC))
$(eval $(call assert_boolean,STM32MP_SDMMC))
46
$(eval $(call assert_boolean,STM32MP_RAW_NAND))
47
$(eval $(call assert_boolean,STM32MP_SPI_NAND))
48
$(eval $(call assert_boolean,STM32MP_SPI_NOR))
49
50
$(eval $(call add_define,STM32MP_EMMC))
$(eval $(call add_define,STM32MP_SDMMC))
51
$(eval $(call add_define,STM32MP_RAW_NAND))
52
$(eval $(call add_define,STM32MP_SPI_NAND))
53
$(eval $(call add_define,STM32MP_SPI_NOR))
54

55
56
PLAT_INCLUDES		:=	-Iplat/st/common/include/
PLAT_INCLUDES		+=	-Iplat/st/stm32mp1/include/
57

58
# Device tree
Yann Gautier's avatar
Yann Gautier committed
59
60
DTB_FILE_NAME		?=	stm32mp157c-ev1.dtb
FDT_SOURCES		:=	$(addprefix fdts/, $(patsubst %.dtb,%.dts,$(DTB_FILE_NAME)))
61
62
DTC_FLAGS		+=	-Wno-unit_address_vs_reg

63
64
include lib/libfdt/libfdt.mk

65
66
PLAT_BL_COMMON_SOURCES	:=	plat/st/common/stm32mp_common.c				\
				plat/st/stm32mp1/stm32mp1_private.c
67

68
PLAT_BL_COMMON_SOURCES	+=	drivers/st/uart/aarch32/stm32_console.S
69
70
71
72
73
74
75
76
77
78

ifneq (${ENABLE_STACK_PROTECTOR},0)
PLAT_BL_COMMON_SOURCES	+=	plat/st/stm32mp1/stm32mp1_stack_protector.c
endif

include lib/xlat_tables_v2/xlat_tables.mk
PLAT_BL_COMMON_SOURCES	+=	${XLAT_TABLES_LIB_SRCS}

PLAT_BL_COMMON_SOURCES	+=	lib/cpus/aarch32/cortex_a7.S

79
PLAT_BL_COMMON_SOURCES	+=	drivers/arm/tzc/tzc400.c				\
80
81
				drivers/delay_timer/delay_timer.c			\
				drivers/delay_timer/generic_delay_timer.c		\
Yann Gautier's avatar
Yann Gautier committed
82
				drivers/st/bsec/bsec.c					\
Yann Gautier's avatar
Yann Gautier committed
83
				drivers/st/clk/stm32mp_clkfunc.c			\
84
				drivers/st/clk/stm32mp1_clk.c				\
85
				drivers/st/ddr/stm32mp1_ddr_helpers.c			\
Yann Gautier's avatar
Yann Gautier committed
86
				drivers/st/gpio/stm32_gpio.c				\
87
				drivers/st/i2c/stm32_i2c.c				\
Yann Gautier's avatar
Yann Gautier committed
88
				drivers/st/iwdg/stm32_iwdg.c				\
89
90
				drivers/st/pmic/stm32mp_pmic.c				\
				drivers/st/pmic/stpmic1.c				\
91
				drivers/st/reset/stm32mp1_reset.c			\
92
				plat/st/common/stm32mp_dt.c				\
93
				plat/st/stm32mp1/stm32mp1_context.c			\
Yann Gautier's avatar
Yann Gautier committed
94
				plat/st/stm32mp1/stm32mp1_dbgmcu.c			\
95
				plat/st/stm32mp1/stm32mp1_helper.S			\
96
97
				plat/st/stm32mp1/stm32mp1_security.c			\
				plat/st/stm32mp1/stm32mp1_syscfg.c
98

99
100
BL2_SOURCES		+=	drivers/io/io_block.c					\
				drivers/io/io_dummy.c					\
101
				drivers/io/io_mtd.c					\
102
				drivers/io/io_storage.c					\
103
				drivers/st/crypto/stm32_hash.c				\
104
				drivers/st/io/io_stm32image.c				\
105
				plat/st/common/stm32mp_auth.c				\
106
				plat/st/common/bl2_io_storage.c				\
107
108
				plat/st/stm32mp1/bl2_plat_setup.c

109
ifneq ($(filter 1,${STM32MP_EMMC} ${STM32MP_SDMMC}),)
110
111
112
113
114
BL2_SOURCES		+=	drivers/mmc/mmc.c					\
				drivers/partition/gpt.c					\
				drivers/partition/partition.c				\
				drivers/st/io/io_mmc.c					\
				drivers/st/mmc/stm32_sdmmc2.c
115
endif
116

117
118
119
120
121
122
ifeq (${STM32MP_RAW_NAND},1)
$(eval $(call add_define_val,NAND_ONFI_DETECT,1))
BL2_SOURCES		+=	drivers/mtd/nand/raw_nand.c				\
				drivers/st/fmc/stm32_fmc2_nand.c
endif

123
124
125
126
ifeq (${STM32MP_SPI_NAND},1)
BL2_SOURCES		+=	drivers/mtd/nand/spi_nand.c
endif

127
128
129
130
131
ifeq (${STM32MP_SPI_NOR},1)
BL2_SOURCES		+=	drivers/mtd/nor/spi_nor.c
endif

ifneq ($(filter 1,${STM32MP_SPI_NAND} ${STM32MP_SPI_NOR}),)
132
133
134
135
136
BL2_SOURCES		+=	drivers/mtd/spi-mem/spi_mem.c				\
				drivers/st/spi/stm32_qspi.c
endif

ifneq ($(filter 1,${STM32MP_RAW_NAND} ${STM32MP_SPI_NAND}),)
137
138
139
140
141
BL2_SOURCES		+=	drivers/mtd/nand/core.c
endif

ifneq ($(filter 1,${STM32MP_RAW_NAND} ${STM32MP_SPI_NAND} ${STM32MP_SPI_NOR}),)
BL2_SOURCES		+=	plat/st/stm32mp1/stm32mp1_boot_device.c
142
143
endif

144
145
146
BL2_SOURCES		+=	drivers/st/ddr/stm32mp1_ddr.c				\
				drivers/st/ddr/stm32mp1_ram.c

147
148
149
150
BL2_SOURCES		+=	common/desc_image_load.c				\
				plat/st/stm32mp1/plat_bl2_mem_params_desc.c		\
				plat/st/stm32mp1/plat_image_load.c

Yann Gautier's avatar
Yann Gautier committed
151
152
153
154
ifeq ($(AARCH32_SP),optee)
BL2_SOURCES		+=	lib/optee/optee_utils.c
endif

155
156
# Macros and rules to build TF binary
STM32_TF_ELF_LDFLAGS	:=	--hash-style=gnu --as-needed
157
STM32_TF_STM32		:=	$(addprefix ${BUILD_PLAT}/tf-a-, $(patsubst %.dtb,%.stm32,$(DTB_FILE_NAME)))
158
STM32_TF_LINKERFILE	:=	${BUILD_PLAT}/stm32mp1.ld
159
160
161
162
163

# Variables for use with stm32image
STM32IMAGEPATH		?= tools/stm32image
STM32IMAGE		?= ${STM32IMAGEPATH}/stm32image${BIN_EXT}

164
.PHONY:			check_dtc_version stm32image clean_stm32image
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
.SUFFIXES:

all: check_dtc_version ${STM32_TF_STM32} stm32image

ifeq ($(AARCH32_SP),sp_min)
# BL32 is built only if using SP_MIN
BL32_DEP		:= bl32
BL32_PATH		:= -DBL32_BIN_PATH=\"${BUILD_PLAT}/bl32.bin\"
endif

distclean realclean clean: clean_stm32image

stm32image:
	${Q}${MAKE} CPPFLAGS="" --no-print-directory -C ${STM32IMAGEPATH}

clean_stm32image:
	${Q}${MAKE} --no-print-directory -C ${STM32IMAGEPATH} clean

check_dtc_version:
	$(eval DTC_V = $(shell $(DTC) -v | awk '{print $$NF}'))
	$(eval DTC_VERSION = $(shell printf "%d" $(shell echo ${DTC_V} | cut -d- -f1 | sed "s/\./0/g")))
	@if [ ${DTC_VERSION} -lt 10404 ]; then \
		echo "dtc version too old (${DTC_V}), you need at least version 1.4.4"; \
		false; \
	fi


192
193
${BUILD_PLAT}/stm32mp1-%.o:	${BUILD_PLAT}/fdts/%.dtb plat/st/stm32mp1/stm32mp1.S bl2 ${BL32_DEP}
			@echo "  AS      stm32mp1.S"
194
195
196
			${Q}${AS} ${ASFLAGS} ${TF_CFLAGS} \
				${BL32_PATH} \
				-DBL2_BIN_PATH=\"${BUILD_PLAT}/bl2.bin\" \
197
				-DDTB_BIN_PATH=\"$<\" \
198
199
				-c plat/st/stm32mp1/stm32mp1.S -o $@

Yann Gautier's avatar
Yann Gautier committed
200
${STM32_TF_LINKERFILE}:	plat/st/stm32mp1/stm32mp1.ld.S ${BUILD_PLAT}
201
202
203
			@echo "  LDS     $<"
			${Q}${AS} ${ASFLAGS} ${TF_CFLAGS} -P -E $< -o $@

204
tf-a-%.elf:		stm32mp1-%.o ${STM32_TF_LINKERFILE}
205
			@echo "  LDS     $<"
206
			${Q}${LD} -o $@ ${STM32_TF_ELF_LDFLAGS} -Map=$(@:.elf=.map) --script ${STM32_TF_LINKERFILE} $<
207

208
209
tf-a-%.bin:		tf-a-%.elf
			${Q}${OC} -O binary $< $@
210
211
212
213
			@echo
			@echo "Built $@ successfully"
			@echo

214
tf-a-%.stm32:		tf-a-%.bin stm32image
215
216
			@echo
			@echo "Generated $@"
217
218
			$(eval LOADADDR =  $(shell cat $(@:.stm32=.map) | grep RAM | awk '{print $$2}'))
			$(eval ENTRY =  $(shell cat $(@:.stm32=.map) | grep "__BL2_IMAGE_START" | awk '{print $$1}'))
219
			${STM32IMAGE} -s $< -d $@ -l $(LOADADDR) -e ${ENTRY} -v ${STM32_TF_VERSION}
220
			@echo