blob: cd763db3fb197f7576bb8a9335446dcd8e0d0125 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001#
Chris Kayfaab7482025-01-13 15:57:32 +00002# Copyright (c) 2013-2025, Arm Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003#
dp-armfa3cf0b2017-05-03 09:38:09 +01004# SPDX-License-Identifier: BSD-3-Clause
Achin Gupta4f6ad662013-10-25 09:08:21 +01005#
6
Jeenu Viswambharan19a0ace2014-05-15 14:40:58 +01007#
Juan Castillo04be3a52014-06-30 11:41:46 +01008# Trusted Firmware Version
9#
Soby Mathewd42eaee2018-10-01 16:16:34 +010010VERSION_MAJOR := 2
Govindraj Rajacf5f9802024-11-15 09:56:50 +010011VERSION_MINOR := 12
Yann Gautier5f4cbed2024-02-08 18:40:27 +010012# VERSION_PATCH is only used for LTS releases
13VERSION_PATCH := 0
Yann Gautier57078a92023-10-03 11:09:07 +020014VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
Juan Castillo04be3a52014-06-30 11:41:46 +010015
Juan Castillo396644b2015-10-22 11:34:44 +010016# Default goal is build all images
17.DEFAULT_GOAL := all
18
Douglas Raillard527cd902016-12-28 14:47:50 +000019# Avoid any implicit propagation of command line variable definitions to
20# sub-Makefiles, like CFLAGS that we reserved for the firmware images'
21# usage. Other command line options like "-s" are still propagated as usual.
22MAKEOVERRIDES =
23
Evan Lloydf2697142015-12-02 18:17:37 +000024MAKE_HELPERS_DIRECTORY := make_helpers/
25include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
Chris Kay1559f642024-06-04 00:04:48 +000026include ${MAKE_HELPERS_DIRECTORY}build-rules.mk
Chris Kay1870c722024-05-02 17:52:37 +000027include ${MAKE_HELPERS_DIRECTORY}common.mk
Juan Castilloa3487d12015-08-18 14:23:04 +010028
29################################################################################
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010030# Default values for build configurations, and their dependencies
Juan Castilloa3487d12015-08-18 14:23:04 +010031################################################################################
Jeenu Viswambharan19a0ace2014-05-15 14:40:58 +010032
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010033include ${MAKE_HELPERS_DIRECTORY}defaults.mk
Yann Gautier05f92a32025-01-17 11:02:50 +010034PLAT := ${DEFAULT_PLAT}
Andrey Skvortsov89c3a142024-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-arm3cac7862016-09-19 11:18:44 +010041
Chris Kayc8a47ba2023-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 Diaz808c2292017-04-18 15:16:05 +010048# Assertions enabled for DEBUG builds by default
Antonio Nino Diaz808c2292017-04-18 15:16:05 +010049ENABLE_ASSERTIONS := ${DEBUG}
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010050ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION}
Achin Gupta4f6ad662013-10-25 09:08:21 +010051
Juan Castilloa3487d12015-08-18 14:23:04 +010052################################################################################
53# Checkpatch script options
54################################################################################
55
Sandrine Bailleux0b5a1582016-06-02 11:19:59 +010056CHECKCODE_ARGS := --no-patch
Dan Handleyd7b59e42016-06-02 17:15:13 +010057# Do not check the coding style on imported library files or documentation files
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030058INC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \
59 include/drivers/arm, \
60 $(wildcard include/drivers/*)))
Dan Handleyd7b59e42016-06-02 17:15:13 +010061INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \
Dan Handley3a355712016-06-02 18:21:02 +010062 include/lib/libfdt \
Roberto Vargas0f8f9852018-05-08 10:27:10 +010063 include/lib/libc, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010064 $(wildcard include/lib/*)))
65INC_DIRS_TO_CHECK := $(sort $(filter-out \
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030066 include/lib \
67 include/drivers, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010068 $(wildcard include/*)))
69LIB_DIRS_TO_CHECK := $(sort $(filter-out \
dp-arme3cc8382017-05-04 12:15:35 +010070 lib/compiler-rt \
Antonio Nino Diazd84f88e2017-01-16 17:20:45 +000071 lib/libfdt% \
Roberto Vargas0f8f9852018-05-08 10:27:10 +010072 lib/libc, \
Daniel Boulby958f1dd2022-10-05 11:05:22 +010073 lib/zlib \
Dan Handleyd7b59e42016-06-02 17:15:13 +010074 $(wildcard lib/*)))
75ROOT_DIRS_TO_CHECK := $(sort $(filter-out \
76 lib \
77 include \
78 docs \
Paul Beesleyadfab5b2019-03-07 16:42:31 +000079 %.rst, \
Dan Handleyd7b59e42016-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-Yossef033327a2019-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 Castilloa3487d12015-08-18 14:23:04 +010088################################################################################
89# Process build options
90################################################################################
91
Chris Kay1870c722024-05-02 17:52:37 +000092ifeq ($(verbose),)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +010093 CHECKCODE_ARGS += --no-summary --terse
Achin Gupta4f6ad662013-10-25 09:08:21 +010094endif
Andre Przywaracf2bb082018-09-27 10:56:05 +010095
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +010096################################################################################
Jayanth Dodderi Chidanand2ee5d402023-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 Kayfaab7482025-01-13 15:57:32 +0000102CRTTOOL ?= ${CRTTOOLPATH}/cert_create$(.exe)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100103
104# Variables for use with Firmware Encryption Tool
105ENCTOOLPATH ?= tools/encrypt_fw
Chris Kayfaab7482025-01-13 15:57:32 +0000106ENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw$(.exe)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100107
108# Variables for use with Firmware Image Package
109FIPTOOLPATH ?= tools/fiptool
Chris Kayfaab7482025-01-13 15:57:32 +0000110FIPTOOL ?= ${FIPTOOLPATH}/fiptool$(.exe)
Jayanth Dodderi Chidanand2ee5d402023-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 Meakinaba46182023-02-14 11:56:02 +0000116SP_DTS_LIST_FRAGMENT ?= ${BUILD_PLAT}/sp_list_fragment.dts
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100117
118# Variables for use with ROMLIB
119ROMLIBPATH ?= lib/romlib
120
121# Variable for use with Python
122PYTHON ?= python3
123
124# Variables for use with documentation build using Sphinx tool
125DOCS_PATH ?= docs
126
127################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100128# Compiler Configuration based on ARCH_MAJOR and ARCH_MINOR flags
Juan Castilloa3487d12015-08-18 14:23:04 +0100129################################################################################
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100130ifeq (${ARM_ARCH_MAJOR},7)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100131 target32-directive = -target arm-none-eabi
Govindraj Rajacd10c6e2023-05-30 16:52:15 -0500132# Will set march-directive from platform configuration
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100133else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100134 target32-directive = -target armv8a-none-eabi
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100135endif #(ARM_ARCH_MAJOR)
136
137################################################################################
138# Get Architecture Feature Modifiers
139################################################################################
140arch-features = ${ARM_ARCH_FEATURE}
141
Chris Kaycfba6452023-12-04 09:55:50 +0000142ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
143 ifeq ($($(ARCH)-cc-id),arm-clang)
Govindraj Raja69096412023-06-01 16:29:16 -0500144 TF_CFLAGS_aarch32 := -target arm-arm-none-eabi
145 TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi
originfba80d82022-01-19 16:30:14 +0000146 else
Govindraj Raja69096412023-06-01 16:29:16 -0500147 TF_CFLAGS_aarch32 = $(target32-directive)
148 TF_CFLAGS_aarch64 := -target aarch64-elf
originfba80d82022-01-19 16:30:14 +0000149 endif
150
Chris Kaycfba6452023-12-04 09:55:50 +0000151else ifeq ($($(ARCH)-cc-id),gnu-gcc)
Chris Kay00416dc2024-02-20 16:19:54 +0000152 # Enable LTO only for aarch64
153 ifeq (${ARCH},aarch64)
154 LTO_CFLAGS = $(if $(filter-out 0,$(ENABLE_LTO)),-flto)
zelalem-aweked5f45272019-11-12 16:20:17 -0600155 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100156endif #(clang)
dp-arm320e8442017-05-02 12:00:08 +0100157
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100158# Process Debug flag
159$(eval $(call add_define,DEBUG))
160ifneq (${DEBUG}, 0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100161 BUILD_TYPE := debug
162 TF_CFLAGS += -g -gdwarf-4
163 ASFLAGS += -g -Wa,-gdwarf-4
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100164
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100165 # Use LOG_LEVEL_INFO by default for debug builds
166 LOG_LEVEL := 40
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100167else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100168 BUILD_TYPE := release
169 # Use LOG_LEVEL_NOTICE by default for release builds
170 LOG_LEVEL := 20
171endif #(Debug)
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100172
Peiyuan Song44f8f472020-04-25 16:53:43 +0800173# Default build string (git branch and commit)
174ifeq (${BUILD_STRING},)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100175 BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null)
Peiyuan Song44f8f472020-04-25 16:53:43 +0800176endif
laurenw-arme954f652022-07-12 10:12:05 -0500177VERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
Peiyuan Song44f8f472020-04-25 16:53:43 +0800178
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100179ifeq (${AARCH32_INSTRUCTION_SET},A32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100180 TF_CFLAGS_aarch32 += -marm
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100181else ifeq (${AARCH32_INSTRUCTION_SET},T32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100182 TF_CFLAGS_aarch32 += -mthumb
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100183else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100184 $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
185endif #(AARCH32_INSTRUCTION_SET)
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100186
Sandrine Bailleux1aa72ec2018-07-03 09:14:45 +0200187TF_CFLAGS_aarch32 += -mno-unaligned-access
dp-arm320e8442017-05-02 12:00:08 +0100188TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align
Soby Mathewa1941252016-05-05 14:33:33 +0100189
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100190##############################################################################
191# WARNINGS Configuration
192###############################################################################
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100193# General warnings
194WARNINGS := -Wall -Wmissing-include-dirs -Wunused \
Yann Gautier94a40b62021-05-20 13:18:14 +0200195 -Wdisabled-optimization -Wvla -Wshadow \
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000196 -Wredundant-decls
197# stricter warnings
198WARNINGS += -Wextra -Wno-trigraphs
199# too verbose for generic build
200WARNINGS += -Wno-missing-field-initializers \
201 -Wno-type-limits -Wno-sign-compare \
202# on clang this flag gets reset if -Wextra is set after it. No difference on gcc
203WARNINGS += -Wno-unused-parameter
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100204
205# Additional warnings
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000206# Level 1 - infrequent warnings we should have none of
207# full -Wextra
208WARNING1 += -Wsign-compare
209WARNING1 += -Wtype-limits
210WARNING1 += -Wmissing-field-initializers
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100211
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000212# Level 2 - problematic warnings that we want
213# zlib, compiler-rt, coreboot, and mbdedtls blow up with these
214# TODO: disable just for them and move into default build
215WARNING2 += -Wold-style-definition
216WARNING2 += -Wmissing-prototypes
217WARNING2 += -Wmissing-format-attribute
218# TF-A aims to comply with this eventually. Effort too large at present
219WARNING2 += -Wundef
Boyan Karatotev9c6ba592022-11-21 14:49:05 +0000220# currently very involved and many platforms set this off
221WARNING2 += -Wunused-const-variable=2
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100222
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000223# Level 3 - very pedantic, frequently ignored
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100224WARNING3 := -Wbad-function-cast
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000225WARNING3 += -Waggregate-return
226WARNING3 += -Wnested-externs
227WARNING3 += -Wcast-align
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100228WARNING3 += -Wcast-qual
229WARNING3 += -Wconversion
230WARNING3 += -Wpacked
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100231WARNING3 += -Wpointer-arith
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100232WARNING3 += -Wswitch-default
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100233
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000234# Setting W is quite verbose and most warnings will be pre-existing issues
235# outside of the contributor's control. Don't fail the build on them so warnings
236# can be seen and hopefully addressed
237ifdef W
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100238 ifneq (${W},0)
239 E ?= 0
240 endif
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000241endif
242
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100243ifeq (${W},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100244 WARNINGS += $(WARNING1)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100245else ifeq (${W},2)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100246 WARNINGS += $(WARNING1) $(WARNING2)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100247else ifeq (${W},3)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100248 WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
249endif #(W)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100250
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100251# Compiler specific warnings
Chris Kaycfba6452023-12-04 09:55:50 +0000252ifeq ($(filter %-clang,$($(ARCH)-cc-id)),)
Justin Chadwell7a914232019-07-03 14:15:56 +0100253# not using clang
Justin Chadwell42d18ca2019-09-18 14:13:42 +0100254WARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \
255 -Wpacked-bitfield-compat -Wshift-overflow=2 \
256 -Wlogical-op
Govindraj Rajaaa8ef3f2023-05-05 09:09:36 -0500257
258# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
Boyan Karatoteve9f127f2024-10-10 13:54:37 +0100259TF_CFLAGS_MIN_PAGE_SIZE := $(call cc_option, --param=min-pagesize=0)
260TF_CFLAGS += $(TF_CFLAGS_MIN_PAGE_SIZE)
Govindraj Rajaaa8ef3f2023-05-05 09:09:36 -0500261
Bipin Ravie53e6ae2023-09-28 13:17:24 -0500262ifeq ($(HARDEN_SLS), 1)
Boyan Karatoteve9f127f2024-10-10 13:54:37 +0100263 TF_CFLAGS_MHARDEN_SLS := $(call cc_option, -mharden-sls=all)
264 TF_CFLAGS_aarch64 += $(TF_CFLAGS_MHARDEN_SLS)
Bipin Ravie53e6ae2023-09-28 13:17:24 -0500265endif
266
Justin Chadwell7a914232019-07-03 14:15:56 +0100267else
268# using clang
Justin Chadwell42d18ca2019-09-18 14:13:42 +0100269WARNINGS += -Wshift-overflow -Wshift-sign-overflow \
270 -Wlogical-op-parentheses
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100271endif #(Clang Warning)
Ambroise Vincent067e4d92019-05-24 12:47:43 +0100272
Yann Gautier957c3532018-12-10 18:08:53 +0100273ifneq (${E},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100274 ERRORS := -Werror
275endif #(E)
Yann Gautier957c3532018-12-10 18:08:53 +0100276
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100277################################################################################
278# Compiler and Linker Directives
279################################################################################
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100280CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
281 $(ERRORS) $(WARNINGS)
Govindraj Rajacd10c6e2023-05-30 16:52:15 -0500282ASFLAGS += $(CPPFLAGS) \
Julius Werner53456fc2019-07-09 13:49:11 -0700283 -ffreestanding -Wa,--fatal-warnings
Masahiro Yamada0dec9fa2016-12-22 12:51:53 +0900284TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \
Samuel Holland23f5e542019-10-20 16:11:25 -0500285 -ffunction-sections -fdata-sections \
Boyan Karatoteva353fbf2024-12-09 08:24:12 +0000286 -ffreestanding -fno-common \
Samuel Holland23f5e542019-10-20 16:11:25 -0500287 -Os -std=gnu99
Juan Castilloa3487d12015-08-18 14:23:04 +0100288
Justin Chadwell83e04882019-08-20 11:01:52 +0100289ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100290 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover
291endif #(${SANITIZE_UB},on)
292
Justin Chadwell83e04882019-08-20 11:01:52 +0100293ifeq (${SANITIZE_UB},trap)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100294 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \
Justin Chadwell83e04882019-08-20 11:01:52 +0100295 -fsanitize-undefined-trap-on-error
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100296endif #(${SANITIZE_UB},trap)
Justin Chadwell83e04882019-08-20 11:01:52 +0100297
Chris Kay0adde4e2024-05-14 13:08:31 +0000298GCC_V_OUTPUT := $(if $($(ARCH)-cc),$(shell $($(ARCH)-cc) -v 2>&1))
david cunado34ab6092017-11-30 21:58:01 +0000299
Marco Felsch24ad8402022-11-09 12:59:09 +0100300TF_LDFLAGS += -z noexecstack
301
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100302# LD = armlink
Chris Kaycfba6452023-12-04 09:55:50 +0000303ifeq ($($(ARCH)-ld-id),arm-link)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100304 TF_LDFLAGS += --diag_error=warning --lto_level=O1
305 TF_LDFLAGS += --remove --info=unused,unusedsymbols
306 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100307
308# LD = gcc (used when GCC LTO is enabled)
Chris Kaycfba6452023-12-04 09:55:50 +0000309else ifeq ($($(ARCH)-ld-id),gnu-gcc)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100310 # Pass ld options with Wl or Xlinker switches
Chris Kayb0fe96f2024-01-16 11:53:35 +0000311 TF_LDFLAGS += $(call ld_option,-Xlinker --no-warn-rwx-segments)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100312 TF_LDFLAGS += -Wl,--fatal-warnings -O1
313 TF_LDFLAGS += -Wl,--gc-sections
Chris Kay73b1f402022-12-22 13:26:37 +0000314
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100315 TF_LDFLAGS += -Wl,-z,common-page-size=4096 #Configure page size constants
316 TF_LDFLAGS += -Wl,-z,max-page-size=4096
Andrey Skvortsove2ebb722023-09-05 23:06:29 +0300317 TF_LDFLAGS += -Wl,--build-id=none
Chris Kay73b1f402022-12-22 13:26:37 +0000318
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100319 ifeq ($(ENABLE_LTO),1)
320 ifeq (${ARCH},aarch64)
321 TF_LDFLAGS += -flto -fuse-linker-plugin
Andrey Skvortsov664d6502023-12-08 18:04:51 +0300322 TF_LDFLAGS += -flto-partition=one
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100323 endif
324 endif #(ENABLE_LTO)
325
zelalem-aweked5f45272019-11-12 16:20:17 -0600326# GCC automatically adds fix-cortex-a53-843419 flag when used to link
327# which breaks some builds, so disable if errata fix is not explicitly enabled
Yann Gautier3d73d162023-03-15 16:18:16 +0100328 ifeq (${ARCH},aarch64)
329 ifneq (${ERRATA_A53_843419},1)
330 TF_LDFLAGS += -mno-fix-cortex-a53-843419
331 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100332 endif
333 TF_LDFLAGS += -nostdlib
334 TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100335
336# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
Varun Wadekar4d034c52019-01-11 14:47:48 -0800337else
Marco Felsch24ad8402022-11-09 12:59:09 +0100338# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
339# are not loaded by a elf loader.
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100340 TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments)
341 TF_LDFLAGS += -O1
342 TF_LDFLAGS += --gc-sections
Chris Kay73b1f402022-12-22 13:26:37 +0000343
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100344 TF_LDFLAGS += -z common-page-size=4096 # Configure page size constants
345 TF_LDFLAGS += -z max-page-size=4096
Andrey Skvortsove2ebb722023-09-05 23:06:29 +0300346 TF_LDFLAGS += --build-id=none
Chris Kay73b1f402022-12-22 13:26:37 +0000347
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100348# ld.lld doesn't recognize the errata flags,
Yabin Cuied7dc512023-01-19 20:06:04 +0000349# therefore don't add those in that case.
350# ld.lld reports section type mismatch warnings,
351# therefore don't add --fatal-warnings to it.
Chris Kaycfba6452023-12-04 09:55:50 +0000352 ifneq ($($(ARCH)-ld-id),llvm-lld)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100353 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) --fatal-warnings
354 endif
355
356endif #(LD = armlink)
Juan Castilloa3487d12015-08-18 14:23:04 +0100357
358################################################################################
Govindraj Raja0386e312023-08-17 10:41:48 -0500359# Setup ARCH_MAJOR/MINOR before parsing arch_features.
360################################################################################
361ifeq (${ENABLE_RME},1)
AlexeiFedorov65258452024-03-13 11:53:44 +0000362 ARM_ARCH_MAJOR := 9
363 ARM_ARCH_MINOR := 2
Govindraj Raja0386e312023-08-17 10:41:48 -0500364endif
365
366################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +0100367# Common sources and include directories
368################################################################################
dp-arme3cc8382017-05-04 12:15:35 +0100369include lib/compiler-rt/compiler-rt.mk
Juan Castilloa3487d12015-08-18 14:23:04 +0100370
Chris Kay99b5b2e2024-03-08 16:08:31 +0000371# Allow overriding the timestamp, for example for reproducible builds, or to
372# synchronize timestamps across multiple projects.
373# This must be set to a C string (including quotes where applicable).
374BUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__
375
376DEFINES += -DBUILD_MESSAGE_TIMESTAMP='$(BUILD_MESSAGE_TIMESTAMP)'
377DEFINES += -DBUILD_MESSAGE_VERSION_STRING='"$(VERSION_STRING)"'
378DEFINES += -DBUILD_MESSAGE_VERSION='"$(VERSION)"'
379
Juan Castilloa3487d12015-08-18 14:23:04 +0100380BL_COMMON_SOURCES += common/bl_common.c \
Soby Mathewaaf15f52017-09-04 11:49:29 +0100381 common/tf_log.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100382 common/${ARCH}/debug.S \
Julius Werner03020da2018-11-27 22:10:56 -0800383 drivers/console/multi_console.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100384 lib/${ARCH}/cache_helpers.S \
385 lib/${ARCH}/misc_helpers.S \
Boyan Karatotev05504ba2023-02-15 13:21:50 +0000386 lib/extensions/pmuv3/${ARCH}/pmuv3.c \
Soby Mathew2f38ce32018-02-08 17:45:12 +0000387 plat/common/plat_bl_common.c \
Soby Mathewaaf15f52017-09-04 11:49:29 +0100388 plat/common/plat_log_common.c \
dp-arm230011c2017-03-07 11:02:47 +0000389 plat/common/${ARCH}/plat_common.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100390 plat/common/${ARCH}/platform_helpers.S \
Roberto Vargas0f8f9852018-05-08 10:27:10 +0100391 ${COMPILER_RT_SRCS}
Ryan Harkind7a6b0f2014-01-13 14:40:13 +0000392
Chris Kaycfba6452023-12-04 09:55:50 +0000393ifeq ($($(ARCH)-cc-id),arm-clang)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100394 BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S
Antonio Nino Diazeea20fc2018-08-16 15:42:44 +0100395endif
396
Justin Chadwell83e04882019-08-20 11:01:52 +0100397ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100398 BL_COMMON_SOURCES += plat/common/ubsan.c
Justin Chadwell83e04882019-08-20 11:01:52 +0100399endif
400
Yann Gautier2cf1dbc2018-06-18 16:00:23 +0200401INCLUDES += -Iinclude \
Antonio Nino Diaz8d1ade62018-12-17 17:20:57 +0000402 -Iinclude/arch/${ARCH} \
Antonio Nino Diaze0f90632018-12-14 00:18:21 +0000403 -Iinclude/lib/cpus/${ARCH} \
404 -Iinclude/lib/el3_runtime/${ARCH} \
405 ${PLAT_INCLUDES} \
406 ${SPD_INCLUDES}
407
Nishant Sharma331b5682022-08-15 16:37:07 +0100408DTC_FLAGS += -I dts -O dtb
409DTC_CPPFLAGS += -P -nostdinc $(INCLUDES) -Ifdts -undef \
410 -x assembler-with-cpp $(DEFINES)
411
Antonio Nino Diazc3a2cf22018-11-19 11:48:30 +0000412include common/backtrace/backtrace.mk
413
Juan Castilloa3487d12015-08-18 14:23:04 +0100414################################################################################
Govindraj Raja1a211292023-09-20 14:32:24 -0500415# Generic definitions
416################################################################################
Govindraj Raja1a211292023-09-20 14:32:24 -0500417
418ifeq (${BUILD_BASE},)
419 BUILD_BASE := ./build
420endif
421BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
422
423SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
424
425# Platforms providing their own TBB makefile may override this value
426INCLUDE_TBBR_MK := 1
427
428################################################################################
429# Include SPD Makefile if one has been specified
430################################################################################
431
432ifneq (${SPD},none)
433 ifeq (${ARCH},aarch32)
434 $(error "Error: SPD is incompatible with AArch32.")
435 endif
436
437 ifdef EL3_PAYLOAD_BASE
438 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
439 $(warning "The SPD and its BL32 companion will be present but \
440 ignored.")
441 endif
442
443 ifeq (${SPD},spmd)
444 # SPMD is located in std_svc directory
445 SPD_DIR := std_svc
446
447 ifeq ($(SPMD_SPM_AT_SEL2),1)
448 CTX_INCLUDE_EL2_REGS := 1
449 ifeq ($(SPMC_AT_EL3),1)
450 $(error SPM cannot be enabled in both S-EL2 and EL3.)
451 endif
Madhukar Pappireddy7503cdc2024-04-25 23:01:00 -0500452 ifeq ($(CTX_INCLUDE_SVE_REGS),1)
453 $(error SVE context management not needed with Hafnium SPMC.)
454 endif
Govindraj Raja1a211292023-09-20 14:32:24 -0500455 endif
456
457 ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
458 DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG
459 endif
460
Arunachalam Ganapathyfd29d582022-04-11 14:36:54 +0100461 ifeq ($(findstring trusty_sp,$(ARM_SPMC_MANIFEST_DTS)),trusty_sp)
462 DTC_CPPFLAGS += -DTRUSTY_SP_FW_CONFIG
463 endif
464
Govindraj Raja1a211292023-09-20 14:32:24 -0500465 ifeq ($(TS_SP_FW_CONFIG),1)
Arunachalam Ganapathyfd29d582022-04-11 14:36:54 +0100466 DTC_CPPFLAGS += -DTS_SP_FW_CONFIG
Govindraj Raja1a211292023-09-20 14:32:24 -0500467 endif
468
469 ifneq ($(ARM_BL2_SP_LIST_DTS),)
470 DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
471 endif
472
473 ifneq ($(SP_LAYOUT_FILE),)
474 BL2_ENABLE_SP_LOAD := 1
475 endif
Govindraj Rajabad835a2023-10-31 14:48:11 -0500476
477 ifeq ($(SPMC_AT_EL3_SEL0_SP),1)
478 ifneq ($(SPMC_AT_EL3),1)
479 $(error SEL0 SP cannot be enabled without SPMC at EL3)
480 endif
481 endif
Govindraj Raja1a211292023-09-20 14:32:24 -0500482 else
483 # All other SPDs in spd directory
484 SPD_DIR := spd
485 endif #(SPD)
486
487 # We expect to locate an spd.mk under the specified SPD directory
488 SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
489
490 ifeq (${SPD_MAKE},)
491 $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
492 endif
493 $(info Including ${SPD_MAKE})
494 include ${SPD_MAKE}
495
496 # If there's BL32 companion for the chosen SPD, we expect that the SPD's
497 # Makefile would set NEED_BL32 to "yes". In this case, the build system
498 # supports two mutually exclusive options:
499 # * BL32 is built from source: then BL32_SOURCES must contain the list
500 # of source files to build BL32
501 # * BL32 is a prebuilt binary: then BL32 must point to the image file
502 # that will be included in the FIP
503 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
504 # over the sources.
505endif #(SPD=none)
506
507ifeq (${ENABLE_SPMD_LP}, 1)
508ifneq (${SPD},spmd)
509 $(error Error: ENABLE_SPMD_LP requires SPD=spmd.)
510endif
511ifeq ($(SPMC_AT_EL3),1)
512 $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.)
513endif
514endif
515
516################################################################################
Olivier Deprez4b467722025-01-03 13:38:50 +0100517# Include the platform specific Makefile after the SPD Makefile (the platform
518# makefile may use all previous definitions in this file)
519################################################################################
520include ${PLAT_MAKEFILE_FULL}
521
522################################################################################
Govindraj Raja0386e312023-08-17 10:41:48 -0500523# Process BRANCH_PROTECTION value and set
524# Pointer Authentication and Branch Target Identification flags
525################################################################################
526ifeq (${BRANCH_PROTECTION},0)
527 # Default value turns off all types of branch protection
528 BP_OPTION := none
529else ifneq (${ARCH},aarch64)
530 $(error BRANCH_PROTECTION requires AArch64)
531else ifeq (${BRANCH_PROTECTION},1)
532 # Enables all types of branch protection features
533 BP_OPTION := standard
534 ENABLE_BTI := 1
535 ENABLE_PAUTH := 1
536else ifeq (${BRANCH_PROTECTION},2)
537 # Return address signing to its standard level
538 BP_OPTION := pac-ret
539 ENABLE_PAUTH := 1
540else ifeq (${BRANCH_PROTECTION},3)
541 # Extend the signing to include leaf functions
542 BP_OPTION := pac-ret+leaf
543 ENABLE_PAUTH := 1
544else ifeq (${BRANCH_PROTECTION},4)
545 # Turn on branch target identification mechanism
546 BP_OPTION := bti
547 ENABLE_BTI := 1
548else
549 $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
550endif #(BRANCH_PROTECTION)
551
552ifeq ($(ENABLE_PAUTH),1)
553 CTX_INCLUDE_PAUTH_REGS := 1
554endif
555ifneq (${BP_OPTION},none)
556 TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION}
557endif #(BP_OPTION)
558
559# Pointer Authentication sources
560ifeq (${ENABLE_PAUTH}, 1)
561# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the
562# Pauth support. As it's not secure, it must be reimplemented for real platforms
563 BL_COMMON_SOURCES += lib/extensions/pauth/pauth_helpers.S
564endif
565
Govindraj Raja1a211292023-09-20 14:32:24 -0500566################################################################################
Govindraj Raja1a211292023-09-20 14:32:24 -0500567# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from
568# platform.
569################################################################################
570include ${MAKE_HELPERS_DIRECTORY}arch_features.mk
571
Govindraj Raja0386e312023-08-17 10:41:48 -0500572####################################################
573# Enable required options for Memory Stack Tagging.
574####################################################
575
576# Currently, these options are enabled only for clang and armclang compiler.
577ifeq (${SUPPORT_STACK_MEMTAG},yes)
578 ifdef mem_tag_arch_support
579 # Check for armclang and clang compilers
Chris Kaycfba6452023-12-04 09:55:50 +0000580 ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
Govindraj Raja0386e312023-08-17 10:41:48 -0500581 # Add "memtag" architecture feature modifier if not specified
582 ifeq ( ,$(findstring memtag,$(arch-features)))
583 arch-features := $(arch-features)+memtag
584 endif # memtag
Chris Kaycfba6452023-12-04 09:55:50 +0000585 ifeq ($($(ARCH)-cc-id),arm-clang)
Govindraj Raja0386e312023-08-17 10:41:48 -0500586 TF_CFLAGS += -mmemtag-stack
Chris Kaycfba6452023-12-04 09:55:50 +0000587 else ifeq ($($(ARCH)-cc-id),llvm-clang)
Govindraj Raja0386e312023-08-17 10:41:48 -0500588 TF_CFLAGS += -fsanitize=memtag
589 endif # armclang
590 endif
591 else
592 $(error "Error: stack memory tagging is not supported for \
593 architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
594 endif #(mem_tag_arch_support)
595endif #(SUPPORT_STACK_MEMTAG)
596
597################################################################################
598# RME dependent flags configuration, Enable optional features for RME.
599################################################################################
600# FEAT_RME
601ifeq (${ENABLE_RME},1)
Govindraj Raja0386e312023-08-17 10:41:48 -0500602 # RME requires AARCH64
603 ifneq (${ARCH},aarch64)
604 $(error ENABLE_RME requires AArch64)
605 endif
606
607 # RME requires el2 context to be saved for now.
608 CTX_INCLUDE_EL2_REGS := 1
609 CTX_INCLUDE_AARCH32_REGS := 0
610 CTX_INCLUDE_PAUTH_REGS := 1
611
612 # RME enables CSV2_2 extension by default.
613 ENABLE_FEAT_CSV2_2 = 1
614endif #(FEAT_RME)
615
616################################################################################
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500617# Include rmmd Makefile if RME is enabled
618################################################################################
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500619ifneq (${ENABLE_RME},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100620 ifneq (${ARCH},aarch64)
621 $(error ENABLE_RME requires AArch64)
622 endif
623 ifeq ($(SPMC_AT_EL3),1)
624 $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
625 endif
626
627 ifneq (${SPD}, none)
628 ifneq (${SPD}, spmd)
629 $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd)
630 endif
631 endif
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500632include services/std_svc/rmmd/rmmd.mk
633$(warning "RME is an experimental feature")
634endif
635
Govindraj Raja1a211292023-09-20 14:32:24 -0500636ifeq (${CTX_INCLUDE_EL2_REGS}, 1)
637 ifeq (${SPD},none)
638 ifeq (${ENABLE_RME},0)
639 $(error CTX_INCLUDE_EL2_REGS is available only when SPD \
640 or RME is enabled)
641 endif
642 endif
643endif
Jon Medhurst66573cb2014-02-13 15:19:28 +0000644
Govindraj Raja69096412023-06-01 16:29:16 -0500645################################################################################
Govindraj Rajae63794e2024-09-06 15:43:43 +0100646# Make 128-Bit sysreg read/writes availabe when FEAT_D128 is enabled.
647################################################################################
648ifneq (${ENABLE_FEAT_D128}, 0)
649 BL_COMMON_SOURCES += lib/extensions/sysreg128/sysreg128.S
650endif
651
652################################################################################
Govindraj Raja69096412023-06-01 16:29:16 -0500653# Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come
654# up with appropriate march values for compiler.
655################################################################################
656include ${MAKE_HELPERS_DIRECTORY}march.mk
657
658TF_CFLAGS += $(march-directive)
Govindraj Raja0c572472024-01-23 16:00:19 -0600659ASFLAGS += $(march-directive)
Govindraj Raja69096412023-06-01 16:29:16 -0500660
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600661# This internal flag is common option which is set to 1 for scenarios
662# when the BL2 is running in EL3 level. This occurs in two scenarios -
663# 4 world system running BL2 at EL3 and two world system without BL1 running
664# BL2 in EL3
665
666ifeq (${RESET_TO_BL2},1)
667 BL2_RUNS_AT_EL3 := 1
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100668 ifeq (${ENABLE_RME},1)
669 $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \
670 supported at the moment.)
671 endif
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600672else ifeq (${ENABLE_RME},1)
673 BL2_RUNS_AT_EL3 := 1
674else
675 BL2_RUNS_AT_EL3 := 0
676endif
677
Manish Pandeyf90a73c2023-10-10 15:42:19 +0100678# This internal flag is set to 1 when Firmware First handling of External aborts
679# is required by lowe ELs. Currently only NS requires this support.
680ifeq ($(HANDLE_EA_EL3_FIRST_NS),1)
681 FFH_SUPPORT := 1
682else
683 FFH_SUPPORT := 0
684endif
685
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100686ifeq (${ARM_ARCH_MAJOR},7)
687include make_helpers/armv7-a-cpus.mk
688endif
689
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900690PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT})
691ifneq ($(PIE_FOUND),)
692 TF_CFLAGS += -fno-PIE
Chris Kaycfba6452023-12-04 09:55:50 +0000693ifeq ($($(ARCH)-ld-id),gnu-gcc)
Samuel Holland9286c022022-04-08 21:56:02 -0500694 TF_LDFLAGS += -no-pie
695endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100696endif #(PIE_FOUND)
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900697
Chris Kaycfba6452023-12-04 09:55:50 +0000698ifeq ($($(ARCH)-ld-id),gnu-gcc)
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900699 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
Soby Mathew078f1a42018-08-28 11:13:55 +0100700else
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900701 PIE_LDFLAGS += -pie --no-dynamic-linker
702endif
703
704ifeq ($(ENABLE_PIE),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100705 ifeq ($(RESET_TO_BL2),1)
706 ifneq ($(BL2_IN_XIP_MEM),1)
707 BL2_CPPFLAGS += -fpie
708 BL2_CFLAGS += -fpie
709 BL2_LDFLAGS += $(PIE_LDFLAGS)
710 endif #(BL2_IN_XIP_MEM)
711 endif #(RESET_TO_BL2)
Chris Kay13886c82023-02-02 14:39:03 +0000712 BL31_CPPFLAGS += -fpie
713 BL31_CFLAGS += -fpie
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900714 BL31_LDFLAGS += $(PIE_LDFLAGS)
Chris Kay13886c82023-02-02 14:39:03 +0000715
716 BL32_CPPFLAGS += -fpie
Masahiro Yamadade634f82020-01-17 13:45:14 +0900717 BL32_CFLAGS += -fpie
718 BL32_LDFLAGS += $(PIE_LDFLAGS)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100719endif #(ENABLE_PIE)
Soby Mathew078f1a42018-08-28 11:13:55 +0100720
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000721BL1_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
722BL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
723BL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
724
Masahiro Yamadaf1441572020-04-01 14:20:58 +0900725BL1_CPPFLAGS += -DIMAGE_AT_EL3
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600726ifeq ($(RESET_TO_BL2),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100727 BL2_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamada003dd762020-03-26 13:18:48 +0900728else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100729 BL2_CPPFLAGS += -DIMAGE_AT_EL1
730endif #(RESET_TO_BL2)
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000731
732ifeq (${ARCH},aarch64)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100733 BL2U_CPPFLAGS += -DIMAGE_AT_EL1
734 BL31_CPPFLAGS += -DIMAGE_AT_EL3
735 BL32_CPPFLAGS += -DIMAGE_AT_EL1
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000736else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100737 BL32_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamada003dd762020-03-26 13:18:48 +0900738endif
739
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000740# Include the CPU specific operations makefile, which provides default
741# values for all CPU errata workarounds and CPU specific optimisations.
742# This can be overridden by the platform.
Soby Mathew937488b2014-09-22 14:13:34 +0100743include lib/cpus/cpu-ops.mk
Soby Mathew802f8652014-08-14 16:19:29 +0100744
dp-armcdd03cb2017-02-15 11:07:55 +0000745################################################################################
746# Build `AARCH32_SP` as BL32 image for AArch32
747################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100748ifeq (${ARCH},aarch32)
749 NEED_BL32 := yes
dp-armcdd03cb2017-02-15 11:07:55 +0000750
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100751 ifneq (${AARCH32_SP},none)
752 # We expect to locate an sp.mk under the specified AARCH32_SP directory
753 AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
dp-armcdd03cb2017-02-15 11:07:55 +0000754
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100755 ifeq (${AARCH32_SP_MAKE},)
756 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
757 endif
Juan Pablo Conde6aba3b12023-08-09 13:19:21 -0500758 $(info Including ${AARCH32_SP_MAKE})
759 include ${AARCH32_SP_MAKE}
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100760 endif
761endif #(ARCH=aarch32)
Varun Wadekar3f9002c2019-01-31 09:22:30 -0800762
763################################################################################
764# Include libc if not overridden
765################################################################################
766ifeq (${OVERRIDE_LIBC},0)
767include lib/libc/libc.mk
dp-armcdd03cb2017-02-15 11:07:55 +0000768endif
Juan Castilloa3487d12015-08-18 14:23:04 +0100769
770################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100771# Check incompatible options and dependencies
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000772################################################################################
773
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100774# USE_DEBUGFS experimental feature recommended only in debug builds
775ifeq (${USE_DEBUGFS},1)
776 ifeq (${DEBUG},1)
777 $(warning DEBUGFS experimental feature is enabled.)
778 else
779 $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
Qixiang Xube9bd9d2017-08-24 11:03:23 +0800780 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100781endif #(USE_DEBUGFS)
782
783# USE_SPINLOCK_CAS requires AArch64 build
784ifeq (${USE_SPINLOCK_CAS},1)
785 ifneq (${ARCH},aarch64)
786 $(error USE_SPINLOCK_CAS requires AArch64)
Qixiang Xube9bd9d2017-08-24 11:03:23 +0800787 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100788endif #(USE_SPINLOCK_CAS)
789
790# The cert_create tool cannot generate certificates individually, so we use the
791# target 'certificates' to create them all
792ifneq (${GENERATE_COT},0)
793 FIP_DEPS += certificates
794 FWU_FIP_DEPS += fwu_certificates
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000795endif
796
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100797ifneq (${DECRYPTION_SUPPORT},none)
798 ENC_ARGS += -f ${FW_ENC_STATUS}
799 ENC_ARGS += -k ${ENC_KEY}
800 ENC_ARGS += -n ${ENC_NONCE}
801 FIP_DEPS += enctool
802 FWU_FIP_DEPS += enctool
803endif #(DECRYPTION_SUPPORT)
804
805ifdef EL3_PAYLOAD_BASE
806 ifdef PRELOADED_BL33_BASE
807 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
808 incompatible build options. EL3_PAYLOAD_BASE has priority.")
809 endif
810 ifneq (${GENERATE_COT},0)
811 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \
812 build options.")
813 endif
814 ifneq (${TRUSTED_BOARD_BOOT},0)
815 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \
816 incompatible \ build options.")
817 endif
818endif #(EL3_PAYLOAD_BASE)
819
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000820ifeq (${NEED_BL33},yes)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100821 ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000822 $(warning "BL33 image is not needed when option \
823 BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100824 endif
825 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz2b8277b2016-04-06 17:31:57 +0100826 $(warning "BL33 image is not needed when option \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100827 PRELOADED_BL33_BASE is used and won't be added to the FIP file.")
828 endif
829endif #(NEED_BL33)
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000830
Jeenu Viswambharan7ed2cbc2017-01-06 16:14:42 +0000831# When building for systems with hardware-assisted coherency, there's no need to
832# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
833ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100834 $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
Jeenu Viswambharan7ed2cbc2017-01-06 16:14:42 +0000835endif
Yatharth Kocharf528faf2016-06-28 16:58:26 +0100836
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600837#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1.
838ifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100839 $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled")
Jiafei Pan43a7bf42018-03-21 07:20:09 +0000840endif
841
Manish Pandeyd419e222023-02-13 12:39:17 +0000842# RAS_EXTENSION is deprecated, provide alternate build options
Jeenu Viswambharan9a7ce2f2018-04-04 16:07:11 +0100843ifeq ($(RAS_EXTENSION),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100844 $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +0100845 and HANDLE_EA_EL3_FIRST_NS instead")
Manish Pandeyd419e222023-02-13 12:39:17 +0000846endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100847
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100848
Manish Pandeyd419e222023-02-13 12:39:17 +0000849# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled
Jeenu Viswambharanf00da742017-12-08 12:13:51 +0000850ifeq ($(FAULT_INJECTION_SUPPORT),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100851 ifeq ($(ENABLE_FEAT_RAS),0)
852 $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0)
853 endif
854endif #(FAULT_INJECTION_SUPPORT)
Jeenu Viswambharanf00da742017-12-08 12:13:51 +0000855
Roberto Vargas025946a2018-09-24 17:20:48 +0100856# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
Soby Mathew9fe88042018-03-26 12:43:37 +0100857ifeq ($(DYN_DISABLE_AUTH), 1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100858 ifeq (${TRUSTED_BOARD_BOOT}, 0)
859 $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \
860 to be set.")
861 endif
862endif #(DYN_DISABLE_AUTH)
Soby Mathew9fe88042018-03-26 12:43:37 +0100863
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100864ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
865# Support authentication verification and hash calculation
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100866 CRYPTO_SUPPORT := 3
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100867else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
868# Support authentication verification and hash calculation
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100869 CRYPTO_SUPPORT := 3
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100870else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
871# Support hash calculation only
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100872 CRYPTO_SUPPORT := 2
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100873else ifeq (${TRUSTED_BOARD_BOOT},1)
874# Support authentication verification only
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100875 CRYPTO_SUPPORT := 1
Manish V Badarkhe5181d602022-01-08 22:56:06 +0000876else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100877 CRYPTO_SUPPORT := 0
878endif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT))
Manish V Badarkhe5181d602022-01-08 22:56:06 +0000879
Manish V Badarkhe8cad2e12024-12-03 21:46:51 +0000880ifneq ($(filter 1 2 3,$(CRYPTO_SUPPORT)),)
881CRYPTO_LIB := $(BUILD_PLAT)/lib/libmbedtls.a
882endif
883
Balint Dobszayd0dbd5e2019-12-18 15:28:00 +0100884# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
885ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100886 $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
Manish V Badarkhead339892020-06-29 10:32:53 +0100887endif
888
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000889# If pointer authentication is used in the firmware, make sure that all the
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100890# registers associated to it are also saved and restored.
891# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000892ifeq ($(ENABLE_PAUTH),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100893 ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
894 $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
895 endif
896endif #(ENABLE_PAUTH)
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100897
898ifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100899 ifneq (${ARCH},aarch64)
900 $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
901 endif
902endif #(CTX_INCLUDE_PAUTH_REGS)
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000903
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +0000904ifeq ($(FEATURE_DETECTION),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100905 $(info FEATURE_DETECTION is an experimental feature)
906endif #(FEATURE_DETECTION)
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +0000907
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +0000908ifneq ($(ENABLE_SME2_FOR_NS), 0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100909 ifeq (${ENABLE_SME_FOR_NS}, 0)
910 $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \
911 to be set")
912 $(warning "Forced ENABLE_SME_FOR_NS=1")
913 override ENABLE_SME_FOR_NS := 1
914 endif
915endif #(ENABLE_SME2_FOR_NS)
Jayanth Dodderi Chidanand605419a2023-03-06 23:56:14 +0000916
Petre-Ionut Tudore5a6fef2019-11-07 15:18:03 +0000917ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100918 ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
919 $(error "ALLOW_RO_XLAT_TABLES requires translation tables \
920 library v2")
921 endif
922endif #(ARM_XLAT_TABLES_LIB_V1)
Petre-Ionut Tudore5a6fef2019-11-07 15:18:03 +0000923
Sumit Garg392e4df2019-11-15 10:43:00 +0530924ifneq (${DECRYPTION_SUPPORT},none)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100925 ifeq (${TRUSTED_BOARD_BOOT}, 0)
926 $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \
927 to be set)
928 endif
929endif #(DECRYPTION_SUPPORT)
Sumit Garg392e4df2019-11-15 10:43:00 +0530930
johpow0181865962022-01-28 17:06:20 -0600931# Ensure that no Aarch64-only features are enabled in Aarch32 build
johpow019baade32021-07-08 14:14:00 -0500932ifeq (${ARCH},aarch32)
johpow0181865962022-01-28 17:06:20 -0600933
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100934 # SME/SVE only supported on AArch64
935 ifneq (${ENABLE_SME_FOR_NS},0)
936 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
937 endif
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +0000938
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100939 ifeq (${ENABLE_SVE_FOR_NS},1)
940 # Warning instead of error due to CI dependency on this
941 $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
942 endif
johpow0181865962022-01-28 17:06:20 -0600943
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100944 # BRBE is not supported in AArch32
945 ifeq (${ENABLE_BRBE_FOR_NS},1)
946 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
947 endif
johpow0181865962022-01-28 17:06:20 -0600948
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100949 # FEAT_RNG_TRAP is not supported in AArch32
950 ifeq (${ENABLE_FEAT_RNG_TRAP},1)
951 $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
952 endif
Arvind Ram Prakashe558f9c2024-11-11 14:32:37 -0600953
954 ifneq (${ENABLE_FEAT_FPMR},0)
955 $(error "ENABLE_FEAT_FPMR cannot be used with ARCH=aarch32")
956 endif
Boyan Karatotev8e7c43c2024-10-25 11:38:41 +0100957
958 ifeq (${ARCH_FEATURE_AVAILABILITY},1)
959 $(error "ARCH_FEATURE_AVAILABILITY cannot be used with ARCH=aarch32")
960 endif
Arvind Ram Prakashf915deb2025-01-09 17:18:30 -0600961 # FEAT_MOPS is only supported on AArch64
962 ifneq (${ENABLE_FEAT_MOPS},0)
963 $(error "ENABLE_FEAT_MOPS cannot be used with ARCH=aarch32")
964 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100965endif #(ARCH=aarch32)
johpow019baade32021-07-08 14:14:00 -0500966
Arvind Ram Prakashe558f9c2024-11-11 14:32:37 -0600967ifneq (${ENABLE_FEAT_FPMR},0)
968 ifeq (${ENABLE_FEAT_FGT},0)
969 $(error "ENABLE_FEAT_FPMR requires ENABLE_FEAT_FGT")
970 endif
971 ifeq (${ENABLE_FEAT_HCX},0)
972 $(error "ENABLE_FEAT_FPMR requires ENABLE_FEAT_HCX")
973 endif
974endif #(ENABLE_FEAT_FPMR)
975
Boyan Karatotev7f5dcc72023-03-08 16:29:26 +0000976ifneq (${ENABLE_SME_FOR_NS},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100977 ifeq (${ENABLE_SVE_FOR_NS},0)
978 $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS")
979 endif
980endif #(ENABLE_SME_FOR_NS)
Boyan Karatotev7f5dcc72023-03-08 16:29:26 +0000981
johpow019baade32021-07-08 14:14:00 -0500982# Secure SME/SVE requires the non-secure component as well
983ifeq (${ENABLE_SME_FOR_SWD},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100984 ifeq (${ENABLE_SME_FOR_NS},0)
985 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
986 endif
987 ifeq (${ENABLE_SVE_FOR_SWD},0)
988 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD")
989 endif
990endif #(ENABLE_SME_FOR_SWD)
991
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -0500992# Enabling SVE for SWD requires enabling SVE for NWD due to ENABLE_FEAT
993# mechanism.
johpow019baade32021-07-08 14:14:00 -0500994ifeq (${ENABLE_SVE_FOR_SWD},1)
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -0500995 ifeq (${ENABLE_SVE_FOR_NS},0)
996 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
997 endif
998endif
johpow019baade32021-07-08 14:14:00 -0500999
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -05001000# Enabling SVE for both the worlds typically requires the context
1001# management of SVE registers. The only exception being SPMC at S-EL2.
1002ifeq (${ENABLE_SVE_FOR_SWD}, 1)
1003 ifneq (${ENABLE_SVE_FOR_NS}, 0)
1004 ifeq (${CTX_INCLUDE_SVE_REGS}-$(SPMD_SPM_AT_SEL2),0-0)
1005 $(warning "ENABLE_SVE_FOR_SWD and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
1006 endif
1007 endif
1008endif
1009
1010# Enabling SVE in either world while enabling CTX_INCLUDE_FPREGS requires
1011# CTX_INCLUDE_SVE_REGS to be enabled due to architectural dependency between FP
1012# and SVE registers.
1013ifeq (${CTX_INCLUDE_FPREGS}, 1)
1014 ifneq (${ENABLE_SVE_FOR_NS},0)
1015 ifeq (${CTX_INCLUDE_SVE_REGS},0)
1016 # Warning instead of error due to CI dependency on this
1017 $(warning "CTX_INCLUDE_FPREGS and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
1018 $(warning "Forced ENABLE_SVE_FOR_NS=0")
1019 override ENABLE_SVE_FOR_NS := 0
1020 endif
1021 endif
1022endif #(CTX_INCLUDE_FPREGS)
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +00001023
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -05001024# SVE context management is only required if secure world has access to SVE/FP
1025# functionality.
1026ifeq (${CTX_INCLUDE_SVE_REGS},1)
1027 ifeq (${ENABLE_SVE_FOR_SWD},0)
1028 $(error "CTX_INCLUDE_SVE_REGS requires ENABLE_SVE_FOR_SWD to also be enabled")
1029 endif
1030endif
1031
1032# SME cannot be used with CTX_INCLUDE_FPREGS since SPM does its own context
1033# management including FPU registers.
1034ifeq (${CTX_INCLUDE_FPREGS},1)
1035 ifneq (${ENABLE_SME_FOR_NS},0)
1036 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1037 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001038endif #(CTX_INCLUDE_FPREGS)
johpow019baade32021-07-08 14:14:00 -05001039
Manish V Badarkhe191a5fc2022-03-02 12:06:35 +00001040ifeq ($(DRTM_SUPPORT),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001041 $(info DRTM_SUPPORT is an experimental feature)
Manish V Badarkhe191a5fc2022-03-02 12:06:35 +00001042endif
1043
Levi Yun03adb132024-05-13 10:24:31 +01001044ifeq (${HOB_LIST},1)
1045 $(warning HOB_LIST is an experimental feature)
1046endif
1047
Raymond Mao98983392023-07-25 07:53:35 -07001048ifeq (${TRANSFER_LIST},1)
1049 $(info TRANSFER_LIST is an experimental feature)
1050endif
1051
Chris Kayd02c2312022-09-29 16:21:24 +01001052ifeq (${ENABLE_RME},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001053 ifneq (${SEPARATE_CODE_AND_RODATA},1)
1054 $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
1055 endif
Chris Kayd02c2312022-09-29 16:21:24 +01001056endif
1057
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001058ifeq ($(PSA_CRYPTO),1)
1059 $(info PSA_CRYPTO is an experimental feature)
1060endif
1061
Manish V Badarkhed8d7d932024-05-09 12:14:13 +01001062ifeq ($(DICE_PROTECTION_ENVIRONMENT),1)
1063 $(info DICE_PROTECTION_ENVIRONMENT is an experimental feature)
1064endif
1065
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +00001066################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001067# Process platform overrideable behaviour
1068################################################################################
1069
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001070ifdef BL1_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001071 NEED_BL1 := yes
1072endif #(BL1_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001073
Jon Medhurst66573cb2014-02-13 15:19:28 +00001074ifdef BL2_SOURCES
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001075 NEED_BL2 := yes
1076
1077 # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
1078 # Certificate generation tools. This flag can be overridden by the platform.
1079 ifdef EL3_PAYLOAD_BASE
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001080 # If booting an EL3 payload there is no need for a BL33 image
1081 # in the FIP file.
1082 NEED_BL33 := no
1083 else
1084 ifdef PRELOADED_BL33_BASE
1085 # If booting a BL33 preloaded image there is no need of
1086 # another one in the FIP file.
1087 NEED_BL33 := no
1088 else
1089 NEED_BL33 ?= yes
1090 endif
1091 endif
1092endif #(BL2_SOURCES)
Achin Gupta4f6ad662013-10-25 09:08:21 +01001093
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001094ifdef BL2U_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001095 NEED_BL2U := yes
1096endif #(BL2U_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001097
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001098# If SCP_BL2 is given, we always want FIP to include it.
1099ifdef SCP_BL2
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001100 NEED_SCP_BL2 := yes
1101endif #(SCP_BL2)
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001102
Soby Mathewbf169232017-11-14 14:10:10 +00001103# For AArch32, BL31 is not currently supported.
1104ifneq (${ARCH},aarch32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001105 ifdef BL31_SOURCES
1106 # When booting an EL3 payload, there is no need to compile the BL31
1107 # image nor put it in the FIP.
1108 ifndef EL3_PAYLOAD_BASE
1109 NEED_BL31 := yes
1110 endif
1111 endif
1112endif #(ARCH=aarch64)
Soby Mathewbf169232017-11-14 14:10:10 +00001113
Juan Castilloa3487d12015-08-18 14:23:04 +01001114# Process TBB related flags
1115ifneq (${GENERATE_COT},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001116 # Common cert_create options
1117 ifneq (${CREATE_KEYS},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001118 $(eval CRT_ARGS += -n)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001119 $(eval FWU_CRT_ARGS += -n)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001120 ifneq (${SAVE_KEYS},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001121 $(eval CRT_ARGS += -k)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001122 $(eval FWU_CRT_ARGS += -k)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001123 endif
1124 endif
1125 # Include TBBR makefile (unless the platform indicates otherwise)
1126 ifeq (${INCLUDE_TBBR_MK},1)
Juan Castilloa3487d12015-08-18 14:23:04 +01001127 include make_helpers/tbbr/tbbr_tools.mk
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001128 endif
1129endif #(GENERATE_COT)
Achin Gupta4f6ad662013-10-25 09:08:21 +01001130
Masahiro Yamada4d87eb42016-12-25 13:52:22 +09001131ifneq (${FIP_ALIGN},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001132 FIP_ARGS += --align ${FIP_ALIGN}
1133endif #(FIP_ALIGN)
Masahiro Yamada4d87eb42016-12-25 13:52:22 +09001134
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001135ifdef FDT_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001136 NEED_FDT := yes
1137endif #(FDT_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001138
Juan Castilloa3487d12015-08-18 14:23:04 +01001139################################################################################
Michalis Pappas0f223c52018-03-20 13:01:27 +08001140# Include libraries' Makefile that are used in all BL
1141################################################################################
1142
1143include lib/stack_protector/stack_protector.mk
1144
1145################################################################################
Soby Mathew574e01e2017-02-14 10:05:07 +00001146# Include BL specific makefiles
1147################################################################################
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001148
1149ifeq (${NEED_BL1},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001150include bl1/bl1.mk
1151endif
1152
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001153ifeq (${NEED_BL2},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001154include bl2/bl2.mk
1155endif
1156
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001157ifeq (${NEED_BL2U},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001158include bl2u/bl2u.mk
1159endif
1160
Soby Mathewbf169232017-11-14 14:10:10 +00001161ifeq (${NEED_BL31},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001162include bl31/bl31.mk
1163endif
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001164
Soby Mathew574e01e2017-02-14 10:05:07 +00001165################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001166# Build options checks
1167################################################################################
1168
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001169# Boolean_Flags
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001170$(eval $(call assert_booleans,\
1171 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001172 ALLOW_RO_XLAT_TABLES \
1173 BL2_ENABLE_SP_LOAD \
1174 COLD_BOOT_SINGLE_CPU \
1175 CREATE_KEYS \
1176 CTX_INCLUDE_AARCH32_REGS \
1177 CTX_INCLUDE_FPREGS \
Madhukar Pappireddydd9af9b2024-06-17 15:17:03 -05001178 CTX_INCLUDE_SVE_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001179 CTX_INCLUDE_EL2_REGS \
Arvind Ram Prakash4851b492023-10-06 14:35:21 -05001180 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001181 DEBUG \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001182 DYN_DISABLE_AUTH \
1183 EL3_EXCEPTION_HANDLING \
1184 ENABLE_AMU_AUXILIARY_COUNTERS \
1185 ENABLE_AMU_FCONF \
1186 AMU_RESTRICT_COUNTERS \
1187 ENABLE_ASSERTIONS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001188 ENABLE_PIE \
1189 ENABLE_PMF \
1190 ENABLE_PSCI_STAT \
1191 ENABLE_RUNTIME_INSTRUMENTATION \
1192 ENABLE_SME_FOR_SWD \
1193 ENABLE_SVE_FOR_SWD \
Manish Pandey514a3012023-10-10 13:53:25 +01001194 ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +01001195 FFH_SUPPORT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001196 ERROR_DEPRECATED \
1197 FAULT_INJECTION_SUPPORT \
1198 GENERATE_COT \
1199 GICV2_G0_FOR_EL3 \
1200 HANDLE_EA_EL3_FIRST_NS \
Bipin Ravie53e6ae2023-09-28 13:17:24 -05001201 HARDEN_SLS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001202 HW_ASSISTED_COHERENCY \
1203 MEASURED_BOOT \
Tamas Bana4260892023-06-07 13:35:04 +02001204 DICE_PROTECTION_ENVIRONMENT \
Raghu Krishnamurthyc11b60e2024-06-03 19:02:29 -07001205 RMMD_ENABLE_EL3_TOKEN_SIGN \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001206 DRTM_SUPPORT \
1207 NS_TIMER_SWITCH \
1208 OVERRIDE_LIBC \
1209 PL011_GENERIC_UART \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001210 PROGRAMMABLE_RESET_ADDRESS \
1211 PSCI_EXTENDED_STATE_ID \
1212 PSCI_OS_INIT_MODE \
Boyan Karatotev8e7c43c2024-10-25 11:38:41 +01001213 ARCH_FEATURE_AVAILABILITY \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001214 RESET_TO_BL31 \
1215 SAVE_KEYS \
1216 SEPARATE_CODE_AND_RODATA \
1217 SEPARATE_BL2_NOLOAD_REGION \
1218 SEPARATE_NOBITS_REGION \
Ye Li97267752022-08-26 13:48:31 +08001219 SEPARATE_RWDATA_REGION \
Madhukar Pappireddy5c1b8d92024-06-17 15:26:00 -05001220 SEPARATE_SIMD_SECTION \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001221 SPIN_ON_BL1_EXIT \
1222 SPM_MM \
1223 SPMC_AT_EL3 \
Nishant Sharma9e719112023-06-27 00:36:01 +01001224 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001225 SPMD_SPM_AT_SEL2 \
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -08001226 ENABLE_SPMD_LP \
Raymond Mao98983392023-07-25 07:53:35 -07001227 TRANSFER_LIST \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001228 TRUSTED_BOARD_BOOT \
1229 USE_COHERENT_MEM \
1230 USE_DEBUGFS \
1231 ARM_IO_IN_DTB \
1232 SDEI_IN_FCONF \
1233 SEC_INT_DESC_IN_FCONF \
1234 USE_ROMLIB \
1235 USE_TBBR_DEFS \
1236 WARMBOOT_ENABLE_DCACHE_EARLY \
1237 RESET_TO_BL2 \
1238 BL2_IN_XIP_MEM \
1239 BL2_INV_DCACHE \
1240 USE_SPINLOCK_CAS \
1241 ENCRYPT_BL31 \
1242 ENCRYPT_BL32 \
1243 ERRATA_SPECULATIVE_AT \
1244 RAS_TRAP_NS_ERR_REC_ACCESS \
1245 COT_DESC_IN_DTB \
1246 USE_SP804_TIMER \
1247 PSA_FWU_SUPPORT \
Sughosh Ganu61905e52024-02-01 12:51:20 +05301248 PSA_FWU_METADATA_FW_STORE_DESC \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001249 ENABLE_MPMM \
Boyan Karatotev7262eff2024-12-19 16:07:29 +00001250 FEAT_PABANDON \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001251 ENABLE_MPMM_FCONF \
1252 FEATURE_DETECTION \
Jayanth Dodderi Chidanand7c7faff2022-10-11 17:16:07 +01001253 TRNG_SUPPORT \
Sona Mathew7fe03522022-11-18 18:05:38 -06001254 ERRATA_ABI_SUPPORT \
Sona Mathew5a4c9fc2023-03-14 14:02:03 -05001255 ERRATA_NON_ARM_INTERCONNECT \
Okash Khawaja037b56e2022-11-04 12:38:01 +00001256 CONDITIONAL_CMO \
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001257 PSA_CRYPTO \
Sandrine Bailleuxf57e2032023-10-11 08:38:00 +02001258 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash8bd27c92023-08-15 16:28:06 -05001259 INIT_UNUSED_NS_EL2 \
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001260 PLATFORM_REPORT_CTX_MEM_USE \
Yann Gautier5ae29c02024-01-16 19:39:31 +01001261 EARLY_CONSOLE \
Arvind Ram Prakasheaa90192023-12-21 00:25:52 -06001262 PRESERVE_DSU_PMU_REGS \
Levi Yun03adb132024-05-13 10:24:31 +01001263 HOB_LIST \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001264)))
Dan Handley81be1002015-03-27 17:44:35 +00001265
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001266# Numeric_Flags
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001267$(eval $(call assert_numerics,\
1268 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001269 ARM_ARCH_MAJOR \
1270 ARM_ARCH_MINOR \
1271 BRANCH_PROTECTION \
1272 CTX_INCLUDE_PAUTH_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001273 CTX_INCLUDE_NEVE_REGS \
1274 CRYPTO_SUPPORT \
Boyan Karatotev677ed8a2023-02-16 09:45:29 +00001275 DISABLE_MTPMU \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001276 ENABLE_BRBE_FOR_NS \
1277 ENABLE_TRBE_FOR_NS \
1278 ENABLE_BTI \
1279 ENABLE_PAUTH \
1280 ENABLE_FEAT_AMU \
1281 ENABLE_FEAT_AMUv1p1 \
1282 ENABLE_FEAT_CSV2_2 \
Sona Mathew3b84c962023-10-25 16:48:19 -05001283 ENABLE_FEAT_CSV2_3 \
Arvind Ram Prakash05b47632024-05-22 15:24:00 -05001284 ENABLE_FEAT_DEBUGV8P9 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001285 ENABLE_FEAT_DIT \
1286 ENABLE_FEAT_ECV \
1287 ENABLE_FEAT_FGT \
Arvind Ram Prakash62d87e72024-06-06 11:33:37 -05001288 ENABLE_FEAT_FGT2 \
Arvind Ram Prakashe558f9c2024-11-11 14:32:37 -06001289 ENABLE_FEAT_FPMR \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001290 ENABLE_FEAT_HCX \
Andre Przywara8fc8e182024-08-09 17:04:22 +01001291 ENABLE_FEAT_LS64_ACCDATA \
Arvind Ram Prakashf915deb2025-01-09 17:18:30 -06001292 ENABLE_FEAT_MOPS \
Govindraj Rajad7b63ac2024-01-26 10:08:37 -06001293 ENABLE_FEAT_MTE2 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001294 ENABLE_FEAT_PAN \
1295 ENABLE_FEAT_RNG \
1296 ENABLE_FEAT_RNG_TRAP \
1297 ENABLE_FEAT_SEL2 \
1298 ENABLE_FEAT_TCR2 \
Jayanth Dodderi Chidanand6b706862024-09-05 22:24:04 +01001299 ENABLE_FEAT_THE \
Govindraj Rajac2dad572024-01-23 16:03:53 -06001300 ENABLE_FEAT_SB \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001301 ENABLE_FEAT_S2PIE \
1302 ENABLE_FEAT_S1PIE \
1303 ENABLE_FEAT_S2POE \
1304 ENABLE_FEAT_S1POE \
Jayanth Dodderi Chidanand70cc1752024-09-06 13:49:31 +01001305 ENABLE_FEAT_SCTLR2 \
Govindraj Rajae63794e2024-09-06 15:43:43 +01001306 ENABLE_FEAT_D128 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001307 ENABLE_FEAT_GCS \
1308 ENABLE_FEAT_VHE \
Arvind Ram Prakashab28d4b2023-10-11 12:10:56 -05001309 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001310 ENABLE_RME \
1311 ENABLE_SPE_FOR_NS \
1312 ENABLE_SYS_REG_TRACE_FOR_NS \
1313 ENABLE_SME_FOR_NS \
1314 ENABLE_SME2_FOR_NS \
1315 ENABLE_SVE_FOR_NS \
1316 ENABLE_TRF_FOR_NS \
1317 FW_ENC_STATUS \
1318 NR_OF_FW_BANKS \
1319 NR_OF_IMAGES_IN_FW_BANK \
1320 TWED_DELAY \
1321 ENABLE_FEAT_TWED \
1322 SVE_VECTOR_LEN \
Varun Wadekar0a46eb12023-04-13 21:06:18 +01001323 IMPDEF_SYSREG_TRAP \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001324)))
Jeenu Viswambharanfca76802017-01-16 16:52:35 +00001325
Justin Chadwellf9b32c12019-07-29 17:13:10 +01001326ifdef KEY_SIZE
1327 $(eval $(call assert_numeric,KEY_SIZE))
1328endif
1329
Justin Chadwell83e04882019-08-20 11:01:52 +01001330ifeq ($(filter $(SANITIZE_UB), on off trap),)
1331 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
1332endif
1333
Juan Castilloa3487d12015-08-18 14:23:04 +01001334################################################################################
1335# Add definitions to the cpp preprocessor based on the current build options.
1336# This is done after including the platform specific makefile to allow the
1337# platform to overwrite the default options
1338################################################################################
Jeenu Viswambharand1b60152014-05-12 15:28:47 +01001339
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001340$(eval $(call add_defines,\
1341 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001342 ALLOW_RO_XLAT_TABLES \
1343 ARM_ARCH_MAJOR \
1344 ARM_ARCH_MINOR \
1345 BL2_ENABLE_SP_LOAD \
1346 COLD_BOOT_SINGLE_CPU \
1347 CTX_INCLUDE_AARCH32_REGS \
1348 CTX_INCLUDE_FPREGS \
Madhukar Pappireddydd9af9b2024-06-17 15:17:03 -05001349 CTX_INCLUDE_SVE_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001350 CTX_INCLUDE_PAUTH_REGS \
Arvind Ram Prakash4851b492023-10-06 14:35:21 -05001351 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001352 EL3_EXCEPTION_HANDLING \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001353 CTX_INCLUDE_EL2_REGS \
1354 CTX_INCLUDE_NEVE_REGS \
1355 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
1356 DISABLE_MTPMU \
1357 ENABLE_FEAT_AMU \
1358 ENABLE_AMU_AUXILIARY_COUNTERS \
1359 ENABLE_AMU_FCONF \
1360 AMU_RESTRICT_COUNTERS \
1361 ENABLE_ASSERTIONS \
1362 ENABLE_BTI \
Arvind Ram Prakash05b47632024-05-22 15:24:00 -05001363 ENABLE_FEAT_DEBUGV8P9 \
Arvind Ram Prakashab28d4b2023-10-11 12:10:56 -05001364 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001365 ENABLE_PAUTH \
1366 ENABLE_PIE \
1367 ENABLE_PMF \
1368 ENABLE_PSCI_STAT \
1369 ENABLE_RME \
Raghu Krishnamurthyc11b60e2024-06-03 19:02:29 -07001370 RMMD_ENABLE_EL3_TOKEN_SIGN \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001371 ENABLE_RUNTIME_INSTRUMENTATION \
1372 ENABLE_SME_FOR_NS \
1373 ENABLE_SME2_FOR_NS \
1374 ENABLE_SME_FOR_SWD \
1375 ENABLE_SPE_FOR_NS \
1376 ENABLE_SVE_FOR_NS \
1377 ENABLE_SVE_FOR_SWD \
Manish Pandey514a3012023-10-10 13:53:25 +01001378 ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +01001379 FFH_SUPPORT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001380 ENCRYPT_BL31 \
1381 ENCRYPT_BL32 \
1382 ERROR_DEPRECATED \
1383 FAULT_INJECTION_SUPPORT \
1384 GICV2_G0_FOR_EL3 \
1385 HANDLE_EA_EL3_FIRST_NS \
1386 HW_ASSISTED_COHERENCY \
1387 LOG_LEVEL \
1388 MEASURED_BOOT \
Tamas Bana4260892023-06-07 13:35:04 +02001389 DICE_PROTECTION_ENVIRONMENT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001390 DRTM_SUPPORT \
1391 NS_TIMER_SWITCH \
1392 PL011_GENERIC_UART \
1393 PLAT_${PLAT} \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001394 PROGRAMMABLE_RESET_ADDRESS \
1395 PSCI_EXTENDED_STATE_ID \
1396 PSCI_OS_INIT_MODE \
Boyan Karatotev8e7c43c2024-10-25 11:38:41 +01001397 ARCH_FEATURE_AVAILABILITY \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001398 RESET_TO_BL31 \
AlexeiFedorovc0ca2d72024-05-13 15:35:54 +01001399 RME_GPT_BITLOCK_BLOCK \
AlexeiFedorovbd8b1bb2024-03-13 17:07:03 +00001400 RME_GPT_MAX_BLOCK \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001401 SEPARATE_CODE_AND_RODATA \
1402 SEPARATE_BL2_NOLOAD_REGION \
1403 SEPARATE_NOBITS_REGION \
Ye Li97267752022-08-26 13:48:31 +08001404 SEPARATE_RWDATA_REGION \
Madhukar Pappireddy5c1b8d92024-06-17 15:26:00 -05001405 SEPARATE_SIMD_SECTION \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001406 RECLAIM_INIT_CODE \
1407 SPD_${SPD} \
1408 SPIN_ON_BL1_EXIT \
1409 SPM_MM \
1410 SPMC_AT_EL3 \
Nishant Sharma9e719112023-06-27 00:36:01 +01001411 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001412 SPMD_SPM_AT_SEL2 \
Raymond Mao98983392023-07-25 07:53:35 -07001413 TRANSFER_LIST \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001414 TRUSTED_BOARD_BOOT \
1415 CRYPTO_SUPPORT \
1416 TRNG_SUPPORT \
1417 ERRATA_ABI_SUPPORT \
Sona Mathew5a4c9fc2023-03-14 14:02:03 -05001418 ERRATA_NON_ARM_INTERCONNECT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001419 USE_COHERENT_MEM \
1420 USE_DEBUGFS \
1421 ARM_IO_IN_DTB \
1422 SDEI_IN_FCONF \
1423 SEC_INT_DESC_IN_FCONF \
1424 USE_ROMLIB \
1425 USE_TBBR_DEFS \
1426 WARMBOOT_ENABLE_DCACHE_EARLY \
1427 RESET_TO_BL2 \
1428 BL2_RUNS_AT_EL3 \
1429 BL2_IN_XIP_MEM \
1430 BL2_INV_DCACHE \
1431 USE_SPINLOCK_CAS \
1432 ERRATA_SPECULATIVE_AT \
1433 RAS_TRAP_NS_ERR_REC_ACCESS \
1434 COT_DESC_IN_DTB \
1435 USE_SP804_TIMER \
1436 ENABLE_FEAT_RNG \
1437 ENABLE_FEAT_RNG_TRAP \
1438 ENABLE_FEAT_SB \
1439 ENABLE_FEAT_DIT \
1440 NR_OF_FW_BANKS \
1441 NR_OF_IMAGES_IN_FW_BANK \
1442 PSA_FWU_SUPPORT \
Sughosh Ganu61905e52024-02-01 12:51:20 +05301443 PSA_FWU_METADATA_FW_STORE_DESC \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001444 ENABLE_BRBE_FOR_NS \
1445 ENABLE_TRBE_FOR_NS \
1446 ENABLE_SYS_REG_TRACE_FOR_NS \
1447 ENABLE_TRF_FOR_NS \
1448 ENABLE_FEAT_HCX \
1449 ENABLE_MPMM \
Boyan Karatotev7262eff2024-12-19 16:07:29 +00001450 FEAT_PABANDON \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001451 ENABLE_MPMM_FCONF \
1452 ENABLE_FEAT_FGT \
Arvind Ram Prakash62d87e72024-06-06 11:33:37 -05001453 ENABLE_FEAT_FGT2 \
Arvind Ram Prakashe558f9c2024-11-11 14:32:37 -06001454 ENABLE_FEAT_FPMR \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001455 ENABLE_FEAT_ECV \
1456 ENABLE_FEAT_AMUv1p1 \
1457 ENABLE_FEAT_SEL2 \
1458 ENABLE_FEAT_VHE \
1459 ENABLE_FEAT_CSV2_2 \
Sona Mathew3b84c962023-10-25 16:48:19 -05001460 ENABLE_FEAT_CSV2_3 \
Andre Przywara8fc8e182024-08-09 17:04:22 +01001461 ENABLE_FEAT_LS64_ACCDATA \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001462 ENABLE_FEAT_PAN \
1463 ENABLE_FEAT_TCR2 \
Jayanth Dodderi Chidanand6b706862024-09-05 22:24:04 +01001464 ENABLE_FEAT_THE \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001465 ENABLE_FEAT_S2PIE \
1466 ENABLE_FEAT_S1PIE \
1467 ENABLE_FEAT_S2POE \
1468 ENABLE_FEAT_S1POE \
Jayanth Dodderi Chidanand70cc1752024-09-06 13:49:31 +01001469 ENABLE_FEAT_SCTLR2 \
Govindraj Rajae63794e2024-09-06 15:43:43 +01001470 ENABLE_FEAT_D128 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001471 ENABLE_FEAT_GCS \
Arvind Ram Prakashf915deb2025-01-09 17:18:30 -06001472 ENABLE_FEAT_MOPS \
Govindraj Rajad7b63ac2024-01-26 10:08:37 -06001473 ENABLE_FEAT_MTE2 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001474 FEATURE_DETECTION \
1475 TWED_DELAY \
1476 ENABLE_FEAT_TWED \
Okash Khawaja037b56e2022-11-04 12:38:01 +00001477 CONDITIONAL_CMO \
Varun Wadekar0a46eb12023-04-13 21:06:18 +01001478 IMPDEF_SYSREG_TRAP \
Jayanth Dodderi Chidanand23c2fe22023-04-26 15:57:30 +01001479 SVE_VECTOR_LEN \
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -08001480 ENABLE_SPMD_LP \
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001481 PSA_CRYPTO \
Sandrine Bailleuxf57e2032023-10-11 08:38:00 +02001482 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash8bd27c92023-08-15 16:28:06 -05001483 INIT_UNUSED_NS_EL2 \
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001484 PLATFORM_REPORT_CTX_MEM_USE \
Yann Gautier5ae29c02024-01-16 19:39:31 +01001485 EARLY_CONSOLE \
Arvind Ram Prakasheaa90192023-12-21 00:25:52 -06001486 PRESERVE_DSU_PMU_REGS \
Levi Yun03adb132024-05-13 10:24:31 +01001487 HOB_LIST \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001488)))
Jeenu Viswambharan615ff392016-10-24 14:31:51 +01001489
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001490ifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1)
1491ifeq (${DEBUG}, 0)
1492 $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only")
1493 override PLATFORM_REPORT_CTX_MEM_USE := 0
1494endif
1495endif
1496
Justin Chadwell83e04882019-08-20 11:01:52 +01001497ifeq (${SANITIZE_UB},trap)
1498 $(eval $(call add_define,MONITOR_TRAPS))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001499endif #(SANITIZE_UB)
Justin Chadwell83e04882019-08-20 11:01:52 +01001500
Sandrine Bailleux03897bb2015-11-26 16:31:34 +00001501# Define the EL3_PAYLOAD_BASE flag only if it is provided.
1502ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +00001503 $(eval $(call add_define,EL3_PAYLOAD_BASE))
1504else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001505# Define the PRELOADED_BL33_BASE flag only if it is provided and
1506# EL3_PAYLOAD_BASE is not defined, as it has priority.
1507 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz2b8277b2016-04-06 17:31:57 +01001508 $(eval $(call add_define,PRELOADED_BL33_BASE))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001509 endif
1510endif #(EL3_PAYLOAD_BASE)
Soby Mathew85dbf5a2015-04-07 12:16:56 +01001511
Soby Mathew9fe88042018-03-26 12:43:37 +01001512# Define the DYN_DISABLE_AUTH flag only if set.
1513ifeq (${DYN_DISABLE_AUTH},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001514 $(eval $(call add_define,DYN_DISABLE_AUTH))
Soby Mathew9fe88042018-03-26 12:43:37 +01001515endif
1516
Chris Kaycfba6452023-12-04 09:55:50 +00001517ifeq ($($(ARCH)-ld-id),arm-link)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001518 $(eval $(call add_define,USE_ARM_LINK))
Varun Wadekar4d034c52019-01-11 14:47:48 -08001519endif
1520
Manish Pandey3f90ad72020-01-14 11:52:05 +00001521# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
Manish Pandey3f90ad72020-01-14 11:52:05 +00001522ifeq (${SPD},spmd)
Olivier Deprez042db532020-03-19 09:27:11 +01001523ifdef SP_LAYOUT_FILE
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001524 -include $(BUILD_PLAT)/sp_gen.mk
1525 FIP_DEPS += sp
1526 CRT_DEPS += sp
1527 NEED_SP_PKG := yes
Manish Pandey3f90ad72020-01-14 11:52:05 +00001528else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001529 ifeq (${SPMD_SPM_AT_SEL2},1)
1530 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1531 endif
1532endif #(SP_LAYOUT_FILE)
1533endif #(SPD)
Manish Pandey3f90ad72020-01-14 11:52:05 +00001534
Juan Castilloa3487d12015-08-18 14:23:04 +01001535################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001536# Build targets
1537################################################################################
Achin Gupta4f6ad662013-10-25 09:08:21 +01001538
Harrison Mutai36d971a2024-08-28 13:27:19 +00001539.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp tl fwu_fip certtool dtbs memmap doc enctool
Achin Gupta4f6ad662013-10-25 09:08:21 +01001540
Juan Castilloa3487d12015-08-18 14:23:04 +01001541all: msg_start
Harry Liebelf58ad362014-01-10 18:00:33 +00001542
Juan Castilloa3487d12015-08-18 14:23:04 +01001543msg_start:
Chris Kay1870c722024-05-02 17:52:37 +00001544 $(s)echo "Building ${PLAT}"
Juan Castillo11abdcd2014-10-21 11:30:42 +01001545
Soby Mathew18a62042015-10-26 14:29:21 +00001546ifeq (${ERROR_DEPRECATED},0)
Julius Werner53456fc2019-07-09 13:49:11 -07001547# Check if deprecated declarations and cpp warnings should be treated as error or not.
Chris Kaycfba6452023-12-04 09:55:50 +00001548ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
Varun Wadekar4d034c52019-01-11 14:47:48 -08001549 CPPFLAGS += -Wno-error=deprecated-declarations
1550else
Dan Handley6fa89a22018-02-27 16:03:58 +00001551 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp
Soby Mathew18a62042015-10-26 14:29:21 +00001552endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001553endif #(!ERROR_DEPRECATED)
Soby Mathew18a62042015-10-26 14:29:21 +00001554
Roberto Vargas0f8f9852018-05-08 10:27:10 +01001555$(eval $(call MAKE_LIB,c))
Roberto Vargas21360f32018-05-08 10:27:10 +01001556
Juan Castilloa3487d12015-08-18 14:23:04 +01001557# Expand build macros for the different images
1558ifeq (${NEED_BL1},yes)
Chris Kay0a542ec2021-09-28 15:44:19 +01001559BL1_SOURCES := $(sort ${BL1_SOURCES})
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001560$(eval $(call MAKE_BL,bl1))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001561endif #(NEED_BL1)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001562
Juan Castilloa3487d12015-08-18 14:23:04 +01001563ifeq (${NEED_BL2},yes)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001564
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -06001565ifeq (${RESET_TO_BL2}, 0)
Roberto Vargas53c052b2018-01-02 11:23:41 +00001566FIP_BL2_ARGS := tb-fw
1567endif
1568
Chris Kayfb3b0512021-09-28 15:44:37 +01001569BL2_SOURCES := $(sort ${BL2_SOURCES})
1570
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001571$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001572 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001573
1574endif #(NEED_BL2)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001575
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001576ifeq (${NEED_SCP_BL2},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001577$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001578endif #(NEED_SCP_BL2)
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001579
Juan Castilloa3487d12015-08-18 14:23:04 +01001580ifeq (${NEED_BL31},yes)
1581BL31_SOURCES += ${SPD_SOURCES}
Madhukar Pappireddyae9677b2020-01-27 13:37:51 -06001582# Sort BL31 source files to remove duplicates
1583BL31_SOURCES := $(sort ${BL31_SOURCES})
Sumit Gargeec52442019-11-14 16:33:45 +05301584ifneq (${DECRYPTION_SUPPORT},none)
1585$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001586 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
Sumit Gargeec52442019-11-14 16:33:45 +05301587else
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001588$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001589 $(eval $(call MAKE_BL,bl31,soc-fw)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001590endif #(DECRYPTION_SUPPORT)
1591endif #(NEED_BL31)
Juan Castillo379954c2014-11-04 17:36:40 +00001592
Juan Castillo671b8db2015-11-12 10:59:26 +00001593# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
Masahiro Yamada4d156802018-01-26 11:42:01 +09001594# build system will call TOOL_ADD_IMG to print a warning message and abort the
Juan Castillo671b8db2015-11-12 10:59:26 +00001595# process. Note that the dependency on BL32 applies to the FIP only.
Juan Castilloa3487d12015-08-18 14:23:04 +01001596ifeq (${NEED_BL32},yes)
Madhukar Pappireddyae9677b2020-01-27 13:37:51 -06001597# Sort BL32 source files to remove duplicates
1598BL32_SOURCES := $(sort ${BL32_SOURCES})
Masahiro Yamada6ced1b22018-01-26 11:42:01 +09001599BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
1600
Sumit Gargeec52442019-11-14 16:33:45 +05301601ifneq (${DECRYPTION_SUPPORT},none)
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001602$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
Sumit Gargeec52442019-11-14 16:33:45 +05301603 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1604else
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001605$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001606 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001607endif #(DECRYPTION_SUPPORT)
1608endif #(NEED_BL32)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001609
Zelalem Aweke4d37db82021-07-11 18:33:20 -05001610# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
1611# needs to be built from RMM_SOURCES.
1612ifeq (${NEED_RMM},yes)
1613# Sort RMM source files to remove duplicates
1614RMM_SOURCES := $(sort ${RMM_SOURCES})
1615BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
1616
1617$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001618 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1619endif #(NEED_RMM)
Zelalem Aweke4d37db82021-07-11 18:33:20 -05001620
Juan Castilloa3487d12015-08-18 14:23:04 +01001621# Add the BL33 image if required by the platform
1622ifeq (${NEED_BL33},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001623$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001624endif #(NEED_BL33)
Juan Castillo9c25a402015-01-13 12:21:04 +00001625
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001626ifeq (${NEED_BL2U},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001627$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001628 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001629endif #(NEED_BL2U)
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001630
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001631# Expand build macros for the different images
1632ifeq (${NEED_FDT},yes)
Soby Mathewab4181d2017-12-14 17:44:56 +00001633 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001634endif #(NEED_FDT)
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001635
Manish Pandey3f90ad72020-01-14 11:52:05 +00001636# Add Secure Partition packages
1637ifeq (${NEED_SP_PKG},yes)
Chris Kayd67442e2024-07-30 13:33:56 +00001638$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | $$(@D)/
Chris Kay1870c722024-05-02 17:52:37 +00001639 $(q)${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
J-Alvesef8e0982022-03-22 16:28:51 +00001640sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
Chris Kay1870c722024-05-02 17:52:37 +00001641 $(s)echo
1642 $(s)echo "Built SP Images successfully"
1643 $(s)echo
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001644endif #(NEED_SP_PKG)
Manish Pandey3f90ad72020-01-14 11:52:05 +00001645
Ian Spray36eaaf32014-01-30 17:25:28 +00001646locate-checkpatch:
1647ifndef CHECKPATCH
Etienne Carrieref5657572017-08-23 15:44:01 +02001648 $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
Ian Spray36eaaf32014-01-30 17:25:28 +00001649else
1650ifeq (,$(wildcard ${CHECKPATCH}))
Etienne Carrieref5657572017-08-23 15:44:01 +02001651 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
Ian Spray36eaaf32014-01-30 17:25:28 +00001652endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001653endif #(CHECKPATCH)
Ian Spray36eaaf32014-01-30 17:25:28 +00001654
Achin Gupta4f6ad662013-10-25 09:08:21 +01001655clean:
Chris Kay1870c722024-05-02 17:52:37 +00001656 $(s)echo " CLEAN"
Chris Kayfaab7482025-01-13 15:57:32 +00001657 $(q)rm -rf $(BUILD_PLAT)
Chris Kay1870c722024-05-02 17:52:37 +00001658 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Chris Kay1870c722024-05-02 17:52:37 +00001659 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
1660 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
1661 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001662
James Morrisseyeaaeece2013-11-01 13:56:59 +00001663realclean distclean:
Chris Kay1870c722024-05-02 17:52:37 +00001664 $(s)echo " REALCLEAN"
Chris Kayfaab7482025-01-13 15:57:32 +00001665 $(q)rm -rf $(BUILD_BASE)
1666 $(q)rm -rf $(CURDIR)/cscope.*
Chris Kay1870c722024-05-02 17:52:37 +00001667 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Chris Kay1870c722024-05-02 17:52:37 +00001668 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
1669 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
1670 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001671
Ian Spray36eaaf32014-01-30 17:25:28 +00001672checkcodebase: locate-checkpatch
Chris Kay1870c722024-05-02 17:52:37 +00001673 $(s)echo " CHECKING STYLE"
1674 $(q)if test -d .git ; then \
Paul Beesleyadfab5b2019-03-07 16:42:31 +00001675 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \
Dan Handley3a355712016-06-02 18:21:02 +01001676 while read GIT_FILE ; \
1677 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
1678 done ; \
1679 else \
1680 find . -type f -not -iwholename "*.git*" \
1681 -not -iwholename "*build*" \
1682 -not -iwholename "*libfdt*" \
Roberto Vargas0f8f9852018-05-08 10:27:10 +01001683 -not -iwholename "*libc*" \
Dan Handley3a355712016-06-02 18:21:02 +01001684 -not -iwholename "*docs*" \
Paul Beesleyadfab5b2019-03-07 16:42:31 +00001685 -not -iwholename "*.rst" \
Dan Handley3a355712016-06-02 18:21:02 +01001686 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
1687 fi
Ian Spray36eaaf32014-01-30 17:25:28 +00001688
1689checkpatch: locate-checkpatch
Chris Kay1870c722024-05-02 17:52:37 +00001690 $(s)echo " CHECKING STYLE"
1691 $(q)if test -n "${CHECKPATCH_OPTS}"; then \
Yann Gautier0c26a2a2019-03-08 15:44:00 +01001692 echo " with ${CHECKPATCH_OPTS} option(s)"; \
1693 fi
Chris Kay1870c722024-05-02 17:52:37 +00001694 $(q)COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
Yann Gautiera10a6852021-11-02 18:03:31 +01001695 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \
1696 do \
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001697 printf "\n[*] Checking style of '$$commit'\n\n"; \
Yann Gautierfaf8c612024-08-09 11:52:03 +02001698 ( git log --format=email "$$commit~..$$commit" \
1699 -- ${CHECK_PATHS} ; \
1700 git diff --format=email "$$commit~..$$commit" \
1701 -- ${CHECK_PATHS}; ) | \
Yann Gautier0c26a2a2019-03-08 15:44:00 +01001702 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001703 done
Juan Castilloa3487d12015-08-18 14:23:04 +01001704
1705certtool: ${CRTTOOL}
Ian Spray36eaaf32014-01-30 17:25:28 +00001706
Pali Rohár54ff2132020-11-24 15:38:08 +01001707${CRTTOOL}: FORCE
Chris Kay1870c722024-05-02 17:52:37 +00001708 $(q)${MAKE} PLAT=${PLAT} USE_TBBR_DEFS=${USE_TBBR_DEFS} COT=${COT} OPENSSL_DIR=${OPENSSL_DIR} CRTTOOL=${CRTTOOL} DEBUG=${DEBUG} --no-print-directory -C ${CRTTOOLPATH} all
1709 $(s)echo
1710 $(s)echo "Built $@ successfully"
1711 $(s)echo
Jon Medhurst407a95c2014-02-12 15:54:48 +00001712
Juan Castillo11abdcd2014-10-21 11:30:42 +01001713ifneq (${GENERATE_COT},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001714certificates: ${CRT_DEPS} ${CRTTOOL}
Chris Kay1870c722024-05-02 17:52:37 +00001715 $(q)${CRTTOOL} ${CRT_ARGS}
1716 $(s)echo
1717 $(s)echo "Built $@ successfully"
1718 $(s)echo "Certificates can be found in ${BUILD_PLAT}"
1719 $(s)echo
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001720endif #(GENERATE_COT)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001721
Juan Castilloa3487d12015-08-18 14:23:04 +01001722${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
Pali Rohára5416ab2020-11-24 16:53:04 +01001723 $(eval ${CHECK_FIP_CMD})
Chris Kay1870c722024-05-02 17:52:37 +00001724 $(q)${FIPTOOL} create ${FIP_ARGS} $@
1725 $(q)${FIPTOOL} info $@
1726 $(s)echo
1727 $(s)echo "Built $@ successfully"
1728 $(s)echo
Soby Mathewdbee7fc2014-09-08 17:51:01 +01001729
Yatharth Kochard1a93432015-10-12 12:33:47 +01001730ifneq (${GENERATE_COT},0)
1731fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
Chris Kay1870c722024-05-02 17:52:37 +00001732 $(q)${CRTTOOL} ${FWU_CRT_ARGS}
1733 $(s)echo
1734 $(s)echo "Built $@ successfully"
1735 $(s)echo "FWU certificates can be found in ${BUILD_PLAT}"
1736 $(s)echo
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001737endif #(GENERATE_COT)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001738
1739${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
Pali Rohára5416ab2020-11-24 16:53:04 +01001740 $(eval ${CHECK_FWU_FIP_CMD})
Chris Kay1870c722024-05-02 17:52:37 +00001741 $(q)${FIPTOOL} create ${FWU_FIP_ARGS} $@
1742 $(q)${FIPTOOL} info $@
1743 $(s)echo
1744 $(s)echo "Built $@ successfully"
1745 $(s)echo
Yatharth Kochard1a93432015-10-12 12:33:47 +01001746
Juan Castilloa3487d12015-08-18 14:23:04 +01001747fiptool: ${FIPTOOL}
1748fip: ${BUILD_PLAT}/${FIP_NAME}
Yatharth Kochard1a93432015-10-12 12:33:47 +01001749fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
Harry Liebelf58ad362014-01-10 18:00:33 +00001750
Pali Rohár54ff2132020-11-24 15:38:08 +01001751${FIPTOOL}: FORCE
Manish V Badarkhe0a5acd42024-10-03 20:50:04 +01001752 $(q)${MAKE} PLAT=${PLAT} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${FIPTOOLPATH} all
Harry Liebelf58ad362014-01-10 18:00:33 +00001753
Manish V Badarkhe8cad2e12024-12-03 21:46:51 +00001754$(BUILD_PLAT)/romlib/romlib.bin $(BUILD_PLAT)/lib/libwrappers.a $&: $(BUILD_PLAT)/lib/libfdt.a $(BUILD_PLAT)/lib/libc.a $(CRYPTO_LIB)
1755 $(q)${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} CRYPTO_SUPPORT=${CRYPTO_SUPPORT} ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES=$(call escape-shell,$(INCLUDES)) DEFINES=$(call escape-shell,$(DEFINES)) --no-print-directory -C ${ROMLIBPATH} all
Roberto Vargase92111a2018-05-22 16:05:42 +01001756
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +01001757memmap: all
Chris Kay1870c722024-05-02 17:52:37 +00001758 $(q)PYTHONPATH=${CURDIR}/tools/memory \
Harrison Mutaie9bc4882023-02-23 10:33:58 +00001759 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +01001760
Harrison Mutai36d971a2024-08-28 13:27:19 +00001761tl: ${BUILD_PLAT}/tl.bin
1762${BUILD_PLAT}/tl.bin: ${HW_CONFIG}
Chris Kaya152e752024-09-26 14:18:04 +00001763 $(if $(host-poetry),$(q)poetry -q install)
1764 $(q)$(if $(host-poetry),poetry run )tlc create --fdt $< -s ${FW_HANDOFF_SIZE} $@
Harrison Mutai36d971a2024-08-28 13:27:19 +00001765
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -06001766doc:
Chris Kay1870c722024-05-02 17:52:37 +00001767 $(s)echo " BUILD DOCUMENTATION"
1768 $(q)${MAKE} --no-print-directory -C ${DOCS_PATH} html
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -06001769
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301770enctool: ${ENCTOOL}
1771
Pali Rohár54ff2132020-11-24 15:38:08 +01001772${ENCTOOL}: FORCE
Chris Kay1870c722024-05-02 17:52:37 +00001773 $(q)${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} --no-print-directory -C ${ENCTOOLPATH} all
1774 $(s)echo
1775 $(s)echo "Built $@ successfully"
1776 $(s)echo
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301777
Joakim Bech35fab8c2014-01-23 14:51:49 +01001778cscope:
Chris Kay1870c722024-05-02 17:52:37 +00001779 $(s)echo " CSCOPE"
1780 $(q)find ${CURDIR} -name "*.[chsS]" > cscope.files
1781 $(q)cscope -b -q -k
Joakim Bech35fab8c2014-01-23 14:51:49 +01001782
Ryan Harkin72ee3312014-01-15 16:55:07 +00001783help:
Chris Kay1870c722024-05-02 17:52:37 +00001784 $(s)echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
1785 $(s)echo ""
1786 $(s)echo "PLAT is used to specify which platform you wish to build."
1787 $(s)echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
1788 $(s)echo ""
1789 $(s)echo "platform = ${PLATFORM_LIST}"
1790 $(s)echo ""
1791 $(s)echo "Please refer to the User Guide for a list of all supported options."
1792 $(s)echo "Note that the build system doesn't track dependencies for build "
1793 $(s)echo "options. Therefore, if any of the build options are changed "
1794 $(s)echo "from a previous build, a clean build must be performed."
1795 $(s)echo ""
1796 $(s)echo "Supported Targets:"
1797 $(s)echo " all Build all individual bootloader binaries"
1798 $(s)echo " bl1 Build the BL1 binary"
1799 $(s)echo " bl2 Build the BL2 binary"
1800 $(s)echo " bl2u Build the BL2U binary"
1801 $(s)echo " bl31 Build the BL31 binary"
1802 $(s)echo " bl32 Build the BL32 binary. If ARCH=aarch32, then "
1803 $(s)echo " this builds secure payload specified by AARCH32_SP"
1804 $(s)echo " certificates Build the certificates (requires 'GENERATE_COT=1')"
1805 $(s)echo " fip Build the Firmware Image Package (FIP)"
1806 $(s)echo " fwu_fip Build the FWU Firmware Image Package (FIP)"
1807 $(s)echo " checkcodebase Check the coding style of the entire source tree"
1808 $(s)echo " checkpatch Check the coding style on changes in the current"
1809 $(s)echo " branch against BASE_COMMIT (default origin/master)"
1810 $(s)echo " clean Clean the build for the selected platform"
1811 $(s)echo " cscope Generate cscope index"
1812 $(s)echo " distclean Remove all build artifacts for all platforms"
1813 $(s)echo " certtool Build the Certificate generation tool"
1814 $(s)echo " enctool Build the Firmware encryption tool"
1815 $(s)echo " fiptool Build the Firmware Image Package (FIP) creation tool"
1816 $(s)echo " sp Build the Secure Partition Packages"
1817 $(s)echo " sptool Build the Secure Partition Package creation tool"
1818 $(s)echo " dtbs Build the Device Tree Blobs (if required for the platform)"
1819 $(s)echo " memmap Print the memory map of the built binaries"
1820 $(s)echo " doc Build html based documentation using Sphinx tool"
1821 $(s)echo ""
1822 $(s)echo "Note: most build targets require PLAT to be set to a specific platform."
1823 $(s)echo ""
1824 $(s)echo "example: build all targets for the FVP platform:"
1825 $(s)echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
Pali Rohár54ff2132020-11-24 15:38:08 +01001826
1827.PHONY: FORCE
1828FORCE:;