blob: 97a42ac0c8a3e89f5fe64e68c9994bc41a379f58 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001#
Chris Kayfaab7482025-01-13 15:57:32 +00002# Copyright (c) 2013-2025, Arm Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003#
dp-armfa3cf0b2017-05-03 09:38:09 +01004# SPDX-License-Identifier: BSD-3-Clause
Achin Gupta4f6ad662013-10-25 09:08:21 +01005#
6
Jeenu Viswambharan19a0ace2014-05-15 14:40:58 +01007#
Juan Castillo04be3a52014-06-30 11:41:46 +01008# Trusted Firmware Version
9#
Soby Mathewd42eaee2018-10-01 16:16:34 +010010VERSION_MAJOR := 2
Govindraj Rajacf5f9802024-11-15 09:56:50 +010011VERSION_MINOR := 12
Yann Gautier5f4cbed2024-02-08 18:40:27 +010012# VERSION_PATCH is only used for LTS releases
13VERSION_PATCH := 0
Yann Gautier57078a92023-10-03 11:09:07 +020014VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
Juan Castillo04be3a52014-06-30 11:41:46 +010015
Juan Castillo396644b2015-10-22 11:34:44 +010016# Default goal is build all images
17.DEFAULT_GOAL := all
18
Douglas Raillard527cd902016-12-28 14:47:50 +000019# Avoid any implicit propagation of command line variable definitions to
20# sub-Makefiles, like CFLAGS that we reserved for the firmware images'
21# usage. Other command line options like "-s" are still propagated as usual.
22MAKEOVERRIDES =
23
Evan Lloydf2697142015-12-02 18:17:37 +000024MAKE_HELPERS_DIRECTORY := make_helpers/
25include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
Chris Kay1559f642024-06-04 00:04:48 +000026include ${MAKE_HELPERS_DIRECTORY}build-rules.mk
Chris Kay1870c722024-05-02 17:52:37 +000027include ${MAKE_HELPERS_DIRECTORY}common.mk
Juan Castilloa3487d12015-08-18 14:23:04 +010028
29################################################################################
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010030# Default values for build configurations, and their dependencies
Juan Castilloa3487d12015-08-18 14:23:04 +010031################################################################################
Jeenu Viswambharan19a0ace2014-05-15 14:40:58 +010032
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010033include ${MAKE_HELPERS_DIRECTORY}defaults.mk
Andrey Skvortsov89c3a142024-02-18 11:43:12 +030034include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
35
36# To be able to set platform specific defaults
37ifneq ($(PLAT_DEFAULTS_MAKEFILE_FULL),)
38include ${PLAT_DEFAULTS_MAKEFILE_FULL}
39endif
dp-arm3cac7862016-09-19 11:18:44 +010040
Chris Kayc8a47ba2023-10-20 09:17:33 +000041################################################################################
42# Configure the toolchains used to build TF-A and its tools
43################################################################################
44
45include ${MAKE_HELPERS_DIRECTORY}toolchain.mk
46
Antonio Nino Diaz808c2292017-04-18 15:16:05 +010047# Assertions enabled for DEBUG builds by default
Antonio Nino Diaz808c2292017-04-18 15:16:05 +010048ENABLE_ASSERTIONS := ${DEBUG}
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010049ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION}
Achin Gupta4f6ad662013-10-25 09:08:21 +010050
Juan Castilloa3487d12015-08-18 14:23:04 +010051################################################################################
52# Checkpatch script options
53################################################################################
54
Sandrine Bailleux0b5a1582016-06-02 11:19:59 +010055CHECKCODE_ARGS := --no-patch
Dan Handleyd7b59e42016-06-02 17:15:13 +010056# Do not check the coding style on imported library files or documentation files
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030057INC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \
58 include/drivers/arm, \
59 $(wildcard include/drivers/*)))
Dan Handleyd7b59e42016-06-02 17:15:13 +010060INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \
Dan Handley3a355712016-06-02 18:21:02 +010061 include/lib/libfdt \
Roberto Vargas0f8f9852018-05-08 10:27:10 +010062 include/lib/libc, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010063 $(wildcard include/lib/*)))
64INC_DIRS_TO_CHECK := $(sort $(filter-out \
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030065 include/lib \
66 include/drivers, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010067 $(wildcard include/*)))
68LIB_DIRS_TO_CHECK := $(sort $(filter-out \
dp-arme3cc8382017-05-04 12:15:35 +010069 lib/compiler-rt \
Antonio Nino Diazd84f88e2017-01-16 17:20:45 +000070 lib/libfdt% \
Roberto Vargas0f8f9852018-05-08 10:27:10 +010071 lib/libc, \
Daniel Boulby958f1dd2022-10-05 11:05:22 +010072 lib/zlib \
Dan Handleyd7b59e42016-06-02 17:15:13 +010073 $(wildcard lib/*)))
74ROOT_DIRS_TO_CHECK := $(sort $(filter-out \
75 lib \
76 include \
77 docs \
Paul Beesleyadfab5b2019-03-07 16:42:31 +000078 %.rst, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010079 $(wildcard *)))
80CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \
81 ${INC_DIRS_TO_CHECK} \
82 ${INC_LIB_DIRS_TO_CHECK} \
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030083 ${LIB_DIRS_TO_CHECK} \
84 ${INC_DRV_DIRS_TO_CHECK} \
85 ${INC_ARM_DIRS_TO_CHECK}
Ian Spray36eaaf32014-01-30 17:25:28 +000086
Juan Castilloa3487d12015-08-18 14:23:04 +010087################################################################################
88# Process build options
89################################################################################
90
Chris Kay1870c722024-05-02 17:52:37 +000091ifeq ($(verbose),)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +010092 CHECKCODE_ARGS += --no-summary --terse
Achin Gupta4f6ad662013-10-25 09:08:21 +010093endif
Andre Przywaracf2bb082018-09-27 10:56:05 +010094
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +010095################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +010096# Auxiliary tools (fiptool, cert_create, etc)
97################################################################################
98
99# Variables for use with Certificate Generation Tool
100CRTTOOLPATH ?= tools/cert_create
Chris Kayfaab7482025-01-13 15:57:32 +0000101CRTTOOL ?= ${CRTTOOLPATH}/cert_create$(.exe)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100102
103# Variables for use with Firmware Encryption Tool
104ENCTOOLPATH ?= tools/encrypt_fw
Chris Kayfaab7482025-01-13 15:57:32 +0000105ENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw$(.exe)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100106
107# Variables for use with Firmware Image Package
108FIPTOOLPATH ?= tools/fiptool
Chris Kayfaab7482025-01-13 15:57:32 +0000109FIPTOOL ?= ${FIPTOOLPATH}/fiptool$(.exe)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100110
111# Variables for use with sptool
112SPTOOLPATH ?= tools/sptool
113SPTOOL ?= ${SPTOOLPATH}/sptool.py
114SP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py
Karl Meakinaba46182023-02-14 11:56:02 +0000115SP_DTS_LIST_FRAGMENT ?= ${BUILD_PLAT}/sp_list_fragment.dts
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100116
J-Alvesa62598e2024-11-18 17:49:53 +0000117# Variables for use with sptool
118TLCTOOL ?= poetry run tlc
119
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100120# Variables for use with ROMLIB
121ROMLIBPATH ?= lib/romlib
122
123# Variable for use with Python
124PYTHON ?= python3
125
126# Variables for use with documentation build using Sphinx tool
127DOCS_PATH ?= docs
128
129################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100130# Compiler Configuration based on ARCH_MAJOR and ARCH_MINOR flags
Juan Castilloa3487d12015-08-18 14:23:04 +0100131################################################################################
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100132ifeq (${ARM_ARCH_MAJOR},7)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100133 target32-directive = -target arm-none-eabi
Govindraj Rajacd10c6e2023-05-30 16:52:15 -0500134# Will set march-directive from platform configuration
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100135else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100136 target32-directive = -target armv8a-none-eabi
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100137endif #(ARM_ARCH_MAJOR)
138
139################################################################################
140# Get Architecture Feature Modifiers
141################################################################################
142arch-features = ${ARM_ARCH_FEATURE}
143
Chris Kaycfba6452023-12-04 09:55:50 +0000144ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
145 ifeq ($($(ARCH)-cc-id),arm-clang)
Govindraj Raja69096412023-06-01 16:29:16 -0500146 TF_CFLAGS_aarch32 := -target arm-arm-none-eabi
147 TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi
originfba80d82022-01-19 16:30:14 +0000148 else
Govindraj Raja69096412023-06-01 16:29:16 -0500149 TF_CFLAGS_aarch32 = $(target32-directive)
150 TF_CFLAGS_aarch64 := -target aarch64-elf
originfba80d82022-01-19 16:30:14 +0000151 endif
152
Chris Kaycfba6452023-12-04 09:55:50 +0000153else ifeq ($($(ARCH)-cc-id),gnu-gcc)
Chris Kay00416dc2024-02-20 16:19:54 +0000154 # Enable LTO only for aarch64
155 ifeq (${ARCH},aarch64)
156 LTO_CFLAGS = $(if $(filter-out 0,$(ENABLE_LTO)),-flto)
zelalem-aweked5f45272019-11-12 16:20:17 -0600157 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100158endif #(clang)
dp-arm320e8442017-05-02 12:00:08 +0100159
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100160# Process Debug flag
161$(eval $(call add_define,DEBUG))
162ifneq (${DEBUG}, 0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100163 BUILD_TYPE := debug
164 TF_CFLAGS += -g -gdwarf-4
165 ASFLAGS += -g -Wa,-gdwarf-4
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100166
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100167 # Use LOG_LEVEL_INFO by default for debug builds
168 LOG_LEVEL := 40
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100169else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100170 BUILD_TYPE := release
171 # Use LOG_LEVEL_NOTICE by default for release builds
172 LOG_LEVEL := 20
173endif #(Debug)
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100174
Peiyuan Song44f8f472020-04-25 16:53:43 +0800175# Default build string (git branch and commit)
176ifeq (${BUILD_STRING},)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100177 BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null)
Peiyuan Song44f8f472020-04-25 16:53:43 +0800178endif
laurenw-arme954f652022-07-12 10:12:05 -0500179VERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
Peiyuan Song44f8f472020-04-25 16:53:43 +0800180
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100181ifeq (${AARCH32_INSTRUCTION_SET},A32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100182 TF_CFLAGS_aarch32 += -marm
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100183else ifeq (${AARCH32_INSTRUCTION_SET},T32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100184 TF_CFLAGS_aarch32 += -mthumb
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100185else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100186 $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
187endif #(AARCH32_INSTRUCTION_SET)
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100188
Sandrine Bailleux1aa72ec2018-07-03 09:14:45 +0200189TF_CFLAGS_aarch32 += -mno-unaligned-access
dp-arm320e8442017-05-02 12:00:08 +0100190TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align
Soby Mathewa1941252016-05-05 14:33:33 +0100191
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100192##############################################################################
193# WARNINGS Configuration
194###############################################################################
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100195# General warnings
196WARNINGS := -Wall -Wmissing-include-dirs -Wunused \
Yann Gautier94a40b62021-05-20 13:18:14 +0200197 -Wdisabled-optimization -Wvla -Wshadow \
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000198 -Wredundant-decls
199# stricter warnings
200WARNINGS += -Wextra -Wno-trigraphs
201# too verbose for generic build
202WARNINGS += -Wno-missing-field-initializers \
203 -Wno-type-limits -Wno-sign-compare \
204# on clang this flag gets reset if -Wextra is set after it. No difference on gcc
205WARNINGS += -Wno-unused-parameter
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100206
207# Additional warnings
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000208# Level 1 - infrequent warnings we should have none of
209# full -Wextra
210WARNING1 += -Wsign-compare
211WARNING1 += -Wtype-limits
212WARNING1 += -Wmissing-field-initializers
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100213
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000214# Level 2 - problematic warnings that we want
215# zlib, compiler-rt, coreboot, and mbdedtls blow up with these
216# TODO: disable just for them and move into default build
217WARNING2 += -Wold-style-definition
218WARNING2 += -Wmissing-prototypes
219WARNING2 += -Wmissing-format-attribute
220# TF-A aims to comply with this eventually. Effort too large at present
221WARNING2 += -Wundef
Boyan Karatotev9c6ba592022-11-21 14:49:05 +0000222# currently very involved and many platforms set this off
223WARNING2 += -Wunused-const-variable=2
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100224
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000225# Level 3 - very pedantic, frequently ignored
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100226WARNING3 := -Wbad-function-cast
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000227WARNING3 += -Waggregate-return
228WARNING3 += -Wnested-externs
229WARNING3 += -Wcast-align
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100230WARNING3 += -Wcast-qual
231WARNING3 += -Wconversion
232WARNING3 += -Wpacked
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100233WARNING3 += -Wpointer-arith
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100234WARNING3 += -Wswitch-default
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100235
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000236# Setting W is quite verbose and most warnings will be pre-existing issues
237# outside of the contributor's control. Don't fail the build on them so warnings
238# can be seen and hopefully addressed
239ifdef W
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100240 ifneq (${W},0)
241 E ?= 0
242 endif
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000243endif
244
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100245ifeq (${W},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100246 WARNINGS += $(WARNING1)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100247else ifeq (${W},2)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100248 WARNINGS += $(WARNING1) $(WARNING2)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100249else ifeq (${W},3)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100250 WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
251endif #(W)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100252
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100253# Compiler specific warnings
Chris Kaycfba6452023-12-04 09:55:50 +0000254ifeq ($(filter %-clang,$($(ARCH)-cc-id)),)
Justin Chadwell7a914232019-07-03 14:15:56 +0100255# not using clang
Justin Chadwell42d18ca2019-09-18 14:13:42 +0100256WARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \
257 -Wpacked-bitfield-compat -Wshift-overflow=2 \
258 -Wlogical-op
Govindraj Rajaaa8ef3f2023-05-05 09:09:36 -0500259
260# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
Boyan Karatoteve9f127f2024-10-10 13:54:37 +0100261TF_CFLAGS_MIN_PAGE_SIZE := $(call cc_option, --param=min-pagesize=0)
262TF_CFLAGS += $(TF_CFLAGS_MIN_PAGE_SIZE)
Govindraj Rajaaa8ef3f2023-05-05 09:09:36 -0500263
Bipin Ravie53e6ae2023-09-28 13:17:24 -0500264ifeq ($(HARDEN_SLS), 1)
Boyan Karatoteve9f127f2024-10-10 13:54:37 +0100265 TF_CFLAGS_MHARDEN_SLS := $(call cc_option, -mharden-sls=all)
266 TF_CFLAGS_aarch64 += $(TF_CFLAGS_MHARDEN_SLS)
Bipin Ravie53e6ae2023-09-28 13:17:24 -0500267endif
268
Justin Chadwell7a914232019-07-03 14:15:56 +0100269else
270# using clang
Justin Chadwell42d18ca2019-09-18 14:13:42 +0100271WARNINGS += -Wshift-overflow -Wshift-sign-overflow \
272 -Wlogical-op-parentheses
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100273endif #(Clang Warning)
Ambroise Vincent067e4d92019-05-24 12:47:43 +0100274
Yann Gautier957c3532018-12-10 18:08:53 +0100275ifneq (${E},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100276 ERRORS := -Werror
277endif #(E)
Yann Gautier957c3532018-12-10 18:08:53 +0100278
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100279################################################################################
280# Compiler and Linker Directives
281################################################################################
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100282CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
283 $(ERRORS) $(WARNINGS)
Govindraj Rajacd10c6e2023-05-30 16:52:15 -0500284ASFLAGS += $(CPPFLAGS) \
Julius Werner53456fc2019-07-09 13:49:11 -0700285 -ffreestanding -Wa,--fatal-warnings
Masahiro Yamada0dec9fa2016-12-22 12:51:53 +0900286TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \
Samuel Holland23f5e542019-10-20 16:11:25 -0500287 -ffunction-sections -fdata-sections \
Boyan Karatoteva353fbf2024-12-09 08:24:12 +0000288 -ffreestanding -fno-common \
Samuel Holland23f5e542019-10-20 16:11:25 -0500289 -Os -std=gnu99
Juan Castilloa3487d12015-08-18 14:23:04 +0100290
Justin Chadwell83e04882019-08-20 11:01:52 +0100291ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100292 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover
293endif #(${SANITIZE_UB},on)
294
Justin Chadwell83e04882019-08-20 11:01:52 +0100295ifeq (${SANITIZE_UB},trap)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100296 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \
Justin Chadwell83e04882019-08-20 11:01:52 +0100297 -fsanitize-undefined-trap-on-error
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100298endif #(${SANITIZE_UB},trap)
Justin Chadwell83e04882019-08-20 11:01:52 +0100299
Chris Kay0adde4e2024-05-14 13:08:31 +0000300GCC_V_OUTPUT := $(if $($(ARCH)-cc),$(shell $($(ARCH)-cc) -v 2>&1))
david cunado34ab6092017-11-30 21:58:01 +0000301
Marco Felsch24ad8402022-11-09 12:59:09 +0100302TF_LDFLAGS += -z noexecstack
303
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100304# LD = armlink
Chris Kaycfba6452023-12-04 09:55:50 +0000305ifeq ($($(ARCH)-ld-id),arm-link)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100306 TF_LDFLAGS += --diag_error=warning --lto_level=O1
307 TF_LDFLAGS += --remove --info=unused,unusedsymbols
308 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100309
310# LD = gcc (used when GCC LTO is enabled)
Chris Kaycfba6452023-12-04 09:55:50 +0000311else ifeq ($($(ARCH)-ld-id),gnu-gcc)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100312 # Pass ld options with Wl or Xlinker switches
Chris Kayb0fe96f2024-01-16 11:53:35 +0000313 TF_LDFLAGS += $(call ld_option,-Xlinker --no-warn-rwx-segments)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100314 TF_LDFLAGS += -Wl,--fatal-warnings -O1
315 TF_LDFLAGS += -Wl,--gc-sections
Chris Kay73b1f402022-12-22 13:26:37 +0000316
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100317 TF_LDFLAGS += -Wl,-z,common-page-size=4096 #Configure page size constants
318 TF_LDFLAGS += -Wl,-z,max-page-size=4096
Andrey Skvortsove2ebb722023-09-05 23:06:29 +0300319 TF_LDFLAGS += -Wl,--build-id=none
Chris Kay73b1f402022-12-22 13:26:37 +0000320
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100321 ifeq ($(ENABLE_LTO),1)
322 ifeq (${ARCH},aarch64)
323 TF_LDFLAGS += -flto -fuse-linker-plugin
Andrey Skvortsov664d6502023-12-08 18:04:51 +0300324 TF_LDFLAGS += -flto-partition=one
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100325 endif
326 endif #(ENABLE_LTO)
327
zelalem-aweked5f45272019-11-12 16:20:17 -0600328# GCC automatically adds fix-cortex-a53-843419 flag when used to link
329# which breaks some builds, so disable if errata fix is not explicitly enabled
Yann Gautier3d73d162023-03-15 16:18:16 +0100330 ifeq (${ARCH},aarch64)
331 ifneq (${ERRATA_A53_843419},1)
332 TF_LDFLAGS += -mno-fix-cortex-a53-843419
333 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100334 endif
335 TF_LDFLAGS += -nostdlib
336 TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100337
338# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
Varun Wadekar4d034c52019-01-11 14:47:48 -0800339else
Marco Felsch24ad8402022-11-09 12:59:09 +0100340# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
341# are not loaded by a elf loader.
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100342 TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments)
343 TF_LDFLAGS += -O1
344 TF_LDFLAGS += --gc-sections
Chris Kay73b1f402022-12-22 13:26:37 +0000345
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100346 TF_LDFLAGS += -z common-page-size=4096 # Configure page size constants
347 TF_LDFLAGS += -z max-page-size=4096
Andrey Skvortsove2ebb722023-09-05 23:06:29 +0300348 TF_LDFLAGS += --build-id=none
Chris Kay73b1f402022-12-22 13:26:37 +0000349
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100350# ld.lld doesn't recognize the errata flags,
Yabin Cuied7dc512023-01-19 20:06:04 +0000351# therefore don't add those in that case.
352# ld.lld reports section type mismatch warnings,
353# therefore don't add --fatal-warnings to it.
Chris Kaycfba6452023-12-04 09:55:50 +0000354 ifneq ($($(ARCH)-ld-id),llvm-lld)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100355 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) --fatal-warnings
356 endif
357
358endif #(LD = armlink)
Juan Castilloa3487d12015-08-18 14:23:04 +0100359
360################################################################################
Govindraj Raja0386e312023-08-17 10:41:48 -0500361# Setup ARCH_MAJOR/MINOR before parsing arch_features.
362################################################################################
363ifeq (${ENABLE_RME},1)
AlexeiFedorov65258452024-03-13 11:53:44 +0000364 ARM_ARCH_MAJOR := 9
365 ARM_ARCH_MINOR := 2
Govindraj Raja0386e312023-08-17 10:41:48 -0500366endif
367
368################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +0100369# Common sources and include directories
370################################################################################
dp-arme3cc8382017-05-04 12:15:35 +0100371include lib/compiler-rt/compiler-rt.mk
Juan Castilloa3487d12015-08-18 14:23:04 +0100372
Chris Kay99b5b2e2024-03-08 16:08:31 +0000373# Allow overriding the timestamp, for example for reproducible builds, or to
374# synchronize timestamps across multiple projects.
375# This must be set to a C string (including quotes where applicable).
376BUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__
377
378DEFINES += -DBUILD_MESSAGE_TIMESTAMP='$(BUILD_MESSAGE_TIMESTAMP)'
379DEFINES += -DBUILD_MESSAGE_VERSION_STRING='"$(VERSION_STRING)"'
380DEFINES += -DBUILD_MESSAGE_VERSION='"$(VERSION)"'
381
Juan Castilloa3487d12015-08-18 14:23:04 +0100382BL_COMMON_SOURCES += common/bl_common.c \
Soby Mathewaaf15f52017-09-04 11:49:29 +0100383 common/tf_log.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100384 common/${ARCH}/debug.S \
Julius Werner03020da2018-11-27 22:10:56 -0800385 drivers/console/multi_console.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100386 lib/${ARCH}/cache_helpers.S \
387 lib/${ARCH}/misc_helpers.S \
Boyan Karatotev05504ba2023-02-15 13:21:50 +0000388 lib/extensions/pmuv3/${ARCH}/pmuv3.c \
Soby Mathew2f38ce32018-02-08 17:45:12 +0000389 plat/common/plat_bl_common.c \
Soby Mathewaaf15f52017-09-04 11:49:29 +0100390 plat/common/plat_log_common.c \
dp-arm230011c2017-03-07 11:02:47 +0000391 plat/common/${ARCH}/plat_common.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100392 plat/common/${ARCH}/platform_helpers.S \
Roberto Vargas0f8f9852018-05-08 10:27:10 +0100393 ${COMPILER_RT_SRCS}
Ryan Harkind7a6b0f2014-01-13 14:40:13 +0000394
Chris Kaycfba6452023-12-04 09:55:50 +0000395ifeq ($($(ARCH)-cc-id),arm-clang)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100396 BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S
Antonio Nino Diazeea20fc2018-08-16 15:42:44 +0100397endif
398
Justin Chadwell83e04882019-08-20 11:01:52 +0100399ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100400 BL_COMMON_SOURCES += plat/common/ubsan.c
Justin Chadwell83e04882019-08-20 11:01:52 +0100401endif
402
Yann Gautier2cf1dbc2018-06-18 16:00:23 +0200403INCLUDES += -Iinclude \
Antonio Nino Diaz8d1ade62018-12-17 17:20:57 +0000404 -Iinclude/arch/${ARCH} \
Antonio Nino Diaze0f90632018-12-14 00:18:21 +0000405 -Iinclude/lib/cpus/${ARCH} \
406 -Iinclude/lib/el3_runtime/${ARCH} \
407 ${PLAT_INCLUDES} \
408 ${SPD_INCLUDES}
409
Nishant Sharma331b5682022-08-15 16:37:07 +0100410DTC_FLAGS += -I dts -O dtb
411DTC_CPPFLAGS += -P -nostdinc $(INCLUDES) -Ifdts -undef \
412 -x assembler-with-cpp $(DEFINES)
413
Antonio Nino Diazc3a2cf22018-11-19 11:48:30 +0000414include common/backtrace/backtrace.mk
415
Juan Castilloa3487d12015-08-18 14:23:04 +0100416################################################################################
Govindraj Raja1a211292023-09-20 14:32:24 -0500417# Generic definitions
418################################################################################
Govindraj Raja1a211292023-09-20 14:32:24 -0500419
420ifeq (${BUILD_BASE},)
421 BUILD_BASE := ./build
422endif
423BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
424
425SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
426
427# Platforms providing their own TBB makefile may override this value
428INCLUDE_TBBR_MK := 1
429
430################################################################################
431# Include SPD Makefile if one has been specified
432################################################################################
433
434ifneq (${SPD},none)
435 ifeq (${ARCH},aarch32)
436 $(error "Error: SPD is incompatible with AArch32.")
437 endif
438
439 ifdef EL3_PAYLOAD_BASE
440 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
441 $(warning "The SPD and its BL32 companion will be present but \
442 ignored.")
443 endif
444
445 ifeq (${SPD},spmd)
446 # SPMD is located in std_svc directory
447 SPD_DIR := std_svc
448
449 ifeq ($(SPMD_SPM_AT_SEL2),1)
450 CTX_INCLUDE_EL2_REGS := 1
451 ifeq ($(SPMC_AT_EL3),1)
452 $(error SPM cannot be enabled in both S-EL2 and EL3.)
453 endif
Madhukar Pappireddy7503cdc2024-04-25 23:01:00 -0500454 ifeq ($(CTX_INCLUDE_SVE_REGS),1)
455 $(error SVE context management not needed with Hafnium SPMC.)
456 endif
Govindraj Raja1a211292023-09-20 14:32:24 -0500457 endif
458
459 ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
460 DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG
461 endif
462
Arunachalam Ganapathyfd29d582022-04-11 14:36:54 +0100463 ifeq ($(findstring trusty_sp,$(ARM_SPMC_MANIFEST_DTS)),trusty_sp)
464 DTC_CPPFLAGS += -DTRUSTY_SP_FW_CONFIG
465 endif
466
Govindraj Raja1a211292023-09-20 14:32:24 -0500467 ifeq ($(TS_SP_FW_CONFIG),1)
Arunachalam Ganapathyfd29d582022-04-11 14:36:54 +0100468 DTC_CPPFLAGS += -DTS_SP_FW_CONFIG
Govindraj Raja1a211292023-09-20 14:32:24 -0500469 endif
470
471 ifneq ($(ARM_BL2_SP_LIST_DTS),)
472 DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
473 endif
474
475 ifneq ($(SP_LAYOUT_FILE),)
476 BL2_ENABLE_SP_LOAD := 1
477 endif
Govindraj Rajabad835a2023-10-31 14:48:11 -0500478
479 ifeq ($(SPMC_AT_EL3_SEL0_SP),1)
480 ifneq ($(SPMC_AT_EL3),1)
481 $(error SEL0 SP cannot be enabled without SPMC at EL3)
482 endif
483 endif
Govindraj Raja1a211292023-09-20 14:32:24 -0500484 else
485 # All other SPDs in spd directory
486 SPD_DIR := spd
487 endif #(SPD)
488
489 # We expect to locate an spd.mk under the specified SPD directory
490 SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
491
492 ifeq (${SPD_MAKE},)
493 $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
494 endif
495 $(info Including ${SPD_MAKE})
496 include ${SPD_MAKE}
497
498 # If there's BL32 companion for the chosen SPD, we expect that the SPD's
499 # Makefile would set NEED_BL32 to "yes". In this case, the build system
500 # supports two mutually exclusive options:
501 # * BL32 is built from source: then BL32_SOURCES must contain the list
502 # of source files to build BL32
503 # * BL32 is a prebuilt binary: then BL32 must point to the image file
504 # that will be included in the FIP
505 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
506 # over the sources.
507endif #(SPD=none)
508
509ifeq (${ENABLE_SPMD_LP}, 1)
510ifneq (${SPD},spmd)
511 $(error Error: ENABLE_SPMD_LP requires SPD=spmd.)
512endif
513ifeq ($(SPMC_AT_EL3),1)
514 $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.)
515endif
516endif
517
518################################################################################
Olivier Deprez4b467722025-01-03 13:38:50 +0100519# Include the platform specific Makefile after the SPD Makefile (the platform
520# makefile may use all previous definitions in this file)
521################################################################################
522include ${PLAT_MAKEFILE_FULL}
523
524################################################################################
Govindraj Raja0386e312023-08-17 10:41:48 -0500525# Process BRANCH_PROTECTION value and set
526# Pointer Authentication and Branch Target Identification flags
527################################################################################
528ifeq (${BRANCH_PROTECTION},0)
529 # Default value turns off all types of branch protection
530 BP_OPTION := none
531else ifneq (${ARCH},aarch64)
532 $(error BRANCH_PROTECTION requires AArch64)
533else ifeq (${BRANCH_PROTECTION},1)
534 # Enables all types of branch protection features
535 BP_OPTION := standard
536 ENABLE_BTI := 1
537 ENABLE_PAUTH := 1
538else ifeq (${BRANCH_PROTECTION},2)
539 # Return address signing to its standard level
540 BP_OPTION := pac-ret
541 ENABLE_PAUTH := 1
542else ifeq (${BRANCH_PROTECTION},3)
543 # Extend the signing to include leaf functions
544 BP_OPTION := pac-ret+leaf
545 ENABLE_PAUTH := 1
546else ifeq (${BRANCH_PROTECTION},4)
547 # Turn on branch target identification mechanism
548 BP_OPTION := bti
549 ENABLE_BTI := 1
550else
551 $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
552endif #(BRANCH_PROTECTION)
553
554ifeq ($(ENABLE_PAUTH),1)
555 CTX_INCLUDE_PAUTH_REGS := 1
556endif
557ifneq (${BP_OPTION},none)
558 TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION}
559endif #(BP_OPTION)
560
561# Pointer Authentication sources
562ifeq (${ENABLE_PAUTH}, 1)
563# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the
564# Pauth support. As it's not secure, it must be reimplemented for real platforms
565 BL_COMMON_SOURCES += lib/extensions/pauth/pauth_helpers.S
566endif
567
Govindraj Raja1a211292023-09-20 14:32:24 -0500568################################################################################
Govindraj Raja1a211292023-09-20 14:32:24 -0500569# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from
570# platform.
571################################################################################
572include ${MAKE_HELPERS_DIRECTORY}arch_features.mk
573
Govindraj Raja0386e312023-08-17 10:41:48 -0500574####################################################
575# Enable required options for Memory Stack Tagging.
576####################################################
577
578# Currently, these options are enabled only for clang and armclang compiler.
579ifeq (${SUPPORT_STACK_MEMTAG},yes)
580 ifdef mem_tag_arch_support
581 # Check for armclang and clang compilers
Chris Kaycfba6452023-12-04 09:55:50 +0000582 ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
Govindraj Raja0386e312023-08-17 10:41:48 -0500583 # Add "memtag" architecture feature modifier if not specified
584 ifeq ( ,$(findstring memtag,$(arch-features)))
585 arch-features := $(arch-features)+memtag
586 endif # memtag
Chris Kaycfba6452023-12-04 09:55:50 +0000587 ifeq ($($(ARCH)-cc-id),arm-clang)
Govindraj Raja0386e312023-08-17 10:41:48 -0500588 TF_CFLAGS += -mmemtag-stack
Chris Kaycfba6452023-12-04 09:55:50 +0000589 else ifeq ($($(ARCH)-cc-id),llvm-clang)
Govindraj Raja0386e312023-08-17 10:41:48 -0500590 TF_CFLAGS += -fsanitize=memtag
591 endif # armclang
592 endif
593 else
594 $(error "Error: stack memory tagging is not supported for \
595 architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
596 endif #(mem_tag_arch_support)
597endif #(SUPPORT_STACK_MEMTAG)
598
599################################################################################
600# RME dependent flags configuration, Enable optional features for RME.
601################################################################################
602# FEAT_RME
603ifeq (${ENABLE_RME},1)
Govindraj Raja0386e312023-08-17 10:41:48 -0500604 # RME requires AARCH64
605 ifneq (${ARCH},aarch64)
606 $(error ENABLE_RME requires AArch64)
607 endif
608
609 # RME requires el2 context to be saved for now.
610 CTX_INCLUDE_EL2_REGS := 1
611 CTX_INCLUDE_AARCH32_REGS := 0
612 CTX_INCLUDE_PAUTH_REGS := 1
613
614 # RME enables CSV2_2 extension by default.
615 ENABLE_FEAT_CSV2_2 = 1
616endif #(FEAT_RME)
617
618################################################################################
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500619# Include rmmd Makefile if RME is enabled
620################################################################################
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500621ifneq (${ENABLE_RME},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100622 ifneq (${ARCH},aarch64)
623 $(error ENABLE_RME requires AArch64)
624 endif
625 ifeq ($(SPMC_AT_EL3),1)
626 $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
627 endif
628
629 ifneq (${SPD}, none)
630 ifneq (${SPD}, spmd)
631 $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd)
632 endif
633 endif
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500634include services/std_svc/rmmd/rmmd.mk
635$(warning "RME is an experimental feature")
636endif
637
Govindraj Raja1a211292023-09-20 14:32:24 -0500638ifeq (${CTX_INCLUDE_EL2_REGS}, 1)
639 ifeq (${SPD},none)
640 ifeq (${ENABLE_RME},0)
641 $(error CTX_INCLUDE_EL2_REGS is available only when SPD \
642 or RME is enabled)
643 endif
644 endif
645endif
Jon Medhurst66573cb2014-02-13 15:19:28 +0000646
Govindraj Raja69096412023-06-01 16:29:16 -0500647################################################################################
Govindraj Rajae63794e2024-09-06 15:43:43 +0100648# Make 128-Bit sysreg read/writes availabe when FEAT_D128 is enabled.
649################################################################################
650ifneq (${ENABLE_FEAT_D128}, 0)
651 BL_COMMON_SOURCES += lib/extensions/sysreg128/sysreg128.S
652endif
653
654################################################################################
Govindraj Raja69096412023-06-01 16:29:16 -0500655# Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come
656# up with appropriate march values for compiler.
657################################################################################
658include ${MAKE_HELPERS_DIRECTORY}march.mk
659
660TF_CFLAGS += $(march-directive)
Govindraj Raja0c572472024-01-23 16:00:19 -0600661ASFLAGS += $(march-directive)
Govindraj Raja69096412023-06-01 16:29:16 -0500662
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600663# This internal flag is common option which is set to 1 for scenarios
664# when the BL2 is running in EL3 level. This occurs in two scenarios -
665# 4 world system running BL2 at EL3 and two world system without BL1 running
666# BL2 in EL3
667
668ifeq (${RESET_TO_BL2},1)
669 BL2_RUNS_AT_EL3 := 1
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100670 ifeq (${ENABLE_RME},1)
671 $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \
672 supported at the moment.)
673 endif
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600674else ifeq (${ENABLE_RME},1)
675 BL2_RUNS_AT_EL3 := 1
676else
677 BL2_RUNS_AT_EL3 := 0
678endif
679
Manish Pandeyf90a73c2023-10-10 15:42:19 +0100680# This internal flag is set to 1 when Firmware First handling of External aborts
681# is required by lowe ELs. Currently only NS requires this support.
682ifeq ($(HANDLE_EA_EL3_FIRST_NS),1)
683 FFH_SUPPORT := 1
684else
685 FFH_SUPPORT := 0
686endif
687
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100688ifeq (${ARM_ARCH_MAJOR},7)
689include make_helpers/armv7-a-cpus.mk
690endif
691
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900692PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT})
693ifneq ($(PIE_FOUND),)
694 TF_CFLAGS += -fno-PIE
Chris Kaycfba6452023-12-04 09:55:50 +0000695ifeq ($($(ARCH)-ld-id),gnu-gcc)
Samuel Holland9286c022022-04-08 21:56:02 -0500696 TF_LDFLAGS += -no-pie
697endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100698endif #(PIE_FOUND)
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900699
Chris Kaycfba6452023-12-04 09:55:50 +0000700ifeq ($($(ARCH)-ld-id),gnu-gcc)
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900701 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
Soby Mathew078f1a42018-08-28 11:13:55 +0100702else
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900703 PIE_LDFLAGS += -pie --no-dynamic-linker
704endif
705
706ifeq ($(ENABLE_PIE),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100707 ifeq ($(RESET_TO_BL2),1)
708 ifneq ($(BL2_IN_XIP_MEM),1)
709 BL2_CPPFLAGS += -fpie
710 BL2_CFLAGS += -fpie
711 BL2_LDFLAGS += $(PIE_LDFLAGS)
712 endif #(BL2_IN_XIP_MEM)
713 endif #(RESET_TO_BL2)
Chris Kay13886c82023-02-02 14:39:03 +0000714 BL31_CPPFLAGS += -fpie
715 BL31_CFLAGS += -fpie
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900716 BL31_LDFLAGS += $(PIE_LDFLAGS)
Chris Kay13886c82023-02-02 14:39:03 +0000717
718 BL32_CPPFLAGS += -fpie
Masahiro Yamadade634f82020-01-17 13:45:14 +0900719 BL32_CFLAGS += -fpie
720 BL32_LDFLAGS += $(PIE_LDFLAGS)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100721endif #(ENABLE_PIE)
Soby Mathew078f1a42018-08-28 11:13:55 +0100722
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000723BL1_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
724BL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
725BL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
726
Masahiro Yamadaf1441572020-04-01 14:20:58 +0900727BL1_CPPFLAGS += -DIMAGE_AT_EL3
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600728ifeq ($(RESET_TO_BL2),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100729 BL2_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamada003dd762020-03-26 13:18:48 +0900730else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100731 BL2_CPPFLAGS += -DIMAGE_AT_EL1
732endif #(RESET_TO_BL2)
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000733
734ifeq (${ARCH},aarch64)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100735 BL2U_CPPFLAGS += -DIMAGE_AT_EL1
736 BL31_CPPFLAGS += -DIMAGE_AT_EL3
737 BL32_CPPFLAGS += -DIMAGE_AT_EL1
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000738else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100739 BL32_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamada003dd762020-03-26 13:18:48 +0900740endif
741
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000742# Include the CPU specific operations makefile, which provides default
743# values for all CPU errata workarounds and CPU specific optimisations.
744# This can be overridden by the platform.
Soby Mathew937488b2014-09-22 14:13:34 +0100745include lib/cpus/cpu-ops.mk
Soby Mathew802f8652014-08-14 16:19:29 +0100746
dp-armcdd03cb2017-02-15 11:07:55 +0000747################################################################################
748# Build `AARCH32_SP` as BL32 image for AArch32
749################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100750ifeq (${ARCH},aarch32)
751 NEED_BL32 := yes
dp-armcdd03cb2017-02-15 11:07:55 +0000752
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100753 ifneq (${AARCH32_SP},none)
754 # We expect to locate an sp.mk under the specified AARCH32_SP directory
755 AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
dp-armcdd03cb2017-02-15 11:07:55 +0000756
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100757 ifeq (${AARCH32_SP_MAKE},)
758 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
759 endif
Juan Pablo Conde6aba3b12023-08-09 13:19:21 -0500760 $(info Including ${AARCH32_SP_MAKE})
761 include ${AARCH32_SP_MAKE}
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100762 endif
763endif #(ARCH=aarch32)
Varun Wadekar3f9002c2019-01-31 09:22:30 -0800764
765################################################################################
766# Include libc if not overridden
767################################################################################
768ifeq (${OVERRIDE_LIBC},0)
769include lib/libc/libc.mk
dp-armcdd03cb2017-02-15 11:07:55 +0000770endif
Juan Castilloa3487d12015-08-18 14:23:04 +0100771
772################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100773# Check incompatible options and dependencies
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000774################################################################################
775
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100776# USE_DEBUGFS experimental feature recommended only in debug builds
777ifeq (${USE_DEBUGFS},1)
778 ifeq (${DEBUG},1)
779 $(warning DEBUGFS experimental feature is enabled.)
780 else
781 $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
Qixiang Xube9bd9d2017-08-24 11:03:23 +0800782 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100783endif #(USE_DEBUGFS)
784
785# USE_SPINLOCK_CAS requires AArch64 build
786ifeq (${USE_SPINLOCK_CAS},1)
787 ifneq (${ARCH},aarch64)
788 $(error USE_SPINLOCK_CAS requires AArch64)
Qixiang Xube9bd9d2017-08-24 11:03:23 +0800789 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100790endif #(USE_SPINLOCK_CAS)
791
792# The cert_create tool cannot generate certificates individually, so we use the
793# target 'certificates' to create them all
794ifneq (${GENERATE_COT},0)
795 FIP_DEPS += certificates
796 FWU_FIP_DEPS += fwu_certificates
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000797endif
798
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100799ifneq (${DECRYPTION_SUPPORT},none)
800 ENC_ARGS += -f ${FW_ENC_STATUS}
801 ENC_ARGS += -k ${ENC_KEY}
802 ENC_ARGS += -n ${ENC_NONCE}
803 FIP_DEPS += enctool
804 FWU_FIP_DEPS += enctool
805endif #(DECRYPTION_SUPPORT)
806
807ifdef EL3_PAYLOAD_BASE
808 ifdef PRELOADED_BL33_BASE
809 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
810 incompatible build options. EL3_PAYLOAD_BASE has priority.")
811 endif
812 ifneq (${GENERATE_COT},0)
813 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \
814 build options.")
815 endif
816 ifneq (${TRUSTED_BOARD_BOOT},0)
817 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \
818 incompatible \ build options.")
819 endif
820endif #(EL3_PAYLOAD_BASE)
821
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000822ifeq (${NEED_BL33},yes)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100823 ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000824 $(warning "BL33 image is not needed when option \
825 BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100826 endif
827 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz2b8277b2016-04-06 17:31:57 +0100828 $(warning "BL33 image is not needed when option \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100829 PRELOADED_BL33_BASE is used and won't be added to the FIP file.")
830 endif
831endif #(NEED_BL33)
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000832
Jeenu Viswambharan7ed2cbc2017-01-06 16:14:42 +0000833# When building for systems with hardware-assisted coherency, there's no need to
834# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
835ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100836 $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
Jeenu Viswambharan7ed2cbc2017-01-06 16:14:42 +0000837endif
Yatharth Kocharf528faf2016-06-28 16:58:26 +0100838
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600839#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1.
840ifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100841 $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled")
Jiafei Pan43a7bf42018-03-21 07:20:09 +0000842endif
843
Manish Pandeyd419e222023-02-13 12:39:17 +0000844# RAS_EXTENSION is deprecated, provide alternate build options
Jeenu Viswambharan9a7ce2f2018-04-04 16:07:11 +0100845ifeq ($(RAS_EXTENSION),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100846 $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +0100847 and HANDLE_EA_EL3_FIRST_NS instead")
Manish Pandeyd419e222023-02-13 12:39:17 +0000848endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100849
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100850
Manish Pandeyd419e222023-02-13 12:39:17 +0000851# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled
Jeenu Viswambharanf00da742017-12-08 12:13:51 +0000852ifeq ($(FAULT_INJECTION_SUPPORT),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100853 ifeq ($(ENABLE_FEAT_RAS),0)
854 $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0)
855 endif
856endif #(FAULT_INJECTION_SUPPORT)
Jeenu Viswambharanf00da742017-12-08 12:13:51 +0000857
Roberto Vargas025946a2018-09-24 17:20:48 +0100858# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
Soby Mathew9fe88042018-03-26 12:43:37 +0100859ifeq ($(DYN_DISABLE_AUTH), 1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100860 ifeq (${TRUSTED_BOARD_BOOT}, 0)
861 $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \
862 to be set.")
863 endif
864endif #(DYN_DISABLE_AUTH)
Soby Mathew9fe88042018-03-26 12:43:37 +0100865
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100866ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
867# Support authentication verification and hash calculation
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100868 CRYPTO_SUPPORT := 3
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100869else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
870# Support authentication verification and hash calculation
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100871 CRYPTO_SUPPORT := 3
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100872else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
873# Support hash calculation only
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100874 CRYPTO_SUPPORT := 2
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100875else ifeq (${TRUSTED_BOARD_BOOT},1)
876# Support authentication verification only
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100877 CRYPTO_SUPPORT := 1
Manish V Badarkhe5181d602022-01-08 22:56:06 +0000878else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100879 CRYPTO_SUPPORT := 0
880endif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT))
Manish V Badarkhe5181d602022-01-08 22:56:06 +0000881
Manish V Badarkhe8cad2e12024-12-03 21:46:51 +0000882ifneq ($(filter 1 2 3,$(CRYPTO_SUPPORT)),)
883CRYPTO_LIB := $(BUILD_PLAT)/lib/libmbedtls.a
884endif
885
Balint Dobszayd0dbd5e2019-12-18 15:28:00 +0100886# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
887ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100888 $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
Manish V Badarkhead339892020-06-29 10:32:53 +0100889endif
890
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000891# If pointer authentication is used in the firmware, make sure that all the
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100892# 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.
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000894ifeq ($(ENABLE_PAUTH),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100895 ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
896 $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
897 endif
898endif #(ENABLE_PAUTH)
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100899
900ifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100901 ifneq (${ARCH},aarch64)
902 $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
903 endif
904endif #(CTX_INCLUDE_PAUTH_REGS)
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000905
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +0000906ifeq ($(FEATURE_DETECTION),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100907 $(info FEATURE_DETECTION is an experimental feature)
908endif #(FEATURE_DETECTION)
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +0000909
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +0000910ifneq ($(ENABLE_SME2_FOR_NS), 0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100911 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
917endif #(ENABLE_SME2_FOR_NS)
Jayanth Dodderi Chidanand605419a2023-03-06 23:56:14 +0000918
Petre-Ionut Tudore5a6fef2019-11-07 15:18:03 +0000919ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100920 ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
921 $(error "ALLOW_RO_XLAT_TABLES requires translation tables \
922 library v2")
923 endif
924endif #(ARM_XLAT_TABLES_LIB_V1)
Petre-Ionut Tudore5a6fef2019-11-07 15:18:03 +0000925
Sumit Garg392e4df2019-11-15 10:43:00 +0530926ifneq (${DECRYPTION_SUPPORT},none)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100927 ifeq (${TRUSTED_BOARD_BOOT}, 0)
928 $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \
929 to be set)
930 endif
931endif #(DECRYPTION_SUPPORT)
Sumit Garg392e4df2019-11-15 10:43:00 +0530932
johpow0181865962022-01-28 17:06:20 -0600933# Ensure that no Aarch64-only features are enabled in Aarch32 build
johpow019baade32021-07-08 14:14:00 -0500934ifeq (${ARCH},aarch32)
johpow0181865962022-01-28 17:06:20 -0600935
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100936 # 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
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +0000940
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100941 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
johpow0181865962022-01-28 17:06:20 -0600945
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100946 # 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
johpow0181865962022-01-28 17:06:20 -0600950
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100951 # 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
Arvind Ram Prakashe558f9c2024-11-11 14:32:37 -0600955
956 ifneq (${ENABLE_FEAT_FPMR},0)
957 $(error "ENABLE_FEAT_FPMR cannot be used with ARCH=aarch32")
958 endif
Boyan Karatotev8e7c43c2024-10-25 11:38:41 +0100959
960 ifeq (${ARCH_FEATURE_AVAILABILITY},1)
961 $(error "ARCH_FEATURE_AVAILABILITY cannot be used with ARCH=aarch32")
962 endif
Arvind Ram Prakashf915deb2025-01-09 17:18:30 -0600963 # FEAT_MOPS is only supported on AArch64
964 ifneq (${ENABLE_FEAT_MOPS},0)
965 $(error "ENABLE_FEAT_MOPS cannot be used with ARCH=aarch32")
966 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100967endif #(ARCH=aarch32)
johpow019baade32021-07-08 14:14:00 -0500968
Arvind Ram Prakashe558f9c2024-11-11 14:32:37 -0600969ifneq (${ENABLE_FEAT_FPMR},0)
970 ifeq (${ENABLE_FEAT_FGT},0)
971 $(error "ENABLE_FEAT_FPMR requires ENABLE_FEAT_FGT")
972 endif
973 ifeq (${ENABLE_FEAT_HCX},0)
974 $(error "ENABLE_FEAT_FPMR requires ENABLE_FEAT_HCX")
975 endif
976endif #(ENABLE_FEAT_FPMR)
977
Boyan Karatotev7f5dcc72023-03-08 16:29:26 +0000978ifneq (${ENABLE_SME_FOR_NS},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100979 ifeq (${ENABLE_SVE_FOR_NS},0)
980 $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS")
981 endif
982endif #(ENABLE_SME_FOR_NS)
Boyan Karatotev7f5dcc72023-03-08 16:29:26 +0000983
johpow019baade32021-07-08 14:14:00 -0500984# Secure SME/SVE requires the non-secure component as well
985ifeq (${ENABLE_SME_FOR_SWD},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100986 ifeq (${ENABLE_SME_FOR_NS},0)
987 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
988 endif
989 ifeq (${ENABLE_SVE_FOR_SWD},0)
990 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD")
991 endif
992endif #(ENABLE_SME_FOR_SWD)
993
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -0500994# Enabling SVE for SWD requires enabling SVE for NWD due to ENABLE_FEAT
995# mechanism.
johpow019baade32021-07-08 14:14:00 -0500996ifeq (${ENABLE_SVE_FOR_SWD},1)
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -0500997 ifeq (${ENABLE_SVE_FOR_NS},0)
998 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
999 endif
1000endif
johpow019baade32021-07-08 14:14:00 -05001001
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -05001002# Enabling SVE for both the worlds typically requires the context
1003# management of SVE registers. The only exception being SPMC at S-EL2.
1004ifeq (${ENABLE_SVE_FOR_SWD}, 1)
1005 ifneq (${ENABLE_SVE_FOR_NS}, 0)
1006 ifeq (${CTX_INCLUDE_SVE_REGS}-$(SPMD_SPM_AT_SEL2),0-0)
1007 $(warning "ENABLE_SVE_FOR_SWD and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
1008 endif
1009 endif
1010endif
1011
1012# Enabling SVE in either world while enabling CTX_INCLUDE_FPREGS requires
1013# CTX_INCLUDE_SVE_REGS to be enabled due to architectural dependency between FP
1014# and SVE registers.
1015ifeq (${CTX_INCLUDE_FPREGS}, 1)
1016 ifneq (${ENABLE_SVE_FOR_NS},0)
1017 ifeq (${CTX_INCLUDE_SVE_REGS},0)
1018 # Warning instead of error due to CI dependency on this
1019 $(warning "CTX_INCLUDE_FPREGS and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
1020 $(warning "Forced ENABLE_SVE_FOR_NS=0")
1021 override ENABLE_SVE_FOR_NS := 0
1022 endif
1023 endif
1024endif #(CTX_INCLUDE_FPREGS)
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +00001025
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -05001026# SVE context management is only required if secure world has access to SVE/FP
1027# functionality.
1028ifeq (${CTX_INCLUDE_SVE_REGS},1)
1029 ifeq (${ENABLE_SVE_FOR_SWD},0)
1030 $(error "CTX_INCLUDE_SVE_REGS requires ENABLE_SVE_FOR_SWD to also be enabled")
1031 endif
1032endif
1033
1034# SME cannot be used with CTX_INCLUDE_FPREGS since SPM does its own context
1035# management including FPU registers.
1036ifeq (${CTX_INCLUDE_FPREGS},1)
1037 ifneq (${ENABLE_SME_FOR_NS},0)
1038 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1039 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001040endif #(CTX_INCLUDE_FPREGS)
johpow019baade32021-07-08 14:14:00 -05001041
Manish V Badarkhe191a5fc2022-03-02 12:06:35 +00001042ifeq ($(DRTM_SUPPORT),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001043 $(info DRTM_SUPPORT is an experimental feature)
Manish V Badarkhe191a5fc2022-03-02 12:06:35 +00001044endif
1045
Levi Yun03adb132024-05-13 10:24:31 +01001046ifeq (${HOB_LIST},1)
1047 $(warning HOB_LIST is an experimental feature)
1048endif
1049
Raymond Mao98983392023-07-25 07:53:35 -07001050ifeq (${TRANSFER_LIST},1)
1051 $(info TRANSFER_LIST is an experimental feature)
1052endif
1053
Chris Kayd02c2312022-09-29 16:21:24 +01001054ifeq (${ENABLE_RME},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001055 ifneq (${SEPARATE_CODE_AND_RODATA},1)
1056 $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
1057 endif
Chris Kayd02c2312022-09-29 16:21:24 +01001058endif
1059
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001060ifeq ($(PSA_CRYPTO),1)
1061 $(info PSA_CRYPTO is an experimental feature)
1062endif
1063
Manish V Badarkhed8d7d932024-05-09 12:14:13 +01001064ifeq ($(DICE_PROTECTION_ENVIRONMENT),1)
1065 $(info DICE_PROTECTION_ENVIRONMENT is an experimental feature)
1066endif
1067
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +00001068################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001069# Process platform overrideable behaviour
1070################################################################################
1071
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001072ifdef BL1_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001073 NEED_BL1 := yes
1074endif #(BL1_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001075
Jon Medhurst66573cb2014-02-13 15:19:28 +00001076ifdef BL2_SOURCES
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001077 NEED_BL2 := yes
1078
1079 # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
1080 # Certificate generation tools. This flag can be overridden by the platform.
1081 ifdef EL3_PAYLOAD_BASE
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001082 # If booting an EL3 payload there is no need for a BL33 image
1083 # in the FIP file.
1084 NEED_BL33 := no
1085 else
1086 ifdef PRELOADED_BL33_BASE
1087 # If booting a BL33 preloaded image there is no need of
1088 # another one in the FIP file.
1089 NEED_BL33 := no
1090 else
1091 NEED_BL33 ?= yes
1092 endif
1093 endif
1094endif #(BL2_SOURCES)
Achin Gupta4f6ad662013-10-25 09:08:21 +01001095
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001096ifdef BL2U_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001097 NEED_BL2U := yes
1098endif #(BL2U_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001099
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001100# If SCP_BL2 is given, we always want FIP to include it.
1101ifdef SCP_BL2
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001102 NEED_SCP_BL2 := yes
1103endif #(SCP_BL2)
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001104
Soby Mathewbf169232017-11-14 14:10:10 +00001105# For AArch32, BL31 is not currently supported.
1106ifneq (${ARCH},aarch32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001107 ifdef BL31_SOURCES
1108 # When booting an EL3 payload, there is no need to compile the BL31
1109 # image nor put it in the FIP.
1110 ifndef EL3_PAYLOAD_BASE
1111 NEED_BL31 := yes
1112 endif
1113 endif
1114endif #(ARCH=aarch64)
Soby Mathewbf169232017-11-14 14:10:10 +00001115
Juan Castilloa3487d12015-08-18 14:23:04 +01001116# Process TBB related flags
1117ifneq (${GENERATE_COT},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001118 # Common cert_create options
1119 ifneq (${CREATE_KEYS},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001120 $(eval CRT_ARGS += -n)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001121 $(eval FWU_CRT_ARGS += -n)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001122 ifneq (${SAVE_KEYS},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001123 $(eval CRT_ARGS += -k)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001124 $(eval FWU_CRT_ARGS += -k)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001125 endif
1126 endif
1127 # Include TBBR makefile (unless the platform indicates otherwise)
1128 ifeq (${INCLUDE_TBBR_MK},1)
Juan Castilloa3487d12015-08-18 14:23:04 +01001129 include make_helpers/tbbr/tbbr_tools.mk
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001130 endif
1131endif #(GENERATE_COT)
Achin Gupta4f6ad662013-10-25 09:08:21 +01001132
Masahiro Yamada4d87eb42016-12-25 13:52:22 +09001133ifneq (${FIP_ALIGN},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001134 FIP_ARGS += --align ${FIP_ALIGN}
1135endif #(FIP_ALIGN)
Masahiro Yamada4d87eb42016-12-25 13:52:22 +09001136
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001137ifdef FDT_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001138 NEED_FDT := yes
1139endif #(FDT_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001140
Juan Castilloa3487d12015-08-18 14:23:04 +01001141################################################################################
Michalis Pappas0f223c52018-03-20 13:01:27 +08001142# Include libraries' Makefile that are used in all BL
1143################################################################################
1144
1145include lib/stack_protector/stack_protector.mk
1146
1147################################################################################
Soby Mathew574e01e2017-02-14 10:05:07 +00001148# Include BL specific makefiles
1149################################################################################
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001150
1151ifeq (${NEED_BL1},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001152include bl1/bl1.mk
1153endif
1154
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001155ifeq (${NEED_BL2},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001156include bl2/bl2.mk
1157endif
1158
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001159ifeq (${NEED_BL2U},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001160include bl2u/bl2u.mk
1161endif
1162
Soby Mathewbf169232017-11-14 14:10:10 +00001163ifeq (${NEED_BL31},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001164include bl31/bl31.mk
1165endif
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001166
Soby Mathew574e01e2017-02-14 10:05:07 +00001167################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001168# Build options checks
1169################################################################################
1170
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001171# Boolean_Flags
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001172$(eval $(call assert_booleans,\
1173 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001174 ALLOW_RO_XLAT_TABLES \
1175 BL2_ENABLE_SP_LOAD \
1176 COLD_BOOT_SINGLE_CPU \
1177 CREATE_KEYS \
1178 CTX_INCLUDE_AARCH32_REGS \
1179 CTX_INCLUDE_FPREGS \
Madhukar Pappireddydd9af9b2024-06-17 15:17:03 -05001180 CTX_INCLUDE_SVE_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001181 CTX_INCLUDE_EL2_REGS \
Arvind Ram Prakash4851b492023-10-06 14:35:21 -05001182 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001183 DEBUG \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001184 DYN_DISABLE_AUTH \
1185 EL3_EXCEPTION_HANDLING \
1186 ENABLE_AMU_AUXILIARY_COUNTERS \
1187 ENABLE_AMU_FCONF \
1188 AMU_RESTRICT_COUNTERS \
1189 ENABLE_ASSERTIONS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001190 ENABLE_PIE \
1191 ENABLE_PMF \
1192 ENABLE_PSCI_STAT \
1193 ENABLE_RUNTIME_INSTRUMENTATION \
1194 ENABLE_SME_FOR_SWD \
1195 ENABLE_SVE_FOR_SWD \
Manish Pandey514a3012023-10-10 13:53:25 +01001196 ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +01001197 FFH_SUPPORT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001198 ERROR_DEPRECATED \
1199 FAULT_INJECTION_SUPPORT \
1200 GENERATE_COT \
1201 GICV2_G0_FOR_EL3 \
1202 HANDLE_EA_EL3_FIRST_NS \
Bipin Ravie53e6ae2023-09-28 13:17:24 -05001203 HARDEN_SLS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001204 HW_ASSISTED_COHERENCY \
1205 MEASURED_BOOT \
Tamas Bana4260892023-06-07 13:35:04 +02001206 DICE_PROTECTION_ENVIRONMENT \
Raghu Krishnamurthyc11b60e2024-06-03 19:02:29 -07001207 RMMD_ENABLE_EL3_TOKEN_SIGN \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001208 DRTM_SUPPORT \
1209 NS_TIMER_SWITCH \
1210 OVERRIDE_LIBC \
1211 PL011_GENERIC_UART \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001212 PROGRAMMABLE_RESET_ADDRESS \
1213 PSCI_EXTENDED_STATE_ID \
1214 PSCI_OS_INIT_MODE \
Boyan Karatotev8e7c43c2024-10-25 11:38:41 +01001215 ARCH_FEATURE_AVAILABILITY \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001216 RESET_TO_BL31 \
1217 SAVE_KEYS \
1218 SEPARATE_CODE_AND_RODATA \
1219 SEPARATE_BL2_NOLOAD_REGION \
1220 SEPARATE_NOBITS_REGION \
Ye Li97267752022-08-26 13:48:31 +08001221 SEPARATE_RWDATA_REGION \
Madhukar Pappireddy5c1b8d92024-06-17 15:26:00 -05001222 SEPARATE_SIMD_SECTION \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001223 SPIN_ON_BL1_EXIT \
1224 SPM_MM \
1225 SPMC_AT_EL3 \
Nishant Sharma9e719112023-06-27 00:36:01 +01001226 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001227 SPMD_SPM_AT_SEL2 \
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -08001228 ENABLE_SPMD_LP \
Raymond Mao98983392023-07-25 07:53:35 -07001229 TRANSFER_LIST \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001230 TRUSTED_BOARD_BOOT \
1231 USE_COHERENT_MEM \
1232 USE_DEBUGFS \
1233 ARM_IO_IN_DTB \
1234 SDEI_IN_FCONF \
1235 SEC_INT_DESC_IN_FCONF \
1236 USE_ROMLIB \
1237 USE_TBBR_DEFS \
1238 WARMBOOT_ENABLE_DCACHE_EARLY \
1239 RESET_TO_BL2 \
1240 BL2_IN_XIP_MEM \
1241 BL2_INV_DCACHE \
1242 USE_SPINLOCK_CAS \
1243 ENCRYPT_BL31 \
1244 ENCRYPT_BL32 \
1245 ERRATA_SPECULATIVE_AT \
1246 RAS_TRAP_NS_ERR_REC_ACCESS \
1247 COT_DESC_IN_DTB \
1248 USE_SP804_TIMER \
1249 PSA_FWU_SUPPORT \
Sughosh Ganu61905e52024-02-01 12:51:20 +05301250 PSA_FWU_METADATA_FW_STORE_DESC \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001251 ENABLE_MPMM \
1252 ENABLE_MPMM_FCONF \
1253 FEATURE_DETECTION \
Jayanth Dodderi Chidanand7c7faff2022-10-11 17:16:07 +01001254 TRNG_SUPPORT \
Sona Mathew7fe03522022-11-18 18:05:38 -06001255 ERRATA_ABI_SUPPORT \
Sona Mathew5a4c9fc2023-03-14 14:02:03 -05001256 ERRATA_NON_ARM_INTERCONNECT \
Okash Khawaja037b56e2022-11-04 12:38:01 +00001257 CONDITIONAL_CMO \
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001258 PSA_CRYPTO \
Sandrine Bailleuxf57e2032023-10-11 08:38:00 +02001259 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash8bd27c92023-08-15 16:28:06 -05001260 INIT_UNUSED_NS_EL2 \
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001261 PLATFORM_REPORT_CTX_MEM_USE \
Yann Gautier5ae29c02024-01-16 19:39:31 +01001262 EARLY_CONSOLE \
Arvind Ram Prakasheaa90192023-12-21 00:25:52 -06001263 PRESERVE_DSU_PMU_REGS \
Levi Yun03adb132024-05-13 10:24:31 +01001264 HOB_LIST \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001265)))
Dan Handley81be1002015-03-27 17:44:35 +00001266
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001267# Numeric_Flags
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001268$(eval $(call assert_numerics,\
1269 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001270 ARM_ARCH_MAJOR \
1271 ARM_ARCH_MINOR \
1272 BRANCH_PROTECTION \
1273 CTX_INCLUDE_PAUTH_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001274 CTX_INCLUDE_NEVE_REGS \
1275 CRYPTO_SUPPORT \
Boyan Karatotev677ed8a2023-02-16 09:45:29 +00001276 DISABLE_MTPMU \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001277 ENABLE_BRBE_FOR_NS \
1278 ENABLE_TRBE_FOR_NS \
1279 ENABLE_BTI \
1280 ENABLE_PAUTH \
1281 ENABLE_FEAT_AMU \
1282 ENABLE_FEAT_AMUv1p1 \
1283 ENABLE_FEAT_CSV2_2 \
Sona Mathew3b84c962023-10-25 16:48:19 -05001284 ENABLE_FEAT_CSV2_3 \
Arvind Ram Prakash05b47632024-05-22 15:24:00 -05001285 ENABLE_FEAT_DEBUGV8P9 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001286 ENABLE_FEAT_DIT \
1287 ENABLE_FEAT_ECV \
1288 ENABLE_FEAT_FGT \
Arvind Ram Prakash62d87e72024-06-06 11:33:37 -05001289 ENABLE_FEAT_FGT2 \
Arvind Ram Prakashe558f9c2024-11-11 14:32:37 -06001290 ENABLE_FEAT_FPMR \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001291 ENABLE_FEAT_HCX \
Andre Przywara8fc8e182024-08-09 17:04:22 +01001292 ENABLE_FEAT_LS64_ACCDATA \
Arvind Ram Prakashf915deb2025-01-09 17:18:30 -06001293 ENABLE_FEAT_MOPS \
Govindraj Rajad7b63ac2024-01-26 10:08:37 -06001294 ENABLE_FEAT_MTE2 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001295 ENABLE_FEAT_PAN \
1296 ENABLE_FEAT_RNG \
1297 ENABLE_FEAT_RNG_TRAP \
1298 ENABLE_FEAT_SEL2 \
1299 ENABLE_FEAT_TCR2 \
Jayanth Dodderi Chidanand6b706862024-09-05 22:24:04 +01001300 ENABLE_FEAT_THE \
Govindraj Rajac2dad572024-01-23 16:03:53 -06001301 ENABLE_FEAT_SB \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001302 ENABLE_FEAT_S2PIE \
1303 ENABLE_FEAT_S1PIE \
1304 ENABLE_FEAT_S2POE \
1305 ENABLE_FEAT_S1POE \
Jayanth Dodderi Chidanand70cc1752024-09-06 13:49:31 +01001306 ENABLE_FEAT_SCTLR2 \
Govindraj Rajae63794e2024-09-06 15:43:43 +01001307 ENABLE_FEAT_D128 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001308 ENABLE_FEAT_GCS \
1309 ENABLE_FEAT_VHE \
Arvind Ram Prakashab28d4b2023-10-11 12:10:56 -05001310 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001311 ENABLE_RME \
1312 ENABLE_SPE_FOR_NS \
1313 ENABLE_SYS_REG_TRACE_FOR_NS \
1314 ENABLE_SME_FOR_NS \
1315 ENABLE_SME2_FOR_NS \
1316 ENABLE_SVE_FOR_NS \
1317 ENABLE_TRF_FOR_NS \
1318 FW_ENC_STATUS \
1319 NR_OF_FW_BANKS \
1320 NR_OF_IMAGES_IN_FW_BANK \
1321 TWED_DELAY \
1322 ENABLE_FEAT_TWED \
1323 SVE_VECTOR_LEN \
Varun Wadekar0a46eb12023-04-13 21:06:18 +01001324 IMPDEF_SYSREG_TRAP \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001325)))
Jeenu Viswambharanfca76802017-01-16 16:52:35 +00001326
Justin Chadwellf9b32c12019-07-29 17:13:10 +01001327ifdef KEY_SIZE
1328 $(eval $(call assert_numeric,KEY_SIZE))
1329endif
1330
Justin Chadwell83e04882019-08-20 11:01:52 +01001331ifeq ($(filter $(SANITIZE_UB), on off trap),)
1332 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
1333endif
1334
Juan Castilloa3487d12015-08-18 14:23:04 +01001335################################################################################
1336# Add definitions to the cpp preprocessor based on the current build options.
1337# This is done after including the platform specific makefile to allow the
1338# platform to overwrite the default options
1339################################################################################
Jeenu Viswambharand1b60152014-05-12 15:28:47 +01001340
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001341$(eval $(call add_defines,\
1342 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001343 ALLOW_RO_XLAT_TABLES \
1344 ARM_ARCH_MAJOR \
1345 ARM_ARCH_MINOR \
1346 BL2_ENABLE_SP_LOAD \
1347 COLD_BOOT_SINGLE_CPU \
1348 CTX_INCLUDE_AARCH32_REGS \
1349 CTX_INCLUDE_FPREGS \
Madhukar Pappireddydd9af9b2024-06-17 15:17:03 -05001350 CTX_INCLUDE_SVE_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001351 CTX_INCLUDE_PAUTH_REGS \
Arvind Ram Prakash4851b492023-10-06 14:35:21 -05001352 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001353 EL3_EXCEPTION_HANDLING \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001354 CTX_INCLUDE_EL2_REGS \
1355 CTX_INCLUDE_NEVE_REGS \
1356 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
1357 DISABLE_MTPMU \
1358 ENABLE_FEAT_AMU \
1359 ENABLE_AMU_AUXILIARY_COUNTERS \
1360 ENABLE_AMU_FCONF \
1361 AMU_RESTRICT_COUNTERS \
1362 ENABLE_ASSERTIONS \
1363 ENABLE_BTI \
Arvind Ram Prakash05b47632024-05-22 15:24:00 -05001364 ENABLE_FEAT_DEBUGV8P9 \
Arvind Ram Prakashab28d4b2023-10-11 12:10:56 -05001365 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001366 ENABLE_PAUTH \
1367 ENABLE_PIE \
1368 ENABLE_PMF \
1369 ENABLE_PSCI_STAT \
1370 ENABLE_RME \
Raghu Krishnamurthyc11b60e2024-06-03 19:02:29 -07001371 RMMD_ENABLE_EL3_TOKEN_SIGN \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001372 ENABLE_RUNTIME_INSTRUMENTATION \
1373 ENABLE_SME_FOR_NS \
1374 ENABLE_SME2_FOR_NS \
1375 ENABLE_SME_FOR_SWD \
1376 ENABLE_SPE_FOR_NS \
1377 ENABLE_SVE_FOR_NS \
1378 ENABLE_SVE_FOR_SWD \
Manish Pandey514a3012023-10-10 13:53:25 +01001379 ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +01001380 FFH_SUPPORT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001381 ENCRYPT_BL31 \
1382 ENCRYPT_BL32 \
1383 ERROR_DEPRECATED \
1384 FAULT_INJECTION_SUPPORT \
1385 GICV2_G0_FOR_EL3 \
1386 HANDLE_EA_EL3_FIRST_NS \
1387 HW_ASSISTED_COHERENCY \
1388 LOG_LEVEL \
1389 MEASURED_BOOT \
Tamas Bana4260892023-06-07 13:35:04 +02001390 DICE_PROTECTION_ENVIRONMENT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001391 DRTM_SUPPORT \
1392 NS_TIMER_SWITCH \
1393 PL011_GENERIC_UART \
1394 PLAT_${PLAT} \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001395 PROGRAMMABLE_RESET_ADDRESS \
1396 PSCI_EXTENDED_STATE_ID \
1397 PSCI_OS_INIT_MODE \
Boyan Karatotev8e7c43c2024-10-25 11:38:41 +01001398 ARCH_FEATURE_AVAILABILITY \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001399 RESET_TO_BL31 \
AlexeiFedorovc0ca2d72024-05-13 15:35:54 +01001400 RME_GPT_BITLOCK_BLOCK \
AlexeiFedorovbd8b1bb2024-03-13 17:07:03 +00001401 RME_GPT_MAX_BLOCK \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001402 SEPARATE_CODE_AND_RODATA \
1403 SEPARATE_BL2_NOLOAD_REGION \
1404 SEPARATE_NOBITS_REGION \
Ye Li97267752022-08-26 13:48:31 +08001405 SEPARATE_RWDATA_REGION \
Madhukar Pappireddy5c1b8d92024-06-17 15:26:00 -05001406 SEPARATE_SIMD_SECTION \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001407 RECLAIM_INIT_CODE \
1408 SPD_${SPD} \
1409 SPIN_ON_BL1_EXIT \
1410 SPM_MM \
1411 SPMC_AT_EL3 \
Nishant Sharma9e719112023-06-27 00:36:01 +01001412 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001413 SPMD_SPM_AT_SEL2 \
Raymond Mao98983392023-07-25 07:53:35 -07001414 TRANSFER_LIST \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001415 TRUSTED_BOARD_BOOT \
1416 CRYPTO_SUPPORT \
1417 TRNG_SUPPORT \
1418 ERRATA_ABI_SUPPORT \
Sona Mathew5a4c9fc2023-03-14 14:02:03 -05001419 ERRATA_NON_ARM_INTERCONNECT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001420 USE_COHERENT_MEM \
1421 USE_DEBUGFS \
1422 ARM_IO_IN_DTB \
1423 SDEI_IN_FCONF \
1424 SEC_INT_DESC_IN_FCONF \
1425 USE_ROMLIB \
1426 USE_TBBR_DEFS \
1427 WARMBOOT_ENABLE_DCACHE_EARLY \
1428 RESET_TO_BL2 \
1429 BL2_RUNS_AT_EL3 \
1430 BL2_IN_XIP_MEM \
1431 BL2_INV_DCACHE \
1432 USE_SPINLOCK_CAS \
1433 ERRATA_SPECULATIVE_AT \
1434 RAS_TRAP_NS_ERR_REC_ACCESS \
1435 COT_DESC_IN_DTB \
1436 USE_SP804_TIMER \
1437 ENABLE_FEAT_RNG \
1438 ENABLE_FEAT_RNG_TRAP \
1439 ENABLE_FEAT_SB \
1440 ENABLE_FEAT_DIT \
1441 NR_OF_FW_BANKS \
1442 NR_OF_IMAGES_IN_FW_BANK \
1443 PSA_FWU_SUPPORT \
Sughosh Ganu61905e52024-02-01 12:51:20 +05301444 PSA_FWU_METADATA_FW_STORE_DESC \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001445 ENABLE_BRBE_FOR_NS \
1446 ENABLE_TRBE_FOR_NS \
1447 ENABLE_SYS_REG_TRACE_FOR_NS \
1448 ENABLE_TRF_FOR_NS \
1449 ENABLE_FEAT_HCX \
1450 ENABLE_MPMM \
1451 ENABLE_MPMM_FCONF \
1452 ENABLE_FEAT_FGT \
Arvind Ram Prakash62d87e72024-06-06 11:33:37 -05001453 ENABLE_FEAT_FGT2 \
Arvind Ram Prakashe558f9c2024-11-11 14:32:37 -06001454 ENABLE_FEAT_FPMR \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001455 ENABLE_FEAT_ECV \
1456 ENABLE_FEAT_AMUv1p1 \
1457 ENABLE_FEAT_SEL2 \
1458 ENABLE_FEAT_VHE \
1459 ENABLE_FEAT_CSV2_2 \
Sona Mathew3b84c962023-10-25 16:48:19 -05001460 ENABLE_FEAT_CSV2_3 \
Andre Przywara8fc8e182024-08-09 17:04:22 +01001461 ENABLE_FEAT_LS64_ACCDATA \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001462 ENABLE_FEAT_PAN \
1463 ENABLE_FEAT_TCR2 \
Jayanth Dodderi Chidanand6b706862024-09-05 22:24:04 +01001464 ENABLE_FEAT_THE \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001465 ENABLE_FEAT_S2PIE \
1466 ENABLE_FEAT_S1PIE \
1467 ENABLE_FEAT_S2POE \
1468 ENABLE_FEAT_S1POE \
Jayanth Dodderi Chidanand70cc1752024-09-06 13:49:31 +01001469 ENABLE_FEAT_SCTLR2 \
Govindraj Rajae63794e2024-09-06 15:43:43 +01001470 ENABLE_FEAT_D128 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001471 ENABLE_FEAT_GCS \
Arvind Ram Prakashf915deb2025-01-09 17:18:30 -06001472 ENABLE_FEAT_MOPS \
Govindraj Rajad7b63ac2024-01-26 10:08:37 -06001473 ENABLE_FEAT_MTE2 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001474 FEATURE_DETECTION \
1475 TWED_DELAY \
1476 ENABLE_FEAT_TWED \
Okash Khawaja037b56e2022-11-04 12:38:01 +00001477 CONDITIONAL_CMO \
Varun Wadekar0a46eb12023-04-13 21:06:18 +01001478 IMPDEF_SYSREG_TRAP \
Jayanth Dodderi Chidanand23c2fe22023-04-26 15:57:30 +01001479 SVE_VECTOR_LEN \
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -08001480 ENABLE_SPMD_LP \
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001481 PSA_CRYPTO \
Sandrine Bailleuxf57e2032023-10-11 08:38:00 +02001482 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash8bd27c92023-08-15 16:28:06 -05001483 INIT_UNUSED_NS_EL2 \
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001484 PLATFORM_REPORT_CTX_MEM_USE \
Yann Gautier5ae29c02024-01-16 19:39:31 +01001485 EARLY_CONSOLE \
Arvind Ram Prakasheaa90192023-12-21 00:25:52 -06001486 PRESERVE_DSU_PMU_REGS \
Levi Yun03adb132024-05-13 10:24:31 +01001487 HOB_LIST \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001488)))
Jeenu Viswambharan615ff392016-10-24 14:31:51 +01001489
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001490ifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1)
1491ifeq (${DEBUG}, 0)
1492 $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only")
1493 override PLATFORM_REPORT_CTX_MEM_USE := 0
1494endif
1495endif
1496
Justin Chadwell83e04882019-08-20 11:01:52 +01001497ifeq (${SANITIZE_UB},trap)
1498 $(eval $(call add_define,MONITOR_TRAPS))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001499endif #(SANITIZE_UB)
Justin Chadwell83e04882019-08-20 11:01:52 +01001500
Sandrine Bailleux03897bb2015-11-26 16:31:34 +00001501# Define the EL3_PAYLOAD_BASE flag only if it is provided.
1502ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +00001503 $(eval $(call add_define,EL3_PAYLOAD_BASE))
1504else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001505# Define the PRELOADED_BL33_BASE flag only if it is provided and
1506# EL3_PAYLOAD_BASE is not defined, as it has priority.
1507 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz2b8277b2016-04-06 17:31:57 +01001508 $(eval $(call add_define,PRELOADED_BL33_BASE))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001509 endif
1510endif #(EL3_PAYLOAD_BASE)
Soby Mathew85dbf5a2015-04-07 12:16:56 +01001511
Soby Mathew9fe88042018-03-26 12:43:37 +01001512# Define the DYN_DISABLE_AUTH flag only if set.
1513ifeq (${DYN_DISABLE_AUTH},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001514 $(eval $(call add_define,DYN_DISABLE_AUTH))
Soby Mathew9fe88042018-03-26 12:43:37 +01001515endif
1516
Chris Kaycfba6452023-12-04 09:55:50 +00001517ifeq ($($(ARCH)-ld-id),arm-link)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001518 $(eval $(call add_define,USE_ARM_LINK))
Varun Wadekar4d034c52019-01-11 14:47:48 -08001519endif
1520
Manish Pandey3f90ad72020-01-14 11:52:05 +00001521# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
Manish Pandey3f90ad72020-01-14 11:52:05 +00001522ifeq (${SPD},spmd)
Olivier Deprez042db532020-03-19 09:27:11 +01001523ifdef SP_LAYOUT_FILE
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001524 -include $(BUILD_PLAT)/sp_gen.mk
1525 FIP_DEPS += sp
1526 CRT_DEPS += sp
1527 NEED_SP_PKG := yes
Manish Pandey3f90ad72020-01-14 11:52:05 +00001528else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001529 ifeq (${SPMD_SPM_AT_SEL2},1)
1530 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1531 endif
1532endif #(SP_LAYOUT_FILE)
1533endif #(SPD)
Manish Pandey3f90ad72020-01-14 11:52:05 +00001534
Juan Castilloa3487d12015-08-18 14:23:04 +01001535################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001536# Build targets
1537################################################################################
Achin Gupta4f6ad662013-10-25 09:08:21 +01001538
Harrison Mutai36d971a2024-08-28 13:27:19 +00001539.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp tl fwu_fip certtool dtbs memmap doc enctool
Achin Gupta4f6ad662013-10-25 09:08:21 +01001540
Juan Castilloa3487d12015-08-18 14:23:04 +01001541all: msg_start
Harry Liebelf58ad362014-01-10 18:00:33 +00001542
Juan Castilloa3487d12015-08-18 14:23:04 +01001543msg_start:
Chris Kay1870c722024-05-02 17:52:37 +00001544 $(s)echo "Building ${PLAT}"
Juan Castillo11abdcd2014-10-21 11:30:42 +01001545
Soby Mathew18a62042015-10-26 14:29:21 +00001546ifeq (${ERROR_DEPRECATED},0)
Julius Werner53456fc2019-07-09 13:49:11 -07001547# Check if deprecated declarations and cpp warnings should be treated as error or not.
Chris Kaycfba6452023-12-04 09:55:50 +00001548ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
Varun Wadekar4d034c52019-01-11 14:47:48 -08001549 CPPFLAGS += -Wno-error=deprecated-declarations
1550else
Dan Handley6fa89a22018-02-27 16:03:58 +00001551 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp
Soby Mathew18a62042015-10-26 14:29:21 +00001552endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001553endif #(!ERROR_DEPRECATED)
Soby Mathew18a62042015-10-26 14:29:21 +00001554
Roberto Vargas0f8f9852018-05-08 10:27:10 +01001555$(eval $(call MAKE_LIB,c))
Roberto Vargas21360f32018-05-08 10:27:10 +01001556
Juan Castilloa3487d12015-08-18 14:23:04 +01001557# Expand build macros for the different images
1558ifeq (${NEED_BL1},yes)
Chris Kay0a542ec2021-09-28 15:44:19 +01001559BL1_SOURCES := $(sort ${BL1_SOURCES})
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001560$(eval $(call MAKE_BL,bl1))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001561endif #(NEED_BL1)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001562
Juan Castilloa3487d12015-08-18 14:23:04 +01001563ifeq (${NEED_BL2},yes)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001564
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -06001565ifeq (${RESET_TO_BL2}, 0)
Roberto Vargas53c052b2018-01-02 11:23:41 +00001566FIP_BL2_ARGS := tb-fw
1567endif
1568
Chris Kayfb3b0512021-09-28 15:44:37 +01001569BL2_SOURCES := $(sort ${BL2_SOURCES})
1570
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001571$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001572 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001573
1574endif #(NEED_BL2)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001575
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001576ifeq (${NEED_SCP_BL2},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001577$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001578endif #(NEED_SCP_BL2)
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001579
Juan Castilloa3487d12015-08-18 14:23:04 +01001580ifeq (${NEED_BL31},yes)
1581BL31_SOURCES += ${SPD_SOURCES}
Madhukar Pappireddyae9677b2020-01-27 13:37:51 -06001582# Sort BL31 source files to remove duplicates
1583BL31_SOURCES := $(sort ${BL31_SOURCES})
Sumit Gargeec52442019-11-14 16:33:45 +05301584ifneq (${DECRYPTION_SUPPORT},none)
1585$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001586 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
Sumit Gargeec52442019-11-14 16:33:45 +05301587else
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001588$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001589 $(eval $(call MAKE_BL,bl31,soc-fw)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001590endif #(DECRYPTION_SUPPORT)
1591endif #(NEED_BL31)
Juan Castillo379954c2014-11-04 17:36:40 +00001592
Juan Castillo671b8db2015-11-12 10:59:26 +00001593# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
Masahiro Yamada4d156802018-01-26 11:42:01 +09001594# build system will call TOOL_ADD_IMG to print a warning message and abort the
Juan Castillo671b8db2015-11-12 10:59:26 +00001595# process. Note that the dependency on BL32 applies to the FIP only.
Juan Castilloa3487d12015-08-18 14:23:04 +01001596ifeq (${NEED_BL32},yes)
Madhukar Pappireddyae9677b2020-01-27 13:37:51 -06001597# Sort BL32 source files to remove duplicates
1598BL32_SOURCES := $(sort ${BL32_SOURCES})
Masahiro Yamada6ced1b22018-01-26 11:42:01 +09001599BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
1600
Sumit Gargeec52442019-11-14 16:33:45 +05301601ifneq (${DECRYPTION_SUPPORT},none)
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001602$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
Sumit Gargeec52442019-11-14 16:33:45 +05301603 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1604else
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001605$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001606 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001607endif #(DECRYPTION_SUPPORT)
1608endif #(NEED_BL32)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001609
Zelalem Aweke4d37db82021-07-11 18:33:20 -05001610# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
1611# needs to be built from RMM_SOURCES.
1612ifeq (${NEED_RMM},yes)
1613# Sort RMM source files to remove duplicates
1614RMM_SOURCES := $(sort ${RMM_SOURCES})
1615BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
1616
1617$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001618 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1619endif #(NEED_RMM)
Zelalem Aweke4d37db82021-07-11 18:33:20 -05001620
Juan Castilloa3487d12015-08-18 14:23:04 +01001621# Add the BL33 image if required by the platform
1622ifeq (${NEED_BL33},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001623$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001624endif #(NEED_BL33)
Juan Castillo9c25a402015-01-13 12:21:04 +00001625
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001626ifeq (${NEED_BL2U},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001627$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001628 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001629endif #(NEED_BL2U)
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001630
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001631# Expand build macros for the different images
1632ifeq (${NEED_FDT},yes)
Soby Mathewab4181d2017-12-14 17:44:56 +00001633 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001634endif #(NEED_FDT)
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001635
Manish Pandey3f90ad72020-01-14 11:52:05 +00001636# Add Secure Partition packages
1637ifeq (${NEED_SP_PKG},yes)
Chris Kayd67442e2024-07-30 13:33:56 +00001638$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | $$(@D)/
Chris Kay1870c722024-05-02 17:52:37 +00001639 $(q)${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
J-Alvesef8e0982022-03-22 16:28:51 +00001640sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
Chris Kay1870c722024-05-02 17:52:37 +00001641 $(s)echo
1642 $(s)echo "Built SP Images successfully"
1643 $(s)echo
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001644endif #(NEED_SP_PKG)
Manish Pandey3f90ad72020-01-14 11:52:05 +00001645
Ian Spray36eaaf32014-01-30 17:25:28 +00001646locate-checkpatch:
1647ifndef CHECKPATCH
Etienne Carrieref5657572017-08-23 15:44:01 +02001648 $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
Ian Spray36eaaf32014-01-30 17:25:28 +00001649else
1650ifeq (,$(wildcard ${CHECKPATCH}))
Etienne Carrieref5657572017-08-23 15:44:01 +02001651 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
Ian Spray36eaaf32014-01-30 17:25:28 +00001652endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001653endif #(CHECKPATCH)
Ian Spray36eaaf32014-01-30 17:25:28 +00001654
Achin Gupta4f6ad662013-10-25 09:08:21 +01001655clean:
Chris Kay1870c722024-05-02 17:52:37 +00001656 $(s)echo " CLEAN"
Chris Kayfaab7482025-01-13 15:57:32 +00001657 $(q)rm -rf $(BUILD_PLAT)
Chris Kay1870c722024-05-02 17:52:37 +00001658 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Chris Kay1870c722024-05-02 17:52:37 +00001659 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
1660 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
1661 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001662
James Morrisseyeaaeece2013-11-01 13:56:59 +00001663realclean distclean:
Chris Kay1870c722024-05-02 17:52:37 +00001664 $(s)echo " REALCLEAN"
Chris Kayfaab7482025-01-13 15:57:32 +00001665 $(q)rm -rf $(BUILD_BASE)
1666 $(q)rm -rf $(CURDIR)/cscope.*
Chris Kay1870c722024-05-02 17:52:37 +00001667 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Chris Kay1870c722024-05-02 17:52:37 +00001668 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
1669 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
1670 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001671
Ian Spray36eaaf32014-01-30 17:25:28 +00001672checkcodebase: locate-checkpatch
Chris Kay1870c722024-05-02 17:52:37 +00001673 $(s)echo " CHECKING STYLE"
1674 $(q)if test -d .git ; then \
Paul Beesleyadfab5b2019-03-07 16:42:31 +00001675 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \
Dan Handley3a355712016-06-02 18:21:02 +01001676 while read GIT_FILE ; \
1677 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
1678 done ; \
1679 else \
1680 find . -type f -not -iwholename "*.git*" \
1681 -not -iwholename "*build*" \
1682 -not -iwholename "*libfdt*" \
Roberto Vargas0f8f9852018-05-08 10:27:10 +01001683 -not -iwholename "*libc*" \
Dan Handley3a355712016-06-02 18:21:02 +01001684 -not -iwholename "*docs*" \
Paul Beesleyadfab5b2019-03-07 16:42:31 +00001685 -not -iwholename "*.rst" \
Dan Handley3a355712016-06-02 18:21:02 +01001686 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
1687 fi
Ian Spray36eaaf32014-01-30 17:25:28 +00001688
1689checkpatch: locate-checkpatch
Chris Kay1870c722024-05-02 17:52:37 +00001690 $(s)echo " CHECKING STYLE"
1691 $(q)if test -n "${CHECKPATCH_OPTS}"; then \
Yann Gautier0c26a2a2019-03-08 15:44:00 +01001692 echo " with ${CHECKPATCH_OPTS} option(s)"; \
1693 fi
Chris Kay1870c722024-05-02 17:52:37 +00001694 $(q)COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
Yann Gautiera10a6852021-11-02 18:03:31 +01001695 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \
1696 do \
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001697 printf "\n[*] Checking style of '$$commit'\n\n"; \
Yann Gautierfaf8c612024-08-09 11:52:03 +02001698 ( git log --format=email "$$commit~..$$commit" \
1699 -- ${CHECK_PATHS} ; \
1700 git diff --format=email "$$commit~..$$commit" \
1701 -- ${CHECK_PATHS}; ) | \
Yann Gautier0c26a2a2019-03-08 15:44:00 +01001702 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001703 done
Juan Castilloa3487d12015-08-18 14:23:04 +01001704
1705certtool: ${CRTTOOL}
Ian Spray36eaaf32014-01-30 17:25:28 +00001706
Pali Rohár54ff2132020-11-24 15:38:08 +01001707${CRTTOOL}: FORCE
Chris Kay1870c722024-05-02 17:52:37 +00001708 $(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
1709 $(s)echo
1710 $(s)echo "Built $@ successfully"
1711 $(s)echo
Jon Medhurst407a95c2014-02-12 15:54:48 +00001712
Juan Castillo11abdcd2014-10-21 11:30:42 +01001713ifneq (${GENERATE_COT},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001714certificates: ${CRT_DEPS} ${CRTTOOL}
Chris Kay1870c722024-05-02 17:52:37 +00001715 $(q)${CRTTOOL} ${CRT_ARGS}
1716 $(s)echo
1717 $(s)echo "Built $@ successfully"
1718 $(s)echo "Certificates can be found in ${BUILD_PLAT}"
1719 $(s)echo
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001720endif #(GENERATE_COT)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001721
Juan Castilloa3487d12015-08-18 14:23:04 +01001722${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
Pali Rohára5416ab2020-11-24 16:53:04 +01001723 $(eval ${CHECK_FIP_CMD})
Chris Kay1870c722024-05-02 17:52:37 +00001724 $(q)${FIPTOOL} create ${FIP_ARGS} $@
1725 $(q)${FIPTOOL} info $@
1726 $(s)echo
1727 $(s)echo "Built $@ successfully"
1728 $(s)echo
Soby Mathewdbee7fc2014-09-08 17:51:01 +01001729
Yatharth Kochard1a93432015-10-12 12:33:47 +01001730ifneq (${GENERATE_COT},0)
1731fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
Chris Kay1870c722024-05-02 17:52:37 +00001732 $(q)${CRTTOOL} ${FWU_CRT_ARGS}
1733 $(s)echo
1734 $(s)echo "Built $@ successfully"
1735 $(s)echo "FWU certificates can be found in ${BUILD_PLAT}"
1736 $(s)echo
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001737endif #(GENERATE_COT)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001738
1739${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
Pali Rohára5416ab2020-11-24 16:53:04 +01001740 $(eval ${CHECK_FWU_FIP_CMD})
Chris Kay1870c722024-05-02 17:52:37 +00001741 $(q)${FIPTOOL} create ${FWU_FIP_ARGS} $@
1742 $(q)${FIPTOOL} info $@
1743 $(s)echo
1744 $(s)echo "Built $@ successfully"
1745 $(s)echo
Yatharth Kochard1a93432015-10-12 12:33:47 +01001746
Juan Castilloa3487d12015-08-18 14:23:04 +01001747fiptool: ${FIPTOOL}
1748fip: ${BUILD_PLAT}/${FIP_NAME}
Yatharth Kochard1a93432015-10-12 12:33:47 +01001749fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
Harry Liebelf58ad362014-01-10 18:00:33 +00001750
Pali Rohár54ff2132020-11-24 15:38:08 +01001751${FIPTOOL}: FORCE
Manish V Badarkhe0a5acd42024-10-03 20:50:04 +01001752 $(q)${MAKE} PLAT=${PLAT} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${FIPTOOLPATH} all
Harry Liebelf58ad362014-01-10 18:00:33 +00001753
Manish V Badarkhe8cad2e12024-12-03 21:46:51 +00001754$(BUILD_PLAT)/romlib/romlib.bin $(BUILD_PLAT)/lib/libwrappers.a $&: $(BUILD_PLAT)/lib/libfdt.a $(BUILD_PLAT)/lib/libc.a $(CRYPTO_LIB)
1755 $(q)${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} CRYPTO_SUPPORT=${CRYPTO_SUPPORT} ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES=$(call escape-shell,$(INCLUDES)) DEFINES=$(call escape-shell,$(DEFINES)) --no-print-directory -C ${ROMLIBPATH} all
Roberto Vargase92111a2018-05-22 16:05:42 +01001756
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +01001757memmap: all
Chris Kay1870c722024-05-02 17:52:37 +00001758 $(q)PYTHONPATH=${CURDIR}/tools/memory \
Harrison Mutaie9bc4882023-02-23 10:33:58 +00001759 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +01001760
Harrison Mutai36d971a2024-08-28 13:27:19 +00001761tl: ${BUILD_PLAT}/tl.bin
1762${BUILD_PLAT}/tl.bin: ${HW_CONFIG}
Chris Kaya152e752024-09-26 14:18:04 +00001763 $(if $(host-poetry),$(q)poetry -q install)
1764 $(q)$(if $(host-poetry),poetry run )tlc create --fdt $< -s ${FW_HANDOFF_SIZE} $@
Harrison Mutai36d971a2024-08-28 13:27:19 +00001765
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -06001766doc:
Chris Kay1870c722024-05-02 17:52:37 +00001767 $(s)echo " BUILD DOCUMENTATION"
1768 $(q)${MAKE} --no-print-directory -C ${DOCS_PATH} html
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -06001769
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301770enctool: ${ENCTOOL}
1771
Pali Rohár54ff2132020-11-24 15:38:08 +01001772${ENCTOOL}: FORCE
Chris Kay1870c722024-05-02 17:52:37 +00001773 $(q)${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} --no-print-directory -C ${ENCTOOLPATH} all
1774 $(s)echo
1775 $(s)echo "Built $@ successfully"
1776 $(s)echo
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301777
Joakim Bech35fab8c2014-01-23 14:51:49 +01001778cscope:
Chris Kay1870c722024-05-02 17:52:37 +00001779 $(s)echo " CSCOPE"
1780 $(q)find ${CURDIR} -name "*.[chsS]" > cscope.files
1781 $(q)cscope -b -q -k
Joakim Bech35fab8c2014-01-23 14:51:49 +01001782
Ryan Harkin72ee3312014-01-15 16:55:07 +00001783help:
Chris Kay1870c722024-05-02 17:52:37 +00001784 $(s)echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
1785 $(s)echo ""
1786 $(s)echo "PLAT is used to specify which platform you wish to build."
1787 $(s)echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
1788 $(s)echo ""
1789 $(s)echo "platform = ${PLATFORM_LIST}"
1790 $(s)echo ""
1791 $(s)echo "Please refer to the User Guide for a list of all supported options."
1792 $(s)echo "Note that the build system doesn't track dependencies for build "
1793 $(s)echo "options. Therefore, if any of the build options are changed "
1794 $(s)echo "from a previous build, a clean build must be performed."
1795 $(s)echo ""
1796 $(s)echo "Supported Targets:"
1797 $(s)echo " all Build all individual bootloader binaries"
1798 $(s)echo " bl1 Build the BL1 binary"
1799 $(s)echo " bl2 Build the BL2 binary"
1800 $(s)echo " bl2u Build the BL2U binary"
1801 $(s)echo " bl31 Build the BL31 binary"
1802 $(s)echo " bl32 Build the BL32 binary. If ARCH=aarch32, then "
1803 $(s)echo " this builds secure payload specified by AARCH32_SP"
1804 $(s)echo " certificates Build the certificates (requires 'GENERATE_COT=1')"
1805 $(s)echo " fip Build the Firmware Image Package (FIP)"
1806 $(s)echo " fwu_fip Build the FWU Firmware Image Package (FIP)"
1807 $(s)echo " checkcodebase Check the coding style of the entire source tree"
1808 $(s)echo " checkpatch Check the coding style on changes in the current"
1809 $(s)echo " branch against BASE_COMMIT (default origin/master)"
1810 $(s)echo " clean Clean the build for the selected platform"
1811 $(s)echo " cscope Generate cscope index"
1812 $(s)echo " distclean Remove all build artifacts for all platforms"
1813 $(s)echo " certtool Build the Certificate generation tool"
1814 $(s)echo " enctool Build the Firmware encryption tool"
1815 $(s)echo " fiptool Build the Firmware Image Package (FIP) creation tool"
1816 $(s)echo " sp Build the Secure Partition Packages"
1817 $(s)echo " sptool Build the Secure Partition Package creation tool"
1818 $(s)echo " dtbs Build the Device Tree Blobs (if required for the platform)"
1819 $(s)echo " memmap Print the memory map of the built binaries"
1820 $(s)echo " doc Build html based documentation using Sphinx tool"
1821 $(s)echo ""
1822 $(s)echo "Note: most build targets require PLAT to be set to a specific platform."
1823 $(s)echo ""
1824 $(s)echo "example: build all targets for the FVP platform:"
1825 $(s)echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
Pali Rohár54ff2132020-11-24 15:38:08 +01001826
1827.PHONY: FORCE
1828FORCE:;