blob: 037330fb84709ffbd77bb84ba2a082002e9c810b [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001#
Govindraj Raja0a33adc2023-12-21 13:57:49 -06002# Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003#
dp-arm82cb2c12017-05-03 09:38:09 +01004# SPDX-License-Identifier: BSD-3-Clause
Achin Gupta4f6ad662013-10-25 09:08:21 +01005#
6
Jeenu Viswambharane35c4042014-05-15 14:40:58 +01007#
Juan Castilloaaa3e722014-06-30 11:41:46 +01008# Trusted Firmware Version
9#
Soby Mathew1a0f1122018-10-01 16:16:34 +010010VERSION_MAJOR := 2
Govindraj Raja07a6a652024-11-15 09:56:50 +010011VERSION_MINOR := 12
Yann Gautierc25d1cc2024-02-08 18:40:27 +010012# VERSION_PATCH is only used for LTS releases
Release CIa9fcaf32025-06-20 16:07:49 +000013VERSION_PATCH := 4
Yann Gautier055ebec2023-10-03 11:09:07 +020014VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
Juan Castilloaaa3e722014-06-30 11:41:46 +010015
Juan Castillo88154672015-10-22 11:34:44 +010016# Default goal is build all images
17.DEFAULT_GOAL := all
18
Douglas Raillard72fc70e2016-12-28 14:47:50 +000019# Avoid any implicit propagation of command line variable definitions to
20# sub-Makefiles, like CFLAGS that we reserved for the firmware images'
21# usage. Other command line options like "-s" are still propagated as usual.
22MAKEOVERRIDES =
23
Evan Lloyd231c1472015-12-02 18:17:37 +000024MAKE_HELPERS_DIRECTORY := make_helpers/
25include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
Evan Lloyde7f54db2015-12-02 18:56:06 +000026include ${MAKE_HELPERS_DIRECTORY}build_env.mk
Chris Kayf4dd18c2024-06-04 00:04:48 +000027include ${MAKE_HELPERS_DIRECTORY}build-rules.mk
Chris Kay7c4e1ee2024-05-02 17:52:37 +000028include ${MAKE_HELPERS_DIRECTORY}common.mk
Juan Castillo73c99d42015-08-18 14:23:04 +010029
30################################################################################
Jeenu Viswambharan2fae4b12016-10-24 14:31:51 +010031# Default values for build configurations, and their dependencies
Juan Castillo73c99d42015-08-18 14:23:04 +010032################################################################################
Jeenu Viswambharane35c4042014-05-15 14:40:58 +010033
Jeenu Viswambharan2fae4b12016-10-24 14:31:51 +010034include ${MAKE_HELPERS_DIRECTORY}defaults.mk
Yann Gautierd1c3a5d2025-01-17 11:02:50 +010035PLAT := ${DEFAULT_PLAT}
Andrey Skvortsov1b2fb6a2024-02-18 11:43:12 +030036include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
37
38# To be able to set platform specific defaults
39ifneq ($(PLAT_DEFAULTS_MAKEFILE_FULL),)
40include ${PLAT_DEFAULTS_MAKEFILE_FULL}
41endif
dp-arm872be882016-09-19 11:18:44 +010042
Chris Kaycc277de2023-10-20 09:17:33 +000043################################################################################
44# Configure the toolchains used to build TF-A and its tools
45################################################################################
46
47include ${MAKE_HELPERS_DIRECTORY}toolchain.mk
48
Antonio Nino Diazcc8b5632017-04-18 15:16:05 +010049# Assertions enabled for DEBUG builds by default
Antonio Nino Diazcc8b5632017-04-18 15:16:05 +010050ENABLE_ASSERTIONS := ${DEBUG}
Jeenu Viswambharan2fae4b12016-10-24 14:31:51 +010051ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION}
Juan Castillo73c99d42015-08-18 14:23:04 +010052
53################################################################################
54# Checkpatch script options
55################################################################################
56
Sandrine Bailleuxf6077392016-06-02 11:19:59 +010057CHECKCODE_ARGS := --no-patch
Dan Handleyf0b489c2016-06-02 17:15:13 +010058# Do not check the coding style on imported library files or documentation files
Gilad Ben-Yossef45018432019-05-15 09:24:04 +030059INC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \
60 include/drivers/arm, \
61 $(wildcard include/drivers/*)))
Dan Handleyf0b489c2016-06-02 17:15:13 +010062INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \
Dan Handley1a41e8c2016-06-02 18:21:02 +010063 include/lib/libfdt \
Roberto Vargas61f72a32018-05-08 10:27:10 +010064 include/lib/libc, \
Dan Handleyf0b489c2016-06-02 17:15:13 +010065 $(wildcard include/lib/*)))
66INC_DIRS_TO_CHECK := $(sort $(filter-out \
Gilad Ben-Yossef45018432019-05-15 09:24:04 +030067 include/lib \
68 include/drivers, \
Dan Handleyf0b489c2016-06-02 17:15:13 +010069 $(wildcard include/*)))
70LIB_DIRS_TO_CHECK := $(sort $(filter-out \
dp-armd801fbb2017-05-04 12:15:35 +010071 lib/compiler-rt \
Antonio Nino Diaz55cdcf72017-01-16 17:20:45 +000072 lib/libfdt% \
Roberto Vargas61f72a32018-05-08 10:27:10 +010073 lib/libc, \
Daniel Boulbya1942552022-10-05 11:05:22 +010074 lib/zlib \
Dan Handleyf0b489c2016-06-02 17:15:13 +010075 $(wildcard lib/*)))
76ROOT_DIRS_TO_CHECK := $(sort $(filter-out \
77 lib \
78 include \
79 docs \
Paul Beesley1ef35512019-03-07 16:42:31 +000080 %.rst, \
Dan Handleyf0b489c2016-06-02 17:15:13 +010081 $(wildcard *)))
82CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \
83 ${INC_DIRS_TO_CHECK} \
84 ${INC_LIB_DIRS_TO_CHECK} \
Gilad Ben-Yossef45018432019-05-15 09:24:04 +030085 ${LIB_DIRS_TO_CHECK} \
86 ${INC_DRV_DIRS_TO_CHECK} \
87 ${INC_ARM_DIRS_TO_CHECK}
Ian Spray36eaaf32014-01-30 17:25:28 +000088
Juan Castillo73c99d42015-08-18 14:23:04 +010089################################################################################
90# Process build options
91################################################################################
92
Chris Kay7c4e1ee2024-05-02 17:52:37 +000093ifeq ($(verbose),)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +010094 CHECKCODE_ARGS += --no-summary --terse
Achin Gupta4f6ad662013-10-25 09:08:21 +010095endif
Andre Przywaraee1ba6d2018-09-27 10:56:05 +010096
Juan Castillo73c99d42015-08-18 14:23:04 +010097################################################################################
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +010098# Auxiliary tools (fiptool, cert_create, etc)
99################################################################################
100
101# Variables for use with Certificate Generation Tool
102CRTTOOLPATH ?= tools/cert_create
103CRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT}
104
105# Variables for use with Firmware Encryption Tool
106ENCTOOLPATH ?= tools/encrypt_fw
107ENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
108
109# Variables for use with Firmware Image Package
110FIPTOOLPATH ?= tools/fiptool
111FIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT}
112
113# Variables for use with sptool
114SPTOOLPATH ?= tools/sptool
115SPTOOL ?= ${SPTOOLPATH}/sptool.py
116SP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py
Karl Meakin20629b32023-02-14 11:56:02 +0000117SP_DTS_LIST_FRAGMENT ?= ${BUILD_PLAT}/sp_list_fragment.dts
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100118
119# Variables for use with ROMLIB
120ROMLIBPATH ?= lib/romlib
121
122# Variable for use with Python
123PYTHON ?= python3
124
125# Variables for use with documentation build using Sphinx tool
126DOCS_PATH ?= docs
127
128################################################################################
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100129# Compiler Configuration based on ARCH_MAJOR and ARCH_MINOR flags
130################################################################################
Etienne Carriere26e63c42017-11-08 13:48:40 +0100131ifeq (${ARM_ARCH_MAJOR},7)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100132 target32-directive = -target arm-none-eabi
Govindraj Rajad4089fb2023-05-30 16:52:15 -0500133# Will set march-directive from platform configuration
Etienne Carriere26e63c42017-11-08 13:48:40 +0100134else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100135 target32-directive = -target armv8a-none-eabi
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100136endif #(ARM_ARCH_MAJOR)
137
138################################################################################
139# Get Architecture Feature Modifiers
140################################################################################
141arch-features = ${ARM_ARCH_FEATURE}
142
Chris Kay8620bd02023-12-04 09:55:50 +0000143ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
144 ifeq ($($(ARCH)-cc-id),arm-clang)
Govindraj Raja7794d6c2023-06-01 16:29:16 -0500145 TF_CFLAGS_aarch32 := -target arm-arm-none-eabi
146 TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi
originc8a992f2022-01-19 16:30:14 +0000147 else
Govindraj Raja7794d6c2023-06-01 16:29:16 -0500148 TF_CFLAGS_aarch32 = $(target32-directive)
149 TF_CFLAGS_aarch64 := -target aarch64-elf
originc8a992f2022-01-19 16:30:14 +0000150 endif
151
Chris Kay8620bd02023-12-04 09:55:50 +0000152else ifeq ($($(ARCH)-cc-id),gnu-gcc)
Chris Kayfa402f32024-02-20 16:19:54 +0000153 # Enable LTO only for aarch64
154 ifeq (${ARCH},aarch64)
155 LTO_CFLAGS = $(if $(filter-out 0,$(ENABLE_LTO)),-flto)
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600156 endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100157endif #(clang)
dp-armd5461852017-05-02 12:00:08 +0100158
Ahmad Fatoum32b209b2020-02-25 11:25:08 +0100159# Process Debug flag
160$(eval $(call add_define,DEBUG))
161ifneq (${DEBUG}, 0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100162 BUILD_TYPE := debug
163 TF_CFLAGS += -g -gdwarf-4
164 ASFLAGS += -g -Wa,-gdwarf-4
Ahmad Fatoum32b209b2020-02-25 11:25:08 +0100165
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100166 # Use LOG_LEVEL_INFO by default for debug builds
167 LOG_LEVEL := 40
Ahmad Fatoum32b209b2020-02-25 11:25:08 +0100168else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100169 BUILD_TYPE := release
170 # Use LOG_LEVEL_NOTICE by default for release builds
171 LOG_LEVEL := 20
172endif #(Debug)
Ahmad Fatoum32b209b2020-02-25 11:25:08 +0100173
Peiyuan Songf1de4c82020-04-25 16:53:43 +0800174# Default build string (git branch and commit)
175ifeq (${BUILD_STRING},)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100176 BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null)
Peiyuan Songf1de4c82020-04-25 16:53:43 +0800177endif
laurenw-armdddf4282022-07-12 10:12:05 -0500178VERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
Peiyuan Songf1de4c82020-04-25 16:53:43 +0800179
Antonio Nino Diaz8fd9d4d2018-08-08 16:28:43 +0100180ifeq (${AARCH32_INSTRUCTION_SET},A32)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100181 TF_CFLAGS_aarch32 += -marm
Antonio Nino Diaz8fd9d4d2018-08-08 16:28:43 +0100182else ifeq (${AARCH32_INSTRUCTION_SET},T32)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100183 TF_CFLAGS_aarch32 += -mthumb
Antonio Nino Diaz8fd9d4d2018-08-08 16:28:43 +0100184else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100185 $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
186endif #(AARCH32_INSTRUCTION_SET)
Antonio Nino Diaz8fd9d4d2018-08-08 16:28:43 +0100187
Sandrine Bailleuxa9c4dde2018-07-03 09:14:45 +0200188TF_CFLAGS_aarch32 += -mno-unaligned-access
dp-armd5461852017-05-02 12:00:08 +0100189TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align
Soby Mathew9d29c222016-05-05 14:33:33 +0100190
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100191##############################################################################
192# WARNINGS Configuration
193###############################################################################
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100194# General warnings
195WARNINGS := -Wall -Wmissing-include-dirs -Wunused \
Yann Gautier34b508b2021-05-20 13:18:14 +0200196 -Wdisabled-optimization -Wvla -Wshadow \
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000197 -Wredundant-decls
198# stricter warnings
199WARNINGS += -Wextra -Wno-trigraphs
200# too verbose for generic build
201WARNINGS += -Wno-missing-field-initializers \
202 -Wno-type-limits -Wno-sign-compare \
203# on clang this flag gets reset if -Wextra is set after it. No difference on gcc
204WARNINGS += -Wno-unused-parameter
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100205
206# Additional warnings
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000207# Level 1 - infrequent warnings we should have none of
208# full -Wextra
209WARNING1 += -Wsign-compare
210WARNING1 += -Wtype-limits
211WARNING1 += -Wmissing-field-initializers
Yann Gautiere7c645b2018-12-10 18:00:26 +0100212
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000213# Level 2 - problematic warnings that we want
214# zlib, compiler-rt, coreboot, and mbdedtls blow up with these
215# TODO: disable just for them and move into default build
216WARNING2 += -Wold-style-definition
217WARNING2 += -Wmissing-prototypes
218WARNING2 += -Wmissing-format-attribute
219# TF-A aims to comply with this eventually. Effort too large at present
220WARNING2 += -Wundef
Boyan Karatotevd141e632022-11-21 14:49:05 +0000221# currently very involved and many platforms set this off
222WARNING2 += -Wunused-const-variable=2
Yann Gautiere7c645b2018-12-10 18:00:26 +0100223
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000224# Level 3 - very pedantic, frequently ignored
Yann Gautiere7c645b2018-12-10 18:00:26 +0100225WARNING3 := -Wbad-function-cast
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000226WARNING3 += -Waggregate-return
227WARNING3 += -Wnested-externs
228WARNING3 += -Wcast-align
Yann Gautiere7c645b2018-12-10 18:00:26 +0100229WARNING3 += -Wcast-qual
230WARNING3 += -Wconversion
231WARNING3 += -Wpacked
Yann Gautiere7c645b2018-12-10 18:00:26 +0100232WARNING3 += -Wpointer-arith
Yann Gautiere7c645b2018-12-10 18:00:26 +0100233WARNING3 += -Wswitch-default
Yann Gautiere7c645b2018-12-10 18:00:26 +0100234
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000235# Setting W is quite verbose and most warnings will be pre-existing issues
236# outside of the contributor's control. Don't fail the build on them so warnings
237# can be seen and hopefully addressed
238ifdef W
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100239 ifneq (${W},0)
240 E ?= 0
241 endif
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000242endif
243
Yann Gautiere7c645b2018-12-10 18:00:26 +0100244ifeq (${W},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100245 WARNINGS += $(WARNING1)
Yann Gautiere7c645b2018-12-10 18:00:26 +0100246else ifeq (${W},2)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100247 WARNINGS += $(WARNING1) $(WARNING2)
Yann Gautiere7c645b2018-12-10 18:00:26 +0100248else ifeq (${W},3)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100249 WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
250endif #(W)
Yann Gautiere7c645b2018-12-10 18:00:26 +0100251
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100252# Compiler specific warnings
Chris Kay8620bd02023-12-04 09:55:50 +0000253ifeq ($(filter %-clang,$($(ARCH)-cc-id)),)
Justin Chadwell93c690e2019-07-03 14:15:56 +0100254# not using clang
Justin Chadwelld7b4cd42019-09-18 14:13:42 +0100255WARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \
256 -Wpacked-bitfield-compat -Wshift-overflow=2 \
257 -Wlogical-op
Govindraj Rajadea23e22023-05-05 09:09:36 -0500258
259# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
Boyan Karatotev316f5c92024-10-10 13:54:37 +0100260TF_CFLAGS_MIN_PAGE_SIZE := $(call cc_option, --param=min-pagesize=0)
261TF_CFLAGS += $(TF_CFLAGS_MIN_PAGE_SIZE)
Govindraj Rajadea23e22023-05-05 09:09:36 -0500262
Bipin Ravi538516f2023-09-28 13:17:24 -0500263ifeq ($(HARDEN_SLS), 1)
Boyan Karatotev316f5c92024-10-10 13:54:37 +0100264 TF_CFLAGS_MHARDEN_SLS := $(call cc_option, -mharden-sls=all)
265 TF_CFLAGS_aarch64 += $(TF_CFLAGS_MHARDEN_SLS)
Bipin Ravi538516f2023-09-28 13:17:24 -0500266endif
267
Justin Chadwell93c690e2019-07-03 14:15:56 +0100268else
269# using clang
Justin Chadwelld7b4cd42019-09-18 14:13:42 +0100270WARNINGS += -Wshift-overflow -Wshift-sign-overflow \
271 -Wlogical-op-parentheses
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100272endif #(Clang Warning)
Ambroise Vincent00296572019-05-24 12:47:43 +0100273
Yann Gautier6336b072018-12-10 18:08:53 +0100274ifneq (${E},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100275 ERRORS := -Werror
276endif #(E)
Yann Gautier6336b072018-12-10 18:08:53 +0100277
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100278################################################################################
279# Compiler and Linker Directives
280################################################################################
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100281CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
282 $(ERRORS) $(WARNINGS)
Govindraj Rajad4089fb2023-05-30 16:52:15 -0500283ASFLAGS += $(CPPFLAGS) \
Julius Wernerd5dfdeb2019-07-09 13:49:11 -0700284 -ffreestanding -Wa,--fatal-warnings
Masahiro Yamada59de5092016-12-22 12:51:53 +0900285TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \
Samuel Hollandebd6efa2019-10-20 16:11:25 -0500286 -ffunction-sections -fdata-sections \
287 -ffreestanding -fno-builtin -fno-common \
288 -Os -std=gnu99
Juan Castillo73c99d42015-08-18 14:23:04 +0100289
Justin Chadwell1f461972019-08-20 11:01:52 +0100290ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100291 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover
292endif #(${SANITIZE_UB},on)
293
Justin Chadwell1f461972019-08-20 11:01:52 +0100294ifeq (${SANITIZE_UB},trap)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100295 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \
Justin Chadwell1f461972019-08-20 11:01:52 +0100296 -fsanitize-undefined-trap-on-error
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100297endif #(${SANITIZE_UB},trap)
Justin Chadwell1f461972019-08-20 11:01:52 +0100298
Chris Kay291e7182024-05-14 13:08:31 +0000299GCC_V_OUTPUT := $(if $($(ARCH)-cc),$(shell $($(ARCH)-cc) -v 2>&1))
david cunadof7ec31d2017-11-30 21:58:01 +0000300
Marco Felsch1f49db52022-11-09 12:59:09 +0100301TF_LDFLAGS += -z noexecstack
302
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100303# LD = armlink
Chris Kay8620bd02023-12-04 09:55:50 +0000304ifeq ($($(ARCH)-ld-id),arm-link)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100305 TF_LDFLAGS += --diag_error=warning --lto_level=O1
306 TF_LDFLAGS += --remove --info=unused,unusedsymbols
307 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100308
309# LD = gcc (used when GCC LTO is enabled)
Chris Kay8620bd02023-12-04 09:55:50 +0000310else ifeq ($($(ARCH)-ld-id),gnu-gcc)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100311 # Pass ld options with Wl or Xlinker switches
Chris Kay86e489c2024-01-16 11:53:35 +0000312 TF_LDFLAGS += $(call ld_option,-Xlinker --no-warn-rwx-segments)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100313 TF_LDFLAGS += -Wl,--fatal-warnings -O1
314 TF_LDFLAGS += -Wl,--gc-sections
Chris Kayac98b822022-12-22 13:26:37 +0000315
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100316 TF_LDFLAGS += -Wl,-z,common-page-size=4096 #Configure page size constants
317 TF_LDFLAGS += -Wl,-z,max-page-size=4096
Andrey Skvortsov304ad942023-09-05 23:06:29 +0300318 TF_LDFLAGS += -Wl,--build-id=none
Chris Kayac98b822022-12-22 13:26:37 +0000319
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100320 ifeq ($(ENABLE_LTO),1)
321 ifeq (${ARCH},aarch64)
322 TF_LDFLAGS += -flto -fuse-linker-plugin
Andrey Skvortsov31f80ef2023-12-08 18:04:51 +0300323 TF_LDFLAGS += -flto-partition=one
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100324 endif
325 endif #(ENABLE_LTO)
326
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600327# GCC automatically adds fix-cortex-a53-843419 flag when used to link
328# which breaks some builds, so disable if errata fix is not explicitly enabled
Yann Gautiercfe67672023-03-15 16:18:16 +0100329 ifeq (${ARCH},aarch64)
330 ifneq (${ERRATA_A53_843419},1)
331 TF_LDFLAGS += -mno-fix-cortex-a53-843419
332 endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100333 endif
334 TF_LDFLAGS += -nostdlib
335 TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100336
337# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
Varun Wadekarc2ad38c2019-01-11 14:47:48 -0800338else
Marco Felsch1f49db52022-11-09 12:59:09 +0100339# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
340# are not loaded by a elf loader.
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100341 TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments)
342 TF_LDFLAGS += -O1
343 TF_LDFLAGS += --gc-sections
Chris Kayac98b822022-12-22 13:26:37 +0000344
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100345 TF_LDFLAGS += -z common-page-size=4096 # Configure page size constants
346 TF_LDFLAGS += -z max-page-size=4096
Andrey Skvortsov304ad942023-09-05 23:06:29 +0300347 TF_LDFLAGS += --build-id=none
Chris Kayac98b822022-12-22 13:26:37 +0000348
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100349# ld.lld doesn't recognize the errata flags,
Yabin Cuiebac6922023-01-19 20:06:04 +0000350# therefore don't add those in that case.
351# ld.lld reports section type mismatch warnings,
352# therefore don't add --fatal-warnings to it.
Chris Kay8620bd02023-12-04 09:55:50 +0000353 ifneq ($($(ARCH)-ld-id),llvm-lld)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100354 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) --fatal-warnings
355 endif
356
357endif #(LD = armlink)
Juan Castillo73c99d42015-08-18 14:23:04 +0100358
359################################################################################
Govindraj Rajaf5211422023-08-17 10:41:48 -0500360# Setup ARCH_MAJOR/MINOR before parsing arch_features.
361################################################################################
362ifeq (${ENABLE_RME},1)
AlexeiFedorov7d5fc982024-03-13 11:53:44 +0000363 ARM_ARCH_MAJOR := 9
364 ARM_ARCH_MINOR := 2
Govindraj Rajaf5211422023-08-17 10:41:48 -0500365endif
366
367################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +0100368# Common sources and include directories
369################################################################################
dp-armd801fbb2017-05-04 12:15:35 +0100370include lib/compiler-rt/compiler-rt.mk
Juan Castillo73c99d42015-08-18 14:23:04 +0100371
Chris Kay758ccb82024-03-08 16:08:31 +0000372# Allow overriding the timestamp, for example for reproducible builds, or to
373# synchronize timestamps across multiple projects.
374# This must be set to a C string (including quotes where applicable).
375BUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__
376
377DEFINES += -DBUILD_MESSAGE_TIMESTAMP='$(BUILD_MESSAGE_TIMESTAMP)'
378DEFINES += -DBUILD_MESSAGE_VERSION_STRING='"$(VERSION_STRING)"'
379DEFINES += -DBUILD_MESSAGE_VERSION='"$(VERSION)"'
380
Juan Castillo73c99d42015-08-18 14:23:04 +0100381BL_COMMON_SOURCES += common/bl_common.c \
Soby Mathew7f56e9a2017-09-04 11:49:29 +0100382 common/tf_log.c \
Soby Mathew9d29c222016-05-05 14:33:33 +0100383 common/${ARCH}/debug.S \
Julius Werner91b48c92018-11-27 22:10:56 -0800384 drivers/console/multi_console.c \
Soby Mathew9d29c222016-05-05 14:33:33 +0100385 lib/${ARCH}/cache_helpers.S \
386 lib/${ARCH}/misc_helpers.S \
Boyan Karatotevc73686a2023-02-15 13:21:50 +0000387 lib/extensions/pmuv3/${ARCH}/pmuv3.c \
Soby Mathew566034f2018-02-08 17:45:12 +0000388 plat/common/plat_bl_common.c \
Soby Mathew7f56e9a2017-09-04 11:49:29 +0100389 plat/common/plat_log_common.c \
dp-arm75311202017-03-07 11:02:47 +0000390 plat/common/${ARCH}/plat_common.c \
Soby Mathew9d29c222016-05-05 14:33:33 +0100391 plat/common/${ARCH}/platform_helpers.S \
Roberto Vargas61f72a32018-05-08 10:27:10 +0100392 ${COMPILER_RT_SRCS}
Ryan Harkind7a6b0f2014-01-13 14:40:13 +0000393
Chris Kay8620bd02023-12-04 09:55:50 +0000394ifeq ($($(ARCH)-cc-id),arm-clang)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100395 BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S
Antonio Nino Diaz8422a842018-08-16 15:42:44 +0100396endif
397
Justin Chadwell1f461972019-08-20 11:01:52 +0100398ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100399 BL_COMMON_SOURCES += plat/common/ubsan.c
Justin Chadwell1f461972019-08-20 11:01:52 +0100400endif
401
Yann Gautier01d237c2018-06-18 16:00:23 +0200402INCLUDES += -Iinclude \
Antonio Nino Diazf5478de2018-12-17 17:20:57 +0000403 -Iinclude/arch/${ARCH} \
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +0000404 -Iinclude/lib/cpus/${ARCH} \
405 -Iinclude/lib/el3_runtime/${ARCH} \
406 ${PLAT_INCLUDES} \
407 ${SPD_INCLUDES}
408
Nishant Sharmae03dcc82022-08-15 16:37:07 +0100409DTC_FLAGS += -I dts -O dtb
410DTC_CPPFLAGS += -P -nostdinc $(INCLUDES) -Ifdts -undef \
411 -x assembler-with-cpp $(DEFINES)
412
Antonio Nino Diaz9c6d1c52018-11-19 11:48:30 +0000413include common/backtrace/backtrace.mk
414
Juan Castillo73c99d42015-08-18 14:23:04 +0100415################################################################################
Govindraj Raja35472702023-09-20 14:32:24 -0500416# Generic definitions
417################################################################################
Govindraj Raja35472702023-09-20 14:32:24 -0500418
419ifeq (${BUILD_BASE},)
420 BUILD_BASE := ./build
421endif
422BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
423
424SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
425
426# Platforms providing their own TBB makefile may override this value
427INCLUDE_TBBR_MK := 1
428
429################################################################################
430# Include SPD Makefile if one has been specified
431################################################################################
432
433ifneq (${SPD},none)
434 ifeq (${ARCH},aarch32)
435 $(error "Error: SPD is incompatible with AArch32.")
436 endif
437
438 ifdef EL3_PAYLOAD_BASE
439 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
440 $(warning "The SPD and its BL32 companion will be present but \
441 ignored.")
442 endif
443
444 ifeq (${SPD},spmd)
445 # SPMD is located in std_svc directory
446 SPD_DIR := std_svc
447
448 ifeq ($(SPMD_SPM_AT_SEL2),1)
449 CTX_INCLUDE_EL2_REGS := 1
450 ifeq ($(SPMC_AT_EL3),1)
451 $(error SPM cannot be enabled in both S-EL2 and EL3.)
452 endif
Madhukar Pappireddy59bdcc52024-04-25 23:01:00 -0500453 ifeq ($(CTX_INCLUDE_SVE_REGS),1)
454 $(error SVE context management not needed with Hafnium SPMC.)
455 endif
Govindraj Raja35472702023-09-20 14:32:24 -0500456 endif
457
458 ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
459 DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG
460 endif
461
Arunachalam Ganapathy0686a012022-04-11 14:36:54 +0100462 ifeq ($(findstring trusty_sp,$(ARM_SPMC_MANIFEST_DTS)),trusty_sp)
463 DTC_CPPFLAGS += -DTRUSTY_SP_FW_CONFIG
464 endif
465
Govindraj Raja35472702023-09-20 14:32:24 -0500466 ifeq ($(TS_SP_FW_CONFIG),1)
Arunachalam Ganapathy0686a012022-04-11 14:36:54 +0100467 DTC_CPPFLAGS += -DTS_SP_FW_CONFIG
Govindraj Raja35472702023-09-20 14:32:24 -0500468 endif
469
470 ifneq ($(ARM_BL2_SP_LIST_DTS),)
471 DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
472 endif
473
474 ifneq ($(SP_LAYOUT_FILE),)
475 BL2_ENABLE_SP_LOAD := 1
476 endif
Govindraj Rajac189adb2023-10-31 14:48:11 -0500477
478 ifeq ($(SPMC_AT_EL3_SEL0_SP),1)
479 ifneq ($(SPMC_AT_EL3),1)
480 $(error SEL0 SP cannot be enabled without SPMC at EL3)
481 endif
482 endif
Govindraj Raja35472702023-09-20 14:32:24 -0500483 else
484 # All other SPDs in spd directory
485 SPD_DIR := spd
486 endif #(SPD)
487
488 # We expect to locate an spd.mk under the specified SPD directory
489 SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
490
491 ifeq (${SPD_MAKE},)
492 $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
493 endif
494 $(info Including ${SPD_MAKE})
495 include ${SPD_MAKE}
496
497 # If there's BL32 companion for the chosen SPD, we expect that the SPD's
498 # Makefile would set NEED_BL32 to "yes". In this case, the build system
499 # supports two mutually exclusive options:
500 # * BL32 is built from source: then BL32_SOURCES must contain the list
501 # of source files to build BL32
502 # * BL32 is a prebuilt binary: then BL32 must point to the image file
503 # that will be included in the FIP
504 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
505 # over the sources.
506endif #(SPD=none)
507
508ifeq (${ENABLE_SPMD_LP}, 1)
509ifneq (${SPD},spmd)
510 $(error Error: ENABLE_SPMD_LP requires SPD=spmd.)
511endif
512ifeq ($(SPMC_AT_EL3),1)
513 $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.)
514endif
515endif
516
517################################################################################
Govindraj Rajaf5211422023-08-17 10:41:48 -0500518# Process BRANCH_PROTECTION value and set
519# Pointer Authentication and Branch Target Identification flags
520################################################################################
521ifeq (${BRANCH_PROTECTION},0)
522 # Default value turns off all types of branch protection
523 BP_OPTION := none
524else ifneq (${ARCH},aarch64)
525 $(error BRANCH_PROTECTION requires AArch64)
526else ifeq (${BRANCH_PROTECTION},1)
527 # Enables all types of branch protection features
528 BP_OPTION := standard
529 ENABLE_BTI := 1
530 ENABLE_PAUTH := 1
531else ifeq (${BRANCH_PROTECTION},2)
532 # Return address signing to its standard level
533 BP_OPTION := pac-ret
534 ENABLE_PAUTH := 1
535else ifeq (${BRANCH_PROTECTION},3)
536 # Extend the signing to include leaf functions
537 BP_OPTION := pac-ret+leaf
538 ENABLE_PAUTH := 1
539else ifeq (${BRANCH_PROTECTION},4)
540 # Turn on branch target identification mechanism
541 BP_OPTION := bti
542 ENABLE_BTI := 1
543else
544 $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
545endif #(BRANCH_PROTECTION)
546
547ifeq ($(ENABLE_PAUTH),1)
548 CTX_INCLUDE_PAUTH_REGS := 1
549endif
550ifneq (${BP_OPTION},none)
551 TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION}
552endif #(BP_OPTION)
553
554# Pointer Authentication sources
555ifeq (${ENABLE_PAUTH}, 1)
556# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the
557# Pauth support. As it's not secure, it must be reimplemented for real platforms
558 BL_COMMON_SOURCES += lib/extensions/pauth/pauth_helpers.S
559endif
560
Govindraj Raja35472702023-09-20 14:32:24 -0500561################################################################################
562# Include the platform specific Makefile after the SPD Makefile (the platform
563# makefile may use all previous definitions in this file)
564################################################################################
565include ${PLAT_MAKEFILE_FULL}
566
567################################################################################
568# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from
569# platform.
570################################################################################
571include ${MAKE_HELPERS_DIRECTORY}arch_features.mk
572
Govindraj Rajaf5211422023-08-17 10:41:48 -0500573####################################################
574# Enable required options for Memory Stack Tagging.
575####################################################
576
577# Currently, these options are enabled only for clang and armclang compiler.
578ifeq (${SUPPORT_STACK_MEMTAG},yes)
579 ifdef mem_tag_arch_support
580 # Check for armclang and clang compilers
Chris Kay8620bd02023-12-04 09:55:50 +0000581 ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
Govindraj Rajaf5211422023-08-17 10:41:48 -0500582 # Add "memtag" architecture feature modifier if not specified
583 ifeq ( ,$(findstring memtag,$(arch-features)))
584 arch-features := $(arch-features)+memtag
585 endif # memtag
Chris Kay8620bd02023-12-04 09:55:50 +0000586 ifeq ($($(ARCH)-cc-id),arm-clang)
Govindraj Rajaf5211422023-08-17 10:41:48 -0500587 TF_CFLAGS += -mmemtag-stack
Chris Kay8620bd02023-12-04 09:55:50 +0000588 else ifeq ($($(ARCH)-cc-id),llvm-clang)
Govindraj Rajaf5211422023-08-17 10:41:48 -0500589 TF_CFLAGS += -fsanitize=memtag
590 endif # armclang
591 endif
592 else
593 $(error "Error: stack memory tagging is not supported for \
594 architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
595 endif #(mem_tag_arch_support)
596endif #(SUPPORT_STACK_MEMTAG)
597
598################################################################################
599# RME dependent flags configuration, Enable optional features for RME.
600################################################################################
601# FEAT_RME
602ifeq (${ENABLE_RME},1)
603 # RME doesn't support PIE
604 ifneq (${ENABLE_PIE},0)
605 $(error ENABLE_RME does not support PIE)
606 endif
607
Govindraj Rajaf5211422023-08-17 10:41:48 -0500608 # RME requires AARCH64
609 ifneq (${ARCH},aarch64)
610 $(error ENABLE_RME requires AArch64)
611 endif
612
613 # RME requires el2 context to be saved for now.
614 CTX_INCLUDE_EL2_REGS := 1
615 CTX_INCLUDE_AARCH32_REGS := 0
616 CTX_INCLUDE_PAUTH_REGS := 1
617
618 # RME enables CSV2_2 extension by default.
619 ENABLE_FEAT_CSV2_2 = 1
620endif #(FEAT_RME)
621
622################################################################################
Zelalem Aweke5b18de02021-07-11 18:33:20 -0500623# Include rmmd Makefile if RME is enabled
624################################################################################
Zelalem Aweke5b18de02021-07-11 18:33:20 -0500625ifneq (${ENABLE_RME},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100626 ifneq (${ARCH},aarch64)
627 $(error ENABLE_RME requires AArch64)
628 endif
629 ifeq ($(SPMC_AT_EL3),1)
630 $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
631 endif
632
633 ifneq (${SPD}, none)
634 ifneq (${SPD}, spmd)
635 $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd)
636 endif
637 endif
Zelalem Aweke5b18de02021-07-11 18:33:20 -0500638include services/std_svc/rmmd/rmmd.mk
639$(warning "RME is an experimental feature")
640endif
641
Govindraj Raja35472702023-09-20 14:32:24 -0500642ifeq (${CTX_INCLUDE_EL2_REGS}, 1)
643 ifeq (${SPD},none)
644 ifeq (${ENABLE_RME},0)
645 $(error CTX_INCLUDE_EL2_REGS is available only when SPD \
646 or RME is enabled)
647 endif
648 endif
649endif
Juan Castillo0f21c542014-06-25 17:26:36 +0100650
Govindraj Raja7794d6c2023-06-01 16:29:16 -0500651################################################################################
Govindraj Raja30655132024-09-06 15:43:43 +0100652# Make 128-Bit sysreg read/writes availabe when FEAT_D128 is enabled.
653################################################################################
654ifneq (${ENABLE_FEAT_D128}, 0)
655 BL_COMMON_SOURCES += lib/extensions/sysreg128/sysreg128.S
656endif
657
658################################################################################
Govindraj Raja7794d6c2023-06-01 16:29:16 -0500659# Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come
660# up with appropriate march values for compiler.
661################################################################################
662include ${MAKE_HELPERS_DIRECTORY}march.mk
663
664TF_CFLAGS += $(march-directive)
Govindraj Raja7275ac22024-01-23 16:00:19 -0600665ASFLAGS += $(march-directive)
Govindraj Raja7794d6c2023-06-01 16:29:16 -0500666
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600667# This internal flag is common option which is set to 1 for scenarios
668# when the BL2 is running in EL3 level. This occurs in two scenarios -
669# 4 world system running BL2 at EL3 and two world system without BL1 running
670# BL2 in EL3
671
672ifeq (${RESET_TO_BL2},1)
673 BL2_RUNS_AT_EL3 := 1
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100674 ifeq (${ENABLE_RME},1)
675 $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \
676 supported at the moment.)
677 endif
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600678else ifeq (${ENABLE_RME},1)
679 BL2_RUNS_AT_EL3 := 1
680else
681 BL2_RUNS_AT_EL3 := 0
682endif
683
Manish Pandeyf87e54f2023-10-10 15:42:19 +0100684# This internal flag is set to 1 when Firmware First handling of External aborts
685# is required by lowe ELs. Currently only NS requires this support.
686ifeq ($(HANDLE_EA_EL3_FIRST_NS),1)
687 FFH_SUPPORT := 1
688else
689 FFH_SUPPORT := 0
690endif
691
Etienne Carriere26e63c42017-11-08 13:48:40 +0100692ifeq (${ARM_ARCH_MAJOR},7)
693include make_helpers/armv7-a-cpus.mk
694endif
695
Masahiro Yamada320920c2020-01-17 13:44:37 +0900696PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT})
697ifneq ($(PIE_FOUND),)
698 TF_CFLAGS += -fno-PIE
Chris Kay8620bd02023-12-04 09:55:50 +0000699ifeq ($($(ARCH)-ld-id),gnu-gcc)
Samuel Holland7b592412022-04-08 21:56:02 -0500700 TF_LDFLAGS += -no-pie
701endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100702endif #(PIE_FOUND)
Masahiro Yamada320920c2020-01-17 13:44:37 +0900703
Chris Kay8620bd02023-12-04 09:55:50 +0000704ifeq ($($(ARCH)-ld-id),gnu-gcc)
Masahiro Yamada320920c2020-01-17 13:44:37 +0900705 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
Soby Mathew3bd17c02018-08-28 11:13:55 +0100706else
Masahiro Yamada320920c2020-01-17 13:44:37 +0900707 PIE_LDFLAGS += -pie --no-dynamic-linker
708endif
709
710ifeq ($(ENABLE_PIE),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100711 ifeq ($(RESET_TO_BL2),1)
712 ifneq ($(BL2_IN_XIP_MEM),1)
713 BL2_CPPFLAGS += -fpie
714 BL2_CFLAGS += -fpie
715 BL2_LDFLAGS += $(PIE_LDFLAGS)
716 endif #(BL2_IN_XIP_MEM)
717 endif #(RESET_TO_BL2)
Chris Kay966660e2023-02-02 14:39:03 +0000718 BL31_CPPFLAGS += -fpie
719 BL31_CFLAGS += -fpie
Masahiro Yamada320920c2020-01-17 13:44:37 +0900720 BL31_LDFLAGS += $(PIE_LDFLAGS)
Chris Kay966660e2023-02-02 14:39:03 +0000721
722 BL32_CPPFLAGS += -fpie
Masahiro Yamadad9743012020-01-17 13:45:14 +0900723 BL32_CFLAGS += -fpie
724 BL32_LDFLAGS += $(PIE_LDFLAGS)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100725endif #(ENABLE_PIE)
Soby Mathew3bd17c02018-08-28 11:13:55 +0100726
Boyan Karatotev007433d2023-01-25 16:55:18 +0000727BL1_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
728BL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
729BL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
730
Masahiro Yamada9cefb4b2020-04-01 14:20:58 +0900731BL1_CPPFLAGS += -DIMAGE_AT_EL3
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600732ifeq ($(RESET_TO_BL2),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100733 BL2_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamadad5e97a12020-03-26 13:18:48 +0900734else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100735 BL2_CPPFLAGS += -DIMAGE_AT_EL1
736endif #(RESET_TO_BL2)
Boyan Karatotev007433d2023-01-25 16:55:18 +0000737
738ifeq (${ARCH},aarch64)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100739 BL2U_CPPFLAGS += -DIMAGE_AT_EL1
740 BL31_CPPFLAGS += -DIMAGE_AT_EL3
741 BL32_CPPFLAGS += -DIMAGE_AT_EL1
Boyan Karatotev007433d2023-01-25 16:55:18 +0000742else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100743 BL32_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamadad5e97a12020-03-26 13:18:48 +0900744endif
745
Sandrine Bailleux54035fc2016-01-13 14:57:38 +0000746# Include the CPU specific operations makefile, which provides default
747# values for all CPU errata workarounds and CPU specific optimisations.
748# This can be overridden by the platform.
Juan Castillo73c99d42015-08-18 14:23:04 +0100749include lib/cpus/cpu-ops.mk
Achin Gupta4f6ad662013-10-25 09:08:21 +0100750
dp-arma4409002017-02-15 11:07:55 +0000751################################################################################
752# Build `AARCH32_SP` as BL32 image for AArch32
753################################################################################
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100754ifeq (${ARCH},aarch32)
755 NEED_BL32 := yes
dp-arma4409002017-02-15 11:07:55 +0000756
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100757 ifneq (${AARCH32_SP},none)
758 # We expect to locate an sp.mk under the specified AARCH32_SP directory
759 AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
dp-arma4409002017-02-15 11:07:55 +0000760
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100761 ifeq (${AARCH32_SP_MAKE},)
762 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
763 endif
Juan Pablo Conde043f38f2023-08-09 13:19:21 -0500764 $(info Including ${AARCH32_SP_MAKE})
765 include ${AARCH32_SP_MAKE}
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100766 endif
767endif #(ARCH=aarch32)
Achin Gupta4f6ad662013-10-25 09:08:21 +0100768
Juan Castillo73c99d42015-08-18 14:23:04 +0100769################################################################################
Varun Wadekar77f1f7a2019-01-31 09:22:30 -0800770# Include libc if not overridden
771################################################################################
772ifeq (${OVERRIDE_LIBC},0)
773include lib/libc/libc.mk
774endif
775
776################################################################################
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100777# Check incompatible options and dependencies
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000778################################################################################
779
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100780# USE_DEBUGFS experimental feature recommended only in debug builds
781ifeq (${USE_DEBUGFS},1)
782 ifeq (${DEBUG},1)
783 $(warning DEBUGFS experimental feature is enabled.)
784 else
785 $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000786 endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100787endif #(USE_DEBUGFS)
788
789# USE_SPINLOCK_CAS requires AArch64 build
790ifeq (${USE_SPINLOCK_CAS},1)
791 ifneq (${ARCH},aarch64)
792 $(error USE_SPINLOCK_CAS requires AArch64)
Qixiang Xu76580f32017-08-24 11:03:23 +0800793 endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100794endif #(USE_SPINLOCK_CAS)
795
796# The cert_create tool cannot generate certificates individually, so we use the
797# target 'certificates' to create them all
798ifneq (${GENERATE_COT},0)
799 FIP_DEPS += certificates
800 FWU_FIP_DEPS += fwu_certificates
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000801endif
802
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100803ifneq (${DECRYPTION_SUPPORT},none)
804 ENC_ARGS += -f ${FW_ENC_STATUS}
805 ENC_ARGS += -k ${ENC_KEY}
806 ENC_ARGS += -n ${ENC_NONCE}
807 FIP_DEPS += enctool
808 FWU_FIP_DEPS += enctool
809endif #(DECRYPTION_SUPPORT)
810
811ifdef EL3_PAYLOAD_BASE
812 ifdef PRELOADED_BL33_BASE
813 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
814 incompatible build options. EL3_PAYLOAD_BASE has priority.")
815 endif
816 ifneq (${GENERATE_COT},0)
817 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \
818 build options.")
819 endif
820 ifneq (${TRUSTED_BOARD_BOOT},0)
821 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \
822 incompatible \ build options.")
823 endif
824endif #(EL3_PAYLOAD_BASE)
825
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000826ifeq (${NEED_BL33},yes)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100827 ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000828 $(warning "BL33 image is not needed when option \
829 BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100830 endif
831 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz68450a62016-04-06 17:31:57 +0100832 $(warning "BL33 image is not needed when option \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100833 PRELOADED_BL33_BASE is used and won't be added to the FIP file.")
834 endif
835endif #(NEED_BL33)
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000836
Jeenu Viswambharand4593e42017-01-06 16:14:42 +0000837# When building for systems with hardware-assisted coherency, there's no need to
838# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
839ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100840 $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
Jeenu Viswambharand4593e42017-01-06 16:14:42 +0000841endif
Yatharth Kochar1a0a3f02016-06-28 16:58:26 +0100842
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600843#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1.
844ifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100845 $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled")
Jiafei Pan7d173fc2018-03-21 07:20:09 +0000846endif
847
Manish Pandey9202d512023-02-13 12:39:17 +0000848# RAS_EXTENSION is deprecated, provide alternate build options
Jeenu Viswambharan14c60162018-04-04 16:07:11 +0100849ifeq ($(RAS_EXTENSION),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100850 $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \
Manish Pandeyf87e54f2023-10-10 15:42:19 +0100851 and HANDLE_EA_EL3_FIRST_NS instead")
Manish Pandey9202d512023-02-13 12:39:17 +0000852endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100853
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100854
Manish Pandey9202d512023-02-13 12:39:17 +0000855# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled
Jeenu Viswambharan1a7c1cf2017-12-08 12:13:51 +0000856ifeq ($(FAULT_INJECTION_SUPPORT),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100857 ifeq ($(ENABLE_FEAT_RAS),0)
858 $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0)
859 endif
860endif #(FAULT_INJECTION_SUPPORT)
Jeenu Viswambharan1a7c1cf2017-12-08 12:13:51 +0000861
Roberto Vargased51b512018-09-24 17:20:48 +0100862# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
Soby Mathew209a60c2018-03-26 12:43:37 +0100863ifeq ($(DYN_DISABLE_AUTH), 1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100864 ifeq (${TRUSTED_BOARD_BOOT}, 0)
865 $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \
866 to be set.")
867 endif
868endif #(DYN_DISABLE_AUTH)
Soby Mathew209a60c2018-03-26 12:43:37 +0100869
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +0100870ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
871# Support authentication verification and hash calculation
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100872 CRYPTO_SUPPORT := 3
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +0100873else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
874# Support authentication verification and hash calculation
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100875 CRYPTO_SUPPORT := 3
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +0100876else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
877# Support hash calculation only
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100878 CRYPTO_SUPPORT := 2
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +0100879else ifeq (${TRUSTED_BOARD_BOOT},1)
880# Support authentication verification only
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100881 CRYPTO_SUPPORT := 1
Manish V Badarkhec9c56f62022-01-08 22:56:06 +0000882else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100883 CRYPTO_SUPPORT := 0
884endif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT))
Manish V Badarkhec9c56f62022-01-08 22:56:06 +0000885
Balint Dobszaycbf9e842019-12-18 15:28:00 +0100886# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
887ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100888 $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
Manish V Badarkhe84ef9cd2020-06-29 10:32:53 +0100889endif
890
Antonio Nino Diazb86048c2019-02-19 11:53:51 +0000891# If pointer authentication is used in the firmware, make sure that all the
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100892# registers associated to it are also saved and restored.
893# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
Antonio Nino Diazb86048c2019-02-19 11:53:51 +0000894ifeq ($(ENABLE_PAUTH),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100895 ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
896 $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
897 endif
898endif #(ENABLE_PAUTH)
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100899
900ifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100901 ifneq (${ARCH},aarch64)
902 $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
903 endif
904endif #(CTX_INCLUDE_PAUTH_REGS)
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100905
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +0000906ifeq ($(FEATURE_DETECTION),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100907 $(info FEATURE_DETECTION is an experimental feature)
908endif #(FEATURE_DETECTION)
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +0000909
Jayanth Dodderi Chidanand03d3c0d2022-11-08 10:31:07 +0000910ifneq ($(ENABLE_SME2_FOR_NS), 0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100911 ifeq (${ENABLE_SME_FOR_NS}, 0)
912 $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \
913 to be set")
914 $(warning "Forced ENABLE_SME_FOR_NS=1")
915 override ENABLE_SME_FOR_NS := 1
916 endif
917endif #(ENABLE_SME2_FOR_NS)
Jayanth Dodderi Chidanand45007ac2023-03-06 23:56:14 +0000918
Petre-Ionut Tudor60e8f3c2019-11-07 15:18:03 +0000919ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100920 ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
921 $(error "ALLOW_RO_XLAT_TABLES requires translation tables \
922 library v2")
923 endif
924endif #(ARM_XLAT_TABLES_LIB_V1)
Petre-Ionut Tudor60e8f3c2019-11-07 15:18:03 +0000925
Sumit Garg7cda17b2019-11-15 10:43:00 +0530926ifneq (${DECRYPTION_SUPPORT},none)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100927 ifeq (${TRUSTED_BOARD_BOOT}, 0)
928 $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \
929 to be set)
930 endif
931endif #(DECRYPTION_SUPPORT)
Sumit Garg7cda17b2019-11-15 10:43:00 +0530932
johpow01744ad972022-01-28 17:06:20 -0600933# Ensure that no Aarch64-only features are enabled in Aarch32 build
johpow01dc78e622021-07-08 14:14:00 -0500934ifeq (${ARCH},aarch32)
johpow01744ad972022-01-28 17:06:20 -0600935
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100936 # SME/SVE only supported on AArch64
937 ifneq (${ENABLE_SME_FOR_NS},0)
938 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
939 endif
Jayanth Dodderi Chidanand03d3c0d2022-11-08 10:31:07 +0000940
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100941 ifeq (${ENABLE_SVE_FOR_NS},1)
942 # Warning instead of error due to CI dependency on this
943 $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
944 endif
johpow01744ad972022-01-28 17:06:20 -0600945
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100946 # BRBE is not supported in AArch32
947 ifeq (${ENABLE_BRBE_FOR_NS},1)
948 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
949 endif
johpow01744ad972022-01-28 17:06:20 -0600950
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100951 # FEAT_RNG_TRAP is not supported in AArch32
952 ifeq (${ENABLE_FEAT_RNG_TRAP},1)
953 $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
954 endif
955endif #(ARCH=aarch32)
johpow01dc78e622021-07-08 14:14:00 -0500956
Boyan Karatotev0d122942023-03-08 16:29:26 +0000957ifneq (${ENABLE_SME_FOR_NS},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100958 ifeq (${ENABLE_SVE_FOR_NS},0)
959 $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS")
960 endif
961endif #(ENABLE_SME_FOR_NS)
Boyan Karatotev0d122942023-03-08 16:29:26 +0000962
johpow01dc78e622021-07-08 14:14:00 -0500963# Secure SME/SVE requires the non-secure component as well
964ifeq (${ENABLE_SME_FOR_SWD},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100965 ifeq (${ENABLE_SME_FOR_NS},0)
966 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
967 endif
968 ifeq (${ENABLE_SVE_FOR_SWD},0)
969 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD")
970 endif
971endif #(ENABLE_SME_FOR_SWD)
972
Madhukar Pappireddy3524d072024-06-17 15:28:33 -0500973# Enabling SVE for SWD requires enabling SVE for NWD due to ENABLE_FEAT
974# mechanism.
johpow01dc78e622021-07-08 14:14:00 -0500975ifeq (${ENABLE_SVE_FOR_SWD},1)
Madhukar Pappireddy3524d072024-06-17 15:28:33 -0500976 ifeq (${ENABLE_SVE_FOR_NS},0)
977 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
978 endif
979endif
johpow01dc78e622021-07-08 14:14:00 -0500980
Madhukar Pappireddy3524d072024-06-17 15:28:33 -0500981# Enabling SVE for both the worlds typically requires the context
982# management of SVE registers. The only exception being SPMC at S-EL2.
983ifeq (${ENABLE_SVE_FOR_SWD}, 1)
984 ifneq (${ENABLE_SVE_FOR_NS}, 0)
985 ifeq (${CTX_INCLUDE_SVE_REGS}-$(SPMD_SPM_AT_SEL2),0-0)
986 $(warning "ENABLE_SVE_FOR_SWD and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
987 endif
988 endif
989endif
990
991# Enabling SVE in either world while enabling CTX_INCLUDE_FPREGS requires
992# CTX_INCLUDE_SVE_REGS to be enabled due to architectural dependency between FP
993# and SVE registers.
994ifeq (${CTX_INCLUDE_FPREGS}, 1)
995 ifneq (${ENABLE_SVE_FOR_NS},0)
996 ifeq (${CTX_INCLUDE_SVE_REGS},0)
997 # Warning instead of error due to CI dependency on this
998 $(warning "CTX_INCLUDE_FPREGS and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
999 $(warning "Forced ENABLE_SVE_FOR_NS=0")
1000 override ENABLE_SVE_FOR_NS := 0
1001 endif
1002 endif
1003endif #(CTX_INCLUDE_FPREGS)
1004
1005# SVE context management is only required if secure world has access to SVE/FP
1006# functionality.
1007ifeq (${CTX_INCLUDE_SVE_REGS},1)
1008 ifeq (${ENABLE_SVE_FOR_SWD},0)
1009 $(error "CTX_INCLUDE_SVE_REGS requires ENABLE_SVE_FOR_SWD to also be enabled")
1010 endif
1011endif
1012
1013# SME cannot be used with CTX_INCLUDE_FPREGS since SPM does its own context
1014# management including FPU registers.
johpow01dc78e622021-07-08 14:14:00 -05001015ifeq (${CTX_INCLUDE_FPREGS},1)
Madhukar Pappireddy3524d072024-06-17 15:28:33 -05001016 ifneq (${ENABLE_SME_FOR_NS},0)
1017 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1018 endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001019endif #(CTX_INCLUDE_FPREGS)
johpow01dc78e622021-07-08 14:14:00 -05001020
Manish V Badarkhe00e28872022-03-02 12:06:35 +00001021ifeq ($(DRTM_SUPPORT),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001022 $(info DRTM_SUPPORT is an experimental feature)
Manish V Badarkhe00e28872022-03-02 12:06:35 +00001023endif
1024
Raymond Mao3ba2c152023-07-25 07:53:35 -07001025ifeq (${TRANSFER_LIST},1)
1026 $(info TRANSFER_LIST is an experimental feature)
1027endif
1028
Chris Kay274a69e2022-09-29 16:21:24 +01001029ifeq (${ENABLE_RME},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001030 ifneq (${SEPARATE_CODE_AND_RODATA},1)
1031 $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
1032 endif
Chris Kay274a69e2022-09-29 16:21:24 +01001033endif
1034
Manish V Badarkhe5782b892023-09-06 09:08:28 +01001035ifeq ($(PSA_CRYPTO),1)
1036 $(info PSA_CRYPTO is an experimental feature)
1037endif
1038
Manish V Badarkhe82222db2024-05-09 12:14:13 +01001039ifeq ($(DICE_PROTECTION_ENVIRONMENT),1)
1040 $(info DICE_PROTECTION_ENVIRONMENT is an experimental feature)
1041endif
1042
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +00001043################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +01001044# Process platform overrideable behaviour
1045################################################################################
Achin Gupta4f6ad662013-10-25 09:08:21 +01001046
Manish Pandey5f24ce92021-10-06 10:59:52 +01001047ifdef BL1_SOURCES
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001048 NEED_BL1 := yes
1049endif #(BL1_SOURCES)
Manish Pandey5f24ce92021-10-06 10:59:52 +01001050
Juan Castillo73c99d42015-08-18 14:23:04 +01001051ifdef BL2_SOURCES
Manish Pandey5f24ce92021-10-06 10:59:52 +01001052 NEED_BL2 := yes
1053
1054 # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
1055 # Certificate generation tools. This flag can be overridden by the platform.
1056 ifdef EL3_PAYLOAD_BASE
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001057 # If booting an EL3 payload there is no need for a BL33 image
1058 # in the FIP file.
1059 NEED_BL33 := no
1060 else
1061 ifdef PRELOADED_BL33_BASE
1062 # If booting a BL33 preloaded image there is no need of
1063 # another one in the FIP file.
1064 NEED_BL33 := no
1065 else
1066 NEED_BL33 ?= yes
1067 endif
1068 endif
1069endif #(BL2_SOURCES)
Juan Castillo73c99d42015-08-18 14:23:04 +01001070
Manish Pandey5f24ce92021-10-06 10:59:52 +01001071ifdef BL2U_SOURCES
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001072 NEED_BL2U := yes
1073endif #(BL2U_SOURCES)
Manish Pandey5f24ce92021-10-06 10:59:52 +01001074
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001075# If SCP_BL2 is given, we always want FIP to include it.
1076ifdef SCP_BL2
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001077 NEED_SCP_BL2 := yes
1078endif #(SCP_BL2)
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001079
Soby Mathew5744e872017-11-14 14:10:10 +00001080# For AArch32, BL31 is not currently supported.
1081ifneq (${ARCH},aarch32)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001082 ifdef BL31_SOURCES
1083 # When booting an EL3 payload, there is no need to compile the BL31
1084 # image nor put it in the FIP.
1085 ifndef EL3_PAYLOAD_BASE
1086 NEED_BL31 := yes
1087 endif
1088 endif
1089endif #(ARCH=aarch64)
Soby Mathew5744e872017-11-14 14:10:10 +00001090
Juan Castillo73c99d42015-08-18 14:23:04 +01001091# Process TBB related flags
1092ifneq (${GENERATE_COT},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001093 # Common cert_create options
1094 ifneq (${CREATE_KEYS},0)
Juan Castillo73c99d42015-08-18 14:23:04 +01001095 $(eval CRT_ARGS += -n)
Yatharth Kochar01912622015-10-12 12:33:47 +01001096 $(eval FWU_CRT_ARGS += -n)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001097 ifneq (${SAVE_KEYS},0)
Juan Castillo73c99d42015-08-18 14:23:04 +01001098 $(eval CRT_ARGS += -k)
Yatharth Kochar01912622015-10-12 12:33:47 +01001099 $(eval FWU_CRT_ARGS += -k)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001100 endif
1101 endif
1102 # Include TBBR makefile (unless the platform indicates otherwise)
1103 ifeq (${INCLUDE_TBBR_MK},1)
Juan Castillo73c99d42015-08-18 14:23:04 +01001104 include make_helpers/tbbr/tbbr_tools.mk
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001105 endif
1106endif #(GENERATE_COT)
Juan Castillo73c99d42015-08-18 14:23:04 +01001107
Masahiro Yamada1c75d5d2016-12-25 13:52:22 +09001108ifneq (${FIP_ALIGN},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001109 FIP_ARGS += --align ${FIP_ALIGN}
1110endif #(FIP_ALIGN)
Masahiro Yamada1c75d5d2016-12-25 13:52:22 +09001111
Manish Pandey5f24ce92021-10-06 10:59:52 +01001112ifdef FDT_SOURCES
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001113 NEED_FDT := yes
1114endif #(FDT_SOURCES)
Manish Pandey5f24ce92021-10-06 10:59:52 +01001115
Juan Castillo73c99d42015-08-18 14:23:04 +01001116################################################################################
Michalis Pappas46e5e032018-03-20 13:01:27 +08001117# Include libraries' Makefile that are used in all BL
1118################################################################################
1119
1120include lib/stack_protector/stack_protector.mk
1121
1122################################################################################
Soby Mathew8a860522017-02-14 10:05:07 +00001123# Include BL specific makefiles
1124################################################################################
Manish Pandey5f24ce92021-10-06 10:59:52 +01001125
1126ifeq (${NEED_BL1},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001127include bl1/bl1.mk
1128endif
1129
Manish Pandey5f24ce92021-10-06 10:59:52 +01001130ifeq (${NEED_BL2},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001131include bl2/bl2.mk
1132endif
1133
Manish Pandey5f24ce92021-10-06 10:59:52 +01001134ifeq (${NEED_BL2U},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001135include bl2u/bl2u.mk
1136endif
1137
Soby Mathew5744e872017-11-14 14:10:10 +00001138ifeq (${NEED_BL31},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001139include bl31/bl31.mk
1140endif
Nishanth Menon03b397a2016-10-14 01:13:57 +00001141
Juan Castillo73c99d42015-08-18 14:23:04 +01001142################################################################################
1143# Build options checks
1144################################################################################
Juan Castillob7124ea2014-11-04 17:36:40 +00001145
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001146# Boolean_Flags
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001147$(eval $(call assert_booleans,\
1148 $(sort \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001149 ALLOW_RO_XLAT_TABLES \
1150 BL2_ENABLE_SP_LOAD \
1151 COLD_BOOT_SINGLE_CPU \
1152 CREATE_KEYS \
1153 CTX_INCLUDE_AARCH32_REGS \
1154 CTX_INCLUDE_FPREGS \
Madhukar Pappireddy42422622024-06-17 15:17:03 -05001155 CTX_INCLUDE_SVE_REGS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001156 CTX_INCLUDE_EL2_REGS \
Arvind Ram Prakash9acff282023-10-06 14:35:21 -05001157 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001158 DEBUG \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001159 DYN_DISABLE_AUTH \
1160 EL3_EXCEPTION_HANDLING \
1161 ENABLE_AMU_AUXILIARY_COUNTERS \
1162 ENABLE_AMU_FCONF \
1163 AMU_RESTRICT_COUNTERS \
1164 ENABLE_ASSERTIONS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001165 ENABLE_PIE \
1166 ENABLE_PMF \
1167 ENABLE_PSCI_STAT \
1168 ENABLE_RUNTIME_INSTRUMENTATION \
1169 ENABLE_SME_FOR_SWD \
1170 ENABLE_SVE_FOR_SWD \
Manish Pandey970a4a82023-10-10 13:53:25 +01001171 ENABLE_FEAT_RAS \
Manish Pandeyf87e54f2023-10-10 15:42:19 +01001172 FFH_SUPPORT \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001173 ERROR_DEPRECATED \
1174 FAULT_INJECTION_SUPPORT \
1175 GENERATE_COT \
1176 GICV2_G0_FOR_EL3 \
1177 HANDLE_EA_EL3_FIRST_NS \
Bipin Ravi538516f2023-09-28 13:17:24 -05001178 HARDEN_SLS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001179 HW_ASSISTED_COHERENCY \
1180 MEASURED_BOOT \
Tamas Bane7f11812023-06-07 13:35:04 +02001181 DICE_PROTECTION_ENVIRONMENT \
Raghu Krishnamurthy6a88ec82024-06-03 19:02:29 -07001182 RMMD_ENABLE_EL3_TOKEN_SIGN \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001183 DRTM_SUPPORT \
1184 NS_TIMER_SWITCH \
1185 OVERRIDE_LIBC \
1186 PL011_GENERIC_UART \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001187 PROGRAMMABLE_RESET_ADDRESS \
1188 PSCI_EXTENDED_STATE_ID \
1189 PSCI_OS_INIT_MODE \
1190 RESET_TO_BL31 \
1191 SAVE_KEYS \
1192 SEPARATE_CODE_AND_RODATA \
1193 SEPARATE_BL2_NOLOAD_REGION \
1194 SEPARATE_NOBITS_REGION \
Ye Li86acbbe2022-08-26 13:48:31 +08001195 SEPARATE_RWDATA_REGION \
Madhukar Pappireddy308ebfa2024-06-17 15:26:00 -05001196 SEPARATE_SIMD_SECTION \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001197 SPIN_ON_BL1_EXIT \
1198 SPM_MM \
1199 SPMC_AT_EL3 \
Nishant Sharma801cd3c2023-06-27 00:36:01 +01001200 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001201 SPMD_SPM_AT_SEL2 \
Raghu Krishnamurthy890b5082023-02-25 13:26:10 -08001202 ENABLE_SPMD_LP \
Raymond Mao3ba2c152023-07-25 07:53:35 -07001203 TRANSFER_LIST \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001204 TRUSTED_BOARD_BOOT \
1205 USE_COHERENT_MEM \
1206 USE_DEBUGFS \
1207 ARM_IO_IN_DTB \
1208 SDEI_IN_FCONF \
1209 SEC_INT_DESC_IN_FCONF \
1210 USE_ROMLIB \
1211 USE_TBBR_DEFS \
1212 WARMBOOT_ENABLE_DCACHE_EARLY \
1213 RESET_TO_BL2 \
1214 BL2_IN_XIP_MEM \
1215 BL2_INV_DCACHE \
1216 USE_SPINLOCK_CAS \
1217 ENCRYPT_BL31 \
1218 ENCRYPT_BL32 \
1219 ERRATA_SPECULATIVE_AT \
1220 RAS_TRAP_NS_ERR_REC_ACCESS \
1221 COT_DESC_IN_DTB \
1222 USE_SP804_TIMER \
1223 PSA_FWU_SUPPORT \
Sughosh Ganu11d05a72024-02-01 12:51:20 +05301224 PSA_FWU_METADATA_FW_STORE_DESC \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001225 ENABLE_MPMM \
1226 ENABLE_MPMM_FCONF \
1227 FEATURE_DETECTION \
Jayanth Dodderi Chidanand0b22e592022-10-11 17:16:07 +01001228 TRNG_SUPPORT \
Boyan Karatotev04aca842023-03-22 15:55:36 +00001229 ENABLE_ERRATA_ALL \
Sona Mathewffea3842022-11-18 18:05:38 -06001230 ERRATA_ABI_SUPPORT \
Sona Mathewef63f5b2023-03-14 14:02:03 -05001231 ERRATA_NON_ARM_INTERCONNECT \
Okash Khawaja04c73032022-11-04 12:38:01 +00001232 CONDITIONAL_CMO \
Manish V Badarkhe5782b892023-09-06 09:08:28 +01001233 PSA_CRYPTO \
Sandrine Bailleux85bebe12023-10-11 08:38:00 +02001234 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash183329a2023-08-15 16:28:06 -05001235 INIT_UNUSED_NS_EL2 \
Juan Pablo Condebfef8b92023-11-08 16:14:28 -06001236 PLATFORM_REPORT_CTX_MEM_USE \
Yann Gautierae770fe2024-01-16 19:39:31 +01001237 EARLY_CONSOLE \
Arvind Ram Prakashf99a69c2023-12-21 00:25:52 -06001238 PRESERVE_DSU_PMU_REGS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001239)))
Juan Castillo73c99d42015-08-18 14:23:04 +01001240
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001241# Numeric_Flags
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001242$(eval $(call assert_numerics,\
1243 $(sort \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001244 ARM_ARCH_MAJOR \
1245 ARM_ARCH_MINOR \
1246 BRANCH_PROTECTION \
1247 CTX_INCLUDE_PAUTH_REGS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001248 CTX_INCLUDE_NEVE_REGS \
1249 CRYPTO_SUPPORT \
Boyan Karatotev83a4dae2023-02-16 09:45:29 +00001250 DISABLE_MTPMU \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001251 ENABLE_BRBE_FOR_NS \
1252 ENABLE_TRBE_FOR_NS \
1253 ENABLE_BTI \
1254 ENABLE_PAUTH \
1255 ENABLE_FEAT_AMU \
1256 ENABLE_FEAT_AMUv1p1 \
1257 ENABLE_FEAT_CSV2_2 \
Sona Mathew30019d82023-10-25 16:48:19 -05001258 ENABLE_FEAT_CSV2_3 \
Arvind Ram Prakash83271d52024-05-22 15:24:00 -05001259 ENABLE_FEAT_DEBUGV8P9 \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001260 ENABLE_FEAT_DIT \
1261 ENABLE_FEAT_ECV \
1262 ENABLE_FEAT_FGT \
Arvind Ram Prakash33e6aaa2024-06-06 11:33:37 -05001263 ENABLE_FEAT_FGT2 \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001264 ENABLE_FEAT_HCX \
Andre Przywara19d52a82024-08-09 17:04:22 +01001265 ENABLE_FEAT_LS64_ACCDATA \
Govindraj Raja8e397882024-01-26 10:08:37 -06001266 ENABLE_FEAT_MTE2 \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001267 ENABLE_FEAT_PAN \
1268 ENABLE_FEAT_RNG \
1269 ENABLE_FEAT_RNG_TRAP \
1270 ENABLE_FEAT_SEL2 \
1271 ENABLE_FEAT_TCR2 \
Jayanth Dodderi Chidanand6d0433f2024-09-05 22:24:04 +01001272 ENABLE_FEAT_THE \
Govindraj Raja0e4daed2024-01-23 16:03:53 -06001273 ENABLE_FEAT_SB \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001274 ENABLE_FEAT_S2PIE \
1275 ENABLE_FEAT_S1PIE \
1276 ENABLE_FEAT_S2POE \
1277 ENABLE_FEAT_S1POE \
Jayanth Dodderi Chidanand4ec4e542024-09-06 13:49:31 +01001278 ENABLE_FEAT_SCTLR2 \
Govindraj Raja30655132024-09-06 15:43:43 +01001279 ENABLE_FEAT_D128 \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001280 ENABLE_FEAT_GCS \
1281 ENABLE_FEAT_VHE \
Arvind Ram Prakashedebefb2023-10-11 12:10:56 -05001282 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001283 ENABLE_RME \
1284 ENABLE_SPE_FOR_NS \
1285 ENABLE_SYS_REG_TRACE_FOR_NS \
1286 ENABLE_SME_FOR_NS \
1287 ENABLE_SME2_FOR_NS \
1288 ENABLE_SVE_FOR_NS \
1289 ENABLE_TRF_FOR_NS \
1290 FW_ENC_STATUS \
1291 NR_OF_FW_BANKS \
1292 NR_OF_IMAGES_IN_FW_BANK \
1293 TWED_DELAY \
1294 ENABLE_FEAT_TWED \
1295 SVE_VECTOR_LEN \
Varun Wadekar0ed3be62023-04-13 21:06:18 +01001296 IMPDEF_SYSREG_TRAP \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001297)))
Jeenu Viswambharanc877b412017-01-16 16:52:35 +00001298
Justin Chadwellaacff742019-07-29 17:13:10 +01001299ifdef KEY_SIZE
1300 $(eval $(call assert_numeric,KEY_SIZE))
1301endif
1302
Justin Chadwell1f461972019-08-20 11:01:52 +01001303ifeq ($(filter $(SANITIZE_UB), on off trap),)
1304 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
1305endif
1306
Juan Castillo73c99d42015-08-18 14:23:04 +01001307################################################################################
1308# Add definitions to the cpp preprocessor based on the current build options.
1309# This is done after including the platform specific makefile to allow the
1310# platform to overwrite the default options
1311################################################################################
1312
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001313$(eval $(call add_defines,\
1314 $(sort \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001315 ALLOW_RO_XLAT_TABLES \
1316 ARM_ARCH_MAJOR \
1317 ARM_ARCH_MINOR \
1318 BL2_ENABLE_SP_LOAD \
1319 COLD_BOOT_SINGLE_CPU \
1320 CTX_INCLUDE_AARCH32_REGS \
1321 CTX_INCLUDE_FPREGS \
Madhukar Pappireddy42422622024-06-17 15:17:03 -05001322 CTX_INCLUDE_SVE_REGS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001323 CTX_INCLUDE_PAUTH_REGS \
Arvind Ram Prakash9acff282023-10-06 14:35:21 -05001324 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001325 EL3_EXCEPTION_HANDLING \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001326 CTX_INCLUDE_EL2_REGS \
1327 CTX_INCLUDE_NEVE_REGS \
1328 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
1329 DISABLE_MTPMU \
1330 ENABLE_FEAT_AMU \
1331 ENABLE_AMU_AUXILIARY_COUNTERS \
1332 ENABLE_AMU_FCONF \
1333 AMU_RESTRICT_COUNTERS \
1334 ENABLE_ASSERTIONS \
1335 ENABLE_BTI \
Arvind Ram Prakash83271d52024-05-22 15:24:00 -05001336 ENABLE_FEAT_DEBUGV8P9 \
Arvind Ram Prakashedebefb2023-10-11 12:10:56 -05001337 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001338 ENABLE_PAUTH \
1339 ENABLE_PIE \
1340 ENABLE_PMF \
1341 ENABLE_PSCI_STAT \
1342 ENABLE_RME \
Raghu Krishnamurthy6a88ec82024-06-03 19:02:29 -07001343 RMMD_ENABLE_EL3_TOKEN_SIGN \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001344 ENABLE_RUNTIME_INSTRUMENTATION \
1345 ENABLE_SME_FOR_NS \
1346 ENABLE_SME2_FOR_NS \
1347 ENABLE_SME_FOR_SWD \
1348 ENABLE_SPE_FOR_NS \
1349 ENABLE_SVE_FOR_NS \
1350 ENABLE_SVE_FOR_SWD \
Manish Pandey970a4a82023-10-10 13:53:25 +01001351 ENABLE_FEAT_RAS \
Manish Pandeyf87e54f2023-10-10 15:42:19 +01001352 FFH_SUPPORT \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001353 ENCRYPT_BL31 \
1354 ENCRYPT_BL32 \
1355 ERROR_DEPRECATED \
1356 FAULT_INJECTION_SUPPORT \
1357 GICV2_G0_FOR_EL3 \
1358 HANDLE_EA_EL3_FIRST_NS \
1359 HW_ASSISTED_COHERENCY \
1360 LOG_LEVEL \
1361 MEASURED_BOOT \
Tamas Bane7f11812023-06-07 13:35:04 +02001362 DICE_PROTECTION_ENVIRONMENT \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001363 DRTM_SUPPORT \
1364 NS_TIMER_SWITCH \
1365 PL011_GENERIC_UART \
1366 PLAT_${PLAT} \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001367 PROGRAMMABLE_RESET_ADDRESS \
1368 PSCI_EXTENDED_STATE_ID \
1369 PSCI_OS_INIT_MODE \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001370 RESET_TO_BL31 \
AlexeiFedorovd7660842024-05-13 15:35:54 +01001371 RME_GPT_BITLOCK_BLOCK \
AlexeiFedorovec0088b2024-03-13 17:07:03 +00001372 RME_GPT_MAX_BLOCK \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001373 SEPARATE_CODE_AND_RODATA \
1374 SEPARATE_BL2_NOLOAD_REGION \
1375 SEPARATE_NOBITS_REGION \
Ye Li86acbbe2022-08-26 13:48:31 +08001376 SEPARATE_RWDATA_REGION \
Madhukar Pappireddy308ebfa2024-06-17 15:26:00 -05001377 SEPARATE_SIMD_SECTION \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001378 RECLAIM_INIT_CODE \
1379 SPD_${SPD} \
1380 SPIN_ON_BL1_EXIT \
1381 SPM_MM \
1382 SPMC_AT_EL3 \
Nishant Sharma801cd3c2023-06-27 00:36:01 +01001383 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001384 SPMD_SPM_AT_SEL2 \
Raymond Mao3ba2c152023-07-25 07:53:35 -07001385 TRANSFER_LIST \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001386 TRUSTED_BOARD_BOOT \
1387 CRYPTO_SUPPORT \
1388 TRNG_SUPPORT \
1389 ERRATA_ABI_SUPPORT \
Sona Mathewef63f5b2023-03-14 14:02:03 -05001390 ERRATA_NON_ARM_INTERCONNECT \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001391 USE_COHERENT_MEM \
1392 USE_DEBUGFS \
1393 ARM_IO_IN_DTB \
1394 SDEI_IN_FCONF \
1395 SEC_INT_DESC_IN_FCONF \
1396 USE_ROMLIB \
1397 USE_TBBR_DEFS \
1398 WARMBOOT_ENABLE_DCACHE_EARLY \
1399 RESET_TO_BL2 \
1400 BL2_RUNS_AT_EL3 \
1401 BL2_IN_XIP_MEM \
1402 BL2_INV_DCACHE \
1403 USE_SPINLOCK_CAS \
1404 ERRATA_SPECULATIVE_AT \
1405 RAS_TRAP_NS_ERR_REC_ACCESS \
1406 COT_DESC_IN_DTB \
1407 USE_SP804_TIMER \
1408 ENABLE_FEAT_RNG \
1409 ENABLE_FEAT_RNG_TRAP \
1410 ENABLE_FEAT_SB \
1411 ENABLE_FEAT_DIT \
1412 NR_OF_FW_BANKS \
1413 NR_OF_IMAGES_IN_FW_BANK \
1414 PSA_FWU_SUPPORT \
Sughosh Ganu11d05a72024-02-01 12:51:20 +05301415 PSA_FWU_METADATA_FW_STORE_DESC \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001416 ENABLE_BRBE_FOR_NS \
1417 ENABLE_TRBE_FOR_NS \
1418 ENABLE_SYS_REG_TRACE_FOR_NS \
1419 ENABLE_TRF_FOR_NS \
1420 ENABLE_FEAT_HCX \
1421 ENABLE_MPMM \
1422 ENABLE_MPMM_FCONF \
1423 ENABLE_FEAT_FGT \
Arvind Ram Prakash33e6aaa2024-06-06 11:33:37 -05001424 ENABLE_FEAT_FGT2 \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001425 ENABLE_FEAT_ECV \
1426 ENABLE_FEAT_AMUv1p1 \
1427 ENABLE_FEAT_SEL2 \
1428 ENABLE_FEAT_VHE \
1429 ENABLE_FEAT_CSV2_2 \
Sona Mathew30019d82023-10-25 16:48:19 -05001430 ENABLE_FEAT_CSV2_3 \
Andre Przywara19d52a82024-08-09 17:04:22 +01001431 ENABLE_FEAT_LS64_ACCDATA \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001432 ENABLE_FEAT_PAN \
1433 ENABLE_FEAT_TCR2 \
Jayanth Dodderi Chidanand6d0433f2024-09-05 22:24:04 +01001434 ENABLE_FEAT_THE \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001435 ENABLE_FEAT_S2PIE \
1436 ENABLE_FEAT_S1PIE \
1437 ENABLE_FEAT_S2POE \
1438 ENABLE_FEAT_S1POE \
Jayanth Dodderi Chidanand4ec4e542024-09-06 13:49:31 +01001439 ENABLE_FEAT_SCTLR2 \
Govindraj Raja30655132024-09-06 15:43:43 +01001440 ENABLE_FEAT_D128 \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001441 ENABLE_FEAT_GCS \
Govindraj Raja8e397882024-01-26 10:08:37 -06001442 ENABLE_FEAT_MTE2 \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001443 FEATURE_DETECTION \
1444 TWED_DELAY \
1445 ENABLE_FEAT_TWED \
Okash Khawaja04c73032022-11-04 12:38:01 +00001446 CONDITIONAL_CMO \
Varun Wadekar0ed3be62023-04-13 21:06:18 +01001447 IMPDEF_SYSREG_TRAP \
Jayanth Dodderi Chidananda8cf6fa2023-04-26 15:57:30 +01001448 SVE_VECTOR_LEN \
Raghu Krishnamurthy890b5082023-02-25 13:26:10 -08001449 ENABLE_SPMD_LP \
Manish V Badarkhe5782b892023-09-06 09:08:28 +01001450 PSA_CRYPTO \
Sandrine Bailleux85bebe12023-10-11 08:38:00 +02001451 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash183329a2023-08-15 16:28:06 -05001452 INIT_UNUSED_NS_EL2 \
Juan Pablo Condebfef8b92023-11-08 16:14:28 -06001453 PLATFORM_REPORT_CTX_MEM_USE \
Yann Gautierae770fe2024-01-16 19:39:31 +01001454 EARLY_CONSOLE \
Arvind Ram Prakashf99a69c2023-12-21 00:25:52 -06001455 PRESERVE_DSU_PMU_REGS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001456)))
Jeenu Viswambharan2fae4b12016-10-24 14:31:51 +01001457
Juan Pablo Condebfef8b92023-11-08 16:14:28 -06001458ifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1)
1459ifeq (${DEBUG}, 0)
1460 $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only")
1461 override PLATFORM_REPORT_CTX_MEM_USE := 0
1462endif
1463endif
1464
Justin Chadwell1f461972019-08-20 11:01:52 +01001465ifeq (${SANITIZE_UB},trap)
1466 $(eval $(call add_define,MONITOR_TRAPS))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001467endif #(SANITIZE_UB)
Justin Chadwell1f461972019-08-20 11:01:52 +01001468
Sandrine Bailleux4c117f62015-11-26 16:31:34 +00001469# Define the EL3_PAYLOAD_BASE flag only if it is provided.
1470ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +00001471 $(eval $(call add_define,EL3_PAYLOAD_BASE))
1472else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001473# Define the PRELOADED_BL33_BASE flag only if it is provided and
1474# EL3_PAYLOAD_BASE is not defined, as it has priority.
1475 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz68450a62016-04-06 17:31:57 +01001476 $(eval $(call add_define,PRELOADED_BL33_BASE))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001477 endif
1478endif #(EL3_PAYLOAD_BASE)
Juan Castillo73c99d42015-08-18 14:23:04 +01001479
Soby Mathew209a60c2018-03-26 12:43:37 +01001480# Define the DYN_DISABLE_AUTH flag only if set.
1481ifeq (${DYN_DISABLE_AUTH},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001482 $(eval $(call add_define,DYN_DISABLE_AUTH))
Soby Mathew209a60c2018-03-26 12:43:37 +01001483endif
1484
Chris Kay8620bd02023-12-04 09:55:50 +00001485ifeq ($($(ARCH)-ld-id),arm-link)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001486 $(eval $(call add_define,USE_ARM_LINK))
Varun Wadekarc2ad38c2019-01-11 14:47:48 -08001487endif
1488
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001489# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001490ifeq (${SPD},spmd)
Olivier Deprezc33ff192020-03-19 09:27:11 +01001491ifdef SP_LAYOUT_FILE
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001492 -include $(BUILD_PLAT)/sp_gen.mk
1493 FIP_DEPS += sp
1494 CRT_DEPS += sp
1495 NEED_SP_PKG := yes
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001496else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001497 ifeq (${SPMD_SPM_AT_SEL2},1)
1498 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1499 endif
1500endif #(SP_LAYOUT_FILE)
1501endif #(SPD)
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001502
Juan Castillo73c99d42015-08-18 14:23:04 +01001503################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +01001504# Build targets
1505################################################################################
1506
Harrison Mutai2329e222024-08-28 13:27:19 +00001507.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp tl fwu_fip certtool dtbs memmap doc enctool
Juan Castillo73c99d42015-08-18 14:23:04 +01001508.SUFFIXES:
1509
1510all: msg_start
1511
1512msg_start:
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001513 $(s)echo "Building ${PLAT}"
Juan Castillo73c99d42015-08-18 14:23:04 +01001514
Soby Mathew7a24cba2015-10-26 14:29:21 +00001515ifeq (${ERROR_DEPRECATED},0)
Julius Wernerd5dfdeb2019-07-09 13:49:11 -07001516# Check if deprecated declarations and cpp warnings should be treated as error or not.
Chris Kay8620bd02023-12-04 09:55:50 +00001517ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
Varun Wadekarc2ad38c2019-01-11 14:47:48 -08001518 CPPFLAGS += -Wno-error=deprecated-declarations
1519else
Dan Handleybc1a03c2018-02-27 16:03:58 +00001520 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp
Soby Mathew7a24cba2015-10-26 14:29:21 +00001521endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001522endif #(!ERROR_DEPRECATED)
Soby Mathew7a24cba2015-10-26 14:29:21 +00001523
Roberto Vargas61f72a32018-05-08 10:27:10 +01001524$(eval $(call MAKE_LIB,c))
Roberto Vargas5fee0282018-05-08 10:27:10 +01001525
Juan Castillo73c99d42015-08-18 14:23:04 +01001526# Expand build macros for the different images
1527ifeq (${NEED_BL1},yes)
Chris Kayb34635a2021-09-28 15:44:19 +01001528BL1_SOURCES := $(sort ${BL1_SOURCES})
Zelalem Aweke434d0492021-07-11 17:25:48 -05001529$(eval $(call MAKE_BL,bl1))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001530endif #(NEED_BL1)
Juan Castillo73c99d42015-08-18 14:23:04 +01001531
1532ifeq (${NEED_BL2},yes)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001533
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -06001534ifeq (${RESET_TO_BL2}, 0)
Roberto Vargasc9b31ae2018-01-02 11:23:41 +00001535FIP_BL2_ARGS := tb-fw
1536endif
1537
Chris Kayeb1acfb2021-09-28 15:44:37 +01001538BL2_SOURCES := $(sort ${BL2_SOURCES})
1539
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001540$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001541 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001542
1543endif #(NEED_BL2)
Juan Castillo73c99d42015-08-18 14:23:04 +01001544
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001545ifeq (${NEED_SCP_BL2},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001546$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001547endif #(NEED_SCP_BL2)
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001548
Juan Castillo73c99d42015-08-18 14:23:04 +01001549ifeq (${NEED_BL31},yes)
1550BL31_SOURCES += ${SPD_SOURCES}
Madhukar Pappireddy26d1e0c2020-01-27 13:37:51 -06001551# Sort BL31 source files to remove duplicates
1552BL31_SOURCES := $(sort ${BL31_SOURCES})
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301553ifneq (${DECRYPTION_SUPPORT},none)
1554$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001555 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301556else
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001557$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001558 $(eval $(call MAKE_BL,bl31,soc-fw)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001559endif #(DECRYPTION_SUPPORT)
1560endif #(NEED_BL31)
Juan Castillo73c99d42015-08-18 14:23:04 +01001561
Juan Castillo70d1fc52015-11-12 10:59:26 +00001562# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
Masahiro Yamadac939d132018-01-26 11:42:01 +09001563# build system will call TOOL_ADD_IMG to print a warning message and abort the
Juan Castillo70d1fc52015-11-12 10:59:26 +00001564# process. Note that the dependency on BL32 applies to the FIP only.
Juan Castillo73c99d42015-08-18 14:23:04 +01001565ifeq (${NEED_BL32},yes)
Madhukar Pappireddy26d1e0c2020-01-27 13:37:51 -06001566# Sort BL32 source files to remove duplicates
1567BL32_SOURCES := $(sort ${BL32_SOURCES})
Masahiro Yamada9cd15232018-01-26 11:42:01 +09001568BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
1569
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301570ifneq (${DECRYPTION_SUPPORT},none)
Zelalem Aweke434d0492021-07-11 17:25:48 -05001571$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301572 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1573else
Zelalem Aweke434d0492021-07-11 17:25:48 -05001574$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001575 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001576endif #(DECRYPTION_SUPPORT)
1577endif #(NEED_BL32)
Juan Castillo73c99d42015-08-18 14:23:04 +01001578
Zelalem Aweke5b18de02021-07-11 18:33:20 -05001579# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
1580# needs to be built from RMM_SOURCES.
1581ifeq (${NEED_RMM},yes)
1582# Sort RMM source files to remove duplicates
1583RMM_SOURCES := $(sort ${RMM_SOURCES})
1584BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
1585
1586$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001587 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1588endif #(NEED_RMM)
Zelalem Aweke5b18de02021-07-11 18:33:20 -05001589
Juan Castillo73c99d42015-08-18 14:23:04 +01001590# Add the BL33 image if required by the platform
1591ifeq (${NEED_BL33},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001592$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001593endif #(NEED_BL33)
Juan Castillodb6071c2015-01-13 12:21:04 +00001594
Yatharth Kochar9003fa02015-10-14 15:27:24 +01001595ifeq (${NEED_BL2U},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001596$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001597 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001598endif #(NEED_BL2U)
Yatharth Kochar9003fa02015-10-14 15:27:24 +01001599
Nishanth Menon03b397a2016-10-14 01:13:57 +00001600# Expand build macros for the different images
1601ifeq (${NEED_FDT},yes)
Soby Mathew38c14d82017-12-14 17:44:56 +00001602 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001603endif #(NEED_FDT)
Nishanth Menon03b397a2016-10-14 01:13:57 +00001604
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001605# Add Secure Partition packages
1606ifeq (${NEED_SP_PKG},yes)
Chris Kayfd74ca02024-07-30 13:33:56 +00001607$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | $$(@D)/
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001608 $(q)${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
J-Alves822c7272022-03-22 16:28:51 +00001609sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001610 $(s)echo
1611 $(s)echo "Built SP Images successfully"
1612 $(s)echo
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001613endif #(NEED_SP_PKG)
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001614
Ian Spray36eaaf32014-01-30 17:25:28 +00001615locate-checkpatch:
1616ifndef CHECKPATCH
Etienne Carriere66079b02017-08-23 15:44:01 +02001617 $(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 +00001618else
1619ifeq (,$(wildcard ${CHECKPATCH}))
Etienne Carriere66079b02017-08-23 15:44:01 +02001620 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
Ian Spray36eaaf32014-01-30 17:25:28 +00001621endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001622endif #(CHECKPATCH)
Ian Spray36eaaf32014-01-30 17:25:28 +00001623
Achin Gupta4f6ad662013-10-25 09:08:21 +01001624clean:
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001625 $(s)echo " CLEAN"
Evan Lloydf1477d42015-12-02 18:33:55 +00001626 $(call SHELL_REMOVE_DIR,${BUILD_PLAT})
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001627ifdef UNIX_MK
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001628 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001629else
1630# Clear the MAKEFLAGS as we do not want
1631# to pass the gnumake flags to nmake.
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001632 $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001633endif #(UNIX_MK)
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001634 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
1635 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
1636 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001637
James Morrisseyeaaeece2013-11-01 13:56:59 +00001638realclean distclean:
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001639 $(s)echo " REALCLEAN"
Evan Lloydf1477d42015-12-02 18:33:55 +00001640 $(call SHELL_REMOVE_DIR,${BUILD_BASE})
1641 $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001642ifdef UNIX_MK
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001643 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001644else
1645# Clear the MAKEFLAGS as we do not want
1646# to pass the gnumake flags to nmake.
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001647 $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001648endif #(UNIX_MK)
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001649 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
1650 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
1651 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001652
Ian Spray36eaaf32014-01-30 17:25:28 +00001653checkcodebase: locate-checkpatch
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001654 $(s)echo " CHECKING STYLE"
1655 $(q)if test -d .git ; then \
Paul Beesley1ef35512019-03-07 16:42:31 +00001656 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001657 while read GIT_FILE ; \
1658 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
1659 done ; \
1660 else \
1661 find . -type f -not -iwholename "*.git*" \
1662 -not -iwholename "*build*" \
1663 -not -iwholename "*libfdt*" \
Roberto Vargas61f72a32018-05-08 10:27:10 +01001664 -not -iwholename "*libc*" \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001665 -not -iwholename "*docs*" \
Paul Beesley1ef35512019-03-07 16:42:31 +00001666 -not -iwholename "*.rst" \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001667 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
1668 fi
Ian Spray36eaaf32014-01-30 17:25:28 +00001669
1670checkpatch: locate-checkpatch
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001671 $(s)echo " CHECKING STYLE"
1672 $(q)if test -n "${CHECKPATCH_OPTS}"; then \
Yann Gautier02a76d52019-03-08 15:44:00 +01001673 echo " with ${CHECKPATCH_OPTS} option(s)"; \
1674 fi
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001675 $(q)COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
Yann Gautier77a0a7f2021-11-02 18:03:31 +01001676 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \
1677 do \
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001678 printf "\n[*] Checking style of '$$commit'\n\n"; \
Yann Gautier1a721742024-08-09 11:52:03 +02001679 ( git log --format=email "$$commit~..$$commit" \
1680 -- ${CHECK_PATHS} ; \
1681 git diff --format=email "$$commit~..$$commit" \
1682 -- ${CHECK_PATHS}; ) | \
Yann Gautier02a76d52019-03-08 15:44:00 +01001683 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001684 done
Juan Castillo73c99d42015-08-18 14:23:04 +01001685
1686certtool: ${CRTTOOL}
Ian Spray36eaaf32014-01-30 17:25:28 +00001687
Pali Rohára9812202020-11-24 15:38:08 +01001688${CRTTOOL}: FORCE
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001689 $(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
1690 $(s)echo
1691 $(s)echo "Built $@ successfully"
1692 $(s)echo
Juan Castillo73c99d42015-08-18 14:23:04 +01001693
1694ifneq (${GENERATE_COT},0)
1695certificates: ${CRT_DEPS} ${CRTTOOL}
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001696 $(q)${CRTTOOL} ${CRT_ARGS}
1697 $(s)echo
1698 $(s)echo "Built $@ successfully"
1699 $(s)echo "Certificates can be found in ${BUILD_PLAT}"
1700 $(s)echo
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001701endif #(GENERATE_COT)
Juan Castillo73c99d42015-08-18 14:23:04 +01001702
1703${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
Pali Rohár4727fd12020-11-24 16:53:04 +01001704 $(eval ${CHECK_FIP_CMD})
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001705 $(q)${FIPTOOL} create ${FIP_ARGS} $@
1706 $(q)${FIPTOOL} info $@
1707 $(s)echo
1708 $(s)echo "Built $@ successfully"
1709 $(s)echo
Juan Castillo73c99d42015-08-18 14:23:04 +01001710
Yatharth Kochar01912622015-10-12 12:33:47 +01001711ifneq (${GENERATE_COT},0)
1712fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001713 $(q)${CRTTOOL} ${FWU_CRT_ARGS}
1714 $(s)echo
1715 $(s)echo "Built $@ successfully"
1716 $(s)echo "FWU certificates can be found in ${BUILD_PLAT}"
1717 $(s)echo
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001718endif #(GENERATE_COT)
Yatharth Kochar01912622015-10-12 12:33:47 +01001719
1720${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
Pali Rohár4727fd12020-11-24 16:53:04 +01001721 $(eval ${CHECK_FWU_FIP_CMD})
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001722 $(q)${FIPTOOL} create ${FWU_FIP_ARGS} $@
1723 $(q)${FIPTOOL} info $@
1724 $(s)echo
1725 $(s)echo "Built $@ successfully"
1726 $(s)echo
Yatharth Kochar01912622015-10-12 12:33:47 +01001727
Juan Castillo73c99d42015-08-18 14:23:04 +01001728fiptool: ${FIPTOOL}
1729fip: ${BUILD_PLAT}/${FIP_NAME}
Yatharth Kochar01912622015-10-12 12:33:47 +01001730fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
Juan Castillo6f971622014-10-21 11:30:42 +01001731
Pali Rohára9812202020-11-24 15:38:08 +01001732${FIPTOOL}: FORCE
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001733ifdef UNIX_MK
Manish V Badarkhe40469bf2024-10-03 20:50:04 +01001734 $(q)${MAKE} PLAT=${PLAT} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${FIPTOOLPATH} all
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001735else
1736# Clear the MAKEFLAGS as we do not want
1737# to pass the gnumake flags to nmake.
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001738 $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001739endif #(UNIX_MK)
Harry Liebelf58ad362014-01-10 18:00:33 +00001740
Pali Rohára9812202020-11-24 15:38:08 +01001741romlib.bin: libraries FORCE
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001742 $(q)${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES=$(call escape-shell,$(INCLUDES)) DEFINES=$(call escape-shell,$(DEFINES)) --no-print-directory -C ${ROMLIBPATH} all
Roberto Vargas5accce52018-05-22 16:05:42 +01001743
Louis Mayencourtcfe83912019-10-16 14:30:51 +01001744memmap: all
Harrison Mutaiaf5b49e2023-02-23 10:33:58 +00001745ifdef UNIX_MK
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001746 $(q)PYTHONPATH=${CURDIR}/tools/memory \
Harrison Mutaiaf5b49e2023-02-23 10:33:58 +00001747 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1748else
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001749 $(q)set PYTHONPATH=${CURDIR}/tools/memory && \
Harrison Mutaiaf5b49e2023-02-23 10:33:58 +00001750 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1751endif
Louis Mayencourtcfe83912019-10-16 14:30:51 +01001752
Harrison Mutai2329e222024-08-28 13:27:19 +00001753tl: ${BUILD_PLAT}/tl.bin
1754${BUILD_PLAT}/tl.bin: ${HW_CONFIG}
Chris Kayd2867392024-09-26 14:18:04 +00001755 $(if $(host-poetry),$(q)poetry -q install)
1756 $(q)$(if $(host-poetry),poetry run )tlc create --fdt $< -s ${FW_HANDOFF_SIZE} $@
Harrison Mutai2329e222024-08-28 13:27:19 +00001757
Madhukar Pappireddy6de32372020-01-28 12:41:20 -06001758doc:
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001759 $(s)echo " BUILD DOCUMENTATION"
1760 $(q)${MAKE} --no-print-directory -C ${DOCS_PATH} html
Madhukar Pappireddy6de32372020-01-28 12:41:20 -06001761
Sumit Garg90aa9012019-11-11 18:46:36 +05301762enctool: ${ENCTOOL}
1763
Pali Rohára9812202020-11-24 15:38:08 +01001764${ENCTOOL}: FORCE
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001765 $(q)${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} --no-print-directory -C ${ENCTOOLPATH} all
1766 $(s)echo
1767 $(s)echo "Built $@ successfully"
1768 $(s)echo
Sumit Garg90aa9012019-11-11 18:46:36 +05301769
Joakim Bech35fab8c2014-01-23 14:51:49 +01001770cscope:
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001771 $(s)echo " CSCOPE"
1772 $(q)find ${CURDIR} -name "*.[chsS]" > cscope.files
1773 $(q)cscope -b -q -k
Joakim Bech35fab8c2014-01-23 14:51:49 +01001774
Ryan Harkin72ee3312014-01-15 16:55:07 +00001775help:
Chris Kay7c4e1ee2024-05-02 17:52:37 +00001776 $(s)echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
1777 $(s)echo ""
1778 $(s)echo "PLAT is used to specify which platform you wish to build."
1779 $(s)echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
1780 $(s)echo ""
1781 $(s)echo "platform = ${PLATFORM_LIST}"
1782 $(s)echo ""
1783 $(s)echo "Please refer to the User Guide for a list of all supported options."
1784 $(s)echo "Note that the build system doesn't track dependencies for build "
1785 $(s)echo "options. Therefore, if any of the build options are changed "
1786 $(s)echo "from a previous build, a clean build must be performed."
1787 $(s)echo ""
1788 $(s)echo "Supported Targets:"
1789 $(s)echo " all Build all individual bootloader binaries"
1790 $(s)echo " bl1 Build the BL1 binary"
1791 $(s)echo " bl2 Build the BL2 binary"
1792 $(s)echo " bl2u Build the BL2U binary"
1793 $(s)echo " bl31 Build the BL31 binary"
1794 $(s)echo " bl32 Build the BL32 binary. If ARCH=aarch32, then "
1795 $(s)echo " this builds secure payload specified by AARCH32_SP"
1796 $(s)echo " certificates Build the certificates (requires 'GENERATE_COT=1')"
1797 $(s)echo " fip Build the Firmware Image Package (FIP)"
1798 $(s)echo " fwu_fip Build the FWU Firmware Image Package (FIP)"
1799 $(s)echo " checkcodebase Check the coding style of the entire source tree"
1800 $(s)echo " checkpatch Check the coding style on changes in the current"
1801 $(s)echo " branch against BASE_COMMIT (default origin/master)"
1802 $(s)echo " clean Clean the build for the selected platform"
1803 $(s)echo " cscope Generate cscope index"
1804 $(s)echo " distclean Remove all build artifacts for all platforms"
1805 $(s)echo " certtool Build the Certificate generation tool"
1806 $(s)echo " enctool Build the Firmware encryption tool"
1807 $(s)echo " fiptool Build the Firmware Image Package (FIP) creation tool"
1808 $(s)echo " sp Build the Secure Partition Packages"
1809 $(s)echo " sptool Build the Secure Partition Package creation tool"
1810 $(s)echo " dtbs Build the Device Tree Blobs (if required for the platform)"
1811 $(s)echo " memmap Print the memory map of the built binaries"
1812 $(s)echo " doc Build html based documentation using Sphinx tool"
1813 $(s)echo ""
1814 $(s)echo "Note: most build targets require PLAT to be set to a specific platform."
1815 $(s)echo ""
1816 $(s)echo "example: build all targets for the FVP platform:"
1817 $(s)echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
Pali Rohára9812202020-11-24 15:38:08 +01001818
1819.PHONY: FORCE
1820FORCE:;