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-unknown-none-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 (${SPD},spmd) 437 # SPMD is located in std_svc directory 438 SPD_DIR := std_svc 439 440 ifeq ($(SPMD_SPM_AT_SEL2),1) 441 CTX_INCLUDE_EL2_REGS := 1 442 endif 443 444 ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp) 445 DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG 446 endif 447 448 ifeq ($(findstring trusty_sp,$(ARM_SPMC_MANIFEST_DTS)),trusty_sp) 449 DTC_CPPFLAGS += -DTRUSTY_SP_FW_CONFIG 450 endif 451 452 ifeq ($(TS_SP_FW_CONFIG),1) 453 DTC_CPPFLAGS += -DTS_SP_FW_CONFIG 454 endif 455 456 ifneq ($(ARM_BL2_SP_LIST_DTS),) 457 DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS) 458 endif 459 460 ifneq ($(SP_LAYOUT_FILE),) 461 BL2_ENABLE_SP_LOAD := 1 462 endif 463 else 464 # All other SPDs in spd directory 465 SPD_DIR := spd 466 endif #(SPD) 467 468 # We expect to locate an spd.mk under the specified SPD directory 469 SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk) 470 471 ifeq (${SPD_MAKE},) 472 $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located) 473 endif 474 $(info Including ${SPD_MAKE}) 475 include ${SPD_MAKE} 476 477 # If there's BL32 companion for the chosen SPD, we expect that the SPD's 478 # Makefile would set NEED_BL32 to "yes". In this case, the build system 479 # supports two mutually exclusive options: 480 # * BL32 is built from source: then BL32_SOURCES must contain the list 481 # of source files to build BL32 482 # * BL32 is a prebuilt binary: then BL32 must point to the image file 483 # that will be included in the FIP 484 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence 485 # over the sources. 486endif #(SPD=none) 487 488################################################################################ 489# Include the platform specific Makefile after the SPD Makefile (the platform 490# makefile may use all previous definitions in this file) 491################################################################################ 492include ${PLAT_MAKEFILE_FULL} 493 494################################################################################ 495# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from 496# platform. 497################################################################################ 498 499include ${MAKE_HELPERS_DIRECTORY}arch_features.mk 500################################################################################ 501# Process BRANCH_PROTECTION value and set 502# Pointer Authentication and Branch Target Identification flags 503################################################################################ 504ifeq (${BRANCH_PROTECTION},0) 505 # Default value turns off all types of branch protection 506 BP_OPTION := none 507else ifneq (${ARCH},aarch64) 508 $(error BRANCH_PROTECTION requires AArch64) 509else ifeq (${BRANCH_PROTECTION},1) 510 # Enables all types of branch protection features 511 BP_OPTION := standard 512 ENABLE_BTI := 1 513 ENABLE_PAUTH := 1 514else ifeq (${BRANCH_PROTECTION},2) 515 # Return address signing to its standard level 516 BP_OPTION := pac-ret 517 ENABLE_PAUTH := 1 518else ifeq (${BRANCH_PROTECTION},3) 519 # Extend the signing to include leaf functions 520 BP_OPTION := pac-ret+leaf 521 ENABLE_PAUTH := 1 522else ifeq (${BRANCH_PROTECTION},4) 523 # Turn on branch target identification mechanism 524 BP_OPTION := bti 525 ENABLE_BTI := 1 526else ifeq (${BRANCH_PROTECTION},5) 527 # Turn on branch target identification mechanism 528 BP_OPTION := standard 529 ENABLE_BTI := 2 530 ENABLE_PAUTH := 2 531else 532 $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION}) 533endif #(BRANCH_PROTECTION) 534 535ifneq ($(ENABLE_PAUTH),0) 536 CTX_INCLUDE_PAUTH_REGS := ${ENABLE_PAUTH} 537endif 538ifneq (${BP_OPTION},none) 539 TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION} 540endif #(BP_OPTION) 541 542# Pointer Authentication sources 543ifneq (${ENABLE_PAUTH},0) 544# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the 545# Pauth support. As it's not secure, it must be reimplemented for real platforms 546 BL_COMMON_SOURCES += lib/extensions/pauth/pauth.c 547endif 548 549#################################################### 550# Enable required options for Memory Stack Tagging. 551#################################################### 552 553# Currently, these options are enabled only for clang and armclang compiler. 554ifeq (${SUPPORT_STACK_MEMTAG},yes) 555 ifdef mem_tag_arch_support 556 # Check for armclang and clang compilers 557 ifneq ($(filter %-clang,$($(ARCH)-cc-id)),) 558 # Add "memtag" architecture feature modifier if not specified 559 ifeq ( ,$(findstring memtag,$(arch-features))) 560 arch-features := $(arch-features)+memtag 561 endif # memtag 562 ifeq ($($(ARCH)-cc-id),arm-clang) 563 TF_CFLAGS += -mmemtag-stack 564 else ifeq ($($(ARCH)-cc-id),llvm-clang) 565 TF_CFLAGS += -fsanitize=memtag 566 endif # armclang 567 endif 568 else 569 $(error "Error: stack memory tagging is not supported for \ 570 architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a") 571 endif #(mem_tag_arch_support) 572endif #(SUPPORT_STACK_MEMTAG) 573 574################################################################################ 575# RME dependent flags configuration, Enable optional features for RME. 576################################################################################ 577# FEAT_RME 578ifeq (${ENABLE_RME},1) 579 # RME requires AARCH64 580 ifneq (${ARCH},aarch64) 581 $(error ENABLE_RME requires AArch64) 582 endif 583 584 # RME requires el2 context to be saved for now. 585 CTX_INCLUDE_EL2_REGS := 1 586 CTX_INCLUDE_AARCH32_REGS := 0 587 CTX_INCLUDE_PAUTH_REGS := 1 588 589 ifneq ($(ENABLE_FEAT_MPAM), 0) 590 CTX_INCLUDE_MPAM_REGS := 1 591 endif 592 593 # RME enables CSV2_2 extension by default. 594 ENABLE_FEAT_CSV2_2 = 1 595endif #(FEAT_RME) 596 597################################################################################ 598# Include rmmd Makefile if RME is enabled 599################################################################################ 600ifneq (${ENABLE_RME},0) 601 ifneq (${ARCH},aarch64) 602 $(error ENABLE_RME requires AArch64) 603 endif 604 ifeq ($(SPMC_AT_EL3),1) 605 $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.) 606 endif 607 608 ifneq (${SPD}, none) 609 ifneq (${SPD}, spmd) 610 $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd) 611 endif 612 endif 613include services/std_svc/rmmd/rmmd.mk 614$(warning "RME is an experimental feature") 615endif 616 617ifeq (${CTX_INCLUDE_EL2_REGS}, 1) 618 ifeq (${SPD},none) 619 ifeq (${ENABLE_RME},0) 620 $(error CTX_INCLUDE_EL2_REGS is available only when SPD \ 621 or RME is enabled) 622 endif 623 endif 624endif 625 626################################################################################ 627# Verify FEAT_RME, FEAT_SCTLR2 and FEAT_TCR2 are enabled if FEAT_MEC is enabled. 628################################################################################ 629 630ifneq (${ENABLE_FEAT_MEC},0) 631 ifeq (${ENABLE_RME},0) 632 $(error FEAT_RME must be enabled when FEAT_MEC is enabled.) 633 endif 634 ifeq (${ENABLE_FEAT_TCR2},0) 635 $(error FEAT_TCR2 must be enabled when FEAT_MEC is enabled.) 636 endif 637 ifeq (${ENABLE_FEAT_SCTLR2},0) 638 $(error FEAT_SCTLR2 must be enabled when FEAT_MEC is enabled.) 639 endif 640endif 641 642################################################################################ 643# Make 128-Bit sysreg read/writes availabe when FEAT_D128 is enabled. 644################################################################################ 645ifneq (${ENABLE_FEAT_D128}, 0) 646 BL_COMMON_SOURCES += lib/extensions/sysreg128/sysreg128.S 647endif 648 649################################################################################ 650# Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come 651# up with appropriate march values for compiler. 652################################################################################ 653include ${MAKE_HELPERS_DIRECTORY}march.mk 654 655TF_CFLAGS += $(march-directive) 656ASFLAGS += $(march-directive) 657 658# This internal flag is common option which is set to 1 for scenarios 659# when the BL2 is running in EL3 level. This occurs in two scenarios - 660# 4 world system running BL2 at EL3 and two world system without BL1 running 661# BL2 in EL3 662 663ifeq (${RESET_TO_BL2},1) 664 BL2_RUNS_AT_EL3 := 1 665 ifeq (${ENABLE_RME},1) 666 $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \ 667 supported at the moment.) 668 endif 669else ifeq (${ENABLE_RME},1) 670 BL2_RUNS_AT_EL3 := 1 671else 672 BL2_RUNS_AT_EL3 := 0 673endif 674 675# This internal flag is set to 1 when Firmware First handling of External aborts 676# is required by lowe ELs. Currently only NS requires this support. 677ifeq ($(HANDLE_EA_EL3_FIRST_NS),1) 678 FFH_SUPPORT := 1 679else 680 FFH_SUPPORT := 0 681endif 682 683ifeq (${ARM_ARCH_MAJOR},7) 684include make_helpers/armv7-a-cpus.mk 685endif 686 687PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT}) 688ifneq ($(PIE_FOUND),) 689 TF_CFLAGS += -fno-PIE 690ifeq ($($(ARCH)-ld-id),gnu-gcc) 691 TF_LDFLAGS += -no-pie 692endif 693endif #(PIE_FOUND) 694 695ifeq ($($(ARCH)-ld-id),gnu-gcc) 696 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker 697else 698 PIE_LDFLAGS += -pie --no-dynamic-linker 699endif 700 701ifeq ($(ENABLE_PIE),1) 702 ifeq ($(RESET_TO_BL2),1) 703 ifneq ($(BL2_IN_XIP_MEM),1) 704 BL2_CPPFLAGS += -fpie 705 BL2_CFLAGS += -fpie 706 BL2_LDFLAGS += $(PIE_LDFLAGS) 707 endif #(BL2_IN_XIP_MEM) 708 endif #(RESET_TO_BL2) 709 BL31_CPPFLAGS += -fpie 710 BL31_CFLAGS += -fpie 711 BL31_LDFLAGS += $(PIE_LDFLAGS) 712 713 BL32_CPPFLAGS += -fpie 714 BL32_CFLAGS += -fpie 715 BL32_LDFLAGS += $(PIE_LDFLAGS) 716endif #(ENABLE_PIE) 717 718BL1_CPPFLAGS += -DREPORT_ERRATA=${DEBUG} 719BL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG} 720BL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG} 721 722BL1_CPPFLAGS += -DIMAGE_AT_EL3 723ifeq ($(RESET_TO_BL2),1) 724 BL2_CPPFLAGS += -DIMAGE_AT_EL3 725else 726 BL2_CPPFLAGS += -DIMAGE_AT_EL1 727endif #(RESET_TO_BL2) 728 729ifeq (${ARCH},aarch64) 730 BL2U_CPPFLAGS += -DIMAGE_AT_EL1 731 BL31_CPPFLAGS += -DIMAGE_AT_EL3 732 BL32_CPPFLAGS += -DIMAGE_AT_EL1 733else 734 BL32_CPPFLAGS += -DIMAGE_AT_EL3 735endif 736 737# Include the CPU specific operations makefile, which provides default 738# values for all CPU errata workarounds and CPU specific optimisations. 739# This can be overridden by the platform. 740include lib/cpus/cpu-ops.mk 741 742################################################################################ 743# Build `AARCH32_SP` as BL32 image for AArch32 744################################################################################ 745ifeq (${ARCH},aarch32) 746 NEED_BL32 := yes 747 748 ifneq (${AARCH32_SP},none) 749 # We expect to locate an sp.mk under the specified AARCH32_SP directory 750 AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk) 751 752 ifeq (${AARCH32_SP_MAKE},) 753 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located) 754 endif 755 $(info Including ${AARCH32_SP_MAKE}) 756 include ${AARCH32_SP_MAKE} 757 endif 758endif #(ARCH=aarch32) 759 760################################################################################ 761# Include libc if not overridden 762################################################################################ 763ifeq (${OVERRIDE_LIBC},0) 764include lib/libc/libc.mk 765endif 766 767ifneq (${USE_GIC_DRIVER},0) 768include drivers/arm/gic/gic.mk 769endif 770 771################################################################################ 772# Check incompatible options and dependencies 773################################################################################ 774 775# Handle all invalid build configurations with SPMD usage. 776ifeq (${ENABLE_SPMD_LP}, 1) 777ifneq (${SPD},spmd) 778 $(error Error: ENABLE_SPMD_LP requires SPD=spmd.) 779endif 780ifeq ($(SPMC_AT_EL3),1) 781 $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.) 782endif 783endif 784 785ifneq (${SPD},none) 786ifeq (${ARCH},aarch32) 787 $(error "Error: SPD is incompatible with AArch32.") 788endif 789ifdef EL3_PAYLOAD_BASE 790 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.") 791 $(warning "The SPD and its BL32 companion will be present but ignored.") 792endif 793ifeq (${SPD},spmd) 794ifeq ($(SPMD_SPM_AT_SEL2),1) 795 ifeq ($(SPMC_AT_EL3),1) 796 $(error SPM cannot be enabled in both S-EL2 and EL3.) 797 endif 798 ifeq ($(CTX_INCLUDE_SVE_REGS),1) 799 $(error SVE context management not needed with Hafnium SPMC.) 800 endif 801endif 802 803ifeq ($(SPMC_AT_EL3_SEL0_SP),1) 804 ifneq ($(SPMC_AT_EL3),1) 805 $(error SEL0 SP cannot be enabled without SPMC at EL3) 806 endif 807endif 808endif #(SPD=spmd) 809endif #(SPD!=none) 810 811# USE_DEBUGFS experimental feature recommended only in debug builds 812ifeq (${USE_DEBUGFS},1) 813 ifeq (${DEBUG},1) 814 $(warning DEBUGFS experimental feature is enabled.) 815 else 816 $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY) 817 endif 818endif #(USE_DEBUGFS) 819 820# USE_SPINLOCK_CAS requires AArch64 build 821ifeq (${USE_SPINLOCK_CAS},1) 822 ifneq (${ARCH},aarch64) 823 $(error USE_SPINLOCK_CAS requires AArch64) 824 endif 825endif #(USE_SPINLOCK_CAS) 826 827# The cert_create tool cannot generate certificates individually, so we use the 828# target 'certificates' to create them all 829ifneq (${GENERATE_COT},0) 830 FIP_DEPS += certificates 831 FWU_FIP_DEPS += fwu_certificates 832endif 833 834ifneq (${DECRYPTION_SUPPORT},none) 835 ENC_ARGS += -f ${FW_ENC_STATUS} 836 ENC_ARGS += -k ${ENC_KEY} 837 ENC_ARGS += -n ${ENC_NONCE} 838 FIP_DEPS += enctool 839 FWU_FIP_DEPS += enctool 840endif #(DECRYPTION_SUPPORT) 841 842ifdef EL3_PAYLOAD_BASE 843 ifdef PRELOADED_BL33_BASE 844 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \ 845 incompatible build options. EL3_PAYLOAD_BASE has priority.") 846 endif 847 ifneq (${GENERATE_COT},0) 848 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \ 849 build options.") 850 endif 851 ifneq (${TRUSTED_BOARD_BOOT},0) 852 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \ 853 incompatible \ build options.") 854 endif 855endif #(EL3_PAYLOAD_BASE) 856 857ifeq (${NEED_BL33},yes) 858 ifdef EL3_PAYLOAD_BASE 859 $(warning "BL33 image is not needed when option \ 860 BL33_PAYLOAD_BASE is used and won't be added to the FIP file.") 861 endif 862 ifdef PRELOADED_BL33_BASE 863 $(warning "BL33 image is not needed when option \ 864 PRELOADED_BL33_BASE is used and won't be added to the FIP file.") 865 endif 866endif #(NEED_BL33) 867 868# When building for systems with hardware-assisted coherency, there's no need to 869# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too. 870ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1) 871 $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY) 872endif 873 874#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1. 875ifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1) 876 $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled") 877endif 878 879# RAS_EXTENSION is deprecated, provide alternate build options 880ifeq ($(RAS_EXTENSION),1) 881 $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \ 882 and HANDLE_EA_EL3_FIRST_NS instead") 883endif 884 885 886# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled 887ifeq ($(FAULT_INJECTION_SUPPORT),1) 888 ifeq ($(ENABLE_FEAT_RAS),0) 889 $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0) 890 endif 891endif #(FAULT_INJECTION_SUPPORT) 892 893# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1 894ifeq ($(DYN_DISABLE_AUTH), 1) 895 ifeq (${TRUSTED_BOARD_BOOT}, 0) 896 $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \ 897 to be set.") 898 endif 899endif #(DYN_DISABLE_AUTH) 900 901ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1) 902# Support authentication verification and hash calculation 903 CRYPTO_SUPPORT := 3 904else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1) 905# Support authentication verification and hash calculation 906 CRYPTO_SUPPORT := 3 907else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),) 908# Support hash calculation only 909 CRYPTO_SUPPORT := 2 910else ifeq (${TRUSTED_BOARD_BOOT},1) 911# Support authentication verification only 912 CRYPTO_SUPPORT := 1 913else 914 CRYPTO_SUPPORT := 0 915endif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT)) 916 917ifneq ($(filter 1 2 3,$(CRYPTO_SUPPORT)),) 918CRYPTO_LIB := $(BUILD_PLAT)/lib/libmbedtls.a 919endif 920 921# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled. 922ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1) 923 $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled") 924endif 925 926# If pointer authentication is used in the firmware, make sure that all the 927# registers associated to it are also saved and restored. 928# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1. 929ifneq ($(ENABLE_PAUTH),0) 930 ifeq ($(CTX_INCLUDE_PAUTH_REGS),0) 931 $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS to be enabled) 932 endif 933endif #(ENABLE_PAUTH) 934 935ifneq ($(CTX_INCLUDE_PAUTH_REGS),0) 936 ifneq (${ARCH},aarch64) 937 $(error CTX_INCLUDE_PAUTH_REGS requires AArch64) 938 endif 939endif #(CTX_INCLUDE_PAUTH_REGS) 940 941ifeq ($(FEATURE_DETECTION),1) 942 $(info FEATURE_DETECTION is an experimental feature) 943endif #(FEATURE_DETECTION) 944 945ifneq ($(ENABLE_SME2_FOR_NS), 0) 946 ifeq (${ENABLE_SME_FOR_NS}, 0) 947 $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \ 948 to be set") 949 $(warning "Forced ENABLE_SME_FOR_NS=1") 950 override ENABLE_SME_FOR_NS := 1 951 endif 952endif #(ENABLE_SME2_FOR_NS) 953 954ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1) 955 ifeq (${ALLOW_RO_XLAT_TABLES}, 1) 956 $(error "ALLOW_RO_XLAT_TABLES requires translation tables \ 957 library v2") 958 endif 959endif #(ARM_XLAT_TABLES_LIB_V1) 960 961ifneq (${DECRYPTION_SUPPORT},none) 962 ifeq (${TRUSTED_BOARD_BOOT}, 0) 963 $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \ 964 to be set) 965 endif 966endif #(DECRYPTION_SUPPORT) 967 968# Ensure that no Aarch64-only features are enabled in Aarch32 build 969ifeq (${ARCH},aarch32) 970 971 # SME/SVE only supported on AArch64 972 ifneq (${ENABLE_SME_FOR_NS},0) 973 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32") 974 endif 975 976 ifeq (${ENABLE_SVE_FOR_NS},1) 977 # Warning instead of error due to CI dependency on this 978 $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32") 979 endif 980 981 # BRBE is not supported in AArch32 982 ifeq (${ENABLE_BRBE_FOR_NS},1) 983 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32") 984 endif 985 986 # FEAT_RNG_TRAP is not supported in AArch32 987 ifeq (${ENABLE_FEAT_RNG_TRAP},1) 988 $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32") 989 endif 990 991 ifneq (${ENABLE_FEAT_FPMR},0) 992 $(error "ENABLE_FEAT_FPMR cannot be used with ARCH=aarch32") 993 endif 994 995 ifeq (${ARCH_FEATURE_AVAILABILITY},1) 996 $(error "ARCH_FEATURE_AVAILABILITY cannot be used with ARCH=aarch32") 997 endif 998 # FEAT_MOPS is only supported on AArch64 999 ifneq (${ENABLE_FEAT_MOPS},0) 1000 $(error "ENABLE_FEAT_MOPS cannot be used with ARCH=aarch32") 1001 endif 1002endif #(ARCH=aarch32) 1003 1004ifneq (${ENABLE_FEAT_FPMR},0) 1005 ifeq (${ENABLE_FEAT_FGT},0) 1006 $(error "ENABLE_FEAT_FPMR requires ENABLE_FEAT_FGT") 1007 endif 1008 ifeq (${ENABLE_FEAT_HCX},0) 1009 $(error "ENABLE_FEAT_FPMR requires ENABLE_FEAT_HCX") 1010 endif 1011endif #(ENABLE_FEAT_FPMR) 1012 1013ifneq (${ENABLE_SME_FOR_NS},0) 1014 ifeq (${ENABLE_SVE_FOR_NS},0) 1015 $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS") 1016 endif 1017endif #(ENABLE_SME_FOR_NS) 1018 1019# Secure SME/SVE requires the non-secure component as well 1020ifeq (${ENABLE_SME_FOR_SWD},1) 1021 ifeq (${ENABLE_SME_FOR_NS},0) 1022 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS") 1023 endif 1024 ifeq (${ENABLE_SVE_FOR_SWD},0) 1025 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD") 1026 endif 1027endif #(ENABLE_SME_FOR_SWD) 1028 1029# Enabling SVE for SWD requires enabling SVE for NWD due to ENABLE_FEAT 1030# mechanism. 1031ifeq (${ENABLE_SVE_FOR_SWD},1) 1032 ifeq (${ENABLE_SVE_FOR_NS},0) 1033 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS") 1034 endif 1035endif 1036 1037# Enabling FEAT_MOPS requires access to hcrx_el2 registers which is 1038# available only when FEAT_HCX is enabled. 1039ifneq (${ENABLE_FEAT_MOPS},0) 1040 ifeq (${ENABLE_FEAT_HCX},0) 1041 $(error "ENABLE_FEAT_MOPS requires ENABLE_FEAT_HCX") 1042 endif 1043endif 1044 1045# Enabling SVE for both the worlds typically requires the context 1046# management of SVE registers. The only exception being SPMC at S-EL2. 1047ifeq (${ENABLE_SVE_FOR_SWD}, 1) 1048 ifneq (${ENABLE_SVE_FOR_NS}, 0) 1049 ifeq (${CTX_INCLUDE_SVE_REGS}-$(SPMD_SPM_AT_SEL2),0-0) 1050 $(warning "ENABLE_SVE_FOR_SWD and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS") 1051 endif 1052 endif 1053endif 1054 1055# Enabling SVE in either world while enabling CTX_INCLUDE_FPREGS requires 1056# CTX_INCLUDE_SVE_REGS to be enabled due to architectural dependency between FP 1057# and SVE registers. 1058ifeq (${CTX_INCLUDE_FPREGS}, 1) 1059 ifneq (${ENABLE_SVE_FOR_NS},0) 1060 ifeq (${CTX_INCLUDE_SVE_REGS},0) 1061 # Warning instead of error due to CI dependency on this 1062 $(warning "CTX_INCLUDE_FPREGS and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS") 1063 $(warning "Forced ENABLE_SVE_FOR_NS=0") 1064 override ENABLE_SVE_FOR_NS := 0 1065 endif 1066 endif 1067endif #(CTX_INCLUDE_FPREGS) 1068 1069# SVE context management is only required if secure world has access to SVE/FP 1070# functionality. 1071ifeq (${CTX_INCLUDE_SVE_REGS},1) 1072 ifeq (${ENABLE_SVE_FOR_SWD},0) 1073 $(error "CTX_INCLUDE_SVE_REGS requires ENABLE_SVE_FOR_SWD to also be enabled") 1074 endif 1075endif 1076 1077# SME cannot be used with CTX_INCLUDE_FPREGS since SPM does its own context 1078# management including FPU registers. 1079ifeq (${CTX_INCLUDE_FPREGS},1) 1080 ifneq (${ENABLE_SME_FOR_NS},0) 1081 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS") 1082 endif 1083endif #(CTX_INCLUDE_FPREGS) 1084 1085ifeq ($(DRTM_SUPPORT),1) 1086 $(info DRTM_SUPPORT is an experimental feature) 1087endif 1088 1089ifeq (${HOB_LIST},1) 1090 $(warning HOB_LIST is an experimental feature) 1091endif 1092 1093ifeq (${TRANSFER_LIST},1) 1094 $(info TRANSFER_LIST is an experimental feature) 1095endif 1096 1097ifeq (${ENABLE_RME},1) 1098 ifneq (${SEPARATE_CODE_AND_RODATA},1) 1099 $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`) 1100 endif 1101endif 1102 1103ifeq ($(PSA_CRYPTO),1) 1104 $(info PSA_CRYPTO is an experimental feature) 1105endif 1106 1107ifeq ($(DICE_PROTECTION_ENVIRONMENT),1) 1108 $(info DICE_PROTECTION_ENVIRONMENT is an experimental feature) 1109endif 1110 1111################################################################################ 1112# Process platform overrideable behaviour 1113################################################################################ 1114 1115ifdef BL1_SOURCES 1116 NEED_BL1 := yes 1117endif #(BL1_SOURCES) 1118 1119ifdef BL2_SOURCES 1120 NEED_BL2 := yes 1121 1122 # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and 1123 # Certificate generation tools. This flag can be overridden by the platform. 1124 ifdef EL3_PAYLOAD_BASE 1125 # If booting an EL3 payload there is no need for a BL33 image 1126 # in the FIP file. 1127 NEED_BL33 := no 1128 else 1129 ifdef PRELOADED_BL33_BASE 1130 # If booting a BL33 preloaded image there is no need of 1131 # another one in the FIP file. 1132 NEED_BL33 := no 1133 else 1134 NEED_BL33 ?= yes 1135 endif 1136 endif 1137endif #(BL2_SOURCES) 1138 1139ifdef BL2U_SOURCES 1140 NEED_BL2U := yes 1141endif #(BL2U_SOURCES) 1142 1143# If SCP_BL2 is given, we always want FIP to include it. 1144ifdef SCP_BL2 1145 NEED_SCP_BL2 := yes 1146endif #(SCP_BL2) 1147 1148# For AArch32, BL31 is not currently supported. 1149ifneq (${ARCH},aarch32) 1150 ifdef BL31_SOURCES 1151 # When booting an EL3 payload, there is no need to compile the BL31 1152 # image nor put it in the FIP. 1153 ifndef EL3_PAYLOAD_BASE 1154 NEED_BL31 := yes 1155 endif 1156 endif 1157endif #(ARCH=aarch64) 1158 1159# Process TBB related flags 1160ifneq (${GENERATE_COT},0) 1161 # Common cert_create options 1162 ifneq (${CREATE_KEYS},0) 1163 $(eval CRT_ARGS += -n) 1164 $(eval FWU_CRT_ARGS += -n) 1165 ifneq (${SAVE_KEYS},0) 1166 $(eval CRT_ARGS += -k) 1167 $(eval FWU_CRT_ARGS += -k) 1168 endif 1169 endif 1170 # Include TBBR makefile (unless the platform indicates otherwise) 1171 ifeq (${INCLUDE_TBBR_MK},1) 1172 include make_helpers/tbbr/tbbr_tools.mk 1173 endif 1174endif #(GENERATE_COT) 1175 1176ifneq (${FIP_ALIGN},0) 1177 FIP_ARGS += --align ${FIP_ALIGN} 1178endif #(FIP_ALIGN) 1179 1180ifdef FDT_SOURCES 1181 NEED_FDT := yes 1182endif #(FDT_SOURCES) 1183 1184################################################################################ 1185# Include libraries' Makefile that are used in all BL 1186################################################################################ 1187 1188include lib/stack_protector/stack_protector.mk 1189 1190################################################################################ 1191# Include BL specific makefiles 1192################################################################################ 1193 1194ifeq (${NEED_BL1},yes) 1195include bl1/bl1.mk 1196endif 1197 1198ifeq (${NEED_BL2},yes) 1199include bl2/bl2.mk 1200endif 1201 1202ifeq (${NEED_BL2U},yes) 1203include bl2u/bl2u.mk 1204endif 1205 1206ifeq (${NEED_BL31},yes) 1207include bl31/bl31.mk 1208endif 1209 1210################################################################################ 1211# Build options checks 1212################################################################################ 1213 1214# Boolean_Flags 1215$(eval $(call assert_booleans,\ 1216 $(sort \ 1217 ALLOW_RO_XLAT_TABLES \ 1218 BL2_ENABLE_SP_LOAD \ 1219 COLD_BOOT_SINGLE_CPU \ 1220 CREATE_KEYS \ 1221 CTX_INCLUDE_AARCH32_REGS \ 1222 CTX_INCLUDE_FPREGS \ 1223 CTX_INCLUDE_SVE_REGS \ 1224 CTX_INCLUDE_EL2_REGS \ 1225 CTX_INCLUDE_MPAM_REGS \ 1226 DEBUG \ 1227 DYN_DISABLE_AUTH \ 1228 EL3_EXCEPTION_HANDLING \ 1229 ENABLE_AMU_AUXILIARY_COUNTERS \ 1230 AMU_RESTRICT_COUNTERS \ 1231 ENABLE_ASSERTIONS \ 1232 ENABLE_PIE \ 1233 ENABLE_PMF \ 1234 ENABLE_PSCI_STAT \ 1235 ENABLE_RUNTIME_INSTRUMENTATION \ 1236 ENABLE_SME_FOR_SWD \ 1237 ENABLE_SVE_FOR_SWD \ 1238 ENABLE_FEAT_RAS \ 1239 FFH_SUPPORT \ 1240 ERROR_DEPRECATED \ 1241 FAULT_INJECTION_SUPPORT \ 1242 GENERATE_COT \ 1243 GICV2_G0_FOR_EL3 \ 1244 HANDLE_EA_EL3_FIRST_NS \ 1245 HARDEN_SLS \ 1246 HW_ASSISTED_COHERENCY \ 1247 MEASURED_BOOT \ 1248 DISCRETE_TPM \ 1249 DICE_PROTECTION_ENVIRONMENT \ 1250 RMMD_ENABLE_EL3_TOKEN_SIGN \ 1251 RMMD_ENABLE_IDE_KEY_PROG \ 1252 DRTM_SUPPORT \ 1253 NS_TIMER_SWITCH \ 1254 OVERRIDE_LIBC \ 1255 PL011_GENERIC_UART \ 1256 PROGRAMMABLE_RESET_ADDRESS \ 1257 PSCI_EXTENDED_STATE_ID \ 1258 PSCI_OS_INIT_MODE \ 1259 ARCH_FEATURE_AVAILABILITY \ 1260 RESET_TO_BL31 \ 1261 SAVE_KEYS \ 1262 SEPARATE_CODE_AND_RODATA \ 1263 SEPARATE_BL2_NOLOAD_REGION \ 1264 SEPARATE_NOBITS_REGION \ 1265 SEPARATE_RWDATA_REGION \ 1266 SEPARATE_SIMD_SECTION \ 1267 SPIN_ON_BL1_EXIT \ 1268 SPM_MM \ 1269 SPMC_AT_EL3 \ 1270 SPMC_AT_EL3_SEL0_SP \ 1271 SPMD_SPM_AT_SEL2 \ 1272 ENABLE_SPMD_LP \ 1273 TRANSFER_LIST \ 1274 TRUSTED_BOARD_BOOT \ 1275 USE_COHERENT_MEM \ 1276 USE_DEBUGFS \ 1277 ARM_IO_IN_DTB \ 1278 SDEI_IN_FCONF \ 1279 SEC_INT_DESC_IN_FCONF \ 1280 USE_ROMLIB \ 1281 USE_TBBR_DEFS \ 1282 WARMBOOT_ENABLE_DCACHE_EARLY \ 1283 RESET_TO_BL2 \ 1284 BL2_IN_XIP_MEM \ 1285 BL2_INV_DCACHE \ 1286 USE_SPINLOCK_CAS \ 1287 ENCRYPT_BL31 \ 1288 ENCRYPT_BL32 \ 1289 ERRATA_SPECULATIVE_AT \ 1290 ERRATA_SME_POWER_DOWN \ 1291 RAS_TRAP_NS_ERR_REC_ACCESS \ 1292 COT_DESC_IN_DTB \ 1293 USE_SP804_TIMER \ 1294 PSA_FWU_SUPPORT \ 1295 PSA_FWU_METADATA_FW_STORE_DESC \ 1296 ENABLE_MPMM \ 1297 FEAT_PABANDON \ 1298 FEATURE_DETECTION \ 1299 TRNG_SUPPORT \ 1300 ENABLE_ERRATA_ALL \ 1301 ERRATA_ABI_SUPPORT \ 1302 ERRATA_NON_ARM_INTERCONNECT \ 1303 CONDITIONAL_CMO \ 1304 PSA_CRYPTO \ 1305 ENABLE_CONSOLE_GETC \ 1306 INIT_UNUSED_NS_EL2 \ 1307 PLATFORM_REPORT_CTX_MEM_USE \ 1308 EARLY_CONSOLE \ 1309 PRESERVE_DSU_PMU_REGS \ 1310 HOB_LIST \ 1311))) 1312 1313# Numeric_Flags 1314$(eval $(call assert_numerics,\ 1315 $(sort \ 1316 ARM_ARCH_MAJOR \ 1317 ARM_ARCH_MINOR \ 1318 BRANCH_PROTECTION \ 1319 CTX_INCLUDE_PAUTH_REGS \ 1320 CTX_INCLUDE_NEVE_REGS \ 1321 CRYPTO_SUPPORT \ 1322 DISABLE_MTPMU \ 1323 ENABLE_BRBE_FOR_NS \ 1324 ENABLE_TRBE_FOR_NS \ 1325 ENABLE_BTI \ 1326 ENABLE_PAUTH \ 1327 ENABLE_FEAT_AMU \ 1328 ENABLE_FEAT_AMUv1p1 \ 1329 ENABLE_FEAT_CSV2_2 \ 1330 ENABLE_FEAT_CSV2_3 \ 1331 ENABLE_FEAT_DEBUGV8P9 \ 1332 ENABLE_FEAT_DIT \ 1333 ENABLE_FEAT_ECV \ 1334 ENABLE_FEAT_FGT \ 1335 ENABLE_FEAT_FGT2 \ 1336 ENABLE_FEAT_FPMR \ 1337 ENABLE_FEAT_HCX \ 1338 ENABLE_FEAT_LS64_ACCDATA \ 1339 ENABLE_FEAT_MEC \ 1340 ENABLE_FEAT_MOPS \ 1341 ENABLE_FEAT_MTE2 \ 1342 ENABLE_FEAT_PAN \ 1343 ENABLE_FEAT_RNG \ 1344 ENABLE_FEAT_RNG_TRAP \ 1345 ENABLE_FEAT_SEL2 \ 1346 ENABLE_FEAT_TCR2 \ 1347 ENABLE_FEAT_THE \ 1348 ENABLE_FEAT_SB \ 1349 ENABLE_FEAT_S2PIE \ 1350 ENABLE_FEAT_S1PIE \ 1351 ENABLE_FEAT_S2POE \ 1352 ENABLE_FEAT_S1POE \ 1353 ENABLE_FEAT_SCTLR2 \ 1354 ENABLE_FEAT_D128 \ 1355 ENABLE_FEAT_GCS \ 1356 ENABLE_FEAT_VHE \ 1357 ENABLE_FEAT_MPAM \ 1358 ENABLE_RME \ 1359 ENABLE_SPE_FOR_NS \ 1360 ENABLE_SYS_REG_TRACE_FOR_NS \ 1361 ENABLE_SME_FOR_NS \ 1362 ENABLE_SME2_FOR_NS \ 1363 ENABLE_SVE_FOR_NS \ 1364 ENABLE_TRF_FOR_NS \ 1365 FW_ENC_STATUS \ 1366 NR_OF_FW_BANKS \ 1367 NR_OF_IMAGES_IN_FW_BANK \ 1368 TWED_DELAY \ 1369 ENABLE_FEAT_TWED \ 1370 SVE_VECTOR_LEN \ 1371 IMPDEF_SYSREG_TRAP \ 1372))) 1373 1374ifdef KEY_SIZE 1375 $(eval $(call assert_numeric,KEY_SIZE)) 1376endif 1377 1378ifeq ($(filter $(SANITIZE_UB), on off trap),) 1379 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap") 1380endif 1381 1382################################################################################ 1383# Add definitions to the cpp preprocessor based on the current build options. 1384# This is done after including the platform specific makefile to allow the 1385# platform to overwrite the default options 1386################################################################################ 1387 1388$(eval $(call add_defines,\ 1389 $(sort \ 1390 ALLOW_RO_XLAT_TABLES \ 1391 ARM_ARCH_MAJOR \ 1392 ARM_ARCH_MINOR \ 1393 BL2_ENABLE_SP_LOAD \ 1394 COLD_BOOT_SINGLE_CPU \ 1395 CTX_INCLUDE_AARCH32_REGS \ 1396 CTX_INCLUDE_FPREGS \ 1397 CTX_INCLUDE_SVE_REGS \ 1398 CTX_INCLUDE_PAUTH_REGS \ 1399 CTX_INCLUDE_MPAM_REGS \ 1400 EL3_EXCEPTION_HANDLING \ 1401 CTX_INCLUDE_EL2_REGS \ 1402 CTX_INCLUDE_NEVE_REGS \ 1403 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \ 1404 DISABLE_MTPMU \ 1405 ENABLE_FEAT_AMU \ 1406 ENABLE_AMU_AUXILIARY_COUNTERS \ 1407 AMU_RESTRICT_COUNTERS \ 1408 ENABLE_ASSERTIONS \ 1409 ENABLE_BTI \ 1410 ENABLE_FEAT_DEBUGV8P9 \ 1411 ENABLE_FEAT_MPAM \ 1412 ENABLE_PAUTH \ 1413 ENABLE_PIE \ 1414 ENABLE_PMF \ 1415 ENABLE_PSCI_STAT \ 1416 ENABLE_RME \ 1417 RMMD_ENABLE_EL3_TOKEN_SIGN \ 1418 RMMD_ENABLE_IDE_KEY_PROG \ 1419 ENABLE_RUNTIME_INSTRUMENTATION \ 1420 ENABLE_SME_FOR_NS \ 1421 ENABLE_SME2_FOR_NS \ 1422 ENABLE_SME_FOR_SWD \ 1423 ENABLE_SPE_FOR_NS \ 1424 ENABLE_SVE_FOR_NS \ 1425 ENABLE_SVE_FOR_SWD \ 1426 ENABLE_FEAT_RAS \ 1427 FFH_SUPPORT \ 1428 ENCRYPT_BL31 \ 1429 ENCRYPT_BL32 \ 1430 ERROR_DEPRECATED \ 1431 FAULT_INJECTION_SUPPORT \ 1432 GICV2_G0_FOR_EL3 \ 1433 HANDLE_EA_EL3_FIRST_NS \ 1434 HW_ASSISTED_COHERENCY \ 1435 LOG_LEVEL \ 1436 MEASURED_BOOT \ 1437 DISCRETE_TPM \ 1438 DICE_PROTECTION_ENVIRONMENT \ 1439 DRTM_SUPPORT \ 1440 NS_TIMER_SWITCH \ 1441 PL011_GENERIC_UART \ 1442 PLAT_${PLAT} \ 1443 PROGRAMMABLE_RESET_ADDRESS \ 1444 PSCI_EXTENDED_STATE_ID \ 1445 PSCI_OS_INIT_MODE \ 1446 ARCH_FEATURE_AVAILABILITY \ 1447 RESET_TO_BL31 \ 1448 RME_GPT_BITLOCK_BLOCK \ 1449 RME_GPT_MAX_BLOCK \ 1450 SEPARATE_CODE_AND_RODATA \ 1451 SEPARATE_BL2_NOLOAD_REGION \ 1452 SEPARATE_NOBITS_REGION \ 1453 SEPARATE_RWDATA_REGION \ 1454 SEPARATE_SIMD_SECTION \ 1455 RECLAIM_INIT_CODE \ 1456 SPD_${SPD} \ 1457 SPIN_ON_BL1_EXIT \ 1458 SPM_MM \ 1459 SPMC_AT_EL3 \ 1460 SPMC_AT_EL3_SEL0_SP \ 1461 SPMD_SPM_AT_SEL2 \ 1462 TRANSFER_LIST \ 1463 TRUSTED_BOARD_BOOT \ 1464 CRYPTO_SUPPORT \ 1465 TRNG_SUPPORT \ 1466 ERRATA_ABI_SUPPORT \ 1467 ERRATA_NON_ARM_INTERCONNECT \ 1468 USE_COHERENT_MEM \ 1469 USE_DEBUGFS \ 1470 ARM_IO_IN_DTB \ 1471 SDEI_IN_FCONF \ 1472 SEC_INT_DESC_IN_FCONF \ 1473 USE_ROMLIB \ 1474 USE_TBBR_DEFS \ 1475 WARMBOOT_ENABLE_DCACHE_EARLY \ 1476 RESET_TO_BL2 \ 1477 BL2_RUNS_AT_EL3 \ 1478 BL2_IN_XIP_MEM \ 1479 BL2_INV_DCACHE \ 1480 USE_SPINLOCK_CAS \ 1481 ERRATA_SPECULATIVE_AT \ 1482 ERRATA_SME_POWER_DOWN \ 1483 RAS_TRAP_NS_ERR_REC_ACCESS \ 1484 COT_DESC_IN_DTB \ 1485 USE_SP804_TIMER \ 1486 ENABLE_FEAT_RNG \ 1487 ENABLE_FEAT_RNG_TRAP \ 1488 ENABLE_FEAT_SB \ 1489 ENABLE_FEAT_DIT \ 1490 NR_OF_FW_BANKS \ 1491 NR_OF_IMAGES_IN_FW_BANK \ 1492 PSA_FWU_SUPPORT \ 1493 PSA_FWU_METADATA_FW_STORE_DESC \ 1494 ENABLE_BRBE_FOR_NS \ 1495 ENABLE_TRBE_FOR_NS \ 1496 ENABLE_SYS_REG_TRACE_FOR_NS \ 1497 ENABLE_TRF_FOR_NS \ 1498 ENABLE_FEAT_HCX \ 1499 ENABLE_MPMM \ 1500 FEAT_PABANDON \ 1501 ENABLE_FEAT_FGT \ 1502 ENABLE_FEAT_FGT2 \ 1503 ENABLE_FEAT_FPMR \ 1504 ENABLE_FEAT_ECV \ 1505 ENABLE_FEAT_AMUv1p1 \ 1506 ENABLE_FEAT_SEL2 \ 1507 ENABLE_FEAT_VHE \ 1508 ENABLE_FEAT_CSV2_2 \ 1509 ENABLE_FEAT_CSV2_3 \ 1510 ENABLE_FEAT_LS64_ACCDATA \ 1511 ENABLE_FEAT_MEC \ 1512 ENABLE_FEAT_PAN \ 1513 ENABLE_FEAT_TCR2 \ 1514 ENABLE_FEAT_THE \ 1515 ENABLE_FEAT_S2PIE \ 1516 ENABLE_FEAT_S1PIE \ 1517 ENABLE_FEAT_S2POE \ 1518 ENABLE_FEAT_S1POE \ 1519 ENABLE_FEAT_SCTLR2 \ 1520 ENABLE_FEAT_D128 \ 1521 ENABLE_FEAT_GCS \ 1522 ENABLE_FEAT_MOPS \ 1523 ENABLE_FEAT_MTE2 \ 1524 FEATURE_DETECTION \ 1525 TWED_DELAY \ 1526 ENABLE_FEAT_TWED \ 1527 CONDITIONAL_CMO \ 1528 IMPDEF_SYSREG_TRAP \ 1529 SVE_VECTOR_LEN \ 1530 ENABLE_SPMD_LP \ 1531 PSA_CRYPTO \ 1532 ENABLE_CONSOLE_GETC \ 1533 INIT_UNUSED_NS_EL2 \ 1534 PLATFORM_REPORT_CTX_MEM_USE \ 1535 EARLY_CONSOLE \ 1536 PRESERVE_DSU_PMU_REGS \ 1537 HOB_LIST \ 1538))) 1539 1540ifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1) 1541ifeq (${DEBUG}, 0) 1542 $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only") 1543 override PLATFORM_REPORT_CTX_MEM_USE := 0 1544endif 1545endif 1546 1547ifeq (${SANITIZE_UB},trap) 1548 $(eval $(call add_define,MONITOR_TRAPS)) 1549endif #(SANITIZE_UB) 1550 1551# Define the EL3_PAYLOAD_BASE flag only if it is provided. 1552ifdef EL3_PAYLOAD_BASE 1553 $(eval $(call add_define,EL3_PAYLOAD_BASE)) 1554else 1555# Define the PRELOADED_BL33_BASE flag only if it is provided and 1556# EL3_PAYLOAD_BASE is not defined, as it has priority. 1557 ifdef PRELOADED_BL33_BASE 1558 $(eval $(call add_define,PRELOADED_BL33_BASE)) 1559 endif 1560endif #(EL3_PAYLOAD_BASE) 1561 1562# Define the DYN_DISABLE_AUTH flag only if set. 1563ifeq (${DYN_DISABLE_AUTH},1) 1564 $(eval $(call add_define,DYN_DISABLE_AUTH)) 1565endif 1566 1567ifeq ($($(ARCH)-ld-id),arm-link) 1568 $(eval $(call add_define,USE_ARM_LINK)) 1569endif 1570 1571# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined 1572ifeq (${SPD},spmd) 1573ifdef SP_LAYOUT_FILE 1574 -include $(BUILD_PLAT)/sp_gen.mk 1575 FIP_DEPS += sp 1576 CRT_DEPS += sp 1577 NEED_SP_PKG := yes 1578else 1579 ifeq (${SPMD_SPM_AT_SEL2},1) 1580 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE") 1581 endif 1582endif #(SP_LAYOUT_FILE) 1583endif #(SPD) 1584 1585################################################################################ 1586# Build targets 1587################################################################################ 1588 1589.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp tl fwu_fip certtool dtbs memmap doc enctool 1590 1591all: msg_start 1592 1593msg_start: 1594 $(s)echo "Building ${PLAT}" 1595 1596ifeq (${ERROR_DEPRECATED},0) 1597# Check if deprecated declarations and cpp warnings should be treated as error or not. 1598ifneq ($(filter %-clang,$($(ARCH)-cc-id)),) 1599 CPPFLAGS += -Wno-error=deprecated-declarations 1600else 1601 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp 1602endif 1603endif #(!ERROR_DEPRECATED) 1604 1605$(eval $(call MAKE_LIB,c)) 1606 1607# Expand build macros for the different images 1608ifeq (${NEED_BL1},yes) 1609BL1_SOURCES := $(sort ${BL1_SOURCES}) 1610$(eval $(call MAKE_BL,bl1)) 1611endif #(NEED_BL1) 1612 1613ifeq (${NEED_BL2},yes) 1614 1615ifeq (${RESET_TO_BL2}, 0) 1616FIP_BL2_ARGS := tb-fw 1617endif 1618 1619BL2_SOURCES := $(sort ${BL2_SOURCES}) 1620 1621$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\ 1622 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS}))) 1623 1624endif #(NEED_BL2) 1625 1626ifeq (${NEED_SCP_BL2},yes) 1627$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw)) 1628endif #(NEED_SCP_BL2) 1629 1630ifeq (${NEED_BL31},yes) 1631BL31_SOURCES += ${SPD_SOURCES} 1632# Sort BL31 source files to remove duplicates 1633BL31_SOURCES := $(sort ${BL31_SOURCES}) 1634ifneq (${DECRYPTION_SUPPORT},none) 1635$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\ 1636 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31)))) 1637else 1638$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\ 1639 $(eval $(call MAKE_BL,bl31,soc-fw))) 1640endif #(DECRYPTION_SUPPORT) 1641endif #(NEED_BL31) 1642 1643# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the 1644# build system will call TOOL_ADD_IMG to print a warning message and abort the 1645# process. Note that the dependency on BL32 applies to the FIP only. 1646ifeq (${NEED_BL32},yes) 1647# Sort BL32 source files to remove duplicates 1648BL32_SOURCES := $(sort ${BL32_SOURCES}) 1649BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1)) 1650 1651ifneq (${DECRYPTION_SUPPORT},none) 1652$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\ 1653 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32)))) 1654else 1655$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\ 1656 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw))) 1657endif #(DECRYPTION_SUPPORT) 1658endif #(NEED_BL32) 1659 1660# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP) 1661# needs to be built from RMM_SOURCES. 1662ifeq (${NEED_RMM},yes) 1663# Sort RMM source files to remove duplicates 1664RMM_SOURCES := $(sort ${RMM_SOURCES}) 1665BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1)) 1666 1667$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\ 1668 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw))) 1669endif #(NEED_RMM) 1670 1671# Add the BL33 image if required by the platform 1672ifeq (${NEED_BL33},yes) 1673$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw)) 1674endif #(NEED_BL33) 1675 1676ifeq (${NEED_BL2U},yes) 1677$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\ 1678 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_))) 1679endif #(NEED_BL2U) 1680 1681# Expand build macros for the different images 1682ifeq (${NEED_FDT},yes) 1683 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES))) 1684 1685 ifneq (${INITRD_SIZE}${INITRD_PATH},) 1686 ifndef INITRD_BASE 1687 $(error INITRD_BASE must be set when inserting initrd properties to the DTB.) 1688 endif 1689 1690 INITRD_SIZE ?= $(shell printf "0x%x\n" $$(stat -Lc %s $(INITRD_PATH))) 1691 initrd_end = $(shell printf "0x%x\n" $$(expr $$(($(INITRD_BASE) + $(INITRD_SIZE))))) 1692 1693 define $(HW_CONFIG)-after += 1694 $(s)echo " INITRD $(HW_CONFIG)" 1695 $(q)fdtput -t x $@ /chosen linux,initrd-start $(INITRD_BASE) 1696 $(q)fdtput -t x $@ /chosen linux,initrd-end $(initrd_end) 1697 endef 1698 endif 1699endif #(NEED_FDT) 1700 1701# Add Secure Partition packages 1702ifeq (${NEED_SP_PKG},yes) 1703$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | $$(@D)/ 1704 $(if $(host-poetry),$(q)poetry -q install --no-root) 1705 $(q)$(if $(host-poetry),poetry run )${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT} 1706sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS) 1707 $(s)echo 1708 $(s)echo "Built SP Images successfully" 1709 $(s)echo 1710endif #(NEED_SP_PKG) 1711 1712locate-checkpatch: 1713ifndef CHECKPATCH 1714 $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 1715else 1716ifeq (,$(wildcard ${CHECKPATCH})) 1717 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 1718endif 1719endif #(CHECKPATCH) 1720 1721clean: 1722 $(s)echo " CLEAN" 1723 $(q)rm -rf $(BUILD_PLAT) 1724 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 1725 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 1726 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean 1727 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 1728 1729realclean distclean: 1730 $(s)echo " REALCLEAN" 1731 $(q)rm -rf $(BUILD_BASE) 1732 $(q)rm -rf $(CURDIR)/cscope.* 1733 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 1734 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean 1735 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean 1736 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 1737 1738checkcodebase: locate-checkpatch 1739 $(s)echo " CHECKING STYLE" 1740 $(q)if test -d .git ; then \ 1741 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \ 1742 while read GIT_FILE ; \ 1743 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \ 1744 done ; \ 1745 else \ 1746 find . -type f -not -iwholename "*.git*" \ 1747 -not -iwholename "*build*" \ 1748 -not -iwholename "*libfdt*" \ 1749 -not -iwholename "*libc*" \ 1750 -not -iwholename "*docs*" \ 1751 -not -iwholename "*.rst" \ 1752 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \ 1753 fi 1754 1755checkpatch: locate-checkpatch 1756 $(s)echo " CHECKING STYLE" 1757 $(q)if test -n "${CHECKPATCH_OPTS}"; then \ 1758 echo " with ${CHECKPATCH_OPTS} option(s)"; \ 1759 fi 1760 $(q)COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \ 1761 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \ 1762 do \ 1763 printf "\n[*] Checking style of '$$commit'\n\n"; \ 1764 ( git log --format=email "$$commit~..$$commit" \ 1765 -- ${CHECK_PATHS} ; \ 1766 git diff --format=email "$$commit~..$$commit" \ 1767 -- ${CHECK_PATHS}; ) | \ 1768 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 1769 done 1770 1771certtool: ${CRTTOOL} 1772 1773${CRTTOOL}: FORCE 1774 $(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 1775 $(s)echo 1776 $(s)echo "Built $@ successfully" 1777 $(s)echo 1778 1779ifneq (${GENERATE_COT},0) 1780certificates: ${CRT_DEPS} ${CRTTOOL} 1781 $(q)${CRTTOOL} ${CRT_ARGS} 1782 $(s)echo 1783 $(s)echo "Built $@ successfully" 1784 $(s)echo "Certificates can be found in ${BUILD_PLAT}" 1785 $(s)echo 1786endif #(GENERATE_COT) 1787 1788${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL} 1789 $(eval ${CHECK_FIP_CMD}) 1790 $(q)${FIPTOOL} create ${FIP_ARGS} $@ 1791 $(q)${FIPTOOL} info $@ 1792 $(s)echo 1793 $(s)echo "Built $@ successfully" 1794 $(s)echo 1795 1796ifneq (${GENERATE_COT},0) 1797fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL} 1798 $(q)${CRTTOOL} ${FWU_CRT_ARGS} 1799 $(s)echo 1800 $(s)echo "Built $@ successfully" 1801 $(s)echo "FWU certificates can be found in ${BUILD_PLAT}" 1802 $(s)echo 1803endif #(GENERATE_COT) 1804 1805${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL} 1806 $(eval ${CHECK_FWU_FIP_CMD}) 1807 $(q)${FIPTOOL} create ${FWU_FIP_ARGS} $@ 1808 $(q)${FIPTOOL} info $@ 1809 $(s)echo 1810 $(s)echo "Built $@ successfully" 1811 $(s)echo 1812 1813fiptool: ${FIPTOOL} 1814fip: ${BUILD_PLAT}/${FIP_NAME} 1815fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME} 1816 1817${FIPTOOL}: FORCE 1818 $(q)${MAKE} PLAT=${PLAT} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${FIPTOOLPATH} all 1819 1820$(BUILD_PLAT)/romlib/romlib.bin $(BUILD_PLAT)/lib/libwrappers.a $&: $(BUILD_PLAT)/lib/libfdt.a $(BUILD_PLAT)/lib/libc.a $(CRYPTO_LIB) 1821 $(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 1822 1823memmap: all 1824 $(if $(host-poetry),$(q)poetry -q install --no-root) 1825 $(q)$(if $(host-poetry),poetry run )memory -sr ${BUILD_PLAT} 1826 1827tl: ${BUILD_PLAT}/tl.bin 1828${BUILD_PLAT}/tl.bin: ${HW_CONFIG} 1829 $(if $(host-poetry),$(q)poetry -q install --no-root) 1830 $(q)$(if $(host-poetry),poetry run )tlc create --fdt $< -s ${FW_HANDOFF_SIZE} $@ 1831 1832doc: 1833 $(s)echo " BUILD DOCUMENTATION" 1834 $(q)${MAKE} --no-print-directory -C ${DOCS_PATH} html 1835 1836enctool: ${ENCTOOL} 1837 1838${ENCTOOL}: FORCE 1839 $(q)${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} --no-print-directory -C ${ENCTOOLPATH} all 1840 $(s)echo 1841 $(s)echo "Built $@ successfully" 1842 $(s)echo 1843 1844cscope: 1845 $(s)echo " CSCOPE" 1846 $(q)find ${CURDIR} -name "*.[chsS]" > cscope.files 1847 $(q)cscope -b -q -k 1848 1849help: 1850 $(s)echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]" 1851 $(s)echo "" 1852 $(s)echo "PLAT is used to specify which platform you wish to build." 1853 $(s)echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}" 1854 $(s)echo "" 1855 $(s)echo "platform = ${PLATFORM_LIST}" 1856 $(s)echo "" 1857 $(s)echo "Please refer to the User Guide for a list of all supported options." 1858 $(s)echo "Note that the build system doesn't track dependencies for build " 1859 $(s)echo "options. Therefore, if any of the build options are changed " 1860 $(s)echo "from a previous build, a clean build must be performed." 1861 $(s)echo "" 1862 $(s)echo "Supported Targets:" 1863 $(s)echo " all Build all individual bootloader binaries" 1864 $(s)echo " bl1 Build the BL1 binary" 1865 $(s)echo " bl2 Build the BL2 binary" 1866 $(s)echo " bl2u Build the BL2U binary" 1867 $(s)echo " bl31 Build the BL31 binary" 1868 $(s)echo " bl32 Build the BL32 binary. If ARCH=aarch32, then " 1869 $(s)echo " this builds secure payload specified by AARCH32_SP" 1870 $(s)echo " certificates Build the certificates (requires 'GENERATE_COT=1')" 1871 $(s)echo " fip Build the Firmware Image Package (FIP)" 1872 $(s)echo " fwu_fip Build the FWU Firmware Image Package (FIP)" 1873 $(s)echo " checkcodebase Check the coding style of the entire source tree" 1874 $(s)echo " checkpatch Check the coding style on changes in the current" 1875 $(s)echo " branch against BASE_COMMIT (default origin/master)" 1876 $(s)echo " clean Clean the build for the selected platform" 1877 $(s)echo " cscope Generate cscope index" 1878 $(s)echo " distclean Remove all build artifacts for all platforms" 1879 $(s)echo " certtool Build the Certificate generation tool" 1880 $(s)echo " enctool Build the Firmware encryption tool" 1881 $(s)echo " fiptool Build the Firmware Image Package (FIP) creation tool" 1882 $(s)echo " sp Build the Secure Partition Packages" 1883 $(s)echo " sptool Build the Secure Partition Package creation tool" 1884 $(s)echo " dtbs Build the Device Tree Blobs (if required for the platform)" 1885 $(s)echo " memmap Print the memory map of the built binaries" 1886 $(s)echo " doc Build html based documentation using Sphinx tool" 1887 $(s)echo "" 1888 $(s)echo "Note: most build targets require PLAT to be set to a specific platform." 1889 $(s)echo "" 1890 $(s)echo "example: build all targets for the FVP platform:" 1891 $(s)echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all" 1892 1893.PHONY: FORCE 1894FORCE:; 1895