platform.mk 4.72 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#
# Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#

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

STM32_TF_VERSION	?=	0

# Not needed for Cortex-A7
WORKAROUND_CVE_2017_5715:=	0

PLAT_INCLUDES		:=	-Iplat/st/stm32mp1/include/
PLAT_INCLUDES		+=	-Iinclude/common/tbbr
PLAT_INCLUDES		+=	-Iinclude/drivers/st

23
24
25
26
27
# Device tree
STM32_DTB_FILE_NAME	?=	stm32mp157c-ev1.dtb
FDT_SOURCES		:=	$(addprefix fdts/, $(patsubst %.dtb,%.dts,$(STM32_DTB_FILE_NAME)))
DTC_FLAGS		+=	-Wno-unit_address_vs_reg

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
include lib/libfdt/libfdt.mk

PLAT_BL_COMMON_SOURCES	:=	plat/st/stm32mp1/stm32mp1_common.c

PLAT_BL_COMMON_SOURCES	+=	drivers/console/aarch32/console.S			\
				drivers/st/uart/aarch32/stm32_console.S

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

PLAT_BL_COMMON_SOURCES	+=	${LIBFDT_SRCS}						\
45
				drivers/arm/tzc/tzc400.c				\
46
47
				drivers/delay_timer/delay_timer.c			\
				drivers/delay_timer/generic_delay_timer.c		\
48
49
				drivers/st/clk/stm32mp1_clk.c				\
				drivers/st/clk/stm32mp1_clkfunc.c			\
50
				drivers/st/ddr/stm32mp1_ddr_helpers.c			\
Yann Gautier's avatar
Yann Gautier committed
51
				drivers/st/gpio/stm32_gpio.c				\
Yann Gautier's avatar
Yann Gautier committed
52
53
54
				drivers/st/pmic/stm32_i2c.c				\
				drivers/st/pmic/stm32mp1_pmic.c				\
				drivers/st/pmic/stpmu1.c				\
55
				drivers/st/reset/stm32mp1_reset.c			\
56
				plat/st/stm32mp1/stm32mp1_context.c			\
57
				plat/st/stm32mp1/stm32mp1_dt.c				\
58
59
				plat/st/stm32mp1/stm32mp1_helper.S			\
				plat/st/stm32mp1/stm32mp1_security.c
60
61
62
63
64
65

BL2_SOURCES		+=	drivers/io/io_dummy.c					\
				drivers/io/io_storage.c					\
				plat/st/stm32mp1/bl2_io_storage.c			\
				plat/st/stm32mp1/bl2_plat_setup.c

66
67
68
BL2_SOURCES		+=	drivers/st/ddr/stm32mp1_ddr.c				\
				drivers/st/ddr/stm32mp1_ram.c

69
70
71
72
73
74
75
BL2_SOURCES		+=	common/desc_image_load.c				\
				plat/st/stm32mp1/plat_bl2_mem_params_desc.c		\
				plat/st/stm32mp1/plat_image_load.c

# For memory footprint optimization, build with thumb and interwork support
ASFLAGS			+=	-mthumb -mthumb-interwork
TF_CFLAGS		+=	-mthumb -mthumb-interwork
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148

# Macros and rules to build TF binary
STM32_TF_ELF_LDFLAGS	:=	--hash-style=gnu --as-needed
STM32_DT_BASENAME	:=	$(STM32_DTB_FILE_NAME:.dtb=)
STM32_TF_STM32		:=	${BUILD_PLAT}/tf-a-${STM32_DT_BASENAME}.stm32
STM32_TF_BINARY		:=	$(STM32_TF_STM32:.stm32=.bin)
STM32_TF_MAPFILE	:=	$(STM32_TF_STM32:.stm32=.map)
STM32_TF_LINKERFILE	:=	$(STM32_TF_STM32:.stm32=.ld)
STM32_TF_ELF		:=	$(STM32_TF_STM32:.stm32=.elf)
STM32_TF_DTBFILE	:=      ${BUILD_PLAT}/fdts/${STM32_DTB_FILE_NAME}
STM32_TF_OBJS		:=	${BUILD_PLAT}/stm32mp1.o

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

.PHONY:			${STM32_TF_STM32}
.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


${STM32_TF_OBJS}:	plat/st/stm32mp1/stm32mp1.S bl2 ${BL32_DEP} ${STM32_TF_DTBFILE}
			@echo "  AS      $<"
			${Q}${AS} ${ASFLAGS} ${TF_CFLAGS} \
				${BL32_PATH} \
				-DBL2_BIN_PATH=\"${BUILD_PLAT}/bl2.bin\" \
				-DDTB_BIN_PATH=\"${STM32_TF_DTBFILE}\" \
				-c plat/st/stm32mp1/stm32mp1.S -o $@

${STM32_TF_LINKERFILE}:	plat/st/stm32mp1/stm32mp1.ld.S
			@echo "  LDS     $<"
			${Q}${AS} ${ASFLAGS} ${TF_CFLAGS} -P -E $< -o $@

${STM32_TF_ELF}:	${STM32_TF_OBJS} ${STM32_TF_LINKERFILE}
			@echo "  LDS     $<"
			${Q}${LD} -o $@ ${STM32_TF_ELF_LDFLAGS} -Map=${STM32_TF_MAPFILE} --script ${STM32_TF_LINKERFILE} ${STM32_TF_OBJS}

${STM32_TF_BINARY}:	${STM32_TF_ELF}
			${Q}${OC} -O binary ${STM32_TF_ELF} $@
			@echo
			@echo "Built $@ successfully"
			@echo

${STM32_TF_STM32}:	stm32image ${STM32_TF_BINARY}
			@echo
			@echo "Generated $@"
			$(eval LOADADDR =  $(shell cat ${STM32_TF_MAPFILE} | grep RAM | awk '{print $$2}'))
			$(eval ENTRY =  $(shell cat ${STM32_TF_MAPFILE} | grep "__BL2_IMAGE_START" | awk '{print $$1}'))
			${STM32IMAGE} -s ${STM32_TF_BINARY} -d $@ -l $(LOADADDR) -e ${ENTRY} -v ${STM32_TF_VERSION}
			@echo