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