blob: 3e3460189e5cd82d90aec66973ed2dfbb7d303c1 [file] [log] [blame]
Yann Gautier4b0c72a2018-07-16 10:54:09 +02001#
Yann Gautiera45433b2019-01-16 18:31:00 +01002# Copyright (c) 2015-2019, 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
Yann Gautier8593e442018-11-14 18:46:15 +010011MULTI_CONSOLE_API := 1
Yann Gautier4b0c72a2018-07-16 10:54:09 +020012
13STM32_TF_VERSION ?= 0
14
15# Not needed for Cortex-A7
16WORKAROUND_CVE_2017_5715:= 0
17
Yann Gautier8244e1d2018-10-15 09:36:58 +020018# Number of TF-A copies in the device
19STM32_TF_A_COPIES := 2
20$(eval $(call add_define,STM32_TF_A_COPIES))
21PLAT_PARTITION_MAX_ENTRIES := $(shell echo $$(($(STM32_TF_A_COPIES) + 1)))
22$(eval $(call add_define,PLAT_PARTITION_MAX_ENTRIES))
23
Yann Gautieree8f5422019-02-14 11:13:25 +010024PLAT_INCLUDES := -Iplat/st/common/include/
25PLAT_INCLUDES += -Iplat/st/stm32mp1/include/
Yann Gautier4b0c72a2018-07-16 10:54:09 +020026
Yann Gautier761797d2018-07-16 14:34:50 +020027# Device tree
Yann Gautierf9d40d52019-01-17 14:41:46 +010028DTB_FILE_NAME ?= stm32mp157c-ev1.dtb
29FDT_SOURCES := $(addprefix fdts/, $(patsubst %.dtb,%.dts,$(DTB_FILE_NAME)))
Yann Gautier761797d2018-07-16 14:34:50 +020030DTC_FLAGS += -Wno-unit_address_vs_reg
31
Yann Gautier4b0c72a2018-07-16 10:54:09 +020032include lib/libfdt/libfdt.mk
33
Yann Gautieree8f5422019-02-14 11:13:25 +010034PLAT_BL_COMMON_SOURCES := plat/st/common/stm32mp_common.c \
35 plat/st/stm32mp1/stm32mp1_private.c
Yann Gautier4b0c72a2018-07-16 10:54:09 +020036
Julius Werner6b88b652018-11-27 17:50:28 -080037PLAT_BL_COMMON_SOURCES += drivers/st/uart/aarch32/stm32_console.S
Yann Gautier4b0c72a2018-07-16 10:54:09 +020038
39ifneq (${ENABLE_STACK_PROTECTOR},0)
40PLAT_BL_COMMON_SOURCES += plat/st/stm32mp1/stm32mp1_stack_protector.c
41endif
42
43include lib/xlat_tables_v2/xlat_tables.mk
44PLAT_BL_COMMON_SOURCES += ${XLAT_TABLES_LIB_SRCS}
45
46PLAT_BL_COMMON_SOURCES += lib/cpus/aarch32/cortex_a7.S
47
48PLAT_BL_COMMON_SOURCES += ${LIBFDT_SRCS} \
Yann Gautiercaf575b2018-07-24 17:18:19 +020049 drivers/arm/tzc/tzc400.c \
Yann Gautier4b0c72a2018-07-16 10:54:09 +020050 drivers/delay_timer/delay_timer.c \
51 drivers/delay_timer/generic_delay_timer.c \
Yann Gautier36a1e4b2019-01-17 14:52:47 +010052 drivers/st/bsec/bsec.c \
Yann Gautier4d429472019-02-14 11:15:20 +010053 drivers/st/clk/stm32mp_clkfunc.c \
Yann Gautier9aea69e2018-07-24 17:13:36 +020054 drivers/st/clk/stm32mp1_clk.c \
55 drivers/st/clk/stm32mp1_clkfunc.c \
Yann Gautiercaf575b2018-07-24 17:18:19 +020056 drivers/st/ddr/stm32mp1_ddr_helpers.c \
Yann Gautierd0ca7f42018-07-13 21:33:09 +020057 drivers/st/gpio/stm32_gpio.c \
Yann Gautier113f31e2019-01-17 09:34:18 +010058 drivers/st/i2c/stm32_i2c.c \
Yann Gautiera45433b2019-01-16 18:31:00 +010059 drivers/st/pmic/stm32mp_pmic.c \
60 drivers/st/pmic/stpmic1.c \
Yann Gautier9aea69e2018-07-24 17:13:36 +020061 drivers/st/reset/stm32mp1_reset.c \
Yann Gautieree8f5422019-02-14 11:13:25 +010062 plat/st/common/stm32mp_dt.c \
Yann Gautier41934662018-07-20 11:36:05 +020063 plat/st/stm32mp1/stm32mp1_context.c \
Yann Gautiercaf575b2018-07-24 17:18:19 +020064 plat/st/stm32mp1/stm32mp1_helper.S \
65 plat/st/stm32mp1/stm32mp1_security.c
Yann Gautier4b0c72a2018-07-16 10:54:09 +020066
Yann Gautier8244e1d2018-10-15 09:36:58 +020067BL2_SOURCES += drivers/io/io_block.c \
68 drivers/io/io_dummy.c \
Yann Gautier4b0c72a2018-07-16 10:54:09 +020069 drivers/io/io_storage.c \
Yann Gautier8244e1d2018-10-15 09:36:58 +020070 drivers/st/io/io_stm32image.c \
Yann Gautieree8f5422019-02-14 11:13:25 +010071 plat/st/common/bl2_io_storage.c \
Yann Gautier4b0c72a2018-07-16 10:54:09 +020072 plat/st/stm32mp1/bl2_plat_setup.c
73
Yann Gautier8244e1d2018-10-15 09:36:58 +020074BL2_SOURCES += drivers/mmc/mmc.c \
75 drivers/partition/gpt.c \
76 drivers/partition/partition.c \
77 drivers/st/io/io_mmc.c \
78 drivers/st/mmc/stm32_sdmmc2.c
79
Yann Gautiercaf575b2018-07-24 17:18:19 +020080BL2_SOURCES += drivers/st/ddr/stm32mp1_ddr.c \
81 drivers/st/ddr/stm32mp1_ram.c
82
Yann Gautier4b0c72a2018-07-16 10:54:09 +020083BL2_SOURCES += common/desc_image_load.c \
84 plat/st/stm32mp1/plat_bl2_mem_params_desc.c \
85 plat/st/stm32mp1/plat_image_load.c
86
Yann Gautier761797d2018-07-16 14:34:50 +020087# Macros and rules to build TF binary
88STM32_TF_ELF_LDFLAGS := --hash-style=gnu --as-needed
Yann Gautierf9d40d52019-01-17 14:41:46 +010089STM32_DT_BASENAME := $(DTB_FILE_NAME:.dtb=)
Yann Gautier761797d2018-07-16 14:34:50 +020090STM32_TF_STM32 := ${BUILD_PLAT}/tf-a-${STM32_DT_BASENAME}.stm32
91STM32_TF_BINARY := $(STM32_TF_STM32:.stm32=.bin)
92STM32_TF_MAPFILE := $(STM32_TF_STM32:.stm32=.map)
93STM32_TF_LINKERFILE := $(STM32_TF_STM32:.stm32=.ld)
94STM32_TF_ELF := $(STM32_TF_STM32:.stm32=.elf)
Yann Gautierf9d40d52019-01-17 14:41:46 +010095STM32_TF_DTBFILE := ${BUILD_PLAT}/fdts/${DTB_FILE_NAME}
Yann Gautier761797d2018-07-16 14:34:50 +020096STM32_TF_OBJS := ${BUILD_PLAT}/stm32mp1.o
97
98# Variables for use with stm32image
99STM32IMAGEPATH ?= tools/stm32image
100STM32IMAGE ?= ${STM32IMAGEPATH}/stm32image${BIN_EXT}
101
102.PHONY: ${STM32_TF_STM32}
103.SUFFIXES:
104
105all: check_dtc_version ${STM32_TF_STM32} stm32image
106
107ifeq ($(AARCH32_SP),sp_min)
108# BL32 is built only if using SP_MIN
109BL32_DEP := bl32
110BL32_PATH := -DBL32_BIN_PATH=\"${BUILD_PLAT}/bl32.bin\"
111endif
112
113distclean realclean clean: clean_stm32image
114
115stm32image:
116 ${Q}${MAKE} CPPFLAGS="" --no-print-directory -C ${STM32IMAGEPATH}
117
118clean_stm32image:
119 ${Q}${MAKE} --no-print-directory -C ${STM32IMAGEPATH} clean
120
121check_dtc_version:
122 $(eval DTC_V = $(shell $(DTC) -v | awk '{print $$NF}'))
123 $(eval DTC_VERSION = $(shell printf "%d" $(shell echo ${DTC_V} | cut -d- -f1 | sed "s/\./0/g")))
124 @if [ ${DTC_VERSION} -lt 10404 ]; then \
125 echo "dtc version too old (${DTC_V}), you need at least version 1.4.4"; \
126 false; \
127 fi
128
129
130${STM32_TF_OBJS}: plat/st/stm32mp1/stm32mp1.S bl2 ${BL32_DEP} ${STM32_TF_DTBFILE}
131 @echo " AS $<"
132 ${Q}${AS} ${ASFLAGS} ${TF_CFLAGS} \
133 ${BL32_PATH} \
134 -DBL2_BIN_PATH=\"${BUILD_PLAT}/bl2.bin\" \
135 -DDTB_BIN_PATH=\"${STM32_TF_DTBFILE}\" \
136 -c plat/st/stm32mp1/stm32mp1.S -o $@
137
Yann Gautierf9d40d52019-01-17 14:41:46 +0100138${STM32_TF_LINKERFILE}: plat/st/stm32mp1/stm32mp1.ld.S ${BUILD_PLAT}
Yann Gautier761797d2018-07-16 14:34:50 +0200139 @echo " LDS $<"
140 ${Q}${AS} ${ASFLAGS} ${TF_CFLAGS} -P -E $< -o $@
141
142${STM32_TF_ELF}: ${STM32_TF_OBJS} ${STM32_TF_LINKERFILE}
143 @echo " LDS $<"
144 ${Q}${LD} -o $@ ${STM32_TF_ELF_LDFLAGS} -Map=${STM32_TF_MAPFILE} --script ${STM32_TF_LINKERFILE} ${STM32_TF_OBJS}
145
146${STM32_TF_BINARY}: ${STM32_TF_ELF}
147 ${Q}${OC} -O binary ${STM32_TF_ELF} $@
148 @echo
149 @echo "Built $@ successfully"
150 @echo
151
152${STM32_TF_STM32}: stm32image ${STM32_TF_BINARY}
153 @echo
154 @echo "Generated $@"
155 $(eval LOADADDR = $(shell cat ${STM32_TF_MAPFILE} | grep RAM | awk '{print $$2}'))
156 $(eval ENTRY = $(shell cat ${STM32_TF_MAPFILE} | grep "__BL2_IMAGE_START" | awk '{print $$1}'))
157 ${STM32IMAGE} -s ${STM32_TF_BINARY} -d $@ -l $(LOADADDR) -e ${ENTRY} -v ${STM32_TF_VERSION}
158 @echo