Debian Codegraph @

Makefile

raw symbols SCIP
1 #
2 # Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved.
3 #
4 # SPDX-License-Identifier: BSD-3-Clause
5 #
6
7 #
8 # Trusted Firmware Version
9 #
10 VERSION_MAJOR := 2
11 VERSION_MINOR := 12
12 # VERSION_PATCH is only used for LTS releases
13 VERSION_PATCH := 1
14 VERSION := ${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.
22 MAKEOVERRIDES =
23
24 MAKE_HELPERS_DIRECTORY := make_helpers/
25 include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
26 include ${MAKE_HELPERS_DIRECTORY}build_env.mk
27 include ${MAKE_HELPERS_DIRECTORY}build-rules.mk
28 include ${MAKE_HELPERS_DIRECTORY}common.mk
29
30 ################################################################################
31 # Default values for build configurations, and their dependencies
32 ################################################################################
33
34 include ${MAKE_HELPERS_DIRECTORY}defaults.mk
35 PLAT := ${DEFAULT_PLAT}
36 include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
37
38 # To be able to set platform specific defaults
39 ifneq ($(PLAT_DEFAULTS_MAKEFILE_FULL),)
40 include ${PLAT_DEFAULTS_MAKEFILE_FULL}
41 endif
42
43 ################################################################################
44 # Configure the toolchains used to build TF-A and its tools
45 ################################################################################
46
47 include ${MAKE_HELPERS_DIRECTORY}toolchain.mk
48
49 # Assertions enabled for DEBUG builds by default
50 ENABLE_ASSERTIONS := ${DEBUG}
51 ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION}
52
53 ################################################################################
54 # Checkpatch script options
55 ################################################################################
56
57 CHECKCODE_ARGS := --no-patch
58 # Do not check the coding style on imported library files or documentation files
59 INC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \
60 include/drivers/arm, \
61 $(wildcard include/drivers/*)))
62 INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \
63 include/lib/libfdt \
64 include/lib/libc, \
65 $(wildcard include/lib/*)))
66 INC_DIRS_TO_CHECK := $(sort $(filter-out \
67 include/lib \
68 include/drivers, \
69 $(wildcard include/*)))
70 LIB_DIRS_TO_CHECK := $(sort $(filter-out \
71 lib/compiler-rt \
72 lib/libfdt% \
73 lib/libc, \
74 lib/zlib \
75 $(wildcard lib/*)))
76 ROOT_DIRS_TO_CHECK := $(sort $(filter-out \
77 lib \
78 include \
79 docs \
80 %.rst, \
81 $(wildcard *)))
82 CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \
83 ${INC_DIRS_TO_CHECK} \
84 ${INC_LIB_DIRS_TO_CHECK} \
85 ${LIB_DIRS_TO_CHECK} \
86 ${INC_DRV_DIRS_TO_CHECK} \
87 ${INC_ARM_DIRS_TO_CHECK}
88
89 ################################################################################
90 # Process build options
91 ################################################################################
92
93 ifeq ($(verbose),)
94 CHECKCODE_ARGS += --no-summary --terse
95 endif
96
97 ################################################################################
98 # Auxiliary tools (fiptool, cert_create, etc)
99 ################################################################################
100
101 # Variables for use with Certificate Generation Tool
102 CRTTOOLPATH ?= tools/cert_create
103 CRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT}
104
105 # Variables for use with Firmware Encryption Tool
106 ENCTOOLPATH ?= tools/encrypt_fw
107 ENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
108
109 # Variables for use with Firmware Image Package
110 FIPTOOLPATH ?= tools/fiptool
111 FIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT}
112
113 # Variables for use with sptool
114 SPTOOLPATH ?= tools/sptool
115 SPTOOL ?= ${SPTOOLPATH}/sptool.py
116 SP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py
117 SP_DTS_LIST_FRAGMENT ?= ${BUILD_PLAT}/sp_list_fragment.dts
118
119 # Variables for use with ROMLIB
120 ROMLIBPATH ?= lib/romlib
121
122 # Variable for use with Python
123 PYTHON ?= python3
124
125 # Variables for use with documentation build using Sphinx tool
126 DOCS_PATH ?= docs
127
128 ################################################################################
129 # Compiler Configuration based on ARCH_MAJOR and ARCH_MINOR flags
130 ################################################################################
131 ifeq (${ARM_ARCH_MAJOR},7)
132 target32-directive = -target arm-none-eabi
133 # Will set march-directive from platform configuration
134 else
135 target32-directive = -target armv8a-none-eabi
136 endif #(ARM_ARCH_MAJOR)
137
138 ################################################################################
139 # Get Architecture Feature Modifiers
140 ################################################################################
141 arch-features = ${ARM_ARCH_FEATURE}
142
143 ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
144 ifeq ($($(ARCH)-cc-id),arm-clang)
145 TF_CFLAGS_aarch32 := -target arm-arm-none-eabi
146 TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi
147 else
148 TF_CFLAGS_aarch32 = $(target32-directive)
149 TF_CFLAGS_aarch64 := -target aarch64-elf
150 endif
151
152 else ifeq ($($(ARCH)-cc-id),gnu-gcc)
153 # Enable LTO only for aarch64
154 ifeq (${ARCH},aarch64)
155 LTO_CFLAGS = $(if $(filter-out 0,$(ENABLE_LTO)),-flto)
156 endif
157 endif #(clang)
158
159 # Process Debug flag
160 $(eval $(call add_define,DEBUG))
161 ifneq (${DEBUG}, 0)
162 BUILD_TYPE := debug
163 TF_CFLAGS += -g -gdwarf-4
164 ASFLAGS += -g -Wa,-gdwarf-4
165
166 # Use LOG_LEVEL_INFO by default for debug builds
167 LOG_LEVEL := 40
168 else
169 BUILD_TYPE := release
170 # Use LOG_LEVEL_NOTICE by default for release builds
171 LOG_LEVEL := 20
172 endif #(Debug)
173
174 # Default build string (git branch and commit)
175 ifeq (${BUILD_STRING},)
176 BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null)
177 endif
178 VERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
179
180 ifeq (${AARCH32_INSTRUCTION_SET},A32)
181 TF_CFLAGS_aarch32 += -marm
182 else ifeq (${AARCH32_INSTRUCTION_SET},T32)
183 TF_CFLAGS_aarch32 += -mthumb
184 else
185 $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
186 endif #(AARCH32_INSTRUCTION_SET)
187
188 TF_CFLAGS_aarch32 += -mno-unaligned-access
189 TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align
190
191 ##############################################################################
192 # WARNINGS Configuration
193 ###############################################################################
194 # General warnings
195 WARNINGS := -Wall -Wmissing-include-dirs -Wunused \
196 -Wdisabled-optimization -Wvla -Wshadow \
197 -Wredundant-decls
198 # stricter warnings
199 WARNINGS += -Wextra -Wno-trigraphs
200 # too verbose for generic build
201 WARNINGS += -Wno-missing-field-initializers \
202 -Wno-type-limits -Wno-sign-compare \
203 # on clang this flag gets reset if -Wextra is set after it. No difference on gcc
204 WARNINGS += -Wno-unused-parameter
205
206 # Additional warnings
207 # Level 1 - infrequent warnings we should have none of
208 # full -Wextra
209 WARNING1 += -Wsign-compare
210 WARNING1 += -Wtype-limits
211 WARNING1 += -Wmissing-field-initializers
212
213 # Level 2 - problematic warnings that we want
214 # zlib, compiler-rt, coreboot, and mbdedtls blow up with these
215 # TODO: disable just for them and move into default build
216 WARNING2 += -Wold-style-definition
217 WARNING2 += -Wmissing-prototypes
218 WARNING2 += -Wmissing-format-attribute
219 # TF-A aims to comply with this eventually. Effort too large at present
220 WARNING2 += -Wundef
221 # currently very involved and many platforms set this off
222 WARNING2 += -Wunused-const-variable=2
223
224 # Level 3 - very pedantic, frequently ignored
225 WARNING3 := -Wbad-function-cast
226 WARNING3 += -Waggregate-return
227 WARNING3 += -Wnested-externs
228 WARNING3 += -Wcast-align
229 WARNING3 += -Wcast-qual
230 WARNING3 += -Wconversion
231 WARNING3 += -Wpacked
232 WARNING3 += -Wpointer-arith
233 WARNING3 += -Wswitch-default
234
235 # Setting W is quite verbose and most warnings will be pre-existing issues
236 # outside of the contributor's control. Don't fail the build on them so warnings
237 # can be seen and hopefully addressed
238 ifdef W
239 ifneq (${W},0)
240 E ?= 0
241 endif
242 endif
243
244 ifeq (${W},1)
245 WARNINGS += $(WARNING1)
246 else ifeq (${W},2)
247 WARNINGS += $(WARNING1) $(WARNING2)
248 else ifeq (${W},3)
249 WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
250 endif #(W)
251
252 # Compiler specific warnings
253 ifeq ($(filter %-clang,$($(ARCH)-cc-id)),)
254 # not using clang
255 WARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \
256 -Wpacked-bitfield-compat -Wshift-overflow=2 \
257 -Wlogical-op
258
259 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
260 TF_CFLAGS_MIN_PAGE_SIZE := $(call cc_option, --param=min-pagesize=0)
261 TF_CFLAGS += $(TF_CFLAGS_MIN_PAGE_SIZE)
262
263 ifeq ($(HARDEN_SLS), 1)
264 TF_CFLAGS_MHARDEN_SLS := $(call cc_option, -mharden-sls=all)
265 TF_CFLAGS_aarch64 += $(TF_CFLAGS_MHARDEN_SLS)
266 endif
267
268 else
269 # using clang
270 WARNINGS += -Wshift-overflow -Wshift-sign-overflow \
271 -Wlogical-op-parentheses
272 endif #(Clang Warning)
273
274 ifneq (${E},0)
275 ERRORS := -Werror
276 endif #(E)
277
278 ################################################################################
279 # Compiler and Linker Directives
280 ################################################################################
281 CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
282 $(ERRORS) $(WARNINGS)
283 ASFLAGS += $(CPPFLAGS) \
284 -ffreestanding -Wa,--fatal-warnings
285 TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \
286 -ffunction-sections -fdata-sections \
287 -ffreestanding -fno-builtin -fno-common \
288 -Os -std=gnu99
289
290 ifeq (${SANITIZE_UB},on)
291 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover
292 endif #(${SANITIZE_UB},on)
293
294 ifeq (${SANITIZE_UB},trap)
295 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \
296 -fsanitize-undefined-trap-on-error
297 endif #(${SANITIZE_UB},trap)
298
299 GCC_V_OUTPUT := $(if $($(ARCH)-cc),$(shell $($(ARCH)-cc) -v 2>&1))
300
301 TF_LDFLAGS += -z noexecstack
302
303 # LD = armlink
304 ifeq ($($(ARCH)-ld-id),arm-link)
305 TF_LDFLAGS += --diag_error=warning --lto_level=O1
306 TF_LDFLAGS += --remove --info=unused,unusedsymbols
307 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
308
309 # LD = gcc (used when GCC LTO is enabled)
310 else ifeq ($($(ARCH)-ld-id),gnu-gcc)
311 # Pass ld options with Wl or Xlinker switches
312 TF_LDFLAGS += $(call ld_option,-Xlinker --no-warn-rwx-segments)
313 TF_LDFLAGS += -Wl,--fatal-warnings -O1
314 TF_LDFLAGS += -Wl,--gc-sections
315
316 TF_LDFLAGS += -Wl,-z,common-page-size=4096 #Configure page size constants
317 TF_LDFLAGS += -Wl,-z,max-page-size=4096
318 TF_LDFLAGS += -Wl,--build-id=none
319
320 ifeq ($(ENABLE_LTO),1)
321 ifeq (${ARCH},aarch64)
322 TF_LDFLAGS += -flto -fuse-linker-plugin
323 TF_LDFLAGS += -flto-partition=one
324 endif
325 endif #(ENABLE_LTO)
326
327 # GCC automatically adds fix-cortex-a53-843419 flag when used to link
328 # which breaks some builds, so disable if errata fix is not explicitly enabled
329 ifeq (${ARCH},aarch64)
330 ifneq (${ERRATA_A53_843419},1)
331 TF_LDFLAGS += -mno-fix-cortex-a53-843419
332 endif
333 endif
334 TF_LDFLAGS += -nostdlib
335 TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
336
337 # LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
338 else
339 # With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
340 # are not loaded by a elf loader.
341 TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments)
342 TF_LDFLAGS += -O1
343 TF_LDFLAGS += --gc-sections
344
345 TF_LDFLAGS += -z common-page-size=4096 # Configure page size constants
346 TF_LDFLAGS += -z max-page-size=4096
347 TF_LDFLAGS += --build-id=none
348
349 # ld.lld doesn't recognize the errata flags,
350 # therefore don't add those in that case.
351 # ld.lld reports section type mismatch warnings,
352 # therefore don't add --fatal-warnings to it.
353 ifneq ($($(ARCH)-ld-id),llvm-lld)
354 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) --fatal-warnings
355 endif
356
357 endif #(LD = armlink)
358
359 ################################################################################
360 # Setup ARCH_MAJOR/MINOR before parsing arch_features.
361 ################################################################################
362 ifeq (${ENABLE_RME},1)
363 ARM_ARCH_MAJOR := 9
364 ARM_ARCH_MINOR := 2
365 endif
366
367 ################################################################################
368 # Common sources and include directories
369 ################################################################################
370 include lib/compiler-rt/compiler-rt.mk
371
372 # Allow overriding the timestamp, for example for reproducible builds, or to
373 # synchronize timestamps across multiple projects.
374 # This must be set to a C string (including quotes where applicable).
375 BUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__
376
377 DEFINES += -DBUILD_MESSAGE_TIMESTAMP='$(BUILD_MESSAGE_TIMESTAMP)'
378 DEFINES += -DBUILD_MESSAGE_VERSION_STRING='"$(VERSION_STRING)"'
379 DEFINES += -DBUILD_MESSAGE_VERSION='"$(VERSION)"'
380
381 BL_COMMON_SOURCES += common/bl_common.c \
382 common/tf_log.c \
383 common/${ARCH}/debug.S \
384 drivers/console/multi_console.c \
385 lib/${ARCH}/cache_helpers.S \
386 lib/${ARCH}/misc_helpers.S \
387 lib/extensions/pmuv3/${ARCH}/pmuv3.c \
388 plat/common/plat_bl_common.c \
389 plat/common/plat_log_common.c \
390 plat/common/${ARCH}/plat_common.c \
391 plat/common/${ARCH}/platform_helpers.S \
392 ${COMPILER_RT_SRCS}
393
394 ifeq ($($(ARCH)-cc-id),arm-clang)
395 BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S
396 endif
397
398 ifeq (${SANITIZE_UB},on)
399 BL_COMMON_SOURCES += plat/common/ubsan.c
400 endif
401
402 INCLUDES += -Iinclude \
403 -Iinclude/arch/${ARCH} \
404 -Iinclude/lib/cpus/${ARCH} \
405 -Iinclude/lib/el3_runtime/${ARCH} \
406 ${PLAT_INCLUDES} \
407 ${SPD_INCLUDES}
408
409 DTC_FLAGS += -I dts -O dtb
410 DTC_CPPFLAGS += -P -nostdinc $(INCLUDES) -Ifdts -undef \
411 -x assembler-with-cpp $(DEFINES)
412
413 include common/backtrace/backtrace.mk
414
415 ################################################################################
416 # Generic definitions
417 ################################################################################
418
419 ifeq (${BUILD_BASE},)
420 BUILD_BASE := ./build
421 endif
422 BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
423
424 SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
425
426 # Platforms providing their own TBB makefile may override this value
427 INCLUDE_TBBR_MK := 1
428
429 ################################################################################
430 # Include SPD Makefile if one has been specified
431 ################################################################################
432
433 ifneq (${SPD},none)
434 ifeq (${ARCH},aarch32)
435 $(error "Error: SPD is incompatible with AArch32.")
436 endif
437
438 ifdef EL3_PAYLOAD_BASE
439 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
440 $(warning "The SPD and its BL32 companion will be present but \
441 ignored.")
442 endif
443
444 ifeq (${SPD},spmd)
445 # SPMD is located in std_svc directory
446 SPD_DIR := std_svc
447
448 ifeq ($(SPMD_SPM_AT_SEL2),1)
449 CTX_INCLUDE_EL2_REGS := 1
450 ifeq ($(SPMC_AT_EL3),1)
451 $(error SPM cannot be enabled in both S-EL2 and EL3.)
452 endif
453 ifeq ($(CTX_INCLUDE_SVE_REGS),1)
454 $(error SVE context management not needed with Hafnium SPMC.)
455 endif
456 endif
457
458 ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
459 DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG
460 endif
461
462 ifeq ($(findstring trusty_sp,$(ARM_SPMC_MANIFEST_DTS)),trusty_sp)
463 DTC_CPPFLAGS += -DTRUSTY_SP_FW_CONFIG
464 endif
465
466 ifeq ($(TS_SP_FW_CONFIG),1)
467 DTC_CPPFLAGS += -DTS_SP_FW_CONFIG
468 endif
469
470 ifneq ($(ARM_BL2_SP_LIST_DTS),)
471 DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
472 endif
473
474 ifneq ($(SP_LAYOUT_FILE),)
475 BL2_ENABLE_SP_LOAD := 1
476 endif
477
478 ifeq ($(SPMC_AT_EL3_SEL0_SP),1)
479 ifneq ($(SPMC_AT_EL3),1)
480 $(error SEL0 SP cannot be enabled without SPMC at EL3)
481 endif
482 endif
483 else
484 # All other SPDs in spd directory
485 SPD_DIR := spd
486 endif #(SPD)
487
488 # We expect to locate an spd.mk under the specified SPD directory
489 SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
490
491 ifeq (${SPD_MAKE},)
492 $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
493 endif
494 $(info Including ${SPD_MAKE})
495 include ${SPD_MAKE}
496
497 # If there's BL32 companion for the chosen SPD, we expect that the SPD's
498 # Makefile would set NEED_BL32 to "yes". In this case, the build system
499 # supports two mutually exclusive options:
500 # * BL32 is built from source: then BL32_SOURCES must contain the list
501 # of source files to build BL32
502 # * BL32 is a prebuilt binary: then BL32 must point to the image file
503 # that will be included in the FIP
504 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
505 # over the sources.
506 endif #(SPD=none)
507
508 ifeq (${ENABLE_SPMD_LP}, 1)
509 ifneq (${SPD},spmd)
510 $(error Error: ENABLE_SPMD_LP requires SPD=spmd.)
511 endif
512 ifeq ($(SPMC_AT_EL3),1)
513 $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.)
514 endif
515 endif
516
517 ################################################################################
518 # Process BRANCH_PROTECTION value and set
519 # Pointer Authentication and Branch Target Identification flags
520 ################################################################################
521 ifeq (${BRANCH_PROTECTION},0)
522 # Default value turns off all types of branch protection
523 BP_OPTION := none
524 else ifneq (${ARCH},aarch64)
525 $(error BRANCH_PROTECTION requires AArch64)
526 else ifeq (${BRANCH_PROTECTION},1)
527 # Enables all types of branch protection features
528 BP_OPTION := standard
529 ENABLE_BTI := 1
530 ENABLE_PAUTH := 1
531 else ifeq (${BRANCH_PROTECTION},2)
532 # Return address signing to its standard level
533 BP_OPTION := pac-ret
534 ENABLE_PAUTH := 1
535 else ifeq (${BRANCH_PROTECTION},3)
536 # Extend the signing to include leaf functions
537 BP_OPTION := pac-ret+leaf
538 ENABLE_PAUTH := 1
539 else ifeq (${BRANCH_PROTECTION},4)
540 # Turn on branch target identification mechanism
541 BP_OPTION := bti
542 ENABLE_BTI := 1
543 else
544 $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
545 endif #(BRANCH_PROTECTION)
546
547 ifeq ($(ENABLE_PAUTH),1)
548 CTX_INCLUDE_PAUTH_REGS := 1
549 endif
550 ifneq (${BP_OPTION},none)
551 TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION}
552 endif #(BP_OPTION)
553
554 # Pointer Authentication sources
555 ifeq (${ENABLE_PAUTH}, 1)
556 # arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the
557 # Pauth support. As it's not secure, it must be reimplemented for real platforms
558 BL_COMMON_SOURCES += lib/extensions/pauth/pauth_helpers.S
559 endif
560
561 ################################################################################
562 # Include the platform specific Makefile after the SPD Makefile (the platform
563 # makefile may use all previous definitions in this file)
564 ################################################################################
565 include ${PLAT_MAKEFILE_FULL}
566
567 ################################################################################
568 # Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from
569 # platform.
570 ################################################################################
571 include ${MAKE_HELPERS_DIRECTORY}arch_features.mk
572
573 ####################################################
574 # Enable required options for Memory Stack Tagging.
575 ####################################################
576
577 # Currently, these options are enabled only for clang and armclang compiler.
578 ifeq (${SUPPORT_STACK_MEMTAG},yes)
579 ifdef mem_tag_arch_support
580 # Check for armclang and clang compilers
581 ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
582 # Add "memtag" architecture feature modifier if not specified
583 ifeq ( ,$(findstring memtag,$(arch-features)))
584 arch-features := $(arch-features)+memtag
585 endif # memtag
586 ifeq ($($(ARCH)-cc-id),arm-clang)
587 TF_CFLAGS += -mmemtag-stack
588 else ifeq ($($(ARCH)-cc-id),llvm-clang)
589 TF_CFLAGS += -fsanitize=memtag
590 endif # armclang
591 endif
592 else
593 $(error "Error: stack memory tagging is not supported for \
594 architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
595 endif #(mem_tag_arch_support)
596 endif #(SUPPORT_STACK_MEMTAG)
597
598 ################################################################################
599 # RME dependent flags configuration, Enable optional features for RME.
600 ################################################################################
601 # FEAT_RME
602 ifeq (${ENABLE_RME},1)
603 # RME doesn't support PIE
604 ifneq (${ENABLE_PIE},0)
605 $(error ENABLE_RME does not support PIE)
606 endif
607
608 # RME requires AARCH64
609 ifneq (${ARCH},aarch64)
610 $(error ENABLE_RME requires AArch64)
611 endif
612
613 # RME requires el2 context to be saved for now.
614 CTX_INCLUDE_EL2_REGS := 1
615 CTX_INCLUDE_AARCH32_REGS := 0
616 CTX_INCLUDE_PAUTH_REGS := 1
617
618 # RME enables CSV2_2 extension by default.
619 ENABLE_FEAT_CSV2_2 = 1
620 endif #(FEAT_RME)
621
622 ################################################################################
623 # Include rmmd Makefile if RME is enabled
624 ################################################################################
625 ifneq (${ENABLE_RME},0)
626 ifneq (${ARCH},aarch64)
627 $(error ENABLE_RME requires AArch64)
628 endif
629 ifeq ($(SPMC_AT_EL3),1)
630 $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
631 endif
632
633 ifneq (${SPD}, none)
634 ifneq (${SPD}, spmd)
635 $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd)
636 endif
637 endif
638 include services/std_svc/rmmd/rmmd.mk
639 $(warning "RME is an experimental feature")
640 endif
641
642 ifeq (${CTX_INCLUDE_EL2_REGS}, 1)
643 ifeq (${SPD},none)
644 ifeq (${ENABLE_RME},0)
645 $(error CTX_INCLUDE_EL2_REGS is available only when SPD \
646 or RME is enabled)
647 endif
648 endif
649 endif
650
651 ################################################################################
652 # Make 128-Bit sysreg read/writes availabe when FEAT_D128 is enabled.
653 ################################################################################
654 ifneq (${ENABLE_FEAT_D128}, 0)
655 BL_COMMON_SOURCES += lib/extensions/sysreg128/sysreg128.S
656 endif
657
658 ################################################################################
659 # Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come
660 # up with appropriate march values for compiler.
661 ################################################################################
662 include ${MAKE_HELPERS_DIRECTORY}march.mk
663
664 TF_CFLAGS += $(march-directive)
665 ASFLAGS += $(march-directive)
666
667 # This internal flag is common option which is set to 1 for scenarios
668 # when the BL2 is running in EL3 level. This occurs in two scenarios -
669 # 4 world system running BL2 at EL3 and two world system without BL1 running
670 # BL2 in EL3
671
672 ifeq (${RESET_TO_BL2},1)
673 BL2_RUNS_AT_EL3 := 1
674 ifeq (${ENABLE_RME},1)
675 $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \
676 supported at the moment.)
677 endif
678 else ifeq (${ENABLE_RME},1)
679 BL2_RUNS_AT_EL3 := 1
680 else
681 BL2_RUNS_AT_EL3 := 0
682 endif
683
684 # This internal flag is set to 1 when Firmware First handling of External aborts
685 # is required by lowe ELs. Currently only NS requires this support.
686 ifeq ($(HANDLE_EA_EL3_FIRST_NS),1)
687 FFH_SUPPORT := 1
688 else
689 FFH_SUPPORT := 0
690 endif
691
692 ifeq (${ARM_ARCH_MAJOR},7)
693 include make_helpers/armv7-a-cpus.mk
694 endif
695
696 PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT})
697 ifneq ($(PIE_FOUND),)
698 TF_CFLAGS += -fno-PIE
699 ifeq ($($(ARCH)-ld-id),gnu-gcc)
700 TF_LDFLAGS += -no-pie
701 endif
702 endif #(PIE_FOUND)
703
704 ifeq ($($(ARCH)-ld-id),gnu-gcc)
705 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
706 else
707 PIE_LDFLAGS += -pie --no-dynamic-linker
708 endif
709
710 ifeq ($(ENABLE_PIE),1)
711 ifeq ($(RESET_TO_BL2),1)
712 ifneq ($(BL2_IN_XIP_MEM),1)
713 BL2_CPPFLAGS += -fpie
714 BL2_CFLAGS += -fpie
715 BL2_LDFLAGS += $(PIE_LDFLAGS)
716 endif #(BL2_IN_XIP_MEM)
717 endif #(RESET_TO_BL2)
718 BL31_CPPFLAGS += -fpie
719 BL31_CFLAGS += -fpie
720 BL31_LDFLAGS += $(PIE_LDFLAGS)
721
722 BL32_CPPFLAGS += -fpie
723 BL32_CFLAGS += -fpie
724 BL32_LDFLAGS += $(PIE_LDFLAGS)
725 endif #(ENABLE_PIE)
726
727 BL1_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
728 BL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
729 BL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
730
731 BL1_CPPFLAGS += -DIMAGE_AT_EL3
732 ifeq ($(RESET_TO_BL2),1)
733 BL2_CPPFLAGS += -DIMAGE_AT_EL3
734 else
735 BL2_CPPFLAGS += -DIMAGE_AT_EL1
736 endif #(RESET_TO_BL2)
737
738 ifeq (${ARCH},aarch64)
739 BL2U_CPPFLAGS += -DIMAGE_AT_EL1
740 BL31_CPPFLAGS += -DIMAGE_AT_EL3
741 BL32_CPPFLAGS += -DIMAGE_AT_EL1
742 else
743 BL32_CPPFLAGS += -DIMAGE_AT_EL3
744 endif
745
746 # Include the CPU specific operations makefile, which provides default
747 # values for all CPU errata workarounds and CPU specific optimisations.
748 # This can be overridden by the platform.
749 include lib/cpus/cpu-ops.mk
750
751 ################################################################################
752 # Build `AARCH32_SP` as BL32 image for AArch32
753 ################################################################################
754 ifeq (${ARCH},aarch32)
755 NEED_BL32 := yes
756
757 ifneq (${AARCH32_SP},none)
758 # We expect to locate an sp.mk under the specified AARCH32_SP directory
759 AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
760
761 ifeq (${AARCH32_SP_MAKE},)
762 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
763 endif
764 $(info Including ${AARCH32_SP_MAKE})
765 include ${AARCH32_SP_MAKE}
766 endif
767 endif #(ARCH=aarch32)
768
769 ################################################################################
770 # Include libc if not overridden
771 ################################################################################
772 ifeq (${OVERRIDE_LIBC},0)
773 include lib/libc/libc.mk
774 endif
775
776 ################################################################################
777 # Check incompatible options and dependencies
778 ################################################################################
779
780 # USE_DEBUGFS experimental feature recommended only in debug builds
781 ifeq (${USE_DEBUGFS},1)
782 ifeq (${DEBUG},1)
783 $(warning DEBUGFS experimental feature is enabled.)
784 else
785 $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
786 endif
787 endif #(USE_DEBUGFS)
788
789 # USE_SPINLOCK_CAS requires AArch64 build
790 ifeq (${USE_SPINLOCK_CAS},1)
791 ifneq (${ARCH},aarch64)
792 $(error USE_SPINLOCK_CAS requires AArch64)
793 endif
794 endif #(USE_SPINLOCK_CAS)
795
796 # The cert_create tool cannot generate certificates individually, so we use the
797 # target 'certificates' to create them all
798 ifneq (${GENERATE_COT},0)
799 FIP_DEPS += certificates
800 FWU_FIP_DEPS += fwu_certificates
801 endif
802
803 ifneq (${DECRYPTION_SUPPORT},none)
804 ENC_ARGS += -f ${FW_ENC_STATUS}
805 ENC_ARGS += -k ${ENC_KEY}
806 ENC_ARGS += -n ${ENC_NONCE}
807 FIP_DEPS += enctool
808 FWU_FIP_DEPS += enctool
809 endif #(DECRYPTION_SUPPORT)
810
811 ifdef EL3_PAYLOAD_BASE
812 ifdef PRELOADED_BL33_BASE
813 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
814 incompatible build options. EL3_PAYLOAD_BASE has priority.")
815 endif
816 ifneq (${GENERATE_COT},0)
817 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \
818 build options.")
819 endif
820 ifneq (${TRUSTED_BOARD_BOOT},0)
821 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \
822 incompatible \ build options.")
823 endif
824 endif #(EL3_PAYLOAD_BASE)
825
826 ifeq (${NEED_BL33},yes)
827 ifdef EL3_PAYLOAD_BASE
828 $(warning "BL33 image is not needed when option \
829 BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
830 endif
831 ifdef PRELOADED_BL33_BASE
832 $(warning "BL33 image is not needed when option \
833 PRELOADED_BL33_BASE is used and won't be added to the FIP file.")
834 endif
835 endif #(NEED_BL33)
836
837 # When building for systems with hardware-assisted coherency, there's no need to
838 # use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
839 ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
840 $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
841 endif
842
843 #For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1.
844 ifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1)
845 $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled")
846 endif
847
848 # RAS_EXTENSION is deprecated, provide alternate build options
849 ifeq ($(RAS_EXTENSION),1)
850 $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \
851 and HANDLE_EA_EL3_FIRST_NS instead")
852 endif
853
854
855 # When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled
856 ifeq ($(FAULT_INJECTION_SUPPORT),1)
857 ifeq ($(ENABLE_FEAT_RAS),0)
858 $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0)
859 endif
860 endif #(FAULT_INJECTION_SUPPORT)
861
862 # DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
863 ifeq ($(DYN_DISABLE_AUTH), 1)
864 ifeq (${TRUSTED_BOARD_BOOT}, 0)
865 $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \
866 to be set.")
867 endif
868 endif #(DYN_DISABLE_AUTH)
869
870 ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
871 # Support authentication verification and hash calculation
872 CRYPTO_SUPPORT := 3
873 else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
874 # Support authentication verification and hash calculation
875 CRYPTO_SUPPORT := 3
876 else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
877 # Support hash calculation only
878 CRYPTO_SUPPORT := 2
879 else ifeq (${TRUSTED_BOARD_BOOT},1)
880 # Support authentication verification only
881 CRYPTO_SUPPORT := 1
882 else
883 CRYPTO_SUPPORT := 0
884 endif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT))
885
886 # SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
887 ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
888 $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
889 endif
890
891 # If pointer authentication is used in the firmware, make sure that all the
892 # registers associated to it are also saved and restored.
893 # Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
894 ifeq ($(ENABLE_PAUTH),1)
895 ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
896 $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
897 endif
898 endif #(ENABLE_PAUTH)
899
900 ifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
901 ifneq (${ARCH},aarch64)
902 $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
903 endif
904 endif #(CTX_INCLUDE_PAUTH_REGS)
905
906 ifeq ($(FEATURE_DETECTION),1)
907 $(info FEATURE_DETECTION is an experimental feature)
908 endif #(FEATURE_DETECTION)
909
910 ifneq ($(ENABLE_SME2_FOR_NS), 0)
911 ifeq (${ENABLE_SME_FOR_NS}, 0)
912 $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \
913 to be set")
914 $(warning "Forced ENABLE_SME_FOR_NS=1")
915 override ENABLE_SME_FOR_NS := 1
916 endif
917 endif #(ENABLE_SME2_FOR_NS)
918
919 ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
920 ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
921 $(error "ALLOW_RO_XLAT_TABLES requires translation tables \
922 library v2")
923 endif
924 endif #(ARM_XLAT_TABLES_LIB_V1)
925
926 ifneq (${DECRYPTION_SUPPORT},none)
927 ifeq (${TRUSTED_BOARD_BOOT}, 0)
928 $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \
929 to be set)
930 endif
931 endif #(DECRYPTION_SUPPORT)
932
933 # Ensure that no Aarch64-only features are enabled in Aarch32 build
934 ifeq (${ARCH},aarch32)
935
936 # SME/SVE only supported on AArch64
937 ifneq (${ENABLE_SME_FOR_NS},0)
938 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
939 endif
940
941 ifeq (${ENABLE_SVE_FOR_NS},1)
942 # Warning instead of error due to CI dependency on this
943 $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
944 endif
945
946 # BRBE is not supported in AArch32
947 ifeq (${ENABLE_BRBE_FOR_NS},1)
948 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
949 endif
950
951 # FEAT_RNG_TRAP is not supported in AArch32
952 ifeq (${ENABLE_FEAT_RNG_TRAP},1)
953 $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
954 endif
955 endif #(ARCH=aarch32)
956
957 ifneq (${ENABLE_SME_FOR_NS},0)
958 ifeq (${ENABLE_SVE_FOR_NS},0)
959 $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS")
960 endif
961 endif #(ENABLE_SME_FOR_NS)
962
963 # Secure SME/SVE requires the non-secure component as well
964 ifeq (${ENABLE_SME_FOR_SWD},1)
965 ifeq (${ENABLE_SME_FOR_NS},0)
966 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
967 endif
968 ifeq (${ENABLE_SVE_FOR_SWD},0)
969 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD")
970 endif
971 endif #(ENABLE_SME_FOR_SWD)
972
973 # Enabling SVE for SWD requires enabling SVE for NWD due to ENABLE_FEAT
974 # mechanism.
975 ifeq (${ENABLE_SVE_FOR_SWD},1)
976 ifeq (${ENABLE_SVE_FOR_NS},0)
977 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
978 endif
979 endif
980
981 # Enabling SVE for both the worlds typically requires the context
982 # management of SVE registers. The only exception being SPMC at S-EL2.
983 ifeq (${ENABLE_SVE_FOR_SWD}, 1)
984 ifneq (${ENABLE_SVE_FOR_NS}, 0)
985 ifeq (${CTX_INCLUDE_SVE_REGS}-$(SPMD_SPM_AT_SEL2),0-0)
986 $(warning "ENABLE_SVE_FOR_SWD and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
987 endif
988 endif
989 endif
990
991 # Enabling SVE in either world while enabling CTX_INCLUDE_FPREGS requires
992 # CTX_INCLUDE_SVE_REGS to be enabled due to architectural dependency between FP
993 # and SVE registers.
994 ifeq (${CTX_INCLUDE_FPREGS}, 1)
995 ifneq (${ENABLE_SVE_FOR_NS},0)
996 ifeq (${CTX_INCLUDE_SVE_REGS},0)
997 # Warning instead of error due to CI dependency on this
998 $(warning "CTX_INCLUDE_FPREGS and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
999 $(warning "Forced ENABLE_SVE_FOR_NS=0")
1000 override ENABLE_SVE_FOR_NS := 0
1001 endif
1002 endif
1003 endif #(CTX_INCLUDE_FPREGS)
1004
1005 # SVE context management is only required if secure world has access to SVE/FP
1006 # functionality.
1007 ifeq (${CTX_INCLUDE_SVE_REGS},1)
1008 ifeq (${ENABLE_SVE_FOR_SWD},0)
1009 $(error "CTX_INCLUDE_SVE_REGS requires ENABLE_SVE_FOR_SWD to also be enabled")
1010 endif
1011 endif
1012
1013 # SME cannot be used with CTX_INCLUDE_FPREGS since SPM does its own context
1014 # management including FPU registers.
1015 ifeq (${CTX_INCLUDE_FPREGS},1)
1016 ifneq (${ENABLE_SME_FOR_NS},0)
1017 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1018 endif
1019 endif #(CTX_INCLUDE_FPREGS)
1020
1021 ifeq ($(DRTM_SUPPORT),1)
1022 $(info DRTM_SUPPORT is an experimental feature)
1023 endif
1024
1025 ifeq (${TRANSFER_LIST},1)
1026 $(info TRANSFER_LIST is an experimental feature)
1027 endif
1028
1029 ifeq (${ENABLE_RME},1)
1030 ifneq (${SEPARATE_CODE_AND_RODATA},1)
1031 $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
1032 endif
1033 endif
1034
1035 ifeq ($(PSA_CRYPTO),1)
1036 $(info PSA_CRYPTO is an experimental feature)
1037 endif
1038
1039 ifeq ($(DICE_PROTECTION_ENVIRONMENT),1)
1040 $(info DICE_PROTECTION_ENVIRONMENT is an experimental feature)
1041 endif
1042
1043 ################################################################################
1044 # Process platform overrideable behaviour
1045 ################################################################################
1046
1047 ifdef BL1_SOURCES
1048 NEED_BL1 := yes
1049 endif #(BL1_SOURCES)
1050
1051 ifdef BL2_SOURCES
1052 NEED_BL2 := yes
1053
1054 # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
1055 # Certificate generation tools. This flag can be overridden by the platform.
1056 ifdef EL3_PAYLOAD_BASE
1057 # If booting an EL3 payload there is no need for a BL33 image
1058 # in the FIP file.
1059 NEED_BL33 := no
1060 else
1061 ifdef PRELOADED_BL33_BASE
1062 # If booting a BL33 preloaded image there is no need of
1063 # another one in the FIP file.
1064 NEED_BL33 := no
1065 else
1066 NEED_BL33 ?= yes
1067 endif
1068 endif
1069 endif #(BL2_SOURCES)
1070
1071 ifdef BL2U_SOURCES
1072 NEED_BL2U := yes
1073 endif #(BL2U_SOURCES)
1074
1075 # If SCP_BL2 is given, we always want FIP to include it.
1076 ifdef SCP_BL2
1077 NEED_SCP_BL2 := yes
1078 endif #(SCP_BL2)
1079
1080 # For AArch32, BL31 is not currently supported.
1081 ifneq (${ARCH},aarch32)
1082 ifdef BL31_SOURCES
1083 # When booting an EL3 payload, there is no need to compile the BL31
1084 # image nor put it in the FIP.
1085 ifndef EL3_PAYLOAD_BASE
1086 NEED_BL31 := yes
1087 endif
1088 endif
1089 endif #(ARCH=aarch64)
1090
1091 # Process TBB related flags
1092 ifneq (${GENERATE_COT},0)
1093 # Common cert_create options
1094 ifneq (${CREATE_KEYS},0)
1095 $(eval CRT_ARGS += -n)
1096 $(eval FWU_CRT_ARGS += -n)
1097 ifneq (${SAVE_KEYS},0)
1098 $(eval CRT_ARGS += -k)
1099 $(eval FWU_CRT_ARGS += -k)
1100 endif
1101 endif
1102 # Include TBBR makefile (unless the platform indicates otherwise)
1103 ifeq (${INCLUDE_TBBR_MK},1)
1104 include make_helpers/tbbr/tbbr_tools.mk
1105 endif
1106 endif #(GENERATE_COT)
1107
1108 ifneq (${FIP_ALIGN},0)
1109 FIP_ARGS += --align ${FIP_ALIGN}
1110 endif #(FIP_ALIGN)
1111
1112 ifdef FDT_SOURCES
1113 NEED_FDT := yes
1114 endif #(FDT_SOURCES)
1115
1116 ################################################################################
1117 # Include libraries' Makefile that are used in all BL
1118 ################################################################################
1119
1120 include lib/stack_protector/stack_protector.mk
1121
1122 ################################################################################
1123 # Include BL specific makefiles
1124 ################################################################################
1125
1126 ifeq (${NEED_BL1},yes)
1127 include bl1/bl1.mk
1128 endif
1129
1130 ifeq (${NEED_BL2},yes)
1131 include bl2/bl2.mk
1132 endif
1133
1134 ifeq (${NEED_BL2U},yes)
1135 include bl2u/bl2u.mk
1136 endif
1137
1138 ifeq (${NEED_BL31},yes)
1139 include bl31/bl31.mk
1140 endif
1141
1142 ################################################################################
1143 # Build options checks
1144 ################################################################################
1145
1146 # Boolean_Flags
1147 $(eval $(call assert_booleans,\
1148 $(sort \
1149 ALLOW_RO_XLAT_TABLES \
1150 BL2_ENABLE_SP_LOAD \
1151 COLD_BOOT_SINGLE_CPU \
1152 CREATE_KEYS \
1153 CTX_INCLUDE_AARCH32_REGS \
1154 CTX_INCLUDE_FPREGS \
1155 CTX_INCLUDE_SVE_REGS \
1156 CTX_INCLUDE_EL2_REGS \
1157 CTX_INCLUDE_MPAM_REGS \
1158 DEBUG \
1159 DYN_DISABLE_AUTH \
1160 EL3_EXCEPTION_HANDLING \
1161 ENABLE_AMU_AUXILIARY_COUNTERS \
1162 ENABLE_AMU_FCONF \
1163 AMU_RESTRICT_COUNTERS \
1164 ENABLE_ASSERTIONS \
1165 ENABLE_PIE \
1166 ENABLE_PMF \
1167 ENABLE_PSCI_STAT \
1168 ENABLE_RUNTIME_INSTRUMENTATION \
1169 ENABLE_SME_FOR_SWD \
1170 ENABLE_SVE_FOR_SWD \
1171 ENABLE_FEAT_RAS \
1172 FFH_SUPPORT \
1173 ERROR_DEPRECATED \
1174 FAULT_INJECTION_SUPPORT \
1175 GENERATE_COT \
1176 GICV2_G0_FOR_EL3 \
1177 HANDLE_EA_EL3_FIRST_NS \
1178 HARDEN_SLS \
1179 HW_ASSISTED_COHERENCY \
1180 MEASURED_BOOT \
1181 DICE_PROTECTION_ENVIRONMENT \
1182 RMMD_ENABLE_EL3_TOKEN_SIGN \
1183 DRTM_SUPPORT \
1184 NS_TIMER_SWITCH \
1185 OVERRIDE_LIBC \
1186 PL011_GENERIC_UART \
1187 PROGRAMMABLE_RESET_ADDRESS \
1188 PSCI_EXTENDED_STATE_ID \
1189 PSCI_OS_INIT_MODE \
1190 RESET_TO_BL31 \
1191 SAVE_KEYS \
1192 SEPARATE_CODE_AND_RODATA \
1193 SEPARATE_BL2_NOLOAD_REGION \
1194 SEPARATE_NOBITS_REGION \
1195 SEPARATE_RWDATA_REGION \
1196 SEPARATE_SIMD_SECTION \
1197 SPIN_ON_BL1_EXIT \
1198 SPM_MM \
1199 SPMC_AT_EL3 \
1200 SPMC_AT_EL3_SEL0_SP \
1201 SPMD_SPM_AT_SEL2 \
1202 ENABLE_SPMD_LP \
1203 TRANSFER_LIST \
1204 TRUSTED_BOARD_BOOT \
1205 USE_COHERENT_MEM \
1206 USE_DEBUGFS \
1207 ARM_IO_IN_DTB \
1208 SDEI_IN_FCONF \
1209 SEC_INT_DESC_IN_FCONF \
1210 USE_ROMLIB \
1211 USE_TBBR_DEFS \
1212 WARMBOOT_ENABLE_DCACHE_EARLY \
1213 RESET_TO_BL2 \
1214 BL2_IN_XIP_MEM \
1215 BL2_INV_DCACHE \
1216 USE_SPINLOCK_CAS \
1217 ENCRYPT_BL31 \
1218 ENCRYPT_BL32 \
1219 ERRATA_SPECULATIVE_AT \
1220 RAS_TRAP_NS_ERR_REC_ACCESS \
1221 COT_DESC_IN_DTB \
1222 USE_SP804_TIMER \
1223 PSA_FWU_SUPPORT \
1224 PSA_FWU_METADATA_FW_STORE_DESC \
1225 ENABLE_MPMM \
1226 ENABLE_MPMM_FCONF \
1227 FEATURE_DETECTION \
1228 TRNG_SUPPORT \
1229 ERRATA_ABI_SUPPORT \
1230 ERRATA_NON_ARM_INTERCONNECT \
1231 CONDITIONAL_CMO \
1232 PSA_CRYPTO \
1233 ENABLE_CONSOLE_GETC \
1234 INIT_UNUSED_NS_EL2 \
1235 PLATFORM_REPORT_CTX_MEM_USE \
1236 EARLY_CONSOLE \
1237 PRESERVE_DSU_PMU_REGS \
1238 )))
1239
1240 # Numeric_Flags
1241 $(eval $(call assert_numerics,\
1242 $(sort \
1243 ARM_ARCH_MAJOR \
1244 ARM_ARCH_MINOR \
1245 BRANCH_PROTECTION \
1246 CTX_INCLUDE_PAUTH_REGS \
1247 CTX_INCLUDE_NEVE_REGS \
1248 CRYPTO_SUPPORT \
1249 DISABLE_MTPMU \
1250 ENABLE_BRBE_FOR_NS \
1251 ENABLE_TRBE_FOR_NS \
1252 ENABLE_BTI \
1253 ENABLE_PAUTH \
1254 ENABLE_FEAT_AMU \
1255 ENABLE_FEAT_AMUv1p1 \
1256 ENABLE_FEAT_CSV2_2 \
1257 ENABLE_FEAT_CSV2_3 \
1258 ENABLE_FEAT_DEBUGV8P9 \
1259 ENABLE_FEAT_DIT \
1260 ENABLE_FEAT_ECV \
1261 ENABLE_FEAT_FGT \
1262 ENABLE_FEAT_FGT2 \
1263 ENABLE_FEAT_HCX \
1264 ENABLE_FEAT_LS64_ACCDATA \
1265 ENABLE_FEAT_MTE2 \
1266 ENABLE_FEAT_PAN \
1267 ENABLE_FEAT_RNG \
1268 ENABLE_FEAT_RNG_TRAP \
1269 ENABLE_FEAT_SEL2 \
1270 ENABLE_FEAT_TCR2 \
1271 ENABLE_FEAT_THE \
1272 ENABLE_FEAT_SB \
1273 ENABLE_FEAT_S2PIE \
1274 ENABLE_FEAT_S1PIE \
1275 ENABLE_FEAT_S2POE \
1276 ENABLE_FEAT_S1POE \
1277 ENABLE_FEAT_SCTLR2 \
1278 ENABLE_FEAT_D128 \
1279 ENABLE_FEAT_GCS \
1280 ENABLE_FEAT_VHE \
1281 ENABLE_FEAT_MPAM \
1282 ENABLE_RME \
1283 ENABLE_SPE_FOR_NS \
1284 ENABLE_SYS_REG_TRACE_FOR_NS \
1285 ENABLE_SME_FOR_NS \
1286 ENABLE_SME2_FOR_NS \
1287 ENABLE_SVE_FOR_NS \
1288 ENABLE_TRF_FOR_NS \
1289 FW_ENC_STATUS \
1290 NR_OF_FW_BANKS \
1291 NR_OF_IMAGES_IN_FW_BANK \
1292 TWED_DELAY \
1293 ENABLE_FEAT_TWED \
1294 SVE_VECTOR_LEN \
1295 IMPDEF_SYSREG_TRAP \
1296 )))
1297
1298 ifdef KEY_SIZE
1299 $(eval $(call assert_numeric,KEY_SIZE))
1300 endif
1301
1302 ifeq ($(filter $(SANITIZE_UB), on off trap),)
1303 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
1304 endif
1305
1306 ################################################################################
1307 # Add definitions to the cpp preprocessor based on the current build options.
1308 # This is done after including the platform specific makefile to allow the
1309 # platform to overwrite the default options
1310 ################################################################################
1311
1312 $(eval $(call add_defines,\
1313 $(sort \
1314 ALLOW_RO_XLAT_TABLES \
1315 ARM_ARCH_MAJOR \
1316 ARM_ARCH_MINOR \
1317 BL2_ENABLE_SP_LOAD \
1318 COLD_BOOT_SINGLE_CPU \
1319 CTX_INCLUDE_AARCH32_REGS \
1320 CTX_INCLUDE_FPREGS \
1321 CTX_INCLUDE_SVE_REGS \
1322 CTX_INCLUDE_PAUTH_REGS \
1323 CTX_INCLUDE_MPAM_REGS \
1324 EL3_EXCEPTION_HANDLING \
1325 CTX_INCLUDE_EL2_REGS \
1326 CTX_INCLUDE_NEVE_REGS \
1327 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
1328 DISABLE_MTPMU \
1329 ENABLE_FEAT_AMU \
1330 ENABLE_AMU_AUXILIARY_COUNTERS \
1331 ENABLE_AMU_FCONF \
1332 AMU_RESTRICT_COUNTERS \
1333 ENABLE_ASSERTIONS \
1334 ENABLE_BTI \
1335 ENABLE_FEAT_DEBUGV8P9 \
1336 ENABLE_FEAT_MPAM \
1337 ENABLE_PAUTH \
1338 ENABLE_PIE \
1339 ENABLE_PMF \
1340 ENABLE_PSCI_STAT \
1341 ENABLE_RME \
1342 RMMD_ENABLE_EL3_TOKEN_SIGN \
1343 ENABLE_RUNTIME_INSTRUMENTATION \
1344 ENABLE_SME_FOR_NS \
1345 ENABLE_SME2_FOR_NS \
1346 ENABLE_SME_FOR_SWD \
1347 ENABLE_SPE_FOR_NS \
1348 ENABLE_SVE_FOR_NS \
1349 ENABLE_SVE_FOR_SWD \
1350 ENABLE_FEAT_RAS \
1351 FFH_SUPPORT \
1352 ENCRYPT_BL31 \
1353 ENCRYPT_BL32 \
1354 ERROR_DEPRECATED \
1355 FAULT_INJECTION_SUPPORT \
1356 GICV2_G0_FOR_EL3 \
1357 HANDLE_EA_EL3_FIRST_NS \
1358 HW_ASSISTED_COHERENCY \
1359 LOG_LEVEL \
1360 MEASURED_BOOT \
1361 DICE_PROTECTION_ENVIRONMENT \
1362 DRTM_SUPPORT \
1363 NS_TIMER_SWITCH \
1364 PL011_GENERIC_UART \
1365 PLAT_${PLAT} \
1366 PROGRAMMABLE_RESET_ADDRESS \
1367 PSCI_EXTENDED_STATE_ID \
1368 PSCI_OS_INIT_MODE \
1369 RESET_TO_BL31 \
1370 RME_GPT_BITLOCK_BLOCK \
1371 RME_GPT_MAX_BLOCK \
1372 SEPARATE_CODE_AND_RODATA \
1373 SEPARATE_BL2_NOLOAD_REGION \
1374 SEPARATE_NOBITS_REGION \
1375 SEPARATE_RWDATA_REGION \
1376 SEPARATE_SIMD_SECTION \
1377 RECLAIM_INIT_CODE \
1378 SPD_${SPD} \
1379 SPIN_ON_BL1_EXIT \
1380 SPM_MM \
1381 SPMC_AT_EL3 \
1382 SPMC_AT_EL3_SEL0_SP \
1383 SPMD_SPM_AT_SEL2 \
1384 TRANSFER_LIST \
1385 TRUSTED_BOARD_BOOT \
1386 CRYPTO_SUPPORT \
1387 TRNG_SUPPORT \
1388 ERRATA_ABI_SUPPORT \
1389 ERRATA_NON_ARM_INTERCONNECT \
1390 USE_COHERENT_MEM \
1391 USE_DEBUGFS \
1392 ARM_IO_IN_DTB \
1393 SDEI_IN_FCONF \
1394 SEC_INT_DESC_IN_FCONF \
1395 USE_ROMLIB \
1396 USE_TBBR_DEFS \
1397 WARMBOOT_ENABLE_DCACHE_EARLY \
1398 RESET_TO_BL2 \
1399 BL2_RUNS_AT_EL3 \
1400 BL2_IN_XIP_MEM \
1401 BL2_INV_DCACHE \
1402 USE_SPINLOCK_CAS \
1403 ERRATA_SPECULATIVE_AT \
1404 RAS_TRAP_NS_ERR_REC_ACCESS \
1405 COT_DESC_IN_DTB \
1406 USE_SP804_TIMER \
1407 ENABLE_FEAT_RNG \
1408 ENABLE_FEAT_RNG_TRAP \
1409 ENABLE_FEAT_SB \
1410 ENABLE_FEAT_DIT \
1411 NR_OF_FW_BANKS \
1412 NR_OF_IMAGES_IN_FW_BANK \
1413 PSA_FWU_SUPPORT \
1414 PSA_FWU_METADATA_FW_STORE_DESC \
1415 ENABLE_BRBE_FOR_NS \
1416 ENABLE_TRBE_FOR_NS \
1417 ENABLE_SYS_REG_TRACE_FOR_NS \
1418 ENABLE_TRF_FOR_NS \
1419 ENABLE_FEAT_HCX \
1420 ENABLE_MPMM \
1421 ENABLE_MPMM_FCONF \
1422 ENABLE_FEAT_FGT \
1423 ENABLE_FEAT_FGT2 \
1424 ENABLE_FEAT_ECV \
1425 ENABLE_FEAT_AMUv1p1 \
1426 ENABLE_FEAT_SEL2 \
1427 ENABLE_FEAT_VHE \
1428 ENABLE_FEAT_CSV2_2 \
1429 ENABLE_FEAT_CSV2_3 \
1430 ENABLE_FEAT_LS64_ACCDATA \
1431 ENABLE_FEAT_PAN \
1432 ENABLE_FEAT_TCR2 \
1433 ENABLE_FEAT_THE \
1434 ENABLE_FEAT_S2PIE \
1435 ENABLE_FEAT_S1PIE \
1436 ENABLE_FEAT_S2POE \
1437 ENABLE_FEAT_S1POE \
1438 ENABLE_FEAT_SCTLR2 \
1439 ENABLE_FEAT_D128 \
1440 ENABLE_FEAT_GCS \
1441 ENABLE_FEAT_MTE2 \
1442 FEATURE_DETECTION \
1443 TWED_DELAY \
1444 ENABLE_FEAT_TWED \
1445 CONDITIONAL_CMO \
1446 IMPDEF_SYSREG_TRAP \
1447 SVE_VECTOR_LEN \
1448 ENABLE_SPMD_LP \
1449 PSA_CRYPTO \
1450 ENABLE_CONSOLE_GETC \
1451 INIT_UNUSED_NS_EL2 \
1452 PLATFORM_REPORT_CTX_MEM_USE \
1453 EARLY_CONSOLE \
1454 PRESERVE_DSU_PMU_REGS \
1455 )))
1456
1457 ifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1)
1458 ifeq (${DEBUG}, 0)
1459 $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only")
1460 override PLATFORM_REPORT_CTX_MEM_USE := 0
1461 endif
1462 endif
1463
1464 ifeq (${SANITIZE_UB},trap)
1465 $(eval $(call add_define,MONITOR_TRAPS))
1466 endif #(SANITIZE_UB)
1467
1468 # Define the EL3_PAYLOAD_BASE flag only if it is provided.
1469 ifdef EL3_PAYLOAD_BASE
1470 $(eval $(call add_define,EL3_PAYLOAD_BASE))
1471 else
1472 # Define the PRELOADED_BL33_BASE flag only if it is provided and
1473 # EL3_PAYLOAD_BASE is not defined, as it has priority.
1474 ifdef PRELOADED_BL33_BASE
1475 $(eval $(call add_define,PRELOADED_BL33_BASE))
1476 endif
1477 endif #(EL3_PAYLOAD_BASE)
1478
1479 # Define the DYN_DISABLE_AUTH flag only if set.
1480 ifeq (${DYN_DISABLE_AUTH},1)
1481 $(eval $(call add_define,DYN_DISABLE_AUTH))
1482 endif
1483
1484 ifeq ($($(ARCH)-ld-id),arm-link)
1485 $(eval $(call add_define,USE_ARM_LINK))
1486 endif
1487
1488 # Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
1489 ifeq (${SPD},spmd)
1490 ifdef SP_LAYOUT_FILE
1491 -include $(BUILD_PLAT)/sp_gen.mk
1492 FIP_DEPS += sp
1493 CRT_DEPS += sp
1494 NEED_SP_PKG := yes
1495 else
1496 ifeq (${SPMD_SPM_AT_SEL2},1)
1497 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1498 endif
1499 endif #(SP_LAYOUT_FILE)
1500 endif #(SPD)
1501
1502 ################################################################################
1503 # Build targets
1504 ################################################################################
1505
1506 .PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp tl fwu_fip certtool dtbs memmap doc enctool
1507 .SUFFIXES:
1508
1509 all: msg_start
1510
1511 msg_start:
1512 $(s)echo "Building ${PLAT}"
1513
1514 ifeq (${ERROR_DEPRECATED},0)
1515 # Check if deprecated declarations and cpp warnings should be treated as error or not.
1516 ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
1517 CPPFLAGS += -Wno-error=deprecated-declarations
1518 else
1519 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp
1520 endif
1521 endif #(!ERROR_DEPRECATED)
1522
1523 $(eval $(call MAKE_LIB,c))
1524
1525 # Expand build macros for the different images
1526 ifeq (${NEED_BL1},yes)
1527 BL1_SOURCES := $(sort ${BL1_SOURCES})
1528 $(eval $(call MAKE_BL,bl1))
1529 endif #(NEED_BL1)
1530
1531 ifeq (${NEED_BL2},yes)
1532
1533 ifeq (${RESET_TO_BL2}, 0)
1534 FIP_BL2_ARGS := tb-fw
1535 endif
1536
1537 BL2_SOURCES := $(sort ${BL2_SOURCES})
1538
1539 $(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
1540 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
1541
1542 endif #(NEED_BL2)
1543
1544 ifeq (${NEED_SCP_BL2},yes)
1545 $(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
1546 endif #(NEED_SCP_BL2)
1547
1548 ifeq (${NEED_BL31},yes)
1549 BL31_SOURCES += ${SPD_SOURCES}
1550 # Sort BL31 source files to remove duplicates
1551 BL31_SOURCES := $(sort ${BL31_SOURCES})
1552 ifneq (${DECRYPTION_SUPPORT},none)
1553 $(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
1554 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
1555 else
1556 $(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
1557 $(eval $(call MAKE_BL,bl31,soc-fw)))
1558 endif #(DECRYPTION_SUPPORT)
1559 endif #(NEED_BL31)
1560
1561 # If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
1562 # build system will call TOOL_ADD_IMG to print a warning message and abort the
1563 # process. Note that the dependency on BL32 applies to the FIP only.
1564 ifeq (${NEED_BL32},yes)
1565 # Sort BL32 source files to remove duplicates
1566 BL32_SOURCES := $(sort ${BL32_SOURCES})
1567 BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
1568
1569 ifneq (${DECRYPTION_SUPPORT},none)
1570 $(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
1571 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1572 else
1573 $(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
1574 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
1575 endif #(DECRYPTION_SUPPORT)
1576 endif #(NEED_BL32)
1577
1578 # If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
1579 # needs to be built from RMM_SOURCES.
1580 ifeq (${NEED_RMM},yes)
1581 # Sort RMM source files to remove duplicates
1582 RMM_SOURCES := $(sort ${RMM_SOURCES})
1583 BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
1584
1585 $(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
1586 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1587 endif #(NEED_RMM)
1588
1589 # Add the BL33 image if required by the platform
1590 ifeq (${NEED_BL33},yes)
1591 $(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
1592 endif #(NEED_BL33)
1593
1594 ifeq (${NEED_BL2U},yes)
1595 $(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
1596 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
1597 endif #(NEED_BL2U)
1598
1599 # Expand build macros for the different images
1600 ifeq (${NEED_FDT},yes)
1601 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
1602 endif #(NEED_FDT)
1603
1604 # Add Secure Partition packages
1605 ifeq (${NEED_SP_PKG},yes)
1606 $(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | $$(@D)/
1607 $(q)${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
1608 sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
1609 $(s)echo
1610 $(s)echo "Built SP Images successfully"
1611 $(s)echo
1612 endif #(NEED_SP_PKG)
1613
1614 locate-checkpatch:
1615 ifndef CHECKPATCH
1616 $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
1617 else
1618 ifeq (,$(wildcard ${CHECKPATCH}))
1619 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
1620 endif
1621 endif #(CHECKPATCH)
1622
1623 clean:
1624 $(s)echo " CLEAN"
1625 $(call SHELL_REMOVE_DIR,${BUILD_PLAT})
1626 ifdef UNIX_MK
1627 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
1628 else
1629 # Clear the MAKEFLAGS as we do not want
1630 # to pass the gnumake flags to nmake.
1631 $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
1632 endif #(UNIX_MK)
1633 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
1634 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
1635 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
1636
1637 realclean distclean:
1638 $(s)echo " REALCLEAN"
1639 $(call SHELL_REMOVE_DIR,${BUILD_BASE})
1640 $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
1641 ifdef UNIX_MK
1642 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
1643 else
1644 # Clear the MAKEFLAGS as we do not want
1645 # to pass the gnumake flags to nmake.
1646 $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean
1647 endif #(UNIX_MK)
1648 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
1649 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
1650 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
1651
1652 checkcodebase: locate-checkpatch
1653 $(s)echo " CHECKING STYLE"
1654 $(q)if test -d .git ; then \
1655 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \
1656 while read GIT_FILE ; \
1657 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
1658 done ; \
1659 else \
1660 find . -type f -not -iwholename "*.git*" \
1661 -not -iwholename "*build*" \
1662 -not -iwholename "*libfdt*" \
1663 -not -iwholename "*libc*" \
1664 -not -iwholename "*docs*" \
1665 -not -iwholename "*.rst" \
1666 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
1667 fi
1668
1669 checkpatch: locate-checkpatch
1670 $(s)echo " CHECKING STYLE"
1671 $(q)if test -n "${CHECKPATCH_OPTS}"; then \
1672 echo " with ${CHECKPATCH_OPTS} option(s)"; \
1673 fi
1674 $(q)COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
1675 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \
1676 do \
1677 printf "\n[*] Checking style of '$$commit'\n\n"; \
1678 ( git log --format=email "$$commit~..$$commit" \
1679 -- ${CHECK_PATHS} ; \
1680 git diff --format=email "$$commit~..$$commit" \
1681 -- ${CHECK_PATHS}; ) | \
1682 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
1683 done
1684
1685 certtool: ${CRTTOOL}
1686
1687 ${CRTTOOL}: FORCE
1688 $(q)${MAKE} PLAT=${PLAT} USE_TBBR_DEFS=${USE_TBBR_DEFS} COT=${COT} OPENSSL_DIR=${OPENSSL_DIR} CRTTOOL=${CRTTOOL} DEBUG=${DEBUG} --no-print-directory -C ${CRTTOOLPATH} all
1689 $(s)echo
1690 $(s)echo "Built $@ successfully"
1691 $(s)echo
1692
1693 ifneq (${GENERATE_COT},0)
1694 certificates: ${CRT_DEPS} ${CRTTOOL}
1695 $(q)${CRTTOOL} ${CRT_ARGS}
1696 $(s)echo
1697 $(s)echo "Built $@ successfully"
1698 $(s)echo "Certificates can be found in ${BUILD_PLAT}"
1699 $(s)echo
1700 endif #(GENERATE_COT)
1701
1702 ${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
1703 $(eval ${CHECK_FIP_CMD})
1704 $(q)${FIPTOOL} create ${FIP_ARGS} $@
1705 $(q)${FIPTOOL} info $@
1706 $(s)echo
1707 $(s)echo "Built $@ successfully"
1708 $(s)echo
1709
1710 ifneq (${GENERATE_COT},0)
1711 fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
1712 $(q)${CRTTOOL} ${FWU_CRT_ARGS}
1713 $(s)echo
1714 $(s)echo "Built $@ successfully"
1715 $(s)echo "FWU certificates can be found in ${BUILD_PLAT}"
1716 $(s)echo
1717 endif #(GENERATE_COT)
1718
1719 ${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
1720 $(eval ${CHECK_FWU_FIP_CMD})
1721 $(q)${FIPTOOL} create ${FWU_FIP_ARGS} $@
1722 $(q)${FIPTOOL} info $@
1723 $(s)echo
1724 $(s)echo "Built $@ successfully"
1725 $(s)echo
1726
1727 fiptool: ${FIPTOOL}
1728 fip: ${BUILD_PLAT}/${FIP_NAME}
1729 fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
1730
1731 ${FIPTOOL}: FORCE
1732 ifdef UNIX_MK
1733 $(q)${MAKE} PLAT=${PLAT} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${FIPTOOLPATH} all
1734 else
1735 # Clear the MAKEFLAGS as we do not want
1736 # to pass the gnumake flags to nmake.
1737 $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
1738 endif #(UNIX_MK)
1739
1740 romlib.bin: libraries FORCE
1741 $(q)${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES=$(call escape-shell,$(INCLUDES)) DEFINES=$(call escape-shell,$(DEFINES)) --no-print-directory -C ${ROMLIBPATH} all
1742
1743 memmap: all
1744 ifdef UNIX_MK
1745 $(q)PYTHONPATH=${CURDIR}/tools/memory \
1746 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1747 else
1748 $(q)set PYTHONPATH=${CURDIR}/tools/memory && \
1749 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1750 endif
1751
1752 tl: ${BUILD_PLAT}/tl.bin
1753 ${BUILD_PLAT}/tl.bin: ${HW_CONFIG}
1754 $(if $(host-poetry),$(q)poetry -q install)
1755 $(q)$(if $(host-poetry),poetry run )tlc create --fdt $< -s ${FW_HANDOFF_SIZE} $@
1756
1757 doc:
1758 $(s)echo " BUILD DOCUMENTATION"
1759 $(q)${MAKE} --no-print-directory -C ${DOCS_PATH} html
1760
1761 enctool: ${ENCTOOL}
1762
1763 ${ENCTOOL}: FORCE
1764 $(q)${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} --no-print-directory -C ${ENCTOOLPATH} all
1765 $(s)echo
1766 $(s)echo "Built $@ successfully"
1767 $(s)echo
1768
1769 cscope:
1770 $(s)echo " CSCOPE"
1771 $(q)find ${CURDIR} -name "*.[chsS]" > cscope.files
1772 $(q)cscope -b -q -k
1773
1774 help:
1775 $(s)echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
1776 $(s)echo ""
1777 $(s)echo "PLAT is used to specify which platform you wish to build."
1778 $(s)echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
1779 $(s)echo ""
1780 $(s)echo "platform = ${PLATFORM_LIST}"
1781 $(s)echo ""
1782 $(s)echo "Please refer to the User Guide for a list of all supported options."
1783 $(s)echo "Note that the build system doesn't track dependencies for build "
1784 $(s)echo "options. Therefore, if any of the build options are changed "
1785 $(s)echo "from a previous build, a clean build must be performed."
1786 $(s)echo ""
1787 $(s)echo "Supported Targets:"
1788 $(s)echo " all Build all individual bootloader binaries"
1789 $(s)echo " bl1 Build the BL1 binary"
1790 $(s)echo " bl2 Build the BL2 binary"
1791 $(s)echo " bl2u Build the BL2U binary"
1792 $(s)echo " bl31 Build the BL31 binary"
1793 $(s)echo " bl32 Build the BL32 binary. If ARCH=aarch32, then "
1794 $(s)echo " this builds secure payload specified by AARCH32_SP"
1795 $(s)echo " certificates Build the certificates (requires 'GENERATE_COT=1')"
1796 $(s)echo " fip Build the Firmware Image Package (FIP)"
1797 $(s)echo " fwu_fip Build the FWU Firmware Image Package (FIP)"
1798 $(s)echo " checkcodebase Check the coding style of the entire source tree"
1799 $(s)echo " checkpatch Check the coding style on changes in the current"
1800 $(s)echo " branch against BASE_COMMIT (default origin/master)"
1801 $(s)echo " clean Clean the build for the selected platform"
1802 $(s)echo " cscope Generate cscope index"
1803 $(s)echo " distclean Remove all build artifacts for all platforms"
1804 $(s)echo " certtool Build the Certificate generation tool"
1805 $(s)echo " enctool Build the Firmware encryption tool"
1806 $(s)echo " fiptool Build the Firmware Image Package (FIP) creation tool"
1807 $(s)echo " sp Build the Secure Partition Packages"
1808 $(s)echo " sptool Build the Secure Partition Package creation tool"
1809 $(s)echo " dtbs Build the Device Tree Blobs (if required for the platform)"
1810 $(s)echo " memmap Print the memory map of the built binaries"
1811 $(s)echo " doc Build html based documentation using Sphinx tool"
1812 $(s)echo ""
1813 $(s)echo "Note: most build targets require PLAT to be set to a specific platform."
1814 $(s)echo ""
1815 $(s)echo "example: build all targets for the FVP platform:"
1816 $(s)echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
1817
1818 .PHONY: FORCE
1819 FORCE:;