blob: 5c6ab35cee9ebdbe2183d8155813b78d0cb8d635 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001#
Chris Kayc3273702025-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-arm82cb2c12017-05-03 09:38:09 +01004# SPDX-License-Identifier: BSD-3-Clause
Achin Gupta4f6ad662013-10-25 09:08:21 +01005#
6
Jeenu Viswambharane35c4042014-05-15 14:40:58 +01007#
Juan Castilloaaa3e722014-06-30 11:41:46 +01008# Trusted Firmware Version
9#
Soby Mathew1a0f1122018-10-01 16:16:34 +010010VERSION_MAJOR := 2
Govindraj Raja07a6a652024-11-15 09:56:50 +010011VERSION_MINOR := 12
Yann Gautierc25d1cc2024-02-08 18:40:27 +010012# VERSION_PATCH is only used for LTS releases
13VERSION_PATCH := 0
Yann Gautier055ebec2023-10-03 11:09:07 +020014VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
Juan Castilloaaa3e722014-06-30 11:41:46 +010015
Juan Castillo88154672015-10-22 11:34:44 +010016# Default goal is build all images
17.DEFAULT_GOAL := all
18
Douglas Raillard72fc70e2016-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 Lloyd231c1472015-12-02 18:17:37 +000024MAKE_HELPERS_DIRECTORY := make_helpers/
25include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
Chris Kayf4dd18c2024-06-04 00:04:48 +000026include ${MAKE_HELPERS_DIRECTORY}build-rules.mk
Chris Kay7c4e1ee2024-05-02 17:52:37 +000027include ${MAKE_HELPERS_DIRECTORY}common.mk
Juan Castillo73c99d42015-08-18 14:23:04 +010028
29################################################################################
Jeenu Viswambharan2fae4b12016-10-24 14:31:51 +010030# Default values for build configurations, and their dependencies
Juan Castillo73c99d42015-08-18 14:23:04 +010031################################################################################
Jeenu Viswambharane35c4042014-05-15 14:40:58 +010032
Jeenu Viswambharan2fae4b12016-10-24 14:31:51 +010033include ${MAKE_HELPERS_DIRECTORY}defaults.mk
Yann Gautier422b1812025-01-17 11:02:50 +010034PLAT := ${DEFAULT_PLAT}
Andrey Skvortsov1b2fb6a2024-02-18 11:43:12 +030035include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
36
37# To be able to set platform specific defaults
38ifneq ($(PLAT_DEFAULTS_MAKEFILE_FULL),)
39include ${PLAT_DEFAULTS_MAKEFILE_FULL}
40endif
dp-arm872be882016-09-19 11:18:44 +010041
Chris Kaycc277de2023-10-20 09:17:33 +000042################################################################################
43# Configure the toolchains used to build TF-A and its tools
44################################################################################
45
46include ${MAKE_HELPERS_DIRECTORY}toolchain.mk
47
Antonio Nino Diazcc8b5632017-04-18 15:16:05 +010048# Assertions enabled for DEBUG builds by default
Antonio Nino Diazcc8b5632017-04-18 15:16:05 +010049ENABLE_ASSERTIONS := ${DEBUG}
Jeenu Viswambharan2fae4b12016-10-24 14:31:51 +010050ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION}
Juan Castillo73c99d42015-08-18 14:23:04 +010051
52################################################################################
53# Checkpatch script options
54################################################################################
55
Sandrine Bailleuxf6077392016-06-02 11:19:59 +010056CHECKCODE_ARGS := --no-patch
Dan Handleyf0b489c2016-06-02 17:15:13 +010057# Do not check the coding style on imported library files or documentation files
Gilad Ben-Yossef45018432019-05-15 09:24:04 +030058INC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \
59 include/drivers/arm, \
60 $(wildcard include/drivers/*)))
Dan Handleyf0b489c2016-06-02 17:15:13 +010061INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \
Dan Handley1a41e8c2016-06-02 18:21:02 +010062 include/lib/libfdt \
Roberto Vargas61f72a32018-05-08 10:27:10 +010063 include/lib/libc, \
Dan Handleyf0b489c2016-06-02 17:15:13 +010064 $(wildcard include/lib/*)))
65INC_DIRS_TO_CHECK := $(sort $(filter-out \
Gilad Ben-Yossef45018432019-05-15 09:24:04 +030066 include/lib \
67 include/drivers, \
Dan Handleyf0b489c2016-06-02 17:15:13 +010068 $(wildcard include/*)))
69LIB_DIRS_TO_CHECK := $(sort $(filter-out \
dp-armd801fbb2017-05-04 12:15:35 +010070 lib/compiler-rt \
Antonio Nino Diaz55cdcf72017-01-16 17:20:45 +000071 lib/libfdt% \
Roberto Vargas61f72a32018-05-08 10:27:10 +010072 lib/libc, \
Daniel Boulbya1942552022-10-05 11:05:22 +010073 lib/zlib \
Dan Handleyf0b489c2016-06-02 17:15:13 +010074 $(wildcard lib/*)))
75ROOT_DIRS_TO_CHECK := $(sort $(filter-out \
76 lib \
77 include \
78 docs \
Paul Beesley1ef35512019-03-07 16:42:31 +000079 %.rst, \
Dan Handleyf0b489c2016-06-02 17:15:13 +010080 $(wildcard *)))
81CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \
82 ${INC_DIRS_TO_CHECK} \
83 ${INC_LIB_DIRS_TO_CHECK} \
Gilad Ben-Yossef45018432019-05-15 09:24:04 +030084 ${LIB_DIRS_TO_CHECK} \
85 ${INC_DRV_DIRS_TO_CHECK} \
86 ${INC_ARM_DIRS_TO_CHECK}
Ian Spray36eaaf32014-01-30 17:25:28 +000087
Juan Castillo73c99d42015-08-18 14:23:04 +010088################################################################################
89# Process build options
90################################################################################
91
Chris Kay7c4e1ee2024-05-02 17:52:37 +000092ifeq ($(verbose),)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +010093 CHECKCODE_ARGS += --no-summary --terse
Achin Gupta4f6ad662013-10-25 09:08:21 +010094endif
Andre Przywaraee1ba6d2018-09-27 10:56:05 +010095
Juan Castillo73c99d42015-08-18 14:23:04 +010096################################################################################
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +010097# Auxiliary tools (fiptool, cert_create, etc)
98################################################################################
99
100# Variables for use with Certificate Generation Tool
101CRTTOOLPATH ?= tools/cert_create
Chris Kayc3273702025-01-13 15:57:32 +0000102CRTTOOL ?= ${CRTTOOLPATH}/cert_create$(.exe)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100103
104# Variables for use with Firmware Encryption Tool
105ENCTOOLPATH ?= tools/encrypt_fw
Chris Kayc3273702025-01-13 15:57:32 +0000106ENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw$(.exe)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100107
108# Variables for use with Firmware Image Package
109FIPTOOLPATH ?= tools/fiptool
Chris Kayc3273702025-01-13 15:57:32 +0000110FIPTOOL ?= ${FIPTOOLPATH}/fiptool$(.exe)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100111
112# Variables for use with sptool
113SPTOOLPATH ?= tools/sptool
114SPTOOL ?= ${SPTOOLPATH}/sptool.py
115SP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py
Karl Meakin20629b32023-02-14 11:56:02 +0000116SP_DTS_LIST_FRAGMENT ?= ${BUILD_PLAT}/sp_list_fragment.dts
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100117
J-Alves0fe374e2024-11-18 17:49:53 +0000118# Variables for use with sptool
119TLCTOOL ?= poetry run tlc
120
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100121# Variables for use with ROMLIB
122ROMLIBPATH ?= lib/romlib
123
124# Variable for use with Python
125PYTHON ?= python3
126
127# Variables for use with documentation build using Sphinx tool
128DOCS_PATH ?= docs
129
130################################################################################
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100131# Compiler Configuration based on ARCH_MAJOR and ARCH_MINOR flags
132################################################################################
Etienne Carriere26e63c42017-11-08 13:48:40 +0100133ifeq (${ARM_ARCH_MAJOR},7)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100134 target32-directive = -target arm-none-eabi
Govindraj Rajad4089fb2023-05-30 16:52:15 -0500135# Will set march-directive from platform configuration
Etienne Carriere26e63c42017-11-08 13:48:40 +0100136else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100137 target32-directive = -target armv8a-none-eabi
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100138endif #(ARM_ARCH_MAJOR)
139
140################################################################################
141# Get Architecture Feature Modifiers
142################################################################################
143arch-features = ${ARM_ARCH_FEATURE}
144
Chris Kay8620bd02023-12-04 09:55:50 +0000145ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
146 ifeq ($($(ARCH)-cc-id),arm-clang)
Govindraj Raja7794d6c2023-06-01 16:29:16 -0500147 TF_CFLAGS_aarch32 := -target arm-arm-none-eabi
148 TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi
originc8a992f2022-01-19 16:30:14 +0000149 else
Govindraj Raja7794d6c2023-06-01 16:29:16 -0500150 TF_CFLAGS_aarch32 = $(target32-directive)
151 TF_CFLAGS_aarch64 := -target aarch64-elf
originc8a992f2022-01-19 16:30:14 +0000152 endif
153
Chris Kay8620bd02023-12-04 09:55:50 +0000154else ifeq ($($(ARCH)-cc-id),gnu-gcc)
Chris Kayfa402f32024-02-20 16:19:54 +0000155 # Enable LTO only for aarch64
156 ifeq (${ARCH},aarch64)
157 LTO_CFLAGS = $(if $(filter-out 0,$(ENABLE_LTO)),-flto)
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600158 endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100159endif #(clang)
dp-armd5461852017-05-02 12:00:08 +0100160
Ahmad Fatoum32b209b2020-02-25 11:25:08 +0100161# Process Debug flag
162$(eval $(call add_define,DEBUG))
163ifneq (${DEBUG}, 0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100164 BUILD_TYPE := debug
165 TF_CFLAGS += -g -gdwarf-4
166 ASFLAGS += -g -Wa,-gdwarf-4
Ahmad Fatoum32b209b2020-02-25 11:25:08 +0100167
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100168 # Use LOG_LEVEL_INFO by default for debug builds
169 LOG_LEVEL := 40
Ahmad Fatoum32b209b2020-02-25 11:25:08 +0100170else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100171 BUILD_TYPE := release
172 # Use LOG_LEVEL_NOTICE by default for release builds
173 LOG_LEVEL := 20
174endif #(Debug)
Ahmad Fatoum32b209b2020-02-25 11:25:08 +0100175
Peiyuan Songf1de4c82020-04-25 16:53:43 +0800176# Default build string (git branch and commit)
177ifeq (${BUILD_STRING},)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100178 BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null)
Peiyuan Songf1de4c82020-04-25 16:53:43 +0800179endif
laurenw-armdddf4282022-07-12 10:12:05 -0500180VERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
Peiyuan Songf1de4c82020-04-25 16:53:43 +0800181
Antonio Nino Diaz8fd9d4d2018-08-08 16:28:43 +0100182ifeq (${AARCH32_INSTRUCTION_SET},A32)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100183 TF_CFLAGS_aarch32 += -marm
Antonio Nino Diaz8fd9d4d2018-08-08 16:28:43 +0100184else ifeq (${AARCH32_INSTRUCTION_SET},T32)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100185 TF_CFLAGS_aarch32 += -mthumb
Antonio Nino Diaz8fd9d4d2018-08-08 16:28:43 +0100186else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100187 $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
188endif #(AARCH32_INSTRUCTION_SET)
Antonio Nino Diaz8fd9d4d2018-08-08 16:28:43 +0100189
Sandrine Bailleuxa9c4dde2018-07-03 09:14:45 +0200190TF_CFLAGS_aarch32 += -mno-unaligned-access
dp-armd5461852017-05-02 12:00:08 +0100191TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align
Soby Mathew9d29c222016-05-05 14:33:33 +0100192
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100193##############################################################################
194# WARNINGS Configuration
195###############################################################################
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100196# General warnings
197WARNINGS := -Wall -Wmissing-include-dirs -Wunused \
Yann Gautier34b508b2021-05-20 13:18:14 +0200198 -Wdisabled-optimization -Wvla -Wshadow \
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000199 -Wredundant-decls
200# stricter warnings
201WARNINGS += -Wextra -Wno-trigraphs
202# too verbose for generic build
203WARNINGS += -Wno-missing-field-initializers \
204 -Wno-type-limits -Wno-sign-compare \
205# on clang this flag gets reset if -Wextra is set after it. No difference on gcc
206WARNINGS += -Wno-unused-parameter
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100207
208# Additional warnings
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000209# Level 1 - infrequent warnings we should have none of
210# full -Wextra
211WARNING1 += -Wsign-compare
212WARNING1 += -Wtype-limits
213WARNING1 += -Wmissing-field-initializers
Yann Gautiere7c645b2018-12-10 18:00:26 +0100214
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000215# Level 2 - problematic warnings that we want
216# zlib, compiler-rt, coreboot, and mbdedtls blow up with these
217# TODO: disable just for them and move into default build
218WARNING2 += -Wold-style-definition
219WARNING2 += -Wmissing-prototypes
220WARNING2 += -Wmissing-format-attribute
221# TF-A aims to comply with this eventually. Effort too large at present
222WARNING2 += -Wundef
Boyan Karatotevd141e632022-11-21 14:49:05 +0000223# currently very involved and many platforms set this off
224WARNING2 += -Wunused-const-variable=2
Yann Gautiere7c645b2018-12-10 18:00:26 +0100225
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000226# Level 3 - very pedantic, frequently ignored
Yann Gautiere7c645b2018-12-10 18:00:26 +0100227WARNING3 := -Wbad-function-cast
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000228WARNING3 += -Waggregate-return
229WARNING3 += -Wnested-externs
230WARNING3 += -Wcast-align
Yann Gautiere7c645b2018-12-10 18:00:26 +0100231WARNING3 += -Wcast-qual
232WARNING3 += -Wconversion
233WARNING3 += -Wpacked
Yann Gautiere7c645b2018-12-10 18:00:26 +0100234WARNING3 += -Wpointer-arith
Yann Gautiere7c645b2018-12-10 18:00:26 +0100235WARNING3 += -Wswitch-default
Yann Gautiere7c645b2018-12-10 18:00:26 +0100236
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000237# Setting W is quite verbose and most warnings will be pre-existing issues
238# outside of the contributor's control. Don't fail the build on them so warnings
239# can be seen and hopefully addressed
240ifdef W
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100241 ifneq (${W},0)
242 E ?= 0
243 endif
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000244endif
245
Yann Gautiere7c645b2018-12-10 18:00:26 +0100246ifeq (${W},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100247 WARNINGS += $(WARNING1)
Yann Gautiere7c645b2018-12-10 18:00:26 +0100248else ifeq (${W},2)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100249 WARNINGS += $(WARNING1) $(WARNING2)
Yann Gautiere7c645b2018-12-10 18:00:26 +0100250else ifeq (${W},3)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100251 WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
252endif #(W)
Yann Gautiere7c645b2018-12-10 18:00:26 +0100253
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100254# Compiler specific warnings
Chris Kay8620bd02023-12-04 09:55:50 +0000255ifeq ($(filter %-clang,$($(ARCH)-cc-id)),)
Justin Chadwell93c690e2019-07-03 14:15:56 +0100256# not using clang
Justin Chadwelld7b4cd42019-09-18 14:13:42 +0100257WARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \
258 -Wpacked-bitfield-compat -Wshift-overflow=2 \
259 -Wlogical-op
Govindraj Rajadea23e22023-05-05 09:09:36 -0500260
261# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
Boyan Karatotev316f5c92024-10-10 13:54:37 +0100262TF_CFLAGS_MIN_PAGE_SIZE := $(call cc_option, --param=min-pagesize=0)
263TF_CFLAGS += $(TF_CFLAGS_MIN_PAGE_SIZE)
Govindraj Rajadea23e22023-05-05 09:09:36 -0500264
Bipin Ravi538516f2023-09-28 13:17:24 -0500265ifeq ($(HARDEN_SLS), 1)
Boyan Karatotev316f5c92024-10-10 13:54:37 +0100266 TF_CFLAGS_MHARDEN_SLS := $(call cc_option, -mharden-sls=all)
267 TF_CFLAGS_aarch64 += $(TF_CFLAGS_MHARDEN_SLS)
Bipin Ravi538516f2023-09-28 13:17:24 -0500268endif
269
Justin Chadwell93c690e2019-07-03 14:15:56 +0100270else
271# using clang
Justin Chadwelld7b4cd42019-09-18 14:13:42 +0100272WARNINGS += -Wshift-overflow -Wshift-sign-overflow \
273 -Wlogical-op-parentheses
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100274endif #(Clang Warning)
Ambroise Vincent00296572019-05-24 12:47:43 +0100275
Yann Gautier6336b072018-12-10 18:08:53 +0100276ifneq (${E},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100277 ERRORS := -Werror
278endif #(E)
Yann Gautier6336b072018-12-10 18:08:53 +0100279
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100280################################################################################
281# Compiler and Linker Directives
282################################################################################
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100283CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
284 $(ERRORS) $(WARNINGS)
Govindraj Rajad4089fb2023-05-30 16:52:15 -0500285ASFLAGS += $(CPPFLAGS) \
Julius Wernerd5dfdeb2019-07-09 13:49:11 -0700286 -ffreestanding -Wa,--fatal-warnings
Masahiro Yamada59de5092016-12-22 12:51:53 +0900287TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \
Samuel Hollandebd6efa2019-10-20 16:11:25 -0500288 -ffunction-sections -fdata-sections \
Boyan Karatotevee0c5b82024-12-09 08:24:12 +0000289 -ffreestanding -fno-common \
Samuel Hollandebd6efa2019-10-20 16:11:25 -0500290 -Os -std=gnu99
Juan Castillo73c99d42015-08-18 14:23:04 +0100291
Justin Chadwell1f461972019-08-20 11:01:52 +0100292ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100293 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover
294endif #(${SANITIZE_UB},on)
295
Justin Chadwell1f461972019-08-20 11:01:52 +0100296ifeq (${SANITIZE_UB},trap)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100297 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \
Justin Chadwell1f461972019-08-20 11:01:52 +0100298 -fsanitize-undefined-trap-on-error
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100299endif #(${SANITIZE_UB},trap)
Justin Chadwell1f461972019-08-20 11:01:52 +0100300
Chris Kay291e7182024-05-14 13:08:31 +0000301GCC_V_OUTPUT := $(if $($(ARCH)-cc),$(shell $($(ARCH)-cc) -v 2>&1))
david cunadof7ec31d2017-11-30 21:58:01 +0000302
Marco Felsch1f49db52022-11-09 12:59:09 +0100303TF_LDFLAGS += -z noexecstack
304
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100305# LD = armlink
Chris Kay8620bd02023-12-04 09:55:50 +0000306ifeq ($($(ARCH)-ld-id),arm-link)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100307 TF_LDFLAGS += --diag_error=warning --lto_level=O1
308 TF_LDFLAGS += --remove --info=unused,unusedsymbols
309 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100310
311# LD = gcc (used when GCC LTO is enabled)
Chris Kay8620bd02023-12-04 09:55:50 +0000312else ifeq ($($(ARCH)-ld-id),gnu-gcc)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100313 # Pass ld options with Wl or Xlinker switches
Chris Kay86e489c2024-01-16 11:53:35 +0000314 TF_LDFLAGS += $(call ld_option,-Xlinker --no-warn-rwx-segments)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100315 TF_LDFLAGS += -Wl,--fatal-warnings -O1
316 TF_LDFLAGS += -Wl,--gc-sections
Chris Kayac98b822022-12-22 13:26:37 +0000317
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100318 TF_LDFLAGS += -Wl,-z,common-page-size=4096 #Configure page size constants
319 TF_LDFLAGS += -Wl,-z,max-page-size=4096
Andrey Skvortsov304ad942023-09-05 23:06:29 +0300320 TF_LDFLAGS += -Wl,--build-id=none
Chris Kayac98b822022-12-22 13:26:37 +0000321
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100322 ifeq ($(ENABLE_LTO),1)
323 ifeq (${ARCH},aarch64)
324 TF_LDFLAGS += -flto -fuse-linker-plugin
Andrey Skvortsov31f80ef2023-12-08 18:04:51 +0300325 TF_LDFLAGS += -flto-partition=one
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100326 endif
327 endif #(ENABLE_LTO)
328
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600329# GCC automatically adds fix-cortex-a53-843419 flag when used to link
330# which breaks some builds, so disable if errata fix is not explicitly enabled
Yann Gautiercfe67672023-03-15 16:18:16 +0100331 ifeq (${ARCH},aarch64)
332 ifneq (${ERRATA_A53_843419},1)
333 TF_LDFLAGS += -mno-fix-cortex-a53-843419
334 endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100335 endif
336 TF_LDFLAGS += -nostdlib
337 TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100338
339# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
Varun Wadekarc2ad38c2019-01-11 14:47:48 -0800340else
Marco Felsch1f49db52022-11-09 12:59:09 +0100341# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
342# are not loaded by a elf loader.
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100343 TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments)
344 TF_LDFLAGS += -O1
345 TF_LDFLAGS += --gc-sections
Chris Kayac98b822022-12-22 13:26:37 +0000346
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100347 TF_LDFLAGS += -z common-page-size=4096 # Configure page size constants
348 TF_LDFLAGS += -z max-page-size=4096
Andrey Skvortsov304ad942023-09-05 23:06:29 +0300349 TF_LDFLAGS += --build-id=none
Chris Kayac98b822022-12-22 13:26:37 +0000350
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100351# ld.lld doesn't recognize the errata flags,
Yabin Cuiebac6922023-01-19 20:06:04 +0000352# therefore don't add those in that case.
353# ld.lld reports section type mismatch warnings,
354# therefore don't add --fatal-warnings to it.
Chris Kay8620bd02023-12-04 09:55:50 +0000355 ifneq ($($(ARCH)-ld-id),llvm-lld)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100356 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) --fatal-warnings
357 endif
358
359endif #(LD = armlink)
Juan Castillo73c99d42015-08-18 14:23:04 +0100360
361################################################################################
Govindraj Rajaf5211422023-08-17 10:41:48 -0500362# Setup ARCH_MAJOR/MINOR before parsing arch_features.
363################################################################################
364ifeq (${ENABLE_RME},1)
AlexeiFedorov7d5fc982024-03-13 11:53:44 +0000365 ARM_ARCH_MAJOR := 9
366 ARM_ARCH_MINOR := 2
Govindraj Rajaf5211422023-08-17 10:41:48 -0500367endif
368
369################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +0100370# Common sources and include directories
371################################################################################
dp-armd801fbb2017-05-04 12:15:35 +0100372include lib/compiler-rt/compiler-rt.mk
Juan Castillo73c99d42015-08-18 14:23:04 +0100373
Chris Kay758ccb82024-03-08 16:08:31 +0000374# Allow overriding the timestamp, for example for reproducible builds, or to
375# synchronize timestamps across multiple projects.
376# This must be set to a C string (including quotes where applicable).
377BUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__
378
379DEFINES += -DBUILD_MESSAGE_TIMESTAMP='$(BUILD_MESSAGE_TIMESTAMP)'
380DEFINES += -DBUILD_MESSAGE_VERSION_STRING='"$(VERSION_STRING)"'
381DEFINES += -DBUILD_MESSAGE_VERSION='"$(VERSION)"'
382
Juan Castillo73c99d42015-08-18 14:23:04 +0100383BL_COMMON_SOURCES += common/bl_common.c \
Soby Mathew7f56e9a2017-09-04 11:49:29 +0100384 common/tf_log.c \
Soby Mathew9d29c222016-05-05 14:33:33 +0100385 common/${ARCH}/debug.S \
Julius Werner91b48c92018-11-27 22:10:56 -0800386 drivers/console/multi_console.c \
Soby Mathew9d29c222016-05-05 14:33:33 +0100387 lib/${ARCH}/cache_helpers.S \
388 lib/${ARCH}/misc_helpers.S \
Boyan Karatotevc73686a2023-02-15 13:21:50 +0000389 lib/extensions/pmuv3/${ARCH}/pmuv3.c \
Soby Mathew566034f2018-02-08 17:45:12 +0000390 plat/common/plat_bl_common.c \
Soby Mathew7f56e9a2017-09-04 11:49:29 +0100391 plat/common/plat_log_common.c \
dp-arm75311202017-03-07 11:02:47 +0000392 plat/common/${ARCH}/plat_common.c \
Soby Mathew9d29c222016-05-05 14:33:33 +0100393 plat/common/${ARCH}/platform_helpers.S \
Roberto Vargas61f72a32018-05-08 10:27:10 +0100394 ${COMPILER_RT_SRCS}
Ryan Harkind7a6b0f2014-01-13 14:40:13 +0000395
Chris Kay8620bd02023-12-04 09:55:50 +0000396ifeq ($($(ARCH)-cc-id),arm-clang)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100397 BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S
Antonio Nino Diaz8422a842018-08-16 15:42:44 +0100398endif
399
Justin Chadwell1f461972019-08-20 11:01:52 +0100400ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100401 BL_COMMON_SOURCES += plat/common/ubsan.c
Justin Chadwell1f461972019-08-20 11:01:52 +0100402endif
403
Yann Gautier01d237c2018-06-18 16:00:23 +0200404INCLUDES += -Iinclude \
Antonio Nino Diazf5478de2018-12-17 17:20:57 +0000405 -Iinclude/arch/${ARCH} \
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +0000406 -Iinclude/lib/cpus/${ARCH} \
407 -Iinclude/lib/el3_runtime/${ARCH} \
408 ${PLAT_INCLUDES} \
409 ${SPD_INCLUDES}
410
Nishant Sharmae03dcc82022-08-15 16:37:07 +0100411DTC_FLAGS += -I dts -O dtb
412DTC_CPPFLAGS += -P -nostdinc $(INCLUDES) -Ifdts -undef \
413 -x assembler-with-cpp $(DEFINES)
414
Antonio Nino Diaz9c6d1c52018-11-19 11:48:30 +0000415include common/backtrace/backtrace.mk
416
Juan Castillo73c99d42015-08-18 14:23:04 +0100417################################################################################
Govindraj Raja35472702023-09-20 14:32:24 -0500418# Generic definitions
419################################################################################
Govindraj Raja35472702023-09-20 14:32:24 -0500420
421ifeq (${BUILD_BASE},)
422 BUILD_BASE := ./build
423endif
424BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
425
426SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
427
428# Platforms providing their own TBB makefile may override this value
429INCLUDE_TBBR_MK := 1
430
431################################################################################
432# Include SPD Makefile if one has been specified
433################################################################################
434
435ifneq (${SPD},none)
436 ifeq (${ARCH},aarch32)
437 $(error "Error: SPD is incompatible with AArch32.")
438 endif
439
440 ifdef EL3_PAYLOAD_BASE
441 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
442 $(warning "The SPD and its BL32 companion will be present but \
443 ignored.")
444 endif
445
446 ifeq (${SPD},spmd)
447 # SPMD is located in std_svc directory
448 SPD_DIR := std_svc
449
450 ifeq ($(SPMD_SPM_AT_SEL2),1)
451 CTX_INCLUDE_EL2_REGS := 1
452 ifeq ($(SPMC_AT_EL3),1)
453 $(error SPM cannot be enabled in both S-EL2 and EL3.)
454 endif
Madhukar Pappireddy59bdcc52024-04-25 23:01:00 -0500455 ifeq ($(CTX_INCLUDE_SVE_REGS),1)
456 $(error SVE context management not needed with Hafnium SPMC.)
457 endif
Govindraj Raja35472702023-09-20 14:32:24 -0500458 endif
459
460 ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
461 DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG
462 endif
463
Arunachalam Ganapathy0686a012022-04-11 14:36:54 +0100464 ifeq ($(findstring trusty_sp,$(ARM_SPMC_MANIFEST_DTS)),trusty_sp)
465 DTC_CPPFLAGS += -DTRUSTY_SP_FW_CONFIG
466 endif
467
Govindraj Raja35472702023-09-20 14:32:24 -0500468 ifeq ($(TS_SP_FW_CONFIG),1)
Arunachalam Ganapathy0686a012022-04-11 14:36:54 +0100469 DTC_CPPFLAGS += -DTS_SP_FW_CONFIG
Govindraj Raja35472702023-09-20 14:32:24 -0500470 endif
471
472 ifneq ($(ARM_BL2_SP_LIST_DTS),)
473 DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
474 endif
475
476 ifneq ($(SP_LAYOUT_FILE),)
477 BL2_ENABLE_SP_LOAD := 1
478 endif
Govindraj Rajac189adb2023-10-31 14:48:11 -0500479
480 ifeq ($(SPMC_AT_EL3_SEL0_SP),1)
481 ifneq ($(SPMC_AT_EL3),1)
482 $(error SEL0 SP cannot be enabled without SPMC at EL3)
483 endif
484 endif
Govindraj Raja35472702023-09-20 14:32:24 -0500485 else
486 # All other SPDs in spd directory
487 SPD_DIR := spd
488 endif #(SPD)
489
490 # We expect to locate an spd.mk under the specified SPD directory
491 SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
492
493 ifeq (${SPD_MAKE},)
494 $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
495 endif
496 $(info Including ${SPD_MAKE})
497 include ${SPD_MAKE}
498
499 # If there's BL32 companion for the chosen SPD, we expect that the SPD's
500 # Makefile would set NEED_BL32 to "yes". In this case, the build system
501 # supports two mutually exclusive options:
502 # * BL32 is built from source: then BL32_SOURCES must contain the list
503 # of source files to build BL32
504 # * BL32 is a prebuilt binary: then BL32 must point to the image file
505 # that will be included in the FIP
506 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
507 # over the sources.
508endif #(SPD=none)
509
510ifeq (${ENABLE_SPMD_LP}, 1)
511ifneq (${SPD},spmd)
512 $(error Error: ENABLE_SPMD_LP requires SPD=spmd.)
513endif
514ifeq ($(SPMC_AT_EL3),1)
515 $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.)
516endif
517endif
518
519################################################################################
Olivier Deprez696ed162025-01-03 13:38:50 +0100520# Include the platform specific Makefile after the SPD Makefile (the platform
521# makefile may use all previous definitions in this file)
522################################################################################
523include ${PLAT_MAKEFILE_FULL}
524
525################################################################################
Govindraj Rajaf5211422023-08-17 10:41:48 -0500526# Process BRANCH_PROTECTION value and set
527# Pointer Authentication and Branch Target Identification flags
528################################################################################
529ifeq (${BRANCH_PROTECTION},0)
530 # Default value turns off all types of branch protection
531 BP_OPTION := none
532else ifneq (${ARCH},aarch64)
533 $(error BRANCH_PROTECTION requires AArch64)
534else ifeq (${BRANCH_PROTECTION},1)
535 # Enables all types of branch protection features
536 BP_OPTION := standard
537 ENABLE_BTI := 1
538 ENABLE_PAUTH := 1
539else ifeq (${BRANCH_PROTECTION},2)
540 # Return address signing to its standard level
541 BP_OPTION := pac-ret
542 ENABLE_PAUTH := 1
543else ifeq (${BRANCH_PROTECTION},3)
544 # Extend the signing to include leaf functions
545 BP_OPTION := pac-ret+leaf
546 ENABLE_PAUTH := 1
547else ifeq (${BRANCH_PROTECTION},4)
548 # Turn on branch target identification mechanism
549 BP_OPTION := bti
550 ENABLE_BTI := 1
551else
552 $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
553endif #(BRANCH_PROTECTION)
554
555ifeq ($(ENABLE_PAUTH),1)
556 CTX_INCLUDE_PAUTH_REGS := 1
557endif
558ifneq (${BP_OPTION},none)
559 TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION}
560endif #(BP_OPTION)
561
562# Pointer Authentication sources
563ifeq (${ENABLE_PAUTH}, 1)
564# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the
565# Pauth support. As it's not secure, it must be reimplemented for real platforms
566 BL_COMMON_SOURCES += lib/extensions/pauth/pauth_helpers.S
567endif
568
Govindraj Raja35472702023-09-20 14:32:24 -0500569################################################################################
Govindraj Raja35472702023-09-20 14:32:24 -0500570# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from
571# platform.
572################################################################################
573include ${MAKE_HELPERS_DIRECTORY}arch_features.mk
574
Govindraj Rajaf5211422023-08-17 10:41:48 -0500575####################################################
576# Enable required options for Memory Stack Tagging.
577####################################################
578
579# Currently, these options are enabled only for clang and armclang compiler.
580ifeq (${SUPPORT_STACK_MEMTAG},yes)
581 ifdef mem_tag_arch_support
582 # Check for armclang and clang compilers
Chris Kay8620bd02023-12-04 09:55:50 +0000583 ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
Govindraj Rajaf5211422023-08-17 10:41:48 -0500584 # Add "memtag" architecture feature modifier if not specified
585 ifeq ( ,$(findstring memtag,$(arch-features)))
586 arch-features := $(arch-features)+memtag
587 endif # memtag
Chris Kay8620bd02023-12-04 09:55:50 +0000588 ifeq ($($(ARCH)-cc-id),arm-clang)
Govindraj Rajaf5211422023-08-17 10:41:48 -0500589 TF_CFLAGS += -mmemtag-stack
Chris Kay8620bd02023-12-04 09:55:50 +0000590 else ifeq ($($(ARCH)-cc-id),llvm-clang)
Govindraj Rajaf5211422023-08-17 10:41:48 -0500591 TF_CFLAGS += -fsanitize=memtag
592 endif # armclang
593 endif
594 else
595 $(error "Error: stack memory tagging is not supported for \
596 architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
597 endif #(mem_tag_arch_support)
598endif #(SUPPORT_STACK_MEMTAG)
599
600################################################################################
601# RME dependent flags configuration, Enable optional features for RME.
602################################################################################
603# FEAT_RME
604ifeq (${ENABLE_RME},1)
Govindraj Rajaf5211422023-08-17 10:41:48 -0500605 # RME requires AARCH64
606 ifneq (${ARCH},aarch64)
607 $(error ENABLE_RME requires AArch64)
608 endif
609
610 # RME requires el2 context to be saved for now.
611 CTX_INCLUDE_EL2_REGS := 1
612 CTX_INCLUDE_AARCH32_REGS := 0
613 CTX_INCLUDE_PAUTH_REGS := 1
614
615 # RME enables CSV2_2 extension by default.
616 ENABLE_FEAT_CSV2_2 = 1
617endif #(FEAT_RME)
618
619################################################################################
Zelalem Aweke5b18de02021-07-11 18:33:20 -0500620# Include rmmd Makefile if RME is enabled
621################################################################################
Zelalem Aweke5b18de02021-07-11 18:33:20 -0500622ifneq (${ENABLE_RME},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100623 ifneq (${ARCH},aarch64)
624 $(error ENABLE_RME requires AArch64)
625 endif
626 ifeq ($(SPMC_AT_EL3),1)
627 $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
628 endif
629
630 ifneq (${SPD}, none)
631 ifneq (${SPD}, spmd)
632 $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd)
633 endif
634 endif
Zelalem Aweke5b18de02021-07-11 18:33:20 -0500635include services/std_svc/rmmd/rmmd.mk
636$(warning "RME is an experimental feature")
637endif
638
Govindraj Raja35472702023-09-20 14:32:24 -0500639ifeq (${CTX_INCLUDE_EL2_REGS}, 1)
640 ifeq (${SPD},none)
641 ifeq (${ENABLE_RME},0)
642 $(error CTX_INCLUDE_EL2_REGS is available only when SPD \
643 or RME is enabled)
644 endif
645 endif
646endif
Juan Castillo0f21c542014-06-25 17:26:36 +0100647
Govindraj Raja7794d6c2023-06-01 16:29:16 -0500648################################################################################
Govindraj Raja30655132024-09-06 15:43:43 +0100649# Make 128-Bit sysreg read/writes availabe when FEAT_D128 is enabled.
650################################################################################
651ifneq (${ENABLE_FEAT_D128}, 0)
652 BL_COMMON_SOURCES += lib/extensions/sysreg128/sysreg128.S
653endif
654
655################################################################################
Govindraj Raja7794d6c2023-06-01 16:29:16 -0500656# Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come
657# up with appropriate march values for compiler.
658################################################################################
659include ${MAKE_HELPERS_DIRECTORY}march.mk
660
661TF_CFLAGS += $(march-directive)
Govindraj Raja7275ac22024-01-23 16:00:19 -0600662ASFLAGS += $(march-directive)
Govindraj Raja7794d6c2023-06-01 16:29:16 -0500663
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600664# This internal flag is common option which is set to 1 for scenarios
665# when the BL2 is running in EL3 level. This occurs in two scenarios -
666# 4 world system running BL2 at EL3 and two world system without BL1 running
667# BL2 in EL3
668
669ifeq (${RESET_TO_BL2},1)
670 BL2_RUNS_AT_EL3 := 1
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100671 ifeq (${ENABLE_RME},1)
672 $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \
673 supported at the moment.)
674 endif
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600675else ifeq (${ENABLE_RME},1)
676 BL2_RUNS_AT_EL3 := 1
677else
678 BL2_RUNS_AT_EL3 := 0
679endif
680
Manish Pandeyf87e54f2023-10-10 15:42:19 +0100681# This internal flag is set to 1 when Firmware First handling of External aborts
682# is required by lowe ELs. Currently only NS requires this support.
683ifeq ($(HANDLE_EA_EL3_FIRST_NS),1)
684 FFH_SUPPORT := 1
685else
686 FFH_SUPPORT := 0
687endif
688
Etienne Carriere26e63c42017-11-08 13:48:40 +0100689ifeq (${ARM_ARCH_MAJOR},7)
690include make_helpers/armv7-a-cpus.mk
691endif
692
Masahiro Yamada320920c2020-01-17 13:44:37 +0900693PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT})
694ifneq ($(PIE_FOUND),)
695 TF_CFLAGS += -fno-PIE
Chris Kay8620bd02023-12-04 09:55:50 +0000696ifeq ($($(ARCH)-ld-id),gnu-gcc)
Samuel Holland7b592412022-04-08 21:56:02 -0500697 TF_LDFLAGS += -no-pie
698endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100699endif #(PIE_FOUND)
Masahiro Yamada320920c2020-01-17 13:44:37 +0900700
Chris Kay8620bd02023-12-04 09:55:50 +0000701ifeq ($($(ARCH)-ld-id),gnu-gcc)
Masahiro Yamada320920c2020-01-17 13:44:37 +0900702 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
Soby Mathew3bd17c02018-08-28 11:13:55 +0100703else
Masahiro Yamada320920c2020-01-17 13:44:37 +0900704 PIE_LDFLAGS += -pie --no-dynamic-linker
705endif
706
707ifeq ($(ENABLE_PIE),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100708 ifeq ($(RESET_TO_BL2),1)
709 ifneq ($(BL2_IN_XIP_MEM),1)
710 BL2_CPPFLAGS += -fpie
711 BL2_CFLAGS += -fpie
712 BL2_LDFLAGS += $(PIE_LDFLAGS)
713 endif #(BL2_IN_XIP_MEM)
714 endif #(RESET_TO_BL2)
Chris Kay966660e2023-02-02 14:39:03 +0000715 BL31_CPPFLAGS += -fpie
716 BL31_CFLAGS += -fpie
Masahiro Yamada320920c2020-01-17 13:44:37 +0900717 BL31_LDFLAGS += $(PIE_LDFLAGS)
Chris Kay966660e2023-02-02 14:39:03 +0000718
719 BL32_CPPFLAGS += -fpie
Masahiro Yamadad9743012020-01-17 13:45:14 +0900720 BL32_CFLAGS += -fpie
721 BL32_LDFLAGS += $(PIE_LDFLAGS)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100722endif #(ENABLE_PIE)
Soby Mathew3bd17c02018-08-28 11:13:55 +0100723
Boyan Karatotev007433d2023-01-25 16:55:18 +0000724BL1_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
725BL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
726BL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
727
Masahiro Yamada9cefb4b2020-04-01 14:20:58 +0900728BL1_CPPFLAGS += -DIMAGE_AT_EL3
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600729ifeq ($(RESET_TO_BL2),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100730 BL2_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamadad5e97a12020-03-26 13:18:48 +0900731else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100732 BL2_CPPFLAGS += -DIMAGE_AT_EL1
733endif #(RESET_TO_BL2)
Boyan Karatotev007433d2023-01-25 16:55:18 +0000734
735ifeq (${ARCH},aarch64)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100736 BL2U_CPPFLAGS += -DIMAGE_AT_EL1
737 BL31_CPPFLAGS += -DIMAGE_AT_EL3
738 BL32_CPPFLAGS += -DIMAGE_AT_EL1
Boyan Karatotev007433d2023-01-25 16:55:18 +0000739else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100740 BL32_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamadad5e97a12020-03-26 13:18:48 +0900741endif
742
Sandrine Bailleux54035fc2016-01-13 14:57:38 +0000743# Include the CPU specific operations makefile, which provides default
744# values for all CPU errata workarounds and CPU specific optimisations.
745# This can be overridden by the platform.
Juan Castillo73c99d42015-08-18 14:23:04 +0100746include lib/cpus/cpu-ops.mk
Achin Gupta4f6ad662013-10-25 09:08:21 +0100747
dp-arma4409002017-02-15 11:07:55 +0000748################################################################################
749# Build `AARCH32_SP` as BL32 image for AArch32
750################################################################################
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100751ifeq (${ARCH},aarch32)
752 NEED_BL32 := yes
dp-arma4409002017-02-15 11:07:55 +0000753
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100754 ifneq (${AARCH32_SP},none)
755 # We expect to locate an sp.mk under the specified AARCH32_SP directory
756 AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
dp-arma4409002017-02-15 11:07:55 +0000757
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100758 ifeq (${AARCH32_SP_MAKE},)
759 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
760 endif
Juan Pablo Conde043f38f2023-08-09 13:19:21 -0500761 $(info Including ${AARCH32_SP_MAKE})
762 include ${AARCH32_SP_MAKE}
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100763 endif
764endif #(ARCH=aarch32)
Achin Gupta4f6ad662013-10-25 09:08:21 +0100765
Juan Castillo73c99d42015-08-18 14:23:04 +0100766################################################################################
Varun Wadekar77f1f7a2019-01-31 09:22:30 -0800767# Include libc if not overridden
768################################################################################
769ifeq (${OVERRIDE_LIBC},0)
770include lib/libc/libc.mk
771endif
772
773################################################################################
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100774# Check incompatible options and dependencies
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000775################################################################################
776
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100777# USE_DEBUGFS experimental feature recommended only in debug builds
778ifeq (${USE_DEBUGFS},1)
779 ifeq (${DEBUG},1)
780 $(warning DEBUGFS experimental feature is enabled.)
781 else
782 $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000783 endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100784endif #(USE_DEBUGFS)
785
786# USE_SPINLOCK_CAS requires AArch64 build
787ifeq (${USE_SPINLOCK_CAS},1)
788 ifneq (${ARCH},aarch64)
789 $(error USE_SPINLOCK_CAS requires AArch64)
Qixiang Xu76580f32017-08-24 11:03:23 +0800790 endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100791endif #(USE_SPINLOCK_CAS)
792
793# The cert_create tool cannot generate certificates individually, so we use the
794# target 'certificates' to create them all
795ifneq (${GENERATE_COT},0)
796 FIP_DEPS += certificates
797 FWU_FIP_DEPS += fwu_certificates
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000798endif
799
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100800ifneq (${DECRYPTION_SUPPORT},none)
801 ENC_ARGS += -f ${FW_ENC_STATUS}
802 ENC_ARGS += -k ${ENC_KEY}
803 ENC_ARGS += -n ${ENC_NONCE}
804 FIP_DEPS += enctool
805 FWU_FIP_DEPS += enctool
806endif #(DECRYPTION_SUPPORT)
807
808ifdef EL3_PAYLOAD_BASE
809 ifdef PRELOADED_BL33_BASE
810 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
811 incompatible build options. EL3_PAYLOAD_BASE has priority.")
812 endif
813 ifneq (${GENERATE_COT},0)
814 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \
815 build options.")
816 endif
817 ifneq (${TRUSTED_BOARD_BOOT},0)
818 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \
819 incompatible \ build options.")
820 endif
821endif #(EL3_PAYLOAD_BASE)
822
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000823ifeq (${NEED_BL33},yes)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100824 ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000825 $(warning "BL33 image is not needed when option \
826 BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100827 endif
828 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz68450a62016-04-06 17:31:57 +0100829 $(warning "BL33 image is not needed when option \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100830 PRELOADED_BL33_BASE is used and won't be added to the FIP file.")
831 endif
832endif #(NEED_BL33)
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000833
Jeenu Viswambharand4593e42017-01-06 16:14:42 +0000834# When building for systems with hardware-assisted coherency, there's no need to
835# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
836ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100837 $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
Jeenu Viswambharand4593e42017-01-06 16:14:42 +0000838endif
Yatharth Kochar1a0a3f02016-06-28 16:58:26 +0100839
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600840#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1.
841ifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100842 $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled")
Jiafei Pan7d173fc2018-03-21 07:20:09 +0000843endif
844
Manish Pandey9202d512023-02-13 12:39:17 +0000845# RAS_EXTENSION is deprecated, provide alternate build options
Jeenu Viswambharan14c60162018-04-04 16:07:11 +0100846ifeq ($(RAS_EXTENSION),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100847 $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \
Manish Pandeyf87e54f2023-10-10 15:42:19 +0100848 and HANDLE_EA_EL3_FIRST_NS instead")
Manish Pandey9202d512023-02-13 12:39:17 +0000849endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100850
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100851
Manish Pandey9202d512023-02-13 12:39:17 +0000852# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled
Jeenu Viswambharan1a7c1cf2017-12-08 12:13:51 +0000853ifeq ($(FAULT_INJECTION_SUPPORT),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100854 ifeq ($(ENABLE_FEAT_RAS),0)
855 $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0)
856 endif
857endif #(FAULT_INJECTION_SUPPORT)
Jeenu Viswambharan1a7c1cf2017-12-08 12:13:51 +0000858
Roberto Vargased51b512018-09-24 17:20:48 +0100859# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
Soby Mathew209a60c2018-03-26 12:43:37 +0100860ifeq ($(DYN_DISABLE_AUTH), 1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100861 ifeq (${TRUSTED_BOARD_BOOT}, 0)
862 $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \
863 to be set.")
864 endif
865endif #(DYN_DISABLE_AUTH)
Soby Mathew209a60c2018-03-26 12:43:37 +0100866
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +0100867ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
868# Support authentication verification and hash calculation
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100869 CRYPTO_SUPPORT := 3
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +0100870else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
871# Support authentication verification and hash calculation
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100872 CRYPTO_SUPPORT := 3
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +0100873else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
874# Support hash calculation only
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100875 CRYPTO_SUPPORT := 2
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +0100876else ifeq (${TRUSTED_BOARD_BOOT},1)
877# Support authentication verification only
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100878 CRYPTO_SUPPORT := 1
Manish V Badarkhec9c56f62022-01-08 22:56:06 +0000879else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100880 CRYPTO_SUPPORT := 0
881endif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT))
Manish V Badarkhec9c56f62022-01-08 22:56:06 +0000882
Manish V Badarkhee4a070e2024-12-03 21:46:51 +0000883ifneq ($(filter 1 2 3,$(CRYPTO_SUPPORT)),)
884CRYPTO_LIB := $(BUILD_PLAT)/lib/libmbedtls.a
885endif
886
Balint Dobszaycbf9e842019-12-18 15:28:00 +0100887# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
888ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100889 $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
Manish V Badarkhe84ef9cd2020-06-29 10:32:53 +0100890endif
891
Antonio Nino Diazb86048c2019-02-19 11:53:51 +0000892# If pointer authentication is used in the firmware, make sure that all the
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100893# registers associated to it are also saved and restored.
894# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
Antonio Nino Diazb86048c2019-02-19 11:53:51 +0000895ifeq ($(ENABLE_PAUTH),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100896 ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
897 $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
898 endif
899endif #(ENABLE_PAUTH)
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100900
901ifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100902 ifneq (${ARCH},aarch64)
903 $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
904 endif
905endif #(CTX_INCLUDE_PAUTH_REGS)
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100906
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +0000907ifeq ($(FEATURE_DETECTION),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100908 $(info FEATURE_DETECTION is an experimental feature)
909endif #(FEATURE_DETECTION)
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +0000910
Jayanth Dodderi Chidanand03d3c0d2022-11-08 10:31:07 +0000911ifneq ($(ENABLE_SME2_FOR_NS), 0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100912 ifeq (${ENABLE_SME_FOR_NS}, 0)
913 $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \
914 to be set")
915 $(warning "Forced ENABLE_SME_FOR_NS=1")
916 override ENABLE_SME_FOR_NS := 1
917 endif
918endif #(ENABLE_SME2_FOR_NS)
Jayanth Dodderi Chidanand45007ac2023-03-06 23:56:14 +0000919
Petre-Ionut Tudor60e8f3c2019-11-07 15:18:03 +0000920ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100921 ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
922 $(error "ALLOW_RO_XLAT_TABLES requires translation tables \
923 library v2")
924 endif
925endif #(ARM_XLAT_TABLES_LIB_V1)
Petre-Ionut Tudor60e8f3c2019-11-07 15:18:03 +0000926
Sumit Garg7cda17b2019-11-15 10:43:00 +0530927ifneq (${DECRYPTION_SUPPORT},none)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100928 ifeq (${TRUSTED_BOARD_BOOT}, 0)
929 $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \
930 to be set)
931 endif
932endif #(DECRYPTION_SUPPORT)
Sumit Garg7cda17b2019-11-15 10:43:00 +0530933
johpow01744ad972022-01-28 17:06:20 -0600934# Ensure that no Aarch64-only features are enabled in Aarch32 build
johpow01dc78e622021-07-08 14:14:00 -0500935ifeq (${ARCH},aarch32)
johpow01744ad972022-01-28 17:06:20 -0600936
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100937 # SME/SVE only supported on AArch64
938 ifneq (${ENABLE_SME_FOR_NS},0)
939 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
940 endif
Jayanth Dodderi Chidanand03d3c0d2022-11-08 10:31:07 +0000941
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100942 ifeq (${ENABLE_SVE_FOR_NS},1)
943 # Warning instead of error due to CI dependency on this
944 $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
945 endif
johpow01744ad972022-01-28 17:06:20 -0600946
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100947 # BRBE is not supported in AArch32
948 ifeq (${ENABLE_BRBE_FOR_NS},1)
949 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
950 endif
johpow01744ad972022-01-28 17:06:20 -0600951
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100952 # FEAT_RNG_TRAP is not supported in AArch32
953 ifeq (${ENABLE_FEAT_RNG_TRAP},1)
954 $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
955 endif
Arvind Ram Prakasha57e18e2024-11-11 14:32:37 -0600956
957 ifneq (${ENABLE_FEAT_FPMR},0)
958 $(error "ENABLE_FEAT_FPMR cannot be used with ARCH=aarch32")
959 endif
Boyan Karatotev8db17052024-10-25 11:38:41 +0100960
961 ifeq (${ARCH_FEATURE_AVAILABILITY},1)
962 $(error "ARCH_FEATURE_AVAILABILITY cannot be used with ARCH=aarch32")
963 endif
Arvind Ram Prakash6b8df7b2025-01-09 17:18:30 -0600964 # FEAT_MOPS is only supported on AArch64
965 ifneq (${ENABLE_FEAT_MOPS},0)
966 $(error "ENABLE_FEAT_MOPS cannot be used with ARCH=aarch32")
967 endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100968endif #(ARCH=aarch32)
johpow01dc78e622021-07-08 14:14:00 -0500969
Arvind Ram Prakasha57e18e2024-11-11 14:32:37 -0600970ifneq (${ENABLE_FEAT_FPMR},0)
971 ifeq (${ENABLE_FEAT_FGT},0)
972 $(error "ENABLE_FEAT_FPMR requires ENABLE_FEAT_FGT")
973 endif
974 ifeq (${ENABLE_FEAT_HCX},0)
975 $(error "ENABLE_FEAT_FPMR requires ENABLE_FEAT_HCX")
976 endif
977endif #(ENABLE_FEAT_FPMR)
978
Boyan Karatotev0d122942023-03-08 16:29:26 +0000979ifneq (${ENABLE_SME_FOR_NS},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100980 ifeq (${ENABLE_SVE_FOR_NS},0)
981 $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS")
982 endif
983endif #(ENABLE_SME_FOR_NS)
Boyan Karatotev0d122942023-03-08 16:29:26 +0000984
johpow01dc78e622021-07-08 14:14:00 -0500985# Secure SME/SVE requires the non-secure component as well
986ifeq (${ENABLE_SME_FOR_SWD},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100987 ifeq (${ENABLE_SME_FOR_NS},0)
988 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
989 endif
990 ifeq (${ENABLE_SVE_FOR_SWD},0)
991 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD")
992 endif
993endif #(ENABLE_SME_FOR_SWD)
994
Madhukar Pappireddy3524d072024-06-17 15:28:33 -0500995# Enabling SVE for SWD requires enabling SVE for NWD due to ENABLE_FEAT
996# mechanism.
johpow01dc78e622021-07-08 14:14:00 -0500997ifeq (${ENABLE_SVE_FOR_SWD},1)
Madhukar Pappireddy3524d072024-06-17 15:28:33 -0500998 ifeq (${ENABLE_SVE_FOR_NS},0)
999 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
1000 endif
1001endif
johpow01dc78e622021-07-08 14:14:00 -05001002
Madhukar Pappireddy3524d072024-06-17 15:28:33 -05001003# Enabling SVE for both the worlds typically requires the context
1004# management of SVE registers. The only exception being SPMC at S-EL2.
1005ifeq (${ENABLE_SVE_FOR_SWD}, 1)
1006 ifneq (${ENABLE_SVE_FOR_NS}, 0)
1007 ifeq (${CTX_INCLUDE_SVE_REGS}-$(SPMD_SPM_AT_SEL2),0-0)
1008 $(warning "ENABLE_SVE_FOR_SWD and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
1009 endif
1010 endif
1011endif
1012
1013# Enabling SVE in either world while enabling CTX_INCLUDE_FPREGS requires
1014# CTX_INCLUDE_SVE_REGS to be enabled due to architectural dependency between FP
1015# and SVE registers.
1016ifeq (${CTX_INCLUDE_FPREGS}, 1)
1017 ifneq (${ENABLE_SVE_FOR_NS},0)
1018 ifeq (${CTX_INCLUDE_SVE_REGS},0)
1019 # Warning instead of error due to CI dependency on this
1020 $(warning "CTX_INCLUDE_FPREGS and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
1021 $(warning "Forced ENABLE_SVE_FOR_NS=0")
1022 override ENABLE_SVE_FOR_NS := 0
1023 endif
1024 endif
1025endif #(CTX_INCLUDE_FPREGS)
1026
1027# SVE context management is only required if secure world has access to SVE/FP
1028# functionality.
1029ifeq (${CTX_INCLUDE_SVE_REGS},1)
1030 ifeq (${ENABLE_SVE_FOR_SWD},0)
1031 $(error "CTX_INCLUDE_SVE_REGS requires ENABLE_SVE_FOR_SWD to also be enabled")
1032 endif
1033endif
1034
1035# SME cannot be used with CTX_INCLUDE_FPREGS since SPM does its own context
1036# management including FPU registers.
johpow01dc78e622021-07-08 14:14:00 -05001037ifeq (${CTX_INCLUDE_FPREGS},1)
Madhukar Pappireddy3524d072024-06-17 15:28:33 -05001038 ifneq (${ENABLE_SME_FOR_NS},0)
1039 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1040 endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001041endif #(CTX_INCLUDE_FPREGS)
johpow01dc78e622021-07-08 14:14:00 -05001042
Manish V Badarkhe00e28872022-03-02 12:06:35 +00001043ifeq ($(DRTM_SUPPORT),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001044 $(info DRTM_SUPPORT is an experimental feature)
Manish V Badarkhe00e28872022-03-02 12:06:35 +00001045endif
1046
Levi Yun89535682024-05-13 10:24:31 +01001047ifeq (${HOB_LIST},1)
1048 $(warning HOB_LIST is an experimental feature)
1049endif
1050
Raymond Mao3ba2c152023-07-25 07:53:35 -07001051ifeq (${TRANSFER_LIST},1)
1052 $(info TRANSFER_LIST is an experimental feature)
1053endif
1054
Chris Kay274a69e2022-09-29 16:21:24 +01001055ifeq (${ENABLE_RME},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001056 ifneq (${SEPARATE_CODE_AND_RODATA},1)
1057 $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
1058 endif
Chris Kay274a69e2022-09-29 16:21:24 +01001059endif
1060
Manish V Badarkhe5782b892023-09-06 09:08:28 +01001061ifeq ($(PSA_CRYPTO),1)
1062 $(info PSA_CRYPTO is an experimental feature)
1063endif
1064
Manish V Badarkhe82222db2024-05-09 12:14:13 +01001065ifeq ($(DICE_PROTECTION_ENVIRONMENT),1)
1066 $(info DICE_PROTECTION_ENVIRONMENT is an experimental feature)
1067endif
1068
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +00001069################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +01001070# Process platform overrideable behaviour
1071################################################################################
Achin Gupta4f6ad662013-10-25 09:08:21 +01001072
Manish Pandey5f24ce92021-10-06 10:59:52 +01001073ifdef BL1_SOURCES
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001074 NEED_BL1 := yes
1075endif #(BL1_SOURCES)
Manish Pandey5f24ce92021-10-06 10:59:52 +01001076
Juan Castillo73c99d42015-08-18 14:23:04 +01001077ifdef BL2_SOURCES
Manish Pandey5f24ce92021-10-06 10:59:52 +01001078 NEED_BL2 := yes
1079
1080 # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
1081 # Certificate generation tools. This flag can be overridden by the platform.
1082 ifdef EL3_PAYLOAD_BASE
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001083 # If booting an EL3 payload there is no need for a BL33 image
1084 # in the FIP file.
1085 NEED_BL33 := no
1086 else
1087 ifdef PRELOADED_BL33_BASE
1088 # If booting a BL33 preloaded image there is no need of
1089 # another one in the FIP file.
1090 NEED_BL33 := no
1091 else
1092 NEED_BL33 ?= yes
1093 endif
1094 endif
1095endif #(BL2_SOURCES)
Juan Castillo73c99d42015-08-18 14:23:04 +01001096
Manish Pandey5f24ce92021-10-06 10:59:52 +01001097ifdef BL2U_SOURCES
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001098 NEED_BL2U := yes
1099endif #(BL2U_SOURCES)
Manish Pandey5f24ce92021-10-06 10:59:52 +01001100
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001101# If SCP_BL2 is given, we always want FIP to include it.
1102ifdef SCP_BL2
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001103 NEED_SCP_BL2 := yes
1104endif #(SCP_BL2)
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001105
Soby Mathew5744e872017-11-14 14:10:10 +00001106# For AArch32, BL31 is not currently supported.
1107ifneq (${ARCH},aarch32)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001108 ifdef BL31_SOURCES
1109 # When booting an EL3 payload, there is no need to compile the BL31
1110 # image nor put it in the FIP.
1111 ifndef EL3_PAYLOAD_BASE
1112 NEED_BL31 := yes
1113 endif
1114 endif
1115endif #(ARCH=aarch64)
Soby Mathew5744e872017-11-14 14:10:10 +00001116
Juan Castillo73c99d42015-08-18 14:23:04 +01001117# Process TBB related flags
1118ifneq (${GENERATE_COT},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001119 # Common cert_create options
1120 ifneq (${CREATE_KEYS},0)
Juan Castillo73c99d42015-08-18 14:23:04 +01001121 $(eval CRT_ARGS += -n)
Yatharth Kochar01912622015-10-12 12:33:47 +01001122 $(eval FWU_CRT_ARGS += -n)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001123 ifneq (${SAVE_KEYS},0)
Juan Castillo73c99d42015-08-18 14:23:04 +01001124 $(eval CRT_ARGS += -k)
Yatharth Kochar01912622015-10-12 12:33:47 +01001125 $(eval FWU_CRT_ARGS += -k)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001126 endif
1127 endif
1128 # Include TBBR makefile (unless the platform indicates otherwise)
1129 ifeq (${INCLUDE_TBBR_MK},1)
Juan Castillo73c99d42015-08-18 14:23:04 +01001130 include make_helpers/tbbr/tbbr_tools.mk
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001131 endif
1132endif #(GENERATE_COT)
Juan Castillo73c99d42015-08-18 14:23:04 +01001133
Masahiro Yamada1c75d5d2016-12-25 13:52:22 +09001134ifneq (${FIP_ALIGN},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001135 FIP_ARGS += --align ${FIP_ALIGN}
1136endif #(FIP_ALIGN)
Masahiro Yamada1c75d5d2016-12-25 13:52:22 +09001137
Manish Pandey5f24ce92021-10-06 10:59:52 +01001138ifdef FDT_SOURCES
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001139 NEED_FDT := yes
1140endif #(FDT_SOURCES)
Manish Pandey5f24ce92021-10-06 10:59:52 +01001141
Juan Castillo73c99d42015-08-18 14:23:04 +01001142################################################################################
Michalis Pappas46e5e032018-03-20 13:01:27 +08001143# Include libraries' Makefile that are used in all BL
1144################################################################################
1145
1146include lib/stack_protector/stack_protector.mk
1147
1148################################################################################
Soby Mathew8a860522017-02-14 10:05:07 +00001149# Include BL specific makefiles
1150################################################################################
Manish Pandey5f24ce92021-10-06 10:59:52 +01001151
1152ifeq (${NEED_BL1},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001153include bl1/bl1.mk
1154endif
1155
Manish Pandey5f24ce92021-10-06 10:59:52 +01001156ifeq (${NEED_BL2},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001157include bl2/bl2.mk
1158endif
1159
Manish Pandey5f24ce92021-10-06 10:59:52 +01001160ifeq (${NEED_BL2U},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001161include bl2u/bl2u.mk
1162endif
1163
Soby Mathew5744e872017-11-14 14:10:10 +00001164ifeq (${NEED_BL31},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001165include bl31/bl31.mk
1166endif
Nishanth Menon03b397a2016-10-14 01:13:57 +00001167
Juan Castillo73c99d42015-08-18 14:23:04 +01001168################################################################################
1169# Build options checks
1170################################################################################
Juan Castillob7124ea2014-11-04 17:36:40 +00001171
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001172# Boolean_Flags
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001173$(eval $(call assert_booleans,\
1174 $(sort \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001175 ALLOW_RO_XLAT_TABLES \
1176 BL2_ENABLE_SP_LOAD \
1177 COLD_BOOT_SINGLE_CPU \
1178 CREATE_KEYS \
1179 CTX_INCLUDE_AARCH32_REGS \
1180 CTX_INCLUDE_FPREGS \
Madhukar Pappireddy42422622024-06-17 15:17:03 -05001181 CTX_INCLUDE_SVE_REGS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001182 CTX_INCLUDE_EL2_REGS \
Arvind Ram Prakash9acff282023-10-06 14:35:21 -05001183 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001184 DEBUG \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001185 DYN_DISABLE_AUTH \
1186 EL3_EXCEPTION_HANDLING \
1187 ENABLE_AMU_AUXILIARY_COUNTERS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001188 AMU_RESTRICT_COUNTERS \
1189 ENABLE_ASSERTIONS \
Jayanth Dodderi Chidanandc5e1da82023-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 Pandey970a4a82023-10-10 13:53:25 +01001196 ENABLE_FEAT_RAS \
Manish Pandeyf87e54f2023-10-10 15:42:19 +01001197 FFH_SUPPORT \
Jayanth Dodderi Chidanandc5e1da82023-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 Ravi538516f2023-09-28 13:17:24 -05001203 HARDEN_SLS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001204 HW_ASSISTED_COHERENCY \
1205 MEASURED_BOOT \
Tamas Bane7f11812023-06-07 13:35:04 +02001206 DICE_PROTECTION_ENVIRONMENT \
Raghu Krishnamurthy6a88ec82024-06-03 19:02:29 -07001207 RMMD_ENABLE_EL3_TOKEN_SIGN \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001208 DRTM_SUPPORT \
1209 NS_TIMER_SWITCH \
1210 OVERRIDE_LIBC \
1211 PL011_GENERIC_UART \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001212 PROGRAMMABLE_RESET_ADDRESS \
1213 PSCI_EXTENDED_STATE_ID \
1214 PSCI_OS_INIT_MODE \
Boyan Karatotev8db17052024-10-25 11:38:41 +01001215 ARCH_FEATURE_AVAILABILITY \
Jayanth Dodderi Chidanandc5e1da82023-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 Li86acbbe2022-08-26 13:48:31 +08001221 SEPARATE_RWDATA_REGION \
Madhukar Pappireddy308ebfa2024-06-17 15:26:00 -05001222 SEPARATE_SIMD_SECTION \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001223 SPIN_ON_BL1_EXIT \
1224 SPM_MM \
1225 SPMC_AT_EL3 \
Nishant Sharma801cd3c2023-06-27 00:36:01 +01001226 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001227 SPMD_SPM_AT_SEL2 \
Raghu Krishnamurthy890b5082023-02-25 13:26:10 -08001228 ENABLE_SPMD_LP \
Raymond Mao3ba2c152023-07-25 07:53:35 -07001229 TRANSFER_LIST \
Jayanth Dodderi Chidanandc5e1da82023-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 \
Boyan Karatotev45c73282024-09-20 13:37:51 +01001246 ERRATA_SME_POWER_DOWN \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001247 RAS_TRAP_NS_ERR_REC_ACCESS \
1248 COT_DESC_IN_DTB \
1249 USE_SP804_TIMER \
1250 PSA_FWU_SUPPORT \
Sughosh Ganu11d05a72024-02-01 12:51:20 +05301251 PSA_FWU_METADATA_FW_STORE_DESC \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001252 ENABLE_MPMM \
Boyan Karatotev2b5e00d2024-12-19 16:07:29 +00001253 FEAT_PABANDON \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001254 FEATURE_DETECTION \
Jayanth Dodderi Chidanand0b22e592022-10-11 17:16:07 +01001255 TRNG_SUPPORT \
Boyan Karatotev593ae352023-03-22 15:55:36 +00001256 ENABLE_ERRATA_ALL \
Sona Mathewffea3842022-11-18 18:05:38 -06001257 ERRATA_ABI_SUPPORT \
Sona Mathewef63f5b2023-03-14 14:02:03 -05001258 ERRATA_NON_ARM_INTERCONNECT \
Okash Khawaja04c73032022-11-04 12:38:01 +00001259 CONDITIONAL_CMO \
Manish V Badarkhe5782b892023-09-06 09:08:28 +01001260 PSA_CRYPTO \
Sandrine Bailleux85bebe12023-10-11 08:38:00 +02001261 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash183329a2023-08-15 16:28:06 -05001262 INIT_UNUSED_NS_EL2 \
Juan Pablo Condebfef8b92023-11-08 16:14:28 -06001263 PLATFORM_REPORT_CTX_MEM_USE \
Yann Gautierae770fe2024-01-16 19:39:31 +01001264 EARLY_CONSOLE \
Arvind Ram Prakashf99a69c2023-12-21 00:25:52 -06001265 PRESERVE_DSU_PMU_REGS \
Levi Yun89535682024-05-13 10:24:31 +01001266 HOB_LIST \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001267)))
Juan Castillo73c99d42015-08-18 14:23:04 +01001268
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001269# Numeric_Flags
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001270$(eval $(call assert_numerics,\
1271 $(sort \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001272 ARM_ARCH_MAJOR \
1273 ARM_ARCH_MINOR \
1274 BRANCH_PROTECTION \
1275 CTX_INCLUDE_PAUTH_REGS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001276 CTX_INCLUDE_NEVE_REGS \
1277 CRYPTO_SUPPORT \
Boyan Karatotev83a4dae2023-02-16 09:45:29 +00001278 DISABLE_MTPMU \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001279 ENABLE_BRBE_FOR_NS \
1280 ENABLE_TRBE_FOR_NS \
1281 ENABLE_BTI \
1282 ENABLE_PAUTH \
1283 ENABLE_FEAT_AMU \
1284 ENABLE_FEAT_AMUv1p1 \
1285 ENABLE_FEAT_CSV2_2 \
Sona Mathew30019d82023-10-25 16:48:19 -05001286 ENABLE_FEAT_CSV2_3 \
Arvind Ram Prakash83271d52024-05-22 15:24:00 -05001287 ENABLE_FEAT_DEBUGV8P9 \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001288 ENABLE_FEAT_DIT \
1289 ENABLE_FEAT_ECV \
1290 ENABLE_FEAT_FGT \
Arvind Ram Prakash33e6aaa2024-06-06 11:33:37 -05001291 ENABLE_FEAT_FGT2 \
Arvind Ram Prakasha57e18e2024-11-11 14:32:37 -06001292 ENABLE_FEAT_FPMR \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001293 ENABLE_FEAT_HCX \
Andre Przywara19d52a82024-08-09 17:04:22 +01001294 ENABLE_FEAT_LS64_ACCDATA \
Arvind Ram Prakash6b8df7b2025-01-09 17:18:30 -06001295 ENABLE_FEAT_MOPS \
Govindraj Raja8e397882024-01-26 10:08:37 -06001296 ENABLE_FEAT_MTE2 \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001297 ENABLE_FEAT_PAN \
1298 ENABLE_FEAT_RNG \
1299 ENABLE_FEAT_RNG_TRAP \
1300 ENABLE_FEAT_SEL2 \
1301 ENABLE_FEAT_TCR2 \
Jayanth Dodderi Chidanand6d0433f2024-09-05 22:24:04 +01001302 ENABLE_FEAT_THE \
Govindraj Raja0e4daed2024-01-23 16:03:53 -06001303 ENABLE_FEAT_SB \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001304 ENABLE_FEAT_S2PIE \
1305 ENABLE_FEAT_S1PIE \
1306 ENABLE_FEAT_S2POE \
1307 ENABLE_FEAT_S1POE \
Jayanth Dodderi Chidanand4ec4e542024-09-06 13:49:31 +01001308 ENABLE_FEAT_SCTLR2 \
Govindraj Raja30655132024-09-06 15:43:43 +01001309 ENABLE_FEAT_D128 \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001310 ENABLE_FEAT_GCS \
1311 ENABLE_FEAT_VHE \
Arvind Ram Prakashedebefb2023-10-11 12:10:56 -05001312 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001313 ENABLE_RME \
1314 ENABLE_SPE_FOR_NS \
1315 ENABLE_SYS_REG_TRACE_FOR_NS \
1316 ENABLE_SME_FOR_NS \
1317 ENABLE_SME2_FOR_NS \
1318 ENABLE_SVE_FOR_NS \
1319 ENABLE_TRF_FOR_NS \
1320 FW_ENC_STATUS \
1321 NR_OF_FW_BANKS \
1322 NR_OF_IMAGES_IN_FW_BANK \
1323 TWED_DELAY \
1324 ENABLE_FEAT_TWED \
1325 SVE_VECTOR_LEN \
Varun Wadekar0ed3be62023-04-13 21:06:18 +01001326 IMPDEF_SYSREG_TRAP \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001327)))
Jeenu Viswambharanc877b412017-01-16 16:52:35 +00001328
Justin Chadwellaacff742019-07-29 17:13:10 +01001329ifdef KEY_SIZE
1330 $(eval $(call assert_numeric,KEY_SIZE))
1331endif
1332
Justin Chadwell1f461972019-08-20 11:01:52 +01001333ifeq ($(filter $(SANITIZE_UB), on off trap),)
1334 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
1335endif
1336
Juan Castillo73c99d42015-08-18 14:23:04 +01001337################################################################################
1338# Add definitions to the cpp preprocessor based on the current build options.
1339# This is done after including the platform specific makefile to allow the
1340# platform to overwrite the default options
1341################################################################################
1342
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001343$(eval $(call add_defines,\
1344 $(sort \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001345 ALLOW_RO_XLAT_TABLES \
1346 ARM_ARCH_MAJOR \
1347 ARM_ARCH_MINOR \
1348 BL2_ENABLE_SP_LOAD \
1349 COLD_BOOT_SINGLE_CPU \
1350 CTX_INCLUDE_AARCH32_REGS \
1351 CTX_INCLUDE_FPREGS \
Madhukar Pappireddy42422622024-06-17 15:17:03 -05001352 CTX_INCLUDE_SVE_REGS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001353 CTX_INCLUDE_PAUTH_REGS \
Arvind Ram Prakash9acff282023-10-06 14:35:21 -05001354 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001355 EL3_EXCEPTION_HANDLING \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001356 CTX_INCLUDE_EL2_REGS \
1357 CTX_INCLUDE_NEVE_REGS \
1358 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
1359 DISABLE_MTPMU \
1360 ENABLE_FEAT_AMU \
1361 ENABLE_AMU_AUXILIARY_COUNTERS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001362 AMU_RESTRICT_COUNTERS \
1363 ENABLE_ASSERTIONS \
1364 ENABLE_BTI \
Arvind Ram Prakash83271d52024-05-22 15:24:00 -05001365 ENABLE_FEAT_DEBUGV8P9 \
Arvind Ram Prakashedebefb2023-10-11 12:10:56 -05001366 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001367 ENABLE_PAUTH \
1368 ENABLE_PIE \
1369 ENABLE_PMF \
1370 ENABLE_PSCI_STAT \
1371 ENABLE_RME \
Raghu Krishnamurthy6a88ec82024-06-03 19:02:29 -07001372 RMMD_ENABLE_EL3_TOKEN_SIGN \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001373 ENABLE_RUNTIME_INSTRUMENTATION \
1374 ENABLE_SME_FOR_NS \
1375 ENABLE_SME2_FOR_NS \
1376 ENABLE_SME_FOR_SWD \
1377 ENABLE_SPE_FOR_NS \
1378 ENABLE_SVE_FOR_NS \
1379 ENABLE_SVE_FOR_SWD \
Manish Pandey970a4a82023-10-10 13:53:25 +01001380 ENABLE_FEAT_RAS \
Manish Pandeyf87e54f2023-10-10 15:42:19 +01001381 FFH_SUPPORT \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001382 ENCRYPT_BL31 \
1383 ENCRYPT_BL32 \
1384 ERROR_DEPRECATED \
1385 FAULT_INJECTION_SUPPORT \
1386 GICV2_G0_FOR_EL3 \
1387 HANDLE_EA_EL3_FIRST_NS \
1388 HW_ASSISTED_COHERENCY \
1389 LOG_LEVEL \
1390 MEASURED_BOOT \
Tamas Bane7f11812023-06-07 13:35:04 +02001391 DICE_PROTECTION_ENVIRONMENT \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001392 DRTM_SUPPORT \
1393 NS_TIMER_SWITCH \
1394 PL011_GENERIC_UART \
1395 PLAT_${PLAT} \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001396 PROGRAMMABLE_RESET_ADDRESS \
1397 PSCI_EXTENDED_STATE_ID \
1398 PSCI_OS_INIT_MODE \
Boyan Karatotev8db17052024-10-25 11:38:41 +01001399 ARCH_FEATURE_AVAILABILITY \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001400 RESET_TO_BL31 \
AlexeiFedorovd7660842024-05-13 15:35:54 +01001401 RME_GPT_BITLOCK_BLOCK \
AlexeiFedorovec0088b2024-03-13 17:07:03 +00001402 RME_GPT_MAX_BLOCK \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001403 SEPARATE_CODE_AND_RODATA \
1404 SEPARATE_BL2_NOLOAD_REGION \
1405 SEPARATE_NOBITS_REGION \
Ye Li86acbbe2022-08-26 13:48:31 +08001406 SEPARATE_RWDATA_REGION \
Madhukar Pappireddy308ebfa2024-06-17 15:26:00 -05001407 SEPARATE_SIMD_SECTION \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001408 RECLAIM_INIT_CODE \
1409 SPD_${SPD} \
1410 SPIN_ON_BL1_EXIT \
1411 SPM_MM \
1412 SPMC_AT_EL3 \
Nishant Sharma801cd3c2023-06-27 00:36:01 +01001413 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001414 SPMD_SPM_AT_SEL2 \
Raymond Mao3ba2c152023-07-25 07:53:35 -07001415 TRANSFER_LIST \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001416 TRUSTED_BOARD_BOOT \
1417 CRYPTO_SUPPORT \
1418 TRNG_SUPPORT \
1419 ERRATA_ABI_SUPPORT \
Sona Mathewef63f5b2023-03-14 14:02:03 -05001420 ERRATA_NON_ARM_INTERCONNECT \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001421 USE_COHERENT_MEM \
1422 USE_DEBUGFS \
1423 ARM_IO_IN_DTB \
1424 SDEI_IN_FCONF \
1425 SEC_INT_DESC_IN_FCONF \
1426 USE_ROMLIB \
1427 USE_TBBR_DEFS \
1428 WARMBOOT_ENABLE_DCACHE_EARLY \
1429 RESET_TO_BL2 \
1430 BL2_RUNS_AT_EL3 \
1431 BL2_IN_XIP_MEM \
1432 BL2_INV_DCACHE \
1433 USE_SPINLOCK_CAS \
1434 ERRATA_SPECULATIVE_AT \
Boyan Karatotev45c73282024-09-20 13:37:51 +01001435 ERRATA_SME_POWER_DOWN \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001436 RAS_TRAP_NS_ERR_REC_ACCESS \
1437 COT_DESC_IN_DTB \
1438 USE_SP804_TIMER \
1439 ENABLE_FEAT_RNG \
1440 ENABLE_FEAT_RNG_TRAP \
1441 ENABLE_FEAT_SB \
1442 ENABLE_FEAT_DIT \
1443 NR_OF_FW_BANKS \
1444 NR_OF_IMAGES_IN_FW_BANK \
1445 PSA_FWU_SUPPORT \
Sughosh Ganu11d05a72024-02-01 12:51:20 +05301446 PSA_FWU_METADATA_FW_STORE_DESC \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001447 ENABLE_BRBE_FOR_NS \
1448 ENABLE_TRBE_FOR_NS \
1449 ENABLE_SYS_REG_TRACE_FOR_NS \
1450 ENABLE_TRF_FOR_NS \
1451 ENABLE_FEAT_HCX \
1452 ENABLE_MPMM \
Boyan Karatotev2b5e00d2024-12-19 16:07:29 +00001453 FEAT_PABANDON \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001454 ENABLE_FEAT_FGT \
Arvind Ram Prakash33e6aaa2024-06-06 11:33:37 -05001455 ENABLE_FEAT_FGT2 \
Arvind Ram Prakasha57e18e2024-11-11 14:32:37 -06001456 ENABLE_FEAT_FPMR \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001457 ENABLE_FEAT_ECV \
1458 ENABLE_FEAT_AMUv1p1 \
1459 ENABLE_FEAT_SEL2 \
1460 ENABLE_FEAT_VHE \
1461 ENABLE_FEAT_CSV2_2 \
Sona Mathew30019d82023-10-25 16:48:19 -05001462 ENABLE_FEAT_CSV2_3 \
Andre Przywara19d52a82024-08-09 17:04:22 +01001463 ENABLE_FEAT_LS64_ACCDATA \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001464 ENABLE_FEAT_PAN \
1465 ENABLE_FEAT_TCR2 \
Jayanth Dodderi Chidanand6d0433f2024-09-05 22:24:04 +01001466 ENABLE_FEAT_THE \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001467 ENABLE_FEAT_S2PIE \
1468 ENABLE_FEAT_S1PIE \
1469 ENABLE_FEAT_S2POE \
1470 ENABLE_FEAT_S1POE \
Jayanth Dodderi Chidanand4ec4e542024-09-06 13:49:31 +01001471 ENABLE_FEAT_SCTLR2 \
Govindraj Raja30655132024-09-06 15:43:43 +01001472 ENABLE_FEAT_D128 \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001473 ENABLE_FEAT_GCS \
Arvind Ram Prakash6b8df7b2025-01-09 17:18:30 -06001474 ENABLE_FEAT_MOPS \
Govindraj Raja8e397882024-01-26 10:08:37 -06001475 ENABLE_FEAT_MTE2 \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001476 FEATURE_DETECTION \
1477 TWED_DELAY \
1478 ENABLE_FEAT_TWED \
Okash Khawaja04c73032022-11-04 12:38:01 +00001479 CONDITIONAL_CMO \
Varun Wadekar0ed3be62023-04-13 21:06:18 +01001480 IMPDEF_SYSREG_TRAP \
Jayanth Dodderi Chidananda8cf6fa2023-04-26 15:57:30 +01001481 SVE_VECTOR_LEN \
Raghu Krishnamurthy890b5082023-02-25 13:26:10 -08001482 ENABLE_SPMD_LP \
Manish V Badarkhe5782b892023-09-06 09:08:28 +01001483 PSA_CRYPTO \
Sandrine Bailleux85bebe12023-10-11 08:38:00 +02001484 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash183329a2023-08-15 16:28:06 -05001485 INIT_UNUSED_NS_EL2 \
Juan Pablo Condebfef8b92023-11-08 16:14:28 -06001486 PLATFORM_REPORT_CTX_MEM_USE \
Yann Gautierae770fe2024-01-16 19:39:31 +01001487 EARLY_CONSOLE \
Arvind Ram Prakashf99a69c2023-12-21 00:25:52 -06001488 PRESERVE_DSU_PMU_REGS \
Levi Yun89535682024-05-13 10:24:31 +01001489 HOB_LIST \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001490)))
Jeenu Viswambharan2fae4b12016-10-24 14:31:51 +01001491
Juan Pablo Condebfef8b92023-11-08 16:14:28 -06001492ifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1)
1493ifeq (${DEBUG}, 0)
1494 $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only")
1495 override PLATFORM_REPORT_CTX_MEM_USE := 0
1496endif
1497endif
1498
Justin Chadwell1f461972019-08-20 11:01:52 +01001499ifeq (${SANITIZE_UB},trap)
1500 $(eval $(call add_define,MONITOR_TRAPS))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001501endif #(SANITIZE_UB)
Justin Chadwell1f461972019-08-20 11:01:52 +01001502
Sandrine Bailleux4c117f62015-11-26 16:31:34 +00001503# Define the EL3_PAYLOAD_BASE flag only if it is provided.
1504ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +00001505 $(eval $(call add_define,EL3_PAYLOAD_BASE))
1506else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001507# Define the PRELOADED_BL33_BASE flag only if it is provided and
1508# EL3_PAYLOAD_BASE is not defined, as it has priority.
1509 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz68450a62016-04-06 17:31:57 +01001510 $(eval $(call add_define,PRELOADED_BL33_BASE))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001511 endif
1512endif #(EL3_PAYLOAD_BASE)
Juan Castillo73c99d42015-08-18 14:23:04 +01001513
Soby Mathew209a60c2018-03-26 12:43:37 +01001514# Define the DYN_DISABLE_AUTH flag only if set.
1515ifeq (${DYN_DISABLE_AUTH},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001516 $(eval $(call add_define,DYN_DISABLE_AUTH))
Soby Mathew209a60c2018-03-26 12:43:37 +01001517endif
1518
Chris Kay8620bd02023-12-04 09:55:50 +00001519ifeq ($($(ARCH)-ld-id),arm-link)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001520 $(eval $(call add_define,USE_ARM_LINK))
Varun Wadekarc2ad38c2019-01-11 14:47:48 -08001521endif
1522
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001523# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001524ifeq (${SPD},spmd)
Olivier Deprezc33ff192020-03-19 09:27:11 +01001525ifdef SP_LAYOUT_FILE
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001526 -include $(BUILD_PLAT)/sp_gen.mk
1527 FIP_DEPS += sp
1528 CRT_DEPS += sp
1529 NEED_SP_PKG := yes
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001530else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001531 ifeq (${SPMD_SPM_AT_SEL2},1)
1532 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1533 endif
1534endif #(SP_LAYOUT_FILE)
1535endif #(SPD)
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001536
Juan Castillo73c99d42015-08-18 14:23:04 +01001537################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +01001538# Build targets
1539################################################################################
1540
Harrison Mutai2329e222024-08-28 13:27:19 +00001541.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp tl fwu_fip certtool dtbs memmap doc enctool
Juan Castillo73c99d42015-08-18 14:23:04 +01001542
1543all: msg_start
1544
1545msg_start:
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001546 $(s)echo "Building ${PLAT}"
Juan Castillo73c99d42015-08-18 14:23:04 +01001547
Soby Mathew7a24cba2015-10-26 14:29:21 +00001548ifeq (${ERROR_DEPRECATED},0)
Julius Wernerd5dfdeb2019-07-09 13:49:11 -07001549# Check if deprecated declarations and cpp warnings should be treated as error or not.
Chris Kay8620bd02023-12-04 09:55:50 +00001550ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
Varun Wadekarc2ad38c2019-01-11 14:47:48 -08001551 CPPFLAGS += -Wno-error=deprecated-declarations
1552else
Dan Handleybc1a03c2018-02-27 16:03:58 +00001553 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp
Soby Mathew7a24cba2015-10-26 14:29:21 +00001554endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001555endif #(!ERROR_DEPRECATED)
Soby Mathew7a24cba2015-10-26 14:29:21 +00001556
Roberto Vargas61f72a32018-05-08 10:27:10 +01001557$(eval $(call MAKE_LIB,c))
Roberto Vargas5fee0282018-05-08 10:27:10 +01001558
Juan Castillo73c99d42015-08-18 14:23:04 +01001559# Expand build macros for the different images
1560ifeq (${NEED_BL1},yes)
Chris Kayb34635a2021-09-28 15:44:19 +01001561BL1_SOURCES := $(sort ${BL1_SOURCES})
Zelalem Aweke434d0492021-07-11 17:25:48 -05001562$(eval $(call MAKE_BL,bl1))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001563endif #(NEED_BL1)
Juan Castillo73c99d42015-08-18 14:23:04 +01001564
1565ifeq (${NEED_BL2},yes)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001566
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -06001567ifeq (${RESET_TO_BL2}, 0)
Roberto Vargasc9b31ae2018-01-02 11:23:41 +00001568FIP_BL2_ARGS := tb-fw
1569endif
1570
Chris Kayeb1acfb2021-09-28 15:44:37 +01001571BL2_SOURCES := $(sort ${BL2_SOURCES})
1572
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001573$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001574 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001575
1576endif #(NEED_BL2)
Juan Castillo73c99d42015-08-18 14:23:04 +01001577
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001578ifeq (${NEED_SCP_BL2},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001579$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001580endif #(NEED_SCP_BL2)
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001581
Juan Castillo73c99d42015-08-18 14:23:04 +01001582ifeq (${NEED_BL31},yes)
1583BL31_SOURCES += ${SPD_SOURCES}
Madhukar Pappireddy26d1e0c2020-01-27 13:37:51 -06001584# Sort BL31 source files to remove duplicates
1585BL31_SOURCES := $(sort ${BL31_SOURCES})
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301586ifneq (${DECRYPTION_SUPPORT},none)
1587$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001588 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301589else
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001590$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001591 $(eval $(call MAKE_BL,bl31,soc-fw)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001592endif #(DECRYPTION_SUPPORT)
1593endif #(NEED_BL31)
Juan Castillo73c99d42015-08-18 14:23:04 +01001594
Juan Castillo70d1fc52015-11-12 10:59:26 +00001595# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
Masahiro Yamadac939d132018-01-26 11:42:01 +09001596# build system will call TOOL_ADD_IMG to print a warning message and abort the
Juan Castillo70d1fc52015-11-12 10:59:26 +00001597# process. Note that the dependency on BL32 applies to the FIP only.
Juan Castillo73c99d42015-08-18 14:23:04 +01001598ifeq (${NEED_BL32},yes)
Madhukar Pappireddy26d1e0c2020-01-27 13:37:51 -06001599# Sort BL32 source files to remove duplicates
1600BL32_SOURCES := $(sort ${BL32_SOURCES})
Masahiro Yamada9cd15232018-01-26 11:42:01 +09001601BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
1602
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301603ifneq (${DECRYPTION_SUPPORT},none)
Zelalem Aweke434d0492021-07-11 17:25:48 -05001604$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301605 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1606else
Zelalem Aweke434d0492021-07-11 17:25:48 -05001607$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001608 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001609endif #(DECRYPTION_SUPPORT)
1610endif #(NEED_BL32)
Juan Castillo73c99d42015-08-18 14:23:04 +01001611
Zelalem Aweke5b18de02021-07-11 18:33:20 -05001612# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
1613# needs to be built from RMM_SOURCES.
1614ifeq (${NEED_RMM},yes)
1615# Sort RMM source files to remove duplicates
1616RMM_SOURCES := $(sort ${RMM_SOURCES})
1617BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
1618
1619$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001620 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1621endif #(NEED_RMM)
Zelalem Aweke5b18de02021-07-11 18:33:20 -05001622
Juan Castillo73c99d42015-08-18 14:23:04 +01001623# Add the BL33 image if required by the platform
1624ifeq (${NEED_BL33},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001625$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001626endif #(NEED_BL33)
Juan Castillodb6071c2015-01-13 12:21:04 +00001627
Yatharth Kochar9003fa02015-10-14 15:27:24 +01001628ifeq (${NEED_BL2U},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001629$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001630 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001631endif #(NEED_BL2U)
Yatharth Kochar9003fa02015-10-14 15:27:24 +01001632
Nishanth Menon03b397a2016-10-14 01:13:57 +00001633# Expand build macros for the different images
1634ifeq (${NEED_FDT},yes)
Soby Mathew38c14d82017-12-14 17:44:56 +00001635 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001636endif #(NEED_FDT)
Nishanth Menon03b397a2016-10-14 01:13:57 +00001637
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001638# Add Secure Partition packages
1639ifeq (${NEED_SP_PKG},yes)
Chris Kayfd74ca02024-07-30 13:33:56 +00001640$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | $$(@D)/
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001641 $(q)${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
J-Alves822c7272022-03-22 16:28:51 +00001642sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001643 $(s)echo
1644 $(s)echo "Built SP Images successfully"
1645 $(s)echo
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001646endif #(NEED_SP_PKG)
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001647
Ian Spray36eaaf32014-01-30 17:25:28 +00001648locate-checkpatch:
1649ifndef CHECKPATCH
Etienne Carriere66079b02017-08-23 15:44:01 +02001650 $(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 +00001651else
1652ifeq (,$(wildcard ${CHECKPATCH}))
Etienne Carriere66079b02017-08-23 15:44:01 +02001653 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
Ian Spray36eaaf32014-01-30 17:25:28 +00001654endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001655endif #(CHECKPATCH)
Ian Spray36eaaf32014-01-30 17:25:28 +00001656
Achin Gupta4f6ad662013-10-25 09:08:21 +01001657clean:
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001658 $(s)echo " CLEAN"
Chris Kayc3273702025-01-13 15:57:32 +00001659 $(q)rm -rf $(BUILD_PLAT)
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001660 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001661 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
1662 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
1663 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001664
James Morrisseyeaaeece2013-11-01 13:56:59 +00001665realclean distclean:
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001666 $(s)echo " REALCLEAN"
Chris Kayc3273702025-01-13 15:57:32 +00001667 $(q)rm -rf $(BUILD_BASE)
1668 $(q)rm -rf $(CURDIR)/cscope.*
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001669 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001670 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
1671 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
1672 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001673
Ian Spray36eaaf32014-01-30 17:25:28 +00001674checkcodebase: locate-checkpatch
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001675 $(s)echo " CHECKING STYLE"
1676 $(q)if test -d .git ; then \
Paul Beesley1ef35512019-03-07 16:42:31 +00001677 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001678 while read GIT_FILE ; \
1679 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
1680 done ; \
1681 else \
1682 find . -type f -not -iwholename "*.git*" \
1683 -not -iwholename "*build*" \
1684 -not -iwholename "*libfdt*" \
Roberto Vargas61f72a32018-05-08 10:27:10 +01001685 -not -iwholename "*libc*" \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001686 -not -iwholename "*docs*" \
Paul Beesley1ef35512019-03-07 16:42:31 +00001687 -not -iwholename "*.rst" \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001688 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
1689 fi
Ian Spray36eaaf32014-01-30 17:25:28 +00001690
1691checkpatch: locate-checkpatch
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001692 $(s)echo " CHECKING STYLE"
1693 $(q)if test -n "${CHECKPATCH_OPTS}"; then \
Yann Gautier02a76d52019-03-08 15:44:00 +01001694 echo " with ${CHECKPATCH_OPTS} option(s)"; \
1695 fi
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001696 $(q)COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
Yann Gautier77a0a7f2021-11-02 18:03:31 +01001697 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \
1698 do \
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001699 printf "\n[*] Checking style of '$$commit'\n\n"; \
Yann Gautier1a721742024-08-09 11:52:03 +02001700 ( git log --format=email "$$commit~..$$commit" \
1701 -- ${CHECK_PATHS} ; \
1702 git diff --format=email "$$commit~..$$commit" \
1703 -- ${CHECK_PATHS}; ) | \
Yann Gautier02a76d52019-03-08 15:44:00 +01001704 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001705 done
Juan Castillo73c99d42015-08-18 14:23:04 +01001706
1707certtool: ${CRTTOOL}
Ian Spray36eaaf32014-01-30 17:25:28 +00001708
Pali Rohára9812202020-11-24 15:38:08 +01001709${CRTTOOL}: FORCE
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001710 $(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
1711 $(s)echo
1712 $(s)echo "Built $@ successfully"
1713 $(s)echo
Juan Castillo73c99d42015-08-18 14:23:04 +01001714
1715ifneq (${GENERATE_COT},0)
1716certificates: ${CRT_DEPS} ${CRTTOOL}
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001717 $(q)${CRTTOOL} ${CRT_ARGS}
1718 $(s)echo
1719 $(s)echo "Built $@ successfully"
1720 $(s)echo "Certificates can be found in ${BUILD_PLAT}"
1721 $(s)echo
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001722endif #(GENERATE_COT)
Juan Castillo73c99d42015-08-18 14:23:04 +01001723
1724${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
Pali Rohár4727fd12020-11-24 16:53:04 +01001725 $(eval ${CHECK_FIP_CMD})
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001726 $(q)${FIPTOOL} create ${FIP_ARGS} $@
1727 $(q)${FIPTOOL} info $@
1728 $(s)echo
1729 $(s)echo "Built $@ successfully"
1730 $(s)echo
Juan Castillo73c99d42015-08-18 14:23:04 +01001731
Yatharth Kochar01912622015-10-12 12:33:47 +01001732ifneq (${GENERATE_COT},0)
1733fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001734 $(q)${CRTTOOL} ${FWU_CRT_ARGS}
1735 $(s)echo
1736 $(s)echo "Built $@ successfully"
1737 $(s)echo "FWU certificates can be found in ${BUILD_PLAT}"
1738 $(s)echo
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001739endif #(GENERATE_COT)
Yatharth Kochar01912622015-10-12 12:33:47 +01001740
1741${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
Pali Rohár4727fd12020-11-24 16:53:04 +01001742 $(eval ${CHECK_FWU_FIP_CMD})
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001743 $(q)${FIPTOOL} create ${FWU_FIP_ARGS} $@
1744 $(q)${FIPTOOL} info $@
1745 $(s)echo
1746 $(s)echo "Built $@ successfully"
1747 $(s)echo
Yatharth Kochar01912622015-10-12 12:33:47 +01001748
Juan Castillo73c99d42015-08-18 14:23:04 +01001749fiptool: ${FIPTOOL}
1750fip: ${BUILD_PLAT}/${FIP_NAME}
Yatharth Kochar01912622015-10-12 12:33:47 +01001751fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
Juan Castillo6f971622014-10-21 11:30:42 +01001752
Pali Rohára9812202020-11-24 15:38:08 +01001753${FIPTOOL}: FORCE
Manish V Badarkhe40469bf2024-10-03 20:50:04 +01001754 $(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 +00001755
Manish V Badarkhee4a070e2024-12-03 21:46:51 +00001756$(BUILD_PLAT)/romlib/romlib.bin $(BUILD_PLAT)/lib/libwrappers.a $&: $(BUILD_PLAT)/lib/libfdt.a $(BUILD_PLAT)/lib/libc.a $(CRYPTO_LIB)
1757 $(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 Vargas5accce52018-05-22 16:05:42 +01001758
Louis Mayencourtcfe83912019-10-16 14:30:51 +01001759memmap: all
Chris Kayed0c8012025-01-28 18:04:11 +00001760 $(q)$(if $(host-poetry),poetry run )memory -sr ${BUILD_PLAT}
Louis Mayencourtcfe83912019-10-16 14:30:51 +01001761
Harrison Mutai2329e222024-08-28 13:27:19 +00001762tl: ${BUILD_PLAT}/tl.bin
1763${BUILD_PLAT}/tl.bin: ${HW_CONFIG}
Chris Kayd2867392024-09-26 14:18:04 +00001764 $(if $(host-poetry),$(q)poetry -q install)
1765 $(q)$(if $(host-poetry),poetry run )tlc create --fdt $< -s ${FW_HANDOFF_SIZE} $@
Harrison Mutai2329e222024-08-28 13:27:19 +00001766
Madhukar Pappireddy6de32372020-01-28 12:41:20 -06001767doc:
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001768 $(s)echo " BUILD DOCUMENTATION"
1769 $(q)${MAKE} --no-print-directory -C ${DOCS_PATH} html
Madhukar Pappireddy6de32372020-01-28 12:41:20 -06001770
Sumit Garg90aa9012019-11-11 18:46:36 +05301771enctool: ${ENCTOOL}
1772
Pali Rohára9812202020-11-24 15:38:08 +01001773${ENCTOOL}: FORCE
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001774 $(q)${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} --no-print-directory -C ${ENCTOOLPATH} all
1775 $(s)echo
1776 $(s)echo "Built $@ successfully"
1777 $(s)echo
Sumit Garg90aa9012019-11-11 18:46:36 +05301778
Joakim Bech35fab8c2014-01-23 14:51:49 +01001779cscope:
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001780 $(s)echo " CSCOPE"
1781 $(q)find ${CURDIR} -name "*.[chsS]" > cscope.files
1782 $(q)cscope -b -q -k
Joakim Bech35fab8c2014-01-23 14:51:49 +01001783
Ryan Harkin72ee3312014-01-15 16:55:07 +00001784help:
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001785 $(s)echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
1786 $(s)echo ""
1787 $(s)echo "PLAT is used to specify which platform you wish to build."
1788 $(s)echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
1789 $(s)echo ""
1790 $(s)echo "platform = ${PLATFORM_LIST}"
1791 $(s)echo ""
1792 $(s)echo "Please refer to the User Guide for a list of all supported options."
1793 $(s)echo "Note that the build system doesn't track dependencies for build "
1794 $(s)echo "options. Therefore, if any of the build options are changed "
1795 $(s)echo "from a previous build, a clean build must be performed."
1796 $(s)echo ""
1797 $(s)echo "Supported Targets:"
1798 $(s)echo " all Build all individual bootloader binaries"
1799 $(s)echo " bl1 Build the BL1 binary"
1800 $(s)echo " bl2 Build the BL2 binary"
1801 $(s)echo " bl2u Build the BL2U binary"
1802 $(s)echo " bl31 Build the BL31 binary"
1803 $(s)echo " bl32 Build the BL32 binary. If ARCH=aarch32, then "
1804 $(s)echo " this builds secure payload specified by AARCH32_SP"
1805 $(s)echo " certificates Build the certificates (requires 'GENERATE_COT=1')"
1806 $(s)echo " fip Build the Firmware Image Package (FIP)"
1807 $(s)echo " fwu_fip Build the FWU Firmware Image Package (FIP)"
1808 $(s)echo " checkcodebase Check the coding style of the entire source tree"
1809 $(s)echo " checkpatch Check the coding style on changes in the current"
1810 $(s)echo " branch against BASE_COMMIT (default origin/master)"
1811 $(s)echo " clean Clean the build for the selected platform"
1812 $(s)echo " cscope Generate cscope index"
1813 $(s)echo " distclean Remove all build artifacts for all platforms"
1814 $(s)echo " certtool Build the Certificate generation tool"
1815 $(s)echo " enctool Build the Firmware encryption tool"
1816 $(s)echo " fiptool Build the Firmware Image Package (FIP) creation tool"
1817 $(s)echo " sp Build the Secure Partition Packages"
1818 $(s)echo " sptool Build the Secure Partition Package creation tool"
1819 $(s)echo " dtbs Build the Device Tree Blobs (if required for the platform)"
1820 $(s)echo " memmap Print the memory map of the built binaries"
1821 $(s)echo " doc Build html based documentation using Sphinx tool"
1822 $(s)echo ""
1823 $(s)echo "Note: most build targets require PLAT to be set to a specific platform."
1824 $(s)echo ""
1825 $(s)echo "example: build all targets for the FVP platform:"
1826 $(s)echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
Pali Rohára9812202020-11-24 15:38:08 +01001827
1828.PHONY: FORCE
1829FORCE:;