aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile222
1 files changed, 161 insertions, 61 deletions
diff --git a/Makefile b/Makefile
index 8eba9403b..f88cd3f04 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,12 @@
#
-# Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+# Copyright (c) 2018-2023, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
# TFTF Version
VERSION_MAJOR := 2
-VERSION_MINOR := 5
+VERSION_MINOR := 10
MAKE_HELPERS_DIRECTORY := make_helpers/
include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
@@ -55,6 +55,19 @@ else
endif
export Q
+################################################################################
+# Toolchain configs
+################################################################################
+CC := ${CROSS_COMPILE}gcc
+CPP := ${CROSS_COMPILE}cpp
+AS := ${CROSS_COMPILE}gcc
+AR := ${CROSS_COMPILE}ar
+LD := ${CROSS_COMPILE}ld
+OC := ${CROSS_COMPILE}objcopy
+OD := ${CROSS_COMPILE}objdump
+NM := ${CROSS_COMPILE}nm
+PP := ${CROSS_COMPILE}gcc
+
ifneq (${DEBUG}, 0)
BUILD_TYPE := debug
# Use LOG_LEVEL_INFO by default for debug builds
@@ -67,7 +80,7 @@ endif
# Default build string (git branch and commit)
ifeq (${BUILD_STRING},)
- BUILD_STRING := $(shell git log -n 1 --pretty=format:"%h")
+ BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null)
endif
VERSION_STRING := v${VERSION_MAJOR}.${VERSION_MINOR}(${PLAT},${BUILD_TYPE}):${BUILD_STRING}
@@ -94,6 +107,10 @@ ifeq ($(wildcard ${PLAT_MAKEFILE_FULL}),)
$(error "Error: Invalid platform. The following platforms are available: ${PLATFORMS}")
endif
+
+EL3_PAYLOAD_PLAT_PATH := $(shell find el3_payload/plat/ -wholename '*/${PLAT}')
+EL3_PAYLOAD_PLAT_MAKEFILE_FULL := ${EL3_PAYLOAD_PLAT_PATH}/${PLAT_MAKEFILE}
+
.PHONY: all
all: msg_start
@@ -102,22 +119,31 @@ msg_start:
@echo "Building ${PLAT}"
@echo "Selected set of tests: ${TESTS}"
+# Set flags for Realm Payload Tests
+ifeq (${ENABLE_REALM_PAYLOAD_TESTS},1)
+ARM_ARCH_MINOR := 5
+BRANCH_PROTECTION := 2
+endif
+
# Include test images makefiles.
include tftf/framework/framework.mk
include tftf/tests/tests.mk
include fwu/ns_bl1u/ns_bl1u.mk
include fwu/ns_bl2u/ns_bl2u.mk
-# Only platform fvp supports cactus_mm, ivy, quark
+# List of secure partitions present.
+SECURE_PARTITIONS :=
+
+# Only platform fvp supports cactus_mm
ifeq (${ARCH}-${PLAT},aarch64-fvp)
include spm/cactus_mm/cactus_mm.mk
-include spm/ivy/ivy.mk
-include spm/quark/quark.mk
+include realm/realm.mk
endif
-# cactus is supported on platforms: fvp, tc0
-ifeq (${ARCH}-${PLAT},$(filter ${ARCH}-${PLAT},aarch64-fvp aarch64-tc0))
+# cactus and ivy are supported on platforms: fvp, tc
+ifeq (${ARCH}-${PLAT},$(filter ${ARCH}-${PLAT},aarch64-fvp aarch64-tc))
include spm/cactus/cactus.mk
+include spm/ivy/ivy.mk
endif
################################################################################
@@ -141,6 +167,9 @@ $(eval $(call assert_boolean,FIRMWARE_UPDATE))
$(eval $(call assert_boolean,FWU_BL_TEST))
$(eval $(call assert_boolean,NEW_TEST_SESSION))
$(eval $(call assert_boolean,USE_NVM))
+$(eval $(call assert_numeric,BRANCH_PROTECTION))
+$(eval $(call assert_boolean,ENABLE_REALM_PAYLOAD_TESTS))
+$(eval $(call assert_boolean,TRANSFER_LIST))
################################################################################
# Process build options
@@ -165,17 +194,21 @@ $(eval $(call add_define,TFTF_DEFINES,LOG_LEVEL))
$(eval $(call add_define,TFTF_DEFINES,NEW_TEST_SESSION))
$(eval $(call add_define,TFTF_DEFINES,PLAT_${PLAT}))
$(eval $(call add_define,TFTF_DEFINES,USE_NVM))
+$(eval $(call add_define,TFTF_DEFINES,ENABLE_REALM_PAYLOAD_TESTS))
+$(eval $(call add_define,TFTF_DEFINES,TRANSFER_LIST))
################################################################################
+################################################################################
# Assembler, compiler and linker flags shared across all test images.
+################################################################################
COMMON_ASFLAGS :=
COMMON_CFLAGS :=
COMMON_LDFLAGS :=
ifeq (${DEBUG},1)
-COMMON_CFLAGS += -g
-COMMON_ASFLAGS += -g -Wa,--gdwarf-2
+COMMON_CFLAGS += -g -gdwarf-4
+COMMON_ASFLAGS += -g -Wa,--gdwarf-4
endif
# Set the compiler's target architecture profile based on ARM_ARCH_MINOR option
@@ -201,36 +234,68 @@ endif
$(info Arm Architecture Features specified: $(subst +, ,$(arch-features)))
endif # arch-features
-COMMON_ASFLAGS_aarch64 := -mgeneral-regs-only ${march64-directive}
-COMMON_CFLAGS_aarch64 := -mgeneral-regs-only -mstrict-align ${march64-directive}
+################################################################################
+# Compiler settings
+################################################################################
+ifneq ($(findstring clang,$(notdir $(CC))),)
+CLANG_CFLAGS_aarch64 := -target aarch64-elf
+
+CPP := $(CC) -E $(COMMON_CFLAGS_$(ARCH))
+PP := $(CC) -E $(COMMON_CFLAGS_$(ARCH))
+
+CLANG_WARNINGS += -nostdinc -ffreestanding -Wall \
+ -Wmissing-include-dirs $(CLANG_CFLAGS_$(ARCH)) \
+ -Wlogical-op-parentheses \
+ -Wno-initializer-overrides \
+ -Wno-sometimes-uninitialized \
+ -Wno-unused-function \
+ -Wno-unused-variable \
+ -Wno-unused-parameter \
+ -Wno-tautological-compare \
+ -Wno-memset-transposed-args \
+ -Wno-parentheses
+
+CLANG_CFLAGS += -Wno-error=deprecated-declarations \
+ -Wno-error=cpp \
+ $(CLANG_WARNINGS)
+endif #(clang)
+
+ifneq ($(findstring gcc,$(notdir $(CC))),)
+GCC_CFLAGS_aarch32 := ${march32-directive} -mno-unaligned-access
+GCC_CFLAGS_aarch64 := -mgeneral-regs-only
+
+GCC_ASFLAGS_aarch32 := ${march32-directive}
+GCC_ASFLAGS_aarch64 := -mgeneral-regs-only ${march64-directive}
+
+GCC_WARNINGS += -nostdinc -ffreestanding -Wall -Werror \
+ -Wmissing-include-dirs $(GCC_CFLAGS_$(ARCH)) \
+ -std=gnu99 -Os
+
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
+GCC_CFLAGS += $(call cc_option, --param=min-pagesize=0)
+GCC_CFLAGS += $(GCC_WARNINGS)
+endif #(gcc)
-COMMON_ASFLAGS_aarch32 := ${march32-directive}
-COMMON_CFLAGS_aarch32 := ${march32-directive} -mno-unaligned-access
+COMMON_CFLAGS_aarch64 += ${march64-directive} -mstrict-align \
+ $(CLANG_CFLAGS_$(ARCH)) $(GCC_CFLAGS_$(ARCH))
-COMMON_ASFLAGS += -nostdinc -ffreestanding -Wa,--fatal-warnings \
- -Werror -Wmissing-include-dirs \
- -D__ASSEMBLY__ $(COMMON_ASFLAGS_$(ARCH)) \
- ${INCLUDES}
-COMMON_CFLAGS += -nostdinc -ffreestanding -Wall -Werror \
- -Wmissing-include-dirs $(COMMON_CFLAGS_$(ARCH)) \
- -std=gnu99 -Os
+COMMON_CFLAGS += $(COMMON_CFLAGS_$(ARCH))
COMMON_CFLAGS += -ffunction-sections -fdata-sections
# Get the content of CFLAGS user defined value last so they are appended after
# the options defined in the Makefile
-COMMON_CFLAGS += ${CFLAGS} ${INCLUDES}
+COMMON_CFLAGS += ${CLANG_CFLAGS} ${GCC_CFLAGS} ${INCLUDES}
+
+COMMON_ASFLAGS += -nostdinc -ffreestanding -Wa,--fatal-warnings \
+ -Werror -Wmissing-include-dirs \
+ -D__ASSEMBLY__ $(GCC_ASFLAGS_$(ARCH)) \
+ ${INCLUDES}
-COMMON_LDFLAGS += --fatal-warnings -O1 --gc-sections --build-id=none
+COMMON_LDFLAGS += ${LDFLAGS} --fatal-warnings -O1 --gc-sections --build-id=none
-CC := ${CROSS_COMPILE}gcc
-CPP := ${CROSS_COMPILE}cpp
-AS := ${CROSS_COMPILE}gcc
-AR := ${CROSS_COMPILE}ar
-LD := ${CROSS_COMPILE}ld
-OC := ${CROSS_COMPILE}objcopy
-OD := ${CROSS_COMPILE}objdump
-NM := ${CROSS_COMPILE}nm
-PP := ${CROSS_COMPILE}gcc
+# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
+# are not loaded by a elf loader.
+COMMON_LDFLAGS += $(call ld_option, --no-warn-rwx-segments)
################################################################################
@@ -248,7 +313,7 @@ NS_BL2U_CFLAGS += -mbranch-protection=${BP_OPTION}
CACTUS_MM_CFLAGS += -mbranch-protection=${BP_OPTION}
CACTUS_CFLAGS += -mbranch-protection=${BP_OPTION}
IVY_CFLAGS += -mbranch-protection=${BP_OPTION}
-QUARK_CFLAGS += -mbranch-protection=${BP_OPTION}
+REALM_CFLAGS += -mbranch-protection=${BP_OPTION}
endif
ifeq ($(SMC_FUZZING), 1)
@@ -289,15 +354,14 @@ CACTUS_LDFLAGS += ${COMMON_LDFLAGS} $(PIE_LDFLAGS)
IVY_SOURCES += ${LIBC_SRCS}
IVY_INCLUDES += ${PLAT_INCLUDES}
-IVY_CFLAGS += ${COMMON_CFLAGS}
+IVY_CFLAGS += ${COMMON_CFLAGS} -fpie
IVY_ASFLAGS += ${COMMON_ASFLAGS}
-IVY_LDFLAGS += ${COMMON_LDFLAGS}
+IVY_LDFLAGS += ${COMMON_LDFLAGS} $(PIE_LDFLAGS)
-QUARK_SOURCES += ${LIBC_SRCS}
-QUARK_INCLUDES += ${PLAT_INCLUDES}
-QUARK_CFLAGS += ${COMMON_CFLAGS}
-QUARK_ASFLAGS += ${COMMON_ASFLAGS}
-QUARK_LDFLAGS += ${COMMON_LDFLAGS}
+REALM_SOURCES += ${LIBC_SRCS}
+REALM_CFLAGS += ${COMMON_CFLAGS} -fpie
+REALM_ASFLAGS += ${COMMON_ASFLAGS}
+REALM_LDFLAGS += ${COMMON_LDFLAGS} $(PIE_LDFLAGS)
.PHONY: locate-checkpatch
locate-checkpatch:
@@ -313,14 +377,18 @@ endif
clean:
@echo " CLEAN"
${Q}rm -rf ${BUILD_PLAT}
+ifneq ($(wildcard ${EL3_PAYLOAD_PLAT_MAKEFILE_FULL}),)
${MAKE} -C el3_payload clean
+endif
.PHONY: realclean distclean
realclean distclean:
@echo " REALCLEAN"
${Q}rm -rf ${BUILD_BASE}
${Q}rm -f ${CURDIR}/cscope.*
+ifneq ($(wildcard ${EL3_PAYLOAD_PLAT_MAKEFILE_FULL}),)
${MAKE} -C el3_payload distclean
+endif
.PHONY: checkcodebase
checkcodebase: locate-checkpatch
@@ -367,21 +435,22 @@ cactus_mm:
@echo "ERROR: $@ is supported only on AArch64 FVP."
@exit 1
-.PHONY: ivy
-ivy:
+.PHONY: realm
+realm:
@echo "ERROR: $@ is supported only on AArch64 FVP."
@exit 1
-.PHONY: quark
-quark:
- @echo "ERROR: $@ is supported only on AArch64 FVP."
- @exit 1
endif
-ifneq (${ARCH}-${PLAT},$(filter ${ARCH}-${PLAT},aarch64-fvp aarch64-tc0))
+ifneq (${ARCH}-${PLAT},$(filter ${ARCH}-${PLAT},aarch64-fvp aarch64-tc))
.PHONY: cactus
cactus:
- @echo "ERROR: $@ is supported only on AArch64 FVP or TC0."
+ @echo "ERROR: $@ is supported only on AArch64 FVP or TC."
+ @exit 1
+
+.PHONY: ivy
+ivy:
+ @echo "ERROR: $@ is supported only on AArch64 FVP or TC."
@exit 1
endif
@@ -494,22 +563,27 @@ all : $(1)
endef
+ifeq (${ARCH},aarch32)
+ ARCH_TESTS_SKIP_LIST := tftf/tests/aarch32_tests_to_skip.txt
+endif
+
$(AUTOGEN_DIR):
$(Q)mkdir -p "$@"
-$(AUTOGEN_DIR)/tests_list.c $(AUTOGEN_DIR)/tests_list.h: $(AUTOGEN_DIR) ${TESTS_FILE} ${PLAT_TESTS_SKIP_LIST}
+$(AUTOGEN_DIR)/tests_list.c $(AUTOGEN_DIR)/tests_list.h: $(AUTOGEN_DIR) ${TESTS_FILE} ${PLAT_TESTS_SKIP_LIST} $(ARCH_TESTS_SKIP_LIST)
@echo " AUTOGEN $@"
- tools/generate_test_list/generate_test_list.pl $(AUTOGEN_DIR)/tests_list.c $(AUTOGEN_DIR)/tests_list.h ${TESTS_FILE} $(PLAT_TESTS_SKIP_LIST)
+ tools/generate_test_list/generate_test_list.py $(AUTOGEN_DIR)/tests_list.c \
+ $(AUTOGEN_DIR)/tests_list.h ${TESTS_FILE} \
+ --plat-skip-file=$(PLAT_TESTS_SKIP_LIST) \
+ --arch-skip-file=$(ARCH_TESTS_SKIP_LIST)
ifeq ($(SMC_FUZZING), 1)
$(Q)mkdir -p ${BUILD_PLAT}/smcf
dtc ${SMC_FUZZ_DTS} >> ${BUILD_PLAT}/smcf/dtb
$(OC) -I binary -O elf64-littleaarch64 -B aarch64 ${BUILD_PLAT}/smcf/dtb ${BUILD_PLAT}/smcf/dtb.o \
- --redefine-sym _binary___build_fvp_debug_smcf_dtb_start=_binary___dtb_start \
- --redefine-sym _binary___build_fvp_debug_smcf_dtb_end=_binary___dtb_end
+ --redefine-sym _binary___build_$(PLAT)_$(BUILD_TYPE)_smcf_dtb_start=_binary___dtb_start \
+ --redefine-sym _binary___build_$(PLAT)_$(BUILD_TYPE)_smcf_dtb_end=_binary___dtb_end
endif
-$(eval $(call MAKE_IMG,tftf))
-
ifeq ($(FIRMWARE_UPDATE), 1)
$(eval $(call MAKE_IMG,ns_bl1u))
$(eval $(call MAKE_IMG,ns_bl2u))
@@ -519,23 +593,50 @@ ifeq (${ARCH}-${PLAT},aarch64-fvp)
$(eval $(call MAKE_IMG,cactus_mm))
$(eval $(call MAKE_IMG,cactus))
$(eval $(call MAKE_IMG,ivy))
- $(eval $(call MAKE_IMG,quark))
endif
-ifeq (${ARCH}-${PLAT},aarch64-tc0)
+.PHONY : tftf
+ $(eval $(call MAKE_IMG,tftf))
+
+# Build flag 'ENABLE_REALM_PAYLOAD_TESTS=1' builds and pack Realm Payload Tests
+ifeq (${ENABLE_REALM_PAYLOAD_TESTS},1)
+ $(eval $(call MAKE_IMG,realm))
+
+# This forces to rebuild tftf.bin. For incremental build this re-creates tftf.bin
+# and removes the old realm payload packed by the last build.
+.PHONY : $(BUILD_PLAT)/tftf.bin
+
+tftf: realm
+ @echo " PACK REALM PAYLOAD"
+ $(shell dd if=$(BUILD_PLAT)/realm.bin of=$(BUILD_PLAT)/tftf.bin obs=1 \
+ oflag=append conv=notrunc)
+endif
+
+ifeq (${ARCH}-${PLAT},aarch64-tc)
$(eval $(call MAKE_IMG,cactus))
+ $(eval $(call MAKE_IMG,ivy))
endif
+SP_LAYOUT:
+ ${Q}tools/generate_json/generate_json.sh \
+ $(BUILD_PLAT) $(SECURE_PARTITIONS)
+
# The EL3 test payload is only supported in AArch64. It has an independent build
# system.
.PHONY: el3_payload
+# TODO: EL3 test payload currently is supported for GCC only. It has an independent
+# build system and support for Clang to be added.
+ifneq ($(findstring gcc,$(notdir $(CC))),)
ifneq (${ARCH},aarch32)
+ifneq ($(wildcard ${EL3_PAYLOAD_PLAT_MAKEFILE_FULL}),)
el3_payload: $(BUILD_DIR)
${Q}${MAKE} -C el3_payload PLAT=${PLAT}
${Q}find "el3_payload/build/${PLAT}" -name '*.bin' -exec cp {} "${BUILD_PLAT}" \;
all: el3_payload
endif
+endif
+endif
doc:
@echo " BUILD DOCUMENTATION"
@@ -551,7 +652,7 @@ cscope:
.SILENT: help
help:
echo "usage: ${MAKE} PLAT=<${PLATFORMS}> \
-<all|tftf|ns_bl1u|ns_bl2u|cactus|ivy|quark|el3_payload|distclean|clean|checkcodebase|checkpatch|help_tests>"
+<all|tftf|ns_bl1u|ns_bl2u|cactus|ivy|el3_payload|distclean|clean|checkcodebase|checkpatch|help_tests>"
echo ""
echo "PLAT is used to specify which platform you wish to build."
echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
@@ -562,10 +663,9 @@ help:
echo " tftf Build the TFTF image"
echo " ns_bl1u Build the NS_BL1U image"
echo " ns_bl2u Build the NS_BL2U image"
- echo " cactus Build the Cactus image (Test S-EL0 payload) and resource description."
- echo " cactus_mm Build the Cactus-MM image (Test S-EL0 payload)."
- echo " ivy Build the Ivy image (Test S-EL0 payload) and resource description."
- echo " quark Build the Quark image (Test S-EL0 payload) and resource description."
+ echo " cactus Build the Cactus image (FF-A S-EL1 test payload)."
+ echo " cactus_mm Build the Cactus-MM image (SPM-MM S-EL0 test payload)."
+ echo " ivy Build the Ivy image (FF-A S-EL0 test payload)."
echo " el3_payload Build the EL3 test payload"
echo " checkcodebase Check the coding style of the entire source tree"
echo " checkpatch Check the coding style on changes in the current"