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