tf-a/Makefile

98 lines
3.7 KiB
Makefile
Raw Permalink Normal View History

2024-01-10 05:21:13 +00:00
#remove default variable
LDFLAGS=
CFLAGS=
CPPFLAGS=
CC=
CPP=
AS=
AR=
LD=
NM=
LOCAL_PATH=$(PWD)
EXTRA_OEMAKE=CROSS_COMPILE=arm-none-linux-gnueabihf- DEBUG=1 LOG_LEVEL=40 PLAT=stm32mp1 ARCH=aarch32 ARM_ARCH_MAJOR=7 STM32MP_SDMMC=1 STM32MP_EMMC=1 STM32MP_SPI_NOR=1 STM32MP_RAW_NAND=1 STM32MP_SPI_NAND=1
EXTRA_OEMAKE_SERIAL= STM32MP_UART_PROGRAMMER=1 STM32MP_USB_PROGRAMMER=1
# Set default config
ELF_DEBUG_ENABLE ?= 1
TF_A_CONFIG ?= trusted optee serialboot
# Set specific OEMAKE config
TF_A_CONFIG_OEMAKE = trusted,"AARCH32_SP=sp_min" optee,"AARCH32_SP=optee" serialboot,"AARCH32_SP=sp_min"
# Set default TFA_DEVICETREE
TFA_DEVICETREE ?= stm32mp157d-cyf
#Set default TF_A_ENABLE_DEBUG_WRAPPER
TF_A_ENABLE_DEBUG_WRAPPER ?= 1
help:
@echo
@echo "Available targets:"
@echo " all : build TF-A binaries for defined config(s)"
@echo " clean : clean build directories from generated files"
@echo
@echo "TF-A configuration:"
@echo " TF_A_CONFIG = $(TF_A_CONFIG)"
@echo " TFA_DEVICETREE = $(TFA_DEVICETREE)"
@echo " ELF_DEBUG_ENABLE = '$(ELF_DEBUG_ENABLE)' ('1' to export elf files)"
@echo " TF_A_ENABLE_DEBUG_WRAPPER = '$(TF_A_ENABLE_DEBUG_WRAPPER)' ('1' to generate tf-a for debugging)"
@echo
all: tf
host_tools:
@$(MAKE) --no-print-directory -C $(LOCAL_PATH)/tools/stm32image
tf: host_tools
for config in $(TF_A_CONFIG) ; do \
# Init any extraoemake \
add_extraoemake= ; \
for fullconfig in $(TF_A_CONFIG_OEMAKE) ; do \
extraconfig=$$(echo $$fullconfig | cut -d',' -f1) ; \
if [ "$$extraconfig" = "$$config" ]; then \
add_extraoemake=$$(echo $$fullconfig | cut -d',' -f2) ; \
fi ; \
done ; \
mkdir -p $(LOCAL_PATH)/../build/$$config ; \
if test -n "$(TFA_DEVICETREE)" ; then \
for dt in $(TFA_DEVICETREE) ; do \
if [ "$(TF_A_CONFIG)" != "serialboot" ]; then \
$(MAKE) $(EXTRA_OEMAKE) -C $(LOCAL_PATH) DTB_FILE_NAME=$$dt.dtb BUILD_PLAT=$(LOCAL_PATH)/../build/$$config $$add_extraoemake ; \
else \
$(MAKE) $(EXTRA_OEMAKE_SERIAL) -C $(LOCAL_PATH) DTB_FILE_NAME=$$dt.dtb BUILD_PLAT=$(LOCAL_PATH)/../build/$$config $$add_extraoemake ; \
fi \
# Copy binary file with explicit name \
cp -f $(LOCAL_PATH)/../build/$$config/tf-a-$$dt.stm32 $(LOCAL_PATH)/../build/$$config/tf-a-$$dt-$$config.stm32 ; \
if [ "$(TF_A_ENABLE_DEBUG_WRAPPER)" = "1" ]; then \
# Generate wrapper for debugging \
stm32wrapper4dbg -s $(LOCAL_PATH)/../build/$$config/tf-a-$$dt.stm32 -d $(LOCAL_PATH)/../build/$$config/debug-tf-a-$$dt-$$config.stm32 ; \
fi \
done ; \
else \
$(MAKE) $(EXTRA_OEMAKE) -C $(LOCAL_PATH) BUILD_PLAT=$(LOCAL_PATH)/../build/$$config $$add_extraoemake; \
tf_version=$$(find $(LOCAL_PATH)/../build/$$config -name tf-a*.stm32 -exec basename {} \; | sed "s/\.stm32//") ; \
# Copy binary file with explicit name \
cp -f $(LOCAL_PATH)/../build/$$config/$$tf_version.stm32 $(LOCAL_PATH)/../build/$$config/$$tf_version-$$config.stm32 ; \
if [ "$(TF_A_ENABLE_DEBUG_WRAPPER)" = "1" ]; then \
# Generate wrapper for debugging \
stm32wrapper4dbg -s $(LOCAL_PATH)/../build/$$config/$$tf_version.stm32 $(LOCAL_PATH)/../build/$$config/debug-$$tf_version-$$config.stm32 ; \
fi \
fi ; \
# Copy elf files with explicit name \
if [ "$(ELF_DEBUG_ENABLE)" = "1" ] ; then \
if [ -f $(LOCAL_PATH)/../build/$$config/bl2/bl2.elf ] ; then \
cp -f $(LOCAL_PATH)/../build/$$config/bl2/bl2.elf $(LOCAL_PATH)/../build/$$config/tf-a-bl2-$$config.elf ; \
fi ; \
if [ -f $(LOCAL_PATH)/../build/$$config/bl32/bl32.elf ] ; then \
cp -f $(LOCAL_PATH)/../build/$$config/bl32/bl32.elf $(LOCAL_PATH)/../build/$$config/tf-a-bl32-$$config.elf ; \
fi ; \
fi ; \
done
clean:
@for config in $(TF_A_CONFIG) ; do \
rm -rf $(LOCAL_PATH)/../build/$$config ; \
done