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