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