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