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