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