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 DRTM_SUPPORT \ 1181 NS_TIMER_SWITCH \ 1182 OVERRIDE_LIBC \ 1183 PL011_GENERIC_UART \ 1184 PROGRAMMABLE_RESET_ADDRESS \ 1185 PSCI_EXTENDED_STATE_ID \ 1186 PSCI_OS_INIT_MODE \ 1187 RESET_TO_BL31 \ 1188 SAVE_KEYS \ 1189 SEPARATE_CODE_AND_RODATA \ 1190 SEPARATE_BL2_NOLOAD_REGION \ 1191 SEPARATE_NOBITS_REGION \ 1192 SEPARATE_SIMD_SECTION \ 1193 SPIN_ON_BL1_EXIT \ 1194 SPM_MM \ 1195 SPMC_AT_EL3 \ 1196 SPMC_AT_EL3_SEL0_SP \ 1197 SPMD_SPM_AT_SEL2 \ 1198 ENABLE_SPMD_LP \ 1199 TRANSFER_LIST \ 1200 TRUSTED_BOARD_BOOT \ 1201 USE_COHERENT_MEM \ 1202 USE_DEBUGFS \ 1203 ARM_IO_IN_DTB \ 1204 SDEI_IN_FCONF \ 1205 SEC_INT_DESC_IN_FCONF \ 1206 USE_ROMLIB \ 1207 USE_TBBR_DEFS \ 1208 WARMBOOT_ENABLE_DCACHE_EARLY \ 1209 RESET_TO_BL2 \ 1210 BL2_IN_XIP_MEM \ 1211 BL2_INV_DCACHE \ 1212 USE_SPINLOCK_CAS \ 1213 ENCRYPT_BL31 \ 1214 ENCRYPT_BL32 \ 1215 ERRATA_SPECULATIVE_AT \ 1216 RAS_TRAP_NS_ERR_REC_ACCESS \ 1217 COT_DESC_IN_DTB \ 1218 USE_SP804_TIMER \ 1219 PSA_FWU_SUPPORT \ 1220 PSA_FWU_METADATA_FW_STORE_DESC \ 1221 ENABLE_MPMM \ 1222 ENABLE_MPMM_FCONF \ 1223 FEATURE_DETECTION \ 1224 TRNG_SUPPORT \ 1225 ERRATA_ABI_SUPPORT \ 1226 ERRATA_NON_ARM_INTERCONNECT \ 1227 CONDITIONAL_CMO \ 1228 PSA_CRYPTO \ 1229 ENABLE_CONSOLE_GETC \ 1230 INIT_UNUSED_NS_EL2 \ 1231 PLATFORM_REPORT_CTX_MEM_USE \ 1232 EARLY_CONSOLE \ 1233 PRESERVE_DSU_PMU_REGS \ 1234))) 1235 1236# Numeric_Flags 1237$(eval $(call assert_numerics,\ 1238 $(sort \ 1239 ARM_ARCH_MAJOR \ 1240 ARM_ARCH_MINOR \ 1241 BRANCH_PROTECTION \ 1242 CTX_INCLUDE_PAUTH_REGS \ 1243 CTX_INCLUDE_NEVE_REGS \ 1244 CRYPTO_SUPPORT \ 1245 DISABLE_MTPMU \ 1246 ENABLE_BRBE_FOR_NS \ 1247 ENABLE_TRBE_FOR_NS \ 1248 ENABLE_BTI \ 1249 ENABLE_PAUTH \ 1250 ENABLE_FEAT_AMU \ 1251 ENABLE_FEAT_AMUv1p1 \ 1252 ENABLE_FEAT_CSV2_2 \ 1253 ENABLE_FEAT_CSV2_3 \ 1254 ENABLE_FEAT_DEBUGV8P9 \ 1255 ENABLE_FEAT_DIT \ 1256 ENABLE_FEAT_ECV \ 1257 ENABLE_FEAT_FGT \ 1258 ENABLE_FEAT_FGT2 \ 1259 ENABLE_FEAT_HCX \ 1260 ENABLE_FEAT_MTE2 \ 1261 ENABLE_FEAT_PAN \ 1262 ENABLE_FEAT_RNG \ 1263 ENABLE_FEAT_RNG_TRAP \ 1264 ENABLE_FEAT_SEL2 \ 1265 ENABLE_FEAT_TCR2 \ 1266 ENABLE_FEAT_SB \ 1267 ENABLE_FEAT_S2PIE \ 1268 ENABLE_FEAT_S1PIE \ 1269 ENABLE_FEAT_S2POE \ 1270 ENABLE_FEAT_S1POE \ 1271 ENABLE_FEAT_GCS \ 1272 ENABLE_FEAT_VHE \ 1273 ENABLE_FEAT_MPAM \ 1274 ENABLE_RME \ 1275 ENABLE_SPE_FOR_NS \ 1276 ENABLE_SYS_REG_TRACE_FOR_NS \ 1277 ENABLE_SME_FOR_NS \ 1278 ENABLE_SME2_FOR_NS \ 1279 ENABLE_SVE_FOR_NS \ 1280 ENABLE_TRF_FOR_NS \ 1281 FW_ENC_STATUS \ 1282 NR_OF_FW_BANKS \ 1283 NR_OF_IMAGES_IN_FW_BANK \ 1284 TWED_DELAY \ 1285 ENABLE_FEAT_TWED \ 1286 SVE_VECTOR_LEN \ 1287 IMPDEF_SYSREG_TRAP \ 1288))) 1289 1290ifdef KEY_SIZE 1291 $(eval $(call assert_numeric,KEY_SIZE)) 1292endif 1293 1294ifeq ($(filter $(SANITIZE_UB), on off trap),) 1295 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap") 1296endif 1297 1298################################################################################ 1299# Add definitions to the cpp preprocessor based on the current build options. 1300# This is done after including the platform specific makefile to allow the 1301# platform to overwrite the default options 1302################################################################################ 1303 1304$(eval $(call add_defines,\ 1305 $(sort \ 1306 ALLOW_RO_XLAT_TABLES \ 1307 ARM_ARCH_MAJOR \ 1308 ARM_ARCH_MINOR \ 1309 BL2_ENABLE_SP_LOAD \ 1310 COLD_BOOT_SINGLE_CPU \ 1311 CTX_INCLUDE_AARCH32_REGS \ 1312 CTX_INCLUDE_FPREGS \ 1313 CTX_INCLUDE_SVE_REGS \ 1314 CTX_INCLUDE_PAUTH_REGS \ 1315 CTX_INCLUDE_MPAM_REGS \ 1316 EL3_EXCEPTION_HANDLING \ 1317 CTX_INCLUDE_EL2_REGS \ 1318 CTX_INCLUDE_NEVE_REGS \ 1319 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \ 1320 DISABLE_MTPMU \ 1321 ENABLE_FEAT_AMU \ 1322 ENABLE_AMU_AUXILIARY_COUNTERS \ 1323 ENABLE_AMU_FCONF \ 1324 AMU_RESTRICT_COUNTERS \ 1325 ENABLE_ASSERTIONS \ 1326 ENABLE_BTI \ 1327 ENABLE_FEAT_DEBUGV8P9 \ 1328 ENABLE_FEAT_MPAM \ 1329 ENABLE_PAUTH \ 1330 ENABLE_PIE \ 1331 ENABLE_PMF \ 1332 ENABLE_PSCI_STAT \ 1333 ENABLE_RME \ 1334 ENABLE_RUNTIME_INSTRUMENTATION \ 1335 ENABLE_SME_FOR_NS \ 1336 ENABLE_SME2_FOR_NS \ 1337 ENABLE_SME_FOR_SWD \ 1338 ENABLE_SPE_FOR_NS \ 1339 ENABLE_SVE_FOR_NS \ 1340 ENABLE_SVE_FOR_SWD \ 1341 ENABLE_FEAT_RAS \ 1342 FFH_SUPPORT \ 1343 ENCRYPT_BL31 \ 1344 ENCRYPT_BL32 \ 1345 ERROR_DEPRECATED \ 1346 FAULT_INJECTION_SUPPORT \ 1347 GICV2_G0_FOR_EL3 \ 1348 HANDLE_EA_EL3_FIRST_NS \ 1349 HW_ASSISTED_COHERENCY \ 1350 LOG_LEVEL \ 1351 MEASURED_BOOT \ 1352 DICE_PROTECTION_ENVIRONMENT \ 1353 DRTM_SUPPORT \ 1354 NS_TIMER_SWITCH \ 1355 PL011_GENERIC_UART \ 1356 PLAT_${PLAT} \ 1357 PROGRAMMABLE_RESET_ADDRESS \ 1358 PSCI_EXTENDED_STATE_ID \ 1359 PSCI_OS_INIT_MODE \ 1360 RESET_TO_BL31 \ 1361 RME_GPT_BITLOCK_BLOCK \ 1362 RME_GPT_MAX_BLOCK \ 1363 SEPARATE_CODE_AND_RODATA \ 1364 SEPARATE_BL2_NOLOAD_REGION \ 1365 SEPARATE_NOBITS_REGION \ 1366 SEPARATE_SIMD_SECTION \ 1367 RECLAIM_INIT_CODE \ 1368 SPD_${SPD} \ 1369 SPIN_ON_BL1_EXIT \ 1370 SPM_MM \ 1371 SPMC_AT_EL3 \ 1372 SPMC_AT_EL3_SEL0_SP \ 1373 SPMD_SPM_AT_SEL2 \ 1374 TRANSFER_LIST \ 1375 TRUSTED_BOARD_BOOT \ 1376 CRYPTO_SUPPORT \ 1377 TRNG_SUPPORT \ 1378 ERRATA_ABI_SUPPORT \ 1379 ERRATA_NON_ARM_INTERCONNECT \ 1380 USE_COHERENT_MEM \ 1381 USE_DEBUGFS \ 1382 ARM_IO_IN_DTB \ 1383 SDEI_IN_FCONF \ 1384 SEC_INT_DESC_IN_FCONF \ 1385 USE_ROMLIB \ 1386 USE_TBBR_DEFS \ 1387 WARMBOOT_ENABLE_DCACHE_EARLY \ 1388 RESET_TO_BL2 \ 1389 BL2_RUNS_AT_EL3 \ 1390 BL2_IN_XIP_MEM \ 1391 BL2_INV_DCACHE \ 1392 USE_SPINLOCK_CAS \ 1393 ERRATA_SPECULATIVE_AT \ 1394 RAS_TRAP_NS_ERR_REC_ACCESS \ 1395 COT_DESC_IN_DTB \ 1396 USE_SP804_TIMER \ 1397 ENABLE_FEAT_RNG \ 1398 ENABLE_FEAT_RNG_TRAP \ 1399 ENABLE_FEAT_SB \ 1400 ENABLE_FEAT_DIT \ 1401 NR_OF_FW_BANKS \ 1402 NR_OF_IMAGES_IN_FW_BANK \ 1403 PSA_FWU_SUPPORT \ 1404 PSA_FWU_METADATA_FW_STORE_DESC \ 1405 ENABLE_BRBE_FOR_NS \ 1406 ENABLE_TRBE_FOR_NS \ 1407 ENABLE_SYS_REG_TRACE_FOR_NS \ 1408 ENABLE_TRF_FOR_NS \ 1409 ENABLE_FEAT_HCX \ 1410 ENABLE_MPMM \ 1411 ENABLE_MPMM_FCONF \ 1412 ENABLE_FEAT_FGT \ 1413 ENABLE_FEAT_FGT2 \ 1414 ENABLE_FEAT_ECV \ 1415 ENABLE_FEAT_AMUv1p1 \ 1416 ENABLE_FEAT_SEL2 \ 1417 ENABLE_FEAT_VHE \ 1418 ENABLE_FEAT_CSV2_2 \ 1419 ENABLE_FEAT_CSV2_3 \ 1420 ENABLE_FEAT_PAN \ 1421 ENABLE_FEAT_TCR2 \ 1422 ENABLE_FEAT_S2PIE \ 1423 ENABLE_FEAT_S1PIE \ 1424 ENABLE_FEAT_S2POE \ 1425 ENABLE_FEAT_S1POE \ 1426 ENABLE_FEAT_GCS \ 1427 ENABLE_FEAT_MTE2 \ 1428 FEATURE_DETECTION \ 1429 TWED_DELAY \ 1430 ENABLE_FEAT_TWED \ 1431 CONDITIONAL_CMO \ 1432 IMPDEF_SYSREG_TRAP \ 1433 SVE_VECTOR_LEN \ 1434 ENABLE_SPMD_LP \ 1435 PSA_CRYPTO \ 1436 ENABLE_CONSOLE_GETC \ 1437 INIT_UNUSED_NS_EL2 \ 1438 PLATFORM_REPORT_CTX_MEM_USE \ 1439 EARLY_CONSOLE \ 1440 PRESERVE_DSU_PMU_REGS \ 1441))) 1442 1443ifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1) 1444ifeq (${DEBUG}, 0) 1445 $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only") 1446 override PLATFORM_REPORT_CTX_MEM_USE := 0 1447endif 1448endif 1449 1450ifeq (${SANITIZE_UB},trap) 1451 $(eval $(call add_define,MONITOR_TRAPS)) 1452endif #(SANITIZE_UB) 1453 1454# Define the EL3_PAYLOAD_BASE flag only if it is provided. 1455ifdef EL3_PAYLOAD_BASE 1456 $(eval $(call add_define,EL3_PAYLOAD_BASE)) 1457else 1458# Define the PRELOADED_BL33_BASE flag only if it is provided and 1459# EL3_PAYLOAD_BASE is not defined, as it has priority. 1460 ifdef PRELOADED_BL33_BASE 1461 $(eval $(call add_define,PRELOADED_BL33_BASE)) 1462 endif 1463endif #(EL3_PAYLOAD_BASE) 1464 1465# Define the DYN_DISABLE_AUTH flag only if set. 1466ifeq (${DYN_DISABLE_AUTH},1) 1467 $(eval $(call add_define,DYN_DISABLE_AUTH)) 1468endif 1469 1470ifeq ($($(ARCH)-ld-id),arm-link) 1471 $(eval $(call add_define,USE_ARM_LINK)) 1472endif 1473 1474# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined 1475ifeq (${SPD},spmd) 1476ifdef SP_LAYOUT_FILE 1477 -include $(BUILD_PLAT)/sp_gen.mk 1478 FIP_DEPS += sp 1479 CRT_DEPS += sp 1480 NEED_SP_PKG := yes 1481else 1482 ifeq (${SPMD_SPM_AT_SEL2},1) 1483 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE") 1484 endif 1485endif #(SP_LAYOUT_FILE) 1486endif #(SPD) 1487 1488################################################################################ 1489# Build targets 1490################################################################################ 1491 1492.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp tl fwu_fip certtool dtbs memmap doc enctool 1493.SUFFIXES: 1494 1495all: msg_start 1496 1497msg_start: 1498 $(s)echo "Building ${PLAT}" 1499 1500ifeq (${ERROR_DEPRECATED},0) 1501# Check if deprecated declarations and cpp warnings should be treated as error or not. 1502ifneq ($(filter %-clang,$($(ARCH)-cc-id)),) 1503 CPPFLAGS += -Wno-error=deprecated-declarations 1504else 1505 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp 1506endif 1507endif #(!ERROR_DEPRECATED) 1508 1509$(eval $(call MAKE_LIB,c)) 1510 1511# Expand build macros for the different images 1512ifeq (${NEED_BL1},yes) 1513BL1_SOURCES := $(sort ${BL1_SOURCES}) 1514$(eval $(call MAKE_BL,bl1)) 1515endif #(NEED_BL1) 1516 1517ifeq (${NEED_BL2},yes) 1518 1519ifeq (${RESET_TO_BL2}, 0) 1520FIP_BL2_ARGS := tb-fw 1521endif 1522 1523BL2_SOURCES := $(sort ${BL2_SOURCES}) 1524 1525$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\ 1526 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS}))) 1527 1528endif #(NEED_BL2) 1529 1530ifeq (${NEED_SCP_BL2},yes) 1531$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw)) 1532endif #(NEED_SCP_BL2) 1533 1534ifeq (${NEED_BL31},yes) 1535BL31_SOURCES += ${SPD_SOURCES} 1536# Sort BL31 source files to remove duplicates 1537BL31_SOURCES := $(sort ${BL31_SOURCES}) 1538ifneq (${DECRYPTION_SUPPORT},none) 1539$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\ 1540 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31)))) 1541else 1542$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\ 1543 $(eval $(call MAKE_BL,bl31,soc-fw))) 1544endif #(DECRYPTION_SUPPORT) 1545endif #(NEED_BL31) 1546 1547# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the 1548# build system will call TOOL_ADD_IMG to print a warning message and abort the 1549# process. Note that the dependency on BL32 applies to the FIP only. 1550ifeq (${NEED_BL32},yes) 1551# Sort BL32 source files to remove duplicates 1552BL32_SOURCES := $(sort ${BL32_SOURCES}) 1553BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1)) 1554 1555ifneq (${DECRYPTION_SUPPORT},none) 1556$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\ 1557 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32)))) 1558else 1559$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\ 1560 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw))) 1561endif #(DECRYPTION_SUPPORT) 1562endif #(NEED_BL32) 1563 1564# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP) 1565# needs to be built from RMM_SOURCES. 1566ifeq (${NEED_RMM},yes) 1567# Sort RMM source files to remove duplicates 1568RMM_SOURCES := $(sort ${RMM_SOURCES}) 1569BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1)) 1570 1571$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\ 1572 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw))) 1573endif #(NEED_RMM) 1574 1575# Add the BL33 image if required by the platform 1576ifeq (${NEED_BL33},yes) 1577$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw)) 1578endif #(NEED_BL33) 1579 1580ifeq (${NEED_BL2U},yes) 1581$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\ 1582 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_))) 1583endif #(NEED_BL2U) 1584 1585# Expand build macros for the different images 1586ifeq (${NEED_FDT},yes) 1587 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES))) 1588endif #(NEED_FDT) 1589 1590# Add Secure Partition packages 1591ifeq (${NEED_SP_PKG},yes) 1592$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | $$(@D)/ 1593 $(q)${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT} 1594sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS) 1595 $(s)echo 1596 $(s)echo "Built SP Images successfully" 1597 $(s)echo 1598endif #(NEED_SP_PKG) 1599 1600locate-checkpatch: 1601ifndef CHECKPATCH 1602 $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 1603else 1604ifeq (,$(wildcard ${CHECKPATCH})) 1605 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 1606endif 1607endif #(CHECKPATCH) 1608 1609clean: 1610 $(s)echo " CLEAN" 1611 $(call SHELL_REMOVE_DIR,${BUILD_PLAT}) 1612ifdef UNIX_MK 1613 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 1614else 1615# Clear the MAKEFLAGS as we do not want 1616# to pass the gnumake flags to nmake. 1617 $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean 1618endif #(UNIX_MK) 1619 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 1620 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean 1621 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 1622 1623realclean distclean: 1624 $(s)echo " REALCLEAN" 1625 $(call SHELL_REMOVE_DIR,${BUILD_BASE}) 1626 $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*) 1627ifdef UNIX_MK 1628 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 1629else 1630# Clear the MAKEFLAGS as we do not want 1631# to pass the gnumake flags to nmake. 1632 $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean 1633endif #(UNIX_MK) 1634 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean 1635 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean 1636 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 1637 1638checkcodebase: locate-checkpatch 1639 $(s)echo " CHECKING STYLE" 1640 $(q)if test -d .git ; then \ 1641 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \ 1642 while read GIT_FILE ; \ 1643 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \ 1644 done ; \ 1645 else \ 1646 find . -type f -not -iwholename "*.git*" \ 1647 -not -iwholename "*build*" \ 1648 -not -iwholename "*libfdt*" \ 1649 -not -iwholename "*libc*" \ 1650 -not -iwholename "*docs*" \ 1651 -not -iwholename "*.rst" \ 1652 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \ 1653 fi 1654 1655checkpatch: locate-checkpatch 1656 $(s)echo " CHECKING STYLE" 1657 $(q)if test -n "${CHECKPATCH_OPTS}"; then \ 1658 echo " with ${CHECKPATCH_OPTS} option(s)"; \ 1659 fi 1660 $(q)COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \ 1661 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \ 1662 do \ 1663 printf "\n[*] Checking style of '$$commit'\n\n"; \ 1664 ( git log --format=email "$$commit~..$$commit" \ 1665 -- ${CHECK_PATHS} ; \ 1666 git diff --format=email "$$commit~..$$commit" \ 1667 -- ${CHECK_PATHS}; ) | \ 1668 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 1669 done 1670 1671certtool: ${CRTTOOL} 1672 1673${CRTTOOL}: FORCE 1674 $(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 1675 $(s)echo 1676 $(s)echo "Built $@ successfully" 1677 $(s)echo 1678 1679ifneq (${GENERATE_COT},0) 1680certificates: ${CRT_DEPS} ${CRTTOOL} 1681 $(q)${CRTTOOL} ${CRT_ARGS} 1682 $(s)echo 1683 $(s)echo "Built $@ successfully" 1684 $(s)echo "Certificates can be found in ${BUILD_PLAT}" 1685 $(s)echo 1686endif #(GENERATE_COT) 1687 1688${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL} 1689 $(eval ${CHECK_FIP_CMD}) 1690 $(q)${FIPTOOL} create ${FIP_ARGS} $@ 1691 $(q)${FIPTOOL} info $@ 1692 $(s)echo 1693 $(s)echo "Built $@ successfully" 1694 $(s)echo 1695 1696ifneq (${GENERATE_COT},0) 1697fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL} 1698 $(q)${CRTTOOL} ${FWU_CRT_ARGS} 1699 $(s)echo 1700 $(s)echo "Built $@ successfully" 1701 $(s)echo "FWU certificates can be found in ${BUILD_PLAT}" 1702 $(s)echo 1703endif #(GENERATE_COT) 1704 1705${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL} 1706 $(eval ${CHECK_FWU_FIP_CMD}) 1707 $(q)${FIPTOOL} create ${FWU_FIP_ARGS} $@ 1708 $(q)${FIPTOOL} info $@ 1709 $(s)echo 1710 $(s)echo "Built $@ successfully" 1711 $(s)echo 1712 1713fiptool: ${FIPTOOL} 1714fip: ${BUILD_PLAT}/${FIP_NAME} 1715fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME} 1716 1717${FIPTOOL}: FORCE 1718ifdef UNIX_MK 1719 $(q)${MAKE} PLAT=${PLAT} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${FIPTOOLPATH} all 1720else 1721# Clear the MAKEFLAGS as we do not want 1722# to pass the gnumake flags to nmake. 1723 $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) 1724endif #(UNIX_MK) 1725 1726romlib.bin: libraries FORCE 1727 $(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 1728 1729memmap: all 1730ifdef UNIX_MK 1731 $(q)PYTHONPATH=${CURDIR}/tools/memory \ 1732 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT} 1733else 1734 $(q)set PYTHONPATH=${CURDIR}/tools/memory && \ 1735 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT} 1736endif 1737 1738tl: ${BUILD_PLAT}/tl.bin 1739${BUILD_PLAT}/tl.bin: ${HW_CONFIG} 1740 $(if $(host-poetry),$(q)poetry -q install) 1741 $(q)$(if $(host-poetry),poetry run )tlc create --fdt $< -s ${FW_HANDOFF_SIZE} $@ 1742 1743doc: 1744 $(s)echo " BUILD DOCUMENTATION" 1745 $(q)${MAKE} --no-print-directory -C ${DOCS_PATH} html 1746 1747enctool: ${ENCTOOL} 1748 1749${ENCTOOL}: FORCE 1750 $(q)${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} --no-print-directory -C ${ENCTOOLPATH} all 1751 $(s)echo 1752 $(s)echo "Built $@ successfully" 1753 $(s)echo 1754 1755cscope: 1756 $(s)echo " CSCOPE" 1757 $(q)find ${CURDIR} -name "*.[chsS]" > cscope.files 1758 $(q)cscope -b -q -k 1759 1760help: 1761 $(s)echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]" 1762 $(s)echo "" 1763 $(s)echo "PLAT is used to specify which platform you wish to build." 1764 $(s)echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}" 1765 $(s)echo "" 1766 $(s)echo "platform = ${PLATFORM_LIST}" 1767 $(s)echo "" 1768 $(s)echo "Please refer to the User Guide for a list of all supported options." 1769 $(s)echo "Note that the build system doesn't track dependencies for build " 1770 $(s)echo "options. Therefore, if any of the build options are changed " 1771 $(s)echo "from a previous build, a clean build must be performed." 1772 $(s)echo "" 1773 $(s)echo "Supported Targets:" 1774 $(s)echo " all Build all individual bootloader binaries" 1775 $(s)echo " bl1 Build the BL1 binary" 1776 $(s)echo " bl2 Build the BL2 binary" 1777 $(s)echo " bl2u Build the BL2U binary" 1778 $(s)echo " bl31 Build the BL31 binary" 1779 $(s)echo " bl32 Build the BL32 binary. If ARCH=aarch32, then " 1780 $(s)echo " this builds secure payload specified by AARCH32_SP" 1781 $(s)echo " certificates Build the certificates (requires 'GENERATE_COT=1')" 1782 $(s)echo " fip Build the Firmware Image Package (FIP)" 1783 $(s)echo " fwu_fip Build the FWU Firmware Image Package (FIP)" 1784 $(s)echo " checkcodebase Check the coding style of the entire source tree" 1785 $(s)echo " checkpatch Check the coding style on changes in the current" 1786 $(s)echo " branch against BASE_COMMIT (default origin/master)" 1787 $(s)echo " clean Clean the build for the selected platform" 1788 $(s)echo " cscope Generate cscope index" 1789 $(s)echo " distclean Remove all build artifacts for all platforms" 1790 $(s)echo " certtool Build the Certificate generation tool" 1791 $(s)echo " enctool Build the Firmware encryption tool" 1792 $(s)echo " fiptool Build the Firmware Image Package (FIP) creation tool" 1793 $(s)echo " sp Build the Secure Partition Packages" 1794 $(s)echo " sptool Build the Secure Partition Package creation tool" 1795 $(s)echo " dtbs Build the Device Tree Blobs (if required for the platform)" 1796 $(s)echo " memmap Print the memory map of the built binaries" 1797 $(s)echo " doc Build html based documentation using Sphinx tool" 1798 $(s)echo "" 1799 $(s)echo "Note: most build targets require PLAT to be set to a specific platform." 1800 $(s)echo "" 1801 $(s)echo "example: build all targets for the FVP platform:" 1802 $(s)echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all" 1803 1804.PHONY: FORCE 1805FORCE:; 1806