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