blob: 4f3f261233b8836670f573c6183acaeb97286b2d [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001#
Govindraj Raja24d3a4e2023-12-21 13:57:49 -06002# Copyright (c) 2013-2024, 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
Manish V Badarkhe8a7af842024-05-17 11:09:28 +010011VERSION_MINOR := 11
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
Evan Lloyda71d2592015-12-02 18:56:06 +000026include ${MAKE_HELPERS_DIRECTORY}build_env.mk
Chris Kay1559f642024-06-04 00:04:48 +000027include ${MAKE_HELPERS_DIRECTORY}build-rules.mk
Chris Kay1870c722024-05-02 17:52:37 +000028include ${MAKE_HELPERS_DIRECTORY}common.mk
Juan Castilloa3487d12015-08-18 14:23:04 +010029
30################################################################################
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010031# Default values for build configurations, and their dependencies
Juan Castilloa3487d12015-08-18 14:23:04 +010032################################################################################
Jeenu Viswambharan19a0ace2014-05-15 14:40:58 +010033
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010034include ${MAKE_HELPERS_DIRECTORY}defaults.mk
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
102CRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT}
103
104# Variables for use with Firmware Encryption Tool
105ENCTOOLPATH ?= tools/encrypt_fw
106ENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
107
108# Variables for use with Firmware Image Package
109FIPTOOLPATH ?= tools/fiptool
110FIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT}
111
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
259TF_CFLAGS += $(call cc_option, --param=min-pagesize=0)
260
Bipin Ravie53e6ae2023-09-28 13:17:24 -0500261ifeq ($(HARDEN_SLS), 1)
262 TF_CFLAGS_aarch64 += $(call cc_option, -mharden-sls=all)
263endif
264
Justin Chadwell7a914232019-07-03 14:15:56 +0100265else
266# using clang
Justin Chadwell42d18ca2019-09-18 14:13:42 +0100267WARNINGS += -Wshift-overflow -Wshift-sign-overflow \
268 -Wlogical-op-parentheses
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100269endif #(Clang Warning)
Ambroise Vincent067e4d92019-05-24 12:47:43 +0100270
Yann Gautier957c3532018-12-10 18:08:53 +0100271ifneq (${E},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100272 ERRORS := -Werror
273endif #(E)
Yann Gautier957c3532018-12-10 18:08:53 +0100274
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100275################################################################################
276# Compiler and Linker Directives
277################################################################################
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100278CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
279 $(ERRORS) $(WARNINGS)
Govindraj Rajacd10c6e2023-05-30 16:52:15 -0500280ASFLAGS += $(CPPFLAGS) \
Julius Werner53456fc2019-07-09 13:49:11 -0700281 -ffreestanding -Wa,--fatal-warnings
Masahiro Yamada0dec9fa2016-12-22 12:51:53 +0900282TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \
Samuel Holland23f5e542019-10-20 16:11:25 -0500283 -ffunction-sections -fdata-sections \
284 -ffreestanding -fno-builtin -fno-common \
285 -Os -std=gnu99
Juan Castilloa3487d12015-08-18 14:23:04 +0100286
Justin Chadwell83e04882019-08-20 11:01:52 +0100287ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100288 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover
289endif #(${SANITIZE_UB},on)
290
Justin Chadwell83e04882019-08-20 11:01:52 +0100291ifeq (${SANITIZE_UB},trap)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100292 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \
Justin Chadwell83e04882019-08-20 11:01:52 +0100293 -fsanitize-undefined-trap-on-error
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100294endif #(${SANITIZE_UB},trap)
Justin Chadwell83e04882019-08-20 11:01:52 +0100295
Chris Kay0adde4e2024-05-14 13:08:31 +0000296GCC_V_OUTPUT := $(if $($(ARCH)-cc),$(shell $($(ARCH)-cc) -v 2>&1))
david cunado34ab6092017-11-30 21:58:01 +0000297
Marco Felsch24ad8402022-11-09 12:59:09 +0100298TF_LDFLAGS += -z noexecstack
299
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100300# LD = armlink
Chris Kaycfba6452023-12-04 09:55:50 +0000301ifeq ($($(ARCH)-ld-id),arm-link)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100302 TF_LDFLAGS += --diag_error=warning --lto_level=O1
303 TF_LDFLAGS += --remove --info=unused,unusedsymbols
304 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100305
306# LD = gcc (used when GCC LTO is enabled)
Chris Kaycfba6452023-12-04 09:55:50 +0000307else ifeq ($($(ARCH)-ld-id),gnu-gcc)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100308 # Pass ld options with Wl or Xlinker switches
Chris Kayb0fe96f2024-01-16 11:53:35 +0000309 TF_LDFLAGS += $(call ld_option,-Xlinker --no-warn-rwx-segments)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100310 TF_LDFLAGS += -Wl,--fatal-warnings -O1
311 TF_LDFLAGS += -Wl,--gc-sections
Chris Kay73b1f402022-12-22 13:26:37 +0000312
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100313 TF_LDFLAGS += -Wl,-z,common-page-size=4096 #Configure page size constants
314 TF_LDFLAGS += -Wl,-z,max-page-size=4096
Andrey Skvortsove2ebb722023-09-05 23:06:29 +0300315 TF_LDFLAGS += -Wl,--build-id=none
Chris Kay73b1f402022-12-22 13:26:37 +0000316
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100317 ifeq ($(ENABLE_LTO),1)
318 ifeq (${ARCH},aarch64)
319 TF_LDFLAGS += -flto -fuse-linker-plugin
Andrey Skvortsov664d6502023-12-08 18:04:51 +0300320 TF_LDFLAGS += -flto-partition=one
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100321 endif
322 endif #(ENABLE_LTO)
323
zelalem-aweked5f45272019-11-12 16:20:17 -0600324# GCC automatically adds fix-cortex-a53-843419 flag when used to link
325# which breaks some builds, so disable if errata fix is not explicitly enabled
Yann Gautier3d73d162023-03-15 16:18:16 +0100326 ifeq (${ARCH},aarch64)
327 ifneq (${ERRATA_A53_843419},1)
328 TF_LDFLAGS += -mno-fix-cortex-a53-843419
329 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100330 endif
331 TF_LDFLAGS += -nostdlib
332 TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100333
334# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
Varun Wadekar4d034c52019-01-11 14:47:48 -0800335else
Marco Felsch24ad8402022-11-09 12:59:09 +0100336# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
337# are not loaded by a elf loader.
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100338 TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments)
339 TF_LDFLAGS += -O1
340 TF_LDFLAGS += --gc-sections
Chris Kay73b1f402022-12-22 13:26:37 +0000341
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100342 TF_LDFLAGS += -z common-page-size=4096 # Configure page size constants
343 TF_LDFLAGS += -z max-page-size=4096
Andrey Skvortsove2ebb722023-09-05 23:06:29 +0300344 TF_LDFLAGS += --build-id=none
Chris Kay73b1f402022-12-22 13:26:37 +0000345
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100346# ld.lld doesn't recognize the errata flags,
Yabin Cuied7dc512023-01-19 20:06:04 +0000347# therefore don't add those in that case.
348# ld.lld reports section type mismatch warnings,
349# therefore don't add --fatal-warnings to it.
Chris Kaycfba6452023-12-04 09:55:50 +0000350 ifneq ($($(ARCH)-ld-id),llvm-lld)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100351 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) --fatal-warnings
352 endif
353
354endif #(LD = armlink)
Juan Castilloa3487d12015-08-18 14:23:04 +0100355
356################################################################################
Govindraj Raja0386e312023-08-17 10:41:48 -0500357# Setup ARCH_MAJOR/MINOR before parsing arch_features.
358################################################################################
359ifeq (${ENABLE_RME},1)
AlexeiFedorov65258452024-03-13 11:53:44 +0000360 ARM_ARCH_MAJOR := 9
361 ARM_ARCH_MINOR := 2
Govindraj Raja0386e312023-08-17 10:41:48 -0500362endif
363
364################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +0100365# Common sources and include directories
366################################################################################
dp-arme3cc8382017-05-04 12:15:35 +0100367include lib/compiler-rt/compiler-rt.mk
Juan Castilloa3487d12015-08-18 14:23:04 +0100368
Chris Kay99b5b2e2024-03-08 16:08:31 +0000369# Allow overriding the timestamp, for example for reproducible builds, or to
370# synchronize timestamps across multiple projects.
371# This must be set to a C string (including quotes where applicable).
372BUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__
373
374DEFINES += -DBUILD_MESSAGE_TIMESTAMP='$(BUILD_MESSAGE_TIMESTAMP)'
375DEFINES += -DBUILD_MESSAGE_VERSION_STRING='"$(VERSION_STRING)"'
376DEFINES += -DBUILD_MESSAGE_VERSION='"$(VERSION)"'
377
Juan Castilloa3487d12015-08-18 14:23:04 +0100378BL_COMMON_SOURCES += common/bl_common.c \
Soby Mathewaaf15f52017-09-04 11:49:29 +0100379 common/tf_log.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100380 common/${ARCH}/debug.S \
Julius Werner03020da2018-11-27 22:10:56 -0800381 drivers/console/multi_console.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100382 lib/${ARCH}/cache_helpers.S \
383 lib/${ARCH}/misc_helpers.S \
Boyan Karatotev05504ba2023-02-15 13:21:50 +0000384 lib/extensions/pmuv3/${ARCH}/pmuv3.c \
Soby Mathew2f38ce32018-02-08 17:45:12 +0000385 plat/common/plat_bl_common.c \
Soby Mathewaaf15f52017-09-04 11:49:29 +0100386 plat/common/plat_log_common.c \
dp-arm230011c2017-03-07 11:02:47 +0000387 plat/common/${ARCH}/plat_common.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100388 plat/common/${ARCH}/platform_helpers.S \
Roberto Vargas0f8f9852018-05-08 10:27:10 +0100389 ${COMPILER_RT_SRCS}
Ryan Harkind7a6b0f2014-01-13 14:40:13 +0000390
Chris Kaycfba6452023-12-04 09:55:50 +0000391ifeq ($($(ARCH)-cc-id),arm-clang)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100392 BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S
Antonio Nino Diazeea20fc2018-08-16 15:42:44 +0100393endif
394
Justin Chadwell83e04882019-08-20 11:01:52 +0100395ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100396 BL_COMMON_SOURCES += plat/common/ubsan.c
Justin Chadwell83e04882019-08-20 11:01:52 +0100397endif
398
Yann Gautier2cf1dbc2018-06-18 16:00:23 +0200399INCLUDES += -Iinclude \
Antonio Nino Diaz8d1ade62018-12-17 17:20:57 +0000400 -Iinclude/arch/${ARCH} \
Antonio Nino Diaze0f90632018-12-14 00:18:21 +0000401 -Iinclude/lib/cpus/${ARCH} \
402 -Iinclude/lib/el3_runtime/${ARCH} \
403 ${PLAT_INCLUDES} \
404 ${SPD_INCLUDES}
405
Nishant Sharma331b5682022-08-15 16:37:07 +0100406DTC_FLAGS += -I dts -O dtb
407DTC_CPPFLAGS += -P -nostdinc $(INCLUDES) -Ifdts -undef \
408 -x assembler-with-cpp $(DEFINES)
409
Antonio Nino Diazc3a2cf22018-11-19 11:48:30 +0000410include common/backtrace/backtrace.mk
411
Juan Castilloa3487d12015-08-18 14:23:04 +0100412################################################################################
Govindraj Raja1a211292023-09-20 14:32:24 -0500413# Generic definitions
414################################################################################
Govindraj Raja1a211292023-09-20 14:32:24 -0500415
416ifeq (${BUILD_BASE},)
417 BUILD_BASE := ./build
418endif
419BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
420
421SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
422
423# Platforms providing their own TBB makefile may override this value
424INCLUDE_TBBR_MK := 1
425
426################################################################################
427# Include SPD Makefile if one has been specified
428################################################################################
429
430ifneq (${SPD},none)
431 ifeq (${ARCH},aarch32)
432 $(error "Error: SPD is incompatible with AArch32.")
433 endif
434
435 ifdef EL3_PAYLOAD_BASE
436 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
437 $(warning "The SPD and its BL32 companion will be present but \
438 ignored.")
439 endif
440
441 ifeq (${SPD},spmd)
442 # SPMD is located in std_svc directory
443 SPD_DIR := std_svc
444
445 ifeq ($(SPMD_SPM_AT_SEL2),1)
446 CTX_INCLUDE_EL2_REGS := 1
447 ifeq ($(SPMC_AT_EL3),1)
448 $(error SPM cannot be enabled in both S-EL2 and EL3.)
449 endif
Madhukar Pappireddy7503cdc2024-04-25 23:01:00 -0500450 ifeq ($(CTX_INCLUDE_SVE_REGS),1)
451 $(error SVE context management not needed with Hafnium SPMC.)
452 endif
Govindraj Raja1a211292023-09-20 14:32:24 -0500453 endif
454
455 ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
456 DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG
457 endif
458
Arunachalam Ganapathyfd29d582022-04-11 14:36:54 +0100459 ifeq ($(findstring trusty_sp,$(ARM_SPMC_MANIFEST_DTS)),trusty_sp)
460 DTC_CPPFLAGS += -DTRUSTY_SP_FW_CONFIG
461 endif
462
Govindraj Raja1a211292023-09-20 14:32:24 -0500463 ifeq ($(TS_SP_FW_CONFIG),1)
Arunachalam Ganapathyfd29d582022-04-11 14:36:54 +0100464 DTC_CPPFLAGS += -DTS_SP_FW_CONFIG
Govindraj Raja1a211292023-09-20 14:32:24 -0500465 endif
466
467 ifneq ($(ARM_BL2_SP_LIST_DTS),)
468 DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
469 endif
470
471 ifneq ($(SP_LAYOUT_FILE),)
472 BL2_ENABLE_SP_LOAD := 1
473 endif
Govindraj Rajabad835a2023-10-31 14:48:11 -0500474
475 ifeq ($(SPMC_AT_EL3_SEL0_SP),1)
476 ifneq ($(SPMC_AT_EL3),1)
477 $(error SEL0 SP cannot be enabled without SPMC at EL3)
478 endif
479 endif
Govindraj Raja1a211292023-09-20 14:32:24 -0500480 else
481 # All other SPDs in spd directory
482 SPD_DIR := spd
483 endif #(SPD)
484
485 # We expect to locate an spd.mk under the specified SPD directory
486 SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
487
488 ifeq (${SPD_MAKE},)
489 $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
490 endif
491 $(info Including ${SPD_MAKE})
492 include ${SPD_MAKE}
493
494 # If there's BL32 companion for the chosen SPD, we expect that the SPD's
495 # Makefile would set NEED_BL32 to "yes". In this case, the build system
496 # supports two mutually exclusive options:
497 # * BL32 is built from source: then BL32_SOURCES must contain the list
498 # of source files to build BL32
499 # * BL32 is a prebuilt binary: then BL32 must point to the image file
500 # that will be included in the FIP
501 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
502 # over the sources.
503endif #(SPD=none)
504
505ifeq (${ENABLE_SPMD_LP}, 1)
506ifneq (${SPD},spmd)
507 $(error Error: ENABLE_SPMD_LP requires SPD=spmd.)
508endif
509ifeq ($(SPMC_AT_EL3),1)
510 $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.)
511endif
512endif
513
514################################################################################
Govindraj Raja0386e312023-08-17 10:41:48 -0500515# Process BRANCH_PROTECTION value and set
516# Pointer Authentication and Branch Target Identification flags
517################################################################################
518ifeq (${BRANCH_PROTECTION},0)
519 # Default value turns off all types of branch protection
520 BP_OPTION := none
521else ifneq (${ARCH},aarch64)
522 $(error BRANCH_PROTECTION requires AArch64)
523else ifeq (${BRANCH_PROTECTION},1)
524 # Enables all types of branch protection features
525 BP_OPTION := standard
526 ENABLE_BTI := 1
527 ENABLE_PAUTH := 1
528else ifeq (${BRANCH_PROTECTION},2)
529 # Return address signing to its standard level
530 BP_OPTION := pac-ret
531 ENABLE_PAUTH := 1
532else ifeq (${BRANCH_PROTECTION},3)
533 # Extend the signing to include leaf functions
534 BP_OPTION := pac-ret+leaf
535 ENABLE_PAUTH := 1
536else ifeq (${BRANCH_PROTECTION},4)
537 # Turn on branch target identification mechanism
538 BP_OPTION := bti
539 ENABLE_BTI := 1
540else
541 $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
542endif #(BRANCH_PROTECTION)
543
544ifeq ($(ENABLE_PAUTH),1)
545 CTX_INCLUDE_PAUTH_REGS := 1
546endif
547ifneq (${BP_OPTION},none)
548 TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION}
549endif #(BP_OPTION)
550
551# Pointer Authentication sources
552ifeq (${ENABLE_PAUTH}, 1)
553# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the
554# Pauth support. As it's not secure, it must be reimplemented for real platforms
555 BL_COMMON_SOURCES += lib/extensions/pauth/pauth_helpers.S
556endif
557
Govindraj Raja1a211292023-09-20 14:32:24 -0500558################################################################################
559# Include the platform specific Makefile after the SPD Makefile (the platform
560# makefile may use all previous definitions in this file)
561################################################################################
562include ${PLAT_MAKEFILE_FULL}
563
564################################################################################
565# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from
566# platform.
567################################################################################
568include ${MAKE_HELPERS_DIRECTORY}arch_features.mk
569
Govindraj Raja0386e312023-08-17 10:41:48 -0500570####################################################
571# Enable required options for Memory Stack Tagging.
572####################################################
573
574# Currently, these options are enabled only for clang and armclang compiler.
575ifeq (${SUPPORT_STACK_MEMTAG},yes)
576 ifdef mem_tag_arch_support
577 # Check for armclang and clang compilers
Chris Kaycfba6452023-12-04 09:55:50 +0000578 ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
Govindraj Raja0386e312023-08-17 10:41:48 -0500579 # Add "memtag" architecture feature modifier if not specified
580 ifeq ( ,$(findstring memtag,$(arch-features)))
581 arch-features := $(arch-features)+memtag
582 endif # memtag
Chris Kaycfba6452023-12-04 09:55:50 +0000583 ifeq ($($(ARCH)-cc-id),arm-clang)
Govindraj Raja0386e312023-08-17 10:41:48 -0500584 TF_CFLAGS += -mmemtag-stack
Chris Kaycfba6452023-12-04 09:55:50 +0000585 else ifeq ($($(ARCH)-cc-id),llvm-clang)
Govindraj Raja0386e312023-08-17 10:41:48 -0500586 TF_CFLAGS += -fsanitize=memtag
587 endif # armclang
588 endif
589 else
590 $(error "Error: stack memory tagging is not supported for \
591 architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
592 endif #(mem_tag_arch_support)
593endif #(SUPPORT_STACK_MEMTAG)
594
595################################################################################
596# RME dependent flags configuration, Enable optional features for RME.
597################################################################################
598# FEAT_RME
599ifeq (${ENABLE_RME},1)
600 # RME doesn't support PIE
601 ifneq (${ENABLE_PIE},0)
602 $(error ENABLE_RME does not support PIE)
603 endif
604
Govindraj Raja0386e312023-08-17 10:41:48 -0500605 # RME requires AARCH64
606 ifneq (${ARCH},aarch64)
607 $(error ENABLE_RME requires AArch64)
608 endif
609
610 # RME requires el2 context to be saved for now.
611 CTX_INCLUDE_EL2_REGS := 1
612 CTX_INCLUDE_AARCH32_REGS := 0
613 CTX_INCLUDE_PAUTH_REGS := 1
614
615 # RME enables CSV2_2 extension by default.
616 ENABLE_FEAT_CSV2_2 = 1
617endif #(FEAT_RME)
618
619################################################################################
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500620# Include rmmd Makefile if RME is enabled
621################################################################################
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500622ifneq (${ENABLE_RME},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100623 ifneq (${ARCH},aarch64)
624 $(error ENABLE_RME requires AArch64)
625 endif
626 ifeq ($(SPMC_AT_EL3),1)
627 $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
628 endif
629
630 ifneq (${SPD}, none)
631 ifneq (${SPD}, spmd)
632 $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd)
633 endif
634 endif
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500635include services/std_svc/rmmd/rmmd.mk
636$(warning "RME is an experimental feature")
637endif
638
Govindraj Raja1a211292023-09-20 14:32:24 -0500639ifeq (${CTX_INCLUDE_EL2_REGS}, 1)
640 ifeq (${SPD},none)
641 ifeq (${ENABLE_RME},0)
642 $(error CTX_INCLUDE_EL2_REGS is available only when SPD \
643 or RME is enabled)
644 endif
645 endif
646endif
Jon Medhurst66573cb2014-02-13 15:19:28 +0000647
Govindraj Raja69096412023-06-01 16:29:16 -0500648################################################################################
649# Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come
650# up with appropriate march values for compiler.
651################################################################################
652include ${MAKE_HELPERS_DIRECTORY}march.mk
653
654TF_CFLAGS += $(march-directive)
Govindraj Raja0c572472024-01-23 16:00:19 -0600655ASFLAGS += $(march-directive)
Govindraj Raja69096412023-06-01 16:29:16 -0500656
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600657# This internal flag is common option which is set to 1 for scenarios
658# when the BL2 is running in EL3 level. This occurs in two scenarios -
659# 4 world system running BL2 at EL3 and two world system without BL1 running
660# BL2 in EL3
661
662ifeq (${RESET_TO_BL2},1)
663 BL2_RUNS_AT_EL3 := 1
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100664 ifeq (${ENABLE_RME},1)
665 $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \
666 supported at the moment.)
667 endif
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600668else ifeq (${ENABLE_RME},1)
669 BL2_RUNS_AT_EL3 := 1
670else
671 BL2_RUNS_AT_EL3 := 0
672endif
673
Manish Pandeyf90a73c2023-10-10 15:42:19 +0100674# This internal flag is set to 1 when Firmware First handling of External aborts
675# is required by lowe ELs. Currently only NS requires this support.
676ifeq ($(HANDLE_EA_EL3_FIRST_NS),1)
677 FFH_SUPPORT := 1
678else
679 FFH_SUPPORT := 0
680endif
681
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100682ifeq (${ARM_ARCH_MAJOR},7)
683include make_helpers/armv7-a-cpus.mk
684endif
685
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900686PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT})
687ifneq ($(PIE_FOUND),)
688 TF_CFLAGS += -fno-PIE
Chris Kaycfba6452023-12-04 09:55:50 +0000689ifeq ($($(ARCH)-ld-id),gnu-gcc)
Samuel Holland9286c022022-04-08 21:56:02 -0500690 TF_LDFLAGS += -no-pie
691endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100692endif #(PIE_FOUND)
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900693
Chris Kaycfba6452023-12-04 09:55:50 +0000694ifeq ($($(ARCH)-ld-id),gnu-gcc)
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900695 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
Soby Mathew078f1a42018-08-28 11:13:55 +0100696else
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900697 PIE_LDFLAGS += -pie --no-dynamic-linker
698endif
699
700ifeq ($(ENABLE_PIE),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100701 ifeq ($(RESET_TO_BL2),1)
702 ifneq ($(BL2_IN_XIP_MEM),1)
703 BL2_CPPFLAGS += -fpie
704 BL2_CFLAGS += -fpie
705 BL2_LDFLAGS += $(PIE_LDFLAGS)
706 endif #(BL2_IN_XIP_MEM)
707 endif #(RESET_TO_BL2)
Chris Kay13886c82023-02-02 14:39:03 +0000708 BL31_CPPFLAGS += -fpie
709 BL31_CFLAGS += -fpie
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900710 BL31_LDFLAGS += $(PIE_LDFLAGS)
Chris Kay13886c82023-02-02 14:39:03 +0000711
712 BL32_CPPFLAGS += -fpie
Masahiro Yamadade634f82020-01-17 13:45:14 +0900713 BL32_CFLAGS += -fpie
714 BL32_LDFLAGS += $(PIE_LDFLAGS)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100715endif #(ENABLE_PIE)
Soby Mathew078f1a42018-08-28 11:13:55 +0100716
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000717BL1_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
718BL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
719BL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
720
Masahiro Yamadaf1441572020-04-01 14:20:58 +0900721BL1_CPPFLAGS += -DIMAGE_AT_EL3
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600722ifeq ($(RESET_TO_BL2),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100723 BL2_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamada003dd762020-03-26 13:18:48 +0900724else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100725 BL2_CPPFLAGS += -DIMAGE_AT_EL1
726endif #(RESET_TO_BL2)
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000727
728ifeq (${ARCH},aarch64)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100729 BL2U_CPPFLAGS += -DIMAGE_AT_EL1
730 BL31_CPPFLAGS += -DIMAGE_AT_EL3
731 BL32_CPPFLAGS += -DIMAGE_AT_EL1
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000732else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100733 BL32_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamada003dd762020-03-26 13:18:48 +0900734endif
735
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000736# Include the CPU specific operations makefile, which provides default
737# values for all CPU errata workarounds and CPU specific optimisations.
738# This can be overridden by the platform.
Soby Mathew937488b2014-09-22 14:13:34 +0100739include lib/cpus/cpu-ops.mk
Soby Mathew802f8652014-08-14 16:19:29 +0100740
dp-armcdd03cb2017-02-15 11:07:55 +0000741################################################################################
742# Build `AARCH32_SP` as BL32 image for AArch32
743################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100744ifeq (${ARCH},aarch32)
745 NEED_BL32 := yes
dp-armcdd03cb2017-02-15 11:07:55 +0000746
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100747 ifneq (${AARCH32_SP},none)
748 # We expect to locate an sp.mk under the specified AARCH32_SP directory
749 AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
dp-armcdd03cb2017-02-15 11:07:55 +0000750
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100751 ifeq (${AARCH32_SP_MAKE},)
752 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
753 endif
Juan Pablo Conde6aba3b12023-08-09 13:19:21 -0500754 $(info Including ${AARCH32_SP_MAKE})
755 include ${AARCH32_SP_MAKE}
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100756 endif
757endif #(ARCH=aarch32)
Varun Wadekar3f9002c2019-01-31 09:22:30 -0800758
759################################################################################
760# Include libc if not overridden
761################################################################################
762ifeq (${OVERRIDE_LIBC},0)
763include lib/libc/libc.mk
dp-armcdd03cb2017-02-15 11:07:55 +0000764endif
Juan Castilloa3487d12015-08-18 14:23:04 +0100765
766################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100767# Check incompatible options and dependencies
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000768################################################################################
769
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100770# USE_DEBUGFS experimental feature recommended only in debug builds
771ifeq (${USE_DEBUGFS},1)
772 ifeq (${DEBUG},1)
773 $(warning DEBUGFS experimental feature is enabled.)
774 else
775 $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
Qixiang Xube9bd9d2017-08-24 11:03:23 +0800776 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100777endif #(USE_DEBUGFS)
778
779# USE_SPINLOCK_CAS requires AArch64 build
780ifeq (${USE_SPINLOCK_CAS},1)
781 ifneq (${ARCH},aarch64)
782 $(error USE_SPINLOCK_CAS requires AArch64)
Qixiang Xube9bd9d2017-08-24 11:03:23 +0800783 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100784endif #(USE_SPINLOCK_CAS)
785
786# The cert_create tool cannot generate certificates individually, so we use the
787# target 'certificates' to create them all
788ifneq (${GENERATE_COT},0)
789 FIP_DEPS += certificates
790 FWU_FIP_DEPS += fwu_certificates
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000791endif
792
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100793ifneq (${DECRYPTION_SUPPORT},none)
794 ENC_ARGS += -f ${FW_ENC_STATUS}
795 ENC_ARGS += -k ${ENC_KEY}
796 ENC_ARGS += -n ${ENC_NONCE}
797 FIP_DEPS += enctool
798 FWU_FIP_DEPS += enctool
799endif #(DECRYPTION_SUPPORT)
800
801ifdef EL3_PAYLOAD_BASE
802 ifdef PRELOADED_BL33_BASE
803 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
804 incompatible build options. EL3_PAYLOAD_BASE has priority.")
805 endif
806 ifneq (${GENERATE_COT},0)
807 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \
808 build options.")
809 endif
810 ifneq (${TRUSTED_BOARD_BOOT},0)
811 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \
812 incompatible \ build options.")
813 endif
814endif #(EL3_PAYLOAD_BASE)
815
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000816ifeq (${NEED_BL33},yes)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100817 ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000818 $(warning "BL33 image is not needed when option \
819 BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100820 endif
821 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz2b8277b2016-04-06 17:31:57 +0100822 $(warning "BL33 image is not needed when option \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100823 PRELOADED_BL33_BASE is used and won't be added to the FIP file.")
824 endif
825endif #(NEED_BL33)
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000826
Jeenu Viswambharan7ed2cbc2017-01-06 16:14:42 +0000827# When building for systems with hardware-assisted coherency, there's no need to
828# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
829ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100830 $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
Jeenu Viswambharan7ed2cbc2017-01-06 16:14:42 +0000831endif
Yatharth Kocharf528faf2016-06-28 16:58:26 +0100832
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600833#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1.
834ifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100835 $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled")
Jiafei Pan43a7bf42018-03-21 07:20:09 +0000836endif
837
Manish Pandeyd419e222023-02-13 12:39:17 +0000838# RAS_EXTENSION is deprecated, provide alternate build options
Jeenu Viswambharan9a7ce2f2018-04-04 16:07:11 +0100839ifeq ($(RAS_EXTENSION),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100840 $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +0100841 and HANDLE_EA_EL3_FIRST_NS instead")
Manish Pandeyd419e222023-02-13 12:39:17 +0000842endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100843
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100844
Manish Pandeyd419e222023-02-13 12:39:17 +0000845# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled
Jeenu Viswambharanf00da742017-12-08 12:13:51 +0000846ifeq ($(FAULT_INJECTION_SUPPORT),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100847 ifeq ($(ENABLE_FEAT_RAS),0)
848 $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0)
849 endif
850endif #(FAULT_INJECTION_SUPPORT)
Jeenu Viswambharanf00da742017-12-08 12:13:51 +0000851
Roberto Vargas025946a2018-09-24 17:20:48 +0100852# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
Soby Mathew9fe88042018-03-26 12:43:37 +0100853ifeq ($(DYN_DISABLE_AUTH), 1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100854 ifeq (${TRUSTED_BOARD_BOOT}, 0)
855 $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \
856 to be set.")
857 endif
858endif #(DYN_DISABLE_AUTH)
Soby Mathew9fe88042018-03-26 12:43:37 +0100859
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100860ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
861# Support authentication verification and hash calculation
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100862 CRYPTO_SUPPORT := 3
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100863else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
864# Support authentication verification and hash calculation
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100865 CRYPTO_SUPPORT := 3
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100866else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
867# Support hash calculation only
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100868 CRYPTO_SUPPORT := 2
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100869else ifeq (${TRUSTED_BOARD_BOOT},1)
870# Support authentication verification only
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100871 CRYPTO_SUPPORT := 1
Manish V Badarkhe5181d602022-01-08 22:56:06 +0000872else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100873 CRYPTO_SUPPORT := 0
874endif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT))
Manish V Badarkhe5181d602022-01-08 22:56:06 +0000875
Balint Dobszayd0dbd5e2019-12-18 15:28:00 +0100876# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
877ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100878 $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
Manish V Badarkhead339892020-06-29 10:32:53 +0100879endif
880
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000881# If pointer authentication is used in the firmware, make sure that all the
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100882# registers associated to it are also saved and restored.
883# 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 +0000884ifeq ($(ENABLE_PAUTH),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100885 ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
886 $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
887 endif
888endif #(ENABLE_PAUTH)
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100889
890ifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100891 ifneq (${ARCH},aarch64)
892 $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
893 endif
894endif #(CTX_INCLUDE_PAUTH_REGS)
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000895
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +0000896ifeq ($(FEATURE_DETECTION),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100897 $(info FEATURE_DETECTION is an experimental feature)
898endif #(FEATURE_DETECTION)
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +0000899
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +0000900ifneq ($(ENABLE_SME2_FOR_NS), 0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100901 ifeq (${ENABLE_SME_FOR_NS}, 0)
902 $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \
903 to be set")
904 $(warning "Forced ENABLE_SME_FOR_NS=1")
905 override ENABLE_SME_FOR_NS := 1
906 endif
907endif #(ENABLE_SME2_FOR_NS)
Jayanth Dodderi Chidanand605419a2023-03-06 23:56:14 +0000908
Petre-Ionut Tudore5a6fef2019-11-07 15:18:03 +0000909ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100910 ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
911 $(error "ALLOW_RO_XLAT_TABLES requires translation tables \
912 library v2")
913 endif
914endif #(ARM_XLAT_TABLES_LIB_V1)
Petre-Ionut Tudore5a6fef2019-11-07 15:18:03 +0000915
Sumit Garg392e4df2019-11-15 10:43:00 +0530916ifneq (${DECRYPTION_SUPPORT},none)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100917 ifeq (${TRUSTED_BOARD_BOOT}, 0)
918 $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \
919 to be set)
920 endif
921endif #(DECRYPTION_SUPPORT)
Sumit Garg392e4df2019-11-15 10:43:00 +0530922
johpow0181865962022-01-28 17:06:20 -0600923# Ensure that no Aarch64-only features are enabled in Aarch32 build
johpow019baade32021-07-08 14:14:00 -0500924ifeq (${ARCH},aarch32)
johpow0181865962022-01-28 17:06:20 -0600925
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100926 # SME/SVE only supported on AArch64
927 ifneq (${ENABLE_SME_FOR_NS},0)
928 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
929 endif
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +0000930
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100931 ifeq (${ENABLE_SVE_FOR_NS},1)
932 # Warning instead of error due to CI dependency on this
933 $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
934 endif
johpow0181865962022-01-28 17:06:20 -0600935
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100936 # BRBE is not supported in AArch32
937 ifeq (${ENABLE_BRBE_FOR_NS},1)
938 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
939 endif
johpow0181865962022-01-28 17:06:20 -0600940
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100941 # FEAT_RNG_TRAP is not supported in AArch32
942 ifeq (${ENABLE_FEAT_RNG_TRAP},1)
943 $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
944 endif
945endif #(ARCH=aarch32)
johpow019baade32021-07-08 14:14:00 -0500946
Boyan Karatotev7f5dcc72023-03-08 16:29:26 +0000947ifneq (${ENABLE_SME_FOR_NS},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100948 ifeq (${ENABLE_SVE_FOR_NS},0)
949 $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS")
950 endif
951endif #(ENABLE_SME_FOR_NS)
Boyan Karatotev7f5dcc72023-03-08 16:29:26 +0000952
johpow019baade32021-07-08 14:14:00 -0500953# Secure SME/SVE requires the non-secure component as well
954ifeq (${ENABLE_SME_FOR_SWD},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100955 ifeq (${ENABLE_SME_FOR_NS},0)
956 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
957 endif
958 ifeq (${ENABLE_SVE_FOR_SWD},0)
959 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD")
960 endif
961endif #(ENABLE_SME_FOR_SWD)
962
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -0500963# Enabling SVE for SWD requires enabling SVE for NWD due to ENABLE_FEAT
964# mechanism.
johpow019baade32021-07-08 14:14:00 -0500965ifeq (${ENABLE_SVE_FOR_SWD},1)
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -0500966 ifeq (${ENABLE_SVE_FOR_NS},0)
967 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
968 endif
969endif
johpow019baade32021-07-08 14:14:00 -0500970
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -0500971# Enabling SVE for both the worlds typically requires the context
972# management of SVE registers. The only exception being SPMC at S-EL2.
973ifeq (${ENABLE_SVE_FOR_SWD}, 1)
974 ifneq (${ENABLE_SVE_FOR_NS}, 0)
975 ifeq (${CTX_INCLUDE_SVE_REGS}-$(SPMD_SPM_AT_SEL2),0-0)
976 $(warning "ENABLE_SVE_FOR_SWD and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
977 endif
978 endif
979endif
980
981# Enabling SVE in either world while enabling CTX_INCLUDE_FPREGS requires
982# CTX_INCLUDE_SVE_REGS to be enabled due to architectural dependency between FP
983# and SVE registers.
984ifeq (${CTX_INCLUDE_FPREGS}, 1)
985 ifneq (${ENABLE_SVE_FOR_NS},0)
986 ifeq (${CTX_INCLUDE_SVE_REGS},0)
987 # Warning instead of error due to CI dependency on this
988 $(warning "CTX_INCLUDE_FPREGS and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
989 $(warning "Forced ENABLE_SVE_FOR_NS=0")
990 override ENABLE_SVE_FOR_NS := 0
991 endif
992 endif
993endif #(CTX_INCLUDE_FPREGS)
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +0000994
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -0500995# SVE context management is only required if secure world has access to SVE/FP
996# functionality.
997ifeq (${CTX_INCLUDE_SVE_REGS},1)
998 ifeq (${ENABLE_SVE_FOR_SWD},0)
999 $(error "CTX_INCLUDE_SVE_REGS requires ENABLE_SVE_FOR_SWD to also be enabled")
1000 endif
1001endif
1002
1003# SME cannot be used with CTX_INCLUDE_FPREGS since SPM does its own context
1004# management including FPU registers.
1005ifeq (${CTX_INCLUDE_FPREGS},1)
1006 ifneq (${ENABLE_SME_FOR_NS},0)
1007 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1008 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001009endif #(CTX_INCLUDE_FPREGS)
johpow019baade32021-07-08 14:14:00 -05001010
Manish V Badarkhe191a5fc2022-03-02 12:06:35 +00001011ifeq ($(DRTM_SUPPORT),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001012 $(info DRTM_SUPPORT is an experimental feature)
Manish V Badarkhe191a5fc2022-03-02 12:06:35 +00001013endif
1014
Raymond Mao98983392023-07-25 07:53:35 -07001015ifeq (${TRANSFER_LIST},1)
1016 $(info TRANSFER_LIST is an experimental feature)
1017endif
1018
Chris Kayd02c2312022-09-29 16:21:24 +01001019ifeq (${ENABLE_RME},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001020 ifneq (${SEPARATE_CODE_AND_RODATA},1)
1021 $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
1022 endif
Chris Kayd02c2312022-09-29 16:21:24 +01001023endif
1024
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001025ifeq ($(PSA_CRYPTO),1)
1026 $(info PSA_CRYPTO is an experimental feature)
1027endif
1028
Manish V Badarkhed8d7d932024-05-09 12:14:13 +01001029ifeq ($(DICE_PROTECTION_ENVIRONMENT),1)
1030 $(info DICE_PROTECTION_ENVIRONMENT is an experimental feature)
1031endif
1032
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +00001033################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001034# Process platform overrideable behaviour
1035################################################################################
1036
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001037ifdef BL1_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001038 NEED_BL1 := yes
1039endif #(BL1_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001040
Jon Medhurst66573cb2014-02-13 15:19:28 +00001041ifdef BL2_SOURCES
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001042 NEED_BL2 := yes
1043
1044 # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
1045 # Certificate generation tools. This flag can be overridden by the platform.
1046 ifdef EL3_PAYLOAD_BASE
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001047 # If booting an EL3 payload there is no need for a BL33 image
1048 # in the FIP file.
1049 NEED_BL33 := no
1050 else
1051 ifdef PRELOADED_BL33_BASE
1052 # If booting a BL33 preloaded image there is no need of
1053 # another one in the FIP file.
1054 NEED_BL33 := no
1055 else
1056 NEED_BL33 ?= yes
1057 endif
1058 endif
1059endif #(BL2_SOURCES)
Achin Gupta4f6ad662013-10-25 09:08:21 +01001060
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001061ifdef BL2U_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001062 NEED_BL2U := yes
1063endif #(BL2U_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001064
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001065# If SCP_BL2 is given, we always want FIP to include it.
1066ifdef SCP_BL2
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001067 NEED_SCP_BL2 := yes
1068endif #(SCP_BL2)
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001069
Soby Mathewbf169232017-11-14 14:10:10 +00001070# For AArch32, BL31 is not currently supported.
1071ifneq (${ARCH},aarch32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001072 ifdef BL31_SOURCES
1073 # When booting an EL3 payload, there is no need to compile the BL31
1074 # image nor put it in the FIP.
1075 ifndef EL3_PAYLOAD_BASE
1076 NEED_BL31 := yes
1077 endif
1078 endif
1079endif #(ARCH=aarch64)
Soby Mathewbf169232017-11-14 14:10:10 +00001080
Juan Castilloa3487d12015-08-18 14:23:04 +01001081# Process TBB related flags
1082ifneq (${GENERATE_COT},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001083 # Common cert_create options
1084 ifneq (${CREATE_KEYS},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001085 $(eval CRT_ARGS += -n)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001086 $(eval FWU_CRT_ARGS += -n)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001087 ifneq (${SAVE_KEYS},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001088 $(eval CRT_ARGS += -k)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001089 $(eval FWU_CRT_ARGS += -k)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001090 endif
1091 endif
1092 # Include TBBR makefile (unless the platform indicates otherwise)
1093 ifeq (${INCLUDE_TBBR_MK},1)
Juan Castilloa3487d12015-08-18 14:23:04 +01001094 include make_helpers/tbbr/tbbr_tools.mk
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001095 endif
1096endif #(GENERATE_COT)
Achin Gupta4f6ad662013-10-25 09:08:21 +01001097
Masahiro Yamada4d87eb42016-12-25 13:52:22 +09001098ifneq (${FIP_ALIGN},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001099 FIP_ARGS += --align ${FIP_ALIGN}
1100endif #(FIP_ALIGN)
Masahiro Yamada4d87eb42016-12-25 13:52:22 +09001101
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001102ifdef FDT_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001103 NEED_FDT := yes
1104endif #(FDT_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001105
Juan Castilloa3487d12015-08-18 14:23:04 +01001106################################################################################
Michalis Pappas0f223c52018-03-20 13:01:27 +08001107# Include libraries' Makefile that are used in all BL
1108################################################################################
1109
1110include lib/stack_protector/stack_protector.mk
1111
1112################################################################################
Soby Mathew574e01e2017-02-14 10:05:07 +00001113# Include BL specific makefiles
1114################################################################################
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001115
1116ifeq (${NEED_BL1},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001117include bl1/bl1.mk
1118endif
1119
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001120ifeq (${NEED_BL2},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001121include bl2/bl2.mk
1122endif
1123
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001124ifeq (${NEED_BL2U},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001125include bl2u/bl2u.mk
1126endif
1127
Soby Mathewbf169232017-11-14 14:10:10 +00001128ifeq (${NEED_BL31},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001129include bl31/bl31.mk
1130endif
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001131
Soby Mathew574e01e2017-02-14 10:05:07 +00001132################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001133# Build options checks
1134################################################################################
1135
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001136# Boolean_Flags
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001137$(eval $(call assert_booleans,\
1138 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001139 ALLOW_RO_XLAT_TABLES \
1140 BL2_ENABLE_SP_LOAD \
1141 COLD_BOOT_SINGLE_CPU \
1142 CREATE_KEYS \
1143 CTX_INCLUDE_AARCH32_REGS \
1144 CTX_INCLUDE_FPREGS \
Madhukar Pappireddydd9af9b2024-06-17 15:17:03 -05001145 CTX_INCLUDE_SVE_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001146 CTX_INCLUDE_EL2_REGS \
Arvind Ram Prakash4851b492023-10-06 14:35:21 -05001147 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001148 DEBUG \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001149 DYN_DISABLE_AUTH \
1150 EL3_EXCEPTION_HANDLING \
1151 ENABLE_AMU_AUXILIARY_COUNTERS \
1152 ENABLE_AMU_FCONF \
1153 AMU_RESTRICT_COUNTERS \
1154 ENABLE_ASSERTIONS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001155 ENABLE_PIE \
1156 ENABLE_PMF \
1157 ENABLE_PSCI_STAT \
1158 ENABLE_RUNTIME_INSTRUMENTATION \
1159 ENABLE_SME_FOR_SWD \
1160 ENABLE_SVE_FOR_SWD \
Manish Pandey514a3012023-10-10 13:53:25 +01001161 ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +01001162 FFH_SUPPORT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001163 ERROR_DEPRECATED \
1164 FAULT_INJECTION_SUPPORT \
1165 GENERATE_COT \
1166 GICV2_G0_FOR_EL3 \
1167 HANDLE_EA_EL3_FIRST_NS \
Bipin Ravie53e6ae2023-09-28 13:17:24 -05001168 HARDEN_SLS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001169 HW_ASSISTED_COHERENCY \
1170 MEASURED_BOOT \
Tamas Bana4260892023-06-07 13:35:04 +02001171 DICE_PROTECTION_ENVIRONMENT \
Raghu Krishnamurthyc11b60e2024-06-03 19:02:29 -07001172 RMMD_ENABLE_EL3_TOKEN_SIGN \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001173 DRTM_SUPPORT \
1174 NS_TIMER_SWITCH \
1175 OVERRIDE_LIBC \
1176 PL011_GENERIC_UART \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001177 PROGRAMMABLE_RESET_ADDRESS \
1178 PSCI_EXTENDED_STATE_ID \
1179 PSCI_OS_INIT_MODE \
1180 RESET_TO_BL31 \
1181 SAVE_KEYS \
1182 SEPARATE_CODE_AND_RODATA \
1183 SEPARATE_BL2_NOLOAD_REGION \
1184 SEPARATE_NOBITS_REGION \
Madhukar Pappireddy5c1b8d92024-06-17 15:26:00 -05001185 SEPARATE_SIMD_SECTION \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001186 SPIN_ON_BL1_EXIT \
1187 SPM_MM \
1188 SPMC_AT_EL3 \
Nishant Sharma9e719112023-06-27 00:36:01 +01001189 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001190 SPMD_SPM_AT_SEL2 \
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -08001191 ENABLE_SPMD_LP \
Raymond Mao98983392023-07-25 07:53:35 -07001192 TRANSFER_LIST \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001193 TRUSTED_BOARD_BOOT \
1194 USE_COHERENT_MEM \
1195 USE_DEBUGFS \
1196 ARM_IO_IN_DTB \
1197 SDEI_IN_FCONF \
1198 SEC_INT_DESC_IN_FCONF \
1199 USE_ROMLIB \
1200 USE_TBBR_DEFS \
1201 WARMBOOT_ENABLE_DCACHE_EARLY \
1202 RESET_TO_BL2 \
1203 BL2_IN_XIP_MEM \
1204 BL2_INV_DCACHE \
1205 USE_SPINLOCK_CAS \
1206 ENCRYPT_BL31 \
1207 ENCRYPT_BL32 \
1208 ERRATA_SPECULATIVE_AT \
1209 RAS_TRAP_NS_ERR_REC_ACCESS \
1210 COT_DESC_IN_DTB \
1211 USE_SP804_TIMER \
1212 PSA_FWU_SUPPORT \
Sughosh Ganu61905e52024-02-01 12:51:20 +05301213 PSA_FWU_METADATA_FW_STORE_DESC \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001214 ENABLE_MPMM \
1215 ENABLE_MPMM_FCONF \
1216 FEATURE_DETECTION \
Jayanth Dodderi Chidanand7c7faff2022-10-11 17:16:07 +01001217 TRNG_SUPPORT \
Sona Mathew7fe03522022-11-18 18:05:38 -06001218 ERRATA_ABI_SUPPORT \
Sona Mathew5a4c9fc2023-03-14 14:02:03 -05001219 ERRATA_NON_ARM_INTERCONNECT \
Okash Khawaja037b56e2022-11-04 12:38:01 +00001220 CONDITIONAL_CMO \
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001221 PSA_CRYPTO \
Sandrine Bailleuxf57e2032023-10-11 08:38:00 +02001222 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash8bd27c92023-08-15 16:28:06 -05001223 INIT_UNUSED_NS_EL2 \
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001224 PLATFORM_REPORT_CTX_MEM_USE \
Yann Gautier5ae29c02024-01-16 19:39:31 +01001225 EARLY_CONSOLE \
Arvind Ram Prakasheaa90192023-12-21 00:25:52 -06001226 PRESERVE_DSU_PMU_REGS \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001227)))
Dan Handley81be1002015-03-27 17:44:35 +00001228
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001229# Numeric_Flags
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001230$(eval $(call assert_numerics,\
1231 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001232 ARM_ARCH_MAJOR \
1233 ARM_ARCH_MINOR \
1234 BRANCH_PROTECTION \
1235 CTX_INCLUDE_PAUTH_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001236 CTX_INCLUDE_NEVE_REGS \
1237 CRYPTO_SUPPORT \
Boyan Karatotev677ed8a2023-02-16 09:45:29 +00001238 DISABLE_MTPMU \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001239 ENABLE_BRBE_FOR_NS \
1240 ENABLE_TRBE_FOR_NS \
1241 ENABLE_BTI \
1242 ENABLE_PAUTH \
1243 ENABLE_FEAT_AMU \
1244 ENABLE_FEAT_AMUv1p1 \
1245 ENABLE_FEAT_CSV2_2 \
Sona Mathew3b84c962023-10-25 16:48:19 -05001246 ENABLE_FEAT_CSV2_3 \
Arvind Ram Prakash05b47632024-05-22 15:24:00 -05001247 ENABLE_FEAT_DEBUGV8P9 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001248 ENABLE_FEAT_DIT \
1249 ENABLE_FEAT_ECV \
1250 ENABLE_FEAT_FGT \
Arvind Ram Prakash62d87e72024-06-06 11:33:37 -05001251 ENABLE_FEAT_FGT2 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001252 ENABLE_FEAT_HCX \
Govindraj Rajad7b63ac2024-01-26 10:08:37 -06001253 ENABLE_FEAT_MTE2 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001254 ENABLE_FEAT_PAN \
1255 ENABLE_FEAT_RNG \
1256 ENABLE_FEAT_RNG_TRAP \
1257 ENABLE_FEAT_SEL2 \
1258 ENABLE_FEAT_TCR2 \
Jayanth Dodderi Chidanand6b706862024-09-05 22:24:04 +01001259 ENABLE_FEAT_THE \
Govindraj Rajac2dad572024-01-23 16:03:53 -06001260 ENABLE_FEAT_SB \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001261 ENABLE_FEAT_S2PIE \
1262 ENABLE_FEAT_S1PIE \
1263 ENABLE_FEAT_S2POE \
1264 ENABLE_FEAT_S1POE \
Jayanth Dodderi Chidanand70cc1752024-09-06 13:49:31 +01001265 ENABLE_FEAT_SCTLR2 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001266 ENABLE_FEAT_GCS \
1267 ENABLE_FEAT_VHE \
Arvind Ram Prakashab28d4b2023-10-11 12:10:56 -05001268 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001269 ENABLE_RME \
1270 ENABLE_SPE_FOR_NS \
1271 ENABLE_SYS_REG_TRACE_FOR_NS \
1272 ENABLE_SME_FOR_NS \
1273 ENABLE_SME2_FOR_NS \
1274 ENABLE_SVE_FOR_NS \
1275 ENABLE_TRF_FOR_NS \
1276 FW_ENC_STATUS \
1277 NR_OF_FW_BANKS \
1278 NR_OF_IMAGES_IN_FW_BANK \
1279 TWED_DELAY \
1280 ENABLE_FEAT_TWED \
1281 SVE_VECTOR_LEN \
Varun Wadekar0a46eb12023-04-13 21:06:18 +01001282 IMPDEF_SYSREG_TRAP \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001283)))
Jeenu Viswambharanfca76802017-01-16 16:52:35 +00001284
Justin Chadwellf9b32c12019-07-29 17:13:10 +01001285ifdef KEY_SIZE
1286 $(eval $(call assert_numeric,KEY_SIZE))
1287endif
1288
Justin Chadwell83e04882019-08-20 11:01:52 +01001289ifeq ($(filter $(SANITIZE_UB), on off trap),)
1290 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
1291endif
1292
Juan Castilloa3487d12015-08-18 14:23:04 +01001293################################################################################
1294# Add definitions to the cpp preprocessor based on the current build options.
1295# This is done after including the platform specific makefile to allow the
1296# platform to overwrite the default options
1297################################################################################
Jeenu Viswambharand1b60152014-05-12 15:28:47 +01001298
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001299$(eval $(call add_defines,\
1300 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001301 ALLOW_RO_XLAT_TABLES \
1302 ARM_ARCH_MAJOR \
1303 ARM_ARCH_MINOR \
1304 BL2_ENABLE_SP_LOAD \
1305 COLD_BOOT_SINGLE_CPU \
1306 CTX_INCLUDE_AARCH32_REGS \
1307 CTX_INCLUDE_FPREGS \
Madhukar Pappireddydd9af9b2024-06-17 15:17:03 -05001308 CTX_INCLUDE_SVE_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001309 CTX_INCLUDE_PAUTH_REGS \
Arvind Ram Prakash4851b492023-10-06 14:35:21 -05001310 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001311 EL3_EXCEPTION_HANDLING \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001312 CTX_INCLUDE_EL2_REGS \
1313 CTX_INCLUDE_NEVE_REGS \
1314 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
1315 DISABLE_MTPMU \
1316 ENABLE_FEAT_AMU \
1317 ENABLE_AMU_AUXILIARY_COUNTERS \
1318 ENABLE_AMU_FCONF \
1319 AMU_RESTRICT_COUNTERS \
1320 ENABLE_ASSERTIONS \
1321 ENABLE_BTI \
Arvind Ram Prakash05b47632024-05-22 15:24:00 -05001322 ENABLE_FEAT_DEBUGV8P9 \
Arvind Ram Prakashab28d4b2023-10-11 12:10:56 -05001323 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001324 ENABLE_PAUTH \
1325 ENABLE_PIE \
1326 ENABLE_PMF \
1327 ENABLE_PSCI_STAT \
1328 ENABLE_RME \
Raghu Krishnamurthyc11b60e2024-06-03 19:02:29 -07001329 RMMD_ENABLE_EL3_TOKEN_SIGN \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001330 ENABLE_RUNTIME_INSTRUMENTATION \
1331 ENABLE_SME_FOR_NS \
1332 ENABLE_SME2_FOR_NS \
1333 ENABLE_SME_FOR_SWD \
1334 ENABLE_SPE_FOR_NS \
1335 ENABLE_SVE_FOR_NS \
1336 ENABLE_SVE_FOR_SWD \
Manish Pandey514a3012023-10-10 13:53:25 +01001337 ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +01001338 FFH_SUPPORT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001339 ENCRYPT_BL31 \
1340 ENCRYPT_BL32 \
1341 ERROR_DEPRECATED \
1342 FAULT_INJECTION_SUPPORT \
1343 GICV2_G0_FOR_EL3 \
1344 HANDLE_EA_EL3_FIRST_NS \
1345 HW_ASSISTED_COHERENCY \
1346 LOG_LEVEL \
1347 MEASURED_BOOT \
Tamas Bana4260892023-06-07 13:35:04 +02001348 DICE_PROTECTION_ENVIRONMENT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001349 DRTM_SUPPORT \
1350 NS_TIMER_SWITCH \
1351 PL011_GENERIC_UART \
1352 PLAT_${PLAT} \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001353 PROGRAMMABLE_RESET_ADDRESS \
1354 PSCI_EXTENDED_STATE_ID \
1355 PSCI_OS_INIT_MODE \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001356 RESET_TO_BL31 \
AlexeiFedorovc0ca2d72024-05-13 15:35:54 +01001357 RME_GPT_BITLOCK_BLOCK \
AlexeiFedorovbd8b1bb2024-03-13 17:07:03 +00001358 RME_GPT_MAX_BLOCK \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001359 SEPARATE_CODE_AND_RODATA \
1360 SEPARATE_BL2_NOLOAD_REGION \
1361 SEPARATE_NOBITS_REGION \
Madhukar Pappireddy5c1b8d92024-06-17 15:26:00 -05001362 SEPARATE_SIMD_SECTION \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001363 RECLAIM_INIT_CODE \
1364 SPD_${SPD} \
1365 SPIN_ON_BL1_EXIT \
1366 SPM_MM \
1367 SPMC_AT_EL3 \
Nishant Sharma9e719112023-06-27 00:36:01 +01001368 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001369 SPMD_SPM_AT_SEL2 \
Raymond Mao98983392023-07-25 07:53:35 -07001370 TRANSFER_LIST \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001371 TRUSTED_BOARD_BOOT \
1372 CRYPTO_SUPPORT \
1373 TRNG_SUPPORT \
1374 ERRATA_ABI_SUPPORT \
Sona Mathew5a4c9fc2023-03-14 14:02:03 -05001375 ERRATA_NON_ARM_INTERCONNECT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001376 USE_COHERENT_MEM \
1377 USE_DEBUGFS \
1378 ARM_IO_IN_DTB \
1379 SDEI_IN_FCONF \
1380 SEC_INT_DESC_IN_FCONF \
1381 USE_ROMLIB \
1382 USE_TBBR_DEFS \
1383 WARMBOOT_ENABLE_DCACHE_EARLY \
1384 RESET_TO_BL2 \
1385 BL2_RUNS_AT_EL3 \
1386 BL2_IN_XIP_MEM \
1387 BL2_INV_DCACHE \
1388 USE_SPINLOCK_CAS \
1389 ERRATA_SPECULATIVE_AT \
1390 RAS_TRAP_NS_ERR_REC_ACCESS \
1391 COT_DESC_IN_DTB \
1392 USE_SP804_TIMER \
1393 ENABLE_FEAT_RNG \
1394 ENABLE_FEAT_RNG_TRAP \
1395 ENABLE_FEAT_SB \
1396 ENABLE_FEAT_DIT \
1397 NR_OF_FW_BANKS \
1398 NR_OF_IMAGES_IN_FW_BANK \
1399 PSA_FWU_SUPPORT \
Sughosh Ganu61905e52024-02-01 12:51:20 +05301400 PSA_FWU_METADATA_FW_STORE_DESC \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001401 ENABLE_BRBE_FOR_NS \
1402 ENABLE_TRBE_FOR_NS \
1403 ENABLE_SYS_REG_TRACE_FOR_NS \
1404 ENABLE_TRF_FOR_NS \
1405 ENABLE_FEAT_HCX \
1406 ENABLE_MPMM \
1407 ENABLE_MPMM_FCONF \
1408 ENABLE_FEAT_FGT \
Arvind Ram Prakash62d87e72024-06-06 11:33:37 -05001409 ENABLE_FEAT_FGT2 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001410 ENABLE_FEAT_ECV \
1411 ENABLE_FEAT_AMUv1p1 \
1412 ENABLE_FEAT_SEL2 \
1413 ENABLE_FEAT_VHE \
1414 ENABLE_FEAT_CSV2_2 \
Sona Mathew3b84c962023-10-25 16:48:19 -05001415 ENABLE_FEAT_CSV2_3 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001416 ENABLE_FEAT_PAN \
1417 ENABLE_FEAT_TCR2 \
Jayanth Dodderi Chidanand6b706862024-09-05 22:24:04 +01001418 ENABLE_FEAT_THE \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001419 ENABLE_FEAT_S2PIE \
1420 ENABLE_FEAT_S1PIE \
1421 ENABLE_FEAT_S2POE \
1422 ENABLE_FEAT_S1POE \
Jayanth Dodderi Chidanand70cc1752024-09-06 13:49:31 +01001423 ENABLE_FEAT_SCTLR2 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001424 ENABLE_FEAT_GCS \
Govindraj Rajad7b63ac2024-01-26 10:08:37 -06001425 ENABLE_FEAT_MTE2 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001426 FEATURE_DETECTION \
1427 TWED_DELAY \
1428 ENABLE_FEAT_TWED \
Okash Khawaja037b56e2022-11-04 12:38:01 +00001429 CONDITIONAL_CMO \
Varun Wadekar0a46eb12023-04-13 21:06:18 +01001430 IMPDEF_SYSREG_TRAP \
Jayanth Dodderi Chidanand23c2fe22023-04-26 15:57:30 +01001431 SVE_VECTOR_LEN \
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -08001432 ENABLE_SPMD_LP \
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001433 PSA_CRYPTO \
Sandrine Bailleuxf57e2032023-10-11 08:38:00 +02001434 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash8bd27c92023-08-15 16:28:06 -05001435 INIT_UNUSED_NS_EL2 \
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001436 PLATFORM_REPORT_CTX_MEM_USE \
Yann Gautier5ae29c02024-01-16 19:39:31 +01001437 EARLY_CONSOLE \
Arvind Ram Prakasheaa90192023-12-21 00:25:52 -06001438 PRESERVE_DSU_PMU_REGS \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001439)))
Jeenu Viswambharan615ff392016-10-24 14:31:51 +01001440
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001441ifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1)
1442ifeq (${DEBUG}, 0)
1443 $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only")
1444 override PLATFORM_REPORT_CTX_MEM_USE := 0
1445endif
1446endif
1447
Justin Chadwell83e04882019-08-20 11:01:52 +01001448ifeq (${SANITIZE_UB},trap)
1449 $(eval $(call add_define,MONITOR_TRAPS))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001450endif #(SANITIZE_UB)
Justin Chadwell83e04882019-08-20 11:01:52 +01001451
Sandrine Bailleux03897bb2015-11-26 16:31:34 +00001452# Define the EL3_PAYLOAD_BASE flag only if it is provided.
1453ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +00001454 $(eval $(call add_define,EL3_PAYLOAD_BASE))
1455else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001456# Define the PRELOADED_BL33_BASE flag only if it is provided and
1457# EL3_PAYLOAD_BASE is not defined, as it has priority.
1458 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz2b8277b2016-04-06 17:31:57 +01001459 $(eval $(call add_define,PRELOADED_BL33_BASE))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001460 endif
1461endif #(EL3_PAYLOAD_BASE)
Soby Mathew85dbf5a2015-04-07 12:16:56 +01001462
Soby Mathew9fe88042018-03-26 12:43:37 +01001463# Define the DYN_DISABLE_AUTH flag only if set.
1464ifeq (${DYN_DISABLE_AUTH},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001465 $(eval $(call add_define,DYN_DISABLE_AUTH))
Soby Mathew9fe88042018-03-26 12:43:37 +01001466endif
1467
Chris Kaycfba6452023-12-04 09:55:50 +00001468ifeq ($($(ARCH)-ld-id),arm-link)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001469 $(eval $(call add_define,USE_ARM_LINK))
Varun Wadekar4d034c52019-01-11 14:47:48 -08001470endif
1471
Manish Pandey3f90ad72020-01-14 11:52:05 +00001472# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
Manish Pandey3f90ad72020-01-14 11:52:05 +00001473ifeq (${SPD},spmd)
Olivier Deprez042db532020-03-19 09:27:11 +01001474ifdef SP_LAYOUT_FILE
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001475 -include $(BUILD_PLAT)/sp_gen.mk
1476 FIP_DEPS += sp
1477 CRT_DEPS += sp
1478 NEED_SP_PKG := yes
Manish Pandey3f90ad72020-01-14 11:52:05 +00001479else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001480 ifeq (${SPMD_SPM_AT_SEL2},1)
1481 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1482 endif
1483endif #(SP_LAYOUT_FILE)
1484endif #(SPD)
Manish Pandey3f90ad72020-01-14 11:52:05 +00001485
Juan Castilloa3487d12015-08-18 14:23:04 +01001486################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001487# Build targets
1488################################################################################
Achin Gupta4f6ad662013-10-25 09:08:21 +01001489
Harrison Mutai36d971a2024-08-28 13:27:19 +00001490.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp tl fwu_fip certtool dtbs memmap doc enctool
Juan Castilloa3487d12015-08-18 14:23:04 +01001491.SUFFIXES:
Achin Gupta4f6ad662013-10-25 09:08:21 +01001492
Juan Castilloa3487d12015-08-18 14:23:04 +01001493all: msg_start
Harry Liebelf58ad362014-01-10 18:00:33 +00001494
Juan Castilloa3487d12015-08-18 14:23:04 +01001495msg_start:
Chris Kay1870c722024-05-02 17:52:37 +00001496 $(s)echo "Building ${PLAT}"
Juan Castillo11abdcd2014-10-21 11:30:42 +01001497
Soby Mathew18a62042015-10-26 14:29:21 +00001498ifeq (${ERROR_DEPRECATED},0)
Julius Werner53456fc2019-07-09 13:49:11 -07001499# Check if deprecated declarations and cpp warnings should be treated as error or not.
Chris Kaycfba6452023-12-04 09:55:50 +00001500ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
Varun Wadekar4d034c52019-01-11 14:47:48 -08001501 CPPFLAGS += -Wno-error=deprecated-declarations
1502else
Dan Handley6fa89a22018-02-27 16:03:58 +00001503 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp
Soby Mathew18a62042015-10-26 14:29:21 +00001504endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001505endif #(!ERROR_DEPRECATED)
Soby Mathew18a62042015-10-26 14:29:21 +00001506
Roberto Vargas0f8f9852018-05-08 10:27:10 +01001507$(eval $(call MAKE_LIB,c))
Roberto Vargas21360f32018-05-08 10:27:10 +01001508
Juan Castilloa3487d12015-08-18 14:23:04 +01001509# Expand build macros for the different images
1510ifeq (${NEED_BL1},yes)
Chris Kay0a542ec2021-09-28 15:44:19 +01001511BL1_SOURCES := $(sort ${BL1_SOURCES})
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001512$(eval $(call MAKE_BL,bl1))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001513endif #(NEED_BL1)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001514
Juan Castilloa3487d12015-08-18 14:23:04 +01001515ifeq (${NEED_BL2},yes)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001516
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -06001517ifeq (${RESET_TO_BL2}, 0)
Roberto Vargas53c052b2018-01-02 11:23:41 +00001518FIP_BL2_ARGS := tb-fw
1519endif
1520
Chris Kayfb3b0512021-09-28 15:44:37 +01001521BL2_SOURCES := $(sort ${BL2_SOURCES})
1522
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001523$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001524 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001525
1526endif #(NEED_BL2)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001527
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001528ifeq (${NEED_SCP_BL2},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001529$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001530endif #(NEED_SCP_BL2)
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001531
Juan Castilloa3487d12015-08-18 14:23:04 +01001532ifeq (${NEED_BL31},yes)
1533BL31_SOURCES += ${SPD_SOURCES}
Madhukar Pappireddyae9677b2020-01-27 13:37:51 -06001534# Sort BL31 source files to remove duplicates
1535BL31_SOURCES := $(sort ${BL31_SOURCES})
Sumit Gargeec52442019-11-14 16:33:45 +05301536ifneq (${DECRYPTION_SUPPORT},none)
1537$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001538 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
Sumit Gargeec52442019-11-14 16:33:45 +05301539else
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001540$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001541 $(eval $(call MAKE_BL,bl31,soc-fw)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001542endif #(DECRYPTION_SUPPORT)
1543endif #(NEED_BL31)
Juan Castillo379954c2014-11-04 17:36:40 +00001544
Juan Castillo671b8db2015-11-12 10:59:26 +00001545# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
Masahiro Yamada4d156802018-01-26 11:42:01 +09001546# build system will call TOOL_ADD_IMG to print a warning message and abort the
Juan Castillo671b8db2015-11-12 10:59:26 +00001547# process. Note that the dependency on BL32 applies to the FIP only.
Juan Castilloa3487d12015-08-18 14:23:04 +01001548ifeq (${NEED_BL32},yes)
Madhukar Pappireddyae9677b2020-01-27 13:37:51 -06001549# Sort BL32 source files to remove duplicates
1550BL32_SOURCES := $(sort ${BL32_SOURCES})
Masahiro Yamada6ced1b22018-01-26 11:42:01 +09001551BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
1552
Sumit Gargeec52442019-11-14 16:33:45 +05301553ifneq (${DECRYPTION_SUPPORT},none)
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001554$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
Sumit Gargeec52442019-11-14 16:33:45 +05301555 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1556else
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001557$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001558 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001559endif #(DECRYPTION_SUPPORT)
1560endif #(NEED_BL32)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001561
Zelalem Aweke4d37db82021-07-11 18:33:20 -05001562# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
1563# needs to be built from RMM_SOURCES.
1564ifeq (${NEED_RMM},yes)
1565# Sort RMM source files to remove duplicates
1566RMM_SOURCES := $(sort ${RMM_SOURCES})
1567BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
1568
1569$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001570 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1571endif #(NEED_RMM)
Zelalem Aweke4d37db82021-07-11 18:33:20 -05001572
Juan Castilloa3487d12015-08-18 14:23:04 +01001573# Add the BL33 image if required by the platform
1574ifeq (${NEED_BL33},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001575$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001576endif #(NEED_BL33)
Juan Castillo9c25a402015-01-13 12:21:04 +00001577
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001578ifeq (${NEED_BL2U},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001579$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001580 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001581endif #(NEED_BL2U)
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001582
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001583# Expand build macros for the different images
1584ifeq (${NEED_FDT},yes)
Soby Mathewab4181d2017-12-14 17:44:56 +00001585 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001586endif #(NEED_FDT)
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001587
Manish Pandey3f90ad72020-01-14 11:52:05 +00001588# Add Secure Partition packages
1589ifeq (${NEED_SP_PKG},yes)
Chris Kayd67442e2024-07-30 13:33:56 +00001590$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | $$(@D)/
Chris Kay1870c722024-05-02 17:52:37 +00001591 $(q)${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
J-Alvesef8e0982022-03-22 16:28:51 +00001592sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
Chris Kay1870c722024-05-02 17:52:37 +00001593 $(s)echo
1594 $(s)echo "Built SP Images successfully"
1595 $(s)echo
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001596endif #(NEED_SP_PKG)
Manish Pandey3f90ad72020-01-14 11:52:05 +00001597
Ian Spray36eaaf32014-01-30 17:25:28 +00001598locate-checkpatch:
1599ifndef CHECKPATCH
Etienne Carrieref5657572017-08-23 15:44:01 +02001600 $(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 +00001601else
1602ifeq (,$(wildcard ${CHECKPATCH}))
Etienne Carrieref5657572017-08-23 15:44:01 +02001603 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
Ian Spray36eaaf32014-01-30 17:25:28 +00001604endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001605endif #(CHECKPATCH)
Ian Spray36eaaf32014-01-30 17:25:28 +00001606
Achin Gupta4f6ad662013-10-25 09:08:21 +01001607clean:
Chris Kay1870c722024-05-02 17:52:37 +00001608 $(s)echo " CLEAN"
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001609 $(call SHELL_REMOVE_DIR,${BUILD_PLAT})
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001610ifdef UNIX_MK
Chris Kay1870c722024-05-02 17:52:37 +00001611 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001612else
1613# Clear the MAKEFLAGS as we do not want
1614# to pass the gnumake flags to nmake.
Chris Kay1870c722024-05-02 17:52:37 +00001615 $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001616endif #(UNIX_MK)
Chris Kay1870c722024-05-02 17:52:37 +00001617 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
1618 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
1619 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001620
James Morrisseyeaaeece2013-11-01 13:56:59 +00001621realclean distclean:
Chris Kay1870c722024-05-02 17:52:37 +00001622 $(s)echo " REALCLEAN"
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001623 $(call SHELL_REMOVE_DIR,${BUILD_BASE})
1624 $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001625ifdef UNIX_MK
Chris Kay1870c722024-05-02 17:52:37 +00001626 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001627else
1628# Clear the MAKEFLAGS as we do not want
1629# to pass the gnumake flags to nmake.
Chris Kay1870c722024-05-02 17:52:37 +00001630 $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001631endif #(UNIX_MK)
Chris Kay1870c722024-05-02 17:52:37 +00001632 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
1633 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
1634 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001635
Ian Spray36eaaf32014-01-30 17:25:28 +00001636checkcodebase: locate-checkpatch
Chris Kay1870c722024-05-02 17:52:37 +00001637 $(s)echo " CHECKING STYLE"
1638 $(q)if test -d .git ; then \
Paul Beesleyadfab5b2019-03-07 16:42:31 +00001639 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \
Dan Handley3a355712016-06-02 18:21:02 +01001640 while read GIT_FILE ; \
1641 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
1642 done ; \
1643 else \
1644 find . -type f -not -iwholename "*.git*" \
1645 -not -iwholename "*build*" \
1646 -not -iwholename "*libfdt*" \
Roberto Vargas0f8f9852018-05-08 10:27:10 +01001647 -not -iwholename "*libc*" \
Dan Handley3a355712016-06-02 18:21:02 +01001648 -not -iwholename "*docs*" \
Paul Beesleyadfab5b2019-03-07 16:42:31 +00001649 -not -iwholename "*.rst" \
Dan Handley3a355712016-06-02 18:21:02 +01001650 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
1651 fi
Ian Spray36eaaf32014-01-30 17:25:28 +00001652
1653checkpatch: locate-checkpatch
Chris Kay1870c722024-05-02 17:52:37 +00001654 $(s)echo " CHECKING STYLE"
1655 $(q)if test -n "${CHECKPATCH_OPTS}"; then \
Yann Gautier0c26a2a2019-03-08 15:44:00 +01001656 echo " with ${CHECKPATCH_OPTS} option(s)"; \
1657 fi
Chris Kay1870c722024-05-02 17:52:37 +00001658 $(q)COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
Yann Gautiera10a6852021-11-02 18:03:31 +01001659 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \
1660 do \
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001661 printf "\n[*] Checking style of '$$commit'\n\n"; \
Yann Gautierfaf8c612024-08-09 11:52:03 +02001662 ( git log --format=email "$$commit~..$$commit" \
1663 -- ${CHECK_PATHS} ; \
1664 git diff --format=email "$$commit~..$$commit" \
1665 -- ${CHECK_PATHS}; ) | \
Yann Gautier0c26a2a2019-03-08 15:44:00 +01001666 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001667 done
Juan Castilloa3487d12015-08-18 14:23:04 +01001668
1669certtool: ${CRTTOOL}
Ian Spray36eaaf32014-01-30 17:25:28 +00001670
Pali Rohár54ff2132020-11-24 15:38:08 +01001671${CRTTOOL}: FORCE
Chris Kay1870c722024-05-02 17:52:37 +00001672 $(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
1673 $(s)echo
1674 $(s)echo "Built $@ successfully"
1675 $(s)echo
Jon Medhurst407a95c2014-02-12 15:54:48 +00001676
Juan Castillo11abdcd2014-10-21 11:30:42 +01001677ifneq (${GENERATE_COT},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001678certificates: ${CRT_DEPS} ${CRTTOOL}
Chris Kay1870c722024-05-02 17:52:37 +00001679 $(q)${CRTTOOL} ${CRT_ARGS}
1680 $(s)echo
1681 $(s)echo "Built $@ successfully"
1682 $(s)echo "Certificates can be found in ${BUILD_PLAT}"
1683 $(s)echo
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001684endif #(GENERATE_COT)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001685
Juan Castilloa3487d12015-08-18 14:23:04 +01001686${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
Pali Rohára5416ab2020-11-24 16:53:04 +01001687 $(eval ${CHECK_FIP_CMD})
Chris Kay1870c722024-05-02 17:52:37 +00001688 $(q)${FIPTOOL} create ${FIP_ARGS} $@
1689 $(q)${FIPTOOL} info $@
1690 $(s)echo
1691 $(s)echo "Built $@ successfully"
1692 $(s)echo
Soby Mathewdbee7fc2014-09-08 17:51:01 +01001693
Yatharth Kochard1a93432015-10-12 12:33:47 +01001694ifneq (${GENERATE_COT},0)
1695fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
Chris Kay1870c722024-05-02 17:52:37 +00001696 $(q)${CRTTOOL} ${FWU_CRT_ARGS}
1697 $(s)echo
1698 $(s)echo "Built $@ successfully"
1699 $(s)echo "FWU certificates can be found in ${BUILD_PLAT}"
1700 $(s)echo
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001701endif #(GENERATE_COT)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001702
1703${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
Pali Rohára5416ab2020-11-24 16:53:04 +01001704 $(eval ${CHECK_FWU_FIP_CMD})
Chris Kay1870c722024-05-02 17:52:37 +00001705 $(q)${FIPTOOL} create ${FWU_FIP_ARGS} $@
1706 $(q)${FIPTOOL} info $@
1707 $(s)echo
1708 $(s)echo "Built $@ successfully"
1709 $(s)echo
Yatharth Kochard1a93432015-10-12 12:33:47 +01001710
Juan Castilloa3487d12015-08-18 14:23:04 +01001711fiptool: ${FIPTOOL}
1712fip: ${BUILD_PLAT}/${FIP_NAME}
Yatharth Kochard1a93432015-10-12 12:33:47 +01001713fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
Harry Liebelf58ad362014-01-10 18:00:33 +00001714
Pali Rohár54ff2132020-11-24 15:38:08 +01001715${FIPTOOL}: FORCE
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001716ifdef UNIX_MK
Manish V Badarkhe0a5acd42024-10-03 20:50:04 +01001717 $(q)${MAKE} PLAT=${PLAT} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${FIPTOOLPATH} all
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001718else
1719# Clear the MAKEFLAGS as we do not want
1720# to pass the gnumake flags to nmake.
Chris Kay1870c722024-05-02 17:52:37 +00001721 $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001722endif #(UNIX_MK)
Harry Liebelf58ad362014-01-10 18:00:33 +00001723
Pali Rohár54ff2132020-11-24 15:38:08 +01001724romlib.bin: libraries FORCE
Chris Kay1870c722024-05-02 17:52:37 +00001725 $(q)${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES=$(call escape-shell,$(INCLUDES)) DEFINES=$(call escape-shell,$(DEFINES)) --no-print-directory -C ${ROMLIBPATH} all
Roberto Vargase92111a2018-05-22 16:05:42 +01001726
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +01001727memmap: all
Harrison Mutaie9bc4882023-02-23 10:33:58 +00001728ifdef UNIX_MK
Chris Kay1870c722024-05-02 17:52:37 +00001729 $(q)PYTHONPATH=${CURDIR}/tools/memory \
Harrison Mutaie9bc4882023-02-23 10:33:58 +00001730 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1731else
Chris Kay1870c722024-05-02 17:52:37 +00001732 $(q)set PYTHONPATH=${CURDIR}/tools/memory && \
Harrison Mutaie9bc4882023-02-23 10:33:58 +00001733 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1734endif
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +01001735
Harrison Mutai36d971a2024-08-28 13:27:19 +00001736tl: ${BUILD_PLAT}/tl.bin
1737${BUILD_PLAT}/tl.bin: ${HW_CONFIG}
Chris Kaya152e752024-09-26 14:18:04 +00001738 $(if $(host-poetry),$(q)poetry -q install)
1739 $(q)$(if $(host-poetry),poetry run )tlc create --fdt $< -s ${FW_HANDOFF_SIZE} $@
Harrison Mutai36d971a2024-08-28 13:27:19 +00001740
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -06001741doc:
Chris Kay1870c722024-05-02 17:52:37 +00001742 $(s)echo " BUILD DOCUMENTATION"
1743 $(q)${MAKE} --no-print-directory -C ${DOCS_PATH} html
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -06001744
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301745enctool: ${ENCTOOL}
1746
Pali Rohár54ff2132020-11-24 15:38:08 +01001747${ENCTOOL}: FORCE
Chris Kay1870c722024-05-02 17:52:37 +00001748 $(q)${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} --no-print-directory -C ${ENCTOOLPATH} all
1749 $(s)echo
1750 $(s)echo "Built $@ successfully"
1751 $(s)echo
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301752
Joakim Bech35fab8c2014-01-23 14:51:49 +01001753cscope:
Chris Kay1870c722024-05-02 17:52:37 +00001754 $(s)echo " CSCOPE"
1755 $(q)find ${CURDIR} -name "*.[chsS]" > cscope.files
1756 $(q)cscope -b -q -k
Joakim Bech35fab8c2014-01-23 14:51:49 +01001757
Ryan Harkin72ee3312014-01-15 16:55:07 +00001758help:
Chris Kay1870c722024-05-02 17:52:37 +00001759 $(s)echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
1760 $(s)echo ""
1761 $(s)echo "PLAT is used to specify which platform you wish to build."
1762 $(s)echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
1763 $(s)echo ""
1764 $(s)echo "platform = ${PLATFORM_LIST}"
1765 $(s)echo ""
1766 $(s)echo "Please refer to the User Guide for a list of all supported options."
1767 $(s)echo "Note that the build system doesn't track dependencies for build "
1768 $(s)echo "options. Therefore, if any of the build options are changed "
1769 $(s)echo "from a previous build, a clean build must be performed."
1770 $(s)echo ""
1771 $(s)echo "Supported Targets:"
1772 $(s)echo " all Build all individual bootloader binaries"
1773 $(s)echo " bl1 Build the BL1 binary"
1774 $(s)echo " bl2 Build the BL2 binary"
1775 $(s)echo " bl2u Build the BL2U binary"
1776 $(s)echo " bl31 Build the BL31 binary"
1777 $(s)echo " bl32 Build the BL32 binary. If ARCH=aarch32, then "
1778 $(s)echo " this builds secure payload specified by AARCH32_SP"
1779 $(s)echo " certificates Build the certificates (requires 'GENERATE_COT=1')"
1780 $(s)echo " fip Build the Firmware Image Package (FIP)"
1781 $(s)echo " fwu_fip Build the FWU Firmware Image Package (FIP)"
1782 $(s)echo " checkcodebase Check the coding style of the entire source tree"
1783 $(s)echo " checkpatch Check the coding style on changes in the current"
1784 $(s)echo " branch against BASE_COMMIT (default origin/master)"
1785 $(s)echo " clean Clean the build for the selected platform"
1786 $(s)echo " cscope Generate cscope index"
1787 $(s)echo " distclean Remove all build artifacts for all platforms"
1788 $(s)echo " certtool Build the Certificate generation tool"
1789 $(s)echo " enctool Build the Firmware encryption tool"
1790 $(s)echo " fiptool Build the Firmware Image Package (FIP) creation tool"
1791 $(s)echo " sp Build the Secure Partition Packages"
1792 $(s)echo " sptool Build the Secure Partition Package creation tool"
1793 $(s)echo " dtbs Build the Device Tree Blobs (if required for the platform)"
1794 $(s)echo " memmap Print the memory map of the built binaries"
1795 $(s)echo " doc Build html based documentation using Sphinx tool"
1796 $(s)echo ""
1797 $(s)echo "Note: most build targets require PLAT to be set to a specific platform."
1798 $(s)echo ""
1799 $(s)echo "example: build all targets for the FVP platform:"
1800 $(s)echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
Pali Rohár54ff2132020-11-24 15:38:08 +01001801
1802.PHONY: FORCE
1803FORCE:;