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