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