1# 2# Copyright (c) 2013-2026, 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 := 14 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-rules.mk 27include ${MAKE_HELPERS_DIRECTORY}common.mk 28 29MBEDTLS_DIR := contrib/mbed-tls 30 31################################################################################ 32# Default values for build configurations, and their dependencies 33################################################################################ 34 35include ${MAKE_HELPERS_DIRECTORY}defaults.mk 36# Include the CPU specific operations makefile, which provides default 37# values for all CPU errata workarounds and CPU specific optimisations. 38# This can be overridden by the platform. 39include lib/cpus/cpu-ops.mk 40 41PLAT := ${DEFAULT_PLAT} 42include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk 43 44# To be able to set platform specific defaults 45ifneq ($(PLAT_DEFAULTS_MAKEFILE_FULL),) 46include ${PLAT_DEFAULTS_MAKEFILE_FULL} 47endif 48 49################################################################################ 50# Configure the toolchains used to build TF-A and its tools 51################################################################################ 52 53include ${MAKE_HELPERS_DIRECTORY}toolchain.mk 54 55# Assertions enabled for DEBUG builds by default 56ENABLE_ASSERTIONS := ${DEBUG} 57ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION} 58 59################################################################################ 60# Checkpatch script options 61################################################################################ 62 63CHECKCODE_ARGS := --no-patch 64# Do not check the coding style on imported library files or documentation files 65INC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \ 66 include/drivers/arm, \ 67 $(wildcard include/drivers/*))) 68INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \ 69 lib/libfdt \ 70 include/lib/libc, \ 71 $(wildcard include/lib/*))) 72INC_DIRS_TO_CHECK := $(sort $(filter-out \ 73 include/lib \ 74 include/drivers, \ 75 $(wildcard include/*))) 76LIB_DIRS_TO_CHECK := $(sort $(filter-out \ 77 lib/compiler-rt \ 78 lib/libfdt% \ 79 lib/libc, \ 80 lib/zlib \ 81 $(wildcard lib/*))) 82ROOT_DIRS_TO_CHECK := $(sort $(filter-out \ 83 lib \ 84 include \ 85 docs \ 86 %.rst, \ 87 $(wildcard *))) 88CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \ 89 ${INC_DIRS_TO_CHECK} \ 90 ${INC_LIB_DIRS_TO_CHECK} \ 91 ${LIB_DIRS_TO_CHECK} \ 92 ${INC_DRV_DIRS_TO_CHECK} \ 93 ${INC_ARM_DIRS_TO_CHECK} 94 95################################################################################ 96# Process build options 97################################################################################ 98 99ifeq ($(verbose),) 100 CHECKCODE_ARGS += --no-summary --terse 101endif 102 103################################################################################ 104# Auxiliary tools (fiptool, cert_create, etc) 105################################################################################ 106 107# Variables for use with Certificate Generation Tool 108CRTTOOLPATH ?= tools/cert_create 109CRTTOOL ?= ${BUILD_PLAT}/${CRTTOOLPATH}/cert_create$(.exe) 110 111# Variables for use with Firmware Encryption Tool 112ENCTOOLPATH ?= tools/encrypt_fw 113ENCTOOL ?= ${BUILD_PLAT}/${ENCTOOLPATH}/encrypt_fw$(.exe) 114 115# Variables for use with Firmware Image Package 116FIPTOOLPATH ?= tools/fiptool 117FIPTOOL ?= ${BUILD_PLAT}/${FIPTOOLPATH}/fiptool$(.exe) 118 119# Variables for use with sptool 120SPTOOLPATH ?= tools/sptool 121SPTOOL ?= ${SPTOOLPATH}/sptool.py 122SP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py 123SP_DTS_LIST_FRAGMENT ?= ${BUILD_PLAT}/sp_list_fragment.dts 124 125# Variables for use with sptool 126TLCTOOL ?= $(host-poetry) run tlc 127 128# Variables for use with ROMLIB 129ROMLIBPATH ?= lib/romlib 130 131# Variable for use with Python 132PYTHON ?= python3 133 134# Variables for use with documentation build using Sphinx tool 135DOCS_PATH ?= docs 136 137# Process Debug flag 138ifneq (${DEBUG}, 0) 139 BUILD_TYPE := debug 140 # Use LOG_LEVEL_INFO by default for debug builds 141 LOG_LEVEL := 40 142else 143 BUILD_TYPE := release 144 # Use LOG_LEVEL_NOTICE by default for release builds 145 LOG_LEVEL := 20 146 # Enable link-time optimization (AKA "inter-procedural optimization") 147 ifeq (${ARCH},aarch64) 148 ifeq ($($(ARCH)-ld-id),$($(ARCH)-cc-id)) 149 ENABLE_LTO := 1 150 endif 151 endif 152endif #(Debug) 153 154# Default build string (git branch and commit) 155ifeq (${BUILD_STRING},) 156 BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null) 157endif 158VERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING} 159 160# Setting W is quite verbose and most warnings will be pre-existing issues 161# outside of the contributor's control. Don't fail the build on them so warnings 162# can be seen and hopefully addressed 163ifdef W 164 ifneq (${W},0) 165 E ?= 0 166 endif 167endif 168 169################################################################################ 170# Common sources and include directories 171################################################################################ 172include lib/compiler-rt/compiler-rt.mk 173 174# Allow overriding the timestamp, for example for reproducible builds, or to 175# synchronize timestamps across multiple projects. 176# This must be set to a C string (including quotes where applicable). 177BUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__ 178 179DEFINES += -DBUILD_MESSAGE_TIMESTAMP='$(BUILD_MESSAGE_TIMESTAMP)' 180DEFINES += -DBUILD_MESSAGE_VERSION_STRING='"$(VERSION_STRING)"' 181DEFINES += -DBUILD_MESSAGE_VERSION='"$(VERSION)"' 182 183BL_COMMON_SOURCES += common/bl_common.c \ 184 common/tf_log.c \ 185 common/${ARCH}/debug.S \ 186 drivers/console/multi_console.c \ 187 lib/${ARCH}/cache_helpers.S \ 188 lib/${ARCH}/misc_helpers.S \ 189 lib/extensions/pmuv3/${ARCH}/pmuv3.c \ 190 lib/locks/exclusive/${ARCH}/spinlock.c \ 191 plat/common/plat_bl_common.c \ 192 plat/common/plat_log_common.c \ 193 plat/common/${ARCH}/plat_common.c \ 194 plat/common/${ARCH}/platform_helpers.S \ 195 ${COMPILER_RT_SRCS} 196 197ifeq ($($(ARCH)-cc-id),arm-clang) 198 BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S 199endif 200 201ifeq (${SANITIZE_UB},on) 202 BL_COMMON_SOURCES += plat/common/ubsan.c 203endif 204 205INCLUDES += -Iinclude \ 206 -Iinclude/arch/${ARCH} \ 207 -Iinclude/lib/cpus/${ARCH} \ 208 -Iinclude/lib/el3_runtime/${ARCH} \ 209 ${PLAT_INCLUDES} \ 210 ${SPD_INCLUDES} 211 212include common/backtrace/backtrace.mk 213 214################################################################################ 215# Generic definitions 216################################################################################ 217 218ifeq (${BUILD_BASE},) 219 BUILD_BASE := ./build 220endif 221BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE} 222 223SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*)))) 224 225# Platforms providing their own TBB makefile may override this value 226INCLUDE_TBBR_MK := 1 227 228################################################################################ 229# Include SPD Makefile if one has been specified 230################################################################################ 231 232ifneq (${SPD},none) 233 ifeq (${SPD},spmd) 234 # SPMD is located in std_svc directory 235 SPD_DIR := std_svc 236 237 ifeq ($(SPMD_SPM_AT_SEL2),1) 238 CTX_INCLUDE_EL2_REGS := 1 239 endif 240 241 ifneq ($(SP_LAYOUT_FILE),) 242 BL2_ENABLE_SP_LOAD := 1 243 endif 244 else 245 # All other SPDs in spd directory 246 SPD_DIR := spd 247 endif #(SPD) 248 249 # We expect to locate an spd.mk under the specified SPD directory 250 SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk) 251 252 ifeq (${SPD_MAKE},) 253 $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located) 254 endif 255 $(info Including ${SPD_MAKE}) 256 include ${SPD_MAKE} 257 258 # If there's BL32 companion for the chosen SPD, we expect that the SPD's 259 # Makefile would set NEED_BL32 to "yes". In this case, the build system 260 # supports two mutually exclusive options: 261 # * BL32 is built from source: then BL32_SOURCES must contain the list 262 # of source files to build BL32 263 # * BL32 is a prebuilt binary: then BL32 must point to the image file 264 # that will be included in the FIP 265 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence 266 # over the sources. 267endif #(SPD=none) 268 269################################################################################ 270# Include the platform specific Makefile after the SPD Makefile (the platform 271# makefile may use all previous definitions in this file) 272################################################################################ 273include ${PLAT_MAKEFILE_FULL} 274 275################################################################################ 276# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from 277# platform. 278################################################################################ 279 280include ${MAKE_HELPERS_DIRECTORY}arch_features.mk 281################################################################################ 282# Process BRANCH_PROTECTION value and set 283# Pointer Authentication and Branch Target Identification flags 284################################################################################ 285ifeq (${BRANCH_PROTECTION},0) 286 # Default value turns off all types of branch protection 287 BP_OPTION := none 288else ifneq (${ARCH},aarch64) 289 $(error BRANCH_PROTECTION requires AArch64) 290else ifeq (${BRANCH_PROTECTION},1) 291 # Enables all types of branch protection features 292 BP_OPTION := standard 293 ENABLE_BTI := 1 294 ENABLE_PAUTH := 1 295else ifeq (${BRANCH_PROTECTION},2) 296 # Return address signing to its standard level 297 BP_OPTION := pac-ret 298 ENABLE_PAUTH := 1 299else ifeq (${BRANCH_PROTECTION},3) 300 # Extend the signing to include leaf functions 301 BP_OPTION := pac-ret+leaf 302 ENABLE_PAUTH := 1 303else ifeq (${BRANCH_PROTECTION},4) 304 # Turn on branch target identification mechanism 305 BP_OPTION := bti 306 ENABLE_BTI := 1 307else ifeq (${BRANCH_PROTECTION},5) 308 # Turn on branch target identification mechanism 309 BP_OPTION := standard 310 ENABLE_BTI := 2 311 ENABLE_PAUTH := 2 312else 313 $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION}) 314endif #(BRANCH_PROTECTION) 315 316ifneq ($(ENABLE_PAUTH),0) 317 CTX_INCLUDE_PAUTH_REGS := ${ENABLE_PAUTH} 318endif 319 320# Pointer Authentication sources 321ifneq (${ENABLE_PAUTH},0) 322# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the 323# Pauth support. As it's not secure, it must be reimplemented for real platforms 324 BL_COMMON_SOURCES += lib/extensions/pauth/pauth.c 325endif 326 327################################################################################ 328# RME dependent flags configuration, Enable optional features for RME. 329################################################################################ 330# FEAT_RME 331ifeq (${ENABLE_RME},1) 332 # RMM relies on SMCCC_ARCH_FEATURE_AVAILABILITY to discover EL3 enablement 333 ARCH_FEATURE_AVAILABILITY := 1 334 335 # RME requires el2 context to be saved for now. 336 CTX_INCLUDE_EL2_REGS := 1 337 CTX_INCLUDE_AARCH32_REGS := 0 338 CTX_INCLUDE_PAUTH_REGS := 1 339 340 ifneq ($(ENABLE_FEAT_MPAM), 0) 341 CTX_INCLUDE_MPAM_REGS := 1 342 endif 343 # bitlocks are only useful with atomics 344 ifneq ($(RME_GPT_BITLOCK_BLOCK), 0) 345 USE_SPINLOCK_CAS := 1 346 endif 347 348 # RME enables CSV2_2 extension by default. 349 ENABLE_FEAT_CSV2_2 = 1 350 # Enable FIRME interface for CCA. 351 FIRME_SUPPORT := 1 352endif #(FEAT_RME) 353 354################################################################################ 355# Include rmmd Makefile if RME is enabled 356################################################################################ 357ifneq (${ENABLE_RME},0) 358include services/std_svc/rmmd/rmmd.mk 359$(warning "RME is an experimental feature") 360endif 361 362################################################################################ 363# Make 128-Bit sysreg read/writes availabe when FEAT_D128 is enabled. 364################################################################################ 365ifneq (${ENABLE_FEAT_D128}, 0) 366 BL_COMMON_SOURCES += lib/extensions/sysreg128/sysreg128.S 367endif 368 369# This internal flag is common option which is set to 1 for scenarios 370# when the BL2 is running in EL3 level. This occurs in two scenarios - 371# 4 world system running BL2 at EL3 and two world system without BL1 running 372# BL2 in EL3 373 374ifneq ($(filter 1,${RESET_TO_BL2} ${ENABLE_RME}),) 375 BL2_RUNS_AT_EL3 := 1 376else 377 BL2_RUNS_AT_EL3 := 0 378endif 379 380# This internal flag is set to 1 when Firmware First handling of External aborts 381# is required by lowe ELs. Currently only NS requires this support. 382ifeq ($(HANDLE_EA_EL3_FIRST_NS),1) 383 FFH_SUPPORT := 1 384else 385 FFH_SUPPORT := 0 386endif 387 388ifneq ($(filter 1,${ERRATA_A53_1530924} ${ERRATA_A55_1530923} \ 389 ${ERRATA_A57_1319537} ${ERRATA_A65_1541130} ${ERRATA_A65AE_1638571} \ 390 ${ERRATA_A72_1319367} ${ERRATA_A76_1165522}),) 391ERRATA_SPECULATIVE_AT := 1 392else 393ERRATA_SPECULATIVE_AT := 0 394endif 395 396################################################################################ 397# Build `AARCH32_SP` as BL32 image for AArch32 398################################################################################ 399ifeq (${ARCH},aarch32) 400 NEED_BL32 := yes 401 402 ifneq (${AARCH32_SP},none) 403 # We expect to locate an sp.mk under the specified AARCH32_SP directory 404 AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk) 405 406 ifeq (${AARCH32_SP_MAKE},) 407 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located) 408 endif 409 $(info Including ${AARCH32_SP_MAKE}) 410 include ${AARCH32_SP_MAKE} 411 endif 412endif #(ARCH=aarch32) 413 414################################################################################ 415# Include libc if not overridden 416################################################################################ 417ifeq (${OVERRIDE_LIBC},0) 418include lib/libc/libc.mk 419endif 420 421ifneq (${USE_GIC_DRIVER},0) 422include drivers/arm/gic/gic.mk 423endif 424 425################################################################################ 426# Check incompatible options and dependencies 427################################################################################ 428include ${MAKE_HELPERS_DIRECTORY}constraints.mk 429 430# The cert_create tool cannot generate certificates individually, so we use the 431# target 'certificates' to create them all 432ifneq (${GENERATE_COT},0) 433 FIP_DEPS += certificates 434 FWU_FIP_DEPS += fwu_certificates 435 BL2_FIP_DEPS += bl2_certificates 436endif 437 438ifneq (${DECRYPTION_SUPPORT},none) 439 ENC_ARGS += -f ${FW_ENC_STATUS} 440 ENC_ARGS += -k ${ENC_KEY} 441 ENC_ARGS += -n ${ENC_NONCE} 442 FIP_DEPS += enctool 443 FWU_FIP_DEPS += enctool 444 BL2_FIP_DEPS += enctool 445endif #(DECRYPTION_SUPPORT) 446 447################################################################################ 448# Process platform overrideable behaviour 449################################################################################ 450 451ifdef BL1_SOURCES 452 NEED_BL1 := yes 453endif #(BL1_SOURCES) 454 455ifdef BL2_SOURCES 456 NEED_BL2 := yes 457 458 # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and 459 # Certificate generation tools. This flag can be overridden by the platform. 460 ifdef EL3_PAYLOAD_BASE 461 # If booting an EL3 payload there is no need for a BL33 image 462 # in the FIP file. 463 NEED_BL33 := no 464 else 465 ifdef PRELOADED_BL33_BASE 466 # If booting a BL33 preloaded image there is no need of 467 # another one in the FIP file. 468 NEED_BL33 := no 469 else 470 NEED_BL33 ?= yes 471 endif 472 endif 473endif #(BL2_SOURCES) 474 475ifdef BL2U_SOURCES 476 NEED_BL2U := yes 477endif #(BL2U_SOURCES) 478 479# If SCP_BL2 is given, we always want FIP to include it. 480ifdef SCP_BL2 481 NEED_SCP_BL2 := yes 482endif #(SCP_BL2) 483 484# For AArch32, BL31 is not currently supported. 485ifneq (${ARCH},aarch32) 486 ifdef BL31_SOURCES 487 # When booting an EL3 payload, there is no need to compile the BL31 488 # image nor put it in the FIP. 489 ifndef EL3_PAYLOAD_BASE 490 NEED_BL31 := yes 491 endif 492 endif 493endif #(ARCH=aarch64) 494 495# Process TBB related flags 496ifneq (${GENERATE_COT},0) 497 # Common cert_create options 498 ifneq (${CREATE_KEYS},0) 499 $(eval CRT_ARGS += -n) 500 $(eval FWU_CRT_ARGS += -n) 501 $(eval BL2_CRT_ARGS += -n) 502 ifneq (${SAVE_KEYS},0) 503 $(eval CRT_ARGS += -k) 504 $(eval FWU_CRT_ARGS += -k) 505 $(eval BL2_CRT_ARGS += -k) 506 endif 507 endif 508 # Include TBBR makefile (unless the platform indicates otherwise) 509 ifeq (${INCLUDE_TBBR_MK},1) 510 include make_helpers/tbbr/tbbr_tools.mk 511 endif 512endif #(GENERATE_COT) 513 514ifneq (${FIP_ALIGN},0) 515 FIP_ARGS += --align ${FIP_ALIGN} 516endif #(FIP_ALIGN) 517 518ifdef FDT_SOURCES 519 NEED_FDT := yes 520endif #(FDT_SOURCES) 521 522################################################################################ 523# Include libraries' Makefile that are used in all BL 524################################################################################ 525 526include lib/stack_protector/stack_protector.mk 527 528################################################################################ 529# Include BL specific makefiles 530################################################################################ 531 532ifeq (${NEED_BL1},yes) 533include bl1/bl1.mk 534endif 535 536ifeq (${NEED_BL2},yes) 537include bl2/bl2.mk 538endif 539 540ifeq (${NEED_BL2U},yes) 541include bl2u/bl2u.mk 542endif 543 544ifeq (${NEED_BL31},yes) 545include bl31/bl31.mk 546endif 547 548################################################################################ 549# Build options checks 550################################################################################ 551 552# Boolean_Flags 553$(eval $(call assert_booleans,\ 554 $(sort \ 555 ALLOW_RO_XLAT_TABLES \ 556 BL2_ENABLE_SP_LOAD \ 557 COLD_BOOT_SINGLE_CPU \ 558 $(CPU_FLAG_LIST) \ 559 CREATE_KEYS \ 560 CTX_INCLUDE_AARCH32_REGS \ 561 CTX_INCLUDE_FPREGS \ 562 CTX_INCLUDE_SVE_REGS \ 563 CTX_INCLUDE_EL2_REGS \ 564 CTX_INCLUDE_MPAM_REGS \ 565 DEBUG \ 566 DYN_DISABLE_AUTH \ 567 EL3_EXCEPTION_HANDLING \ 568 ENABLE_AMU_AUXILIARY_COUNTERS \ 569 AMU_RESTRICT_COUNTERS \ 570 ENABLE_ASSERTIONS \ 571 ENABLE_PIE \ 572 ENABLE_PMF \ 573 ENABLE_PSCI_STAT \ 574 ENABLE_RUNTIME_INSTRUMENTATION \ 575 ENABLE_SME_FOR_SWD \ 576 ENABLE_SVE_FOR_SWD \ 577 ENABLE_FEAT_GCIE \ 578 FFH_SUPPORT \ 579 ERROR_DEPRECATED \ 580 FAULT_INJECTION_SUPPORT \ 581 GENERATE_COT \ 582 GICV2_G0_FOR_EL3 \ 583 HANDLE_EA_EL3_FIRST_NS \ 584 HARDEN_SLS \ 585 HW_ASSISTED_COHERENCY \ 586 MEASURED_BOOT \ 587 DISCRETE_TPM \ 588 DICE_PROTECTION_ENVIRONMENT \ 589 RMMD_ENABLE_EL3_TOKEN_SIGN \ 590 RMMD_ENABLE_IDE_KEY_PROG \ 591 RMM_V1_COMPAT \ 592 DRTM_SUPPORT \ 593 NS_TIMER_SWITCH \ 594 OVERRIDE_LIBC \ 595 PL011_GENERIC_UART \ 596 PLAT_EXTRA_LD_SCRIPT \ 597 PROGRAMMABLE_RESET_ADDRESS \ 598 PSCI_EXTENDED_STATE_ID \ 599 PSCI_OS_INIT_MODE \ 600 ARCH_FEATURE_AVAILABILITY \ 601 RESET_TO_BL31 \ 602 SAVE_KEYS \ 603 SEPARATE_CODE_AND_RODATA \ 604 SEPARATE_BL2_NOLOAD_REGION \ 605 SEPARATE_NOBITS_REGION \ 606 SEPARATE_RWDATA_REGION \ 607 SEPARATE_SIMD_SECTION \ 608 SPIN_ON_BL1_EXIT \ 609 SPM_MM \ 610 SPMC_AT_EL3 \ 611 SPMC_AT_EL3_SEL0_SP \ 612 SPMD_SPM_AT_SEL2 \ 613 ENABLE_SPMD_LP \ 614 TRANSFER_LIST \ 615 TRUSTED_BOARD_BOOT \ 616 USE_COHERENT_MEM \ 617 USE_DEBUGFS \ 618 USE_KERNEL_DT_CONVENTION \ 619 ARM_IO_IN_DTB \ 620 SDEI_IN_FCONF \ 621 SEC_INT_DESC_IN_FCONF \ 622 USE_ROMLIB \ 623 USE_TBBR_DEFS \ 624 WARMBOOT_ENABLE_DCACHE_EARLY \ 625 RESET_TO_BL2 \ 626 BL2_IN_XIP_MEM \ 627 BL2_INV_DCACHE \ 628 ENCRYPT_BL31 \ 629 ENCRYPT_BL32 \ 630 ERRATA_SPECULATIVE_AT \ 631 RAS_TRAP_NS_ERR_REC_ACCESS \ 632 COT_DESC_IN_DTB \ 633 USE_SP804_TIMER \ 634 PSA_FWU_SUPPORT \ 635 PSA_FWU_METADATA_FW_STORE_DESC \ 636 ENABLE_MPMM \ 637 FEATURE_DETECTION \ 638 TRNG_SUPPORT \ 639 ENABLE_ERRATA_ALL \ 640 ERRATA_ABI_SUPPORT \ 641 ERRATA_NON_ARM_INTERCONNECT \ 642 CONDITIONAL_CMO \ 643 PSA_CRYPTO \ 644 ENABLE_CONSOLE_GETC \ 645 INIT_UNUSED_NS_EL2 \ 646 PLATFORM_REPORT_CTX_MEM_USE \ 647 EARLY_CONSOLE \ 648 PRESERVE_DSU_PMU_REGS \ 649 HOB_LIST \ 650 LFA_SUPPORT \ 651 SUPPORT_SP_LIVE_ACTIVATION \ 652 TEST_IO_SHORT_READ_FI \ 653))) 654 655# Numeric_Flags 656$(eval $(call assert_numerics,\ 657 $(sort \ 658 ARM_ARCH_MAJOR \ 659 ARM_ARCH_MINOR \ 660 BRANCH_PROTECTION \ 661 CTX_INCLUDE_PAUTH_REGS \ 662 CTX_INCLUDE_NEVE_REGS \ 663 DISABLE_MTPMU \ 664 ENABLE_BRBE_FOR_NS \ 665 ENABLE_TRBE_FOR_NS \ 666 ENABLE_BTI \ 667 ENABLE_PAUTH \ 668 ENABLE_FEAT_PAUTH_LR \ 669 ENABLE_FEAT_AIE \ 670 ENABLE_FEAT_AMU \ 671 ENABLE_FEAT_AMUv1p1 \ 672 ENABLE_FEAT_CLRBHB \ 673 ENABLE_FEAT_CPA2 \ 674 ENABLE_FEAT_CSV2_2 \ 675 ENABLE_FEAT_CSV2_3 \ 676 ENABLE_FEAT_CRYPTO \ 677 ENABLE_FEAT_CRYPTO_SHA3 \ 678 ENABLE_FEAT_DEBUGV8P9 \ 679 ENABLE_FEAT_DIT \ 680 ENABLE_FEAT_ECV \ 681 ENABLE_FEAT_EBEP \ 682 ENABLE_FEAT_FGT \ 683 ENABLE_FEAT_FGT2 \ 684 ENABLE_FEAT_HDBSS \ 685 ENABLE_FEAT_HACDBS \ 686 ENABLE_FEAT_STEP2 \ 687 ENABLE_FEAT_UINJ \ 688 ENABLE_FEAT_FGWTE3 \ 689 ENABLE_FEAT_FPMR \ 690 ENABLE_FEAT_HCX \ 691 ENABLE_FEAT_IDTE3 \ 692 ENABLE_FEAT_LS64_ACCDATA \ 693 ENABLE_FEAT_MEC \ 694 ENABLE_FEAT_MOPS \ 695 ENABLE_FEAT_MORELLO \ 696 ENABLE_FEAT_MTE2 \ 697 ENABLE_FEAT_PAN \ 698 ENABLE_FEAT_PFAR \ 699 ENABLE_FEAT_RNG \ 700 ENABLE_FEAT_RNG_TRAP \ 701 ENABLE_FEAT_SEL2 \ 702 ENABLE_FEAT_TCR2 \ 703 ENABLE_FEAT_THE \ 704 ENABLE_FEAT_SB \ 705 ENABLE_FEAT_S2PIE \ 706 ENABLE_FEAT_S1PIE \ 707 ENABLE_FEAT_S2POE \ 708 ENABLE_FEAT_S1POE \ 709 ENABLE_FEAT_SCTLR2 \ 710 ENABLE_FEAT_D128 \ 711 ENABLE_FEAT_RME_GDI \ 712 ENABLE_FEAT_GCS \ 713 ENABLE_FEAT_VHE \ 714 ENABLE_FEAT_MPAM \ 715 ENABLE_FEAT_MPAM_PE_BW_CTRL \ 716 ENABLE_FEAT_RAS \ 717 ENABLE_RME \ 718 ENABLE_SPE_FOR_NS \ 719 ENABLE_SYS_REG_TRACE_FOR_NS \ 720 ENABLE_SME_FOR_NS \ 721 ENABLE_SME2_FOR_NS \ 722 ENABLE_SVE_FOR_NS \ 723 ENABLE_TRF_FOR_NS \ 724 FW_ENC_STATUS \ 725 NR_OF_FW_BANKS \ 726 NR_OF_IMAGES_IN_FW_BANK \ 727 SPMC_AT_EL3_PARTITION_MAX_UUIDS \ 728 TWED_DELAY \ 729 ENABLE_FEAT_TWED \ 730 SVE_VECTOR_LEN \ 731 USE_SPINLOCK_CAS \ 732 IMPDEF_SYSREG_TRAP \ 733 W \ 734 TEST_IO_SHORT_READ_FI_IMAGE_ID \ 735))) 736 737ifdef KEY_SIZE 738 $(eval $(call assert_numeric,KEY_SIZE)) 739endif 740 741ifeq ($(filter $(SANITIZE_UB), on off trap),) 742 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap") 743endif 744 745################################################################################ 746# Add definitions to the cpp preprocessor based on the current build options. 747# This is done after including the platform specific makefile to allow the 748# platform to overwrite the default options 749################################################################################ 750 751$(eval $(call add_defines,\ 752 $(sort \ 753 ALLOW_RO_XLAT_TABLES \ 754 ARM_ARCH_MAJOR \ 755 ARM_ARCH_MINOR \ 756 BL2_ENABLE_SP_LOAD \ 757 COLD_BOOT_SINGLE_CPU \ 758 $(CPU_FLAG_LIST) \ 759 CTX_INCLUDE_AARCH32_REGS \ 760 CTX_INCLUDE_FPREGS \ 761 CTX_INCLUDE_SVE_REGS \ 762 CTX_INCLUDE_PAUTH_REGS \ 763 CTX_INCLUDE_MPAM_REGS \ 764 EL3_EXCEPTION_HANDLING \ 765 CTX_INCLUDE_EL2_REGS \ 766 CTX_INCLUDE_NEVE_REGS \ 767 DEBUG \ 768 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \ 769 DISABLE_MTPMU \ 770 ENABLE_FEAT_AMU \ 771 ENABLE_AMU_AUXILIARY_COUNTERS \ 772 AMU_RESTRICT_COUNTERS \ 773 ENABLE_ASSERTIONS \ 774 ENABLE_BTI \ 775 ENABLE_FEAT_CRYPTO \ 776 ENABLE_FEAT_CRYPTO_SHA3 \ 777 ENABLE_FEAT_DEBUGV8P9 \ 778 ENABLE_FEAT_IDTE3 \ 779 ENABLE_FEAT_MPAM \ 780 ENABLE_FEAT_MPAM_PE_BW_CTRL \ 781 ENABLE_PAUTH \ 782 ENABLE_FEAT_PAUTH_LR \ 783 ENABLE_PIE \ 784 ENABLE_PMF \ 785 ENABLE_PSCI_STAT \ 786 ENABLE_RME \ 787 RMM_V1_COMPAT \ 788 RMMD_ENABLE_EL3_TOKEN_SIGN \ 789 RMMD_ENABLE_IDE_KEY_PROG \ 790 ENABLE_RUNTIME_INSTRUMENTATION \ 791 ENABLE_SME_FOR_NS \ 792 ENABLE_SME2_FOR_NS \ 793 ENABLE_SME_FOR_SWD \ 794 ENABLE_SPE_FOR_NS \ 795 ENABLE_SVE_FOR_NS \ 796 ENABLE_SVE_FOR_SWD \ 797 ENABLE_FEAT_RAS \ 798 FFH_SUPPORT \ 799 ENCRYPT_BL31 \ 800 ENCRYPT_BL32 \ 801 ERROR_DEPRECATED \ 802 FAULT_INJECTION_SUPPORT \ 803 GICV2_G0_FOR_EL3 \ 804 HANDLE_EA_EL3_FIRST_NS \ 805 HW_ASSISTED_COHERENCY \ 806 LOG_LEVEL \ 807 MEASURED_BOOT \ 808 DISCRETE_TPM \ 809 DICE_PROTECTION_ENVIRONMENT \ 810 DRTM_SUPPORT \ 811 NS_TIMER_SWITCH \ 812 PLATFORM_NODE_COUNT \ 813 PL011_GENERIC_UART \ 814 PLAT_EXTRA_LD_SCRIPT \ 815 PLAT_${PLAT} \ 816 PROGRAMMABLE_RESET_ADDRESS \ 817 PSCI_EXTENDED_STATE_ID \ 818 PSCI_OS_INIT_MODE \ 819 ARCH_FEATURE_AVAILABILITY \ 820 RESET_TO_BL31 \ 821 RME_GPT_BITLOCK_BLOCK \ 822 RME_GPT_MAX_BLOCK \ 823 SEPARATE_CODE_AND_RODATA \ 824 SEPARATE_BL2_FIP \ 825 SEPARATE_BL2_NOLOAD_REGION \ 826 SEPARATE_NOBITS_REGION \ 827 SEPARATE_RWDATA_REGION \ 828 SEPARATE_SIMD_SECTION \ 829 RECLAIM_INIT_CODE \ 830 SPD_${SPD} \ 831 SPIN_ON_BL1_EXIT \ 832 SPM_MM \ 833 SPMC_AT_EL3 \ 834 SPMC_AT_EL3_PARTITION_MAX_UUIDS \ 835 SPMC_AT_EL3_SEL0_SP \ 836 SPMD_SPM_AT_SEL2 \ 837 TRANSFER_LIST \ 838 TRUSTED_BOARD_BOOT \ 839 TRNG_SUPPORT \ 840 ERRATA_ABI_SUPPORT \ 841 ERRATA_NON_ARM_INTERCONNECT \ 842 USE_COHERENT_MEM \ 843 USE_DEBUGFS \ 844 ARM_IO_IN_DTB \ 845 SDEI_IN_FCONF \ 846 SEC_INT_DESC_IN_FCONF \ 847 USE_ROMLIB \ 848 USE_TBBR_DEFS \ 849 USE_KERNEL_DT_CONVENTION \ 850 WARMBOOT_ENABLE_DCACHE_EARLY \ 851 RESET_TO_BL2 \ 852 BL2_RUNS_AT_EL3 \ 853 BL2_IN_XIP_MEM \ 854 BL2_INV_DCACHE \ 855 USE_SPINLOCK_CAS \ 856 ERRATA_SPECULATIVE_AT \ 857 RAS_TRAP_NS_ERR_REC_ACCESS \ 858 COT_DESC_IN_DTB \ 859 USE_SP804_TIMER \ 860 ENABLE_FEAT_RNG \ 861 ENABLE_FEAT_RNG_TRAP \ 862 ENABLE_FEAT_SB \ 863 ENABLE_FEAT_DIT \ 864 NR_OF_FW_BANKS \ 865 NR_OF_IMAGES_IN_FW_BANK \ 866 PSA_FWU_SUPPORT \ 867 PSA_FWU_METADATA_FW_STORE_DESC \ 868 ENABLE_BRBE_FOR_NS \ 869 ENABLE_TRBE_FOR_NS \ 870 ENABLE_SYS_REG_TRACE_FOR_NS \ 871 ENABLE_TRF_FOR_NS \ 872 ENABLE_FEAT_AIE \ 873 ENABLE_FEAT_HCX \ 874 ENABLE_MPMM \ 875 ENABLE_FEAT_FGT \ 876 ENABLE_FEAT_FGT2 \ 877 ENABLE_FEAT_UINJ \ 878 ENABLE_FEAT_FGWTE3 \ 879 ENABLE_FEAT_FPMR \ 880 ENABLE_FEAT_ECV \ 881 ENABLE_FEAT_EBEP \ 882 ENABLE_FEAT_AMUv1p1 \ 883 ENABLE_FEAT_SEL2 \ 884 ENABLE_FEAT_VHE \ 885 ENABLE_FEAT_CLRBHB \ 886 ENABLE_FEAT_CPA2 \ 887 ENABLE_FEAT_CSV2_2 \ 888 ENABLE_FEAT_CSV2_3 \ 889 ENABLE_FEAT_LS64_ACCDATA \ 890 ENABLE_FEAT_MEC \ 891 ENABLE_FEAT_MORELLO \ 892 ENABLE_FEAT_PAN \ 893 ENABLE_FEAT_TCR2 \ 894 ENABLE_FEAT_THE \ 895 ENABLE_FEAT_S2PIE \ 896 ENABLE_FEAT_S1PIE \ 897 ENABLE_FEAT_S2POE \ 898 ENABLE_FEAT_S1POE \ 899 ENABLE_FEAT_SCTLR2 \ 900 ENABLE_FEAT_STEP2 \ 901 ENABLE_FEAT_D128 \ 902 ENABLE_FEAT_RME_GDI \ 903 ENABLE_FEAT_GCS \ 904 ENABLE_FEAT_HDBSS \ 905 ENABLE_FEAT_HACDBS \ 906 ENABLE_FEAT_MOPS \ 907 ENABLE_FEAT_GCIE \ 908 ENABLE_FEAT_MTE2 \ 909 ENABLE_FEAT_PFAR \ 910 FEATURE_DETECTION \ 911 TWED_DELAY \ 912 ENABLE_FEAT_TWED \ 913 CONDITIONAL_CMO \ 914 IMPDEF_SYSREG_TRAP \ 915 SVE_VECTOR_LEN \ 916 ENABLE_SPMD_LP \ 917 PSA_CRYPTO \ 918 ENABLE_CONSOLE_GETC \ 919 INIT_UNUSED_NS_EL2 \ 920 PLATFORM_REPORT_CTX_MEM_USE \ 921 EARLY_CONSOLE \ 922 PRESERVE_DSU_PMU_REGS \ 923 HOB_LIST \ 924 HW_CONFIG_BASE \ 925 LFA_SUPPORT \ 926 SUPPORT_SP_LIVE_ACTIVATION \ 927 TEST_IO_SHORT_READ_FI \ 928 TEST_IO_SHORT_READ_FI_IMAGE_ID \ 929))) 930 931ifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1) 932ifeq (${DEBUG}, 0) 933 $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only") 934 override PLATFORM_REPORT_CTX_MEM_USE := 0 935endif 936endif 937 938ifeq (${SANITIZE_UB},trap) 939 $(eval $(call add_define,MONITOR_TRAPS)) 940endif #(SANITIZE_UB) 941 942# Define the EL3_PAYLOAD_BASE flag only if it is provided. 943ifdef EL3_PAYLOAD_BASE 944 $(eval $(call add_define,EL3_PAYLOAD_BASE)) 945else 946# Define the PRELOADED_BL33_BASE flag only if it is provided and 947# EL3_PAYLOAD_BASE is not defined, as it has priority. 948 ifdef PRELOADED_BL33_BASE 949 $(eval $(call add_define,PRELOADED_BL33_BASE)) 950 endif 951endif #(EL3_PAYLOAD_BASE) 952 953# Define the DYN_DISABLE_AUTH flag only if set. 954ifeq (${DYN_DISABLE_AUTH},1) 955 $(eval $(call add_define,DYN_DISABLE_AUTH)) 956endif 957 958ifeq ($($(ARCH)-ld-id),arm-link) 959 $(eval $(call add_define,USE_ARM_LINK)) 960endif 961 962# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined 963ifeq (${SPD},spmd) 964ifdef SP_LAYOUT_FILE 965 -include $(BUILD_PLAT)/sp_gen.mk 966 FIP_DEPS += sp 967 CRT_DEPS += sp 968 NEED_SP_PKG := yes 969else 970 ifeq (${SPMD_SPM_AT_SEL2},1) 971 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE") 972 endif 973endif #(SP_LAYOUT_FILE) 974endif #(SPD) 975 976################################################################################ 977# Configure the flags for the specified compiler and linker 978################################################################################ 979include ${MAKE_HELPERS_DIRECTORY}cflags.mk 980 981################################################################################ 982# Build targets 983################################################################################ 984 985.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp tl fwu_fip certtool dtbs memmap doc enctool 986 987all: msg_start 988 989msg_start: 990 $(s)echo "Building ${PLAT}" 991 992$(eval $(call MAKE_LIB,c)) 993 994# Expand build macros for the different images 995ifeq (${NEED_BL1},yes) 996BL1_SOURCES := $(sort ${BL1_SOURCES}) 997$(eval $(call MAKE_BL,bl1)) 998endif #(NEED_BL1) 999 1000ifeq (${NEED_BL2},yes) 1001 1002ifeq (${RESET_TO_BL2}, 0) 1003FIP_BL2_ARGS := tb-fw 1004endif 1005 1006BL2_SOURCES := $(sort ${BL2_SOURCES}) 1007 1008ifeq (${SEPARATE_BL2_FIP},1) 1009$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS},BL2_)), \ 1010 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS},BL2_))) 1011else 1012$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})), \ 1013 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS}))) 1014endif #(SEPARATE_BL2_FIP) 1015 1016endif #(NEED_BL2) 1017 1018ifeq (${NEED_SCP_BL2},yes) 1019$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw)) 1020endif #(NEED_SCP_BL2) 1021 1022ifeq (${NEED_BL31},yes) 1023BL31_SOURCES += ${SPD_SOURCES} 1024# Sort BL31 source files to remove duplicates 1025BL31_SOURCES := $(sort ${BL31_SOURCES}) 1026ifneq (${DECRYPTION_SUPPORT},none) 1027$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\ 1028 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31)))) 1029else 1030$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\ 1031 $(eval $(call MAKE_BL,bl31,soc-fw))) 1032endif #(DECRYPTION_SUPPORT) 1033endif #(NEED_BL31) 1034 1035# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the 1036# build system will call TOOL_ADD_IMG to print a warning message and abort the 1037# process. Note that the dependency on BL32 applies to the FIP only. 1038ifeq (${NEED_BL32},yes) 1039# Sort BL32 source files to remove duplicates 1040BL32_SOURCES := $(sort ${BL32_SOURCES}) 1041BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1)) 1042 1043ifneq (${DECRYPTION_SUPPORT},none) 1044$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\ 1045 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32)))) 1046else 1047$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\ 1048 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw))) 1049endif #(DECRYPTION_SUPPORT) 1050endif #(NEED_BL32) 1051 1052# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP) 1053# needs to be built from RMM_SOURCES. 1054ifeq (${NEED_RMM},yes) 1055# Sort RMM source files to remove duplicates 1056RMM_SOURCES := $(sort ${RMM_SOURCES}) 1057BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1)) 1058 1059$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\ 1060 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw))) 1061endif #(NEED_RMM) 1062 1063# Add the BL33 image if required by the platform 1064ifeq (${NEED_BL33},yes) 1065$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw)) 1066endif #(NEED_BL33) 1067 1068ifeq (${NEED_BL2U},yes) 1069$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\ 1070 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_))) 1071endif #(NEED_BL2U) 1072 1073# Expand build macros for the different images 1074ifeq (${NEED_FDT},yes) 1075 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES))) 1076 1077 ifneq (${INITRD_SIZE}${INITRD_PATH},) 1078 ifndef INITRD_BASE 1079 $(error INITRD_BASE must be set when inserting initrd properties to the DTB.) 1080 endif 1081 1082 INITRD_SIZE ?= $(shell printf "0x%x\n" $$(stat -Lc %s $(INITRD_PATH))) 1083 initrd_end = $(shell printf "0x%x\n" $$(expr $$(($(INITRD_BASE) + $(INITRD_SIZE))))) 1084 1085 define $(HW_CONFIG)-after += 1086 $(s)echo " INITRD $(HW_CONFIG)" 1087 $(q)fdtput -t x $@ /chosen linux,initrd-start $(INITRD_BASE) 1088 $(q)fdtput -t x $@ /chosen linux,initrd-end $(initrd_end) 1089 endef 1090 endif 1091endif #(NEED_FDT) 1092 1093# Add Secure Partition packages 1094ifeq (${NEED_SP_PKG},yes) 1095$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | $$(@D)/ 1096 $(if $(host-poetry),$(q)$(host-poetry) -q install --no-root) 1097 $(q)$(if $(host-poetry),$(host-poetry) run )${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT} 1098sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS) 1099 $(s)echo 1100 $(s)echo "Built SP Images successfully" 1101 $(s)echo 1102endif #(NEED_SP_PKG) 1103 1104locate-checkpatch: 1105ifndef CHECKPATCH 1106 $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 1107else 1108ifeq (,$(wildcard ${CHECKPATCH})) 1109 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 1110endif 1111endif #(CHECKPATCH) 1112 1113clean: 1114 $(s)echo " CLEAN" 1115 $(q)rm -rf $(BUILD_PLAT) 1116 $(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${FIPTOOLPATH} clean 1117 $(q)rm -rf ${FIPTOOLPATH}/fiptool 1118 $(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 1119 $(q)rm -rf ${CRTTOOLPATH}/cert_create 1120 $(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${ENCTOOLPATH} clean 1121 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 1122 1123realclean distclean: 1124 $(s)echo " REALCLEAN" 1125 $(q)rm -rf $(BUILD_BASE) 1126 $(q)rm -rf $(CURDIR)/cscope.* 1127 $(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${FIPTOOLPATH} clean 1128 $(q)rm -rf ${FIPTOOLPATH}/fiptool 1129 $(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 1130 $(q)rm -rf ${CRTTOOLPATH}/cert_create 1131 $(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${ENCTOOLPATH} clean 1132 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 1133 1134checkcodebase: locate-checkpatch 1135 $(s)echo " CHECKING STYLE" 1136 $(q)if test -d .git ; then \ 1137 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \ 1138 while read GIT_FILE ; \ 1139 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \ 1140 done ; \ 1141 else \ 1142 find . -type f -not -iwholename "*.git*" \ 1143 -not -iwholename "*build*" \ 1144 -not -iwholename "*libfdt*" \ 1145 -not -iwholename "*libc*" \ 1146 -not -iwholename "*docs*" \ 1147 -not -iwholename "*.rst" \ 1148 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \ 1149 fi 1150 1151checkpatch: locate-checkpatch 1152 $(s)echo " CHECKING STYLE" 1153 $(q)if test -n "${CHECKPATCH_OPTS}"; then \ 1154 echo " with ${CHECKPATCH_OPTS} option(s)"; \ 1155 fi 1156 $(q)COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \ 1157 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \ 1158 do \ 1159 printf "\n[*] Checking style of '$$commit'\n\n"; \ 1160 ( git log --format=email "$$commit~..$$commit" \ 1161 -- ${CHECK_PATHS} ; \ 1162 git diff --format=email "$$commit~..$$commit" \ 1163 -- ${CHECK_PATHS}; ) | \ 1164 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 1165 done 1166 1167certtool: ${CRTTOOL} 1168 1169${CRTTOOL}: FORCE | $$(@D)/ 1170 $(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=$(abspath ${BUILD_PLAT}) USE_TBBR_DEFS=${USE_TBBR_DEFS} COT=${COT} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${CRTTOOLPATH} all 1171 $(q)ln -sf ${CRTTOOL} ${CRTTOOLPATH}/cert_create 1172 $(s)echo 1173 $(s)echo "Built $@ successfully" 1174 $(s)echo 1175 1176ifneq (${GENERATE_COT},0) 1177certificates: ${CRT_DEPS} ${CRTTOOL} ${DTBS} 1178 $(q)${CRTTOOL} ${CRT_ARGS} 1179 $(s)echo 1180 $(s)echo "Built $@ successfully" 1181 $(s)echo "Certificates can be found in ${BUILD_PLAT}" 1182 $(s)echo 1183endif #(GENERATE_COT) 1184 1185ifeq (${SEPARATE_BL2_FIP},1) 1186${BUILD_PLAT}/${BL2_FIP_NAME}: ${BL2_FIP_DEPS} ${FIPTOOL} | $$(@D)/ 1187 $(eval ${CHECK_BL2_FIP_CMD}) 1188 $(q)${FIPTOOL} create ${BL2_FIP_ARGS} $@ 1189 $(q)${FIPTOOL} info $@ 1190 $(s)echo 1191 $(s)echo "Built $@ successfully" 1192 $(s)echo 1193endif #(SEPARATE_BL2_FIP) 1194 1195${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL} | $$(@D)/ 1196 $(eval ${CHECK_FIP_CMD}) 1197 $(q)${FIPTOOL} create ${FIP_ARGS} $@ 1198 $(q)${FIPTOOL} info $@ 1199 $(s)echo 1200 $(s)echo "Built $@ successfully" 1201 $(s)echo 1202 1203ifneq (${GENERATE_COT},0) 1204fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL} 1205 $(q)${CRTTOOL} ${FWU_CRT_ARGS} 1206 $(s)echo 1207 $(s)echo "Built $@ successfully" 1208 $(s)echo "FWU certificates can be found in ${BUILD_PLAT}" 1209 $(s)echo 1210endif #(GENERATE_COT) 1211 1212ifneq (${GENERATE_COT},0) 1213bl2_certificates: ${BUILD_PLAT}/${FIP_NAME} ${BL2_CRT_DEPS} ${CRTTOOL} | ${BUILD_PLAT}/ 1214 $(q)${CRTTOOL} ${BL2_CRT_ARGS} 1215 $(s)echo 1216 $(s)echo "Built $@ successfully" 1217 $(s)echo "BL2 certificates can be found in ${BUILD_PLAT}" 1218 $(s)echo 1219endif #(GENERATE_COT) 1220 1221${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL} | $$(@D)/ 1222 $(eval ${CHECK_FWU_FIP_CMD}) 1223 $(q)${FIPTOOL} create ${FWU_FIP_ARGS} $@ 1224 $(q)${FIPTOOL} info $@ 1225 $(s)echo 1226 $(s)echo "Built $@ successfully" 1227 $(s)echo 1228 1229fiptool: ${FIPTOOL} 1230ifeq (${SEPARATE_BL2_FIP},1) 1231bl2_fip: ${BUILD_PLAT}/${BL2_FIP_NAME} 1232fip: bl2_fip 1233else 1234fip: ${BUILD_PLAT}/${FIP_NAME} 1235endif #(SEPARATE_BL2_FIP) 1236fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME} 1237 1238# symlink for compatibility before tools were in the build directory 1239${FIPTOOL}: FORCE | $$(@D)/ 1240 $(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=$(abspath ${BUILD_PLAT}) CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${FIPTOOLPATH} all 1241 $(q)ln -sf ${FIPTOOL} ${FIPTOOLPATH}/fiptool 1242 1243$(BUILD_PLAT)/romlib/romlib.bin $(BUILD_PLAT)/lib/libwrappers.a $&: $(BUILD_PLAT)/lib/libfdt.a $(BUILD_PLAT)/lib/libc.a $(CRYPTO_LIB) | $$(@D)/ 1244 $(q)${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} CRYPTO_LIB=$(CRYPTO_LIB) ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES=$(call escape-shell,$(INCLUDES)) DEFINES=$(call escape-shell,$(DEFINES)) --no-print-directory -C ${ROMLIBPATH} all 1245 1246memmap: all 1247 $(if $(host-poetry),$(q)$(host-poetry) -q install --no-root) 1248 $(q)$(if $(host-poetry),$(host-poetry) run )memory --root ${BUILD_PLAT} symbols 1249 1250tl: ${BUILD_PLAT}/tl.bin 1251${BUILD_PLAT}/tl.bin: ${HW_CONFIG} | $$(@D)/ 1252 $(if $(host-poetry),$(q)$(host-poetry) -q install --no-root) 1253 $(q)$(if $(host-poetry),$(host-poetry) run )tlc create --fdt $< -s ${FW_HANDOFF_SIZE} $@ 1254 1255doc: 1256 $(s)echo " BUILD DOCUMENTATION" 1257 $(if $(host-poetry),$(q)$(host-poetry) -q install --with docs --no-root) 1258 $(q)$(if $(host-poetry),$(host-poetry) run )${MAKE} --no-print-directory -C ${DOCS_PATH} BUILDDIR=$(abspath ${BUILD_BASE}/docs) html 1259 1260enctool: ${ENCTOOL} 1261 1262${ENCTOOL}: FORCE | $$(@D)/ 1263 $(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=$(abspath ${BUILD_PLAT}) BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${ENCTOOLPATH} all 1264 $(s)echo 1265 $(s)echo "Built $@ successfully" 1266 $(s)echo 1267 1268cscope: 1269 $(s)echo " CSCOPE" 1270 $(q)find ${CURDIR} -name "*.[chsS]" > cscope.files 1271 $(q)cscope -b -q -k 1272 1273help: 1274 $(s)echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]" 1275 $(s)echo "" 1276 $(s)echo "PLAT is used to specify which platform you wish to build." 1277 $(s)echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}" 1278 $(s)echo "" 1279 $(s)echo "platform = ${PLATFORM_LIST}" 1280 $(s)echo "" 1281 $(s)echo "Please refer to the User Guide for a list of all supported options." 1282 $(s)echo "Note that the build system doesn't track dependencies for build " 1283 $(s)echo "options. Therefore, if any of the build options are changed " 1284 $(s)echo "from a previous build, a clean build must be performed." 1285 $(s)echo "" 1286 $(s)echo "Supported Targets:" 1287 $(s)echo " all Build all individual bootloader binaries" 1288 $(s)echo " bl1 Build the BL1 binary" 1289 $(s)echo " bl2 Build the BL2 binary" 1290 $(s)echo " bl2u Build the BL2U binary" 1291 $(s)echo " bl31 Build the BL31 binary" 1292 $(s)echo " bl32 Build the BL32 binary. If ARCH=aarch32, then " 1293 $(s)echo " this builds secure payload specified by AARCH32_SP" 1294 $(s)echo " certificates Build the certificates (requires 'GENERATE_COT=1')" 1295 $(s)echo " fip Build the Firmware Image Package (FIP)" 1296 $(s)echo " fwu_fip Build the FWU Firmware Image Package (FIP)" 1297 $(s)echo " checkcodebase Check the coding style of the entire source tree" 1298 $(s)echo " checkpatch Check the coding style on changes in the current" 1299 $(s)echo " branch against BASE_COMMIT (default origin/master)" 1300 $(s)echo " clean Clean the build for the selected platform" 1301 $(s)echo " cscope Generate cscope index" 1302 $(s)echo " distclean Remove all build artifacts for all platforms" 1303 $(s)echo " certtool Build the Certificate generation tool" 1304 $(s)echo " enctool Build the Firmware encryption tool" 1305 $(s)echo " fiptool Build the Firmware Image Package (FIP) creation tool" 1306 $(s)echo " sp Build the Secure Partition Packages" 1307 $(s)echo " sptool Build the Secure Partition Package creation tool" 1308 $(s)echo " dtbs Build the Device Tree Blobs (if required for the platform)" 1309 $(s)echo " memmap Print the memory map of the built binaries" 1310 $(s)echo " doc Build html based documentation using Sphinx tool" 1311 $(s)echo "" 1312 $(s)echo "Note: most build targets require PLAT to be set to a specific platform." 1313 $(s)echo "" 1314 $(s)echo "example: build all targets for the FVP platform:" 1315 $(s)echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all" 1316 1317.PHONY: FORCE 1318FORCE:; 1319