Commit eff2edee authored by Manish Pandey's avatar Manish Pandey Committed by TrustedFirmware Code Review
Browse files

Merge changes from topic "stm32mp1_platform_mk" into integration

* changes:
  stm32mp1: cosmetics in platform.mk
  stm32mp1: update rules for stm32image tool
  stm32mp1: add macros to define PLAT_PARTITION_MAX_ENTRIES
  stm32mp1: sort platform.mk
  stm32mp1: use ASFLAGS for binary paths
  stm32mp1: use internal MAKE_LD macro to generate stm32 linker files
parents bb68a9d6 38b23041
# #
# Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved. # Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved.
# #
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
...@@ -13,12 +13,10 @@ STM32_TF_VERSION ?= 0 ...@@ -13,12 +13,10 @@ STM32_TF_VERSION ?= 0
# Enable dynamic memory mapping # Enable dynamic memory mapping
PLAT_XLAT_TABLES_DYNAMIC := 1 PLAT_XLAT_TABLES_DYNAMIC := 1
$(eval $(call assert_boolean,PLAT_XLAT_TABLES_DYNAMIC))
$(eval $(call add_define,PLAT_XLAT_TABLES_DYNAMIC))
ifeq ($(AARCH32_SP),sp_min) ifeq ($(AARCH32_SP),sp_min)
# Disable Neon support: sp_min runtime may conflict with non-secure world # Disable Neon support: sp_min runtime may conflict with non-secure world
TF_CFLAGS += -mfloat-abi=soft TF_CFLAGS += -mfloat-abi=soft
endif endif
# Not needed for Cortex-A7 # Not needed for Cortex-A7
...@@ -26,13 +24,15 @@ WORKAROUND_CVE_2017_5715:= 0 ...@@ -26,13 +24,15 @@ WORKAROUND_CVE_2017_5715:= 0
# Number of TF-A copies in the device # Number of TF-A copies in the device
STM32_TF_A_COPIES := 2 STM32_TF_A_COPIES := 2
$(eval $(call add_define,STM32_TF_A_COPIES)) STM32_BL33_PARTS_NUM := 1
ifeq ($(AARCH32_SP),optee) ifeq ($(AARCH32_SP),optee)
PLAT_PARTITION_MAX_ENTRIES := $(shell echo $$(($(STM32_TF_A_COPIES) + 4))) STM32_RUNTIME_PARTS_NUM := 3
else else
PLAT_PARTITION_MAX_ENTRIES := $(shell echo $$(($(STM32_TF_A_COPIES) + 1))) STM32_RUNTIME_PARTS_NUM := 0
endif endif
$(eval $(call add_define,PLAT_PARTITION_MAX_ENTRIES)) PLAT_PARTITION_MAX_ENTRIES := $(shell echo $$(($(STM32_TF_A_COPIES) + \
$(STM32_BL33_PARTS_NUM) + \
$(STM32_RUNTIME_PARTS_NUM))))
# Boot devices # Boot devices
STM32MP_EMMC ?= 0 STM32MP_EMMC ?= 0
...@@ -46,32 +46,60 @@ ifeq ($(filter 1,${STM32MP_EMMC} ${STM32MP_SDMMC} ${STM32MP_RAW_NAND} \ ...@@ -46,32 +46,60 @@ ifeq ($(filter 1,${STM32MP_EMMC} ${STM32MP_SDMMC} ${STM32MP_RAW_NAND} \
$(error "No boot device driver is enabled") $(error "No boot device driver is enabled")
endif endif
# Device tree
DTB_FILE_NAME ?= stm32mp157c-ev1.dtb
FDT_SOURCES := $(addprefix fdts/, $(patsubst %.dtb,%.dts,$(DTB_FILE_NAME)))
DTC_FLAGS += -Wno-unit_address_vs_reg
# Macros and rules to build TF binary
STM32_TF_ELF_LDFLAGS := --hash-style=gnu --as-needed
STM32_TF_STM32 := $(addprefix ${BUILD_PLAT}/tf-a-, $(patsubst %.dtb,%.stm32,$(DTB_FILE_NAME)))
STM32_TF_LINKERFILE := ${BUILD_PLAT}/stm32mp1.ld
ASFLAGS += -DBL2_BIN_PATH=\"${BUILD_PLAT}/bl2.bin\"
ifeq ($(AARCH32_SP),sp_min)
# BL32 is built only if using SP_MIN
BL32_DEP := bl32
ASFLAGS += -DBL32_BIN_PATH=\"${BUILD_PLAT}/bl32.bin\"
endif
# Variables for use with stm32image
STM32IMAGEPATH ?= tools/stm32image
STM32IMAGE ?= ${STM32IMAGEPATH}/stm32image${BIN_EXT}
# Enable flags for C files
$(eval $(call assert_booleans,\ $(eval $(call assert_booleans,\
$(sort \ $(sort \
STM32MP_EMMC \ STM32MP_EMMC \
STM32MP_SDMMC \ STM32MP_SDMMC \
STM32MP_RAW_NAND \ STM32MP_RAW_NAND \
STM32MP_SPI_NAND \ STM32MP_SPI_NAND \
STM32MP_SPI_NOR \ STM32MP_SPI_NOR \
PLAT_XLAT_TABLES_DYNAMIC \
)))
$(eval $(call assert_numerics,\
$(sort \
STM32_TF_A_COPIES \
PLAT_PARTITION_MAX_ENTRIES \
))) )))
$(eval $(call add_defines,\ $(eval $(call add_defines,\
$(sort \ $(sort \
STM32MP_EMMC \ STM32MP_EMMC \
STM32MP_SDMMC \ STM32MP_SDMMC \
STM32MP_RAW_NAND \ STM32MP_RAW_NAND \
STM32MP_SPI_NAND \ STM32MP_SPI_NAND \
STM32MP_SPI_NOR \ STM32MP_SPI_NOR \
PLAT_XLAT_TABLES_DYNAMIC \
STM32_TF_A_COPIES \
PLAT_PARTITION_MAX_ENTRIES \
))) )))
# Include paths and source files
PLAT_INCLUDES := -Iplat/st/common/include/ PLAT_INCLUDES := -Iplat/st/common/include/
PLAT_INCLUDES += -Iplat/st/stm32mp1/include/ PLAT_INCLUDES += -Iplat/st/stm32mp1/include/
# Device tree
DTB_FILE_NAME ?= stm32mp157c-ev1.dtb
FDT_SOURCES := $(addprefix fdts/, $(patsubst %.dtb,%.dts,$(DTB_FILE_NAME)))
DTC_FLAGS += -Wno-unit_address_vs_reg
include lib/libfdt/libfdt.mk include lib/libfdt/libfdt.mk
PLAT_BL_COMMON_SOURCES := common/fdt_wrappers.c \ PLAT_BL_COMMON_SOURCES := common/fdt_wrappers.c \
...@@ -165,29 +193,17 @@ ifeq ($(AARCH32_SP),optee) ...@@ -165,29 +193,17 @@ ifeq ($(AARCH32_SP),optee)
BL2_SOURCES += lib/optee/optee_utils.c BL2_SOURCES += lib/optee/optee_utils.c
endif endif
# Macros and rules to build TF binary # Compilation rules
STM32_TF_ELF_LDFLAGS := --hash-style=gnu --as-needed .PHONY: check_dtc_version stm32image clean_stm32image
STM32_TF_STM32 := $(addprefix ${BUILD_PLAT}/tf-a-, $(patsubst %.dtb,%.stm32,$(DTB_FILE_NAME)))
STM32_TF_LINKERFILE := ${BUILD_PLAT}/stm32mp1.ld
# Variables for use with stm32image
STM32IMAGEPATH ?= tools/stm32image
STM32IMAGE ?= ${STM32IMAGEPATH}/stm32image${BIN_EXT}
.PHONY: check_dtc_version stm32image clean_stm32image
.SUFFIXES: .SUFFIXES:
all: check_dtc_version ${STM32_TF_STM32} stm32image all: check_dtc_version stm32image ${STM32_TF_STM32}
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 distclean realclean clean: clean_stm32image
stm32image: stm32image: ${STM32IMAGE}
${STM32IMAGE}: ${STM32IMAGE_SRC}
${Q}${MAKE} CPPFLAGS="" --no-print-directory -C ${STM32IMAGEPATH} ${Q}${MAKE} CPPFLAGS="" --no-print-directory -C ${STM32IMAGEPATH}
clean_stm32image: clean_stm32image:
...@@ -202,32 +218,30 @@ check_dtc_version: ...@@ -202,32 +218,30 @@ check_dtc_version:
fi fi
${BUILD_PLAT}/stm32mp1-%.o: ${BUILD_PLAT}/fdts/%.dtb plat/st/stm32mp1/stm32mp1.S bl2 ${BL32_DEP} ${BUILD_PLAT}/stm32mp1-%.o: ${BUILD_PLAT}/fdts/%.dtb plat/st/stm32mp1/stm32mp1.S bl2 ${BL32_DEP}
@echo " AS stm32mp1.S" @echo " AS stm32mp1.S"
${Q}${AS} ${ASFLAGS} ${TF_CFLAGS} \ ${Q}${AS} ${ASFLAGS} ${TF_CFLAGS} \
${BL32_PATH} \ -DDTB_BIN_PATH=\"$<\" \
-DBL2_BIN_PATH=\"${BUILD_PLAT}/bl2.bin\" \ -c plat/st/stm32mp1/stm32mp1.S -o $@
-DDTB_BIN_PATH=\"$<\" \
-c plat/st/stm32mp1/stm32mp1.S -o $@ $(eval $(call MAKE_LD,${STM32_TF_LINKERFILE},plat/st/stm32mp1/stm32mp1.ld.S,2))
${STM32_TF_LINKERFILE}: plat/st/stm32mp1/stm32mp1.ld.S ${BUILD_PLAT} tf-a-%.elf: stm32mp1-%.o ${STM32_TF_LINKERFILE}
@echo " LDS $<" @echo " LDS $<"
${Q}${AS} ${ASFLAGS} ${TF_CFLAGS} -P -E $< -o $@ ${Q}${LD} -o $@ ${STM32_TF_ELF_LDFLAGS} -Map=$(@:.elf=.map) --script ${STM32_TF_LINKERFILE} $<
tf-a-%.elf: stm32mp1-%.o ${STM32_TF_LINKERFILE} tf-a-%.bin: tf-a-%.elf
@echo " LDS $<" ${Q}${OC} -O binary $< $@
${Q}${LD} -o $@ ${STM32_TF_ELF_LDFLAGS} -Map=$(@:.elf=.map) --script ${STM32_TF_LINKERFILE} $< @echo
@echo "Built $@ successfully"
tf-a-%.bin: tf-a-%.elf @echo
${Q}${OC} -O binary $< $@
@echo tf-a-%.stm32: ${STM32IMAGE} tf-a-%.bin
@echo "Built $@ successfully" @echo
@echo @echo "Generate $@"
$(eval LOADADDR = $(shell cat $(@:.stm32=.map) | grep RAM | awk '{print $$2}'))
tf-a-%.stm32: tf-a-%.bin stm32image $(eval ENTRY = $(shell cat $(@:.stm32=.map) | grep "__BL2_IMAGE_START" | awk '{print $$1}'))
@echo ${Q}${STM32IMAGE} -s $(word 2,$^) -d $@ \
@echo "Generated $@" -l $(LOADADDR) -e ${ENTRY} \
$(eval LOADADDR = $(shell cat $(@:.stm32=.map) | grep RAM | awk '{print $$2}')) -v ${STM32_TF_VERSION}
$(eval ENTRY = $(shell cat $(@:.stm32=.map) | grep "__BL2_IMAGE_START" | awk '{print $$1}')) @echo
${STM32IMAGE} -s $< -d $@ -l $(LOADADDR) -e ${ENTRY} -v ${STM32_TF_VERSION}
@echo
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment