blob: 2b6857b5b5748d253da8d5aa1e9e6bdf6a48ca01 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001#
Govindraj Raja24d3a4e2023-12-21 13:57:49 -06002# Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003#
dp-armfa3cf0b2017-05-03 09:38:09 +01004# SPDX-License-Identifier: BSD-3-Clause
Achin Gupta4f6ad662013-10-25 09:08:21 +01005#
6
Jeenu Viswambharan19a0ace2014-05-15 14:40:58 +01007#
Juan Castillo04be3a52014-06-30 11:41:46 +01008# Trusted Firmware Version
9#
Soby Mathewd42eaee2018-10-01 16:16:34 +010010VERSION_MAJOR := 2
Govindraj Rajacf5f9802024-11-15 09:56:50 +010011VERSION_MINOR := 12
Yann Gautier5f4cbed2024-02-08 18:40:27 +010012# VERSION_PATCH is only used for LTS releases
13VERSION_PATCH := 0
Yann Gautier57078a92023-10-03 11:09:07 +020014VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
Juan Castillo04be3a52014-06-30 11:41:46 +010015
Juan Castillo396644b2015-10-22 11:34:44 +010016# Default goal is build all images
17.DEFAULT_GOAL := all
18
Douglas Raillard527cd902016-12-28 14:47:50 +000019# Avoid any implicit propagation of command line variable definitions to
20# sub-Makefiles, like CFLAGS that we reserved for the firmware images'
21# usage. Other command line options like "-s" are still propagated as usual.
22MAKEOVERRIDES =
23
Evan Lloydf2697142015-12-02 18:17:37 +000024MAKE_HELPERS_DIRECTORY := make_helpers/
25include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
Evan Lloyda71d2592015-12-02 18:56:06 +000026include ${MAKE_HELPERS_DIRECTORY}build_env.mk
Chris Kay1559f642024-06-04 00:04:48 +000027include ${MAKE_HELPERS_DIRECTORY}build-rules.mk
Chris Kay1870c722024-05-02 17:52:37 +000028include ${MAKE_HELPERS_DIRECTORY}common.mk
Juan Castilloa3487d12015-08-18 14:23:04 +010029
30################################################################################
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010031# Default values for build configurations, and their dependencies
Juan Castilloa3487d12015-08-18 14:23:04 +010032################################################################################
Jeenu Viswambharan19a0ace2014-05-15 14:40:58 +010033
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010034include ${MAKE_HELPERS_DIRECTORY}defaults.mk
Andrey Skvortsov89c3a142024-02-18 11:43:12 +030035include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
36
37# To be able to set platform specific defaults
38ifneq ($(PLAT_DEFAULTS_MAKEFILE_FULL),)
39include ${PLAT_DEFAULTS_MAKEFILE_FULL}
40endif
dp-arm3cac7862016-09-19 11:18:44 +010041
Chris Kayc8a47ba2023-10-20 09:17:33 +000042################################################################################
43# Configure the toolchains used to build TF-A and its tools
44################################################################################
45
46include ${MAKE_HELPERS_DIRECTORY}toolchain.mk
47
Antonio Nino Diaz808c2292017-04-18 15:16:05 +010048# Assertions enabled for DEBUG builds by default
Antonio Nino Diaz808c2292017-04-18 15:16:05 +010049ENABLE_ASSERTIONS := ${DEBUG}
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010050ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION}
Achin Gupta4f6ad662013-10-25 09:08:21 +010051
Juan Castilloa3487d12015-08-18 14:23:04 +010052################################################################################
53# Checkpatch script options
54################################################################################
55
Sandrine Bailleux0b5a1582016-06-02 11:19:59 +010056CHECKCODE_ARGS := --no-patch
Dan Handleyd7b59e42016-06-02 17:15:13 +010057# Do not check the coding style on imported library files or documentation files
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030058INC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \
59 include/drivers/arm, \
60 $(wildcard include/drivers/*)))
Dan Handleyd7b59e42016-06-02 17:15:13 +010061INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \
Dan Handley3a355712016-06-02 18:21:02 +010062 include/lib/libfdt \
Roberto Vargas0f8f9852018-05-08 10:27:10 +010063 include/lib/libc, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010064 $(wildcard include/lib/*)))
65INC_DIRS_TO_CHECK := $(sort $(filter-out \
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030066 include/lib \
67 include/drivers, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010068 $(wildcard include/*)))
69LIB_DIRS_TO_CHECK := $(sort $(filter-out \
dp-arme3cc8382017-05-04 12:15:35 +010070 lib/compiler-rt \
Antonio Nino Diazd84f88e2017-01-16 17:20:45 +000071 lib/libfdt% \
Roberto Vargas0f8f9852018-05-08 10:27:10 +010072 lib/libc, \
Daniel Boulby958f1dd2022-10-05 11:05:22 +010073 lib/zlib \
Dan Handleyd7b59e42016-06-02 17:15:13 +010074 $(wildcard lib/*)))
75ROOT_DIRS_TO_CHECK := $(sort $(filter-out \
76 lib \
77 include \
78 docs \
Paul Beesleyadfab5b2019-03-07 16:42:31 +000079 %.rst, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010080 $(wildcard *)))
81CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \
82 ${INC_DIRS_TO_CHECK} \
83 ${INC_LIB_DIRS_TO_CHECK} \
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030084 ${LIB_DIRS_TO_CHECK} \
85 ${INC_DRV_DIRS_TO_CHECK} \
86 ${INC_ARM_DIRS_TO_CHECK}
Ian Spray36eaaf32014-01-30 17:25:28 +000087
Juan Castilloa3487d12015-08-18 14:23:04 +010088################################################################################
89# Process build options
90################################################################################
91
Chris Kay1870c722024-05-02 17:52:37 +000092ifeq ($(verbose),)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +010093 CHECKCODE_ARGS += --no-summary --terse
Achin Gupta4f6ad662013-10-25 09:08:21 +010094endif
Andre Przywaracf2bb082018-09-27 10:56:05 +010095
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +010096################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +010097# Auxiliary tools (fiptool, cert_create, etc)
98################################################################################
99
100# Variables for use with Certificate Generation Tool
101CRTTOOLPATH ?= tools/cert_create
102CRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT}
103
104# Variables for use with Firmware Encryption Tool
105ENCTOOLPATH ?= tools/encrypt_fw
106ENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
107
108# Variables for use with Firmware Image Package
109FIPTOOLPATH ?= tools/fiptool
110FIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT}
111
112# Variables for use with sptool
113SPTOOLPATH ?= tools/sptool
114SPTOOL ?= ${SPTOOLPATH}/sptool.py
115SP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py
Karl Meakinaba46182023-02-14 11:56:02 +0000116SP_DTS_LIST_FRAGMENT ?= ${BUILD_PLAT}/sp_list_fragment.dts
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100117
118# Variables for use with ROMLIB
119ROMLIBPATH ?= lib/romlib
120
121# Variable for use with Python
122PYTHON ?= python3
123
124# Variables for use with documentation build using Sphinx tool
125DOCS_PATH ?= docs
126
127################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100128# Compiler Configuration based on ARCH_MAJOR and ARCH_MINOR flags
Juan Castilloa3487d12015-08-18 14:23:04 +0100129################################################################################
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100130ifeq (${ARM_ARCH_MAJOR},7)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100131 target32-directive = -target arm-none-eabi
Govindraj Rajacd10c6e2023-05-30 16:52:15 -0500132# Will set march-directive from platform configuration
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100133else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100134 target32-directive = -target armv8a-none-eabi
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100135endif #(ARM_ARCH_MAJOR)
136
137################################################################################
138# Get Architecture Feature Modifiers
139################################################################################
140arch-features = ${ARM_ARCH_FEATURE}
141
Chris Kaycfba6452023-12-04 09:55:50 +0000142ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
143 ifeq ($($(ARCH)-cc-id),arm-clang)
Govindraj Raja69096412023-06-01 16:29:16 -0500144 TF_CFLAGS_aarch32 := -target arm-arm-none-eabi
145 TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi
originfba80d82022-01-19 16:30:14 +0000146 else
Govindraj Raja69096412023-06-01 16:29:16 -0500147 TF_CFLAGS_aarch32 = $(target32-directive)
148 TF_CFLAGS_aarch64 := -target aarch64-elf
originfba80d82022-01-19 16:30:14 +0000149 endif
150
Chris Kaycfba6452023-12-04 09:55:50 +0000151else ifeq ($($(ARCH)-cc-id),gnu-gcc)
Chris Kay00416dc2024-02-20 16:19:54 +0000152 # Enable LTO only for aarch64
153 ifeq (${ARCH},aarch64)
154 LTO_CFLAGS = $(if $(filter-out 0,$(ENABLE_LTO)),-flto)
zelalem-aweked5f45272019-11-12 16:20:17 -0600155 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100156endif #(clang)
dp-arm320e8442017-05-02 12:00:08 +0100157
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100158# Process Debug flag
159$(eval $(call add_define,DEBUG))
160ifneq (${DEBUG}, 0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100161 BUILD_TYPE := debug
162 TF_CFLAGS += -g -gdwarf-4
163 ASFLAGS += -g -Wa,-gdwarf-4
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100164
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100165 # Use LOG_LEVEL_INFO by default for debug builds
166 LOG_LEVEL := 40
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100167else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100168 BUILD_TYPE := release
169 # Use LOG_LEVEL_NOTICE by default for release builds
170 LOG_LEVEL := 20
171endif #(Debug)
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100172
Peiyuan Song44f8f472020-04-25 16:53:43 +0800173# Default build string (git branch and commit)
174ifeq (${BUILD_STRING},)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100175 BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null)
Peiyuan Song44f8f472020-04-25 16:53:43 +0800176endif
laurenw-arme954f652022-07-12 10:12:05 -0500177VERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
Peiyuan Song44f8f472020-04-25 16:53:43 +0800178
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100179ifeq (${AARCH32_INSTRUCTION_SET},A32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100180 TF_CFLAGS_aarch32 += -marm
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100181else ifeq (${AARCH32_INSTRUCTION_SET},T32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100182 TF_CFLAGS_aarch32 += -mthumb
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100183else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100184 $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
185endif #(AARCH32_INSTRUCTION_SET)
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100186
Sandrine Bailleux1aa72ec2018-07-03 09:14:45 +0200187TF_CFLAGS_aarch32 += -mno-unaligned-access
dp-arm320e8442017-05-02 12:00:08 +0100188TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align
Soby Mathewa1941252016-05-05 14:33:33 +0100189
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100190##############################################################################
191# WARNINGS Configuration
192###############################################################################
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100193# General warnings
194WARNINGS := -Wall -Wmissing-include-dirs -Wunused \
Yann Gautier94a40b62021-05-20 13:18:14 +0200195 -Wdisabled-optimization -Wvla -Wshadow \
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000196 -Wredundant-decls
197# stricter warnings
198WARNINGS += -Wextra -Wno-trigraphs
199# too verbose for generic build
200WARNINGS += -Wno-missing-field-initializers \
201 -Wno-type-limits -Wno-sign-compare \
202# on clang this flag gets reset if -Wextra is set after it. No difference on gcc
203WARNINGS += -Wno-unused-parameter
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100204
205# Additional warnings
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000206# Level 1 - infrequent warnings we should have none of
207# full -Wextra
208WARNING1 += -Wsign-compare
209WARNING1 += -Wtype-limits
210WARNING1 += -Wmissing-field-initializers
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100211
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000212# Level 2 - problematic warnings that we want
213# zlib, compiler-rt, coreboot, and mbdedtls blow up with these
214# TODO: disable just for them and move into default build
215WARNING2 += -Wold-style-definition
216WARNING2 += -Wmissing-prototypes
217WARNING2 += -Wmissing-format-attribute
218# TF-A aims to comply with this eventually. Effort too large at present
219WARNING2 += -Wundef
Boyan Karatotev9c6ba592022-11-21 14:49:05 +0000220# currently very involved and many platforms set this off
221WARNING2 += -Wunused-const-variable=2
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100222
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000223# Level 3 - very pedantic, frequently ignored
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100224WARNING3 := -Wbad-function-cast
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000225WARNING3 += -Waggregate-return
226WARNING3 += -Wnested-externs
227WARNING3 += -Wcast-align
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100228WARNING3 += -Wcast-qual
229WARNING3 += -Wconversion
230WARNING3 += -Wpacked
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100231WARNING3 += -Wpointer-arith
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100232WARNING3 += -Wswitch-default
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100233
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000234# Setting W is quite verbose and most warnings will be pre-existing issues
235# outside of the contributor's control. Don't fail the build on them so warnings
236# can be seen and hopefully addressed
237ifdef W
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100238 ifneq (${W},0)
239 E ?= 0
240 endif
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000241endif
242
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100243ifeq (${W},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100244 WARNINGS += $(WARNING1)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100245else ifeq (${W},2)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100246 WARNINGS += $(WARNING1) $(WARNING2)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100247else ifeq (${W},3)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100248 WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
249endif #(W)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100250
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100251# Compiler specific warnings
Chris Kaycfba6452023-12-04 09:55:50 +0000252ifeq ($(filter %-clang,$($(ARCH)-cc-id)),)
Justin Chadwell7a914232019-07-03 14:15:56 +0100253# not using clang
Justin Chadwell42d18ca2019-09-18 14:13:42 +0100254WARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \
255 -Wpacked-bitfield-compat -Wshift-overflow=2 \
256 -Wlogical-op
Govindraj Rajaaa8ef3f2023-05-05 09:09:36 -0500257
258# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
Boyan Karatoteve9f127f2024-10-10 13:54:37 +0100259TF_CFLAGS_MIN_PAGE_SIZE := $(call cc_option, --param=min-pagesize=0)
260TF_CFLAGS += $(TF_CFLAGS_MIN_PAGE_SIZE)
Govindraj Rajaaa8ef3f2023-05-05 09:09:36 -0500261
Bipin Ravie53e6ae2023-09-28 13:17:24 -0500262ifeq ($(HARDEN_SLS), 1)
Boyan Karatoteve9f127f2024-10-10 13:54:37 +0100263 TF_CFLAGS_MHARDEN_SLS := $(call cc_option, -mharden-sls=all)
264 TF_CFLAGS_aarch64 += $(TF_CFLAGS_MHARDEN_SLS)
Bipin Ravie53e6ae2023-09-28 13:17:24 -0500265endif
266
Justin Chadwell7a914232019-07-03 14:15:56 +0100267else
268# using clang
Justin Chadwell42d18ca2019-09-18 14:13:42 +0100269WARNINGS += -Wshift-overflow -Wshift-sign-overflow \
270 -Wlogical-op-parentheses
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100271endif #(Clang Warning)
Ambroise Vincent067e4d92019-05-24 12:47:43 +0100272
Yann Gautier957c3532018-12-10 18:08:53 +0100273ifneq (${E},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100274 ERRORS := -Werror
275endif #(E)
Yann Gautier957c3532018-12-10 18:08:53 +0100276
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100277################################################################################
278# Compiler and Linker Directives
279################################################################################
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100280CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
281 $(ERRORS) $(WARNINGS)
Govindraj Rajacd10c6e2023-05-30 16:52:15 -0500282ASFLAGS += $(CPPFLAGS) \
Julius Werner53456fc2019-07-09 13:49:11 -0700283 -ffreestanding -Wa,--fatal-warnings
Masahiro Yamada0dec9fa2016-12-22 12:51:53 +0900284TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \
Samuel Holland23f5e542019-10-20 16:11:25 -0500285 -ffunction-sections -fdata-sections \
286 -ffreestanding -fno-builtin -fno-common \
287 -Os -std=gnu99
Juan Castilloa3487d12015-08-18 14:23:04 +0100288
Justin Chadwell83e04882019-08-20 11:01:52 +0100289ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100290 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover
291endif #(${SANITIZE_UB},on)
292
Justin Chadwell83e04882019-08-20 11:01:52 +0100293ifeq (${SANITIZE_UB},trap)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100294 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \
Justin Chadwell83e04882019-08-20 11:01:52 +0100295 -fsanitize-undefined-trap-on-error
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100296endif #(${SANITIZE_UB},trap)
Justin Chadwell83e04882019-08-20 11:01:52 +0100297
Chris Kay0adde4e2024-05-14 13:08:31 +0000298GCC_V_OUTPUT := $(if $($(ARCH)-cc),$(shell $($(ARCH)-cc) -v 2>&1))
david cunado34ab6092017-11-30 21:58:01 +0000299
Marco Felsch24ad8402022-11-09 12:59:09 +0100300TF_LDFLAGS += -z noexecstack
301
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100302# LD = armlink
Chris Kaycfba6452023-12-04 09:55:50 +0000303ifeq ($($(ARCH)-ld-id),arm-link)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100304 TF_LDFLAGS += --diag_error=warning --lto_level=O1
305 TF_LDFLAGS += --remove --info=unused,unusedsymbols
306 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100307
308# LD = gcc (used when GCC LTO is enabled)
Chris Kaycfba6452023-12-04 09:55:50 +0000309else ifeq ($($(ARCH)-ld-id),gnu-gcc)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100310 # Pass ld options with Wl or Xlinker switches
Chris Kayb0fe96f2024-01-16 11:53:35 +0000311 TF_LDFLAGS += $(call ld_option,-Xlinker --no-warn-rwx-segments)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100312 TF_LDFLAGS += -Wl,--fatal-warnings -O1
313 TF_LDFLAGS += -Wl,--gc-sections
Chris Kay73b1f402022-12-22 13:26:37 +0000314
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100315 TF_LDFLAGS += -Wl,-z,common-page-size=4096 #Configure page size constants
316 TF_LDFLAGS += -Wl,-z,max-page-size=4096
Andrey Skvortsove2ebb722023-09-05 23:06:29 +0300317 TF_LDFLAGS += -Wl,--build-id=none
Chris Kay73b1f402022-12-22 13:26:37 +0000318
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100319 ifeq ($(ENABLE_LTO),1)
320 ifeq (${ARCH},aarch64)
321 TF_LDFLAGS += -flto -fuse-linker-plugin
Andrey Skvortsov664d6502023-12-08 18:04:51 +0300322 TF_LDFLAGS += -flto-partition=one
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100323 endif
324 endif #(ENABLE_LTO)
325
zelalem-aweked5f45272019-11-12 16:20:17 -0600326# GCC automatically adds fix-cortex-a53-843419 flag when used to link
327# which breaks some builds, so disable if errata fix is not explicitly enabled
Yann Gautier3d73d162023-03-15 16:18:16 +0100328 ifeq (${ARCH},aarch64)
329 ifneq (${ERRATA_A53_843419},1)
330 TF_LDFLAGS += -mno-fix-cortex-a53-843419
331 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100332 endif
333 TF_LDFLAGS += -nostdlib
334 TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100335
336# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
Varun Wadekar4d034c52019-01-11 14:47:48 -0800337else
Marco Felsch24ad8402022-11-09 12:59:09 +0100338# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
339# are not loaded by a elf loader.
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100340 TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments)
341 TF_LDFLAGS += -O1
342 TF_LDFLAGS += --gc-sections
Chris Kay73b1f402022-12-22 13:26:37 +0000343
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100344 TF_LDFLAGS += -z common-page-size=4096 # Configure page size constants
345 TF_LDFLAGS += -z max-page-size=4096
Andrey Skvortsove2ebb722023-09-05 23:06:29 +0300346 TF_LDFLAGS += --build-id=none
Chris Kay73b1f402022-12-22 13:26:37 +0000347
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100348# ld.lld doesn't recognize the errata flags,
Yabin Cuied7dc512023-01-19 20:06:04 +0000349# therefore don't add those in that case.
350# ld.lld reports section type mismatch warnings,
351# therefore don't add --fatal-warnings to it.
Chris Kaycfba6452023-12-04 09:55:50 +0000352 ifneq ($($(ARCH)-ld-id),llvm-lld)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100353 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) --fatal-warnings
354 endif
355
356endif #(LD = armlink)
Juan Castilloa3487d12015-08-18 14:23:04 +0100357
358################################################################################
Govindraj Raja0386e312023-08-17 10:41:48 -0500359# Setup ARCH_MAJOR/MINOR before parsing arch_features.
360################################################################################
361ifeq (${ENABLE_RME},1)
AlexeiFedorov65258452024-03-13 11:53:44 +0000362 ARM_ARCH_MAJOR := 9
363 ARM_ARCH_MINOR := 2
Govindraj Raja0386e312023-08-17 10:41:48 -0500364endif
365
366################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +0100367# Common sources and include directories
368################################################################################
dp-arme3cc8382017-05-04 12:15:35 +0100369include lib/compiler-rt/compiler-rt.mk
Juan Castilloa3487d12015-08-18 14:23:04 +0100370
Chris Kay99b5b2e2024-03-08 16:08:31 +0000371# Allow overriding the timestamp, for example for reproducible builds, or to
372# synchronize timestamps across multiple projects.
373# This must be set to a C string (including quotes where applicable).
374BUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__
375
376DEFINES += -DBUILD_MESSAGE_TIMESTAMP='$(BUILD_MESSAGE_TIMESTAMP)'
377DEFINES += -DBUILD_MESSAGE_VERSION_STRING='"$(VERSION_STRING)"'
378DEFINES += -DBUILD_MESSAGE_VERSION='"$(VERSION)"'
379
Juan Castilloa3487d12015-08-18 14:23:04 +0100380BL_COMMON_SOURCES += common/bl_common.c \
Soby Mathewaaf15f52017-09-04 11:49:29 +0100381 common/tf_log.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100382 common/${ARCH}/debug.S \
Julius Werner03020da2018-11-27 22:10:56 -0800383 drivers/console/multi_console.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100384 lib/${ARCH}/cache_helpers.S \
385 lib/${ARCH}/misc_helpers.S \
Boyan Karatotev05504ba2023-02-15 13:21:50 +0000386 lib/extensions/pmuv3/${ARCH}/pmuv3.c \
Soby Mathew2f38ce32018-02-08 17:45:12 +0000387 plat/common/plat_bl_common.c \
Soby Mathewaaf15f52017-09-04 11:49:29 +0100388 plat/common/plat_log_common.c \
dp-arm230011c2017-03-07 11:02:47 +0000389 plat/common/${ARCH}/plat_common.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100390 plat/common/${ARCH}/platform_helpers.S \
Roberto Vargas0f8f9852018-05-08 10:27:10 +0100391 ${COMPILER_RT_SRCS}
Ryan Harkind7a6b0f2014-01-13 14:40:13 +0000392
Chris Kaycfba6452023-12-04 09:55:50 +0000393ifeq ($($(ARCH)-cc-id),arm-clang)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100394 BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S
Antonio Nino Diazeea20fc2018-08-16 15:42:44 +0100395endif
396
Justin Chadwell83e04882019-08-20 11:01:52 +0100397ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100398 BL_COMMON_SOURCES += plat/common/ubsan.c
Justin Chadwell83e04882019-08-20 11:01:52 +0100399endif
400
Yann Gautier2cf1dbc2018-06-18 16:00:23 +0200401INCLUDES += -Iinclude \
Antonio Nino Diaz8d1ade62018-12-17 17:20:57 +0000402 -Iinclude/arch/${ARCH} \
Antonio Nino Diaze0f90632018-12-14 00:18:21 +0000403 -Iinclude/lib/cpus/${ARCH} \
404 -Iinclude/lib/el3_runtime/${ARCH} \
405 ${PLAT_INCLUDES} \
406 ${SPD_INCLUDES}
407
Nishant Sharma331b5682022-08-15 16:37:07 +0100408DTC_FLAGS += -I dts -O dtb
409DTC_CPPFLAGS += -P -nostdinc $(INCLUDES) -Ifdts -undef \
410 -x assembler-with-cpp $(DEFINES)
411
Antonio Nino Diazc3a2cf22018-11-19 11:48:30 +0000412include common/backtrace/backtrace.mk
413
Juan Castilloa3487d12015-08-18 14:23:04 +0100414################################################################################
Govindraj Raja1a211292023-09-20 14:32:24 -0500415# Generic definitions
416################################################################################
Govindraj Raja1a211292023-09-20 14:32:24 -0500417
418ifeq (${BUILD_BASE},)
419 BUILD_BASE := ./build
420endif
421BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
422
423SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
424
425# Platforms providing their own TBB makefile may override this value
426INCLUDE_TBBR_MK := 1
427
428################################################################################
429# Include SPD Makefile if one has been specified
430################################################################################
431
432ifneq (${SPD},none)
433 ifeq (${ARCH},aarch32)
434 $(error "Error: SPD is incompatible with AArch32.")
435 endif
436
437 ifdef EL3_PAYLOAD_BASE
438 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
439 $(warning "The SPD and its BL32 companion will be present but \
440 ignored.")
441 endif
442
443 ifeq (${SPD},spmd)
444 # SPMD is located in std_svc directory
445 SPD_DIR := std_svc
446
447 ifeq ($(SPMD_SPM_AT_SEL2),1)
448 CTX_INCLUDE_EL2_REGS := 1
449 ifeq ($(SPMC_AT_EL3),1)
450 $(error SPM cannot be enabled in both S-EL2 and EL3.)
451 endif
Madhukar Pappireddy7503cdc2024-04-25 23:01:00 -0500452 ifeq ($(CTX_INCLUDE_SVE_REGS),1)
453 $(error SVE context management not needed with Hafnium SPMC.)
454 endif
Govindraj Raja1a211292023-09-20 14:32:24 -0500455 endif
456
457 ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
458 DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG
459 endif
460
Arunachalam Ganapathyfd29d582022-04-11 14:36:54 +0100461 ifeq ($(findstring trusty_sp,$(ARM_SPMC_MANIFEST_DTS)),trusty_sp)
462 DTC_CPPFLAGS += -DTRUSTY_SP_FW_CONFIG
463 endif
464
Govindraj Raja1a211292023-09-20 14:32:24 -0500465 ifeq ($(TS_SP_FW_CONFIG),1)
Arunachalam Ganapathyfd29d582022-04-11 14:36:54 +0100466 DTC_CPPFLAGS += -DTS_SP_FW_CONFIG
Govindraj Raja1a211292023-09-20 14:32:24 -0500467 endif
468
469 ifneq ($(ARM_BL2_SP_LIST_DTS),)
470 DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
471 endif
472
473 ifneq ($(SP_LAYOUT_FILE),)
474 BL2_ENABLE_SP_LOAD := 1
475 endif
Govindraj Rajabad835a2023-10-31 14:48:11 -0500476
477 ifeq ($(SPMC_AT_EL3_SEL0_SP),1)
478 ifneq ($(SPMC_AT_EL3),1)
479 $(error SEL0 SP cannot be enabled without SPMC at EL3)
480 endif
481 endif
Govindraj Raja1a211292023-09-20 14:32:24 -0500482 else
483 # All other SPDs in spd directory
484 SPD_DIR := spd
485 endif #(SPD)
486
487 # We expect to locate an spd.mk under the specified SPD directory
488 SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
489
490 ifeq (${SPD_MAKE},)
491 $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
492 endif
493 $(info Including ${SPD_MAKE})
494 include ${SPD_MAKE}
495
496 # If there's BL32 companion for the chosen SPD, we expect that the SPD's
497 # Makefile would set NEED_BL32 to "yes". In this case, the build system
498 # supports two mutually exclusive options:
499 # * BL32 is built from source: then BL32_SOURCES must contain the list
500 # of source files to build BL32
501 # * BL32 is a prebuilt binary: then BL32 must point to the image file
502 # that will be included in the FIP
503 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
504 # over the sources.
505endif #(SPD=none)
506
507ifeq (${ENABLE_SPMD_LP}, 1)
508ifneq (${SPD},spmd)
509 $(error Error: ENABLE_SPMD_LP requires SPD=spmd.)
510endif
511ifeq ($(SPMC_AT_EL3),1)
512 $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.)
513endif
514endif
515
516################################################################################
Govindraj Raja0386e312023-08-17 10:41:48 -0500517# Process BRANCH_PROTECTION value and set
518# Pointer Authentication and Branch Target Identification flags
519################################################################################
520ifeq (${BRANCH_PROTECTION},0)
521 # Default value turns off all types of branch protection
522 BP_OPTION := none
523else ifneq (${ARCH},aarch64)
524 $(error BRANCH_PROTECTION requires AArch64)
525else ifeq (${BRANCH_PROTECTION},1)
526 # Enables all types of branch protection features
527 BP_OPTION := standard
528 ENABLE_BTI := 1
529 ENABLE_PAUTH := 1
530else ifeq (${BRANCH_PROTECTION},2)
531 # Return address signing to its standard level
532 BP_OPTION := pac-ret
533 ENABLE_PAUTH := 1
534else ifeq (${BRANCH_PROTECTION},3)
535 # Extend the signing to include leaf functions
536 BP_OPTION := pac-ret+leaf
537 ENABLE_PAUTH := 1
538else ifeq (${BRANCH_PROTECTION},4)
539 # Turn on branch target identification mechanism
540 BP_OPTION := bti
541 ENABLE_BTI := 1
542else
543 $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
544endif #(BRANCH_PROTECTION)
545
546ifeq ($(ENABLE_PAUTH),1)
547 CTX_INCLUDE_PAUTH_REGS := 1
548endif
549ifneq (${BP_OPTION},none)
550 TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION}
551endif #(BP_OPTION)
552
553# Pointer Authentication sources
554ifeq (${ENABLE_PAUTH}, 1)
555# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the
556# Pauth support. As it's not secure, it must be reimplemented for real platforms
557 BL_COMMON_SOURCES += lib/extensions/pauth/pauth_helpers.S
558endif
559
Govindraj Raja1a211292023-09-20 14:32:24 -0500560################################################################################
561# Include the platform specific Makefile after the SPD Makefile (the platform
562# makefile may use all previous definitions in this file)
563################################################################################
564include ${PLAT_MAKEFILE_FULL}
565
566################################################################################
567# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from
568# platform.
569################################################################################
570include ${MAKE_HELPERS_DIRECTORY}arch_features.mk
571
Govindraj Raja0386e312023-08-17 10:41:48 -0500572####################################################
573# Enable required options for Memory Stack Tagging.
574####################################################
575
576# Currently, these options are enabled only for clang and armclang compiler.
577ifeq (${SUPPORT_STACK_MEMTAG},yes)
578 ifdef mem_tag_arch_support
579 # Check for armclang and clang compilers
Chris Kaycfba6452023-12-04 09:55:50 +0000580 ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
Govindraj Raja0386e312023-08-17 10:41:48 -0500581 # Add "memtag" architecture feature modifier if not specified
582 ifeq ( ,$(findstring memtag,$(arch-features)))
583 arch-features := $(arch-features)+memtag
584 endif # memtag
Chris Kaycfba6452023-12-04 09:55:50 +0000585 ifeq ($($(ARCH)-cc-id),arm-clang)
Govindraj Raja0386e312023-08-17 10:41:48 -0500586 TF_CFLAGS += -mmemtag-stack
Chris Kaycfba6452023-12-04 09:55:50 +0000587 else ifeq ($($(ARCH)-cc-id),llvm-clang)
Govindraj Raja0386e312023-08-17 10:41:48 -0500588 TF_CFLAGS += -fsanitize=memtag
589 endif # armclang
590 endif
591 else
592 $(error "Error: stack memory tagging is not supported for \
593 architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
594 endif #(mem_tag_arch_support)
595endif #(SUPPORT_STACK_MEMTAG)
596
597################################################################################
598# RME dependent flags configuration, Enable optional features for RME.
599################################################################################
600# FEAT_RME
601ifeq (${ENABLE_RME},1)
602 # RME doesn't support PIE
603 ifneq (${ENABLE_PIE},0)
604 $(error ENABLE_RME does not support PIE)
605 endif
606
Govindraj Raja0386e312023-08-17 10:41:48 -0500607 # RME requires AARCH64
608 ifneq (${ARCH},aarch64)
609 $(error ENABLE_RME requires AArch64)
610 endif
611
612 # RME requires el2 context to be saved for now.
613 CTX_INCLUDE_EL2_REGS := 1
614 CTX_INCLUDE_AARCH32_REGS := 0
615 CTX_INCLUDE_PAUTH_REGS := 1
616
617 # RME enables CSV2_2 extension by default.
618 ENABLE_FEAT_CSV2_2 = 1
619endif #(FEAT_RME)
620
621################################################################################
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500622# Include rmmd Makefile if RME is enabled
623################################################################################
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500624ifneq (${ENABLE_RME},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100625 ifneq (${ARCH},aarch64)
626 $(error ENABLE_RME requires AArch64)
627 endif
628 ifeq ($(SPMC_AT_EL3),1)
629 $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
630 endif
631
632 ifneq (${SPD}, none)
633 ifneq (${SPD}, spmd)
634 $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd)
635 endif
636 endif
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500637include services/std_svc/rmmd/rmmd.mk
638$(warning "RME is an experimental feature")
639endif
640
Govindraj Raja1a211292023-09-20 14:32:24 -0500641ifeq (${CTX_INCLUDE_EL2_REGS}, 1)
642 ifeq (${SPD},none)
643 ifeq (${ENABLE_RME},0)
644 $(error CTX_INCLUDE_EL2_REGS is available only when SPD \
645 or RME is enabled)
646 endif
647 endif
648endif
Jon Medhurst66573cb2014-02-13 15:19:28 +0000649
Govindraj Raja69096412023-06-01 16:29:16 -0500650################################################################################
Govindraj Rajae63794e2024-09-06 15:43:43 +0100651# Make 128-Bit sysreg read/writes availabe when FEAT_D128 is enabled.
652################################################################################
653ifneq (${ENABLE_FEAT_D128}, 0)
654 BL_COMMON_SOURCES += lib/extensions/sysreg128/sysreg128.S
655endif
656
657################################################################################
Govindraj Raja69096412023-06-01 16:29:16 -0500658# Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come
659# up with appropriate march values for compiler.
660################################################################################
661include ${MAKE_HELPERS_DIRECTORY}march.mk
662
663TF_CFLAGS += $(march-directive)
Govindraj Raja0c572472024-01-23 16:00:19 -0600664ASFLAGS += $(march-directive)
Govindraj Raja69096412023-06-01 16:29:16 -0500665
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600666# This internal flag is common option which is set to 1 for scenarios
667# when the BL2 is running in EL3 level. This occurs in two scenarios -
668# 4 world system running BL2 at EL3 and two world system without BL1 running
669# BL2 in EL3
670
671ifeq (${RESET_TO_BL2},1)
672 BL2_RUNS_AT_EL3 := 1
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100673 ifeq (${ENABLE_RME},1)
674 $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \
675 supported at the moment.)
676 endif
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600677else ifeq (${ENABLE_RME},1)
678 BL2_RUNS_AT_EL3 := 1
679else
680 BL2_RUNS_AT_EL3 := 0
681endif
682
Manish Pandeyf90a73c2023-10-10 15:42:19 +0100683# This internal flag is set to 1 when Firmware First handling of External aborts
684# is required by lowe ELs. Currently only NS requires this support.
685ifeq ($(HANDLE_EA_EL3_FIRST_NS),1)
686 FFH_SUPPORT := 1
687else
688 FFH_SUPPORT := 0
689endif
690
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100691ifeq (${ARM_ARCH_MAJOR},7)
692include make_helpers/armv7-a-cpus.mk
693endif
694
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900695PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT})
696ifneq ($(PIE_FOUND),)
697 TF_CFLAGS += -fno-PIE
Chris Kaycfba6452023-12-04 09:55:50 +0000698ifeq ($($(ARCH)-ld-id),gnu-gcc)
Samuel Holland9286c022022-04-08 21:56:02 -0500699 TF_LDFLAGS += -no-pie
700endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100701endif #(PIE_FOUND)
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900702
Chris Kaycfba6452023-12-04 09:55:50 +0000703ifeq ($($(ARCH)-ld-id),gnu-gcc)
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900704 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
Soby Mathew078f1a42018-08-28 11:13:55 +0100705else
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900706 PIE_LDFLAGS += -pie --no-dynamic-linker
707endif
708
709ifeq ($(ENABLE_PIE),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100710 ifeq ($(RESET_TO_BL2),1)
711 ifneq ($(BL2_IN_XIP_MEM),1)
712 BL2_CPPFLAGS += -fpie
713 BL2_CFLAGS += -fpie
714 BL2_LDFLAGS += $(PIE_LDFLAGS)
715 endif #(BL2_IN_XIP_MEM)
716 endif #(RESET_TO_BL2)
Chris Kay13886c82023-02-02 14:39:03 +0000717 BL31_CPPFLAGS += -fpie
718 BL31_CFLAGS += -fpie
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900719 BL31_LDFLAGS += $(PIE_LDFLAGS)
Chris Kay13886c82023-02-02 14:39:03 +0000720
721 BL32_CPPFLAGS += -fpie
Masahiro Yamadade634f82020-01-17 13:45:14 +0900722 BL32_CFLAGS += -fpie
723 BL32_LDFLAGS += $(PIE_LDFLAGS)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100724endif #(ENABLE_PIE)
Soby Mathew078f1a42018-08-28 11:13:55 +0100725
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000726BL1_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
727BL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
728BL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
729
Masahiro Yamadaf1441572020-04-01 14:20:58 +0900730BL1_CPPFLAGS += -DIMAGE_AT_EL3
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600731ifeq ($(RESET_TO_BL2),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100732 BL2_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamada003dd762020-03-26 13:18:48 +0900733else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100734 BL2_CPPFLAGS += -DIMAGE_AT_EL1
735endif #(RESET_TO_BL2)
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000736
737ifeq (${ARCH},aarch64)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100738 BL2U_CPPFLAGS += -DIMAGE_AT_EL1
739 BL31_CPPFLAGS += -DIMAGE_AT_EL3
740 BL32_CPPFLAGS += -DIMAGE_AT_EL1
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000741else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100742 BL32_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamada003dd762020-03-26 13:18:48 +0900743endif
744
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000745# Include the CPU specific operations makefile, which provides default
746# values for all CPU errata workarounds and CPU specific optimisations.
747# This can be overridden by the platform.
Soby Mathew937488b2014-09-22 14:13:34 +0100748include lib/cpus/cpu-ops.mk
Soby Mathew802f8652014-08-14 16:19:29 +0100749
dp-armcdd03cb2017-02-15 11:07:55 +0000750################################################################################
751# Build `AARCH32_SP` as BL32 image for AArch32
752################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100753ifeq (${ARCH},aarch32)
754 NEED_BL32 := yes
dp-armcdd03cb2017-02-15 11:07:55 +0000755
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100756 ifneq (${AARCH32_SP},none)
757 # We expect to locate an sp.mk under the specified AARCH32_SP directory
758 AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
dp-armcdd03cb2017-02-15 11:07:55 +0000759
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100760 ifeq (${AARCH32_SP_MAKE},)
761 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
762 endif
Juan Pablo Conde6aba3b12023-08-09 13:19:21 -0500763 $(info Including ${AARCH32_SP_MAKE})
764 include ${AARCH32_SP_MAKE}
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100765 endif
766endif #(ARCH=aarch32)
Varun Wadekar3f9002c2019-01-31 09:22:30 -0800767
768################################################################################
769# Include libc if not overridden
770################################################################################
771ifeq (${OVERRIDE_LIBC},0)
772include lib/libc/libc.mk
dp-armcdd03cb2017-02-15 11:07:55 +0000773endif
Juan Castilloa3487d12015-08-18 14:23:04 +0100774
775################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100776# Check incompatible options and dependencies
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000777################################################################################
778
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100779# USE_DEBUGFS experimental feature recommended only in debug builds
780ifeq (${USE_DEBUGFS},1)
781 ifeq (${DEBUG},1)
782 $(warning DEBUGFS experimental feature is enabled.)
783 else
784 $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
Qixiang Xube9bd9d2017-08-24 11:03:23 +0800785 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100786endif #(USE_DEBUGFS)
787
788# USE_SPINLOCK_CAS requires AArch64 build
789ifeq (${USE_SPINLOCK_CAS},1)
790 ifneq (${ARCH},aarch64)
791 $(error USE_SPINLOCK_CAS requires AArch64)
Qixiang Xube9bd9d2017-08-24 11:03:23 +0800792 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100793endif #(USE_SPINLOCK_CAS)
794
795# The cert_create tool cannot generate certificates individually, so we use the
796# target 'certificates' to create them all
797ifneq (${GENERATE_COT},0)
798 FIP_DEPS += certificates
799 FWU_FIP_DEPS += fwu_certificates
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000800endif
801
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100802ifneq (${DECRYPTION_SUPPORT},none)
803 ENC_ARGS += -f ${FW_ENC_STATUS}
804 ENC_ARGS += -k ${ENC_KEY}
805 ENC_ARGS += -n ${ENC_NONCE}
806 FIP_DEPS += enctool
807 FWU_FIP_DEPS += enctool
808endif #(DECRYPTION_SUPPORT)
809
810ifdef EL3_PAYLOAD_BASE
811 ifdef PRELOADED_BL33_BASE
812 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
813 incompatible build options. EL3_PAYLOAD_BASE has priority.")
814 endif
815 ifneq (${GENERATE_COT},0)
816 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \
817 build options.")
818 endif
819 ifneq (${TRUSTED_BOARD_BOOT},0)
820 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \
821 incompatible \ build options.")
822 endif
823endif #(EL3_PAYLOAD_BASE)
824
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000825ifeq (${NEED_BL33},yes)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100826 ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000827 $(warning "BL33 image is not needed when option \
828 BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100829 endif
830 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz2b8277b2016-04-06 17:31:57 +0100831 $(warning "BL33 image is not needed when option \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100832 PRELOADED_BL33_BASE is used and won't be added to the FIP file.")
833 endif
834endif #(NEED_BL33)
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000835
Jeenu Viswambharan7ed2cbc2017-01-06 16:14:42 +0000836# When building for systems with hardware-assisted coherency, there's no need to
837# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
838ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100839 $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
Jeenu Viswambharan7ed2cbc2017-01-06 16:14:42 +0000840endif
Yatharth Kocharf528faf2016-06-28 16:58:26 +0100841
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600842#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1.
843ifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100844 $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled")
Jiafei Pan43a7bf42018-03-21 07:20:09 +0000845endif
846
Manish Pandeyd419e222023-02-13 12:39:17 +0000847# RAS_EXTENSION is deprecated, provide alternate build options
Jeenu Viswambharan9a7ce2f2018-04-04 16:07:11 +0100848ifeq ($(RAS_EXTENSION),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100849 $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +0100850 and HANDLE_EA_EL3_FIRST_NS instead")
Manish Pandeyd419e222023-02-13 12:39:17 +0000851endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100852
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100853
Manish Pandeyd419e222023-02-13 12:39:17 +0000854# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled
Jeenu Viswambharanf00da742017-12-08 12:13:51 +0000855ifeq ($(FAULT_INJECTION_SUPPORT),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100856 ifeq ($(ENABLE_FEAT_RAS),0)
857 $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0)
858 endif
859endif #(FAULT_INJECTION_SUPPORT)
Jeenu Viswambharanf00da742017-12-08 12:13:51 +0000860
Roberto Vargas025946a2018-09-24 17:20:48 +0100861# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
Soby Mathew9fe88042018-03-26 12:43:37 +0100862ifeq ($(DYN_DISABLE_AUTH), 1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100863 ifeq (${TRUSTED_BOARD_BOOT}, 0)
864 $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \
865 to be set.")
866 endif
867endif #(DYN_DISABLE_AUTH)
Soby Mathew9fe88042018-03-26 12:43:37 +0100868
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100869ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
870# Support authentication verification and hash calculation
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100871 CRYPTO_SUPPORT := 3
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100872else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
873# Support authentication verification and hash calculation
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100874 CRYPTO_SUPPORT := 3
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100875else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
876# Support hash calculation only
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100877 CRYPTO_SUPPORT := 2
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100878else ifeq (${TRUSTED_BOARD_BOOT},1)
879# Support authentication verification only
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100880 CRYPTO_SUPPORT := 1
Manish V Badarkhe5181d602022-01-08 22:56:06 +0000881else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100882 CRYPTO_SUPPORT := 0
883endif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT))
Manish V Badarkhe5181d602022-01-08 22:56:06 +0000884
Balint Dobszayd0dbd5e2019-12-18 15:28:00 +0100885# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
886ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100887 $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
Manish V Badarkhead339892020-06-29 10:32:53 +0100888endif
889
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000890# If pointer authentication is used in the firmware, make sure that all the
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100891# registers associated to it are also saved and restored.
892# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000893ifeq ($(ENABLE_PAUTH),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100894 ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
895 $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
896 endif
897endif #(ENABLE_PAUTH)
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100898
899ifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100900 ifneq (${ARCH},aarch64)
901 $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
902 endif
903endif #(CTX_INCLUDE_PAUTH_REGS)
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000904
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +0000905ifeq ($(FEATURE_DETECTION),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100906 $(info FEATURE_DETECTION is an experimental feature)
907endif #(FEATURE_DETECTION)
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +0000908
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +0000909ifneq ($(ENABLE_SME2_FOR_NS), 0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100910 ifeq (${ENABLE_SME_FOR_NS}, 0)
911 $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \
912 to be set")
913 $(warning "Forced ENABLE_SME_FOR_NS=1")
914 override ENABLE_SME_FOR_NS := 1
915 endif
916endif #(ENABLE_SME2_FOR_NS)
Jayanth Dodderi Chidanand605419a2023-03-06 23:56:14 +0000917
Petre-Ionut Tudore5a6fef2019-11-07 15:18:03 +0000918ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100919 ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
920 $(error "ALLOW_RO_XLAT_TABLES requires translation tables \
921 library v2")
922 endif
923endif #(ARM_XLAT_TABLES_LIB_V1)
Petre-Ionut Tudore5a6fef2019-11-07 15:18:03 +0000924
Sumit Garg392e4df2019-11-15 10:43:00 +0530925ifneq (${DECRYPTION_SUPPORT},none)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100926 ifeq (${TRUSTED_BOARD_BOOT}, 0)
927 $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \
928 to be set)
929 endif
930endif #(DECRYPTION_SUPPORT)
Sumit Garg392e4df2019-11-15 10:43:00 +0530931
johpow0181865962022-01-28 17:06:20 -0600932# Ensure that no Aarch64-only features are enabled in Aarch32 build
johpow019baade32021-07-08 14:14:00 -0500933ifeq (${ARCH},aarch32)
johpow0181865962022-01-28 17:06:20 -0600934
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100935 # SME/SVE only supported on AArch64
936 ifneq (${ENABLE_SME_FOR_NS},0)
937 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
938 endif
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +0000939
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100940 ifeq (${ENABLE_SVE_FOR_NS},1)
941 # Warning instead of error due to CI dependency on this
942 $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
943 endif
johpow0181865962022-01-28 17:06:20 -0600944
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100945 # BRBE is not supported in AArch32
946 ifeq (${ENABLE_BRBE_FOR_NS},1)
947 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
948 endif
johpow0181865962022-01-28 17:06:20 -0600949
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100950 # FEAT_RNG_TRAP is not supported in AArch32
951 ifeq (${ENABLE_FEAT_RNG_TRAP},1)
952 $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
953 endif
Arvind Ram Prakashe558f9c2024-11-11 14:32:37 -0600954
955 ifneq (${ENABLE_FEAT_FPMR},0)
956 $(error "ENABLE_FEAT_FPMR cannot be used with ARCH=aarch32")
957 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100958endif #(ARCH=aarch32)
johpow019baade32021-07-08 14:14:00 -0500959
Arvind Ram Prakashe558f9c2024-11-11 14:32:37 -0600960ifneq (${ENABLE_FEAT_FPMR},0)
961 ifeq (${ENABLE_FEAT_FGT},0)
962 $(error "ENABLE_FEAT_FPMR requires ENABLE_FEAT_FGT")
963 endif
964 ifeq (${ENABLE_FEAT_HCX},0)
965 $(error "ENABLE_FEAT_FPMR requires ENABLE_FEAT_HCX")
966 endif
967endif #(ENABLE_FEAT_FPMR)
968
Boyan Karatotev7f5dcc72023-03-08 16:29:26 +0000969ifneq (${ENABLE_SME_FOR_NS},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100970 ifeq (${ENABLE_SVE_FOR_NS},0)
971 $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS")
972 endif
973endif #(ENABLE_SME_FOR_NS)
Boyan Karatotev7f5dcc72023-03-08 16:29:26 +0000974
johpow019baade32021-07-08 14:14:00 -0500975# Secure SME/SVE requires the non-secure component as well
976ifeq (${ENABLE_SME_FOR_SWD},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100977 ifeq (${ENABLE_SME_FOR_NS},0)
978 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
979 endif
980 ifeq (${ENABLE_SVE_FOR_SWD},0)
981 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD")
982 endif
983endif #(ENABLE_SME_FOR_SWD)
984
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -0500985# Enabling SVE for SWD requires enabling SVE for NWD due to ENABLE_FEAT
986# mechanism.
johpow019baade32021-07-08 14:14:00 -0500987ifeq (${ENABLE_SVE_FOR_SWD},1)
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -0500988 ifeq (${ENABLE_SVE_FOR_NS},0)
989 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
990 endif
991endif
johpow019baade32021-07-08 14:14:00 -0500992
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -0500993# Enabling SVE for both the worlds typically requires the context
994# management of SVE registers. The only exception being SPMC at S-EL2.
995ifeq (${ENABLE_SVE_FOR_SWD}, 1)
996 ifneq (${ENABLE_SVE_FOR_NS}, 0)
997 ifeq (${CTX_INCLUDE_SVE_REGS}-$(SPMD_SPM_AT_SEL2),0-0)
998 $(warning "ENABLE_SVE_FOR_SWD and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
999 endif
1000 endif
1001endif
1002
1003# Enabling SVE in either world while enabling CTX_INCLUDE_FPREGS requires
1004# CTX_INCLUDE_SVE_REGS to be enabled due to architectural dependency between FP
1005# and SVE registers.
1006ifeq (${CTX_INCLUDE_FPREGS}, 1)
1007 ifneq (${ENABLE_SVE_FOR_NS},0)
1008 ifeq (${CTX_INCLUDE_SVE_REGS},0)
1009 # Warning instead of error due to CI dependency on this
1010 $(warning "CTX_INCLUDE_FPREGS and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
1011 $(warning "Forced ENABLE_SVE_FOR_NS=0")
1012 override ENABLE_SVE_FOR_NS := 0
1013 endif
1014 endif
1015endif #(CTX_INCLUDE_FPREGS)
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +00001016
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -05001017# SVE context management is only required if secure world has access to SVE/FP
1018# functionality.
1019ifeq (${CTX_INCLUDE_SVE_REGS},1)
1020 ifeq (${ENABLE_SVE_FOR_SWD},0)
1021 $(error "CTX_INCLUDE_SVE_REGS requires ENABLE_SVE_FOR_SWD to also be enabled")
1022 endif
1023endif
1024
1025# SME cannot be used with CTX_INCLUDE_FPREGS since SPM does its own context
1026# management including FPU registers.
1027ifeq (${CTX_INCLUDE_FPREGS},1)
1028 ifneq (${ENABLE_SME_FOR_NS},0)
1029 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1030 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001031endif #(CTX_INCLUDE_FPREGS)
johpow019baade32021-07-08 14:14:00 -05001032
Manish V Badarkhe191a5fc2022-03-02 12:06:35 +00001033ifeq ($(DRTM_SUPPORT),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001034 $(info DRTM_SUPPORT is an experimental feature)
Manish V Badarkhe191a5fc2022-03-02 12:06:35 +00001035endif
1036
Levi Yun03adb132024-05-13 10:24:31 +01001037ifeq (${HOB_LIST},1)
1038 $(warning HOB_LIST is an experimental feature)
1039endif
1040
Raymond Mao98983392023-07-25 07:53:35 -07001041ifeq (${TRANSFER_LIST},1)
1042 $(info TRANSFER_LIST is an experimental feature)
1043endif
1044
Chris Kayd02c2312022-09-29 16:21:24 +01001045ifeq (${ENABLE_RME},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001046 ifneq (${SEPARATE_CODE_AND_RODATA},1)
1047 $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
1048 endif
Chris Kayd02c2312022-09-29 16:21:24 +01001049endif
1050
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001051ifeq ($(PSA_CRYPTO),1)
1052 $(info PSA_CRYPTO is an experimental feature)
1053endif
1054
Manish V Badarkhed8d7d932024-05-09 12:14:13 +01001055ifeq ($(DICE_PROTECTION_ENVIRONMENT),1)
1056 $(info DICE_PROTECTION_ENVIRONMENT is an experimental feature)
1057endif
1058
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +00001059################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001060# Process platform overrideable behaviour
1061################################################################################
1062
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001063ifdef BL1_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001064 NEED_BL1 := yes
1065endif #(BL1_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001066
Jon Medhurst66573cb2014-02-13 15:19:28 +00001067ifdef BL2_SOURCES
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001068 NEED_BL2 := yes
1069
1070 # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
1071 # Certificate generation tools. This flag can be overridden by the platform.
1072 ifdef EL3_PAYLOAD_BASE
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001073 # If booting an EL3 payload there is no need for a BL33 image
1074 # in the FIP file.
1075 NEED_BL33 := no
1076 else
1077 ifdef PRELOADED_BL33_BASE
1078 # If booting a BL33 preloaded image there is no need of
1079 # another one in the FIP file.
1080 NEED_BL33 := no
1081 else
1082 NEED_BL33 ?= yes
1083 endif
1084 endif
1085endif #(BL2_SOURCES)
Achin Gupta4f6ad662013-10-25 09:08:21 +01001086
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001087ifdef BL2U_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001088 NEED_BL2U := yes
1089endif #(BL2U_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001090
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001091# If SCP_BL2 is given, we always want FIP to include it.
1092ifdef SCP_BL2
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001093 NEED_SCP_BL2 := yes
1094endif #(SCP_BL2)
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001095
Soby Mathewbf169232017-11-14 14:10:10 +00001096# For AArch32, BL31 is not currently supported.
1097ifneq (${ARCH},aarch32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001098 ifdef BL31_SOURCES
1099 # When booting an EL3 payload, there is no need to compile the BL31
1100 # image nor put it in the FIP.
1101 ifndef EL3_PAYLOAD_BASE
1102 NEED_BL31 := yes
1103 endif
1104 endif
1105endif #(ARCH=aarch64)
Soby Mathewbf169232017-11-14 14:10:10 +00001106
Juan Castilloa3487d12015-08-18 14:23:04 +01001107# Process TBB related flags
1108ifneq (${GENERATE_COT},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001109 # Common cert_create options
1110 ifneq (${CREATE_KEYS},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001111 $(eval CRT_ARGS += -n)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001112 $(eval FWU_CRT_ARGS += -n)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001113 ifneq (${SAVE_KEYS},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001114 $(eval CRT_ARGS += -k)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001115 $(eval FWU_CRT_ARGS += -k)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001116 endif
1117 endif
1118 # Include TBBR makefile (unless the platform indicates otherwise)
1119 ifeq (${INCLUDE_TBBR_MK},1)
Juan Castilloa3487d12015-08-18 14:23:04 +01001120 include make_helpers/tbbr/tbbr_tools.mk
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001121 endif
1122endif #(GENERATE_COT)
Achin Gupta4f6ad662013-10-25 09:08:21 +01001123
Masahiro Yamada4d87eb42016-12-25 13:52:22 +09001124ifneq (${FIP_ALIGN},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001125 FIP_ARGS += --align ${FIP_ALIGN}
1126endif #(FIP_ALIGN)
Masahiro Yamada4d87eb42016-12-25 13:52:22 +09001127
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001128ifdef FDT_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001129 NEED_FDT := yes
1130endif #(FDT_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001131
Juan Castilloa3487d12015-08-18 14:23:04 +01001132################################################################################
Michalis Pappas0f223c52018-03-20 13:01:27 +08001133# Include libraries' Makefile that are used in all BL
1134################################################################################
1135
1136include lib/stack_protector/stack_protector.mk
1137
1138################################################################################
Soby Mathew574e01e2017-02-14 10:05:07 +00001139# Include BL specific makefiles
1140################################################################################
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001141
1142ifeq (${NEED_BL1},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001143include bl1/bl1.mk
1144endif
1145
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001146ifeq (${NEED_BL2},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001147include bl2/bl2.mk
1148endif
1149
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001150ifeq (${NEED_BL2U},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001151include bl2u/bl2u.mk
1152endif
1153
Soby Mathewbf169232017-11-14 14:10:10 +00001154ifeq (${NEED_BL31},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001155include bl31/bl31.mk
1156endif
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001157
Soby Mathew574e01e2017-02-14 10:05:07 +00001158################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001159# Build options checks
1160################################################################################
1161
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001162# Boolean_Flags
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001163$(eval $(call assert_booleans,\
1164 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001165 ALLOW_RO_XLAT_TABLES \
1166 BL2_ENABLE_SP_LOAD \
1167 COLD_BOOT_SINGLE_CPU \
1168 CREATE_KEYS \
1169 CTX_INCLUDE_AARCH32_REGS \
1170 CTX_INCLUDE_FPREGS \
Madhukar Pappireddydd9af9b2024-06-17 15:17:03 -05001171 CTX_INCLUDE_SVE_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001172 CTX_INCLUDE_EL2_REGS \
Arvind Ram Prakash4851b492023-10-06 14:35:21 -05001173 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001174 DEBUG \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001175 DYN_DISABLE_AUTH \
1176 EL3_EXCEPTION_HANDLING \
1177 ENABLE_AMU_AUXILIARY_COUNTERS \
1178 ENABLE_AMU_FCONF \
1179 AMU_RESTRICT_COUNTERS \
1180 ENABLE_ASSERTIONS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001181 ENABLE_PIE \
1182 ENABLE_PMF \
1183 ENABLE_PSCI_STAT \
1184 ENABLE_RUNTIME_INSTRUMENTATION \
1185 ENABLE_SME_FOR_SWD \
1186 ENABLE_SVE_FOR_SWD \
Manish Pandey514a3012023-10-10 13:53:25 +01001187 ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +01001188 FFH_SUPPORT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001189 ERROR_DEPRECATED \
1190 FAULT_INJECTION_SUPPORT \
1191 GENERATE_COT \
1192 GICV2_G0_FOR_EL3 \
1193 HANDLE_EA_EL3_FIRST_NS \
Bipin Ravie53e6ae2023-09-28 13:17:24 -05001194 HARDEN_SLS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001195 HW_ASSISTED_COHERENCY \
1196 MEASURED_BOOT \
Tamas Bana4260892023-06-07 13:35:04 +02001197 DICE_PROTECTION_ENVIRONMENT \
Raghu Krishnamurthyc11b60e2024-06-03 19:02:29 -07001198 RMMD_ENABLE_EL3_TOKEN_SIGN \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001199 DRTM_SUPPORT \
1200 NS_TIMER_SWITCH \
1201 OVERRIDE_LIBC \
1202 PL011_GENERIC_UART \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001203 PROGRAMMABLE_RESET_ADDRESS \
1204 PSCI_EXTENDED_STATE_ID \
1205 PSCI_OS_INIT_MODE \
1206 RESET_TO_BL31 \
1207 SAVE_KEYS \
1208 SEPARATE_CODE_AND_RODATA \
1209 SEPARATE_BL2_NOLOAD_REGION \
1210 SEPARATE_NOBITS_REGION \
Ye Li97267752022-08-26 13:48:31 +08001211 SEPARATE_RWDATA_REGION \
Madhukar Pappireddy5c1b8d92024-06-17 15:26:00 -05001212 SEPARATE_SIMD_SECTION \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001213 SPIN_ON_BL1_EXIT \
1214 SPM_MM \
1215 SPMC_AT_EL3 \
Nishant Sharma9e719112023-06-27 00:36:01 +01001216 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001217 SPMD_SPM_AT_SEL2 \
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -08001218 ENABLE_SPMD_LP \
Raymond Mao98983392023-07-25 07:53:35 -07001219 TRANSFER_LIST \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001220 TRUSTED_BOARD_BOOT \
1221 USE_COHERENT_MEM \
1222 USE_DEBUGFS \
1223 ARM_IO_IN_DTB \
1224 SDEI_IN_FCONF \
1225 SEC_INT_DESC_IN_FCONF \
1226 USE_ROMLIB \
1227 USE_TBBR_DEFS \
1228 WARMBOOT_ENABLE_DCACHE_EARLY \
1229 RESET_TO_BL2 \
1230 BL2_IN_XIP_MEM \
1231 BL2_INV_DCACHE \
1232 USE_SPINLOCK_CAS \
1233 ENCRYPT_BL31 \
1234 ENCRYPT_BL32 \
1235 ERRATA_SPECULATIVE_AT \
1236 RAS_TRAP_NS_ERR_REC_ACCESS \
1237 COT_DESC_IN_DTB \
1238 USE_SP804_TIMER \
1239 PSA_FWU_SUPPORT \
Sughosh Ganu61905e52024-02-01 12:51:20 +05301240 PSA_FWU_METADATA_FW_STORE_DESC \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001241 ENABLE_MPMM \
1242 ENABLE_MPMM_FCONF \
1243 FEATURE_DETECTION \
Jayanth Dodderi Chidanand7c7faff2022-10-11 17:16:07 +01001244 TRNG_SUPPORT \
Sona Mathew7fe03522022-11-18 18:05:38 -06001245 ERRATA_ABI_SUPPORT \
Sona Mathew5a4c9fc2023-03-14 14:02:03 -05001246 ERRATA_NON_ARM_INTERCONNECT \
Okash Khawaja037b56e2022-11-04 12:38:01 +00001247 CONDITIONAL_CMO \
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001248 PSA_CRYPTO \
Sandrine Bailleuxf57e2032023-10-11 08:38:00 +02001249 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash8bd27c92023-08-15 16:28:06 -05001250 INIT_UNUSED_NS_EL2 \
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001251 PLATFORM_REPORT_CTX_MEM_USE \
Yann Gautier5ae29c02024-01-16 19:39:31 +01001252 EARLY_CONSOLE \
Arvind Ram Prakasheaa90192023-12-21 00:25:52 -06001253 PRESERVE_DSU_PMU_REGS \
Levi Yun03adb132024-05-13 10:24:31 +01001254 HOB_LIST \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001255)))
Dan Handley81be1002015-03-27 17:44:35 +00001256
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001257# Numeric_Flags
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001258$(eval $(call assert_numerics,\
1259 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001260 ARM_ARCH_MAJOR \
1261 ARM_ARCH_MINOR \
1262 BRANCH_PROTECTION \
1263 CTX_INCLUDE_PAUTH_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001264 CTX_INCLUDE_NEVE_REGS \
1265 CRYPTO_SUPPORT \
Boyan Karatotev677ed8a2023-02-16 09:45:29 +00001266 DISABLE_MTPMU \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001267 ENABLE_BRBE_FOR_NS \
1268 ENABLE_TRBE_FOR_NS \
1269 ENABLE_BTI \
1270 ENABLE_PAUTH \
1271 ENABLE_FEAT_AMU \
1272 ENABLE_FEAT_AMUv1p1 \
1273 ENABLE_FEAT_CSV2_2 \
Sona Mathew3b84c962023-10-25 16:48:19 -05001274 ENABLE_FEAT_CSV2_3 \
Arvind Ram Prakash05b47632024-05-22 15:24:00 -05001275 ENABLE_FEAT_DEBUGV8P9 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001276 ENABLE_FEAT_DIT \
1277 ENABLE_FEAT_ECV \
1278 ENABLE_FEAT_FGT \
Arvind Ram Prakash62d87e72024-06-06 11:33:37 -05001279 ENABLE_FEAT_FGT2 \
Arvind Ram Prakashe558f9c2024-11-11 14:32:37 -06001280 ENABLE_FEAT_FPMR \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001281 ENABLE_FEAT_HCX \
Andre Przywara8fc8e182024-08-09 17:04:22 +01001282 ENABLE_FEAT_LS64_ACCDATA \
Govindraj Rajad7b63ac2024-01-26 10:08:37 -06001283 ENABLE_FEAT_MTE2 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001284 ENABLE_FEAT_PAN \
1285 ENABLE_FEAT_RNG \
1286 ENABLE_FEAT_RNG_TRAP \
1287 ENABLE_FEAT_SEL2 \
1288 ENABLE_FEAT_TCR2 \
Jayanth Dodderi Chidanand6b706862024-09-05 22:24:04 +01001289 ENABLE_FEAT_THE \
Govindraj Rajac2dad572024-01-23 16:03:53 -06001290 ENABLE_FEAT_SB \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001291 ENABLE_FEAT_S2PIE \
1292 ENABLE_FEAT_S1PIE \
1293 ENABLE_FEAT_S2POE \
1294 ENABLE_FEAT_S1POE \
Jayanth Dodderi Chidanand70cc1752024-09-06 13:49:31 +01001295 ENABLE_FEAT_SCTLR2 \
Govindraj Rajae63794e2024-09-06 15:43:43 +01001296 ENABLE_FEAT_D128 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001297 ENABLE_FEAT_GCS \
1298 ENABLE_FEAT_VHE \
Arvind Ram Prakashab28d4b2023-10-11 12:10:56 -05001299 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001300 ENABLE_RME \
1301 ENABLE_SPE_FOR_NS \
1302 ENABLE_SYS_REG_TRACE_FOR_NS \
1303 ENABLE_SME_FOR_NS \
1304 ENABLE_SME2_FOR_NS \
1305 ENABLE_SVE_FOR_NS \
1306 ENABLE_TRF_FOR_NS \
1307 FW_ENC_STATUS \
1308 NR_OF_FW_BANKS \
1309 NR_OF_IMAGES_IN_FW_BANK \
1310 TWED_DELAY \
1311 ENABLE_FEAT_TWED \
1312 SVE_VECTOR_LEN \
Varun Wadekar0a46eb12023-04-13 21:06:18 +01001313 IMPDEF_SYSREG_TRAP \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001314)))
Jeenu Viswambharanfca76802017-01-16 16:52:35 +00001315
Justin Chadwellf9b32c12019-07-29 17:13:10 +01001316ifdef KEY_SIZE
1317 $(eval $(call assert_numeric,KEY_SIZE))
1318endif
1319
Justin Chadwell83e04882019-08-20 11:01:52 +01001320ifeq ($(filter $(SANITIZE_UB), on off trap),)
1321 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
1322endif
1323
Juan Castilloa3487d12015-08-18 14:23:04 +01001324################################################################################
1325# Add definitions to the cpp preprocessor based on the current build options.
1326# This is done after including the platform specific makefile to allow the
1327# platform to overwrite the default options
1328################################################################################
Jeenu Viswambharand1b60152014-05-12 15:28:47 +01001329
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001330$(eval $(call add_defines,\
1331 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001332 ALLOW_RO_XLAT_TABLES \
1333 ARM_ARCH_MAJOR \
1334 ARM_ARCH_MINOR \
1335 BL2_ENABLE_SP_LOAD \
1336 COLD_BOOT_SINGLE_CPU \
1337 CTX_INCLUDE_AARCH32_REGS \
1338 CTX_INCLUDE_FPREGS \
Madhukar Pappireddydd9af9b2024-06-17 15:17:03 -05001339 CTX_INCLUDE_SVE_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001340 CTX_INCLUDE_PAUTH_REGS \
Arvind Ram Prakash4851b492023-10-06 14:35:21 -05001341 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001342 EL3_EXCEPTION_HANDLING \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001343 CTX_INCLUDE_EL2_REGS \
1344 CTX_INCLUDE_NEVE_REGS \
1345 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
1346 DISABLE_MTPMU \
1347 ENABLE_FEAT_AMU \
1348 ENABLE_AMU_AUXILIARY_COUNTERS \
1349 ENABLE_AMU_FCONF \
1350 AMU_RESTRICT_COUNTERS \
1351 ENABLE_ASSERTIONS \
1352 ENABLE_BTI \
Arvind Ram Prakash05b47632024-05-22 15:24:00 -05001353 ENABLE_FEAT_DEBUGV8P9 \
Arvind Ram Prakashab28d4b2023-10-11 12:10:56 -05001354 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001355 ENABLE_PAUTH \
1356 ENABLE_PIE \
1357 ENABLE_PMF \
1358 ENABLE_PSCI_STAT \
1359 ENABLE_RME \
Raghu Krishnamurthyc11b60e2024-06-03 19:02:29 -07001360 RMMD_ENABLE_EL3_TOKEN_SIGN \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001361 ENABLE_RUNTIME_INSTRUMENTATION \
1362 ENABLE_SME_FOR_NS \
1363 ENABLE_SME2_FOR_NS \
1364 ENABLE_SME_FOR_SWD \
1365 ENABLE_SPE_FOR_NS \
1366 ENABLE_SVE_FOR_NS \
1367 ENABLE_SVE_FOR_SWD \
Manish Pandey514a3012023-10-10 13:53:25 +01001368 ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +01001369 FFH_SUPPORT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001370 ENCRYPT_BL31 \
1371 ENCRYPT_BL32 \
1372 ERROR_DEPRECATED \
1373 FAULT_INJECTION_SUPPORT \
1374 GICV2_G0_FOR_EL3 \
1375 HANDLE_EA_EL3_FIRST_NS \
1376 HW_ASSISTED_COHERENCY \
1377 LOG_LEVEL \
1378 MEASURED_BOOT \
Tamas Bana4260892023-06-07 13:35:04 +02001379 DICE_PROTECTION_ENVIRONMENT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001380 DRTM_SUPPORT \
1381 NS_TIMER_SWITCH \
1382 PL011_GENERIC_UART \
1383 PLAT_${PLAT} \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001384 PROGRAMMABLE_RESET_ADDRESS \
1385 PSCI_EXTENDED_STATE_ID \
1386 PSCI_OS_INIT_MODE \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001387 RESET_TO_BL31 \
AlexeiFedorovc0ca2d72024-05-13 15:35:54 +01001388 RME_GPT_BITLOCK_BLOCK \
AlexeiFedorovbd8b1bb2024-03-13 17:07:03 +00001389 RME_GPT_MAX_BLOCK \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001390 SEPARATE_CODE_AND_RODATA \
1391 SEPARATE_BL2_NOLOAD_REGION \
1392 SEPARATE_NOBITS_REGION \
Ye Li97267752022-08-26 13:48:31 +08001393 SEPARATE_RWDATA_REGION \
Madhukar Pappireddy5c1b8d92024-06-17 15:26:00 -05001394 SEPARATE_SIMD_SECTION \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001395 RECLAIM_INIT_CODE \
1396 SPD_${SPD} \
1397 SPIN_ON_BL1_EXIT \
1398 SPM_MM \
1399 SPMC_AT_EL3 \
Nishant Sharma9e719112023-06-27 00:36:01 +01001400 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001401 SPMD_SPM_AT_SEL2 \
Raymond Mao98983392023-07-25 07:53:35 -07001402 TRANSFER_LIST \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001403 TRUSTED_BOARD_BOOT \
1404 CRYPTO_SUPPORT \
1405 TRNG_SUPPORT \
1406 ERRATA_ABI_SUPPORT \
Sona Mathew5a4c9fc2023-03-14 14:02:03 -05001407 ERRATA_NON_ARM_INTERCONNECT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001408 USE_COHERENT_MEM \
1409 USE_DEBUGFS \
1410 ARM_IO_IN_DTB \
1411 SDEI_IN_FCONF \
1412 SEC_INT_DESC_IN_FCONF \
1413 USE_ROMLIB \
1414 USE_TBBR_DEFS \
1415 WARMBOOT_ENABLE_DCACHE_EARLY \
1416 RESET_TO_BL2 \
1417 BL2_RUNS_AT_EL3 \
1418 BL2_IN_XIP_MEM \
1419 BL2_INV_DCACHE \
1420 USE_SPINLOCK_CAS \
1421 ERRATA_SPECULATIVE_AT \
1422 RAS_TRAP_NS_ERR_REC_ACCESS \
1423 COT_DESC_IN_DTB \
1424 USE_SP804_TIMER \
1425 ENABLE_FEAT_RNG \
1426 ENABLE_FEAT_RNG_TRAP \
1427 ENABLE_FEAT_SB \
1428 ENABLE_FEAT_DIT \
1429 NR_OF_FW_BANKS \
1430 NR_OF_IMAGES_IN_FW_BANK \
1431 PSA_FWU_SUPPORT \
Sughosh Ganu61905e52024-02-01 12:51:20 +05301432 PSA_FWU_METADATA_FW_STORE_DESC \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001433 ENABLE_BRBE_FOR_NS \
1434 ENABLE_TRBE_FOR_NS \
1435 ENABLE_SYS_REG_TRACE_FOR_NS \
1436 ENABLE_TRF_FOR_NS \
1437 ENABLE_FEAT_HCX \
1438 ENABLE_MPMM \
1439 ENABLE_MPMM_FCONF \
1440 ENABLE_FEAT_FGT \
Arvind Ram Prakash62d87e72024-06-06 11:33:37 -05001441 ENABLE_FEAT_FGT2 \
Arvind Ram Prakashe558f9c2024-11-11 14:32:37 -06001442 ENABLE_FEAT_FPMR \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001443 ENABLE_FEAT_ECV \
1444 ENABLE_FEAT_AMUv1p1 \
1445 ENABLE_FEAT_SEL2 \
1446 ENABLE_FEAT_VHE \
1447 ENABLE_FEAT_CSV2_2 \
Sona Mathew3b84c962023-10-25 16:48:19 -05001448 ENABLE_FEAT_CSV2_3 \
Andre Przywara8fc8e182024-08-09 17:04:22 +01001449 ENABLE_FEAT_LS64_ACCDATA \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001450 ENABLE_FEAT_PAN \
1451 ENABLE_FEAT_TCR2 \
Jayanth Dodderi Chidanand6b706862024-09-05 22:24:04 +01001452 ENABLE_FEAT_THE \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001453 ENABLE_FEAT_S2PIE \
1454 ENABLE_FEAT_S1PIE \
1455 ENABLE_FEAT_S2POE \
1456 ENABLE_FEAT_S1POE \
Jayanth Dodderi Chidanand70cc1752024-09-06 13:49:31 +01001457 ENABLE_FEAT_SCTLR2 \
Govindraj Rajae63794e2024-09-06 15:43:43 +01001458 ENABLE_FEAT_D128 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001459 ENABLE_FEAT_GCS \
Govindraj Rajad7b63ac2024-01-26 10:08:37 -06001460 ENABLE_FEAT_MTE2 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001461 FEATURE_DETECTION \
1462 TWED_DELAY \
1463 ENABLE_FEAT_TWED \
Okash Khawaja037b56e2022-11-04 12:38:01 +00001464 CONDITIONAL_CMO \
Varun Wadekar0a46eb12023-04-13 21:06:18 +01001465 IMPDEF_SYSREG_TRAP \
Jayanth Dodderi Chidanand23c2fe22023-04-26 15:57:30 +01001466 SVE_VECTOR_LEN \
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -08001467 ENABLE_SPMD_LP \
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001468 PSA_CRYPTO \
Sandrine Bailleuxf57e2032023-10-11 08:38:00 +02001469 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash8bd27c92023-08-15 16:28:06 -05001470 INIT_UNUSED_NS_EL2 \
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001471 PLATFORM_REPORT_CTX_MEM_USE \
Yann Gautier5ae29c02024-01-16 19:39:31 +01001472 EARLY_CONSOLE \
Arvind Ram Prakasheaa90192023-12-21 00:25:52 -06001473 PRESERVE_DSU_PMU_REGS \
Levi Yun03adb132024-05-13 10:24:31 +01001474 HOB_LIST \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001475)))
Jeenu Viswambharan615ff392016-10-24 14:31:51 +01001476
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001477ifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1)
1478ifeq (${DEBUG}, 0)
1479 $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only")
1480 override PLATFORM_REPORT_CTX_MEM_USE := 0
1481endif
1482endif
1483
Justin Chadwell83e04882019-08-20 11:01:52 +01001484ifeq (${SANITIZE_UB},trap)
1485 $(eval $(call add_define,MONITOR_TRAPS))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001486endif #(SANITIZE_UB)
Justin Chadwell83e04882019-08-20 11:01:52 +01001487
Sandrine Bailleux03897bb2015-11-26 16:31:34 +00001488# Define the EL3_PAYLOAD_BASE flag only if it is provided.
1489ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +00001490 $(eval $(call add_define,EL3_PAYLOAD_BASE))
1491else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001492# Define the PRELOADED_BL33_BASE flag only if it is provided and
1493# EL3_PAYLOAD_BASE is not defined, as it has priority.
1494 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz2b8277b2016-04-06 17:31:57 +01001495 $(eval $(call add_define,PRELOADED_BL33_BASE))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001496 endif
1497endif #(EL3_PAYLOAD_BASE)
Soby Mathew85dbf5a2015-04-07 12:16:56 +01001498
Soby Mathew9fe88042018-03-26 12:43:37 +01001499# Define the DYN_DISABLE_AUTH flag only if set.
1500ifeq (${DYN_DISABLE_AUTH},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001501 $(eval $(call add_define,DYN_DISABLE_AUTH))
Soby Mathew9fe88042018-03-26 12:43:37 +01001502endif
1503
Chris Kaycfba6452023-12-04 09:55:50 +00001504ifeq ($($(ARCH)-ld-id),arm-link)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001505 $(eval $(call add_define,USE_ARM_LINK))
Varun Wadekar4d034c52019-01-11 14:47:48 -08001506endif
1507
Manish Pandey3f90ad72020-01-14 11:52:05 +00001508# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
Manish Pandey3f90ad72020-01-14 11:52:05 +00001509ifeq (${SPD},spmd)
Olivier Deprez042db532020-03-19 09:27:11 +01001510ifdef SP_LAYOUT_FILE
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001511 -include $(BUILD_PLAT)/sp_gen.mk
1512 FIP_DEPS += sp
1513 CRT_DEPS += sp
1514 NEED_SP_PKG := yes
Manish Pandey3f90ad72020-01-14 11:52:05 +00001515else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001516 ifeq (${SPMD_SPM_AT_SEL2},1)
1517 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1518 endif
1519endif #(SP_LAYOUT_FILE)
1520endif #(SPD)
Manish Pandey3f90ad72020-01-14 11:52:05 +00001521
Juan Castilloa3487d12015-08-18 14:23:04 +01001522################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001523# Build targets
1524################################################################################
Achin Gupta4f6ad662013-10-25 09:08:21 +01001525
Harrison Mutai36d971a2024-08-28 13:27:19 +00001526.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp tl fwu_fip certtool dtbs memmap doc enctool
Achin Gupta4f6ad662013-10-25 09:08:21 +01001527
Juan Castilloa3487d12015-08-18 14:23:04 +01001528all: msg_start
Harry Liebelf58ad362014-01-10 18:00:33 +00001529
Juan Castilloa3487d12015-08-18 14:23:04 +01001530msg_start:
Chris Kay1870c722024-05-02 17:52:37 +00001531 $(s)echo "Building ${PLAT}"
Juan Castillo11abdcd2014-10-21 11:30:42 +01001532
Soby Mathew18a62042015-10-26 14:29:21 +00001533ifeq (${ERROR_DEPRECATED},0)
Julius Werner53456fc2019-07-09 13:49:11 -07001534# Check if deprecated declarations and cpp warnings should be treated as error or not.
Chris Kaycfba6452023-12-04 09:55:50 +00001535ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
Varun Wadekar4d034c52019-01-11 14:47:48 -08001536 CPPFLAGS += -Wno-error=deprecated-declarations
1537else
Dan Handley6fa89a22018-02-27 16:03:58 +00001538 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp
Soby Mathew18a62042015-10-26 14:29:21 +00001539endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001540endif #(!ERROR_DEPRECATED)
Soby Mathew18a62042015-10-26 14:29:21 +00001541
Roberto Vargas0f8f9852018-05-08 10:27:10 +01001542$(eval $(call MAKE_LIB,c))
Roberto Vargas21360f32018-05-08 10:27:10 +01001543
Juan Castilloa3487d12015-08-18 14:23:04 +01001544# Expand build macros for the different images
1545ifeq (${NEED_BL1},yes)
Chris Kay0a542ec2021-09-28 15:44:19 +01001546BL1_SOURCES := $(sort ${BL1_SOURCES})
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001547$(eval $(call MAKE_BL,bl1))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001548endif #(NEED_BL1)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001549
Juan Castilloa3487d12015-08-18 14:23:04 +01001550ifeq (${NEED_BL2},yes)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001551
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -06001552ifeq (${RESET_TO_BL2}, 0)
Roberto Vargas53c052b2018-01-02 11:23:41 +00001553FIP_BL2_ARGS := tb-fw
1554endif
1555
Chris Kayfb3b0512021-09-28 15:44:37 +01001556BL2_SOURCES := $(sort ${BL2_SOURCES})
1557
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001558$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001559 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001560
1561endif #(NEED_BL2)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001562
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001563ifeq (${NEED_SCP_BL2},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001564$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001565endif #(NEED_SCP_BL2)
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001566
Juan Castilloa3487d12015-08-18 14:23:04 +01001567ifeq (${NEED_BL31},yes)
1568BL31_SOURCES += ${SPD_SOURCES}
Madhukar Pappireddyae9677b2020-01-27 13:37:51 -06001569# Sort BL31 source files to remove duplicates
1570BL31_SOURCES := $(sort ${BL31_SOURCES})
Sumit Gargeec52442019-11-14 16:33:45 +05301571ifneq (${DECRYPTION_SUPPORT},none)
1572$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001573 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
Sumit Gargeec52442019-11-14 16:33:45 +05301574else
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001575$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001576 $(eval $(call MAKE_BL,bl31,soc-fw)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001577endif #(DECRYPTION_SUPPORT)
1578endif #(NEED_BL31)
Juan Castillo379954c2014-11-04 17:36:40 +00001579
Juan Castillo671b8db2015-11-12 10:59:26 +00001580# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
Masahiro Yamada4d156802018-01-26 11:42:01 +09001581# build system will call TOOL_ADD_IMG to print a warning message and abort the
Juan Castillo671b8db2015-11-12 10:59:26 +00001582# process. Note that the dependency on BL32 applies to the FIP only.
Juan Castilloa3487d12015-08-18 14:23:04 +01001583ifeq (${NEED_BL32},yes)
Madhukar Pappireddyae9677b2020-01-27 13:37:51 -06001584# Sort BL32 source files to remove duplicates
1585BL32_SOURCES := $(sort ${BL32_SOURCES})
Masahiro Yamada6ced1b22018-01-26 11:42:01 +09001586BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
1587
Sumit Gargeec52442019-11-14 16:33:45 +05301588ifneq (${DECRYPTION_SUPPORT},none)
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001589$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
Sumit Gargeec52442019-11-14 16:33:45 +05301590 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1591else
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001592$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001593 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001594endif #(DECRYPTION_SUPPORT)
1595endif #(NEED_BL32)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001596
Zelalem Aweke4d37db82021-07-11 18:33:20 -05001597# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
1598# needs to be built from RMM_SOURCES.
1599ifeq (${NEED_RMM},yes)
1600# Sort RMM source files to remove duplicates
1601RMM_SOURCES := $(sort ${RMM_SOURCES})
1602BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
1603
1604$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001605 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1606endif #(NEED_RMM)
Zelalem Aweke4d37db82021-07-11 18:33:20 -05001607
Juan Castilloa3487d12015-08-18 14:23:04 +01001608# Add the BL33 image if required by the platform
1609ifeq (${NEED_BL33},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001610$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001611endif #(NEED_BL33)
Juan Castillo9c25a402015-01-13 12:21:04 +00001612
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001613ifeq (${NEED_BL2U},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001614$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001615 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001616endif #(NEED_BL2U)
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001617
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001618# Expand build macros for the different images
1619ifeq (${NEED_FDT},yes)
Soby Mathewab4181d2017-12-14 17:44:56 +00001620 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001621endif #(NEED_FDT)
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001622
Manish Pandey3f90ad72020-01-14 11:52:05 +00001623# Add Secure Partition packages
1624ifeq (${NEED_SP_PKG},yes)
Chris Kayd67442e2024-07-30 13:33:56 +00001625$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | $$(@D)/
Chris Kay1870c722024-05-02 17:52:37 +00001626 $(q)${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
J-Alvesef8e0982022-03-22 16:28:51 +00001627sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
Chris Kay1870c722024-05-02 17:52:37 +00001628 $(s)echo
1629 $(s)echo "Built SP Images successfully"
1630 $(s)echo
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001631endif #(NEED_SP_PKG)
Manish Pandey3f90ad72020-01-14 11:52:05 +00001632
Ian Spray36eaaf32014-01-30 17:25:28 +00001633locate-checkpatch:
1634ifndef CHECKPATCH
Etienne Carrieref5657572017-08-23 15:44:01 +02001635 $(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 +00001636else
1637ifeq (,$(wildcard ${CHECKPATCH}))
Etienne Carrieref5657572017-08-23 15:44:01 +02001638 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
Ian Spray36eaaf32014-01-30 17:25:28 +00001639endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001640endif #(CHECKPATCH)
Ian Spray36eaaf32014-01-30 17:25:28 +00001641
Achin Gupta4f6ad662013-10-25 09:08:21 +01001642clean:
Chris Kay1870c722024-05-02 17:52:37 +00001643 $(s)echo " CLEAN"
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001644 $(call SHELL_REMOVE_DIR,${BUILD_PLAT})
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001645ifdef UNIX_MK
Chris Kay1870c722024-05-02 17:52:37 +00001646 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001647else
1648# Clear the MAKEFLAGS as we do not want
1649# to pass the gnumake flags to nmake.
Chris Kay1870c722024-05-02 17:52:37 +00001650 $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001651endif #(UNIX_MK)
Chris Kay1870c722024-05-02 17:52:37 +00001652 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
1653 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
1654 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001655
James Morrisseyeaaeece2013-11-01 13:56:59 +00001656realclean distclean:
Chris Kay1870c722024-05-02 17:52:37 +00001657 $(s)echo " REALCLEAN"
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001658 $(call SHELL_REMOVE_DIR,${BUILD_BASE})
1659 $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001660ifdef UNIX_MK
Chris Kay1870c722024-05-02 17:52:37 +00001661 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001662else
1663# Clear the MAKEFLAGS as we do not want
1664# to pass the gnumake flags to nmake.
Chris Kay1870c722024-05-02 17:52:37 +00001665 $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001666endif #(UNIX_MK)
Chris Kay1870c722024-05-02 17:52:37 +00001667 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
1668 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
1669 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001670
Ian Spray36eaaf32014-01-30 17:25:28 +00001671checkcodebase: locate-checkpatch
Chris Kay1870c722024-05-02 17:52:37 +00001672 $(s)echo " CHECKING STYLE"
1673 $(q)if test -d .git ; then \
Paul Beesleyadfab5b2019-03-07 16:42:31 +00001674 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \
Dan Handley3a355712016-06-02 18:21:02 +01001675 while read GIT_FILE ; \
1676 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
1677 done ; \
1678 else \
1679 find . -type f -not -iwholename "*.git*" \
1680 -not -iwholename "*build*" \
1681 -not -iwholename "*libfdt*" \
Roberto Vargas0f8f9852018-05-08 10:27:10 +01001682 -not -iwholename "*libc*" \
Dan Handley3a355712016-06-02 18:21:02 +01001683 -not -iwholename "*docs*" \
Paul Beesleyadfab5b2019-03-07 16:42:31 +00001684 -not -iwholename "*.rst" \
Dan Handley3a355712016-06-02 18:21:02 +01001685 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
1686 fi
Ian Spray36eaaf32014-01-30 17:25:28 +00001687
1688checkpatch: locate-checkpatch
Chris Kay1870c722024-05-02 17:52:37 +00001689 $(s)echo " CHECKING STYLE"
1690 $(q)if test -n "${CHECKPATCH_OPTS}"; then \
Yann Gautier0c26a2a2019-03-08 15:44:00 +01001691 echo " with ${CHECKPATCH_OPTS} option(s)"; \
1692 fi
Chris Kay1870c722024-05-02 17:52:37 +00001693 $(q)COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
Yann Gautiera10a6852021-11-02 18:03:31 +01001694 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \
1695 do \
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001696 printf "\n[*] Checking style of '$$commit'\n\n"; \
Yann Gautierfaf8c612024-08-09 11:52:03 +02001697 ( git log --format=email "$$commit~..$$commit" \
1698 -- ${CHECK_PATHS} ; \
1699 git diff --format=email "$$commit~..$$commit" \
1700 -- ${CHECK_PATHS}; ) | \
Yann Gautier0c26a2a2019-03-08 15:44:00 +01001701 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001702 done
Juan Castilloa3487d12015-08-18 14:23:04 +01001703
1704certtool: ${CRTTOOL}
Ian Spray36eaaf32014-01-30 17:25:28 +00001705
Pali Rohár54ff2132020-11-24 15:38:08 +01001706${CRTTOOL}: FORCE
Chris Kay1870c722024-05-02 17:52:37 +00001707 $(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
1708 $(s)echo
1709 $(s)echo "Built $@ successfully"
1710 $(s)echo
Jon Medhurst407a95c2014-02-12 15:54:48 +00001711
Juan Castillo11abdcd2014-10-21 11:30:42 +01001712ifneq (${GENERATE_COT},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001713certificates: ${CRT_DEPS} ${CRTTOOL}
Chris Kay1870c722024-05-02 17:52:37 +00001714 $(q)${CRTTOOL} ${CRT_ARGS}
1715 $(s)echo
1716 $(s)echo "Built $@ successfully"
1717 $(s)echo "Certificates can be found in ${BUILD_PLAT}"
1718 $(s)echo
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001719endif #(GENERATE_COT)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001720
Juan Castilloa3487d12015-08-18 14:23:04 +01001721${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
Pali Rohára5416ab2020-11-24 16:53:04 +01001722 $(eval ${CHECK_FIP_CMD})
Chris Kay1870c722024-05-02 17:52:37 +00001723 $(q)${FIPTOOL} create ${FIP_ARGS} $@
1724 $(q)${FIPTOOL} info $@
1725 $(s)echo
1726 $(s)echo "Built $@ successfully"
1727 $(s)echo
Soby Mathewdbee7fc2014-09-08 17:51:01 +01001728
Yatharth Kochard1a93432015-10-12 12:33:47 +01001729ifneq (${GENERATE_COT},0)
1730fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
Chris Kay1870c722024-05-02 17:52:37 +00001731 $(q)${CRTTOOL} ${FWU_CRT_ARGS}
1732 $(s)echo
1733 $(s)echo "Built $@ successfully"
1734 $(s)echo "FWU certificates can be found in ${BUILD_PLAT}"
1735 $(s)echo
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001736endif #(GENERATE_COT)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001737
1738${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
Pali Rohára5416ab2020-11-24 16:53:04 +01001739 $(eval ${CHECK_FWU_FIP_CMD})
Chris Kay1870c722024-05-02 17:52:37 +00001740 $(q)${FIPTOOL} create ${FWU_FIP_ARGS} $@
1741 $(q)${FIPTOOL} info $@
1742 $(s)echo
1743 $(s)echo "Built $@ successfully"
1744 $(s)echo
Yatharth Kochard1a93432015-10-12 12:33:47 +01001745
Juan Castilloa3487d12015-08-18 14:23:04 +01001746fiptool: ${FIPTOOL}
1747fip: ${BUILD_PLAT}/${FIP_NAME}
Yatharth Kochard1a93432015-10-12 12:33:47 +01001748fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
Harry Liebelf58ad362014-01-10 18:00:33 +00001749
Pali Rohár54ff2132020-11-24 15:38:08 +01001750${FIPTOOL}: FORCE
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001751ifdef UNIX_MK
Manish V Badarkhe0a5acd42024-10-03 20:50:04 +01001752 $(q)${MAKE} PLAT=${PLAT} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${FIPTOOLPATH} all
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001753else
1754# Clear the MAKEFLAGS as we do not want
1755# to pass the gnumake flags to nmake.
Chris Kay1870c722024-05-02 17:52:37 +00001756 $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001757endif #(UNIX_MK)
Harry Liebelf58ad362014-01-10 18:00:33 +00001758
Chris Kay63b60b42024-09-03 12:36:33 +00001759$(BUILD_PLAT)/romlib/romlib.bin $(BUILD_PLAT)/lib/libwrappers.a $&: $(BUILD_PLAT)/lib/libmbedtls.a $(BUILD_PLAT)/lib/libfdt.a $(BUILD_PLAT)/lib/libc.a
Chris Kay1870c722024-05-02 17:52:37 +00001760 $(q)${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES=$(call escape-shell,$(INCLUDES)) DEFINES=$(call escape-shell,$(DEFINES)) --no-print-directory -C ${ROMLIBPATH} all
Roberto Vargase92111a2018-05-22 16:05:42 +01001761
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +01001762memmap: all
Harrison Mutaie9bc4882023-02-23 10:33:58 +00001763ifdef UNIX_MK
Chris Kay1870c722024-05-02 17:52:37 +00001764 $(q)PYTHONPATH=${CURDIR}/tools/memory \
Harrison Mutaie9bc4882023-02-23 10:33:58 +00001765 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1766else
Chris Kay1870c722024-05-02 17:52:37 +00001767 $(q)set PYTHONPATH=${CURDIR}/tools/memory && \
Harrison Mutaie9bc4882023-02-23 10:33:58 +00001768 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1769endif
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +01001770
Harrison Mutai36d971a2024-08-28 13:27:19 +00001771tl: ${BUILD_PLAT}/tl.bin
1772${BUILD_PLAT}/tl.bin: ${HW_CONFIG}
Chris Kaya152e752024-09-26 14:18:04 +00001773 $(if $(host-poetry),$(q)poetry -q install)
1774 $(q)$(if $(host-poetry),poetry run )tlc create --fdt $< -s ${FW_HANDOFF_SIZE} $@
Harrison Mutai36d971a2024-08-28 13:27:19 +00001775
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -06001776doc:
Chris Kay1870c722024-05-02 17:52:37 +00001777 $(s)echo " BUILD DOCUMENTATION"
1778 $(q)${MAKE} --no-print-directory -C ${DOCS_PATH} html
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -06001779
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301780enctool: ${ENCTOOL}
1781
Pali Rohár54ff2132020-11-24 15:38:08 +01001782${ENCTOOL}: FORCE
Chris Kay1870c722024-05-02 17:52:37 +00001783 $(q)${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} --no-print-directory -C ${ENCTOOLPATH} all
1784 $(s)echo
1785 $(s)echo "Built $@ successfully"
1786 $(s)echo
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301787
Joakim Bech35fab8c2014-01-23 14:51:49 +01001788cscope:
Chris Kay1870c722024-05-02 17:52:37 +00001789 $(s)echo " CSCOPE"
1790 $(q)find ${CURDIR} -name "*.[chsS]" > cscope.files
1791 $(q)cscope -b -q -k
Joakim Bech35fab8c2014-01-23 14:51:49 +01001792
Ryan Harkin72ee3312014-01-15 16:55:07 +00001793help:
Chris Kay1870c722024-05-02 17:52:37 +00001794 $(s)echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
1795 $(s)echo ""
1796 $(s)echo "PLAT is used to specify which platform you wish to build."
1797 $(s)echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
1798 $(s)echo ""
1799 $(s)echo "platform = ${PLATFORM_LIST}"
1800 $(s)echo ""
1801 $(s)echo "Please refer to the User Guide for a list of all supported options."
1802 $(s)echo "Note that the build system doesn't track dependencies for build "
1803 $(s)echo "options. Therefore, if any of the build options are changed "
1804 $(s)echo "from a previous build, a clean build must be performed."
1805 $(s)echo ""
1806 $(s)echo "Supported Targets:"
1807 $(s)echo " all Build all individual bootloader binaries"
1808 $(s)echo " bl1 Build the BL1 binary"
1809 $(s)echo " bl2 Build the BL2 binary"
1810 $(s)echo " bl2u Build the BL2U binary"
1811 $(s)echo " bl31 Build the BL31 binary"
1812 $(s)echo " bl32 Build the BL32 binary. If ARCH=aarch32, then "
1813 $(s)echo " this builds secure payload specified by AARCH32_SP"
1814 $(s)echo " certificates Build the certificates (requires 'GENERATE_COT=1')"
1815 $(s)echo " fip Build the Firmware Image Package (FIP)"
1816 $(s)echo " fwu_fip Build the FWU Firmware Image Package (FIP)"
1817 $(s)echo " checkcodebase Check the coding style of the entire source tree"
1818 $(s)echo " checkpatch Check the coding style on changes in the current"
1819 $(s)echo " branch against BASE_COMMIT (default origin/master)"
1820 $(s)echo " clean Clean the build for the selected platform"
1821 $(s)echo " cscope Generate cscope index"
1822 $(s)echo " distclean Remove all build artifacts for all platforms"
1823 $(s)echo " certtool Build the Certificate generation tool"
1824 $(s)echo " enctool Build the Firmware encryption tool"
1825 $(s)echo " fiptool Build the Firmware Image Package (FIP) creation tool"
1826 $(s)echo " sp Build the Secure Partition Packages"
1827 $(s)echo " sptool Build the Secure Partition Package creation tool"
1828 $(s)echo " dtbs Build the Device Tree Blobs (if required for the platform)"
1829 $(s)echo " memmap Print the memory map of the built binaries"
1830 $(s)echo " doc Build html based documentation using Sphinx tool"
1831 $(s)echo ""
1832 $(s)echo "Note: most build targets require PLAT to be set to a specific platform."
1833 $(s)echo ""
1834 $(s)echo "example: build all targets for the FVP platform:"
1835 $(s)echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
Pali Rohár54ff2132020-11-24 15:38:08 +01001836
1837.PHONY: FORCE
1838FORCE:;