1# 2# Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved. 3# 4# SPDX-License-Identifier: BSD-3-Clause 5# 6 7# 8# Trusted Firmware Version 9# 10VERSION_MAJOR := 2 11VERSION_MINOR := 8 12VERSION := ${VERSION_MAJOR}.${VERSION_MINOR} 13 14# Default goal is build all images 15.DEFAULT_GOAL := all 16 17# Avoid any implicit propagation of command line variable definitions to 18# sub-Makefiles, like CFLAGS that we reserved for the firmware images' 19# usage. Other command line options like "-s" are still propagated as usual. 20MAKEOVERRIDES = 21 22MAKE_HELPERS_DIRECTORY := make_helpers/ 23include ${MAKE_HELPERS_DIRECTORY}build_macros.mk 24include ${MAKE_HELPERS_DIRECTORY}build_env.mk 25 26################################################################################ 27# Default values for build configurations, and their dependencies 28################################################################################ 29 30include ${MAKE_HELPERS_DIRECTORY}defaults.mk 31 32# Assertions enabled for DEBUG builds by default 33ENABLE_ASSERTIONS := ${DEBUG} 34ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION} 35PLAT := ${DEFAULT_PLAT} 36 37################################################################################ 38# Checkpatch script options 39################################################################################ 40 41CHECKCODE_ARGS := --no-patch 42# Do not check the coding style on imported library files or documentation files 43INC_ARM_DIRS_TO_CHECK := $(sort $(filter-out \ 44 include/drivers/arm/cryptocell, \ 45 $(wildcard include/drivers/arm/*))) 46INC_ARM_DIRS_TO_CHECK += include/drivers/arm/cryptocell/*.h 47INC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \ 48 include/drivers/arm, \ 49 $(wildcard include/drivers/*))) 50INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \ 51 include/lib/libfdt \ 52 include/lib/libc, \ 53 $(wildcard include/lib/*))) 54INC_DIRS_TO_CHECK := $(sort $(filter-out \ 55 include/lib \ 56 include/drivers, \ 57 $(wildcard include/*))) 58LIB_DIRS_TO_CHECK := $(sort $(filter-out \ 59 lib/compiler-rt \ 60 lib/libfdt% \ 61 lib/libc, \ 62 lib/zlib \ 63 $(wildcard lib/*))) 64ROOT_DIRS_TO_CHECK := $(sort $(filter-out \ 65 lib \ 66 include \ 67 docs \ 68 %.rst, \ 69 $(wildcard *))) 70CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \ 71 ${INC_DIRS_TO_CHECK} \ 72 ${INC_LIB_DIRS_TO_CHECK} \ 73 ${LIB_DIRS_TO_CHECK} \ 74 ${INC_DRV_DIRS_TO_CHECK} \ 75 ${INC_ARM_DIRS_TO_CHECK} 76 77 78################################################################################ 79# Process build options 80################################################################################ 81 82# Verbose flag 83ifeq (${V},0) 84 Q:=@ 85 ECHO:=@echo 86 CHECKCODE_ARGS += --no-summary --terse 87else 88 Q:= 89 ECHO:=$(ECHO_QUIET) 90endif 91 92ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) 93 Q:=@ 94 ECHO:=$(ECHO_QUIET) 95endif 96 97export Q ECHO 98 99# The cert_create tool cannot generate certificates individually, so we use the 100# target 'certificates' to create them all 101ifneq (${GENERATE_COT},0) 102 FIP_DEPS += certificates 103 FWU_FIP_DEPS += fwu_certificates 104endif 105 106# Process BRANCH_PROTECTION value and set 107# Pointer Authentication and Branch Target Identification flags 108ifeq (${BRANCH_PROTECTION},0) 109 # Default value turns off all types of branch protection 110 BP_OPTION := none 111else ifneq (${ARCH},aarch64) 112 $(error BRANCH_PROTECTION requires AArch64) 113else ifeq (${BRANCH_PROTECTION},1) 114 # Enables all types of branch protection features 115 BP_OPTION := standard 116 ENABLE_BTI := 1 117 ENABLE_PAUTH := 1 118else ifeq (${BRANCH_PROTECTION},2) 119 # Return address signing to its standard level 120 BP_OPTION := pac-ret 121 ENABLE_PAUTH := 1 122else ifeq (${BRANCH_PROTECTION},3) 123 # Extend the signing to include leaf functions 124 BP_OPTION := pac-ret+leaf 125 ENABLE_PAUTH := 1 126else ifeq (${BRANCH_PROTECTION},4) 127 # Turn on branch target identification mechanism 128 BP_OPTION := bti 129 ENABLE_BTI := 1 130else 131 $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION}) 132endif 133 134# FEAT_RME 135ifeq (${ENABLE_RME},1) 136# RME doesn't support PIE 137ifneq (${ENABLE_PIE},0) 138 $(error ENABLE_RME does not support PIE) 139endif 140# RME doesn't support BRBE 141ifneq (${ENABLE_BRBE_FOR_NS},0) 142 $(error ENABLE_RME does not support BRBE.) 143endif 144# RME requires AARCH64 145ifneq (${ARCH},aarch64) 146 $(error ENABLE_RME requires AArch64) 147endif 148# RME requires el2 context to be saved for now. 149CTX_INCLUDE_EL2_REGS := 1 150CTX_INCLUDE_AARCH32_REGS := 0 151ARM_ARCH_MAJOR := 8 152ARM_ARCH_MINOR := 5 153ENABLE_FEAT_ECV = 1 154ENABLE_FEAT_FGT = 1 155 156# RME enables CSV2_2 extension by default. 157ENABLE_FEAT_CSV2_2 = 1 158 159endif 160 161# USE_SPINLOCK_CAS requires AArch64 build 162ifeq (${USE_SPINLOCK_CAS},1) 163ifneq (${ARCH},aarch64) 164 $(error USE_SPINLOCK_CAS requires AArch64) 165endif 166endif 167 168# USE_DEBUGFS experimental feature recommended only in debug builds 169ifeq (${USE_DEBUGFS},1) 170ifeq (${DEBUG},1) 171 $(warning DEBUGFS experimental feature is enabled.) 172else 173 $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY) 174endif 175endif 176 177ifneq (${DECRYPTION_SUPPORT},none) 178ENC_ARGS += -f ${FW_ENC_STATUS} 179ENC_ARGS += -k ${ENC_KEY} 180ENC_ARGS += -n ${ENC_NONCE} 181FIP_DEPS += enctool 182FWU_FIP_DEPS += enctool 183endif 184 185################################################################################ 186# Toolchain 187################################################################################ 188 189HOSTCC := gcc 190export HOSTCC 191 192CC := ${CROSS_COMPILE}gcc 193CPP := ${CROSS_COMPILE}cpp 194AS := ${CROSS_COMPILE}gcc 195AR := ${CROSS_COMPILE}ar 196LINKER := ${CROSS_COMPILE}ld 197OC := ${CROSS_COMPILE}objcopy 198OD := ${CROSS_COMPILE}objdump 199NM := ${CROSS_COMPILE}nm 200PP := ${CROSS_COMPILE}gcc -E 201DTC := dtc 202 203# Use ${LD}.bfd instead if it exists (as absolute path or together with $PATH). 204ifneq ($(strip $(wildcard ${LD}.bfd) \ 205 $(foreach dir,$(subst :, ,${PATH}),$(wildcard ${dir}/${LINKER}.bfd))),) 206LINKER := ${LINKER}.bfd 207endif 208 209ifeq (${ARM_ARCH_MAJOR},7) 210target32-directive = -target arm-none-eabi 211# Will set march32-directive from platform configuration 212else 213target32-directive = -target armv8a-none-eabi 214 215# Set the compiler's target architecture profile based on 216# ARM_ARCH_MAJOR ARM_ARCH_MINOR options 217ifeq (${ARM_ARCH_MINOR},0) 218march32-directive = -march=armv${ARM_ARCH_MAJOR}-a 219march64-directive = -march=armv${ARM_ARCH_MAJOR}-a 220else 221march32-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a 222march64-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a 223endif 224endif 225 226# Memory tagging is supported in architecture Armv8.5-A AArch64 and onwards 227ifeq ($(ARCH), aarch64) 228# Check if revision is greater than or equal to 8.5 229ifeq "8.5" "$(word 1, $(sort 8.5 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))" 230mem_tag_arch_support = yes 231endif 232endif 233 234# Get architecture feature modifiers 235arch-features = ${ARM_ARCH_FEATURE} 236 237# Enable required options for memory stack tagging. 238# Currently, these options are enabled only for clang and armclang compiler. 239ifeq (${SUPPORT_STACK_MEMTAG},yes) 240ifdef mem_tag_arch_support 241# Check for armclang and clang compilers 242ifneq ( ,$(filter $(notdir $(CC)),armclang clang)) 243# Add "memtag" architecture feature modifier if not specified 244ifeq ( ,$(findstring memtag,$(arch-features))) 245arch-features := $(arch-features)+memtag 246endif # memtag 247ifeq ($(notdir $(CC)),armclang) 248TF_CFLAGS += -mmemtag-stack 249else ifeq ($(notdir $(CC)),clang) 250TF_CFLAGS += -fsanitize=memtag 251endif # armclang 252endif # armclang clang 253else 254$(error "Error: stack memory tagging is not supported for architecture \ 255 ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a") 256endif # mem_tag_arch_support 257endif # SUPPORT_STACK_MEMTAG 258 259# Set the compiler's architecture feature modifiers 260ifneq ($(arch-features), none) 261# Strip "none+" from arch-features 262arch-features := $(subst none+,,$(arch-features)) 263ifeq ($(ARCH), aarch32) 264march32-directive := $(march32-directive)+$(arch-features) 265else 266march64-directive := $(march64-directive)+$(arch-features) 267endif 268# Print features 269$(info Arm Architecture Features specified: $(subst +, ,$(arch-features))) 270endif # arch-features 271 272# Determine if FEAT_RNG is supported 273ENABLE_FEAT_RNG = $(if $(findstring rng,${arch-features}),1,0) 274 275# Determine if FEAT_SB is supported 276ENABLE_FEAT_SB = $(if $(findstring sb,${arch-features}),1,0) 277 278ifneq ($(findstring clang,$(notdir $(CC))),) 279 ifneq ($(findstring armclang,$(notdir $(CC))),) 280 TF_CFLAGS_aarch32 := -target arm-arm-none-eabi $(march32-directive) 281 TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi $(march64-directive) 282 LD := $(LINKER) 283 else 284 TF_CFLAGS_aarch32 = $(target32-directive) $(march32-directive) 285 TF_CFLAGS_aarch64 := -target aarch64-elf $(march64-directive) 286 LD := $(shell $(CC) --print-prog-name ld.lld) 287 288 AR := $(shell $(CC) --print-prog-name llvm-ar) 289 OD := $(shell $(CC) --print-prog-name llvm-objdump) 290 OC := $(shell $(CC) --print-prog-name llvm-objcopy) 291 endif 292 293 CPP := $(CC) -E $(TF_CFLAGS_$(ARCH)) 294 PP := $(CC) -E $(TF_CFLAGS_$(ARCH)) 295 AS := $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH)) 296else ifneq ($(findstring gcc,$(notdir $(CC))),) 297TF_CFLAGS_aarch32 = $(march32-directive) 298TF_CFLAGS_aarch64 = $(march64-directive) 299ifeq ($(ENABLE_LTO),1) 300 # Enable LTO only for aarch64 301 ifeq (${ARCH},aarch64) 302 LTO_CFLAGS = -flto 303 # Use gcc as a wrapper for the ld, recommended for LTO 304 LINKER := ${CROSS_COMPILE}gcc 305 endif 306endif 307LD = $(LINKER) 308else 309TF_CFLAGS_aarch32 = $(march32-directive) 310TF_CFLAGS_aarch64 = $(march64-directive) 311LD = $(LINKER) 312endif 313 314# Process Debug flag 315$(eval $(call add_define,DEBUG)) 316ifneq (${DEBUG}, 0) 317 BUILD_TYPE := debug 318 TF_CFLAGS += -g -gdwarf-4 319 ASFLAGS += -g -Wa,-gdwarf-4 320 321 # Use LOG_LEVEL_INFO by default for debug builds 322 LOG_LEVEL := 40 323else 324 BUILD_TYPE := release 325 # Use LOG_LEVEL_NOTICE by default for release builds 326 LOG_LEVEL := 20 327endif 328 329# Default build string (git branch and commit) 330ifeq (${BUILD_STRING},) 331 BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null) 332endif 333VERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING} 334 335ifeq (${AARCH32_INSTRUCTION_SET},A32) 336TF_CFLAGS_aarch32 += -marm 337else ifeq (${AARCH32_INSTRUCTION_SET},T32) 338TF_CFLAGS_aarch32 += -mthumb 339else 340$(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET}) 341endif 342 343TF_CFLAGS_aarch32 += -mno-unaligned-access 344TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align 345 346ifneq (${BP_OPTION},none) 347TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION} 348endif 349 350ASFLAGS_aarch32 = $(march32-directive) 351ASFLAGS_aarch64 = $(march64-directive) 352 353# General warnings 354WARNINGS := -Wall -Wmissing-include-dirs -Wunused \ 355 -Wdisabled-optimization -Wvla -Wshadow \ 356 -Wredundant-decls 357# stricter warnings 358WARNINGS += -Wextra -Wno-trigraphs 359# too verbose for generic build 360WARNINGS += -Wno-missing-field-initializers \ 361 -Wno-type-limits -Wno-sign-compare \ 362# on clang this flag gets reset if -Wextra is set after it. No difference on gcc 363WARNINGS += -Wno-unused-parameter 364 365# Additional warnings 366# Level 1 - infrequent warnings we should have none of 367# full -Wextra 368WARNING1 += -Wsign-compare 369WARNING1 += -Wtype-limits 370WARNING1 += -Wmissing-field-initializers 371 372# Level 2 - problematic warnings that we want 373# zlib, compiler-rt, coreboot, and mbdedtls blow up with these 374# TODO: disable just for them and move into default build 375WARNING2 += -Wold-style-definition 376WARNING2 += -Wmissing-prototypes 377WARNING2 += -Wmissing-format-attribute 378# TF-A aims to comply with this eventually. Effort too large at present 379WARNING2 += -Wundef 380# currently very involved and many platforms set this off 381WARNING2 += -Wunused-const-variable=2 382 383# Level 3 - very pedantic, frequently ignored 384WARNING3 := -Wbad-function-cast 385WARNING3 += -Waggregate-return 386WARNING3 += -Wnested-externs 387WARNING3 += -Wcast-align 388WARNING3 += -Wcast-qual 389WARNING3 += -Wconversion 390WARNING3 += -Wpacked 391WARNING3 += -Wpointer-arith 392WARNING3 += -Wswitch-default 393 394# Setting W is quite verbose and most warnings will be pre-existing issues 395# outside of the contributor's control. Don't fail the build on them so warnings 396# can be seen and hopefully addressed 397ifdef W 398ifneq (${W},0) 399E ?= 0 400endif 401endif 402 403ifeq (${W},1) 404WARNINGS += $(WARNING1) 405else ifeq (${W},2) 406WARNINGS += $(WARNING1) $(WARNING2) 407else ifeq (${W},3) 408WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3) 409endif 410 411# Compiler specific warnings 412ifeq ($(findstring clang,$(notdir $(CC))),) 413# not using clang 414WARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \ 415 -Wpacked-bitfield-compat -Wshift-overflow=2 \ 416 -Wlogical-op 417else 418# using clang 419WARNINGS += -Wshift-overflow -Wshift-sign-overflow \ 420 -Wlogical-op-parentheses 421endif 422 423ifneq (${E},0) 424ERRORS := -Werror 425endif 426 427CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \ 428 $(ERRORS) $(WARNINGS) 429ASFLAGS += $(CPPFLAGS) $(ASFLAGS_$(ARCH)) \ 430 -ffreestanding -Wa,--fatal-warnings 431TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \ 432 -ffunction-sections -fdata-sections \ 433 -ffreestanding -fno-builtin -fno-common \ 434 -Os -std=gnu99 435 436$(eval $(call add_define,SVE_VECTOR_LEN)) 437 438ifeq (${SANITIZE_UB},on) 439TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover 440endif 441ifeq (${SANITIZE_UB},trap) 442TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \ 443 -fsanitize-undefined-trap-on-error 444endif 445 446GCC_V_OUTPUT := $(shell $(CC) -v 2>&1) 447 448# LD = armlink 449ifneq ($(findstring armlink,$(notdir $(LD))),) 450TF_LDFLAGS += --diag_error=warning --lto_level=O1 451TF_LDFLAGS += --remove --info=unused,unusedsymbols 452TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) 453 454# LD = gcc (used when GCC LTO is enabled) 455else ifneq ($(findstring gcc,$(notdir $(LD))),) 456# Pass ld options with Wl or Xlinker switches 457TF_LDFLAGS += -Wl,--fatal-warnings -O1 458TF_LDFLAGS += -Wl,--gc-sections 459ifeq ($(ENABLE_LTO),1) 460 ifeq (${ARCH},aarch64) 461 TF_LDFLAGS += -flto -fuse-linker-plugin 462 endif 463endif 464# GCC automatically adds fix-cortex-a53-843419 flag when used to link 465# which breaks some builds, so disable if errata fix is not explicitly enabled 466ifneq (${ERRATA_A53_843419},1) 467 TF_LDFLAGS += -mno-fix-cortex-a53-843419 468endif 469TF_LDFLAGS += -nostdlib 470TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH))) 471 472# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other 473else 474TF_LDFLAGS += --fatal-warnings -O1 475TF_LDFLAGS += --gc-sections 476# ld.lld doesn't recognize the errata flags, 477# therefore don't add those in that case 478ifeq ($(findstring ld.lld,$(notdir $(LD))),) 479TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) 480endif 481endif 482 483DTC_FLAGS += -I dts -O dtb 484DTC_CPPFLAGS += -P -nostdinc -Iinclude -Ifdts -undef \ 485 -x assembler-with-cpp $(DEFINES) 486 487################################################################################ 488# Common sources and include directories 489################################################################################ 490include ${MAKE_HELPERS_DIRECTORY}arch_features.mk 491include lib/compiler-rt/compiler-rt.mk 492 493BL_COMMON_SOURCES += common/bl_common.c \ 494 common/tf_log.c \ 495 common/${ARCH}/debug.S \ 496 drivers/console/multi_console.c \ 497 lib/${ARCH}/cache_helpers.S \ 498 lib/${ARCH}/misc_helpers.S \ 499 plat/common/plat_bl_common.c \ 500 plat/common/plat_log_common.c \ 501 plat/common/${ARCH}/plat_common.c \ 502 plat/common/${ARCH}/platform_helpers.S \ 503 ${COMPILER_RT_SRCS} 504 505ifeq ($(notdir $(CC)),armclang) 506BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S 507endif 508 509ifeq (${SANITIZE_UB},on) 510BL_COMMON_SOURCES += plat/common/ubsan.c 511endif 512 513INCLUDES += -Iinclude \ 514 -Iinclude/arch/${ARCH} \ 515 -Iinclude/lib/cpus/${ARCH} \ 516 -Iinclude/lib/el3_runtime/${ARCH} \ 517 ${PLAT_INCLUDES} \ 518 ${SPD_INCLUDES} 519 520include common/backtrace/backtrace.mk 521 522################################################################################ 523# Generic definitions 524################################################################################ 525 526include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk 527 528ifeq (${BUILD_BASE},) 529 BUILD_BASE := ./build 530endif 531BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE} 532 533SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*)))) 534 535# Platforms providing their own TBB makefile may override this value 536INCLUDE_TBBR_MK := 1 537 538 539################################################################################ 540# Include SPD Makefile if one has been specified 541################################################################################ 542 543ifneq (${SPD},none) 544 ifeq (${ARCH},aarch32) 545 $(error "Error: SPD is incompatible with AArch32.") 546 endif 547 548 ifdef EL3_PAYLOAD_BASE 549 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.") 550 $(warning "The SPD and its BL32 companion will be present but ignored.") 551 endif 552 553 ifeq (${SPD},spmd) 554 # SPMD is located in std_svc directory 555 SPD_DIR := std_svc 556 557 ifeq ($(SPMD_SPM_AT_SEL2),1) 558 CTX_INCLUDE_EL2_REGS := 1 559 ifeq ($(SPMC_AT_EL3),1) 560 $(error SPM cannot be enabled in both S-EL2 and EL3.) 561 endif 562 endif 563 564 ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp) 565 DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG 566 endif 567 568 ifeq ($(TS_SP_FW_CONFIG),1) 569 DTC_CPPFLAGS += -DTS_SP_FW_CONFIG 570 endif 571 572 ifneq ($(ARM_BL2_SP_LIST_DTS),) 573 DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS) 574 endif 575 576 ifneq ($(SP_LAYOUT_FILE),) 577 BL2_ENABLE_SP_LOAD := 1 578 endif 579 else 580 # All other SPDs in spd directory 581 SPD_DIR := spd 582 endif 583 584 # We expect to locate an spd.mk under the specified SPD directory 585 SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk) 586 587 ifeq (${SPD_MAKE},) 588 $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located) 589 endif 590 $(info Including ${SPD_MAKE}) 591 include ${SPD_MAKE} 592 593 # If there's BL32 companion for the chosen SPD, we expect that the SPD's 594 # Makefile would set NEED_BL32 to "yes". In this case, the build system 595 # supports two mutually exclusive options: 596 # * BL32 is built from source: then BL32_SOURCES must contain the list 597 # of source files to build BL32 598 # * BL32 is a prebuilt binary: then BL32 must point to the image file 599 # that will be included in the FIP 600 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence 601 # over the sources. 602endif 603 604ifeq (${CTX_INCLUDE_EL2_REGS}, 1) 605ifeq (${SPD},none) 606ifeq (${ENABLE_RME},0) 607 $(error CTX_INCLUDE_EL2_REGS is available only when SPD or RME is enabled) 608endif 609endif 610endif 611 612################################################################################ 613# Include rmmd Makefile if RME is enabled 614################################################################################ 615 616ifneq (${ENABLE_RME},0) 617ifneq (${ARCH},aarch64) 618 $(error ENABLE_RME requires AArch64) 619endif 620ifeq ($(SPMC_AT_EL3),1) 621 $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.) 622endif 623include services/std_svc/rmmd/rmmd.mk 624$(warning "RME is an experimental feature") 625endif 626 627################################################################################ 628# Include the platform specific Makefile after the SPD Makefile (the platform 629# makefile may use all previous definitions in this file) 630################################################################################ 631 632include ${PLAT_MAKEFILE_FULL} 633 634$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT})) 635 636ifeq (${ARM_ARCH_MAJOR},7) 637include make_helpers/armv7-a-cpus.mk 638endif 639 640PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT}) 641ifneq ($(PIE_FOUND),) 642 TF_CFLAGS += -fno-PIE 643ifneq ($(findstring gcc,$(notdir $(LD))),) 644 TF_LDFLAGS += -no-pie 645endif 646endif 647 648ifneq ($(findstring gcc,$(notdir $(LD))),) 649 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker 650else 651 PIE_LDFLAGS += -pie --no-dynamic-linker 652endif 653 654ifeq ($(ENABLE_PIE),1) 655ifeq ($(BL2_AT_EL3),1) 656ifneq ($(BL2_IN_XIP_MEM),1) 657 BL2_CPPFLAGS += -fpie 658 BL2_CFLAGS += -fpie 659 BL2_LDFLAGS += $(PIE_LDFLAGS) 660endif 661endif 662 BL31_CPPFLAGS += -fpie 663 BL31_CFLAGS += -fpie 664 BL31_LDFLAGS += $(PIE_LDFLAGS) 665 666 BL32_CPPFLAGS += -fpie 667 BL32_CFLAGS += -fpie 668 BL32_LDFLAGS += $(PIE_LDFLAGS) 669endif 670 671ifeq (${ARCH},aarch64) 672BL1_CPPFLAGS += -DIMAGE_AT_EL3 673ifeq ($(BL2_AT_EL3),1) 674BL2_CPPFLAGS += -DIMAGE_AT_EL3 675else 676BL2_CPPFLAGS += -DIMAGE_AT_EL1 677endif 678BL2U_CPPFLAGS += -DIMAGE_AT_EL1 679BL31_CPPFLAGS += -DIMAGE_AT_EL3 680BL32_CPPFLAGS += -DIMAGE_AT_EL1 681endif 682 683# Include the CPU specific operations makefile, which provides default 684# values for all CPU errata workarounds and CPU specific optimisations. 685# This can be overridden by the platform. 686include lib/cpus/cpu-ops.mk 687 688ifeq (${ARCH},aarch32) 689NEED_BL32 := yes 690 691################################################################################ 692# Build `AARCH32_SP` as BL32 image for AArch32 693################################################################################ 694ifneq (${AARCH32_SP},none) 695# We expect to locate an sp.mk under the specified AARCH32_SP directory 696AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk) 697 698ifeq (${AARCH32_SP_MAKE},) 699 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located) 700endif 701 702$(info Including ${AARCH32_SP_MAKE}) 703include ${AARCH32_SP_MAKE} 704endif 705 706endif 707 708################################################################################ 709# Include libc if not overridden 710################################################################################ 711ifeq (${OVERRIDE_LIBC},0) 712include lib/libc/libc.mk 713endif 714 715################################################################################ 716# Check incompatible options 717################################################################################ 718 719ifdef EL3_PAYLOAD_BASE 720 ifdef PRELOADED_BL33_BASE 721 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \ 722 incompatible build options. EL3_PAYLOAD_BASE has priority.") 723 endif 724 ifneq (${GENERATE_COT},0) 725 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible build options.") 726 endif 727 ifneq (${TRUSTED_BOARD_BOOT},0) 728 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are incompatible build options.") 729 endif 730endif 731 732ifeq (${NEED_BL33},yes) 733 ifdef EL3_PAYLOAD_BASE 734 $(warning "BL33 image is not needed when option \ 735 BL33_PAYLOAD_BASE is used and won't be added to the FIP file.") 736 endif 737 ifdef PRELOADED_BL33_BASE 738 $(warning "BL33 image is not needed when option \ 739 PRELOADED_BL33_BASE is used and won't be added to the FIP \ 740 file.") 741 endif 742endif 743 744# When building for systems with hardware-assisted coherency, there's no need to 745# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too. 746ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1) 747$(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY) 748endif 749 750#For now, BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is 1. 751ifeq ($(BL2_AT_EL3)-$(BL2_IN_XIP_MEM),0-1) 752$(error "BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is enabled") 753endif 754 755# For RAS_EXTENSION, require that EAs are handled in EL3 first 756ifeq ($(RAS_EXTENSION),1) 757 ifneq ($(HANDLE_EA_EL3_FIRST_NS),1) 758 $(error For RAS_EXTENSION, HANDLE_EA_EL3_FIRST_NS must also be 1) 759 endif 760endif 761 762# When FAULT_INJECTION_SUPPORT is used, require that RAS_EXTENSION is enabled 763ifeq ($(FAULT_INJECTION_SUPPORT),1) 764 ifneq ($(RAS_EXTENSION),1) 765 $(error For FAULT_INJECTION_SUPPORT, RAS_EXTENSION must also be 1) 766 endif 767endif 768 769# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1 770ifeq ($(DYN_DISABLE_AUTH), 1) 771 ifeq (${TRUSTED_BOARD_BOOT}, 0) 772 $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH to be set.") 773 endif 774endif 775 776ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1) 777# Support authentication verification and hash calculation 778 CRYPTO_SUPPORT := 3 779else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1) 780# Support authentication verification and hash calculation 781 CRYPTO_SUPPORT := 3 782else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),) 783# Support hash calculation only 784 CRYPTO_SUPPORT := 2 785else ifeq (${TRUSTED_BOARD_BOOT},1) 786# Support authentication verification only 787 CRYPTO_SUPPORT := 1 788else 789 CRYPTO_SUPPORT := 0 790endif 791 792# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled. 793ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1) 794$(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled") 795endif 796 797# If pointer authentication is used in the firmware, make sure that all the 798# registers associated to it are also saved and restored. 799# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1. 800ifeq ($(ENABLE_PAUTH),1) 801 ifeq ($(CTX_INCLUDE_PAUTH_REGS),0) 802 $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1) 803 endif 804endif 805 806ifeq ($(CTX_INCLUDE_PAUTH_REGS),1) 807 ifneq (${ARCH},aarch64) 808 $(error CTX_INCLUDE_PAUTH_REGS requires AArch64) 809 endif 810endif 811 812ifeq ($(CTX_INCLUDE_MTE_REGS),1) 813 ifneq (${ARCH},aarch64) 814 $(error CTX_INCLUDE_MTE_REGS requires AArch64) 815 endif 816endif 817 818ifeq ($(PSA_FWU_SUPPORT),1) 819 $(info PSA_FWU_SUPPORT is an experimental feature) 820endif 821 822ifeq ($(FEATURE_DETECTION),1) 823 $(info FEATURE_DETECTION is an experimental feature) 824endif 825 826ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1) 827 ifeq (${ALLOW_RO_XLAT_TABLES}, 1) 828 $(error "ALLOW_RO_XLAT_TABLES requires translation tables library v2") 829 endif 830endif 831 832ifneq (${DECRYPTION_SUPPORT},none) 833 ifeq (${TRUSTED_BOARD_BOOT}, 0) 834 $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT to be set) 835 endif 836endif 837 838# Ensure that no Aarch64-only features are enabled in Aarch32 build 839ifeq (${ARCH},aarch32) 840 841 # SME/SVE only supported on AArch64 842 ifeq (${ENABLE_SME_FOR_NS},1) 843 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32") 844 endif 845 ifeq (${ENABLE_SVE_FOR_NS},1) 846 # Warning instead of error due to CI dependency on this 847 $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32") 848 endif 849 850 # BRBE is not supported in AArch32 851 ifeq (${ENABLE_BRBE_FOR_NS},1) 852 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32") 853 endif 854 855 # FEAT_RNG_TRAP is not supported in AArch32 856 ifeq (${ENABLE_FEAT_RNG_TRAP},1) 857 $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32") 858 endif 859endif 860 861# Ensure ENABLE_RME is not used with SME 862ifeq (${ENABLE_RME},1) 863 ifeq (${ENABLE_SME_FOR_NS},1) 864 $(error "ENABLE_SME_FOR_NS cannot be used with ENABLE_RME") 865 endif 866endif 867 868# Secure SME/SVE requires the non-secure component as well 869ifeq (${ENABLE_SME_FOR_SWD},1) 870 ifeq (${ENABLE_SME_FOR_NS},0) 871 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS") 872 endif 873endif 874ifeq (${ENABLE_SVE_FOR_SWD},1) 875 ifeq (${ENABLE_SVE_FOR_NS},0) 876 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS") 877 endif 878endif 879 880# SVE and SME cannot be used with CTX_INCLUDE_FPREGS since secure manager does 881# its own context management including FPU registers. 882ifeq (${CTX_INCLUDE_FPREGS},1) 883 ifeq (${ENABLE_SME_FOR_NS},1) 884 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS") 885 endif 886 ifeq (${ENABLE_SVE_FOR_NS},1) 887 # Warning instead of error due to CI dependency on this 888 $(warning "ENABLE_SVE_FOR_NS cannot be used with CTX_INCLUDE_FPREGS") 889 $(warning "Forced ENABLE_SVE_FOR_NS=0") 890 override ENABLE_SVE_FOR_NS := 0 891 endif 892endif 893 894ifeq ($(DRTM_SUPPORT),1) 895 $(info DRTM_SUPPORT is an experimental feature) 896endif 897 898ifeq (${ENABLE_RME},1) 899 ifneq (${SEPARATE_CODE_AND_RODATA},1) 900 $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`) 901 endif 902endif 903 904################################################################################ 905# Process platform overrideable behaviour 906################################################################################ 907 908ifdef BL1_SOURCES 909NEED_BL1 := yes 910endif 911 912ifdef BL2_SOURCES 913 NEED_BL2 := yes 914 915 # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and 916 # Certificate generation tools. This flag can be overridden by the platform. 917 ifdef EL3_PAYLOAD_BASE 918 # If booting an EL3 payload there is no need for a BL33 image 919 # in the FIP file. 920 NEED_BL33 := no 921 else 922 ifdef PRELOADED_BL33_BASE 923 # If booting a BL33 preloaded image there is no need of 924 # another one in the FIP file. 925 NEED_BL33 := no 926 else 927 NEED_BL33 ?= yes 928 endif 929 endif 930endif 931 932ifdef BL2U_SOURCES 933NEED_BL2U := yes 934endif 935 936# If SCP_BL2 is given, we always want FIP to include it. 937ifdef SCP_BL2 938 NEED_SCP_BL2 := yes 939endif 940 941# For AArch32, BL31 is not currently supported. 942ifneq (${ARCH},aarch32) 943 ifdef BL31_SOURCES 944 # When booting an EL3 payload, there is no need to compile the BL31 image nor 945 # put it in the FIP. 946 ifndef EL3_PAYLOAD_BASE 947 NEED_BL31 := yes 948 endif 949 endif 950endif 951 952# Process TBB related flags 953ifneq (${GENERATE_COT},0) 954 # Common cert_create options 955 ifneq (${CREATE_KEYS},0) 956 $(eval CRT_ARGS += -n) 957 $(eval FWU_CRT_ARGS += -n) 958 ifneq (${SAVE_KEYS},0) 959 $(eval CRT_ARGS += -k) 960 $(eval FWU_CRT_ARGS += -k) 961 endif 962 endif 963 # Include TBBR makefile (unless the platform indicates otherwise) 964 ifeq (${INCLUDE_TBBR_MK},1) 965 include make_helpers/tbbr/tbbr_tools.mk 966 endif 967endif 968 969ifneq (${FIP_ALIGN},0) 970FIP_ARGS += --align ${FIP_ALIGN} 971endif 972 973ifdef FDT_SOURCES 974NEED_FDT := yes 975endif 976 977################################################################################ 978# Include libraries' Makefile that are used in all BL 979################################################################################ 980 981include lib/stack_protector/stack_protector.mk 982 983################################################################################ 984# Auxiliary tools (fiptool, cert_create, etc) 985################################################################################ 986 987# Variables for use with Certificate Generation Tool 988CRTTOOLPATH ?= tools/cert_create 989CRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT} 990 991# Variables for use with Firmware Encryption Tool 992ENCTOOLPATH ?= tools/encrypt_fw 993ENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT} 994 995# Variables for use with Firmware Image Package 996FIPTOOLPATH ?= tools/fiptool 997FIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT} 998 999# Variables for use with sptool 1000SPTOOLPATH ?= tools/sptool 1001SPTOOL ?= ${SPTOOLPATH}/sptool.py 1002SP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py 1003 1004# Variables for use with ROMLIB 1005ROMLIBPATH ?= lib/romlib 1006 1007# Variable for use with Python 1008PYTHON ?= python3 1009 1010# Variables for use with PRINT_MEMORY_MAP 1011PRINT_MEMORY_MAP_PATH ?= tools/memory 1012PRINT_MEMORY_MAP ?= ${PRINT_MEMORY_MAP_PATH}/print_memory_map.py 1013 1014# Variables for use with documentation build using Sphinx tool 1015DOCS_PATH ?= docs 1016 1017# Defination of SIMICS flag 1018SIMICS_BUILD ?= 0 1019 1020################################################################################ 1021# Include BL specific makefiles 1022################################################################################ 1023 1024ifeq (${NEED_BL1},yes) 1025include bl1/bl1.mk 1026endif 1027 1028ifeq (${NEED_BL2},yes) 1029include bl2/bl2.mk 1030endif 1031 1032ifeq (${NEED_BL2U},yes) 1033include bl2u/bl2u.mk 1034endif 1035 1036ifeq (${NEED_BL31},yes) 1037include bl31/bl31.mk 1038endif 1039 1040################################################################################ 1041# Build options checks 1042################################################################################ 1043 1044$(eval $(call assert_booleans,\ 1045 $(sort \ 1046 ALLOW_RO_XLAT_TABLES \ 1047 BL2_ENABLE_SP_LOAD \ 1048 COLD_BOOT_SINGLE_CPU \ 1049 CREATE_KEYS \ 1050 CTX_INCLUDE_AARCH32_REGS \ 1051 CTX_INCLUDE_FPREGS \ 1052 CTX_INCLUDE_EL2_REGS \ 1053 DEBUG \ 1054 DISABLE_MTPMU \ 1055 DYN_DISABLE_AUTH \ 1056 EL3_EXCEPTION_HANDLING \ 1057 ENABLE_AMU \ 1058 ENABLE_AMU_AUXILIARY_COUNTERS \ 1059 ENABLE_AMU_FCONF \ 1060 AMU_RESTRICT_COUNTERS \ 1061 ENABLE_ASSERTIONS \ 1062 ENABLE_PIE \ 1063 ENABLE_PMF \ 1064 ENABLE_PSCI_STAT \ 1065 ENABLE_RUNTIME_INSTRUMENTATION \ 1066 ENABLE_SME_FOR_NS \ 1067 ENABLE_SME_FOR_SWD \ 1068 ENABLE_SPE_FOR_LOWER_ELS \ 1069 ENABLE_SVE_FOR_NS \ 1070 ENABLE_SVE_FOR_SWD \ 1071 ERROR_DEPRECATED \ 1072 FAULT_INJECTION_SUPPORT \ 1073 GENERATE_COT \ 1074 GICV2_G0_FOR_EL3 \ 1075 HANDLE_EA_EL3_FIRST_NS \ 1076 HW_ASSISTED_COHERENCY \ 1077 INVERTED_MEMMAP \ 1078 MEASURED_BOOT \ 1079 DRTM_SUPPORT \ 1080 NS_TIMER_SWITCH \ 1081 OVERRIDE_LIBC \ 1082 PL011_GENERIC_UART \ 1083 PLAT_RSS_NOT_SUPPORTED \ 1084 PROGRAMMABLE_RESET_ADDRESS \ 1085 PSCI_EXTENDED_STATE_ID \ 1086 RESET_TO_BL31 \ 1087 RESET_TO_BL31_WITH_PARAMS \ 1088 SAVE_KEYS \ 1089 SEPARATE_CODE_AND_RODATA \ 1090 SEPARATE_BL2_NOLOAD_REGION \ 1091 SEPARATE_NOBITS_REGION \ 1092 SPIN_ON_BL1_EXIT \ 1093 SPM_MM \ 1094 SPMC_AT_EL3 \ 1095 SPMD_SPM_AT_SEL2 \ 1096 TRUSTED_BOARD_BOOT \ 1097 USE_COHERENT_MEM \ 1098 USE_DEBUGFS \ 1099 ARM_IO_IN_DTB \ 1100 SDEI_IN_FCONF \ 1101 SEC_INT_DESC_IN_FCONF \ 1102 USE_ROMLIB \ 1103 USE_TBBR_DEFS \ 1104 WARMBOOT_ENABLE_DCACHE_EARLY \ 1105 BL2_AT_EL3 \ 1106 BL2_IN_XIP_MEM \ 1107 BL2_INV_DCACHE \ 1108 USE_SPINLOCK_CAS \ 1109 ENCRYPT_BL31 \ 1110 ENCRYPT_BL32 \ 1111 ERRATA_SPECULATIVE_AT \ 1112 RAS_TRAP_NS_ERR_REC_ACCESS \ 1113 COT_DESC_IN_DTB \ 1114 USE_SP804_TIMER \ 1115 PSA_FWU_SUPPORT \ 1116 ENABLE_SYS_REG_TRACE_FOR_NS \ 1117 ENABLE_MPMM \ 1118 ENABLE_MPMM_FCONF \ 1119 SIMICS_BUILD \ 1120 FEATURE_DETECTION \ 1121 TRNG_SUPPORT \ 1122 CONDITIONAL_CMO \ 1123))) 1124 1125$(eval $(call assert_numerics,\ 1126 $(sort \ 1127 ARM_ARCH_MAJOR \ 1128 ARM_ARCH_MINOR \ 1129 BRANCH_PROTECTION \ 1130 CTX_INCLUDE_PAUTH_REGS \ 1131 CTX_INCLUDE_MTE_REGS \ 1132 CTX_INCLUDE_NEVE_REGS \ 1133 CRYPTO_SUPPORT \ 1134 ENABLE_BRBE_FOR_NS \ 1135 ENABLE_TRBE_FOR_NS \ 1136 ENABLE_BTI \ 1137 ENABLE_PAUTH \ 1138 ENABLE_FEAT_AMUv1 \ 1139 ENABLE_FEAT_AMUv1p1 \ 1140 ENABLE_FEAT_CSV2_2 \ 1141 ENABLE_FEAT_DIT \ 1142 ENABLE_FEAT_ECV \ 1143 ENABLE_FEAT_FGT \ 1144 ENABLE_FEAT_HCX \ 1145 ENABLE_FEAT_PAN \ 1146 ENABLE_FEAT_RNG \ 1147 ENABLE_FEAT_RNG_TRAP \ 1148 ENABLE_FEAT_SB \ 1149 ENABLE_FEAT_SEL2 \ 1150 ENABLE_FEAT_VHE \ 1151 ENABLE_MPAM_FOR_LOWER_ELS \ 1152 ENABLE_RME \ 1153 ENABLE_TRF_FOR_NS \ 1154 FW_ENC_STATUS \ 1155 NR_OF_FW_BANKS \ 1156 NR_OF_IMAGES_IN_FW_BANK \ 1157 RAS_EXTENSION \ 1158 TWED_DELAY \ 1159 ENABLE_FEAT_TWED \ 1160 SVE_VECTOR_LEN \ 1161))) 1162 1163ifdef KEY_SIZE 1164 $(eval $(call assert_numeric,KEY_SIZE)) 1165endif 1166 1167ifeq ($(filter $(SANITIZE_UB), on off trap),) 1168 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap") 1169endif 1170 1171################################################################################ 1172# Add definitions to the cpp preprocessor based on the current build options. 1173# This is done after including the platform specific makefile to allow the 1174# platform to overwrite the default options 1175################################################################################ 1176 1177$(eval $(call add_defines,\ 1178 $(sort \ 1179 ALLOW_RO_XLAT_TABLES \ 1180 ARM_ARCH_MAJOR \ 1181 ARM_ARCH_MINOR \ 1182 BL2_ENABLE_SP_LOAD \ 1183 COLD_BOOT_SINGLE_CPU \ 1184 CTX_INCLUDE_AARCH32_REGS \ 1185 CTX_INCLUDE_FPREGS \ 1186 CTX_INCLUDE_PAUTH_REGS \ 1187 EL3_EXCEPTION_HANDLING \ 1188 CTX_INCLUDE_MTE_REGS \ 1189 CTX_INCLUDE_EL2_REGS \ 1190 CTX_INCLUDE_NEVE_REGS \ 1191 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \ 1192 DISABLE_MTPMU \ 1193 ENABLE_AMU \ 1194 ENABLE_AMU_AUXILIARY_COUNTERS \ 1195 ENABLE_AMU_FCONF \ 1196 AMU_RESTRICT_COUNTERS \ 1197 ENABLE_ASSERTIONS \ 1198 ENABLE_BTI \ 1199 ENABLE_MPAM_FOR_LOWER_ELS \ 1200 ENABLE_PAUTH \ 1201 ENABLE_PIE \ 1202 ENABLE_PMF \ 1203 ENABLE_PSCI_STAT \ 1204 ENABLE_RME \ 1205 ENABLE_RUNTIME_INSTRUMENTATION \ 1206 ENABLE_SME_FOR_NS \ 1207 ENABLE_SME_FOR_SWD \ 1208 ENABLE_SPE_FOR_LOWER_ELS \ 1209 ENABLE_SVE_FOR_NS \ 1210 ENABLE_SVE_FOR_SWD \ 1211 ENCRYPT_BL31 \ 1212 ENCRYPT_BL32 \ 1213 ERROR_DEPRECATED \ 1214 FAULT_INJECTION_SUPPORT \ 1215 GICV2_G0_FOR_EL3 \ 1216 HANDLE_EA_EL3_FIRST_NS \ 1217 HW_ASSISTED_COHERENCY \ 1218 LOG_LEVEL \ 1219 MEASURED_BOOT \ 1220 DRTM_SUPPORT \ 1221 NS_TIMER_SWITCH \ 1222 PL011_GENERIC_UART \ 1223 PLAT_${PLAT} \ 1224 PLAT_RSS_NOT_SUPPORTED \ 1225 PROGRAMMABLE_RESET_ADDRESS \ 1226 PSCI_EXTENDED_STATE_ID \ 1227 RAS_EXTENSION \ 1228 RESET_TO_BL31 \ 1229 RESET_TO_BL31_WITH_PARAMS \ 1230 SEPARATE_CODE_AND_RODATA \ 1231 SEPARATE_BL2_NOLOAD_REGION \ 1232 SEPARATE_NOBITS_REGION \ 1233 RECLAIM_INIT_CODE \ 1234 SPD_${SPD} \ 1235 SPIN_ON_BL1_EXIT \ 1236 SPM_MM \ 1237 SPMC_AT_EL3 \ 1238 SPMD_SPM_AT_SEL2 \ 1239 TRUSTED_BOARD_BOOT \ 1240 CRYPTO_SUPPORT \ 1241 TRNG_SUPPORT \ 1242 USE_COHERENT_MEM \ 1243 USE_DEBUGFS \ 1244 ARM_IO_IN_DTB \ 1245 SDEI_IN_FCONF \ 1246 SEC_INT_DESC_IN_FCONF \ 1247 USE_ROMLIB \ 1248 USE_TBBR_DEFS \ 1249 WARMBOOT_ENABLE_DCACHE_EARLY \ 1250 BL2_AT_EL3 \ 1251 BL2_IN_XIP_MEM \ 1252 BL2_INV_DCACHE \ 1253 USE_SPINLOCK_CAS \ 1254 ERRATA_SPECULATIVE_AT \ 1255 RAS_TRAP_NS_ERR_REC_ACCESS \ 1256 COT_DESC_IN_DTB \ 1257 USE_SP804_TIMER \ 1258 ENABLE_FEAT_RNG \ 1259 ENABLE_FEAT_RNG_TRAP \ 1260 ENABLE_FEAT_SB \ 1261 ENABLE_FEAT_DIT \ 1262 NR_OF_FW_BANKS \ 1263 NR_OF_IMAGES_IN_FW_BANK \ 1264 PSA_FWU_SUPPORT \ 1265 ENABLE_BRBE_FOR_NS \ 1266 ENABLE_TRBE_FOR_NS \ 1267 ENABLE_SYS_REG_TRACE_FOR_NS \ 1268 ENABLE_TRF_FOR_NS \ 1269 ENABLE_FEAT_HCX \ 1270 ENABLE_MPMM \ 1271 ENABLE_MPMM_FCONF \ 1272 ENABLE_FEAT_FGT \ 1273 ENABLE_FEAT_AMUv1 \ 1274 ENABLE_FEAT_ECV \ 1275 SIMICS_BUILD \ 1276 ENABLE_FEAT_AMUv1p1 \ 1277 ENABLE_FEAT_SEL2 \ 1278 ENABLE_FEAT_VHE \ 1279 ENABLE_FEAT_CSV2_2 \ 1280 ENABLE_FEAT_PAN \ 1281 FEATURE_DETECTION \ 1282 TWED_DELAY \ 1283 ENABLE_FEAT_TWED \ 1284 CONDITIONAL_CMO \ 1285))) 1286 1287ifeq (${SANITIZE_UB},trap) 1288 $(eval $(call add_define,MONITOR_TRAPS)) 1289endif 1290 1291# Define the EL3_PAYLOAD_BASE flag only if it is provided. 1292ifdef EL3_PAYLOAD_BASE 1293 $(eval $(call add_define,EL3_PAYLOAD_BASE)) 1294else 1295 # Define the PRELOADED_BL33_BASE flag only if it is provided and 1296 # EL3_PAYLOAD_BASE is not defined, as it has priority. 1297 ifdef PRELOADED_BL33_BASE 1298 $(eval $(call add_define,PRELOADED_BL33_BASE)) 1299 endif 1300endif 1301 1302# Define the DYN_DISABLE_AUTH flag only if set. 1303ifeq (${DYN_DISABLE_AUTH},1) 1304$(eval $(call add_define,DYN_DISABLE_AUTH)) 1305endif 1306 1307ifneq ($(findstring armlink,$(notdir $(LD))),) 1308$(eval $(call add_define,USE_ARM_LINK)) 1309endif 1310 1311# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined 1312ifeq (${SPD},spmd) 1313ifdef SP_LAYOUT_FILE 1314 -include $(BUILD_PLAT)/sp_gen.mk 1315 FIP_DEPS += sp 1316 CRT_DEPS += sp 1317 NEED_SP_PKG := yes 1318else 1319 ifeq (${SPMD_SPM_AT_SEL2},1) 1320 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE") 1321 endif 1322endif 1323endif 1324 1325################################################################################ 1326# Build targets 1327################################################################################ 1328 1329.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool 1330.SUFFIXES: 1331 1332all: msg_start 1333 1334msg_start: 1335 @echo "Building ${PLAT}" 1336 1337ifeq (${ERROR_DEPRECATED},0) 1338# Check if deprecated declarations and cpp warnings should be treated as error or not. 1339ifneq ($(findstring clang,$(notdir $(CC))),) 1340 CPPFLAGS += -Wno-error=deprecated-declarations 1341else 1342 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp 1343endif 1344endif # !ERROR_DEPRECATED 1345 1346$(eval $(call MAKE_LIB_DIRS)) 1347$(eval $(call MAKE_LIB,c)) 1348 1349# Expand build macros for the different images 1350ifeq (${NEED_BL1},yes) 1351BL1_SOURCES := $(sort ${BL1_SOURCES}) 1352 1353$(eval $(call MAKE_BL,bl1)) 1354endif 1355 1356ifeq (${NEED_BL2},yes) 1357ifeq (${BL2_AT_EL3}, 0) 1358FIP_BL2_ARGS := tb-fw 1359endif 1360 1361BL2_SOURCES := $(sort ${BL2_SOURCES}) 1362 1363$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\ 1364 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS}))) 1365endif 1366 1367ifeq (${NEED_SCP_BL2},yes) 1368$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw)) 1369endif 1370 1371ifeq (${NEED_BL31},yes) 1372BL31_SOURCES += ${SPD_SOURCES} 1373# Sort BL31 source files to remove duplicates 1374BL31_SOURCES := $(sort ${BL31_SOURCES}) 1375ifneq (${DECRYPTION_SUPPORT},none) 1376$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\ 1377 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31)))) 1378else 1379$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\ 1380 $(eval $(call MAKE_BL,bl31,soc-fw))) 1381endif 1382endif 1383 1384# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the 1385# build system will call TOOL_ADD_IMG to print a warning message and abort the 1386# process. Note that the dependency on BL32 applies to the FIP only. 1387ifeq (${NEED_BL32},yes) 1388# Sort BL32 source files to remove duplicates 1389BL32_SOURCES := $(sort ${BL32_SOURCES}) 1390BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1)) 1391 1392ifneq (${DECRYPTION_SUPPORT},none) 1393$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\ 1394 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32)))) 1395else 1396$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\ 1397 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw))) 1398endif 1399endif 1400 1401# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP) 1402# needs to be built from RMM_SOURCES. 1403ifeq (${NEED_RMM},yes) 1404# Sort RMM source files to remove duplicates 1405RMM_SOURCES := $(sort ${RMM_SOURCES}) 1406BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1)) 1407 1408$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\ 1409 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw))) 1410endif 1411 1412# Add the BL33 image if required by the platform 1413ifeq (${NEED_BL33},yes) 1414$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw)) 1415endif 1416 1417ifeq (${NEED_BL2U},yes) 1418$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\ 1419 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_))) 1420endif 1421 1422# Expand build macros for the different images 1423ifeq (${NEED_FDT},yes) 1424 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES))) 1425endif 1426 1427# Add Secure Partition packages 1428ifeq (${NEED_SP_PKG},yes) 1429$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT} 1430 ${Q}${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} 1431sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS) 1432 @${ECHO_BLANK_LINE} 1433 @echo "Built SP Images successfully" 1434 @${ECHO_BLANK_LINE} 1435endif 1436 1437locate-checkpatch: 1438ifndef CHECKPATCH 1439 $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 1440else 1441ifeq (,$(wildcard ${CHECKPATCH})) 1442 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 1443endif 1444endif 1445 1446clean: 1447 @echo " CLEAN" 1448 $(call SHELL_REMOVE_DIR,${BUILD_PLAT}) 1449ifdef UNIX_MK 1450 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 1451else 1452# Clear the MAKEFLAGS as we do not want 1453# to pass the gnumake flags to nmake. 1454 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean 1455endif 1456 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 1457 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean 1458 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 1459 1460realclean distclean: 1461 @echo " REALCLEAN" 1462 $(call SHELL_REMOVE_DIR,${BUILD_BASE}) 1463 $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*) 1464ifdef UNIX_MK 1465 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 1466else 1467# Clear the MAKEFLAGS as we do not want 1468# to pass the gnumake flags to nmake. 1469 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean 1470endif 1471 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean 1472 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean 1473 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 1474 1475checkcodebase: locate-checkpatch 1476 @echo " CHECKING STYLE" 1477 @if test -d .git ; then \ 1478 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \ 1479 while read GIT_FILE ; \ 1480 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \ 1481 done ; \ 1482 else \ 1483 find . -type f -not -iwholename "*.git*" \ 1484 -not -iwholename "*build*" \ 1485 -not -iwholename "*libfdt*" \ 1486 -not -iwholename "*libc*" \ 1487 -not -iwholename "*docs*" \ 1488 -not -iwholename "*.rst" \ 1489 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \ 1490 fi 1491 1492checkpatch: locate-checkpatch 1493 @echo " CHECKING STYLE" 1494 @if test -n "${CHECKPATCH_OPTS}"; then \ 1495 echo " with ${CHECKPATCH_OPTS} option(s)"; \ 1496 fi 1497 ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \ 1498 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \ 1499 do \ 1500 printf "\n[*] Checking style of '$$commit'\n\n"; \ 1501 git log --format=email "$$commit~..$$commit" \ 1502 -- ${CHECK_PATHS} | \ 1503 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 1504 git diff --format=email "$$commit~..$$commit" \ 1505 -- ${CHECK_PATHS} | \ 1506 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 1507 done 1508 1509certtool: ${CRTTOOL} 1510 1511${CRTTOOL}: FORCE 1512 ${Q}${MAKE} PLAT=${PLAT} USE_TBBR_DEFS=${USE_TBBR_DEFS} COT=${COT} OPENSSL_DIR=${OPENSSL_DIR} CRTTOOL=${CRTTOOL} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${CRTTOOLPATH} all 1513 @${ECHO_BLANK_LINE} 1514 @echo "Built $@ successfully" 1515 @${ECHO_BLANK_LINE} 1516 1517ifneq (${GENERATE_COT},0) 1518certificates: ${CRT_DEPS} ${CRTTOOL} 1519 ${Q}${CRTTOOL} ${CRT_ARGS} 1520 @${ECHO_BLANK_LINE} 1521 @echo "Built $@ successfully" 1522 @echo "Certificates can be found in ${BUILD_PLAT}" 1523 @${ECHO_BLANK_LINE} 1524endif 1525 1526${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL} 1527 $(eval ${CHECK_FIP_CMD}) 1528 ${Q}${FIPTOOL} create ${FIP_ARGS} $@ 1529 ${Q}${FIPTOOL} info $@ 1530 @${ECHO_BLANK_LINE} 1531 @echo "Built $@ successfully" 1532 @${ECHO_BLANK_LINE} 1533 1534ifneq (${GENERATE_COT},0) 1535fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL} 1536 ${Q}${CRTTOOL} ${FWU_CRT_ARGS} 1537 @${ECHO_BLANK_LINE} 1538 @echo "Built $@ successfully" 1539 @echo "FWU certificates can be found in ${BUILD_PLAT}" 1540 @${ECHO_BLANK_LINE} 1541endif 1542 1543${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL} 1544 $(eval ${CHECK_FWU_FIP_CMD}) 1545 ${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@ 1546 ${Q}${FIPTOOL} info $@ 1547 @${ECHO_BLANK_LINE} 1548 @echo "Built $@ successfully" 1549 @${ECHO_BLANK_LINE} 1550 1551fiptool: ${FIPTOOL} 1552fip: ${BUILD_PLAT}/${FIP_NAME} 1553fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME} 1554 1555${FIPTOOL}: FORCE 1556ifdef UNIX_MK 1557 ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${FIPTOOLPATH} all 1558else 1559# Clear the MAKEFLAGS as we do not want 1560# to pass the gnumake flags to nmake. 1561 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) 1562endif 1563 1564romlib.bin: libraries FORCE 1565 ${Q}${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES='${INCLUDES}' DEFINES='${DEFINES}' --no-print-directory -C ${ROMLIBPATH} all 1566 1567# Call print_memory_map tool 1568memmap: all 1569 ${Q}${PYTHON} ${PRINT_MEMORY_MAP} ${BUILD_PLAT} ${INVERTED_MEMMAP} 1570 1571doc: 1572 @echo " BUILD DOCUMENTATION" 1573 ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html 1574 1575enctool: ${ENCTOOL} 1576 1577${ENCTOOL}: FORCE 1578 ${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${ENCTOOLPATH} all 1579 @${ECHO_BLANK_LINE} 1580 @echo "Built $@ successfully" 1581 @${ECHO_BLANK_LINE} 1582 1583cscope: 1584 @echo " CSCOPE" 1585 ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files 1586 ${Q}cscope -b -q -k 1587 1588help: 1589 @echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]" 1590 @echo "" 1591 @echo "PLAT is used to specify which platform you wish to build." 1592 @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}" 1593 @echo "" 1594 @echo "platform = ${PLATFORM_LIST}" 1595 @echo "" 1596 @echo "Please refer to the User Guide for a list of all supported options." 1597 @echo "Note that the build system doesn't track dependencies for build " 1598 @echo "options. Therefore, if any of the build options are changed " 1599 @echo "from a previous build, a clean build must be performed." 1600 @echo "" 1601 @echo "Supported Targets:" 1602 @echo " all Build all individual bootloader binaries" 1603 @echo " bl1 Build the BL1 binary" 1604 @echo " bl2 Build the BL2 binary" 1605 @echo " bl2u Build the BL2U binary" 1606 @echo " bl31 Build the BL31 binary" 1607 @echo " bl32 Build the BL32 binary. If ARCH=aarch32, then " 1608 @echo " this builds secure payload specified by AARCH32_SP" 1609 @echo " certificates Build the certificates (requires 'GENERATE_COT=1')" 1610 @echo " fip Build the Firmware Image Package (FIP)" 1611 @echo " fwu_fip Build the FWU Firmware Image Package (FIP)" 1612 @echo " checkcodebase Check the coding style of the entire source tree" 1613 @echo " checkpatch Check the coding style on changes in the current" 1614 @echo " branch against BASE_COMMIT (default origin/master)" 1615 @echo " clean Clean the build for the selected platform" 1616 @echo " cscope Generate cscope index" 1617 @echo " distclean Remove all build artifacts for all platforms" 1618 @echo " certtool Build the Certificate generation tool" 1619 @echo " enctool Build the Firmware encryption tool" 1620 @echo " fiptool Build the Firmware Image Package (FIP) creation tool" 1621 @echo " sp Build the Secure Partition Packages" 1622 @echo " sptool Build the Secure Partition Package creation tool" 1623 @echo " dtbs Build the Device Tree Blobs (if required for the platform)" 1624 @echo " memmap Print the memory map of the built binaries" 1625 @echo " doc Build html based documentation using Sphinx tool" 1626 @echo "" 1627 @echo "Note: most build targets require PLAT to be set to a specific platform." 1628 @echo "" 1629 @echo "example: build all targets for the FVP platform:" 1630 @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all" 1631 1632.PHONY: FORCE 1633FORCE:; 1634