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