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