blob: b8e9e12d2a231fc96b92d6802c04e55cc2570436 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001#
Chris Kayfaab7482025-01-13 15:57:32 +00002# Copyright (c) 2013-2025, Arm Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003#
dp-armfa3cf0b2017-05-03 09:38:09 +01004# SPDX-License-Identifier: BSD-3-Clause
Achin Gupta4f6ad662013-10-25 09:08:21 +01005#
6
Jeenu Viswambharan19a0ace2014-05-15 14:40:58 +01007#
Juan Castillo04be3a52014-06-30 11:41:46 +01008# Trusted Firmware Version
9#
Soby Mathewd42eaee2018-10-01 16:16:34 +010010VERSION_MAJOR := 2
Govindraj Rajacf5f9802024-11-15 09:56:50 +010011VERSION_MINOR := 12
Yann Gautier5f4cbed2024-02-08 18:40:27 +010012# VERSION_PATCH is only used for LTS releases
13VERSION_PATCH := 0
Yann Gautier57078a92023-10-03 11:09:07 +020014VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
Juan Castillo04be3a52014-06-30 11:41:46 +010015
Juan Castillo396644b2015-10-22 11:34:44 +010016# Default goal is build all images
17.DEFAULT_GOAL := all
18
Douglas Raillard527cd902016-12-28 14:47:50 +000019# Avoid any implicit propagation of command line variable definitions to
20# sub-Makefiles, like CFLAGS that we reserved for the firmware images'
21# usage. Other command line options like "-s" are still propagated as usual.
22MAKEOVERRIDES =
23
Evan Lloydf2697142015-12-02 18:17:37 +000024MAKE_HELPERS_DIRECTORY := make_helpers/
25include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
Chris Kay1559f642024-06-04 00:04:48 +000026include ${MAKE_HELPERS_DIRECTORY}build-rules.mk
Chris Kay1870c722024-05-02 17:52:37 +000027include ${MAKE_HELPERS_DIRECTORY}common.mk
Juan Castilloa3487d12015-08-18 14:23:04 +010028
29################################################################################
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010030# Default values for build configurations, and their dependencies
Juan Castilloa3487d12015-08-18 14:23:04 +010031################################################################################
Jeenu Viswambharan19a0ace2014-05-15 14:40:58 +010032
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010033include ${MAKE_HELPERS_DIRECTORY}defaults.mk
Andrey Skvortsov89c3a142024-02-18 11:43:12 +030034include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
35
36# To be able to set platform specific defaults
37ifneq ($(PLAT_DEFAULTS_MAKEFILE_FULL),)
38include ${PLAT_DEFAULTS_MAKEFILE_FULL}
39endif
dp-arm3cac7862016-09-19 11:18:44 +010040
Chris Kayc8a47ba2023-10-20 09:17:33 +000041################################################################################
42# Configure the toolchains used to build TF-A and its tools
43################################################################################
44
45include ${MAKE_HELPERS_DIRECTORY}toolchain.mk
46
Antonio Nino Diaz808c2292017-04-18 15:16:05 +010047# Assertions enabled for DEBUG builds by default
Antonio Nino Diaz808c2292017-04-18 15:16:05 +010048ENABLE_ASSERTIONS := ${DEBUG}
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010049ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION}
Achin Gupta4f6ad662013-10-25 09:08:21 +010050
Juan Castilloa3487d12015-08-18 14:23:04 +010051################################################################################
52# Checkpatch script options
53################################################################################
54
Sandrine Bailleux0b5a1582016-06-02 11:19:59 +010055CHECKCODE_ARGS := --no-patch
Dan Handleyd7b59e42016-06-02 17:15:13 +010056# Do not check the coding style on imported library files or documentation files
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030057INC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \
58 include/drivers/arm, \
59 $(wildcard include/drivers/*)))
Dan Handleyd7b59e42016-06-02 17:15:13 +010060INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \
Dan Handley3a355712016-06-02 18:21:02 +010061 include/lib/libfdt \
Roberto Vargas0f8f9852018-05-08 10:27:10 +010062 include/lib/libc, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010063 $(wildcard include/lib/*)))
64INC_DIRS_TO_CHECK := $(sort $(filter-out \
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030065 include/lib \
66 include/drivers, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010067 $(wildcard include/*)))
68LIB_DIRS_TO_CHECK := $(sort $(filter-out \
dp-arme3cc8382017-05-04 12:15:35 +010069 lib/compiler-rt \
Antonio Nino Diazd84f88e2017-01-16 17:20:45 +000070 lib/libfdt% \
Roberto Vargas0f8f9852018-05-08 10:27:10 +010071 lib/libc, \
Daniel Boulby958f1dd2022-10-05 11:05:22 +010072 lib/zlib \
Dan Handleyd7b59e42016-06-02 17:15:13 +010073 $(wildcard lib/*)))
74ROOT_DIRS_TO_CHECK := $(sort $(filter-out \
75 lib \
76 include \
77 docs \
Paul Beesleyadfab5b2019-03-07 16:42:31 +000078 %.rst, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010079 $(wildcard *)))
80CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \
81 ${INC_DIRS_TO_CHECK} \
82 ${INC_LIB_DIRS_TO_CHECK} \
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030083 ${LIB_DIRS_TO_CHECK} \
84 ${INC_DRV_DIRS_TO_CHECK} \
85 ${INC_ARM_DIRS_TO_CHECK}
Ian Spray36eaaf32014-01-30 17:25:28 +000086
Juan Castilloa3487d12015-08-18 14:23:04 +010087################################################################################
88# Process build options
89################################################################################
90
Chris Kay1870c722024-05-02 17:52:37 +000091ifeq ($(verbose),)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +010092 CHECKCODE_ARGS += --no-summary --terse
Achin Gupta4f6ad662013-10-25 09:08:21 +010093endif
Andre Przywaracf2bb082018-09-27 10:56:05 +010094
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +010095################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +010096# Auxiliary tools (fiptool, cert_create, etc)
97################################################################################
98
99# Variables for use with Certificate Generation Tool
100CRTTOOLPATH ?= tools/cert_create
Chris Kayfaab7482025-01-13 15:57:32 +0000101CRTTOOL ?= ${CRTTOOLPATH}/cert_create$(.exe)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100102
103# Variables for use with Firmware Encryption Tool
104ENCTOOLPATH ?= tools/encrypt_fw
Chris Kayfaab7482025-01-13 15:57:32 +0000105ENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw$(.exe)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100106
107# Variables for use with Firmware Image Package
108FIPTOOLPATH ?= tools/fiptool
Chris Kayfaab7482025-01-13 15:57:32 +0000109FIPTOOL ?= ${FIPTOOLPATH}/fiptool$(.exe)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100110
111# Variables for use with sptool
112SPTOOLPATH ?= tools/sptool
113SPTOOL ?= ${SPTOOLPATH}/sptool.py
114SP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py
Karl Meakinaba46182023-02-14 11:56:02 +0000115SP_DTS_LIST_FRAGMENT ?= ${BUILD_PLAT}/sp_list_fragment.dts
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100116
117# Variables for use with ROMLIB
118ROMLIBPATH ?= lib/romlib
119
120# Variable for use with Python
121PYTHON ?= python3
122
123# Variables for use with documentation build using Sphinx tool
124DOCS_PATH ?= docs
125
126################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100127# Compiler Configuration based on ARCH_MAJOR and ARCH_MINOR flags
Juan Castilloa3487d12015-08-18 14:23:04 +0100128################################################################################
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100129ifeq (${ARM_ARCH_MAJOR},7)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100130 target32-directive = -target arm-none-eabi
Govindraj Rajacd10c6e2023-05-30 16:52:15 -0500131# Will set march-directive from platform configuration
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100132else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100133 target32-directive = -target armv8a-none-eabi
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100134endif #(ARM_ARCH_MAJOR)
135
136################################################################################
137# Get Architecture Feature Modifiers
138################################################################################
139arch-features = ${ARM_ARCH_FEATURE}
140
Chris Kaycfba6452023-12-04 09:55:50 +0000141ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
142 ifeq ($($(ARCH)-cc-id),arm-clang)
Govindraj Raja69096412023-06-01 16:29:16 -0500143 TF_CFLAGS_aarch32 := -target arm-arm-none-eabi
144 TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi
originfba80d82022-01-19 16:30:14 +0000145 else
Govindraj Raja69096412023-06-01 16:29:16 -0500146 TF_CFLAGS_aarch32 = $(target32-directive)
147 TF_CFLAGS_aarch64 := -target aarch64-elf
originfba80d82022-01-19 16:30:14 +0000148 endif
149
Chris Kaycfba6452023-12-04 09:55:50 +0000150else ifeq ($($(ARCH)-cc-id),gnu-gcc)
Chris Kay00416dc2024-02-20 16:19:54 +0000151 # Enable LTO only for aarch64
152 ifeq (${ARCH},aarch64)
153 LTO_CFLAGS = $(if $(filter-out 0,$(ENABLE_LTO)),-flto)
zelalem-aweked5f45272019-11-12 16:20:17 -0600154 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100155endif #(clang)
dp-arm320e8442017-05-02 12:00:08 +0100156
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100157# Process Debug flag
158$(eval $(call add_define,DEBUG))
159ifneq (${DEBUG}, 0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100160 BUILD_TYPE := debug
161 TF_CFLAGS += -g -gdwarf-4
162 ASFLAGS += -g -Wa,-gdwarf-4
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100163
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100164 # Use LOG_LEVEL_INFO by default for debug builds
165 LOG_LEVEL := 40
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100166else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100167 BUILD_TYPE := release
168 # Use LOG_LEVEL_NOTICE by default for release builds
169 LOG_LEVEL := 20
170endif #(Debug)
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100171
Peiyuan Song44f8f472020-04-25 16:53:43 +0800172# Default build string (git branch and commit)
173ifeq (${BUILD_STRING},)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100174 BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null)
Peiyuan Song44f8f472020-04-25 16:53:43 +0800175endif
laurenw-arme954f652022-07-12 10:12:05 -0500176VERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
Peiyuan Song44f8f472020-04-25 16:53:43 +0800177
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100178ifeq (${AARCH32_INSTRUCTION_SET},A32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100179 TF_CFLAGS_aarch32 += -marm
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100180else ifeq (${AARCH32_INSTRUCTION_SET},T32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100181 TF_CFLAGS_aarch32 += -mthumb
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100182else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100183 $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
184endif #(AARCH32_INSTRUCTION_SET)
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100185
Sandrine Bailleux1aa72ec2018-07-03 09:14:45 +0200186TF_CFLAGS_aarch32 += -mno-unaligned-access
dp-arm320e8442017-05-02 12:00:08 +0100187TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align
Soby Mathewa1941252016-05-05 14:33:33 +0100188
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100189##############################################################################
190# WARNINGS Configuration
191###############################################################################
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100192# General warnings
193WARNINGS := -Wall -Wmissing-include-dirs -Wunused \
Yann Gautier94a40b62021-05-20 13:18:14 +0200194 -Wdisabled-optimization -Wvla -Wshadow \
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000195 -Wredundant-decls
196# stricter warnings
197WARNINGS += -Wextra -Wno-trigraphs
198# too verbose for generic build
199WARNINGS += -Wno-missing-field-initializers \
200 -Wno-type-limits -Wno-sign-compare \
201# on clang this flag gets reset if -Wextra is set after it. No difference on gcc
202WARNINGS += -Wno-unused-parameter
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100203
204# Additional warnings
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000205# Level 1 - infrequent warnings we should have none of
206# full -Wextra
207WARNING1 += -Wsign-compare
208WARNING1 += -Wtype-limits
209WARNING1 += -Wmissing-field-initializers
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100210
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000211# Level 2 - problematic warnings that we want
212# zlib, compiler-rt, coreboot, and mbdedtls blow up with these
213# TODO: disable just for them and move into default build
214WARNING2 += -Wold-style-definition
215WARNING2 += -Wmissing-prototypes
216WARNING2 += -Wmissing-format-attribute
217# TF-A aims to comply with this eventually. Effort too large at present
218WARNING2 += -Wundef
Boyan Karatotev9c6ba592022-11-21 14:49:05 +0000219# currently very involved and many platforms set this off
220WARNING2 += -Wunused-const-variable=2
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100221
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000222# Level 3 - very pedantic, frequently ignored
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100223WARNING3 := -Wbad-function-cast
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000224WARNING3 += -Waggregate-return
225WARNING3 += -Wnested-externs
226WARNING3 += -Wcast-align
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100227WARNING3 += -Wcast-qual
228WARNING3 += -Wconversion
229WARNING3 += -Wpacked
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100230WARNING3 += -Wpointer-arith
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100231WARNING3 += -Wswitch-default
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100232
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000233# Setting W is quite verbose and most warnings will be pre-existing issues
234# outside of the contributor's control. Don't fail the build on them so warnings
235# can be seen and hopefully addressed
236ifdef W
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100237 ifneq (${W},0)
238 E ?= 0
239 endif
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000240endif
241
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100242ifeq (${W},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100243 WARNINGS += $(WARNING1)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100244else ifeq (${W},2)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100245 WARNINGS += $(WARNING1) $(WARNING2)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100246else ifeq (${W},3)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100247 WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
248endif #(W)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100249
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100250# Compiler specific warnings
Chris Kaycfba6452023-12-04 09:55:50 +0000251ifeq ($(filter %-clang,$($(ARCH)-cc-id)),)
Justin Chadwell7a914232019-07-03 14:15:56 +0100252# not using clang
Justin Chadwell42d18ca2019-09-18 14:13:42 +0100253WARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \
254 -Wpacked-bitfield-compat -Wshift-overflow=2 \
255 -Wlogical-op
Govindraj Rajaaa8ef3f2023-05-05 09:09:36 -0500256
257# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
Boyan Karatoteve9f127f2024-10-10 13:54:37 +0100258TF_CFLAGS_MIN_PAGE_SIZE := $(call cc_option, --param=min-pagesize=0)
259TF_CFLAGS += $(TF_CFLAGS_MIN_PAGE_SIZE)
Govindraj Rajaaa8ef3f2023-05-05 09:09:36 -0500260
Bipin Ravie53e6ae2023-09-28 13:17:24 -0500261ifeq ($(HARDEN_SLS), 1)
Boyan Karatoteve9f127f2024-10-10 13:54:37 +0100262 TF_CFLAGS_MHARDEN_SLS := $(call cc_option, -mharden-sls=all)
263 TF_CFLAGS_aarch64 += $(TF_CFLAGS_MHARDEN_SLS)
Bipin Ravie53e6ae2023-09-28 13:17:24 -0500264endif
265
Justin Chadwell7a914232019-07-03 14:15:56 +0100266else
267# using clang
Justin Chadwell42d18ca2019-09-18 14:13:42 +0100268WARNINGS += -Wshift-overflow -Wshift-sign-overflow \
269 -Wlogical-op-parentheses
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100270endif #(Clang Warning)
Ambroise Vincent067e4d92019-05-24 12:47:43 +0100271
Yann Gautier957c3532018-12-10 18:08:53 +0100272ifneq (${E},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100273 ERRORS := -Werror
274endif #(E)
Yann Gautier957c3532018-12-10 18:08:53 +0100275
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100276################################################################################
277# Compiler and Linker Directives
278################################################################################
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100279CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
280 $(ERRORS) $(WARNINGS)
Govindraj Rajacd10c6e2023-05-30 16:52:15 -0500281ASFLAGS += $(CPPFLAGS) \
Julius Werner53456fc2019-07-09 13:49:11 -0700282 -ffreestanding -Wa,--fatal-warnings
Masahiro Yamada0dec9fa2016-12-22 12:51:53 +0900283TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \
Samuel Holland23f5e542019-10-20 16:11:25 -0500284 -ffunction-sections -fdata-sections \
Boyan Karatoteva353fbf2024-12-09 08:24:12 +0000285 -ffreestanding -fno-common \
Samuel Holland23f5e542019-10-20 16:11:25 -0500286 -Os -std=gnu99
Juan Castilloa3487d12015-08-18 14:23:04 +0100287
Justin Chadwell83e04882019-08-20 11:01:52 +0100288ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100289 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover
290endif #(${SANITIZE_UB},on)
291
Justin Chadwell83e04882019-08-20 11:01:52 +0100292ifeq (${SANITIZE_UB},trap)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100293 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \
Justin Chadwell83e04882019-08-20 11:01:52 +0100294 -fsanitize-undefined-trap-on-error
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100295endif #(${SANITIZE_UB},trap)
Justin Chadwell83e04882019-08-20 11:01:52 +0100296
Chris Kay0adde4e2024-05-14 13:08:31 +0000297GCC_V_OUTPUT := $(if $($(ARCH)-cc),$(shell $($(ARCH)-cc) -v 2>&1))
david cunado34ab6092017-11-30 21:58:01 +0000298
Marco Felsch24ad8402022-11-09 12:59:09 +0100299TF_LDFLAGS += -z noexecstack
300
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100301# LD = armlink
Chris Kaycfba6452023-12-04 09:55:50 +0000302ifeq ($($(ARCH)-ld-id),arm-link)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100303 TF_LDFLAGS += --diag_error=warning --lto_level=O1
304 TF_LDFLAGS += --remove --info=unused,unusedsymbols
305 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100306
307# LD = gcc (used when GCC LTO is enabled)
Chris Kaycfba6452023-12-04 09:55:50 +0000308else ifeq ($($(ARCH)-ld-id),gnu-gcc)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100309 # Pass ld options with Wl or Xlinker switches
Chris Kayb0fe96f2024-01-16 11:53:35 +0000310 TF_LDFLAGS += $(call ld_option,-Xlinker --no-warn-rwx-segments)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100311 TF_LDFLAGS += -Wl,--fatal-warnings -O1
312 TF_LDFLAGS += -Wl,--gc-sections
Chris Kay73b1f402022-12-22 13:26:37 +0000313
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100314 TF_LDFLAGS += -Wl,-z,common-page-size=4096 #Configure page size constants
315 TF_LDFLAGS += -Wl,-z,max-page-size=4096
Andrey Skvortsove2ebb722023-09-05 23:06:29 +0300316 TF_LDFLAGS += -Wl,--build-id=none
Chris Kay73b1f402022-12-22 13:26:37 +0000317
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100318 ifeq ($(ENABLE_LTO),1)
319 ifeq (${ARCH},aarch64)
320 TF_LDFLAGS += -flto -fuse-linker-plugin
Andrey Skvortsov664d6502023-12-08 18:04:51 +0300321 TF_LDFLAGS += -flto-partition=one
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100322 endif
323 endif #(ENABLE_LTO)
324
zelalem-aweked5f45272019-11-12 16:20:17 -0600325# GCC automatically adds fix-cortex-a53-843419 flag when used to link
326# which breaks some builds, so disable if errata fix is not explicitly enabled
Yann Gautier3d73d162023-03-15 16:18:16 +0100327 ifeq (${ARCH},aarch64)
328 ifneq (${ERRATA_A53_843419},1)
329 TF_LDFLAGS += -mno-fix-cortex-a53-843419
330 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100331 endif
332 TF_LDFLAGS += -nostdlib
333 TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100334
335# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
Varun Wadekar4d034c52019-01-11 14:47:48 -0800336else
Marco Felsch24ad8402022-11-09 12:59:09 +0100337# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
338# are not loaded by a elf loader.
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100339 TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments)
340 TF_LDFLAGS += -O1
341 TF_LDFLAGS += --gc-sections
Chris Kay73b1f402022-12-22 13:26:37 +0000342
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100343 TF_LDFLAGS += -z common-page-size=4096 # Configure page size constants
344 TF_LDFLAGS += -z max-page-size=4096
Andrey Skvortsove2ebb722023-09-05 23:06:29 +0300345 TF_LDFLAGS += --build-id=none
Chris Kay73b1f402022-12-22 13:26:37 +0000346
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100347# ld.lld doesn't recognize the errata flags,
Yabin Cuied7dc512023-01-19 20:06:04 +0000348# therefore don't add those in that case.
349# ld.lld reports section type mismatch warnings,
350# therefore don't add --fatal-warnings to it.
Chris Kaycfba6452023-12-04 09:55:50 +0000351 ifneq ($($(ARCH)-ld-id),llvm-lld)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100352 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) --fatal-warnings
353 endif
354
355endif #(LD = armlink)
Juan Castilloa3487d12015-08-18 14:23:04 +0100356
357################################################################################
Govindraj Raja0386e312023-08-17 10:41:48 -0500358# Setup ARCH_MAJOR/MINOR before parsing arch_features.
359################################################################################
360ifeq (${ENABLE_RME},1)
AlexeiFedorov65258452024-03-13 11:53:44 +0000361 ARM_ARCH_MAJOR := 9
362 ARM_ARCH_MINOR := 2
Govindraj Raja0386e312023-08-17 10:41:48 -0500363endif
364
365################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +0100366# Common sources and include directories
367################################################################################
dp-arme3cc8382017-05-04 12:15:35 +0100368include lib/compiler-rt/compiler-rt.mk
Juan Castilloa3487d12015-08-18 14:23:04 +0100369
Chris Kay99b5b2e2024-03-08 16:08:31 +0000370# Allow overriding the timestamp, for example for reproducible builds, or to
371# synchronize timestamps across multiple projects.
372# This must be set to a C string (including quotes where applicable).
373BUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__
374
375DEFINES += -DBUILD_MESSAGE_TIMESTAMP='$(BUILD_MESSAGE_TIMESTAMP)'
376DEFINES += -DBUILD_MESSAGE_VERSION_STRING='"$(VERSION_STRING)"'
377DEFINES += -DBUILD_MESSAGE_VERSION='"$(VERSION)"'
378
Juan Castilloa3487d12015-08-18 14:23:04 +0100379BL_COMMON_SOURCES += common/bl_common.c \
Soby Mathewaaf15f52017-09-04 11:49:29 +0100380 common/tf_log.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100381 common/${ARCH}/debug.S \
Julius Werner03020da2018-11-27 22:10:56 -0800382 drivers/console/multi_console.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100383 lib/${ARCH}/cache_helpers.S \
384 lib/${ARCH}/misc_helpers.S \
Boyan Karatotev05504ba2023-02-15 13:21:50 +0000385 lib/extensions/pmuv3/${ARCH}/pmuv3.c \
Soby Mathew2f38ce32018-02-08 17:45:12 +0000386 plat/common/plat_bl_common.c \
Soby Mathewaaf15f52017-09-04 11:49:29 +0100387 plat/common/plat_log_common.c \
dp-arm230011c2017-03-07 11:02:47 +0000388 plat/common/${ARCH}/plat_common.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100389 plat/common/${ARCH}/platform_helpers.S \
Roberto Vargas0f8f9852018-05-08 10:27:10 +0100390 ${COMPILER_RT_SRCS}
Ryan Harkind7a6b0f2014-01-13 14:40:13 +0000391
Chris Kaycfba6452023-12-04 09:55:50 +0000392ifeq ($($(ARCH)-cc-id),arm-clang)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100393 BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S
Antonio Nino Diazeea20fc2018-08-16 15:42:44 +0100394endif
395
Justin Chadwell83e04882019-08-20 11:01:52 +0100396ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100397 BL_COMMON_SOURCES += plat/common/ubsan.c
Justin Chadwell83e04882019-08-20 11:01:52 +0100398endif
399
Yann Gautier2cf1dbc2018-06-18 16:00:23 +0200400INCLUDES += -Iinclude \
Antonio Nino Diaz8d1ade62018-12-17 17:20:57 +0000401 -Iinclude/arch/${ARCH} \
Antonio Nino Diaze0f90632018-12-14 00:18:21 +0000402 -Iinclude/lib/cpus/${ARCH} \
403 -Iinclude/lib/el3_runtime/${ARCH} \
404 ${PLAT_INCLUDES} \
405 ${SPD_INCLUDES}
406
Nishant Sharma331b5682022-08-15 16:37:07 +0100407DTC_FLAGS += -I dts -O dtb
408DTC_CPPFLAGS += -P -nostdinc $(INCLUDES) -Ifdts -undef \
409 -x assembler-with-cpp $(DEFINES)
410
Antonio Nino Diazc3a2cf22018-11-19 11:48:30 +0000411include common/backtrace/backtrace.mk
412
Juan Castilloa3487d12015-08-18 14:23:04 +0100413################################################################################
Govindraj Raja1a211292023-09-20 14:32:24 -0500414# Generic definitions
415################################################################################
Govindraj Raja1a211292023-09-20 14:32:24 -0500416
417ifeq (${BUILD_BASE},)
418 BUILD_BASE := ./build
419endif
420BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
421
422SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
423
424# Platforms providing their own TBB makefile may override this value
425INCLUDE_TBBR_MK := 1
426
427################################################################################
428# Include SPD Makefile if one has been specified
429################################################################################
430
431ifneq (${SPD},none)
432 ifeq (${ARCH},aarch32)
433 $(error "Error: SPD is incompatible with AArch32.")
434 endif
435
436 ifdef EL3_PAYLOAD_BASE
437 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
438 $(warning "The SPD and its BL32 companion will be present but \
439 ignored.")
440 endif
441
442 ifeq (${SPD},spmd)
443 # SPMD is located in std_svc directory
444 SPD_DIR := std_svc
445
446 ifeq ($(SPMD_SPM_AT_SEL2),1)
447 CTX_INCLUDE_EL2_REGS := 1
448 ifeq ($(SPMC_AT_EL3),1)
449 $(error SPM cannot be enabled in both S-EL2 and EL3.)
450 endif
Madhukar Pappireddy7503cdc2024-04-25 23:01:00 -0500451 ifeq ($(CTX_INCLUDE_SVE_REGS),1)
452 $(error SVE context management not needed with Hafnium SPMC.)
453 endif
Govindraj Raja1a211292023-09-20 14:32:24 -0500454 endif
455
456 ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
457 DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG
458 endif
459
Arunachalam Ganapathyfd29d582022-04-11 14:36:54 +0100460 ifeq ($(findstring trusty_sp,$(ARM_SPMC_MANIFEST_DTS)),trusty_sp)
461 DTC_CPPFLAGS += -DTRUSTY_SP_FW_CONFIG
462 endif
463
Govindraj Raja1a211292023-09-20 14:32:24 -0500464 ifeq ($(TS_SP_FW_CONFIG),1)
Arunachalam Ganapathyfd29d582022-04-11 14:36:54 +0100465 DTC_CPPFLAGS += -DTS_SP_FW_CONFIG
Govindraj Raja1a211292023-09-20 14:32:24 -0500466 endif
467
468 ifneq ($(ARM_BL2_SP_LIST_DTS),)
469 DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
470 endif
471
472 ifneq ($(SP_LAYOUT_FILE),)
473 BL2_ENABLE_SP_LOAD := 1
474 endif
Govindraj Rajabad835a2023-10-31 14:48:11 -0500475
476 ifeq ($(SPMC_AT_EL3_SEL0_SP),1)
477 ifneq ($(SPMC_AT_EL3),1)
478 $(error SEL0 SP cannot be enabled without SPMC at EL3)
479 endif
480 endif
Govindraj Raja1a211292023-09-20 14:32:24 -0500481 else
482 # All other SPDs in spd directory
483 SPD_DIR := spd
484 endif #(SPD)
485
486 # We expect to locate an spd.mk under the specified SPD directory
487 SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
488
489 ifeq (${SPD_MAKE},)
490 $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
491 endif
492 $(info Including ${SPD_MAKE})
493 include ${SPD_MAKE}
494
495 # If there's BL32 companion for the chosen SPD, we expect that the SPD's
496 # Makefile would set NEED_BL32 to "yes". In this case, the build system
497 # supports two mutually exclusive options:
498 # * BL32 is built from source: then BL32_SOURCES must contain the list
499 # of source files to build BL32
500 # * BL32 is a prebuilt binary: then BL32 must point to the image file
501 # that will be included in the FIP
502 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
503 # over the sources.
504endif #(SPD=none)
505
506ifeq (${ENABLE_SPMD_LP}, 1)
507ifneq (${SPD},spmd)
508 $(error Error: ENABLE_SPMD_LP requires SPD=spmd.)
509endif
510ifeq ($(SPMC_AT_EL3),1)
511 $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.)
512endif
513endif
514
515################################################################################
Olivier Deprez4b467722025-01-03 13:38:50 +0100516# Include the platform specific Makefile after the SPD Makefile (the platform
517# makefile may use all previous definitions in this file)
518################################################################################
519include ${PLAT_MAKEFILE_FULL}
520
521################################################################################
Govindraj Raja0386e312023-08-17 10:41:48 -0500522# Process BRANCH_PROTECTION value and set
523# Pointer Authentication and Branch Target Identification flags
524################################################################################
525ifeq (${BRANCH_PROTECTION},0)
526 # Default value turns off all types of branch protection
527 BP_OPTION := none
528else ifneq (${ARCH},aarch64)
529 $(error BRANCH_PROTECTION requires AArch64)
530else ifeq (${BRANCH_PROTECTION},1)
531 # Enables all types of branch protection features
532 BP_OPTION := standard
533 ENABLE_BTI := 1
534 ENABLE_PAUTH := 1
535else ifeq (${BRANCH_PROTECTION},2)
536 # Return address signing to its standard level
537 BP_OPTION := pac-ret
538 ENABLE_PAUTH := 1
539else ifeq (${BRANCH_PROTECTION},3)
540 # Extend the signing to include leaf functions
541 BP_OPTION := pac-ret+leaf
542 ENABLE_PAUTH := 1
543else ifeq (${BRANCH_PROTECTION},4)
544 # Turn on branch target identification mechanism
545 BP_OPTION := bti
546 ENABLE_BTI := 1
547else
548 $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
549endif #(BRANCH_PROTECTION)
550
551ifeq ($(ENABLE_PAUTH),1)
552 CTX_INCLUDE_PAUTH_REGS := 1
553endif
554ifneq (${BP_OPTION},none)
555 TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION}
556endif #(BP_OPTION)
557
558# Pointer Authentication sources
559ifeq (${ENABLE_PAUTH}, 1)
560# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the
561# Pauth support. As it's not secure, it must be reimplemented for real platforms
562 BL_COMMON_SOURCES += lib/extensions/pauth/pauth_helpers.S
563endif
564
Govindraj Raja1a211292023-09-20 14:32:24 -0500565################################################################################
Govindraj Raja1a211292023-09-20 14:32:24 -0500566# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from
567# platform.
568################################################################################
569include ${MAKE_HELPERS_DIRECTORY}arch_features.mk
570
Govindraj Raja0386e312023-08-17 10:41:48 -0500571####################################################
572# Enable required options for Memory Stack Tagging.
573####################################################
574
575# Currently, these options are enabled only for clang and armclang compiler.
576ifeq (${SUPPORT_STACK_MEMTAG},yes)
577 ifdef mem_tag_arch_support
578 # Check for armclang and clang compilers
Chris Kaycfba6452023-12-04 09:55:50 +0000579 ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
Govindraj Raja0386e312023-08-17 10:41:48 -0500580 # Add "memtag" architecture feature modifier if not specified
581 ifeq ( ,$(findstring memtag,$(arch-features)))
582 arch-features := $(arch-features)+memtag
583 endif # memtag
Chris Kaycfba6452023-12-04 09:55:50 +0000584 ifeq ($($(ARCH)-cc-id),arm-clang)
Govindraj Raja0386e312023-08-17 10:41:48 -0500585 TF_CFLAGS += -mmemtag-stack
Chris Kaycfba6452023-12-04 09:55:50 +0000586 else ifeq ($($(ARCH)-cc-id),llvm-clang)
Govindraj Raja0386e312023-08-17 10:41:48 -0500587 TF_CFLAGS += -fsanitize=memtag
588 endif # armclang
589 endif
590 else
591 $(error "Error: stack memory tagging is not supported for \
592 architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
593 endif #(mem_tag_arch_support)
594endif #(SUPPORT_STACK_MEMTAG)
595
596################################################################################
597# RME dependent flags configuration, Enable optional features for RME.
598################################################################################
599# FEAT_RME
600ifeq (${ENABLE_RME},1)
Govindraj Raja0386e312023-08-17 10:41:48 -0500601 # RME requires AARCH64
602 ifneq (${ARCH},aarch64)
603 $(error ENABLE_RME requires AArch64)
604 endif
605
606 # RME requires el2 context to be saved for now.
607 CTX_INCLUDE_EL2_REGS := 1
608 CTX_INCLUDE_AARCH32_REGS := 0
609 CTX_INCLUDE_PAUTH_REGS := 1
610
611 # RME enables CSV2_2 extension by default.
612 ENABLE_FEAT_CSV2_2 = 1
613endif #(FEAT_RME)
614
615################################################################################
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500616# Include rmmd Makefile if RME is enabled
617################################################################################
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500618ifneq (${ENABLE_RME},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100619 ifneq (${ARCH},aarch64)
620 $(error ENABLE_RME requires AArch64)
621 endif
622 ifeq ($(SPMC_AT_EL3),1)
623 $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
624 endif
625
626 ifneq (${SPD}, none)
627 ifneq (${SPD}, spmd)
628 $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd)
629 endif
630 endif
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500631include services/std_svc/rmmd/rmmd.mk
632$(warning "RME is an experimental feature")
633endif
634
Govindraj Raja1a211292023-09-20 14:32:24 -0500635ifeq (${CTX_INCLUDE_EL2_REGS}, 1)
636 ifeq (${SPD},none)
637 ifeq (${ENABLE_RME},0)
638 $(error CTX_INCLUDE_EL2_REGS is available only when SPD \
639 or RME is enabled)
640 endif
641 endif
642endif
Jon Medhurst66573cb2014-02-13 15:19:28 +0000643
Govindraj Raja69096412023-06-01 16:29:16 -0500644################################################################################
Govindraj Rajae63794e2024-09-06 15:43:43 +0100645# Make 128-Bit sysreg read/writes availabe when FEAT_D128 is enabled.
646################################################################################
647ifneq (${ENABLE_FEAT_D128}, 0)
648 BL_COMMON_SOURCES += lib/extensions/sysreg128/sysreg128.S
649endif
650
651################################################################################
Govindraj Raja69096412023-06-01 16:29:16 -0500652# Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come
653# up with appropriate march values for compiler.
654################################################################################
655include ${MAKE_HELPERS_DIRECTORY}march.mk
656
657TF_CFLAGS += $(march-directive)
Govindraj Raja0c572472024-01-23 16:00:19 -0600658ASFLAGS += $(march-directive)
Govindraj Raja69096412023-06-01 16:29:16 -0500659
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600660# This internal flag is common option which is set to 1 for scenarios
661# when the BL2 is running in EL3 level. This occurs in two scenarios -
662# 4 world system running BL2 at EL3 and two world system without BL1 running
663# BL2 in EL3
664
665ifeq (${RESET_TO_BL2},1)
666 BL2_RUNS_AT_EL3 := 1
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100667 ifeq (${ENABLE_RME},1)
668 $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \
669 supported at the moment.)
670 endif
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600671else ifeq (${ENABLE_RME},1)
672 BL2_RUNS_AT_EL3 := 1
673else
674 BL2_RUNS_AT_EL3 := 0
675endif
676
Manish Pandeyf90a73c2023-10-10 15:42:19 +0100677# This internal flag is set to 1 when Firmware First handling of External aborts
678# is required by lowe ELs. Currently only NS requires this support.
679ifeq ($(HANDLE_EA_EL3_FIRST_NS),1)
680 FFH_SUPPORT := 1
681else
682 FFH_SUPPORT := 0
683endif
684
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100685ifeq (${ARM_ARCH_MAJOR},7)
686include make_helpers/armv7-a-cpus.mk
687endif
688
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900689PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT})
690ifneq ($(PIE_FOUND),)
691 TF_CFLAGS += -fno-PIE
Chris Kaycfba6452023-12-04 09:55:50 +0000692ifeq ($($(ARCH)-ld-id),gnu-gcc)
Samuel Holland9286c022022-04-08 21:56:02 -0500693 TF_LDFLAGS += -no-pie
694endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100695endif #(PIE_FOUND)
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900696
Chris Kaycfba6452023-12-04 09:55:50 +0000697ifeq ($($(ARCH)-ld-id),gnu-gcc)
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900698 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
Soby Mathew078f1a42018-08-28 11:13:55 +0100699else
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900700 PIE_LDFLAGS += -pie --no-dynamic-linker
701endif
702
703ifeq ($(ENABLE_PIE),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100704 ifeq ($(RESET_TO_BL2),1)
705 ifneq ($(BL2_IN_XIP_MEM),1)
706 BL2_CPPFLAGS += -fpie
707 BL2_CFLAGS += -fpie
708 BL2_LDFLAGS += $(PIE_LDFLAGS)
709 endif #(BL2_IN_XIP_MEM)
710 endif #(RESET_TO_BL2)
Chris Kay13886c82023-02-02 14:39:03 +0000711 BL31_CPPFLAGS += -fpie
712 BL31_CFLAGS += -fpie
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900713 BL31_LDFLAGS += $(PIE_LDFLAGS)
Chris Kay13886c82023-02-02 14:39:03 +0000714
715 BL32_CPPFLAGS += -fpie
Masahiro Yamadade634f82020-01-17 13:45:14 +0900716 BL32_CFLAGS += -fpie
717 BL32_LDFLAGS += $(PIE_LDFLAGS)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100718endif #(ENABLE_PIE)
Soby Mathew078f1a42018-08-28 11:13:55 +0100719
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000720BL1_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
721BL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
722BL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
723
Masahiro Yamadaf1441572020-04-01 14:20:58 +0900724BL1_CPPFLAGS += -DIMAGE_AT_EL3
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600725ifeq ($(RESET_TO_BL2),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100726 BL2_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamada003dd762020-03-26 13:18:48 +0900727else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100728 BL2_CPPFLAGS += -DIMAGE_AT_EL1
729endif #(RESET_TO_BL2)
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000730
731ifeq (${ARCH},aarch64)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100732 BL2U_CPPFLAGS += -DIMAGE_AT_EL1
733 BL31_CPPFLAGS += -DIMAGE_AT_EL3
734 BL32_CPPFLAGS += -DIMAGE_AT_EL1
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000735else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100736 BL32_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamada003dd762020-03-26 13:18:48 +0900737endif
738
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000739# Include the CPU specific operations makefile, which provides default
740# values for all CPU errata workarounds and CPU specific optimisations.
741# This can be overridden by the platform.
Soby Mathew937488b2014-09-22 14:13:34 +0100742include lib/cpus/cpu-ops.mk
Soby Mathew802f8652014-08-14 16:19:29 +0100743
dp-armcdd03cb2017-02-15 11:07:55 +0000744################################################################################
745# Build `AARCH32_SP` as BL32 image for AArch32
746################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100747ifeq (${ARCH},aarch32)
748 NEED_BL32 := yes
dp-armcdd03cb2017-02-15 11:07:55 +0000749
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100750 ifneq (${AARCH32_SP},none)
751 # We expect to locate an sp.mk under the specified AARCH32_SP directory
752 AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
dp-armcdd03cb2017-02-15 11:07:55 +0000753
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100754 ifeq (${AARCH32_SP_MAKE},)
755 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
756 endif
Juan Pablo Conde6aba3b12023-08-09 13:19:21 -0500757 $(info Including ${AARCH32_SP_MAKE})
758 include ${AARCH32_SP_MAKE}
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100759 endif
760endif #(ARCH=aarch32)
Varun Wadekar3f9002c2019-01-31 09:22:30 -0800761
762################################################################################
763# Include libc if not overridden
764################################################################################
765ifeq (${OVERRIDE_LIBC},0)
766include lib/libc/libc.mk
dp-armcdd03cb2017-02-15 11:07:55 +0000767endif
Juan Castilloa3487d12015-08-18 14:23:04 +0100768
769################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100770# Check incompatible options and dependencies
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000771################################################################################
772
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100773# USE_DEBUGFS experimental feature recommended only in debug builds
774ifeq (${USE_DEBUGFS},1)
775 ifeq (${DEBUG},1)
776 $(warning DEBUGFS experimental feature is enabled.)
777 else
778 $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
Qixiang Xube9bd9d2017-08-24 11:03:23 +0800779 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100780endif #(USE_DEBUGFS)
781
782# USE_SPINLOCK_CAS requires AArch64 build
783ifeq (${USE_SPINLOCK_CAS},1)
784 ifneq (${ARCH},aarch64)
785 $(error USE_SPINLOCK_CAS requires AArch64)
Qixiang Xube9bd9d2017-08-24 11:03:23 +0800786 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100787endif #(USE_SPINLOCK_CAS)
788
789# The cert_create tool cannot generate certificates individually, so we use the
790# target 'certificates' to create them all
791ifneq (${GENERATE_COT},0)
792 FIP_DEPS += certificates
793 FWU_FIP_DEPS += fwu_certificates
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000794endif
795
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100796ifneq (${DECRYPTION_SUPPORT},none)
797 ENC_ARGS += -f ${FW_ENC_STATUS}
798 ENC_ARGS += -k ${ENC_KEY}
799 ENC_ARGS += -n ${ENC_NONCE}
800 FIP_DEPS += enctool
801 FWU_FIP_DEPS += enctool
802endif #(DECRYPTION_SUPPORT)
803
804ifdef EL3_PAYLOAD_BASE
805 ifdef PRELOADED_BL33_BASE
806 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
807 incompatible build options. EL3_PAYLOAD_BASE has priority.")
808 endif
809 ifneq (${GENERATE_COT},0)
810 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \
811 build options.")
812 endif
813 ifneq (${TRUSTED_BOARD_BOOT},0)
814 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \
815 incompatible \ build options.")
816 endif
817endif #(EL3_PAYLOAD_BASE)
818
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000819ifeq (${NEED_BL33},yes)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100820 ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000821 $(warning "BL33 image is not needed when option \
822 BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100823 endif
824 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz2b8277b2016-04-06 17:31:57 +0100825 $(warning "BL33 image is not needed when option \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100826 PRELOADED_BL33_BASE is used and won't be added to the FIP file.")
827 endif
828endif #(NEED_BL33)
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000829
Jeenu Viswambharan7ed2cbc2017-01-06 16:14:42 +0000830# When building for systems with hardware-assisted coherency, there's no need to
831# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
832ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100833 $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
Jeenu Viswambharan7ed2cbc2017-01-06 16:14:42 +0000834endif
Yatharth Kocharf528faf2016-06-28 16:58:26 +0100835
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600836#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1.
837ifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100838 $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled")
Jiafei Pan43a7bf42018-03-21 07:20:09 +0000839endif
840
Manish Pandeyd419e222023-02-13 12:39:17 +0000841# RAS_EXTENSION is deprecated, provide alternate build options
Jeenu Viswambharan9a7ce2f2018-04-04 16:07:11 +0100842ifeq ($(RAS_EXTENSION),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100843 $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +0100844 and HANDLE_EA_EL3_FIRST_NS instead")
Manish Pandeyd419e222023-02-13 12:39:17 +0000845endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100846
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100847
Manish Pandeyd419e222023-02-13 12:39:17 +0000848# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled
Jeenu Viswambharanf00da742017-12-08 12:13:51 +0000849ifeq ($(FAULT_INJECTION_SUPPORT),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100850 ifeq ($(ENABLE_FEAT_RAS),0)
851 $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0)
852 endif
853endif #(FAULT_INJECTION_SUPPORT)
Jeenu Viswambharanf00da742017-12-08 12:13:51 +0000854
Roberto Vargas025946a2018-09-24 17:20:48 +0100855# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
Soby Mathew9fe88042018-03-26 12:43:37 +0100856ifeq ($(DYN_DISABLE_AUTH), 1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100857 ifeq (${TRUSTED_BOARD_BOOT}, 0)
858 $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \
859 to be set.")
860 endif
861endif #(DYN_DISABLE_AUTH)
Soby Mathew9fe88042018-03-26 12:43:37 +0100862
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100863ifeq ($(MEASURED_BOOT)-$(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 ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
867# Support authentication verification and hash calculation
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100868 CRYPTO_SUPPORT := 3
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100869else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
870# Support hash calculation only
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100871 CRYPTO_SUPPORT := 2
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100872else ifeq (${TRUSTED_BOARD_BOOT},1)
873# Support authentication verification only
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100874 CRYPTO_SUPPORT := 1
Manish V Badarkhe5181d602022-01-08 22:56:06 +0000875else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100876 CRYPTO_SUPPORT := 0
877endif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT))
Manish V Badarkhe5181d602022-01-08 22:56:06 +0000878
Manish V Badarkhe8cad2e12024-12-03 21:46:51 +0000879ifneq ($(filter 1 2 3,$(CRYPTO_SUPPORT)),)
880CRYPTO_LIB := $(BUILD_PLAT)/lib/libmbedtls.a
881endif
882
Balint Dobszayd0dbd5e2019-12-18 15:28:00 +0100883# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
884ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100885 $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
Manish V Badarkhead339892020-06-29 10:32:53 +0100886endif
887
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000888# If pointer authentication is used in the firmware, make sure that all the
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100889# registers associated to it are also saved and restored.
890# 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 +0000891ifeq ($(ENABLE_PAUTH),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100892 ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
893 $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
894 endif
895endif #(ENABLE_PAUTH)
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100896
897ifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100898 ifneq (${ARCH},aarch64)
899 $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
900 endif
901endif #(CTX_INCLUDE_PAUTH_REGS)
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000902
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +0000903ifeq ($(FEATURE_DETECTION),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100904 $(info FEATURE_DETECTION is an experimental feature)
905endif #(FEATURE_DETECTION)
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +0000906
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +0000907ifneq ($(ENABLE_SME2_FOR_NS), 0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100908 ifeq (${ENABLE_SME_FOR_NS}, 0)
909 $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \
910 to be set")
911 $(warning "Forced ENABLE_SME_FOR_NS=1")
912 override ENABLE_SME_FOR_NS := 1
913 endif
914endif #(ENABLE_SME2_FOR_NS)
Jayanth Dodderi Chidanand605419a2023-03-06 23:56:14 +0000915
Petre-Ionut Tudore5a6fef2019-11-07 15:18:03 +0000916ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100917 ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
918 $(error "ALLOW_RO_XLAT_TABLES requires translation tables \
919 library v2")
920 endif
921endif #(ARM_XLAT_TABLES_LIB_V1)
Petre-Ionut Tudore5a6fef2019-11-07 15:18:03 +0000922
Sumit Garg392e4df2019-11-15 10:43:00 +0530923ifneq (${DECRYPTION_SUPPORT},none)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100924 ifeq (${TRUSTED_BOARD_BOOT}, 0)
925 $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \
926 to be set)
927 endif
928endif #(DECRYPTION_SUPPORT)
Sumit Garg392e4df2019-11-15 10:43:00 +0530929
johpow0181865962022-01-28 17:06:20 -0600930# Ensure that no Aarch64-only features are enabled in Aarch32 build
johpow019baade32021-07-08 14:14:00 -0500931ifeq (${ARCH},aarch32)
johpow0181865962022-01-28 17:06:20 -0600932
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100933 # SME/SVE only supported on AArch64
934 ifneq (${ENABLE_SME_FOR_NS},0)
935 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
936 endif
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +0000937
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100938 ifeq (${ENABLE_SVE_FOR_NS},1)
939 # Warning instead of error due to CI dependency on this
940 $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
941 endif
johpow0181865962022-01-28 17:06:20 -0600942
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100943 # BRBE is not supported in AArch32
944 ifeq (${ENABLE_BRBE_FOR_NS},1)
945 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
946 endif
johpow0181865962022-01-28 17:06:20 -0600947
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100948 # FEAT_RNG_TRAP is not supported in AArch32
949 ifeq (${ENABLE_FEAT_RNG_TRAP},1)
950 $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
951 endif
Arvind Ram Prakashe558f9c2024-11-11 14:32:37 -0600952
953 ifneq (${ENABLE_FEAT_FPMR},0)
954 $(error "ENABLE_FEAT_FPMR cannot be used with ARCH=aarch32")
955 endif
Boyan Karatotev8e7c43c2024-10-25 11:38:41 +0100956
957 ifeq (${ARCH_FEATURE_AVAILABILITY},1)
958 $(error "ARCH_FEATURE_AVAILABILITY cannot be used with ARCH=aarch32")
959 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100960endif #(ARCH=aarch32)
johpow019baade32021-07-08 14:14:00 -0500961
Arvind Ram Prakashe558f9c2024-11-11 14:32:37 -0600962ifneq (${ENABLE_FEAT_FPMR},0)
963 ifeq (${ENABLE_FEAT_FGT},0)
964 $(error "ENABLE_FEAT_FPMR requires ENABLE_FEAT_FGT")
965 endif
966 ifeq (${ENABLE_FEAT_HCX},0)
967 $(error "ENABLE_FEAT_FPMR requires ENABLE_FEAT_HCX")
968 endif
969endif #(ENABLE_FEAT_FPMR)
970
Boyan Karatotev7f5dcc72023-03-08 16:29:26 +0000971ifneq (${ENABLE_SME_FOR_NS},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100972 ifeq (${ENABLE_SVE_FOR_NS},0)
973 $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS")
974 endif
975endif #(ENABLE_SME_FOR_NS)
Boyan Karatotev7f5dcc72023-03-08 16:29:26 +0000976
johpow019baade32021-07-08 14:14:00 -0500977# Secure SME/SVE requires the non-secure component as well
978ifeq (${ENABLE_SME_FOR_SWD},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100979 ifeq (${ENABLE_SME_FOR_NS},0)
980 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
981 endif
982 ifeq (${ENABLE_SVE_FOR_SWD},0)
983 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD")
984 endif
985endif #(ENABLE_SME_FOR_SWD)
986
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -0500987# Enabling SVE for SWD requires enabling SVE for NWD due to ENABLE_FEAT
988# mechanism.
johpow019baade32021-07-08 14:14:00 -0500989ifeq (${ENABLE_SVE_FOR_SWD},1)
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -0500990 ifeq (${ENABLE_SVE_FOR_NS},0)
991 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
992 endif
993endif
johpow019baade32021-07-08 14:14:00 -0500994
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -0500995# Enabling SVE for both the worlds typically requires the context
996# management of SVE registers. The only exception being SPMC at S-EL2.
997ifeq (${ENABLE_SVE_FOR_SWD}, 1)
998 ifneq (${ENABLE_SVE_FOR_NS}, 0)
999 ifeq (${CTX_INCLUDE_SVE_REGS}-$(SPMD_SPM_AT_SEL2),0-0)
1000 $(warning "ENABLE_SVE_FOR_SWD and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
1001 endif
1002 endif
1003endif
1004
1005# Enabling SVE in either world while enabling CTX_INCLUDE_FPREGS requires
1006# CTX_INCLUDE_SVE_REGS to be enabled due to architectural dependency between FP
1007# and SVE registers.
1008ifeq (${CTX_INCLUDE_FPREGS}, 1)
1009 ifneq (${ENABLE_SVE_FOR_NS},0)
1010 ifeq (${CTX_INCLUDE_SVE_REGS},0)
1011 # Warning instead of error due to CI dependency on this
1012 $(warning "CTX_INCLUDE_FPREGS and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
1013 $(warning "Forced ENABLE_SVE_FOR_NS=0")
1014 override ENABLE_SVE_FOR_NS := 0
1015 endif
1016 endif
1017endif #(CTX_INCLUDE_FPREGS)
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +00001018
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -05001019# SVE context management is only required if secure world has access to SVE/FP
1020# functionality.
1021ifeq (${CTX_INCLUDE_SVE_REGS},1)
1022 ifeq (${ENABLE_SVE_FOR_SWD},0)
1023 $(error "CTX_INCLUDE_SVE_REGS requires ENABLE_SVE_FOR_SWD to also be enabled")
1024 endif
1025endif
1026
1027# SME cannot be used with CTX_INCLUDE_FPREGS since SPM does its own context
1028# management including FPU registers.
1029ifeq (${CTX_INCLUDE_FPREGS},1)
1030 ifneq (${ENABLE_SME_FOR_NS},0)
1031 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1032 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001033endif #(CTX_INCLUDE_FPREGS)
johpow019baade32021-07-08 14:14:00 -05001034
Manish V Badarkhe191a5fc2022-03-02 12:06:35 +00001035ifeq ($(DRTM_SUPPORT),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001036 $(info DRTM_SUPPORT is an experimental feature)
Manish V Badarkhe191a5fc2022-03-02 12:06:35 +00001037endif
1038
Levi Yun03adb132024-05-13 10:24:31 +01001039ifeq (${HOB_LIST},1)
1040 $(warning HOB_LIST is an experimental feature)
1041endif
1042
Raymond Mao98983392023-07-25 07:53:35 -07001043ifeq (${TRANSFER_LIST},1)
1044 $(info TRANSFER_LIST is an experimental feature)
1045endif
1046
Chris Kayd02c2312022-09-29 16:21:24 +01001047ifeq (${ENABLE_RME},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001048 ifneq (${SEPARATE_CODE_AND_RODATA},1)
1049 $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
1050 endif
Chris Kayd02c2312022-09-29 16:21:24 +01001051endif
1052
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001053ifeq ($(PSA_CRYPTO),1)
1054 $(info PSA_CRYPTO is an experimental feature)
1055endif
1056
Manish V Badarkhed8d7d932024-05-09 12:14:13 +01001057ifeq ($(DICE_PROTECTION_ENVIRONMENT),1)
1058 $(info DICE_PROTECTION_ENVIRONMENT is an experimental feature)
1059endif
1060
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +00001061################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001062# Process platform overrideable behaviour
1063################################################################################
1064
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001065ifdef BL1_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001066 NEED_BL1 := yes
1067endif #(BL1_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001068
Jon Medhurst66573cb2014-02-13 15:19:28 +00001069ifdef BL2_SOURCES
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001070 NEED_BL2 := yes
1071
1072 # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
1073 # Certificate generation tools. This flag can be overridden by the platform.
1074 ifdef EL3_PAYLOAD_BASE
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001075 # If booting an EL3 payload there is no need for a BL33 image
1076 # in the FIP file.
1077 NEED_BL33 := no
1078 else
1079 ifdef PRELOADED_BL33_BASE
1080 # If booting a BL33 preloaded image there is no need of
1081 # another one in the FIP file.
1082 NEED_BL33 := no
1083 else
1084 NEED_BL33 ?= yes
1085 endif
1086 endif
1087endif #(BL2_SOURCES)
Achin Gupta4f6ad662013-10-25 09:08:21 +01001088
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001089ifdef BL2U_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001090 NEED_BL2U := yes
1091endif #(BL2U_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001092
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001093# If SCP_BL2 is given, we always want FIP to include it.
1094ifdef SCP_BL2
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001095 NEED_SCP_BL2 := yes
1096endif #(SCP_BL2)
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001097
Soby Mathewbf169232017-11-14 14:10:10 +00001098# For AArch32, BL31 is not currently supported.
1099ifneq (${ARCH},aarch32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001100 ifdef BL31_SOURCES
1101 # When booting an EL3 payload, there is no need to compile the BL31
1102 # image nor put it in the FIP.
1103 ifndef EL3_PAYLOAD_BASE
1104 NEED_BL31 := yes
1105 endif
1106 endif
1107endif #(ARCH=aarch64)
Soby Mathewbf169232017-11-14 14:10:10 +00001108
Juan Castilloa3487d12015-08-18 14:23:04 +01001109# Process TBB related flags
1110ifneq (${GENERATE_COT},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001111 # Common cert_create options
1112 ifneq (${CREATE_KEYS},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001113 $(eval CRT_ARGS += -n)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001114 $(eval FWU_CRT_ARGS += -n)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001115 ifneq (${SAVE_KEYS},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001116 $(eval CRT_ARGS += -k)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001117 $(eval FWU_CRT_ARGS += -k)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001118 endif
1119 endif
1120 # Include TBBR makefile (unless the platform indicates otherwise)
1121 ifeq (${INCLUDE_TBBR_MK},1)
Juan Castilloa3487d12015-08-18 14:23:04 +01001122 include make_helpers/tbbr/tbbr_tools.mk
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001123 endif
1124endif #(GENERATE_COT)
Achin Gupta4f6ad662013-10-25 09:08:21 +01001125
Masahiro Yamada4d87eb42016-12-25 13:52:22 +09001126ifneq (${FIP_ALIGN},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001127 FIP_ARGS += --align ${FIP_ALIGN}
1128endif #(FIP_ALIGN)
Masahiro Yamada4d87eb42016-12-25 13:52:22 +09001129
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001130ifdef FDT_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001131 NEED_FDT := yes
1132endif #(FDT_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001133
Juan Castilloa3487d12015-08-18 14:23:04 +01001134################################################################################
Michalis Pappas0f223c52018-03-20 13:01:27 +08001135# Include libraries' Makefile that are used in all BL
1136################################################################################
1137
1138include lib/stack_protector/stack_protector.mk
1139
1140################################################################################
Soby Mathew574e01e2017-02-14 10:05:07 +00001141# Include BL specific makefiles
1142################################################################################
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001143
1144ifeq (${NEED_BL1},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001145include bl1/bl1.mk
1146endif
1147
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001148ifeq (${NEED_BL2},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001149include bl2/bl2.mk
1150endif
1151
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001152ifeq (${NEED_BL2U},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001153include bl2u/bl2u.mk
1154endif
1155
Soby Mathewbf169232017-11-14 14:10:10 +00001156ifeq (${NEED_BL31},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001157include bl31/bl31.mk
1158endif
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001159
Soby Mathew574e01e2017-02-14 10:05:07 +00001160################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001161# Build options checks
1162################################################################################
1163
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001164# Boolean_Flags
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001165$(eval $(call assert_booleans,\
1166 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001167 ALLOW_RO_XLAT_TABLES \
1168 BL2_ENABLE_SP_LOAD \
1169 COLD_BOOT_SINGLE_CPU \
1170 CREATE_KEYS \
1171 CTX_INCLUDE_AARCH32_REGS \
1172 CTX_INCLUDE_FPREGS \
Madhukar Pappireddydd9af9b2024-06-17 15:17:03 -05001173 CTX_INCLUDE_SVE_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001174 CTX_INCLUDE_EL2_REGS \
Arvind Ram Prakash4851b492023-10-06 14:35:21 -05001175 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001176 DEBUG \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001177 DYN_DISABLE_AUTH \
1178 EL3_EXCEPTION_HANDLING \
1179 ENABLE_AMU_AUXILIARY_COUNTERS \
1180 ENABLE_AMU_FCONF \
1181 AMU_RESTRICT_COUNTERS \
1182 ENABLE_ASSERTIONS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001183 ENABLE_PIE \
1184 ENABLE_PMF \
1185 ENABLE_PSCI_STAT \
1186 ENABLE_RUNTIME_INSTRUMENTATION \
1187 ENABLE_SME_FOR_SWD \
1188 ENABLE_SVE_FOR_SWD \
Manish Pandey514a3012023-10-10 13:53:25 +01001189 ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +01001190 FFH_SUPPORT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001191 ERROR_DEPRECATED \
1192 FAULT_INJECTION_SUPPORT \
1193 GENERATE_COT \
1194 GICV2_G0_FOR_EL3 \
1195 HANDLE_EA_EL3_FIRST_NS \
Bipin Ravie53e6ae2023-09-28 13:17:24 -05001196 HARDEN_SLS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001197 HW_ASSISTED_COHERENCY \
1198 MEASURED_BOOT \
Tamas Bana4260892023-06-07 13:35:04 +02001199 DICE_PROTECTION_ENVIRONMENT \
Raghu Krishnamurthyc11b60e2024-06-03 19:02:29 -07001200 RMMD_ENABLE_EL3_TOKEN_SIGN \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001201 DRTM_SUPPORT \
1202 NS_TIMER_SWITCH \
1203 OVERRIDE_LIBC \
1204 PL011_GENERIC_UART \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001205 PROGRAMMABLE_RESET_ADDRESS \
1206 PSCI_EXTENDED_STATE_ID \
1207 PSCI_OS_INIT_MODE \
Boyan Karatotev8e7c43c2024-10-25 11:38:41 +01001208 ARCH_FEATURE_AVAILABILITY \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001209 RESET_TO_BL31 \
1210 SAVE_KEYS \
1211 SEPARATE_CODE_AND_RODATA \
1212 SEPARATE_BL2_NOLOAD_REGION \
1213 SEPARATE_NOBITS_REGION \
Ye Li97267752022-08-26 13:48:31 +08001214 SEPARATE_RWDATA_REGION \
Madhukar Pappireddy5c1b8d92024-06-17 15:26:00 -05001215 SEPARATE_SIMD_SECTION \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001216 SPIN_ON_BL1_EXIT \
1217 SPM_MM \
1218 SPMC_AT_EL3 \
Nishant Sharma9e719112023-06-27 00:36:01 +01001219 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001220 SPMD_SPM_AT_SEL2 \
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -08001221 ENABLE_SPMD_LP \
Raymond Mao98983392023-07-25 07:53:35 -07001222 TRANSFER_LIST \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001223 TRUSTED_BOARD_BOOT \
1224 USE_COHERENT_MEM \
1225 USE_DEBUGFS \
1226 ARM_IO_IN_DTB \
1227 SDEI_IN_FCONF \
1228 SEC_INT_DESC_IN_FCONF \
1229 USE_ROMLIB \
1230 USE_TBBR_DEFS \
1231 WARMBOOT_ENABLE_DCACHE_EARLY \
1232 RESET_TO_BL2 \
1233 BL2_IN_XIP_MEM \
1234 BL2_INV_DCACHE \
1235 USE_SPINLOCK_CAS \
1236 ENCRYPT_BL31 \
1237 ENCRYPT_BL32 \
1238 ERRATA_SPECULATIVE_AT \
1239 RAS_TRAP_NS_ERR_REC_ACCESS \
1240 COT_DESC_IN_DTB \
1241 USE_SP804_TIMER \
1242 PSA_FWU_SUPPORT \
Sughosh Ganu61905e52024-02-01 12:51:20 +05301243 PSA_FWU_METADATA_FW_STORE_DESC \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001244 ENABLE_MPMM \
1245 ENABLE_MPMM_FCONF \
1246 FEATURE_DETECTION \
Jayanth Dodderi Chidanand7c7faff2022-10-11 17:16:07 +01001247 TRNG_SUPPORT \
Sona Mathew7fe03522022-11-18 18:05:38 -06001248 ERRATA_ABI_SUPPORT \
Sona Mathew5a4c9fc2023-03-14 14:02:03 -05001249 ERRATA_NON_ARM_INTERCONNECT \
Okash Khawaja037b56e2022-11-04 12:38:01 +00001250 CONDITIONAL_CMO \
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001251 PSA_CRYPTO \
Sandrine Bailleuxf57e2032023-10-11 08:38:00 +02001252 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash8bd27c92023-08-15 16:28:06 -05001253 INIT_UNUSED_NS_EL2 \
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001254 PLATFORM_REPORT_CTX_MEM_USE \
Yann Gautier5ae29c02024-01-16 19:39:31 +01001255 EARLY_CONSOLE \
Arvind Ram Prakasheaa90192023-12-21 00:25:52 -06001256 PRESERVE_DSU_PMU_REGS \
Levi Yun03adb132024-05-13 10:24:31 +01001257 HOB_LIST \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001258)))
Dan Handley81be1002015-03-27 17:44:35 +00001259
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001260# Numeric_Flags
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001261$(eval $(call assert_numerics,\
1262 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001263 ARM_ARCH_MAJOR \
1264 ARM_ARCH_MINOR \
1265 BRANCH_PROTECTION \
1266 CTX_INCLUDE_PAUTH_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001267 CTX_INCLUDE_NEVE_REGS \
1268 CRYPTO_SUPPORT \
Boyan Karatotev677ed8a2023-02-16 09:45:29 +00001269 DISABLE_MTPMU \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001270 ENABLE_BRBE_FOR_NS \
1271 ENABLE_TRBE_FOR_NS \
1272 ENABLE_BTI \
1273 ENABLE_PAUTH \
1274 ENABLE_FEAT_AMU \
1275 ENABLE_FEAT_AMUv1p1 \
1276 ENABLE_FEAT_CSV2_2 \
Sona Mathew3b84c962023-10-25 16:48:19 -05001277 ENABLE_FEAT_CSV2_3 \
Arvind Ram Prakash05b47632024-05-22 15:24:00 -05001278 ENABLE_FEAT_DEBUGV8P9 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001279 ENABLE_FEAT_DIT \
1280 ENABLE_FEAT_ECV \
1281 ENABLE_FEAT_FGT \
Arvind Ram Prakash62d87e72024-06-06 11:33:37 -05001282 ENABLE_FEAT_FGT2 \
Arvind Ram Prakashe558f9c2024-11-11 14:32:37 -06001283 ENABLE_FEAT_FPMR \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001284 ENABLE_FEAT_HCX \
Andre Przywara8fc8e182024-08-09 17:04:22 +01001285 ENABLE_FEAT_LS64_ACCDATA \
Govindraj Rajad7b63ac2024-01-26 10:08:37 -06001286 ENABLE_FEAT_MTE2 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001287 ENABLE_FEAT_PAN \
1288 ENABLE_FEAT_RNG \
1289 ENABLE_FEAT_RNG_TRAP \
1290 ENABLE_FEAT_SEL2 \
1291 ENABLE_FEAT_TCR2 \
Jayanth Dodderi Chidanand6b706862024-09-05 22:24:04 +01001292 ENABLE_FEAT_THE \
Govindraj Rajac2dad572024-01-23 16:03:53 -06001293 ENABLE_FEAT_SB \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001294 ENABLE_FEAT_S2PIE \
1295 ENABLE_FEAT_S1PIE \
1296 ENABLE_FEAT_S2POE \
1297 ENABLE_FEAT_S1POE \
Jayanth Dodderi Chidanand70cc1752024-09-06 13:49:31 +01001298 ENABLE_FEAT_SCTLR2 \
Govindraj Rajae63794e2024-09-06 15:43:43 +01001299 ENABLE_FEAT_D128 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001300 ENABLE_FEAT_GCS \
1301 ENABLE_FEAT_VHE \
Arvind Ram Prakashab28d4b2023-10-11 12:10:56 -05001302 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001303 ENABLE_RME \
1304 ENABLE_SPE_FOR_NS \
1305 ENABLE_SYS_REG_TRACE_FOR_NS \
1306 ENABLE_SME_FOR_NS \
1307 ENABLE_SME2_FOR_NS \
1308 ENABLE_SVE_FOR_NS \
1309 ENABLE_TRF_FOR_NS \
1310 FW_ENC_STATUS \
1311 NR_OF_FW_BANKS \
1312 NR_OF_IMAGES_IN_FW_BANK \
1313 TWED_DELAY \
1314 ENABLE_FEAT_TWED \
1315 SVE_VECTOR_LEN \
Varun Wadekar0a46eb12023-04-13 21:06:18 +01001316 IMPDEF_SYSREG_TRAP \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001317)))
Jeenu Viswambharanfca76802017-01-16 16:52:35 +00001318
Justin Chadwellf9b32c12019-07-29 17:13:10 +01001319ifdef KEY_SIZE
1320 $(eval $(call assert_numeric,KEY_SIZE))
1321endif
1322
Justin Chadwell83e04882019-08-20 11:01:52 +01001323ifeq ($(filter $(SANITIZE_UB), on off trap),)
1324 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
1325endif
1326
Juan Castilloa3487d12015-08-18 14:23:04 +01001327################################################################################
1328# Add definitions to the cpp preprocessor based on the current build options.
1329# This is done after including the platform specific makefile to allow the
1330# platform to overwrite the default options
1331################################################################################
Jeenu Viswambharand1b60152014-05-12 15:28:47 +01001332
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001333$(eval $(call add_defines,\
1334 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001335 ALLOW_RO_XLAT_TABLES \
1336 ARM_ARCH_MAJOR \
1337 ARM_ARCH_MINOR \
1338 BL2_ENABLE_SP_LOAD \
1339 COLD_BOOT_SINGLE_CPU \
1340 CTX_INCLUDE_AARCH32_REGS \
1341 CTX_INCLUDE_FPREGS \
Madhukar Pappireddydd9af9b2024-06-17 15:17:03 -05001342 CTX_INCLUDE_SVE_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001343 CTX_INCLUDE_PAUTH_REGS \
Arvind Ram Prakash4851b492023-10-06 14:35:21 -05001344 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001345 EL3_EXCEPTION_HANDLING \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001346 CTX_INCLUDE_EL2_REGS \
1347 CTX_INCLUDE_NEVE_REGS \
1348 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
1349 DISABLE_MTPMU \
1350 ENABLE_FEAT_AMU \
1351 ENABLE_AMU_AUXILIARY_COUNTERS \
1352 ENABLE_AMU_FCONF \
1353 AMU_RESTRICT_COUNTERS \
1354 ENABLE_ASSERTIONS \
1355 ENABLE_BTI \
Arvind Ram Prakash05b47632024-05-22 15:24:00 -05001356 ENABLE_FEAT_DEBUGV8P9 \
Arvind Ram Prakashab28d4b2023-10-11 12:10:56 -05001357 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001358 ENABLE_PAUTH \
1359 ENABLE_PIE \
1360 ENABLE_PMF \
1361 ENABLE_PSCI_STAT \
1362 ENABLE_RME \
Raghu Krishnamurthyc11b60e2024-06-03 19:02:29 -07001363 RMMD_ENABLE_EL3_TOKEN_SIGN \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001364 ENABLE_RUNTIME_INSTRUMENTATION \
1365 ENABLE_SME_FOR_NS \
1366 ENABLE_SME2_FOR_NS \
1367 ENABLE_SME_FOR_SWD \
1368 ENABLE_SPE_FOR_NS \
1369 ENABLE_SVE_FOR_NS \
1370 ENABLE_SVE_FOR_SWD \
Manish Pandey514a3012023-10-10 13:53:25 +01001371 ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +01001372 FFH_SUPPORT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001373 ENCRYPT_BL31 \
1374 ENCRYPT_BL32 \
1375 ERROR_DEPRECATED \
1376 FAULT_INJECTION_SUPPORT \
1377 GICV2_G0_FOR_EL3 \
1378 HANDLE_EA_EL3_FIRST_NS \
1379 HW_ASSISTED_COHERENCY \
1380 LOG_LEVEL \
1381 MEASURED_BOOT \
Tamas Bana4260892023-06-07 13:35:04 +02001382 DICE_PROTECTION_ENVIRONMENT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001383 DRTM_SUPPORT \
1384 NS_TIMER_SWITCH \
1385 PL011_GENERIC_UART \
1386 PLAT_${PLAT} \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001387 PROGRAMMABLE_RESET_ADDRESS \
1388 PSCI_EXTENDED_STATE_ID \
1389 PSCI_OS_INIT_MODE \
Boyan Karatotev8e7c43c2024-10-25 11:38:41 +01001390 ARCH_FEATURE_AVAILABILITY \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001391 RESET_TO_BL31 \
AlexeiFedorovc0ca2d72024-05-13 15:35:54 +01001392 RME_GPT_BITLOCK_BLOCK \
AlexeiFedorovbd8b1bb2024-03-13 17:07:03 +00001393 RME_GPT_MAX_BLOCK \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001394 SEPARATE_CODE_AND_RODATA \
1395 SEPARATE_BL2_NOLOAD_REGION \
1396 SEPARATE_NOBITS_REGION \
Ye Li97267752022-08-26 13:48:31 +08001397 SEPARATE_RWDATA_REGION \
Madhukar Pappireddy5c1b8d92024-06-17 15:26:00 -05001398 SEPARATE_SIMD_SECTION \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001399 RECLAIM_INIT_CODE \
1400 SPD_${SPD} \
1401 SPIN_ON_BL1_EXIT \
1402 SPM_MM \
1403 SPMC_AT_EL3 \
Nishant Sharma9e719112023-06-27 00:36:01 +01001404 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001405 SPMD_SPM_AT_SEL2 \
Raymond Mao98983392023-07-25 07:53:35 -07001406 TRANSFER_LIST \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001407 TRUSTED_BOARD_BOOT \
1408 CRYPTO_SUPPORT \
1409 TRNG_SUPPORT \
1410 ERRATA_ABI_SUPPORT \
Sona Mathew5a4c9fc2023-03-14 14:02:03 -05001411 ERRATA_NON_ARM_INTERCONNECT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001412 USE_COHERENT_MEM \
1413 USE_DEBUGFS \
1414 ARM_IO_IN_DTB \
1415 SDEI_IN_FCONF \
1416 SEC_INT_DESC_IN_FCONF \
1417 USE_ROMLIB \
1418 USE_TBBR_DEFS \
1419 WARMBOOT_ENABLE_DCACHE_EARLY \
1420 RESET_TO_BL2 \
1421 BL2_RUNS_AT_EL3 \
1422 BL2_IN_XIP_MEM \
1423 BL2_INV_DCACHE \
1424 USE_SPINLOCK_CAS \
1425 ERRATA_SPECULATIVE_AT \
1426 RAS_TRAP_NS_ERR_REC_ACCESS \
1427 COT_DESC_IN_DTB \
1428 USE_SP804_TIMER \
1429 ENABLE_FEAT_RNG \
1430 ENABLE_FEAT_RNG_TRAP \
1431 ENABLE_FEAT_SB \
1432 ENABLE_FEAT_DIT \
1433 NR_OF_FW_BANKS \
1434 NR_OF_IMAGES_IN_FW_BANK \
1435 PSA_FWU_SUPPORT \
Sughosh Ganu61905e52024-02-01 12:51:20 +05301436 PSA_FWU_METADATA_FW_STORE_DESC \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001437 ENABLE_BRBE_FOR_NS \
1438 ENABLE_TRBE_FOR_NS \
1439 ENABLE_SYS_REG_TRACE_FOR_NS \
1440 ENABLE_TRF_FOR_NS \
1441 ENABLE_FEAT_HCX \
1442 ENABLE_MPMM \
1443 ENABLE_MPMM_FCONF \
1444 ENABLE_FEAT_FGT \
Arvind Ram Prakash62d87e72024-06-06 11:33:37 -05001445 ENABLE_FEAT_FGT2 \
Arvind Ram Prakashe558f9c2024-11-11 14:32:37 -06001446 ENABLE_FEAT_FPMR \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001447 ENABLE_FEAT_ECV \
1448 ENABLE_FEAT_AMUv1p1 \
1449 ENABLE_FEAT_SEL2 \
1450 ENABLE_FEAT_VHE \
1451 ENABLE_FEAT_CSV2_2 \
Sona Mathew3b84c962023-10-25 16:48:19 -05001452 ENABLE_FEAT_CSV2_3 \
Andre Przywara8fc8e182024-08-09 17:04:22 +01001453 ENABLE_FEAT_LS64_ACCDATA \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001454 ENABLE_FEAT_PAN \
1455 ENABLE_FEAT_TCR2 \
Jayanth Dodderi Chidanand6b706862024-09-05 22:24:04 +01001456 ENABLE_FEAT_THE \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001457 ENABLE_FEAT_S2PIE \
1458 ENABLE_FEAT_S1PIE \
1459 ENABLE_FEAT_S2POE \
1460 ENABLE_FEAT_S1POE \
Jayanth Dodderi Chidanand70cc1752024-09-06 13:49:31 +01001461 ENABLE_FEAT_SCTLR2 \
Govindraj Rajae63794e2024-09-06 15:43:43 +01001462 ENABLE_FEAT_D128 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001463 ENABLE_FEAT_GCS \
Govindraj Rajad7b63ac2024-01-26 10:08:37 -06001464 ENABLE_FEAT_MTE2 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001465 FEATURE_DETECTION \
1466 TWED_DELAY \
1467 ENABLE_FEAT_TWED \
Okash Khawaja037b56e2022-11-04 12:38:01 +00001468 CONDITIONAL_CMO \
Varun Wadekar0a46eb12023-04-13 21:06:18 +01001469 IMPDEF_SYSREG_TRAP \
Jayanth Dodderi Chidanand23c2fe22023-04-26 15:57:30 +01001470 SVE_VECTOR_LEN \
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -08001471 ENABLE_SPMD_LP \
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001472 PSA_CRYPTO \
Sandrine Bailleuxf57e2032023-10-11 08:38:00 +02001473 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash8bd27c92023-08-15 16:28:06 -05001474 INIT_UNUSED_NS_EL2 \
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001475 PLATFORM_REPORT_CTX_MEM_USE \
Yann Gautier5ae29c02024-01-16 19:39:31 +01001476 EARLY_CONSOLE \
Arvind Ram Prakasheaa90192023-12-21 00:25:52 -06001477 PRESERVE_DSU_PMU_REGS \
Levi Yun03adb132024-05-13 10:24:31 +01001478 HOB_LIST \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001479)))
Jeenu Viswambharan615ff392016-10-24 14:31:51 +01001480
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001481ifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1)
1482ifeq (${DEBUG}, 0)
1483 $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only")
1484 override PLATFORM_REPORT_CTX_MEM_USE := 0
1485endif
1486endif
1487
Justin Chadwell83e04882019-08-20 11:01:52 +01001488ifeq (${SANITIZE_UB},trap)
1489 $(eval $(call add_define,MONITOR_TRAPS))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001490endif #(SANITIZE_UB)
Justin Chadwell83e04882019-08-20 11:01:52 +01001491
Sandrine Bailleux03897bb2015-11-26 16:31:34 +00001492# Define the EL3_PAYLOAD_BASE flag only if it is provided.
1493ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +00001494 $(eval $(call add_define,EL3_PAYLOAD_BASE))
1495else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001496# Define the PRELOADED_BL33_BASE flag only if it is provided and
1497# EL3_PAYLOAD_BASE is not defined, as it has priority.
1498 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz2b8277b2016-04-06 17:31:57 +01001499 $(eval $(call add_define,PRELOADED_BL33_BASE))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001500 endif
1501endif #(EL3_PAYLOAD_BASE)
Soby Mathew85dbf5a2015-04-07 12:16:56 +01001502
Soby Mathew9fe88042018-03-26 12:43:37 +01001503# Define the DYN_DISABLE_AUTH flag only if set.
1504ifeq (${DYN_DISABLE_AUTH},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001505 $(eval $(call add_define,DYN_DISABLE_AUTH))
Soby Mathew9fe88042018-03-26 12:43:37 +01001506endif
1507
Chris Kaycfba6452023-12-04 09:55:50 +00001508ifeq ($($(ARCH)-ld-id),arm-link)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001509 $(eval $(call add_define,USE_ARM_LINK))
Varun Wadekar4d034c52019-01-11 14:47:48 -08001510endif
1511
Manish Pandey3f90ad72020-01-14 11:52:05 +00001512# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
Manish Pandey3f90ad72020-01-14 11:52:05 +00001513ifeq (${SPD},spmd)
Olivier Deprez042db532020-03-19 09:27:11 +01001514ifdef SP_LAYOUT_FILE
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001515 -include $(BUILD_PLAT)/sp_gen.mk
1516 FIP_DEPS += sp
1517 CRT_DEPS += sp
1518 NEED_SP_PKG := yes
Manish Pandey3f90ad72020-01-14 11:52:05 +00001519else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001520 ifeq (${SPMD_SPM_AT_SEL2},1)
1521 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1522 endif
1523endif #(SP_LAYOUT_FILE)
1524endif #(SPD)
Manish Pandey3f90ad72020-01-14 11:52:05 +00001525
Juan Castilloa3487d12015-08-18 14:23:04 +01001526################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001527# Build targets
1528################################################################################
Achin Gupta4f6ad662013-10-25 09:08:21 +01001529
Harrison Mutai36d971a2024-08-28 13:27:19 +00001530.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp tl fwu_fip certtool dtbs memmap doc enctool
Achin Gupta4f6ad662013-10-25 09:08:21 +01001531
Juan Castilloa3487d12015-08-18 14:23:04 +01001532all: msg_start
Harry Liebelf58ad362014-01-10 18:00:33 +00001533
Juan Castilloa3487d12015-08-18 14:23:04 +01001534msg_start:
Chris Kay1870c722024-05-02 17:52:37 +00001535 $(s)echo "Building ${PLAT}"
Juan Castillo11abdcd2014-10-21 11:30:42 +01001536
Soby Mathew18a62042015-10-26 14:29:21 +00001537ifeq (${ERROR_DEPRECATED},0)
Julius Werner53456fc2019-07-09 13:49:11 -07001538# Check if deprecated declarations and cpp warnings should be treated as error or not.
Chris Kaycfba6452023-12-04 09:55:50 +00001539ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
Varun Wadekar4d034c52019-01-11 14:47:48 -08001540 CPPFLAGS += -Wno-error=deprecated-declarations
1541else
Dan Handley6fa89a22018-02-27 16:03:58 +00001542 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp
Soby Mathew18a62042015-10-26 14:29:21 +00001543endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001544endif #(!ERROR_DEPRECATED)
Soby Mathew18a62042015-10-26 14:29:21 +00001545
Roberto Vargas0f8f9852018-05-08 10:27:10 +01001546$(eval $(call MAKE_LIB,c))
Roberto Vargas21360f32018-05-08 10:27:10 +01001547
Juan Castilloa3487d12015-08-18 14:23:04 +01001548# Expand build macros for the different images
1549ifeq (${NEED_BL1},yes)
Chris Kay0a542ec2021-09-28 15:44:19 +01001550BL1_SOURCES := $(sort ${BL1_SOURCES})
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001551$(eval $(call MAKE_BL,bl1))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001552endif #(NEED_BL1)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001553
Juan Castilloa3487d12015-08-18 14:23:04 +01001554ifeq (${NEED_BL2},yes)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001555
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -06001556ifeq (${RESET_TO_BL2}, 0)
Roberto Vargas53c052b2018-01-02 11:23:41 +00001557FIP_BL2_ARGS := tb-fw
1558endif
1559
Chris Kayfb3b0512021-09-28 15:44:37 +01001560BL2_SOURCES := $(sort ${BL2_SOURCES})
1561
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001562$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001563 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001564
1565endif #(NEED_BL2)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001566
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001567ifeq (${NEED_SCP_BL2},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001568$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001569endif #(NEED_SCP_BL2)
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001570
Juan Castilloa3487d12015-08-18 14:23:04 +01001571ifeq (${NEED_BL31},yes)
1572BL31_SOURCES += ${SPD_SOURCES}
Madhukar Pappireddyae9677b2020-01-27 13:37:51 -06001573# Sort BL31 source files to remove duplicates
1574BL31_SOURCES := $(sort ${BL31_SOURCES})
Sumit Gargeec52442019-11-14 16:33:45 +05301575ifneq (${DECRYPTION_SUPPORT},none)
1576$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001577 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
Sumit Gargeec52442019-11-14 16:33:45 +05301578else
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001579$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001580 $(eval $(call MAKE_BL,bl31,soc-fw)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001581endif #(DECRYPTION_SUPPORT)
1582endif #(NEED_BL31)
Juan Castillo379954c2014-11-04 17:36:40 +00001583
Juan Castillo671b8db2015-11-12 10:59:26 +00001584# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
Masahiro Yamada4d156802018-01-26 11:42:01 +09001585# build system will call TOOL_ADD_IMG to print a warning message and abort the
Juan Castillo671b8db2015-11-12 10:59:26 +00001586# process. Note that the dependency on BL32 applies to the FIP only.
Juan Castilloa3487d12015-08-18 14:23:04 +01001587ifeq (${NEED_BL32},yes)
Madhukar Pappireddyae9677b2020-01-27 13:37:51 -06001588# Sort BL32 source files to remove duplicates
1589BL32_SOURCES := $(sort ${BL32_SOURCES})
Masahiro Yamada6ced1b22018-01-26 11:42:01 +09001590BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
1591
Sumit Gargeec52442019-11-14 16:33:45 +05301592ifneq (${DECRYPTION_SUPPORT},none)
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001593$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
Sumit Gargeec52442019-11-14 16:33:45 +05301594 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1595else
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001596$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001597 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001598endif #(DECRYPTION_SUPPORT)
1599endif #(NEED_BL32)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001600
Zelalem Aweke4d37db82021-07-11 18:33:20 -05001601# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
1602# needs to be built from RMM_SOURCES.
1603ifeq (${NEED_RMM},yes)
1604# Sort RMM source files to remove duplicates
1605RMM_SOURCES := $(sort ${RMM_SOURCES})
1606BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
1607
1608$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001609 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1610endif #(NEED_RMM)
Zelalem Aweke4d37db82021-07-11 18:33:20 -05001611
Juan Castilloa3487d12015-08-18 14:23:04 +01001612# Add the BL33 image if required by the platform
1613ifeq (${NEED_BL33},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001614$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001615endif #(NEED_BL33)
Juan Castillo9c25a402015-01-13 12:21:04 +00001616
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001617ifeq (${NEED_BL2U},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001618$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001619 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001620endif #(NEED_BL2U)
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001621
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001622# Expand build macros for the different images
1623ifeq (${NEED_FDT},yes)
Soby Mathewab4181d2017-12-14 17:44:56 +00001624 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001625endif #(NEED_FDT)
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001626
Manish Pandey3f90ad72020-01-14 11:52:05 +00001627# Add Secure Partition packages
1628ifeq (${NEED_SP_PKG},yes)
Chris Kayd67442e2024-07-30 13:33:56 +00001629$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | $$(@D)/
Chris Kay1870c722024-05-02 17:52:37 +00001630 $(q)${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
J-Alvesef8e0982022-03-22 16:28:51 +00001631sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
Chris Kay1870c722024-05-02 17:52:37 +00001632 $(s)echo
1633 $(s)echo "Built SP Images successfully"
1634 $(s)echo
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001635endif #(NEED_SP_PKG)
Manish Pandey3f90ad72020-01-14 11:52:05 +00001636
Ian Spray36eaaf32014-01-30 17:25:28 +00001637locate-checkpatch:
1638ifndef CHECKPATCH
Etienne Carrieref5657572017-08-23 15:44:01 +02001639 $(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 +00001640else
1641ifeq (,$(wildcard ${CHECKPATCH}))
Etienne Carrieref5657572017-08-23 15:44:01 +02001642 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
Ian Spray36eaaf32014-01-30 17:25:28 +00001643endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001644endif #(CHECKPATCH)
Ian Spray36eaaf32014-01-30 17:25:28 +00001645
Achin Gupta4f6ad662013-10-25 09:08:21 +01001646clean:
Chris Kay1870c722024-05-02 17:52:37 +00001647 $(s)echo " CLEAN"
Chris Kayfaab7482025-01-13 15:57:32 +00001648 $(q)rm -rf $(BUILD_PLAT)
Chris Kay1870c722024-05-02 17:52:37 +00001649 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Chris Kay1870c722024-05-02 17:52:37 +00001650 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
1651 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
1652 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001653
James Morrisseyeaaeece2013-11-01 13:56:59 +00001654realclean distclean:
Chris Kay1870c722024-05-02 17:52:37 +00001655 $(s)echo " REALCLEAN"
Chris Kayfaab7482025-01-13 15:57:32 +00001656 $(q)rm -rf $(BUILD_BASE)
1657 $(q)rm -rf $(CURDIR)/cscope.*
Chris Kay1870c722024-05-02 17:52:37 +00001658 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Chris Kay1870c722024-05-02 17:52:37 +00001659 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
1660 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
1661 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001662
Ian Spray36eaaf32014-01-30 17:25:28 +00001663checkcodebase: locate-checkpatch
Chris Kay1870c722024-05-02 17:52:37 +00001664 $(s)echo " CHECKING STYLE"
1665 $(q)if test -d .git ; then \
Paul Beesleyadfab5b2019-03-07 16:42:31 +00001666 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \
Dan Handley3a355712016-06-02 18:21:02 +01001667 while read GIT_FILE ; \
1668 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
1669 done ; \
1670 else \
1671 find . -type f -not -iwholename "*.git*" \
1672 -not -iwholename "*build*" \
1673 -not -iwholename "*libfdt*" \
Roberto Vargas0f8f9852018-05-08 10:27:10 +01001674 -not -iwholename "*libc*" \
Dan Handley3a355712016-06-02 18:21:02 +01001675 -not -iwholename "*docs*" \
Paul Beesleyadfab5b2019-03-07 16:42:31 +00001676 -not -iwholename "*.rst" \
Dan Handley3a355712016-06-02 18:21:02 +01001677 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
1678 fi
Ian Spray36eaaf32014-01-30 17:25:28 +00001679
1680checkpatch: locate-checkpatch
Chris Kay1870c722024-05-02 17:52:37 +00001681 $(s)echo " CHECKING STYLE"
1682 $(q)if test -n "${CHECKPATCH_OPTS}"; then \
Yann Gautier0c26a2a2019-03-08 15:44:00 +01001683 echo " with ${CHECKPATCH_OPTS} option(s)"; \
1684 fi
Chris Kay1870c722024-05-02 17:52:37 +00001685 $(q)COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
Yann Gautiera10a6852021-11-02 18:03:31 +01001686 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \
1687 do \
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001688 printf "\n[*] Checking style of '$$commit'\n\n"; \
Yann Gautierfaf8c612024-08-09 11:52:03 +02001689 ( git log --format=email "$$commit~..$$commit" \
1690 -- ${CHECK_PATHS} ; \
1691 git diff --format=email "$$commit~..$$commit" \
1692 -- ${CHECK_PATHS}; ) | \
Yann Gautier0c26a2a2019-03-08 15:44:00 +01001693 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001694 done
Juan Castilloa3487d12015-08-18 14:23:04 +01001695
1696certtool: ${CRTTOOL}
Ian Spray36eaaf32014-01-30 17:25:28 +00001697
Pali Rohár54ff2132020-11-24 15:38:08 +01001698${CRTTOOL}: FORCE
Chris Kay1870c722024-05-02 17:52:37 +00001699 $(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
1700 $(s)echo
1701 $(s)echo "Built $@ successfully"
1702 $(s)echo
Jon Medhurst407a95c2014-02-12 15:54:48 +00001703
Juan Castillo11abdcd2014-10-21 11:30:42 +01001704ifneq (${GENERATE_COT},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001705certificates: ${CRT_DEPS} ${CRTTOOL}
Chris Kay1870c722024-05-02 17:52:37 +00001706 $(q)${CRTTOOL} ${CRT_ARGS}
1707 $(s)echo
1708 $(s)echo "Built $@ successfully"
1709 $(s)echo "Certificates can be found in ${BUILD_PLAT}"
1710 $(s)echo
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001711endif #(GENERATE_COT)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001712
Juan Castilloa3487d12015-08-18 14:23:04 +01001713${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
Pali Rohára5416ab2020-11-24 16:53:04 +01001714 $(eval ${CHECK_FIP_CMD})
Chris Kay1870c722024-05-02 17:52:37 +00001715 $(q)${FIPTOOL} create ${FIP_ARGS} $@
1716 $(q)${FIPTOOL} info $@
1717 $(s)echo
1718 $(s)echo "Built $@ successfully"
1719 $(s)echo
Soby Mathewdbee7fc2014-09-08 17:51:01 +01001720
Yatharth Kochard1a93432015-10-12 12:33:47 +01001721ifneq (${GENERATE_COT},0)
1722fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
Chris Kay1870c722024-05-02 17:52:37 +00001723 $(q)${CRTTOOL} ${FWU_CRT_ARGS}
1724 $(s)echo
1725 $(s)echo "Built $@ successfully"
1726 $(s)echo "FWU certificates can be found in ${BUILD_PLAT}"
1727 $(s)echo
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001728endif #(GENERATE_COT)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001729
1730${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
Pali Rohára5416ab2020-11-24 16:53:04 +01001731 $(eval ${CHECK_FWU_FIP_CMD})
Chris Kay1870c722024-05-02 17:52:37 +00001732 $(q)${FIPTOOL} create ${FWU_FIP_ARGS} $@
1733 $(q)${FIPTOOL} info $@
1734 $(s)echo
1735 $(s)echo "Built $@ successfully"
1736 $(s)echo
Yatharth Kochard1a93432015-10-12 12:33:47 +01001737
Juan Castilloa3487d12015-08-18 14:23:04 +01001738fiptool: ${FIPTOOL}
1739fip: ${BUILD_PLAT}/${FIP_NAME}
Yatharth Kochard1a93432015-10-12 12:33:47 +01001740fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
Harry Liebelf58ad362014-01-10 18:00:33 +00001741
Pali Rohár54ff2132020-11-24 15:38:08 +01001742${FIPTOOL}: FORCE
Manish V Badarkhe0a5acd42024-10-03 20:50:04 +01001743 $(q)${MAKE} PLAT=${PLAT} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${FIPTOOLPATH} all
Harry Liebelf58ad362014-01-10 18:00:33 +00001744
Manish V Badarkhe8cad2e12024-12-03 21:46:51 +00001745$(BUILD_PLAT)/romlib/romlib.bin $(BUILD_PLAT)/lib/libwrappers.a $&: $(BUILD_PLAT)/lib/libfdt.a $(BUILD_PLAT)/lib/libc.a $(CRYPTO_LIB)
1746 $(q)${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} CRYPTO_SUPPORT=${CRYPTO_SUPPORT} ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES=$(call escape-shell,$(INCLUDES)) DEFINES=$(call escape-shell,$(DEFINES)) --no-print-directory -C ${ROMLIBPATH} all
Roberto Vargase92111a2018-05-22 16:05:42 +01001747
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +01001748memmap: all
Chris Kay1870c722024-05-02 17:52:37 +00001749 $(q)PYTHONPATH=${CURDIR}/tools/memory \
Harrison Mutaie9bc4882023-02-23 10:33:58 +00001750 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +01001751
Harrison Mutai36d971a2024-08-28 13:27:19 +00001752tl: ${BUILD_PLAT}/tl.bin
1753${BUILD_PLAT}/tl.bin: ${HW_CONFIG}
Chris Kaya152e752024-09-26 14:18:04 +00001754 $(if $(host-poetry),$(q)poetry -q install)
1755 $(q)$(if $(host-poetry),poetry run )tlc create --fdt $< -s ${FW_HANDOFF_SIZE} $@
Harrison Mutai36d971a2024-08-28 13:27:19 +00001756
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -06001757doc:
Chris Kay1870c722024-05-02 17:52:37 +00001758 $(s)echo " BUILD DOCUMENTATION"
1759 $(q)${MAKE} --no-print-directory -C ${DOCS_PATH} html
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -06001760
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301761enctool: ${ENCTOOL}
1762
Pali Rohár54ff2132020-11-24 15:38:08 +01001763${ENCTOOL}: FORCE
Chris Kay1870c722024-05-02 17:52:37 +00001764 $(q)${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} --no-print-directory -C ${ENCTOOLPATH} all
1765 $(s)echo
1766 $(s)echo "Built $@ successfully"
1767 $(s)echo
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301768
Joakim Bech35fab8c2014-01-23 14:51:49 +01001769cscope:
Chris Kay1870c722024-05-02 17:52:37 +00001770 $(s)echo " CSCOPE"
1771 $(q)find ${CURDIR} -name "*.[chsS]" > cscope.files
1772 $(q)cscope -b -q -k
Joakim Bech35fab8c2014-01-23 14:51:49 +01001773
Ryan Harkin72ee3312014-01-15 16:55:07 +00001774help:
Chris Kay1870c722024-05-02 17:52:37 +00001775 $(s)echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
1776 $(s)echo ""
1777 $(s)echo "PLAT is used to specify which platform you wish to build."
1778 $(s)echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
1779 $(s)echo ""
1780 $(s)echo "platform = ${PLATFORM_LIST}"
1781 $(s)echo ""
1782 $(s)echo "Please refer to the User Guide for a list of all supported options."
1783 $(s)echo "Note that the build system doesn't track dependencies for build "
1784 $(s)echo "options. Therefore, if any of the build options are changed "
1785 $(s)echo "from a previous build, a clean build must be performed."
1786 $(s)echo ""
1787 $(s)echo "Supported Targets:"
1788 $(s)echo " all Build all individual bootloader binaries"
1789 $(s)echo " bl1 Build the BL1 binary"
1790 $(s)echo " bl2 Build the BL2 binary"
1791 $(s)echo " bl2u Build the BL2U binary"
1792 $(s)echo " bl31 Build the BL31 binary"
1793 $(s)echo " bl32 Build the BL32 binary. If ARCH=aarch32, then "
1794 $(s)echo " this builds secure payload specified by AARCH32_SP"
1795 $(s)echo " certificates Build the certificates (requires 'GENERATE_COT=1')"
1796 $(s)echo " fip Build the Firmware Image Package (FIP)"
1797 $(s)echo " fwu_fip Build the FWU Firmware Image Package (FIP)"
1798 $(s)echo " checkcodebase Check the coding style of the entire source tree"
1799 $(s)echo " checkpatch Check the coding style on changes in the current"
1800 $(s)echo " branch against BASE_COMMIT (default origin/master)"
1801 $(s)echo " clean Clean the build for the selected platform"
1802 $(s)echo " cscope Generate cscope index"
1803 $(s)echo " distclean Remove all build artifacts for all platforms"
1804 $(s)echo " certtool Build the Certificate generation tool"
1805 $(s)echo " enctool Build the Firmware encryption tool"
1806 $(s)echo " fiptool Build the Firmware Image Package (FIP) creation tool"
1807 $(s)echo " sp Build the Secure Partition Packages"
1808 $(s)echo " sptool Build the Secure Partition Package creation tool"
1809 $(s)echo " dtbs Build the Device Tree Blobs (if required for the platform)"
1810 $(s)echo " memmap Print the memory map of the built binaries"
1811 $(s)echo " doc Build html based documentation using Sphinx tool"
1812 $(s)echo ""
1813 $(s)echo "Note: most build targets require PLAT to be set to a specific platform."
1814 $(s)echo ""
1815 $(s)echo "example: build all targets for the FVP platform:"
1816 $(s)echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
Pali Rohár54ff2132020-11-24 15:38:08 +01001817
1818.PHONY: FORCE
1819FORCE:;