1# 2# Copyright (c) 2013-2018, 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 := 1 11VERSION_MINOR := 5 12 13# Default goal is build all images 14.DEFAULT_GOAL := all 15 16# Avoid any implicit propagation of command line variable definitions to 17# sub-Makefiles, like CFLAGS that we reserved for the firmware images' 18# usage. Other command line options like "-s" are still propagated as usual. 19MAKEOVERRIDES = 20 21MAKE_HELPERS_DIRECTORY := make_helpers/ 22include ${MAKE_HELPERS_DIRECTORY}build_macros.mk 23include ${MAKE_HELPERS_DIRECTORY}build_env.mk 24 25################################################################################ 26# Default values for build configurations, and their dependencies 27################################################################################ 28 29ifdef ASM_ASSERTION 30 $(warning ASM_ASSERTION is removed, use ENABLE_ASSERTIONS instead.) 31endif 32 33include ${MAKE_HELPERS_DIRECTORY}defaults.mk 34 35# Assertions enabled for DEBUG builds by default 36ENABLE_ASSERTIONS := ${DEBUG} 37ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION} 38PLAT := ${DEFAULT_PLAT} 39 40################################################################################ 41# Checkpatch script options 42################################################################################ 43 44CHECKCODE_ARGS := --no-patch 45# Do not check the coding style on imported library files or documentation files 46INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \ 47 include/lib/libfdt \ 48 include/lib/stdlib, \ 49 $(wildcard include/lib/*))) 50INC_DIRS_TO_CHECK := $(sort $(filter-out \ 51 include/lib, \ 52 $(wildcard include/*))) 53LIB_DIRS_TO_CHECK := $(sort $(filter-out \ 54 lib/compiler-rt \ 55 lib/libfdt% \ 56 lib/stdlib, \ 57 $(wildcard lib/*))) 58ROOT_DIRS_TO_CHECK := $(sort $(filter-out \ 59 lib \ 60 include \ 61 docs \ 62 %.md, \ 63 $(wildcard *))) 64CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \ 65 ${INC_DIRS_TO_CHECK} \ 66 ${INC_LIB_DIRS_TO_CHECK} \ 67 ${LIB_DIRS_TO_CHECK} 68 69 70################################################################################ 71# Process build options 72################################################################################ 73 74# Verbose flag 75ifeq (${V},0) 76 Q:=@ 77 CHECKCODE_ARGS += --no-summary --terse 78else 79 Q:= 80endif 81export Q 82 83# Process Debug flag 84$(eval $(call add_define,DEBUG)) 85ifneq (${DEBUG}, 0) 86 BUILD_TYPE := debug 87 TF_CFLAGS += -g 88 ASFLAGS += -g -Wa,--gdwarf-2 89 # Use LOG_LEVEL_INFO by default for debug builds 90 LOG_LEVEL := 40 91else 92 BUILD_TYPE := release 93 # Use LOG_LEVEL_NOTICE by default for release builds 94 LOG_LEVEL := 20 95endif 96 97# Default build string (git branch and commit) 98ifeq (${BUILD_STRING},) 99 BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null) 100endif 101VERSION_STRING := v${VERSION_MAJOR}.${VERSION_MINOR}(${BUILD_TYPE}):${BUILD_STRING} 102 103# The cert_create tool cannot generate certificates individually, so we use the 104# target 'certificates' to create them all 105ifneq (${GENERATE_COT},0) 106 FIP_DEPS += certificates 107 FWU_FIP_DEPS += fwu_certificates 108endif 109 110 111################################################################################ 112# Toolchain 113################################################################################ 114 115HOSTCC := gcc 116export HOSTCC 117 118CC := ${CROSS_COMPILE}gcc 119CPP := ${CROSS_COMPILE}cpp 120AS := ${CROSS_COMPILE}gcc 121AR := ${CROSS_COMPILE}ar 122LD := ${CROSS_COMPILE}ld 123OC := ${CROSS_COMPILE}objcopy 124OD := ${CROSS_COMPILE}objdump 125NM := ${CROSS_COMPILE}nm 126PP := ${CROSS_COMPILE}gcc -E 127DTC := dtc 128 129# Use ${LD}.bfd instead if it exists (as absolute path or together with $PATH). 130ifneq ($(strip $(wildcard ${LD}.bfd) \ 131 $(foreach dir,$(subst :, ,${PATH}),$(wildcard ${dir}/${LD}.bfd))),) 132LD := ${LD}.bfd 133endif 134 135ifeq (${ARM_ARCH_MAJOR},7) 136target32-directive = -target arm-none-eabi 137# Will set march32-directive from platform configuration 138else 139target32-directive = -target armv8a-none-eabi 140march32-directive = -march=armv8-a 141endif 142 143ifeq ($(notdir $(CC)),armclang) 144TF_CFLAGS_aarch32 = -target arm-arm-none-eabi $(march32-directive) 145TF_CFLAGS_aarch64 = -target aarch64-arm-none-eabi -march=armv8-a 146else ifneq ($(findstring clang,$(notdir $(CC))),) 147TF_CFLAGS_aarch32 = $(target32-directive) 148TF_CFLAGS_aarch64 = -target aarch64-elf 149else 150TF_CFLAGS_aarch32 = $(march32-directive) 151TF_CFLAGS_aarch64 = -march=armv8-a 152endif 153 154TF_CFLAGS_aarch32 += -mno-unaligned-access 155TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align 156 157ASFLAGS_aarch32 = $(march32-directive) 158ASFLAGS_aarch64 = -march=armv8-a 159 160CPPFLAGS = ${DEFINES} ${INCLUDES} -nostdinc \ 161 -Wmissing-include-dirs -Werror 162ASFLAGS += $(CPPFLAGS) $(ASFLAGS_$(ARCH)) \ 163 -D__ASSEMBLY__ -ffreestanding \ 164 -Wa,--fatal-warnings 165TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \ 166 -ffreestanding -fno-builtin -Wall -std=gnu99 \ 167 -Os -ffunction-sections -fdata-sections 168 169GCC_V_OUTPUT := $(shell $(CC) -v 2>&1) 170PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT}) 171 172ifneq ($(PIE_FOUND),) 173TF_CFLAGS += -fno-PIE 174endif 175 176TF_LDFLAGS += --fatal-warnings -O1 177TF_LDFLAGS += --gc-sections 178TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) 179 180DTC_FLAGS += -I dts -O dtb 181 182################################################################################ 183# Common sources and include directories 184################################################################################ 185include lib/compiler-rt/compiler-rt.mk 186include lib/stdlib/stdlib.mk 187 188BL_COMMON_SOURCES += common/bl_common.c \ 189 common/tf_log.c \ 190 common/tf_printf.c \ 191 common/tf_snprintf.c \ 192 common/${ARCH}/debug.S \ 193 lib/${ARCH}/cache_helpers.S \ 194 lib/${ARCH}/misc_helpers.S \ 195 plat/common/plat_bl_common.c \ 196 plat/common/plat_log_common.c \ 197 plat/common/${ARCH}/plat_common.c \ 198 plat/common/${ARCH}/platform_helpers.S \ 199 ${COMPILER_RT_SRCS} \ 200 ${STDLIB_SRCS} 201 202INCLUDES += -Iinclude \ 203 -Iinclude/bl1 \ 204 -Iinclude/bl2 \ 205 -Iinclude/bl2u \ 206 -Iinclude/bl31 \ 207 -Iinclude/common \ 208 -Iinclude/common/${ARCH} \ 209 -Iinclude/drivers \ 210 -Iinclude/drivers/arm \ 211 -Iinclude/drivers/auth \ 212 -Iinclude/drivers/io \ 213 -Iinclude/drivers/ti/uart \ 214 -Iinclude/lib \ 215 -Iinclude/lib/${ARCH} \ 216 -Iinclude/lib/cpus \ 217 -Iinclude/lib/cpus/${ARCH} \ 218 -Iinclude/lib/el3_runtime \ 219 -Iinclude/lib/el3_runtime/${ARCH} \ 220 -Iinclude/lib/extensions \ 221 -Iinclude/lib/pmf \ 222 -Iinclude/lib/psci \ 223 -Iinclude/lib/xlat_tables \ 224 -Iinclude/plat/common \ 225 -Iinclude/services \ 226 ${PLAT_INCLUDES} \ 227 ${SPD_INCLUDES} \ 228 -Iinclude/tools_share 229 230 231################################################################################ 232# Generic definitions 233################################################################################ 234 235include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk 236 237BUILD_BASE := ./build 238BUILD_PLAT := ${BUILD_BASE}/${PLAT}/${BUILD_TYPE} 239 240SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*)))) 241 242# Platforms providing their own TBB makefile may override this value 243INCLUDE_TBBR_MK := 1 244 245 246################################################################################ 247# Include SPD Makefile if one has been specified 248################################################################################ 249 250ifneq (${SPD},none) 251ifeq (${ARCH},aarch32) 252 $(error "Error: SPD is incompatible with AArch32.") 253endif 254ifdef EL3_PAYLOAD_BASE 255 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.") 256 $(warning "The SPD and its BL32 companion will be present but ignored.") 257endif 258 # We expect to locate an spd.mk under the specified SPD directory 259 SPD_MAKE := $(wildcard services/spd/${SPD}/${SPD}.mk) 260 261 ifeq (${SPD_MAKE},) 262 $(error Error: No services/spd/${SPD}/${SPD}.mk located) 263 endif 264 $(info Including ${SPD_MAKE}) 265 include ${SPD_MAKE} 266 267 # If there's BL32 companion for the chosen SPD, we expect that the SPD's 268 # Makefile would set NEED_BL32 to "yes". In this case, the build system 269 # supports two mutually exclusive options: 270 # * BL32 is built from source: then BL32_SOURCES must contain the list 271 # of source files to build BL32 272 # * BL32 is a prebuilt binary: then BL32 must point to the image file 273 # that will be included in the FIP 274 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence 275 # over the sources. 276endif 277 278################################################################################ 279# Include the platform specific Makefile after the SPD Makefile (the platform 280# makefile may use all previous definitions in this file) 281################################################################################ 282 283include ${PLAT_MAKEFILE_FULL} 284 285$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT})) 286 287ifeq (${ARM_ARCH_MAJOR},7) 288include make_helpers/armv7-a-cpus.mk 289endif 290 291# Platform compatibility is not supported in AArch32 292ifneq (${ARCH},aarch32) 293# If the platform has not defined ENABLE_PLAT_COMPAT, then enable it by default 294ifndef ENABLE_PLAT_COMPAT 295ENABLE_PLAT_COMPAT := 1 296endif 297 298# Include the platform compatibility helpers for PSCI 299ifneq (${ENABLE_PLAT_COMPAT}, 0) 300include plat/compat/plat_compat.mk 301endif 302endif 303 304# Include the CPU specific operations makefile, which provides default 305# values for all CPU errata workarounds and CPU specific optimisations. 306# This can be overridden by the platform. 307include lib/cpus/cpu-ops.mk 308 309ifeq (${ARCH},aarch32) 310NEED_BL32 := yes 311 312################################################################################ 313# Build `AARCH32_SP` as BL32 image for AArch32 314################################################################################ 315ifneq (${AARCH32_SP},none) 316# We expect to locate an sp.mk under the specified AARCH32_SP directory 317AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk) 318 319ifeq (${AARCH32_SP_MAKE},) 320 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located) 321endif 322 323$(info Including ${AARCH32_SP_MAKE}) 324include ${AARCH32_SP_MAKE} 325endif 326 327endif 328 329################################################################################ 330# Check incompatible options 331################################################################################ 332 333ifdef EL3_PAYLOAD_BASE 334 ifdef PRELOADED_BL33_BASE 335 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \ 336 incompatible build options. EL3_PAYLOAD_BASE has priority.") 337 endif 338 ifneq (${GENERATE_COT},0) 339 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible build options.") 340 endif 341 ifneq (${TRUSTED_BOARD_BOOT},0) 342 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are incompatible build options.") 343 endif 344endif 345 346ifeq (${NEED_BL33},yes) 347 ifdef EL3_PAYLOAD_BASE 348 $(warning "BL33 image is not needed when option \ 349 BL33_PAYLOAD_BASE is used and won't be added to the FIP file.") 350 endif 351 ifdef PRELOADED_BL33_BASE 352 $(warning "BL33 image is not needed when option \ 353 PRELOADED_BL33_BASE is used and won't be added to the FIP \ 354 file.") 355 endif 356endif 357 358# For AArch32, LOAD_IMAGE_V2 must be enabled. 359ifeq (${ARCH},aarch32) 360 ifeq (${LOAD_IMAGE_V2}, 0) 361 $(error "For AArch32, LOAD_IMAGE_V2 must be enabled.") 362 endif 363endif 364 365# When building for systems with hardware-assisted coherency, there's no need to 366# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too. 367ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1) 368$(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY) 369endif 370 371ifneq ($(MULTI_CONSOLE_API), 0) 372 ifeq (${ARCH},aarch32) 373 $(error "Error: MULTI_CONSOLE_API is not supported for AArch32") 374 endif 375endif 376 377#For now, BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is 1. 378ifeq ($(BL2_AT_EL3)-$(BL2_IN_XIP_MEM),0-1) 379$(error "BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is enabled") 380endif 381 382# SMC Calling Convention checks 383ifneq (${SMCCC_MAJOR_VERSION},1) 384 ifneq (${SPD},none) 385 $(error "SMC Calling Convention 1.X must be used with SPDs") 386 endif 387 ifeq (${ARCH},aarch32) 388 $(error "Only SMCCC 1.X is supported in AArch32 mode.") 389 endif 390endif 391 392# For RAS_EXTENSION, require that EAs are handled in EL3 first 393ifeq ($(RAS_EXTENSION),1) 394 ifneq ($(HANDLE_EA_EL3_FIRST),1) 395 $(error For RAS_EXTENSION, HANDLE_EA_EL3_FIRST must also be 1) 396 endif 397endif 398 399# When FAULT_INJECTION_SUPPORT is used, require that RAS_EXTENSION is enabled 400ifeq ($(FAULT_INJECTION_SUPPORT),1) 401 ifneq ($(RAS_EXTENSION),1) 402 $(error For FAULT_INJECTION_SUPPORT, RAS_EXTENSION must also be 1) 403 endif 404endif 405 406# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1 and LOAD_IMAGE_V2=1 407ifeq ($(DYN_DISABLE_AUTH), 1) 408 ifeq (${TRUSTED_BOARD_BOOT}, 0) 409 $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH to be set.") 410 endif 411 ifeq (${LOAD_IMAGE_V2}, 0) 412 $(error "DYN_DISABLE_AUTH is only supported for LOAD_IMAGE_V2.") 413 endif 414endif 415 416################################################################################ 417# Process platform overrideable behaviour 418################################################################################ 419 420# Using the ARM Trusted Firmware BL2 implies that a BL33 image also needs to be 421# supplied for the FIP and Certificate generation tools. This flag can be 422# overridden by the platform. 423ifdef BL2_SOURCES 424 ifdef EL3_PAYLOAD_BASE 425 # If booting an EL3 payload there is no need for a BL33 image 426 # in the FIP file. 427 NEED_BL33 := no 428 else 429 ifdef PRELOADED_BL33_BASE 430 # If booting a BL33 preloaded image there is no need of 431 # another one in the FIP file. 432 NEED_BL33 := no 433 else 434 NEED_BL33 ?= yes 435 endif 436 endif 437endif 438 439# If SCP_BL2 is given, we always want FIP to include it. 440ifdef SCP_BL2 441 NEED_SCP_BL2 := yes 442endif 443 444# For AArch32, BL31 is not currently supported. 445ifneq (${ARCH},aarch32) 446 ifdef BL31_SOURCES 447 # When booting an EL3 payload, there is no need to compile the BL31 image nor 448 # put it in the FIP. 449 ifndef EL3_PAYLOAD_BASE 450 NEED_BL31 := yes 451 endif 452 endif 453endif 454 455# Process TBB related flags 456ifneq (${GENERATE_COT},0) 457 # Common cert_create options 458 ifneq (${CREATE_KEYS},0) 459 $(eval CRT_ARGS += -n) 460 $(eval FWU_CRT_ARGS += -n) 461 ifneq (${SAVE_KEYS},0) 462 $(eval CRT_ARGS += -k) 463 $(eval FWU_CRT_ARGS += -k) 464 endif 465 endif 466 # Include TBBR makefile (unless the platform indicates otherwise) 467 ifeq (${INCLUDE_TBBR_MK},1) 468 include make_helpers/tbbr/tbbr_tools.mk 469 endif 470endif 471 472ifneq (${FIP_ALIGN},0) 473FIP_ARGS += --align ${FIP_ALIGN} 474endif 475 476################################################################################ 477# Include libraries' Makefile that are used in all BL 478################################################################################ 479 480include lib/stack_protector/stack_protector.mk 481 482################################################################################ 483# Auxiliary tools (fiptool, cert_create, etc) 484################################################################################ 485 486# Variables for use with Certificate Generation Tool 487CRTTOOLPATH ?= tools/cert_create 488CRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT} 489 490# Variables for use with Firmware Image Package 491FIPTOOLPATH ?= tools/fiptool 492FIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT} 493 494################################################################################ 495# Include BL specific makefiles 496################################################################################ 497ifdef BL1_SOURCES 498NEED_BL1 := yes 499include bl1/bl1.mk 500endif 501 502ifdef BL2_SOURCES 503NEED_BL2 := yes 504include bl2/bl2.mk 505endif 506 507ifdef BL2U_SOURCES 508NEED_BL2U := yes 509include bl2u/bl2u.mk 510endif 511 512ifeq (${NEED_BL31},yes) 513ifdef BL31_SOURCES 514include bl31/bl31.mk 515endif 516endif 517 518ifdef FDT_SOURCES 519NEED_FDT := yes 520endif 521 522################################################################################ 523# Build options checks 524################################################################################ 525 526$(eval $(call assert_boolean,COLD_BOOT_SINGLE_CPU)) 527$(eval $(call assert_boolean,CREATE_KEYS)) 528$(eval $(call assert_boolean,CTX_INCLUDE_AARCH32_REGS)) 529$(eval $(call assert_boolean,CTX_INCLUDE_FPREGS)) 530$(eval $(call assert_boolean,DEBUG)) 531$(eval $(call assert_boolean,DISABLE_PEDANTIC)) 532$(eval $(call assert_boolean,DYN_DISABLE_AUTH)) 533$(eval $(call assert_boolean,EL3_EXCEPTION_HANDLING)) 534$(eval $(call assert_boolean,ENABLE_AMU)) 535$(eval $(call assert_boolean,ENABLE_ASSERTIONS)) 536$(eval $(call assert_boolean,ENABLE_PLAT_COMPAT)) 537$(eval $(call assert_boolean,ENABLE_PMF)) 538$(eval $(call assert_boolean,ENABLE_PSCI_STAT)) 539$(eval $(call assert_boolean,ENABLE_RUNTIME_INSTRUMENTATION)) 540$(eval $(call assert_boolean,ENABLE_SPE_FOR_LOWER_ELS)) 541$(eval $(call assert_boolean,ENABLE_SPM)) 542$(eval $(call assert_boolean,ENABLE_SVE_FOR_NS)) 543$(eval $(call assert_boolean,ERROR_DEPRECATED)) 544$(eval $(call assert_boolean,FAULT_INJECTION_SUPPORT)) 545$(eval $(call assert_boolean,GENERATE_COT)) 546$(eval $(call assert_boolean,GICV2_G0_FOR_EL3)) 547$(eval $(call assert_boolean,HANDLE_EA_EL3_FIRST)) 548$(eval $(call assert_boolean,HW_ASSISTED_COHERENCY)) 549$(eval $(call assert_boolean,LOAD_IMAGE_V2)) 550$(eval $(call assert_boolean,MULTI_CONSOLE_API)) 551$(eval $(call assert_boolean,NS_TIMER_SWITCH)) 552$(eval $(call assert_boolean,PL011_GENERIC_UART)) 553$(eval $(call assert_boolean,PROGRAMMABLE_RESET_ADDRESS)) 554$(eval $(call assert_boolean,PSCI_EXTENDED_STATE_ID)) 555$(eval $(call assert_boolean,RAS_EXTENSION)) 556$(eval $(call assert_boolean,RESET_TO_BL31)) 557$(eval $(call assert_boolean,SAVE_KEYS)) 558$(eval $(call assert_boolean,SEPARATE_CODE_AND_RODATA)) 559$(eval $(call assert_boolean,SPIN_ON_BL1_EXIT)) 560$(eval $(call assert_boolean,TRUSTED_BOARD_BOOT)) 561$(eval $(call assert_boolean,USE_COHERENT_MEM)) 562$(eval $(call assert_boolean,USE_TBBR_DEFS)) 563$(eval $(call assert_boolean,WARMBOOT_ENABLE_DCACHE_EARLY)) 564$(eval $(call assert_boolean,BL2_AT_EL3)) 565$(eval $(call assert_boolean,BL2_IN_XIP_MEM)) 566 567$(eval $(call assert_numeric,ARM_ARCH_MAJOR)) 568$(eval $(call assert_numeric,ARM_ARCH_MINOR)) 569$(eval $(call assert_numeric,SMCCC_MAJOR_VERSION)) 570 571################################################################################ 572# Add definitions to the cpp preprocessor based on the current build options. 573# This is done after including the platform specific makefile to allow the 574# platform to overwrite the default options 575################################################################################ 576 577$(eval $(call add_define,ARM_ARCH_MAJOR)) 578$(eval $(call add_define,ARM_ARCH_MINOR)) 579$(eval $(call add_define,ARM_GIC_ARCH)) 580$(eval $(call add_define,COLD_BOOT_SINGLE_CPU)) 581$(eval $(call add_define,CTX_INCLUDE_AARCH32_REGS)) 582$(eval $(call add_define,CTX_INCLUDE_FPREGS)) 583$(eval $(call add_define,EL3_EXCEPTION_HANDLING)) 584$(eval $(call add_define,ENABLE_AMU)) 585$(eval $(call add_define,ENABLE_ASSERTIONS)) 586$(eval $(call add_define,ENABLE_PLAT_COMPAT)) 587$(eval $(call add_define,ENABLE_PMF)) 588$(eval $(call add_define,ENABLE_PSCI_STAT)) 589$(eval $(call add_define,ENABLE_RUNTIME_INSTRUMENTATION)) 590$(eval $(call add_define,ENABLE_SPE_FOR_LOWER_ELS)) 591$(eval $(call add_define,ENABLE_SPM)) 592$(eval $(call add_define,ENABLE_SVE_FOR_NS)) 593$(eval $(call add_define,ERROR_DEPRECATED)) 594$(eval $(call add_define,FAULT_INJECTION_SUPPORT)) 595$(eval $(call add_define,GICV2_G0_FOR_EL3)) 596$(eval $(call add_define,HANDLE_EA_EL3_FIRST)) 597$(eval $(call add_define,HW_ASSISTED_COHERENCY)) 598$(eval $(call add_define,LOAD_IMAGE_V2)) 599$(eval $(call add_define,LOG_LEVEL)) 600$(eval $(call add_define,MULTI_CONSOLE_API)) 601$(eval $(call add_define,NS_TIMER_SWITCH)) 602$(eval $(call add_define,PL011_GENERIC_UART)) 603$(eval $(call add_define,PLAT_${PLAT})) 604$(eval $(call add_define,PROGRAMMABLE_RESET_ADDRESS)) 605$(eval $(call add_define,PSCI_EXTENDED_STATE_ID)) 606$(eval $(call add_define,RAS_EXTENSION)) 607$(eval $(call add_define,RESET_TO_BL31)) 608$(eval $(call add_define,SEPARATE_CODE_AND_RODATA)) 609$(eval $(call add_define,SMCCC_MAJOR_VERSION)) 610$(eval $(call add_define,SPD_${SPD})) 611$(eval $(call add_define,SPIN_ON_BL1_EXIT)) 612$(eval $(call add_define,TRUSTED_BOARD_BOOT)) 613$(eval $(call add_define,USE_COHERENT_MEM)) 614$(eval $(call add_define,USE_TBBR_DEFS)) 615$(eval $(call add_define,WARMBOOT_ENABLE_DCACHE_EARLY)) 616$(eval $(call add_define,BL2_AT_EL3)) 617$(eval $(call add_define,BL2_IN_XIP_MEM)) 618 619# Define the EL3_PAYLOAD_BASE flag only if it is provided. 620ifdef EL3_PAYLOAD_BASE 621 $(eval $(call add_define,EL3_PAYLOAD_BASE)) 622else 623 # Define the PRELOADED_BL33_BASE flag only if it is provided and 624 # EL3_PAYLOAD_BASE is not defined, as it has priority. 625 ifdef PRELOADED_BL33_BASE 626 $(eval $(call add_define,PRELOADED_BL33_BASE)) 627 endif 628endif 629# Define the AARCH32/AARCH64 flag based on the ARCH flag 630ifeq (${ARCH},aarch32) 631 $(eval $(call add_define,AARCH32)) 632else 633 $(eval $(call add_define,AARCH64)) 634endif 635 636# Define the DYN_DISABLE_AUTH flag only if set. 637ifeq (${DYN_DISABLE_AUTH},1) 638$(eval $(call add_define,DYN_DISABLE_AUTH)) 639endif 640 641################################################################################ 642# Build targets 643################################################################################ 644 645.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool fip fwu_fip certtool dtbs 646.SUFFIXES: 647 648all: msg_start 649 650msg_start: 651 @echo "Building ${PLAT}" 652 653# Check if deprecated declarations and cpp warnings should be treated as error or not. 654ifeq (${ERROR_DEPRECATED},0) 655 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp 656endif 657 658# Expand build macros for the different images 659ifeq (${NEED_BL1},yes) 660$(eval $(call MAKE_BL,1)) 661endif 662 663ifeq (${NEED_BL2},yes) 664ifeq (${BL2_AT_EL3}, 0) 665FIP_BL2_ARGS := tb-fw 666endif 667 668$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\ 669 $(eval $(call MAKE_BL,2,${FIP_BL2_ARGS}))) 670endif 671 672ifeq (${NEED_SCP_BL2},yes) 673$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw)) 674endif 675 676ifeq (${NEED_BL31},yes) 677BL31_SOURCES += ${SPD_SOURCES} 678$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\ 679 $(eval $(call MAKE_BL,31,soc-fw))) 680endif 681 682# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the 683# build system will call TOOL_ADD_IMG to print a warning message and abort the 684# process. Note that the dependency on BL32 applies to the FIP only. 685ifeq (${NEED_BL32},yes) 686 687BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1)) 688 689$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,32,tos-fw)),\ 690 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw))) 691endif 692 693# Add the BL33 image if required by the platform 694ifeq (${NEED_BL33},yes) 695$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw)) 696endif 697 698ifeq (${NEED_BL2U},yes) 699$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\ 700 $(eval $(call MAKE_BL,2u,ap-fwu-cfg,FWU_))) 701endif 702 703# Expand build macros for the different images 704ifeq (${NEED_FDT},yes) 705 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES))) 706endif 707 708locate-checkpatch: 709ifndef CHECKPATCH 710 $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 711else 712ifeq (,$(wildcard ${CHECKPATCH})) 713 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 714endif 715endif 716 717clean: 718 @echo " CLEAN" 719 $(call SHELL_REMOVE_DIR,${BUILD_PLAT}) 720 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 721 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 722 723realclean distclean: 724 @echo " REALCLEAN" 725 $(call SHELL_REMOVE_DIR,${BUILD_BASE}) 726 $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*) 727 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 728 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 729 730checkcodebase: locate-checkpatch 731 @echo " CHECKING STYLE" 732 @if test -d .git ; then \ 733 git ls-files | grep -E -v 'libfdt|stdlib|docs|\.md' | \ 734 while read GIT_FILE ; \ 735 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \ 736 done ; \ 737 else \ 738 find . -type f -not -iwholename "*.git*" \ 739 -not -iwholename "*build*" \ 740 -not -iwholename "*libfdt*" \ 741 -not -iwholename "*stdlib*" \ 742 -not -iwholename "*docs*" \ 743 -not -iwholename "*.md" \ 744 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \ 745 fi 746 747checkpatch: locate-checkpatch 748 @echo " CHECKING STYLE" 749 ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \ 750 for commit in `git rev-list $$COMMON_COMMIT..HEAD`; do \ 751 printf "\n[*] Checking style of '$$commit'\n\n"; \ 752 git log --format=email "$$commit~..$$commit" \ 753 -- ${CHECK_PATHS} | ${CHECKPATCH} - || true; \ 754 git diff --format=email "$$commit~..$$commit" \ 755 -- ${CHECK_PATHS} | ${CHECKPATCH} - || true; \ 756 done 757 758certtool: ${CRTTOOL} 759 760.PHONY: ${CRTTOOL} 761${CRTTOOL}: 762 ${Q}${MAKE} PLAT=${PLAT} USE_TBBR_DEFS=${USE_TBBR_DEFS} --no-print-directory -C ${CRTTOOLPATH} 763 @${ECHO_BLANK_LINE} 764 @echo "Built $@ successfully" 765 @${ECHO_BLANK_LINE} 766 767ifneq (${GENERATE_COT},0) 768certificates: ${CRT_DEPS} ${CRTTOOL} 769 ${Q}${CRTTOOL} ${CRT_ARGS} 770 @${ECHO_BLANK_LINE} 771 @echo "Built $@ successfully" 772 @echo "Certificates can be found in ${BUILD_PLAT}" 773 @${ECHO_BLANK_LINE} 774endif 775 776${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL} 777 ${Q}${FIPTOOL} create ${FIP_ARGS} $@ 778 ${Q}${FIPTOOL} info $@ 779 @${ECHO_BLANK_LINE} 780 @echo "Built $@ successfully" 781 @${ECHO_BLANK_LINE} 782 783ifneq (${GENERATE_COT},0) 784fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL} 785 ${Q}${CRTTOOL} ${FWU_CRT_ARGS} 786 @${ECHO_BLANK_LINE} 787 @echo "Built $@ successfully" 788 @echo "FWU certificates can be found in ${BUILD_PLAT}" 789 @${ECHO_BLANK_LINE} 790endif 791 792${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL} 793 ${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@ 794 ${Q}${FIPTOOL} info $@ 795 @${ECHO_BLANK_LINE} 796 @echo "Built $@ successfully" 797 @${ECHO_BLANK_LINE} 798 799fiptool: ${FIPTOOL} 800fip: ${BUILD_PLAT}/${FIP_NAME} 801fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME} 802 803.PHONY: ${FIPTOOL} 804${FIPTOOL}: 805 ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" --no-print-directory -C ${FIPTOOLPATH} 806 807cscope: 808 @echo " CSCOPE" 809 ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files 810 ${Q}cscope -b -q -k 811 812help: 813 @echo "usage: ${MAKE} PLAT=<${PLATFORM_LIST}> [OPTIONS] [TARGET]" 814 @echo "" 815 @echo "PLAT is used to specify which platform you wish to build." 816 @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}" 817 @echo "" 818 @echo "Please refer to the User Guide for a list of all supported options." 819 @echo "Note that the build system doesn't track dependencies for build " 820 @echo "options. Therefore, if any of the build options are changed " 821 @echo "from a previous build, a clean build must be performed." 822 @echo "" 823 @echo "Supported Targets:" 824 @echo " all Build all individual bootloader binaries" 825 @echo " bl1 Build the BL1 binary" 826 @echo " bl2 Build the BL2 binary" 827 @echo " bl2u Build the BL2U binary" 828 @echo " bl31 Build the BL31 binary" 829 @echo " bl32 Build the BL32 binary. If ARCH=aarch32, then " 830 @echo " this builds secure payload specified by AARCH32_SP" 831 @echo " certificates Build the certificates (requires 'GENERATE_COT=1')" 832 @echo " fip Build the Firmware Image Package (FIP)" 833 @echo " fwu_fip Build the FWU Firmware Image Package (FIP)" 834 @echo " checkcodebase Check the coding style of the entire source tree" 835 @echo " checkpatch Check the coding style on changes in the current" 836 @echo " branch against BASE_COMMIT (default origin/master)" 837 @echo " clean Clean the build for the selected platform" 838 @echo " cscope Generate cscope index" 839 @echo " distclean Remove all build artifacts for all platforms" 840 @echo " certtool Build the Certificate generation tool" 841 @echo " fiptool Build the Firmware Image Package (FIP) creation tool" 842 @echo " dtbs Build the Device Tree Blobs (if required for the platform)" 843 @echo "" 844 @echo "Note: most build targets require PLAT to be set to a specific platform." 845 @echo "" 846 @echo "example: build all targets for the FVP platform:" 847 @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all" 848