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