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