Makefile 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842
  1. #
  2. # Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved.
  3. #
  4. # SPDX-License-Identifier: BSD-3-Clause
  5. #
  6. #
  7. # Trusted Firmware Version
  8. #
  9. VERSION_MAJOR := 2
  10. VERSION_MINOR := 12
  11. # VERSION_PATCH is only used for LTS releases
  12. VERSION_PATCH := 0
  13. VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
  14. # Default goal is build all images
  15. .DEFAULT_GOAL := all
  16. # Avoid any implicit propagation of command line variable definitions to
  17. # sub-Makefiles, like CFLAGS that we reserved for the firmware images'
  18. # usage. Other command line options like "-s" are still propagated as usual.
  19. MAKEOVERRIDES =
  20. MAKE_HELPERS_DIRECTORY := make_helpers/
  21. include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
  22. include ${MAKE_HELPERS_DIRECTORY}build_env.mk
  23. include ${MAKE_HELPERS_DIRECTORY}build-rules.mk
  24. include ${MAKE_HELPERS_DIRECTORY}common.mk
  25. ################################################################################
  26. # Default values for build configurations, and their dependencies
  27. ################################################################################
  28. include ${MAKE_HELPERS_DIRECTORY}defaults.mk
  29. include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
  30. # To be able to set platform specific defaults
  31. ifneq ($(PLAT_DEFAULTS_MAKEFILE_FULL),)
  32. include ${PLAT_DEFAULTS_MAKEFILE_FULL}
  33. endif
  34. ################################################################################
  35. # Configure the toolchains used to build TF-A and its tools
  36. ################################################################################
  37. include ${MAKE_HELPERS_DIRECTORY}toolchain.mk
  38. # Assertions enabled for DEBUG builds by default
  39. ENABLE_ASSERTIONS := ${DEBUG}
  40. ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION}
  41. ################################################################################
  42. # Checkpatch script options
  43. ################################################################################
  44. CHECKCODE_ARGS := --no-patch
  45. # Do not check the coding style on imported library files or documentation files
  46. INC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \
  47. include/drivers/arm, \
  48. $(wildcard include/drivers/*)))
  49. INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \
  50. include/lib/libfdt \
  51. include/lib/libc, \
  52. $(wildcard include/lib/*)))
  53. INC_DIRS_TO_CHECK := $(sort $(filter-out \
  54. include/lib \
  55. include/drivers, \
  56. $(wildcard include/*)))
  57. LIB_DIRS_TO_CHECK := $(sort $(filter-out \
  58. lib/compiler-rt \
  59. lib/libfdt% \
  60. lib/libc, \
  61. lib/zlib \
  62. $(wildcard lib/*)))
  63. ROOT_DIRS_TO_CHECK := $(sort $(filter-out \
  64. lib \
  65. include \
  66. docs \
  67. %.rst, \
  68. $(wildcard *)))
  69. CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \
  70. ${INC_DIRS_TO_CHECK} \
  71. ${INC_LIB_DIRS_TO_CHECK} \
  72. ${LIB_DIRS_TO_CHECK} \
  73. ${INC_DRV_DIRS_TO_CHECK} \
  74. ${INC_ARM_DIRS_TO_CHECK}
  75. ################################################################################
  76. # Process build options
  77. ################################################################################
  78. ifeq ($(verbose),)
  79. CHECKCODE_ARGS += --no-summary --terse
  80. endif
  81. ################################################################################
  82. # Auxiliary tools (fiptool, cert_create, etc)
  83. ################################################################################
  84. # Variables for use with Certificate Generation Tool
  85. CRTTOOLPATH ?= tools/cert_create
  86. CRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT}
  87. # Variables for use with Firmware Encryption Tool
  88. ENCTOOLPATH ?= tools/encrypt_fw
  89. ENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
  90. # Variables for use with Firmware Image Package
  91. FIPTOOLPATH ?= tools/fiptool
  92. FIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT}
  93. # Variables for use with sptool
  94. SPTOOLPATH ?= tools/sptool
  95. SPTOOL ?= ${SPTOOLPATH}/sptool.py
  96. SP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py
  97. SP_DTS_LIST_FRAGMENT ?= ${BUILD_PLAT}/sp_list_fragment.dts
  98. # Variables for use with ROMLIB
  99. ROMLIBPATH ?= lib/romlib
  100. # Variable for use with Python
  101. PYTHON ?= python3
  102. # Variables for use with documentation build using Sphinx tool
  103. DOCS_PATH ?= docs
  104. ################################################################################
  105. # Compiler Configuration based on ARCH_MAJOR and ARCH_MINOR flags
  106. ################################################################################
  107. ifeq (${ARM_ARCH_MAJOR},7)
  108. target32-directive = -target arm-none-eabi
  109. # Will set march-directive from platform configuration
  110. else
  111. target32-directive = -target armv8a-none-eabi
  112. endif #(ARM_ARCH_MAJOR)
  113. ################################################################################
  114. # Get Architecture Feature Modifiers
  115. ################################################################################
  116. arch-features = ${ARM_ARCH_FEATURE}
  117. ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
  118. ifeq ($($(ARCH)-cc-id),arm-clang)
  119. TF_CFLAGS_aarch32 := -target arm-arm-none-eabi
  120. TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi
  121. else
  122. TF_CFLAGS_aarch32 = $(target32-directive)
  123. TF_CFLAGS_aarch64 := -target aarch64-elf
  124. endif
  125. else ifeq ($($(ARCH)-cc-id),gnu-gcc)
  126. # Enable LTO only for aarch64
  127. ifeq (${ARCH},aarch64)
  128. LTO_CFLAGS = $(if $(filter-out 0,$(ENABLE_LTO)),-flto)
  129. endif
  130. endif #(clang)
  131. # Process Debug flag
  132. $(eval $(call add_define,DEBUG))
  133. ifneq (${DEBUG}, 0)
  134. BUILD_TYPE := debug
  135. TF_CFLAGS += -g -gdwarf-4
  136. ASFLAGS += -g -Wa,-gdwarf-4
  137. # Use LOG_LEVEL_INFO by default for debug builds
  138. LOG_LEVEL := 40
  139. else
  140. BUILD_TYPE := release
  141. # Use LOG_LEVEL_NOTICE by default for release builds
  142. LOG_LEVEL := 20
  143. endif #(Debug)
  144. # Default build string (git branch and commit)
  145. ifeq (${BUILD_STRING},)
  146. BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null)
  147. endif
  148. VERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
  149. ifeq (${AARCH32_INSTRUCTION_SET},A32)
  150. TF_CFLAGS_aarch32 += -marm
  151. else ifeq (${AARCH32_INSTRUCTION_SET},T32)
  152. TF_CFLAGS_aarch32 += -mthumb
  153. else
  154. $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
  155. endif #(AARCH32_INSTRUCTION_SET)
  156. TF_CFLAGS_aarch32 += -mno-unaligned-access
  157. TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align
  158. ##############################################################################
  159. # WARNINGS Configuration
  160. ###############################################################################
  161. # General warnings
  162. WARNINGS := -Wall -Wmissing-include-dirs -Wunused \
  163. -Wdisabled-optimization -Wvla -Wshadow \
  164. -Wredundant-decls
  165. # stricter warnings
  166. WARNINGS += -Wextra -Wno-trigraphs
  167. # too verbose for generic build
  168. WARNINGS += -Wno-missing-field-initializers \
  169. -Wno-type-limits -Wno-sign-compare \
  170. # on clang this flag gets reset if -Wextra is set after it. No difference on gcc
  171. WARNINGS += -Wno-unused-parameter
  172. # Additional warnings
  173. # Level 1 - infrequent warnings we should have none of
  174. # full -Wextra
  175. WARNING1 += -Wsign-compare
  176. WARNING1 += -Wtype-limits
  177. WARNING1 += -Wmissing-field-initializers
  178. # Level 2 - problematic warnings that we want
  179. # zlib, compiler-rt, coreboot, and mbdedtls blow up with these
  180. # TODO: disable just for them and move into default build
  181. WARNING2 += -Wold-style-definition
  182. WARNING2 += -Wmissing-prototypes
  183. WARNING2 += -Wmissing-format-attribute
  184. # TF-A aims to comply with this eventually. Effort too large at present
  185. WARNING2 += -Wundef
  186. # currently very involved and many platforms set this off
  187. WARNING2 += -Wunused-const-variable=2
  188. # Level 3 - very pedantic, frequently ignored
  189. WARNING3 := -Wbad-function-cast
  190. WARNING3 += -Waggregate-return
  191. WARNING3 += -Wnested-externs
  192. WARNING3 += -Wcast-align
  193. WARNING3 += -Wcast-qual
  194. WARNING3 += -Wconversion
  195. WARNING3 += -Wpacked
  196. WARNING3 += -Wpointer-arith
  197. WARNING3 += -Wswitch-default
  198. # Setting W is quite verbose and most warnings will be pre-existing issues
  199. # outside of the contributor's control. Don't fail the build on them so warnings
  200. # can be seen and hopefully addressed
  201. ifdef W
  202. ifneq (${W},0)
  203. E ?= 0
  204. endif
  205. endif
  206. ifeq (${W},1)
  207. WARNINGS += $(WARNING1)
  208. else ifeq (${W},2)
  209. WARNINGS += $(WARNING1) $(WARNING2)
  210. else ifeq (${W},3)
  211. WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
  212. endif #(W)
  213. # Compiler specific warnings
  214. ifeq ($(filter %-clang,$($(ARCH)-cc-id)),)
  215. # not using clang
  216. WARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \
  217. -Wpacked-bitfield-compat -Wshift-overflow=2 \
  218. -Wlogical-op
  219. # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
  220. TF_CFLAGS_MIN_PAGE_SIZE := $(call cc_option, --param=min-pagesize=0)
  221. TF_CFLAGS += $(TF_CFLAGS_MIN_PAGE_SIZE)
  222. ifeq ($(HARDEN_SLS), 1)
  223. TF_CFLAGS_MHARDEN_SLS := $(call cc_option, -mharden-sls=all)
  224. TF_CFLAGS_aarch64 += $(TF_CFLAGS_MHARDEN_SLS)
  225. endif
  226. else
  227. # using clang
  228. WARNINGS += -Wshift-overflow -Wshift-sign-overflow \
  229. -Wlogical-op-parentheses
  230. endif #(Clang Warning)
  231. ifneq (${E},0)
  232. ERRORS := -Werror
  233. endif #(E)
  234. ################################################################################
  235. # Compiler and Linker Directives
  236. ################################################################################
  237. CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
  238. $(ERRORS) $(WARNINGS)
  239. ASFLAGS += $(CPPFLAGS) \
  240. -ffreestanding -Wa,--fatal-warnings
  241. TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \
  242. -ffunction-sections -fdata-sections \
  243. -ffreestanding -fno-common \
  244. -Os -std=gnu99
  245. ifeq (${SANITIZE_UB},on)
  246. TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover
  247. endif #(${SANITIZE_UB},on)
  248. ifeq (${SANITIZE_UB},trap)
  249. TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \
  250. -fsanitize-undefined-trap-on-error
  251. endif #(${SANITIZE_UB},trap)
  252. GCC_V_OUTPUT := $(if $($(ARCH)-cc),$(shell $($(ARCH)-cc) -v 2>&1))
  253. TF_LDFLAGS += -z noexecstack
  254. # LD = armlink
  255. ifeq ($($(ARCH)-ld-id),arm-link)
  256. TF_LDFLAGS += --diag_error=warning --lto_level=O1
  257. TF_LDFLAGS += --remove --info=unused,unusedsymbols
  258. TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
  259. # LD = gcc (used when GCC LTO is enabled)
  260. else ifeq ($($(ARCH)-ld-id),gnu-gcc)
  261. # Pass ld options with Wl or Xlinker switches
  262. TF_LDFLAGS += $(call ld_option,-Xlinker --no-warn-rwx-segments)
  263. TF_LDFLAGS += -Wl,--fatal-warnings -O1
  264. TF_LDFLAGS += -Wl,--gc-sections
  265. TF_LDFLAGS += -Wl,-z,common-page-size=4096 #Configure page size constants
  266. TF_LDFLAGS += -Wl,-z,max-page-size=4096
  267. TF_LDFLAGS += -Wl,--build-id=none
  268. ifeq ($(ENABLE_LTO),1)
  269. ifeq (${ARCH},aarch64)
  270. TF_LDFLAGS += -flto -fuse-linker-plugin
  271. TF_LDFLAGS += -flto-partition=one
  272. endif
  273. endif #(ENABLE_LTO)
  274. # GCC automatically adds fix-cortex-a53-843419 flag when used to link
  275. # which breaks some builds, so disable if errata fix is not explicitly enabled
  276. ifeq (${ARCH},aarch64)
  277. ifneq (${ERRATA_A53_843419},1)
  278. TF_LDFLAGS += -mno-fix-cortex-a53-843419
  279. endif
  280. endif
  281. TF_LDFLAGS += -nostdlib
  282. TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
  283. # LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
  284. else
  285. # With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
  286. # are not loaded by a elf loader.
  287. TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments)
  288. TF_LDFLAGS += -O1
  289. TF_LDFLAGS += --gc-sections
  290. TF_LDFLAGS += -z common-page-size=4096 # Configure page size constants
  291. TF_LDFLAGS += -z max-page-size=4096
  292. TF_LDFLAGS += --build-id=none
  293. # ld.lld doesn't recognize the errata flags,
  294. # therefore don't add those in that case.
  295. # ld.lld reports section type mismatch warnings,
  296. # therefore don't add --fatal-warnings to it.
  297. ifneq ($($(ARCH)-ld-id),llvm-lld)
  298. TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) --fatal-warnings
  299. endif
  300. endif #(LD = armlink)
  301. ################################################################################
  302. # Setup ARCH_MAJOR/MINOR before parsing arch_features.
  303. ################################################################################
  304. ifeq (${ENABLE_RME},1)
  305. ARM_ARCH_MAJOR := 9
  306. ARM_ARCH_MINOR := 2
  307. endif
  308. ################################################################################
  309. # Common sources and include directories
  310. ################################################################################
  311. include lib/compiler-rt/compiler-rt.mk
  312. # Allow overriding the timestamp, for example for reproducible builds, or to
  313. # synchronize timestamps across multiple projects.
  314. # This must be set to a C string (including quotes where applicable).
  315. BUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__
  316. DEFINES += -DBUILD_MESSAGE_TIMESTAMP='$(BUILD_MESSAGE_TIMESTAMP)'
  317. DEFINES += -DBUILD_MESSAGE_VERSION_STRING='"$(VERSION_STRING)"'
  318. DEFINES += -DBUILD_MESSAGE_VERSION='"$(VERSION)"'
  319. BL_COMMON_SOURCES += common/bl_common.c \
  320. common/tf_log.c \
  321. common/${ARCH}/debug.S \
  322. drivers/console/multi_console.c \
  323. lib/${ARCH}/cache_helpers.S \
  324. lib/${ARCH}/misc_helpers.S \
  325. lib/extensions/pmuv3/${ARCH}/pmuv3.c \
  326. plat/common/plat_bl_common.c \
  327. plat/common/plat_log_common.c \
  328. plat/common/${ARCH}/plat_common.c \
  329. plat/common/${ARCH}/platform_helpers.S \
  330. ${COMPILER_RT_SRCS}
  331. ifeq ($($(ARCH)-cc-id),arm-clang)
  332. BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S
  333. endif
  334. ifeq (${SANITIZE_UB},on)
  335. BL_COMMON_SOURCES += plat/common/ubsan.c
  336. endif
  337. INCLUDES += -Iinclude \
  338. -Iinclude/arch/${ARCH} \
  339. -Iinclude/lib/cpus/${ARCH} \
  340. -Iinclude/lib/el3_runtime/${ARCH} \
  341. ${PLAT_INCLUDES} \
  342. ${SPD_INCLUDES}
  343. DTC_FLAGS += -I dts -O dtb
  344. DTC_CPPFLAGS += -P -nostdinc $(INCLUDES) -Ifdts -undef \
  345. -x assembler-with-cpp $(DEFINES)
  346. include common/backtrace/backtrace.mk
  347. ################################################################################
  348. # Generic definitions
  349. ################################################################################
  350. ifeq (${BUILD_BASE},)
  351. BUILD_BASE := ./build
  352. endif
  353. BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
  354. SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
  355. # Platforms providing their own TBB makefile may override this value
  356. INCLUDE_TBBR_MK := 1
  357. ################################################################################
  358. # Include SPD Makefile if one has been specified
  359. ################################################################################
  360. ifneq (${SPD},none)
  361. ifeq (${ARCH},aarch32)
  362. $(error "Error: SPD is incompatible with AArch32.")
  363. endif
  364. ifdef EL3_PAYLOAD_BASE
  365. $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
  366. $(warning "The SPD and its BL32 companion will be present but \
  367. ignored.")
  368. endif
  369. ifeq (${SPD},spmd)
  370. # SPMD is located in std_svc directory
  371. SPD_DIR := std_svc
  372. ifeq ($(SPMD_SPM_AT_SEL2),1)
  373. CTX_INCLUDE_EL2_REGS := 1
  374. ifeq ($(SPMC_AT_EL3),1)
  375. $(error SPM cannot be enabled in both S-EL2 and EL3.)
  376. endif
  377. ifeq ($(CTX_INCLUDE_SVE_REGS),1)
  378. $(error SVE context management not needed with Hafnium SPMC.)
  379. endif
  380. endif
  381. ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
  382. DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG
  383. endif
  384. ifeq ($(findstring trusty_sp,$(ARM_SPMC_MANIFEST_DTS)),trusty_sp)
  385. DTC_CPPFLAGS += -DTRUSTY_SP_FW_CONFIG
  386. endif
  387. ifeq ($(TS_SP_FW_CONFIG),1)
  388. DTC_CPPFLAGS += -DTS_SP_FW_CONFIG
  389. endif
  390. ifneq ($(ARM_BL2_SP_LIST_DTS),)
  391. DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
  392. endif
  393. ifneq ($(SP_LAYOUT_FILE),)
  394. BL2_ENABLE_SP_LOAD := 1
  395. endif
  396. ifeq ($(SPMC_AT_EL3_SEL0_SP),1)
  397. ifneq ($(SPMC_AT_EL3),1)
  398. $(error SEL0 SP cannot be enabled without SPMC at EL3)
  399. endif
  400. endif
  401. else
  402. # All other SPDs in spd directory
  403. SPD_DIR := spd
  404. endif #(SPD)
  405. # We expect to locate an spd.mk under the specified SPD directory
  406. SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
  407. ifeq (${SPD_MAKE},)
  408. $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
  409. endif
  410. $(info Including ${SPD_MAKE})
  411. include ${SPD_MAKE}
  412. # If there's BL32 companion for the chosen SPD, we expect that the SPD's
  413. # Makefile would set NEED_BL32 to "yes". In this case, the build system
  414. # supports two mutually exclusive options:
  415. # * BL32 is built from source: then BL32_SOURCES must contain the list
  416. # of source files to build BL32
  417. # * BL32 is a prebuilt binary: then BL32 must point to the image file
  418. # that will be included in the FIP
  419. # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
  420. # over the sources.
  421. endif #(SPD=none)
  422. ifeq (${ENABLE_SPMD_LP}, 1)
  423. ifneq (${SPD},spmd)
  424. $(error Error: ENABLE_SPMD_LP requires SPD=spmd.)
  425. endif
  426. ifeq ($(SPMC_AT_EL3),1)
  427. $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.)
  428. endif
  429. endif
  430. ################################################################################
  431. # Process BRANCH_PROTECTION value and set
  432. # Pointer Authentication and Branch Target Identification flags
  433. ################################################################################
  434. ifeq (${BRANCH_PROTECTION},0)
  435. # Default value turns off all types of branch protection
  436. BP_OPTION := none
  437. else ifneq (${ARCH},aarch64)
  438. $(error BRANCH_PROTECTION requires AArch64)
  439. else ifeq (${BRANCH_PROTECTION},1)
  440. # Enables all types of branch protection features
  441. BP_OPTION := standard
  442. ENABLE_BTI := 1
  443. ENABLE_PAUTH := 1
  444. else ifeq (${BRANCH_PROTECTION},2)
  445. # Return address signing to its standard level
  446. BP_OPTION := pac-ret
  447. ENABLE_PAUTH := 1
  448. else ifeq (${BRANCH_PROTECTION},3)
  449. # Extend the signing to include leaf functions
  450. BP_OPTION := pac-ret+leaf
  451. ENABLE_PAUTH := 1
  452. else ifeq (${BRANCH_PROTECTION},4)
  453. # Turn on branch target identification mechanism
  454. BP_OPTION := bti
  455. ENABLE_BTI := 1
  456. else
  457. $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
  458. endif #(BRANCH_PROTECTION)
  459. ifeq ($(ENABLE_PAUTH),1)
  460. CTX_INCLUDE_PAUTH_REGS := 1
  461. endif
  462. ifneq (${BP_OPTION},none)
  463. TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION}
  464. endif #(BP_OPTION)
  465. # Pointer Authentication sources
  466. ifeq (${ENABLE_PAUTH}, 1)
  467. # arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the
  468. # Pauth support. As it's not secure, it must be reimplemented for real platforms
  469. BL_COMMON_SOURCES += lib/extensions/pauth/pauth_helpers.S
  470. endif
  471. ################################################################################
  472. # Include the platform specific Makefile after the SPD Makefile (the platform
  473. # makefile may use all previous definitions in this file)
  474. ################################################################################
  475. include ${PLAT_MAKEFILE_FULL}
  476. ################################################################################
  477. # Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from
  478. # platform.
  479. ################################################################################
  480. include ${MAKE_HELPERS_DIRECTORY}arch_features.mk
  481. ####################################################
  482. # Enable required options for Memory Stack Tagging.
  483. ####################################################
  484. # Currently, these options are enabled only for clang and armclang compiler.
  485. ifeq (${SUPPORT_STACK_MEMTAG},yes)
  486. ifdef mem_tag_arch_support
  487. # Check for armclang and clang compilers
  488. ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
  489. # Add "memtag" architecture feature modifier if not specified
  490. ifeq ( ,$(findstring memtag,$(arch-features)))
  491. arch-features := $(arch-features)+memtag
  492. endif # memtag
  493. ifeq ($($(ARCH)-cc-id),arm-clang)
  494. TF_CFLAGS += -mmemtag-stack
  495. else ifeq ($($(ARCH)-cc-id),llvm-clang)
  496. TF_CFLAGS += -fsanitize=memtag
  497. endif # armclang
  498. endif
  499. else
  500. $(error "Error: stack memory tagging is not supported for \
  501. architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
  502. endif #(mem_tag_arch_support)
  503. endif #(SUPPORT_STACK_MEMTAG)
  504. ################################################################################
  505. # RME dependent flags configuration, Enable optional features for RME.
  506. ################################################################################
  507. # FEAT_RME
  508. ifeq (${ENABLE_RME},1)
  509. # RME doesn't support PIE
  510. ifneq (${ENABLE_PIE},0)
  511. $(error ENABLE_RME does not support PIE)
  512. endif
  513. # RME requires AARCH64
  514. ifneq (${ARCH},aarch64)
  515. $(error ENABLE_RME requires AArch64)
  516. endif
  517. # RME requires el2 context to be saved for now.
  518. CTX_INCLUDE_EL2_REGS := 1
  519. CTX_INCLUDE_AARCH32_REGS := 0
  520. CTX_INCLUDE_PAUTH_REGS := 1
  521. # RME enables CSV2_2 extension by default.
  522. ENABLE_FEAT_CSV2_2 = 1
  523. endif #(FEAT_RME)
  524. ################################################################################
  525. # Include rmmd Makefile if RME is enabled
  526. ################################################################################
  527. ifneq (${ENABLE_RME},0)
  528. ifneq (${ARCH},aarch64)
  529. $(error ENABLE_RME requires AArch64)
  530. endif
  531. ifeq ($(SPMC_AT_EL3),1)
  532. $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
  533. endif
  534. ifneq (${SPD}, none)
  535. ifneq (${SPD}, spmd)
  536. $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd)
  537. endif
  538. endif
  539. include services/std_svc/rmmd/rmmd.mk
  540. $(warning "RME is an experimental feature")
  541. endif
  542. ifeq (${CTX_INCLUDE_EL2_REGS}, 1)
  543. ifeq (${SPD},none)
  544. ifeq (${ENABLE_RME},0)
  545. $(error CTX_INCLUDE_EL2_REGS is available only when SPD \
  546. or RME is enabled)
  547. endif
  548. endif
  549. endif
  550. ################################################################################
  551. # Make 128-Bit sysreg read/writes availabe when FEAT_D128 is enabled.
  552. ################################################################################
  553. ifneq (${ENABLE_FEAT_D128}, 0)
  554. BL_COMMON_SOURCES += lib/extensions/sysreg128/sysreg128.S
  555. endif
  556. ################################################################################
  557. # Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come
  558. # up with appropriate march values for compiler.
  559. ################################################################################
  560. include ${MAKE_HELPERS_DIRECTORY}march.mk
  561. TF_CFLAGS += $(march-directive)
  562. ASFLAGS += $(march-directive)
  563. # This internal flag is common option which is set to 1 for scenarios
  564. # when the BL2 is running in EL3 level. This occurs in two scenarios -
  565. # 4 world system running BL2 at EL3 and two world system without BL1 running
  566. # BL2 in EL3
  567. ifeq (${RESET_TO_BL2},1)
  568. BL2_RUNS_AT_EL3 := 1
  569. ifeq (${ENABLE_RME},1)
  570. $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \
  571. supported at the moment.)
  572. endif
  573. else ifeq (${ENABLE_RME},1)
  574. BL2_RUNS_AT_EL3 := 1
  575. else
  576. BL2_RUNS_AT_EL3 := 0
  577. endif
  578. # This internal flag is set to 1 when Firmware First handling of External aborts
  579. # is required by lowe ELs. Currently only NS requires this support.
  580. ifeq ($(HANDLE_EA_EL3_FIRST_NS),1)
  581. FFH_SUPPORT := 1
  582. else
  583. FFH_SUPPORT := 0
  584. endif
  585. ifeq (${ARM_ARCH_MAJOR},7)
  586. include make_helpers/armv7-a-cpus.mk
  587. endif
  588. PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT})
  589. ifneq ($(PIE_FOUND),)
  590. TF_CFLAGS += -fno-PIE
  591. ifeq ($($(ARCH)-ld-id),gnu-gcc)
  592. TF_LDFLAGS += -no-pie
  593. endif
  594. endif #(PIE_FOUND)
  595. ifeq ($($(ARCH)-ld-id),gnu-gcc)
  596. PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
  597. else
  598. PIE_LDFLAGS += -pie --no-dynamic-linker
  599. endif
  600. ifeq ($(ENABLE_PIE),1)
  601. ifeq ($(RESET_TO_BL2),1)
  602. ifneq ($(BL2_IN_XIP_MEM),1)
  603. BL2_CPPFLAGS += -fpie
  604. BL2_CFLAGS += -fpie
  605. BL2_LDFLAGS += $(PIE_LDFLAGS)
  606. endif #(BL2_IN_XIP_MEM)
  607. endif #(RESET_TO_BL2)
  608. BL31_CPPFLAGS += -fpie
  609. BL31_CFLAGS += -fpie
  610. BL31_LDFLAGS += $(PIE_LDFLAGS)
  611. BL32_CPPFLAGS += -fpie
  612. BL32_CFLAGS += -fpie
  613. BL32_LDFLAGS += $(PIE_LDFLAGS)
  614. endif #(ENABLE_PIE)
  615. BL1_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
  616. BL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
  617. BL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
  618. BL1_CPPFLAGS += -DIMAGE_AT_EL3
  619. ifeq ($(RESET_TO_BL2),1)
  620. BL2_CPPFLAGS += -DIMAGE_AT_EL3
  621. else
  622. BL2_CPPFLAGS += -DIMAGE_AT_EL1
  623. endif #(RESET_TO_BL2)
  624. ifeq (${ARCH},aarch64)
  625. BL2U_CPPFLAGS += -DIMAGE_AT_EL1
  626. BL31_CPPFLAGS += -DIMAGE_AT_EL3
  627. BL32_CPPFLAGS += -DIMAGE_AT_EL1
  628. else
  629. BL32_CPPFLAGS += -DIMAGE_AT_EL3
  630. endif
  631. # Include the CPU specific operations makefile, which provides default
  632. # values for all CPU errata workarounds and CPU specific optimisations.
  633. # This can be overridden by the platform.
  634. include lib/cpus/cpu-ops.mk
  635. ################################################################################
  636. # Build `AARCH32_SP` as BL32 image for AArch32
  637. ################################################################################
  638. ifeq (${ARCH},aarch32)
  639. NEED_BL32 := yes
  640. ifneq (${AARCH32_SP},none)
  641. # We expect to locate an sp.mk under the specified AARCH32_SP directory
  642. AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
  643. ifeq (${AARCH32_SP_MAKE},)
  644. $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
  645. endif
  646. $(info Including ${AARCH32_SP_MAKE})
  647. include ${AARCH32_SP_MAKE}
  648. endif
  649. endif #(ARCH=aarch32)
  650. ################################################################################
  651. # Include libc if not overridden
  652. ################################################################################
  653. ifeq (${OVERRIDE_LIBC},0)
  654. include lib/libc/libc.mk
  655. endif
  656. ################################################################################
  657. # Check incompatible options and dependencies
  658. ################################################################################
  659. # USE_DEBUGFS experimental feature recommended only in debug builds
  660. ifeq (${USE_DEBUGFS},1)
  661. ifeq (${DEBUG},1)
  662. $(warning DEBUGFS experimental feature is enabled.)
  663. else
  664. $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
  665. endif
  666. endif #(USE_DEBUGFS)
  667. # USE_SPINLOCK_CAS requires AArch64 build
  668. ifeq (${USE_SPINLOCK_CAS},1)
  669. ifneq (${ARCH},aarch64)
  670. $(error USE_SPINLOCK_CAS requires AArch64)
  671. endif
  672. endif #(USE_SPINLOCK_CAS)
  673. # The cert_create tool cannot generate certificates individually, so we use the
  674. # target 'certificates' to create them all
  675. ifneq (${GENERATE_COT},0)
  676. FIP_DEPS += certificates
  677. FWU_FIP_DEPS += fwu_certificates
  678. endif
  679. ifneq (${DECRYPTION_SUPPORT},none)
  680. ENC_ARGS += -f ${FW_ENC_STATUS}
  681. ENC_ARGS += -k ${ENC_KEY}
  682. ENC_ARGS += -n ${ENC_NONCE}
  683. FIP_DEPS += enctool
  684. FWU_FIP_DEPS += enctool
  685. endif #(DECRYPTION_SUPPORT)
  686. ifdef EL3_PAYLOAD_BASE
  687. ifdef PRELOADED_BL33_BASE
  688. $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
  689. incompatible build options. EL3_PAYLOAD_BASE has priority.")
  690. endif
  691. ifneq (${GENERATE_COT},0)
  692. $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \
  693. build options.")
  694. endif
  695. ifneq (${TRUSTED_BOARD_BOOT},0)
  696. $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \
  697. incompatible \ build options.")
  698. endif
  699. endif #(EL3_PAYLOAD_BASE)
  700. ifeq (${NEED_BL33},yes)
  701. ifdef EL3_PAYLOAD_BASE
  702. $(warning "BL33 image is not needed when option \
  703. BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
  704. endif
  705. ifdef PRELOADED_BL33_BASE
  706. $(warning "BL33 image is not needed when option \
  707. PRELOADED_BL33_BASE is used and won't be added to the FIP file.")
  708. endif
  709. endif #(NEED_BL33)
  710. # When building for systems with hardware-assisted coherency, there's no need to
  711. # use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
  712. ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
  713. $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
  714. endif
  715. #For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1.
  716. ifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1)
  717. $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled")
  718. endif
  719. # RAS_EXTENSION is deprecated, provide alternate build options
  720. ifeq ($(RAS_EXTENSION),1)
  721. $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \
  722. and HANDLE_EA_EL3_FIRST_NS instead")
  723. endif
  724. # When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled
  725. ifeq ($(FAULT_INJECTION_SUPPORT),1)
  726. ifeq ($(ENABLE_FEAT_RAS),0)
  727. $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0)
  728. endif
  729. endif #(FAULT_INJECTION_SUPPORT)
  730. # DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
  731. ifeq ($(DYN_DISABLE_AUTH), 1)
  732. ifeq (${TRUSTED_BOARD_BOOT}, 0)
  733. $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \
  734. to be set.")
  735. endif
  736. endif #(DYN_DISABLE_AUTH)
  737. ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
  738. # Support authentication verification and hash calculation
  739. CRYPTO_SUPPORT := 3
  740. else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
  741. # Support authentication verification and hash calculation
  742. CRYPTO_SUPPORT := 3
  743. else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
  744. # Support hash calculation only
  745. CRYPTO_SUPPORT := 2
  746. else ifeq (${TRUSTED_BOARD_BOOT},1)
  747. # Support authentication verification only
  748. CRYPTO_SUPPORT := 1
  749. else
  750. CRYPTO_SUPPORT := 0
  751. endif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT))
  752. ifneq ($(filter 1 2 3,$(CRYPTO_SUPPORT)),)
  753. CRYPTO_LIB := $(BUILD_PLAT)/lib/libmbedtls.a
  754. endif
  755. # SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
  756. ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
  757. $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
  758. endif
  759. # If pointer authentication is used in the firmware, make sure that all the
  760. # registers associated to it are also saved and restored.
  761. # Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
  762. ifeq ($(ENABLE_PAUTH),1)
  763. ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
  764. $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
  765. endif
  766. endif #(ENABLE_PAUTH)
  767. ifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
  768. ifneq (${ARCH},aarch64)
  769. $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
  770. endif
  771. endif #(CTX_INCLUDE_PAUTH_REGS)
  772. ifeq ($(FEATURE_DETECTION),1)
  773. $(info FEATURE_DETECTION is an experimental feature)
  774. endif #(FEATURE_DETECTION)
  775. ifneq ($(ENABLE_SME2_FOR_NS), 0)
  776. ifeq (${ENABLE_SME_FOR_NS}, 0)
  777. $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \
  778. to be set")
  779. $(warning "Forced ENABLE_SME_FOR_NS=1")
  780. override ENABLE_SME_FOR_NS := 1
  781. endif
  782. endif #(ENABLE_SME2_FOR_NS)
  783. ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
  784. ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
  785. $(error "ALLOW_RO_XLAT_TABLES requires translation tables \
  786. library v2")
  787. endif
  788. endif #(ARM_XLAT_TABLES_LIB_V1)
  789. ifneq (${DECRYPTION_SUPPORT},none)
  790. ifeq (${TRUSTED_BOARD_BOOT}, 0)
  791. $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \
  792. to be set)
  793. endif
  794. endif #(DECRYPTION_SUPPORT)
  795. # Ensure that no Aarch64-only features are enabled in Aarch32 build
  796. ifeq (${ARCH},aarch32)
  797. # SME/SVE only supported on AArch64
  798. ifneq (${ENABLE_SME_FOR_NS},0)
  799. $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
  800. endif
  801. ifeq (${ENABLE_SVE_FOR_NS},1)
  802. # Warning instead of error due to CI dependency on this
  803. $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
  804. endif
  805. # BRBE is not supported in AArch32
  806. ifeq (${ENABLE_BRBE_FOR_NS},1)
  807. $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
  808. endif
  809. # FEAT_RNG_TRAP is not supported in AArch32
  810. ifeq (${ENABLE_FEAT_RNG_TRAP},1)
  811. $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
  812. endif
  813. ifneq (${ENABLE_FEAT_FPMR},0)
  814. $(error "ENABLE_FEAT_FPMR cannot be used with ARCH=aarch32")
  815. endif
  816. endif #(ARCH=aarch32)
  817. ifneq (${ENABLE_FEAT_FPMR},0)
  818. ifeq (${ENABLE_FEAT_FGT},0)
  819. $(error "ENABLE_FEAT_FPMR requires ENABLE_FEAT_FGT")
  820. endif
  821. ifeq (${ENABLE_FEAT_HCX},0)
  822. $(error "ENABLE_FEAT_FPMR requires ENABLE_FEAT_HCX")
  823. endif
  824. endif #(ENABLE_FEAT_FPMR)
  825. ifneq (${ENABLE_SME_FOR_NS},0)
  826. ifeq (${ENABLE_SVE_FOR_NS},0)
  827. $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS")
  828. endif
  829. endif #(ENABLE_SME_FOR_NS)
  830. # Secure SME/SVE requires the non-secure component as well
  831. ifeq (${ENABLE_SME_FOR_SWD},1)
  832. ifeq (${ENABLE_SME_FOR_NS},0)
  833. $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
  834. endif
  835. ifeq (${ENABLE_SVE_FOR_SWD},0)
  836. $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD")
  837. endif
  838. endif #(ENABLE_SME_FOR_SWD)
  839. # Enabling SVE for SWD requires enabling SVE for NWD due to ENABLE_FEAT
  840. # mechanism.
  841. ifeq (${ENABLE_SVE_FOR_SWD},1)
  842. ifeq (${ENABLE_SVE_FOR_NS},0)
  843. $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
  844. endif
  845. endif
  846. # Enabling SVE for both the worlds typically requires the context
  847. # management of SVE registers. The only exception being SPMC at S-EL2.
  848. ifeq (${ENABLE_SVE_FOR_SWD}, 1)
  849. ifneq (${ENABLE_SVE_FOR_NS}, 0)
  850. ifeq (${CTX_INCLUDE_SVE_REGS}-$(SPMD_SPM_AT_SEL2),0-0)
  851. $(warning "ENABLE_SVE_FOR_SWD and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
  852. endif
  853. endif
  854. endif
  855. # Enabling SVE in either world while enabling CTX_INCLUDE_FPREGS requires
  856. # CTX_INCLUDE_SVE_REGS to be enabled due to architectural dependency between FP
  857. # and SVE registers.
  858. ifeq (${CTX_INCLUDE_FPREGS}, 1)
  859. ifneq (${ENABLE_SVE_FOR_NS},0)
  860. ifeq (${CTX_INCLUDE_SVE_REGS},0)
  861. # Warning instead of error due to CI dependency on this
  862. $(warning "CTX_INCLUDE_FPREGS and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
  863. $(warning "Forced ENABLE_SVE_FOR_NS=0")
  864. override ENABLE_SVE_FOR_NS := 0
  865. endif
  866. endif
  867. endif #(CTX_INCLUDE_FPREGS)
  868. # SVE context management is only required if secure world has access to SVE/FP
  869. # functionality.
  870. ifeq (${CTX_INCLUDE_SVE_REGS},1)
  871. ifeq (${ENABLE_SVE_FOR_SWD},0)
  872. $(error "CTX_INCLUDE_SVE_REGS requires ENABLE_SVE_FOR_SWD to also be enabled")
  873. endif
  874. endif
  875. # SME cannot be used with CTX_INCLUDE_FPREGS since SPM does its own context
  876. # management including FPU registers.
  877. ifeq (${CTX_INCLUDE_FPREGS},1)
  878. ifneq (${ENABLE_SME_FOR_NS},0)
  879. $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
  880. endif
  881. endif #(CTX_INCLUDE_FPREGS)
  882. ifeq ($(DRTM_SUPPORT),1)
  883. $(info DRTM_SUPPORT is an experimental feature)
  884. endif
  885. ifeq (${HOB_LIST},1)
  886. $(warning HOB_LIST is an experimental feature)
  887. endif
  888. ifeq (${TRANSFER_LIST},1)
  889. $(info TRANSFER_LIST is an experimental feature)
  890. endif
  891. ifeq (${ENABLE_RME},1)
  892. ifneq (${SEPARATE_CODE_AND_RODATA},1)
  893. $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
  894. endif
  895. endif
  896. ifeq ($(PSA_CRYPTO),1)
  897. $(info PSA_CRYPTO is an experimental feature)
  898. endif
  899. ifeq ($(DICE_PROTECTION_ENVIRONMENT),1)
  900. $(info DICE_PROTECTION_ENVIRONMENT is an experimental feature)
  901. endif
  902. ################################################################################
  903. # Process platform overrideable behaviour
  904. ################################################################################
  905. ifdef BL1_SOURCES
  906. NEED_BL1 := yes
  907. endif #(BL1_SOURCES)
  908. ifdef BL2_SOURCES
  909. NEED_BL2 := yes
  910. # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
  911. # Certificate generation tools. This flag can be overridden by the platform.
  912. ifdef EL3_PAYLOAD_BASE
  913. # If booting an EL3 payload there is no need for a BL33 image
  914. # in the FIP file.
  915. NEED_BL33 := no
  916. else
  917. ifdef PRELOADED_BL33_BASE
  918. # If booting a BL33 preloaded image there is no need of
  919. # another one in the FIP file.
  920. NEED_BL33 := no
  921. else
  922. NEED_BL33 ?= yes
  923. endif
  924. endif
  925. endif #(BL2_SOURCES)
  926. ifdef BL2U_SOURCES
  927. NEED_BL2U := yes
  928. endif #(BL2U_SOURCES)
  929. # If SCP_BL2 is given, we always want FIP to include it.
  930. ifdef SCP_BL2
  931. NEED_SCP_BL2 := yes
  932. endif #(SCP_BL2)
  933. # For AArch32, BL31 is not currently supported.
  934. ifneq (${ARCH},aarch32)
  935. ifdef BL31_SOURCES
  936. # When booting an EL3 payload, there is no need to compile the BL31
  937. # image nor put it in the FIP.
  938. ifndef EL3_PAYLOAD_BASE
  939. NEED_BL31 := yes
  940. endif
  941. endif
  942. endif #(ARCH=aarch64)
  943. # Process TBB related flags
  944. ifneq (${GENERATE_COT},0)
  945. # Common cert_create options
  946. ifneq (${CREATE_KEYS},0)
  947. $(eval CRT_ARGS += -n)
  948. $(eval FWU_CRT_ARGS += -n)
  949. ifneq (${SAVE_KEYS},0)
  950. $(eval CRT_ARGS += -k)
  951. $(eval FWU_CRT_ARGS += -k)
  952. endif
  953. endif
  954. # Include TBBR makefile (unless the platform indicates otherwise)
  955. ifeq (${INCLUDE_TBBR_MK},1)
  956. include make_helpers/tbbr/tbbr_tools.mk
  957. endif
  958. endif #(GENERATE_COT)
  959. ifneq (${FIP_ALIGN},0)
  960. FIP_ARGS += --align ${FIP_ALIGN}
  961. endif #(FIP_ALIGN)
  962. ifdef FDT_SOURCES
  963. NEED_FDT := yes
  964. endif #(FDT_SOURCES)
  965. ################################################################################
  966. # Include libraries' Makefile that are used in all BL
  967. ################################################################################
  968. include lib/stack_protector/stack_protector.mk
  969. ################################################################################
  970. # Include BL specific makefiles
  971. ################################################################################
  972. ifeq (${NEED_BL1},yes)
  973. include bl1/bl1.mk
  974. endif
  975. ifeq (${NEED_BL2},yes)
  976. include bl2/bl2.mk
  977. endif
  978. ifeq (${NEED_BL2U},yes)
  979. include bl2u/bl2u.mk
  980. endif
  981. ifeq (${NEED_BL31},yes)
  982. include bl31/bl31.mk
  983. endif
  984. ################################################################################
  985. # Build options checks
  986. ################################################################################
  987. # Boolean_Flags
  988. $(eval $(call assert_booleans,\
  989. $(sort \
  990. ALLOW_RO_XLAT_TABLES \
  991. BL2_ENABLE_SP_LOAD \
  992. COLD_BOOT_SINGLE_CPU \
  993. CREATE_KEYS \
  994. CTX_INCLUDE_AARCH32_REGS \
  995. CTX_INCLUDE_FPREGS \
  996. CTX_INCLUDE_SVE_REGS \
  997. CTX_INCLUDE_EL2_REGS \
  998. CTX_INCLUDE_MPAM_REGS \
  999. DEBUG \
  1000. DYN_DISABLE_AUTH \
  1001. EL3_EXCEPTION_HANDLING \
  1002. ENABLE_AMU_AUXILIARY_COUNTERS \
  1003. ENABLE_AMU_FCONF \
  1004. AMU_RESTRICT_COUNTERS \
  1005. ENABLE_ASSERTIONS \
  1006. ENABLE_PIE \
  1007. ENABLE_PMF \
  1008. ENABLE_PSCI_STAT \
  1009. ENABLE_RUNTIME_INSTRUMENTATION \
  1010. ENABLE_SME_FOR_SWD \
  1011. ENABLE_SVE_FOR_SWD \
  1012. ENABLE_FEAT_RAS \
  1013. FFH_SUPPORT \
  1014. ERROR_DEPRECATED \
  1015. FAULT_INJECTION_SUPPORT \
  1016. GENERATE_COT \
  1017. GICV2_G0_FOR_EL3 \
  1018. HANDLE_EA_EL3_FIRST_NS \
  1019. HARDEN_SLS \
  1020. HW_ASSISTED_COHERENCY \
  1021. MEASURED_BOOT \
  1022. DICE_PROTECTION_ENVIRONMENT \
  1023. RMMD_ENABLE_EL3_TOKEN_SIGN \
  1024. DRTM_SUPPORT \
  1025. NS_TIMER_SWITCH \
  1026. OVERRIDE_LIBC \
  1027. PL011_GENERIC_UART \
  1028. PROGRAMMABLE_RESET_ADDRESS \
  1029. PSCI_EXTENDED_STATE_ID \
  1030. PSCI_OS_INIT_MODE \
  1031. RESET_TO_BL31 \
  1032. SAVE_KEYS \
  1033. SEPARATE_CODE_AND_RODATA \
  1034. SEPARATE_BL2_NOLOAD_REGION \
  1035. SEPARATE_NOBITS_REGION \
  1036. SEPARATE_RWDATA_REGION \
  1037. SEPARATE_SIMD_SECTION \
  1038. SPIN_ON_BL1_EXIT \
  1039. SPM_MM \
  1040. SPMC_AT_EL3 \
  1041. SPMC_AT_EL3_SEL0_SP \
  1042. SPMD_SPM_AT_SEL2 \
  1043. ENABLE_SPMD_LP \
  1044. TRANSFER_LIST \
  1045. TRUSTED_BOARD_BOOT \
  1046. USE_COHERENT_MEM \
  1047. USE_DEBUGFS \
  1048. ARM_IO_IN_DTB \
  1049. SDEI_IN_FCONF \
  1050. SEC_INT_DESC_IN_FCONF \
  1051. USE_ROMLIB \
  1052. USE_TBBR_DEFS \
  1053. WARMBOOT_ENABLE_DCACHE_EARLY \
  1054. RESET_TO_BL2 \
  1055. BL2_IN_XIP_MEM \
  1056. BL2_INV_DCACHE \
  1057. USE_SPINLOCK_CAS \
  1058. ENCRYPT_BL31 \
  1059. ENCRYPT_BL32 \
  1060. ERRATA_SPECULATIVE_AT \
  1061. RAS_TRAP_NS_ERR_REC_ACCESS \
  1062. COT_DESC_IN_DTB \
  1063. USE_SP804_TIMER \
  1064. PSA_FWU_SUPPORT \
  1065. PSA_FWU_METADATA_FW_STORE_DESC \
  1066. ENABLE_MPMM \
  1067. ENABLE_MPMM_FCONF \
  1068. FEATURE_DETECTION \
  1069. TRNG_SUPPORT \
  1070. ERRATA_ABI_SUPPORT \
  1071. ERRATA_NON_ARM_INTERCONNECT \
  1072. CONDITIONAL_CMO \
  1073. PSA_CRYPTO \
  1074. ENABLE_CONSOLE_GETC \
  1075. INIT_UNUSED_NS_EL2 \
  1076. PLATFORM_REPORT_CTX_MEM_USE \
  1077. EARLY_CONSOLE \
  1078. PRESERVE_DSU_PMU_REGS \
  1079. HOB_LIST \
  1080. )))
  1081. # Numeric_Flags
  1082. $(eval $(call assert_numerics,\
  1083. $(sort \
  1084. ARM_ARCH_MAJOR \
  1085. ARM_ARCH_MINOR \
  1086. BRANCH_PROTECTION \
  1087. CTX_INCLUDE_PAUTH_REGS \
  1088. CTX_INCLUDE_NEVE_REGS \
  1089. CRYPTO_SUPPORT \
  1090. DISABLE_MTPMU \
  1091. ENABLE_BRBE_FOR_NS \
  1092. ENABLE_TRBE_FOR_NS \
  1093. ENABLE_BTI \
  1094. ENABLE_PAUTH \
  1095. ENABLE_FEAT_AMU \
  1096. ENABLE_FEAT_AMUv1p1 \
  1097. ENABLE_FEAT_CSV2_2 \
  1098. ENABLE_FEAT_CSV2_3 \
  1099. ENABLE_FEAT_DEBUGV8P9 \
  1100. ENABLE_FEAT_DIT \
  1101. ENABLE_FEAT_ECV \
  1102. ENABLE_FEAT_FGT \
  1103. ENABLE_FEAT_FGT2 \
  1104. ENABLE_FEAT_FPMR \
  1105. ENABLE_FEAT_HCX \
  1106. ENABLE_FEAT_LS64_ACCDATA \
  1107. ENABLE_FEAT_MTE2 \
  1108. ENABLE_FEAT_PAN \
  1109. ENABLE_FEAT_RNG \
  1110. ENABLE_FEAT_RNG_TRAP \
  1111. ENABLE_FEAT_SEL2 \
  1112. ENABLE_FEAT_TCR2 \
  1113. ENABLE_FEAT_THE \
  1114. ENABLE_FEAT_SB \
  1115. ENABLE_FEAT_S2PIE \
  1116. ENABLE_FEAT_S1PIE \
  1117. ENABLE_FEAT_S2POE \
  1118. ENABLE_FEAT_S1POE \
  1119. ENABLE_FEAT_SCTLR2 \
  1120. ENABLE_FEAT_D128 \
  1121. ENABLE_FEAT_GCS \
  1122. ENABLE_FEAT_VHE \
  1123. ENABLE_FEAT_MPAM \
  1124. ENABLE_RME \
  1125. ENABLE_SPE_FOR_NS \
  1126. ENABLE_SYS_REG_TRACE_FOR_NS \
  1127. ENABLE_SME_FOR_NS \
  1128. ENABLE_SME2_FOR_NS \
  1129. ENABLE_SVE_FOR_NS \
  1130. ENABLE_TRF_FOR_NS \
  1131. FW_ENC_STATUS \
  1132. NR_OF_FW_BANKS \
  1133. NR_OF_IMAGES_IN_FW_BANK \
  1134. TWED_DELAY \
  1135. ENABLE_FEAT_TWED \
  1136. SVE_VECTOR_LEN \
  1137. IMPDEF_SYSREG_TRAP \
  1138. )))
  1139. ifdef KEY_SIZE
  1140. $(eval $(call assert_numeric,KEY_SIZE))
  1141. endif
  1142. ifeq ($(filter $(SANITIZE_UB), on off trap),)
  1143. $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
  1144. endif
  1145. ################################################################################
  1146. # Add definitions to the cpp preprocessor based on the current build options.
  1147. # This is done after including the platform specific makefile to allow the
  1148. # platform to overwrite the default options
  1149. ################################################################################
  1150. $(eval $(call add_defines,\
  1151. $(sort \
  1152. ALLOW_RO_XLAT_TABLES \
  1153. ARM_ARCH_MAJOR \
  1154. ARM_ARCH_MINOR \
  1155. BL2_ENABLE_SP_LOAD \
  1156. COLD_BOOT_SINGLE_CPU \
  1157. CTX_INCLUDE_AARCH32_REGS \
  1158. CTX_INCLUDE_FPREGS \
  1159. CTX_INCLUDE_SVE_REGS \
  1160. CTX_INCLUDE_PAUTH_REGS \
  1161. CTX_INCLUDE_MPAM_REGS \
  1162. EL3_EXCEPTION_HANDLING \
  1163. CTX_INCLUDE_EL2_REGS \
  1164. CTX_INCLUDE_NEVE_REGS \
  1165. DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
  1166. DISABLE_MTPMU \
  1167. ENABLE_FEAT_AMU \
  1168. ENABLE_AMU_AUXILIARY_COUNTERS \
  1169. ENABLE_AMU_FCONF \
  1170. AMU_RESTRICT_COUNTERS \
  1171. ENABLE_ASSERTIONS \
  1172. ENABLE_BTI \
  1173. ENABLE_FEAT_DEBUGV8P9 \
  1174. ENABLE_FEAT_MPAM \
  1175. ENABLE_PAUTH \
  1176. ENABLE_PIE \
  1177. ENABLE_PMF \
  1178. ENABLE_PSCI_STAT \
  1179. ENABLE_RME \
  1180. RMMD_ENABLE_EL3_TOKEN_SIGN \
  1181. ENABLE_RUNTIME_INSTRUMENTATION \
  1182. ENABLE_SME_FOR_NS \
  1183. ENABLE_SME2_FOR_NS \
  1184. ENABLE_SME_FOR_SWD \
  1185. ENABLE_SPE_FOR_NS \
  1186. ENABLE_SVE_FOR_NS \
  1187. ENABLE_SVE_FOR_SWD \
  1188. ENABLE_FEAT_RAS \
  1189. FFH_SUPPORT \
  1190. ENCRYPT_BL31 \
  1191. ENCRYPT_BL32 \
  1192. ERROR_DEPRECATED \
  1193. FAULT_INJECTION_SUPPORT \
  1194. GICV2_G0_FOR_EL3 \
  1195. HANDLE_EA_EL3_FIRST_NS \
  1196. HW_ASSISTED_COHERENCY \
  1197. LOG_LEVEL \
  1198. MEASURED_BOOT \
  1199. DICE_PROTECTION_ENVIRONMENT \
  1200. DRTM_SUPPORT \
  1201. NS_TIMER_SWITCH \
  1202. PL011_GENERIC_UART \
  1203. PLAT_${PLAT} \
  1204. PROGRAMMABLE_RESET_ADDRESS \
  1205. PSCI_EXTENDED_STATE_ID \
  1206. PSCI_OS_INIT_MODE \
  1207. RESET_TO_BL31 \
  1208. RME_GPT_BITLOCK_BLOCK \
  1209. RME_GPT_MAX_BLOCK \
  1210. SEPARATE_CODE_AND_RODATA \
  1211. SEPARATE_BL2_NOLOAD_REGION \
  1212. SEPARATE_NOBITS_REGION \
  1213. SEPARATE_RWDATA_REGION \
  1214. SEPARATE_SIMD_SECTION \
  1215. RECLAIM_INIT_CODE \
  1216. SPD_${SPD} \
  1217. SPIN_ON_BL1_EXIT \
  1218. SPM_MM \
  1219. SPMC_AT_EL3 \
  1220. SPMC_AT_EL3_SEL0_SP \
  1221. SPMD_SPM_AT_SEL2 \
  1222. TRANSFER_LIST \
  1223. TRUSTED_BOARD_BOOT \
  1224. CRYPTO_SUPPORT \
  1225. TRNG_SUPPORT \
  1226. ERRATA_ABI_SUPPORT \
  1227. ERRATA_NON_ARM_INTERCONNECT \
  1228. USE_COHERENT_MEM \
  1229. USE_DEBUGFS \
  1230. ARM_IO_IN_DTB \
  1231. SDEI_IN_FCONF \
  1232. SEC_INT_DESC_IN_FCONF \
  1233. USE_ROMLIB \
  1234. USE_TBBR_DEFS \
  1235. WARMBOOT_ENABLE_DCACHE_EARLY \
  1236. RESET_TO_BL2 \
  1237. BL2_RUNS_AT_EL3 \
  1238. BL2_IN_XIP_MEM \
  1239. BL2_INV_DCACHE \
  1240. USE_SPINLOCK_CAS \
  1241. ERRATA_SPECULATIVE_AT \
  1242. RAS_TRAP_NS_ERR_REC_ACCESS \
  1243. COT_DESC_IN_DTB \
  1244. USE_SP804_TIMER \
  1245. ENABLE_FEAT_RNG \
  1246. ENABLE_FEAT_RNG_TRAP \
  1247. ENABLE_FEAT_SB \
  1248. ENABLE_FEAT_DIT \
  1249. NR_OF_FW_BANKS \
  1250. NR_OF_IMAGES_IN_FW_BANK \
  1251. PSA_FWU_SUPPORT \
  1252. PSA_FWU_METADATA_FW_STORE_DESC \
  1253. ENABLE_BRBE_FOR_NS \
  1254. ENABLE_TRBE_FOR_NS \
  1255. ENABLE_SYS_REG_TRACE_FOR_NS \
  1256. ENABLE_TRF_FOR_NS \
  1257. ENABLE_FEAT_HCX \
  1258. ENABLE_MPMM \
  1259. ENABLE_MPMM_FCONF \
  1260. ENABLE_FEAT_FGT \
  1261. ENABLE_FEAT_FGT2 \
  1262. ENABLE_FEAT_FPMR \
  1263. ENABLE_FEAT_ECV \
  1264. ENABLE_FEAT_AMUv1p1 \
  1265. ENABLE_FEAT_SEL2 \
  1266. ENABLE_FEAT_VHE \
  1267. ENABLE_FEAT_CSV2_2 \
  1268. ENABLE_FEAT_CSV2_3 \
  1269. ENABLE_FEAT_LS64_ACCDATA \
  1270. ENABLE_FEAT_PAN \
  1271. ENABLE_FEAT_TCR2 \
  1272. ENABLE_FEAT_THE \
  1273. ENABLE_FEAT_S2PIE \
  1274. ENABLE_FEAT_S1PIE \
  1275. ENABLE_FEAT_S2POE \
  1276. ENABLE_FEAT_S1POE \
  1277. ENABLE_FEAT_SCTLR2 \
  1278. ENABLE_FEAT_D128 \
  1279. ENABLE_FEAT_GCS \
  1280. ENABLE_FEAT_MTE2 \
  1281. FEATURE_DETECTION \
  1282. TWED_DELAY \
  1283. ENABLE_FEAT_TWED \
  1284. CONDITIONAL_CMO \
  1285. IMPDEF_SYSREG_TRAP \
  1286. SVE_VECTOR_LEN \
  1287. ENABLE_SPMD_LP \
  1288. PSA_CRYPTO \
  1289. ENABLE_CONSOLE_GETC \
  1290. INIT_UNUSED_NS_EL2 \
  1291. PLATFORM_REPORT_CTX_MEM_USE \
  1292. EARLY_CONSOLE \
  1293. PRESERVE_DSU_PMU_REGS \
  1294. HOB_LIST \
  1295. )))
  1296. ifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1)
  1297. ifeq (${DEBUG}, 0)
  1298. $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only")
  1299. override PLATFORM_REPORT_CTX_MEM_USE := 0
  1300. endif
  1301. endif
  1302. ifeq (${SANITIZE_UB},trap)
  1303. $(eval $(call add_define,MONITOR_TRAPS))
  1304. endif #(SANITIZE_UB)
  1305. # Define the EL3_PAYLOAD_BASE flag only if it is provided.
  1306. ifdef EL3_PAYLOAD_BASE
  1307. $(eval $(call add_define,EL3_PAYLOAD_BASE))
  1308. else
  1309. # Define the PRELOADED_BL33_BASE flag only if it is provided and
  1310. # EL3_PAYLOAD_BASE is not defined, as it has priority.
  1311. ifdef PRELOADED_BL33_BASE
  1312. $(eval $(call add_define,PRELOADED_BL33_BASE))
  1313. endif
  1314. endif #(EL3_PAYLOAD_BASE)
  1315. # Define the DYN_DISABLE_AUTH flag only if set.
  1316. ifeq (${DYN_DISABLE_AUTH},1)
  1317. $(eval $(call add_define,DYN_DISABLE_AUTH))
  1318. endif
  1319. ifeq ($($(ARCH)-ld-id),arm-link)
  1320. $(eval $(call add_define,USE_ARM_LINK))
  1321. endif
  1322. # Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
  1323. ifeq (${SPD},spmd)
  1324. ifdef SP_LAYOUT_FILE
  1325. -include $(BUILD_PLAT)/sp_gen.mk
  1326. FIP_DEPS += sp
  1327. CRT_DEPS += sp
  1328. NEED_SP_PKG := yes
  1329. else
  1330. ifeq (${SPMD_SPM_AT_SEL2},1)
  1331. $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
  1332. endif
  1333. endif #(SP_LAYOUT_FILE)
  1334. endif #(SPD)
  1335. ################################################################################
  1336. # Build targets
  1337. ################################################################################
  1338. .PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp tl fwu_fip certtool dtbs memmap doc enctool
  1339. all: msg_start
  1340. msg_start:
  1341. $(s)echo "Building ${PLAT}"
  1342. ifeq (${ERROR_DEPRECATED},0)
  1343. # Check if deprecated declarations and cpp warnings should be treated as error or not.
  1344. ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
  1345. CPPFLAGS += -Wno-error=deprecated-declarations
  1346. else
  1347. CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp
  1348. endif
  1349. endif #(!ERROR_DEPRECATED)
  1350. $(eval $(call MAKE_LIB,c))
  1351. # Expand build macros for the different images
  1352. ifeq (${NEED_BL1},yes)
  1353. BL1_SOURCES := $(sort ${BL1_SOURCES})
  1354. $(eval $(call MAKE_BL,bl1))
  1355. endif #(NEED_BL1)
  1356. ifeq (${NEED_BL2},yes)
  1357. ifeq (${RESET_TO_BL2}, 0)
  1358. FIP_BL2_ARGS := tb-fw
  1359. endif
  1360. BL2_SOURCES := $(sort ${BL2_SOURCES})
  1361. $(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
  1362. $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
  1363. endif #(NEED_BL2)
  1364. ifeq (${NEED_SCP_BL2},yes)
  1365. $(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
  1366. endif #(NEED_SCP_BL2)
  1367. ifeq (${NEED_BL31},yes)
  1368. BL31_SOURCES += ${SPD_SOURCES}
  1369. # Sort BL31 source files to remove duplicates
  1370. BL31_SOURCES := $(sort ${BL31_SOURCES})
  1371. ifneq (${DECRYPTION_SUPPORT},none)
  1372. $(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
  1373. $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
  1374. else
  1375. $(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
  1376. $(eval $(call MAKE_BL,bl31,soc-fw)))
  1377. endif #(DECRYPTION_SUPPORT)
  1378. endif #(NEED_BL31)
  1379. # If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
  1380. # build system will call TOOL_ADD_IMG to print a warning message and abort the
  1381. # process. Note that the dependency on BL32 applies to the FIP only.
  1382. ifeq (${NEED_BL32},yes)
  1383. # Sort BL32 source files to remove duplicates
  1384. BL32_SOURCES := $(sort ${BL32_SOURCES})
  1385. BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
  1386. ifneq (${DECRYPTION_SUPPORT},none)
  1387. $(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
  1388. $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
  1389. else
  1390. $(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
  1391. $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
  1392. endif #(DECRYPTION_SUPPORT)
  1393. endif #(NEED_BL32)
  1394. # If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
  1395. # needs to be built from RMM_SOURCES.
  1396. ifeq (${NEED_RMM},yes)
  1397. # Sort RMM source files to remove duplicates
  1398. RMM_SOURCES := $(sort ${RMM_SOURCES})
  1399. BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
  1400. $(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
  1401. $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
  1402. endif #(NEED_RMM)
  1403. # Add the BL33 image if required by the platform
  1404. ifeq (${NEED_BL33},yes)
  1405. $(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
  1406. endif #(NEED_BL33)
  1407. ifeq (${NEED_BL2U},yes)
  1408. $(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
  1409. $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
  1410. endif #(NEED_BL2U)
  1411. # Expand build macros for the different images
  1412. ifeq (${NEED_FDT},yes)
  1413. $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
  1414. endif #(NEED_FDT)
  1415. # Add Secure Partition packages
  1416. ifeq (${NEED_SP_PKG},yes)
  1417. $(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | $$(@D)/
  1418. $(q)${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
  1419. sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
  1420. $(s)echo
  1421. $(s)echo "Built SP Images successfully"
  1422. $(s)echo
  1423. endif #(NEED_SP_PKG)
  1424. locate-checkpatch:
  1425. ifndef CHECKPATCH
  1426. $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
  1427. else
  1428. ifeq (,$(wildcard ${CHECKPATCH}))
  1429. $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
  1430. endif
  1431. endif #(CHECKPATCH)
  1432. clean:
  1433. $(s)echo " CLEAN"
  1434. $(call SHELL_REMOVE_DIR,${BUILD_PLAT})
  1435. ifdef UNIX_MK
  1436. $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
  1437. else
  1438. # Clear the MAKEFLAGS as we do not want
  1439. # to pass the gnumake flags to nmake.
  1440. $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
  1441. endif #(UNIX_MK)
  1442. $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
  1443. $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
  1444. $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
  1445. realclean distclean:
  1446. $(s)echo " REALCLEAN"
  1447. $(call SHELL_REMOVE_DIR,${BUILD_BASE})
  1448. $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
  1449. ifdef UNIX_MK
  1450. $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
  1451. else
  1452. # Clear the MAKEFLAGS as we do not want
  1453. # to pass the gnumake flags to nmake.
  1454. $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean
  1455. endif #(UNIX_MK)
  1456. $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
  1457. $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
  1458. $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
  1459. checkcodebase: locate-checkpatch
  1460. $(s)echo " CHECKING STYLE"
  1461. $(q)if test -d .git ; then \
  1462. git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \
  1463. while read GIT_FILE ; \
  1464. do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
  1465. done ; \
  1466. else \
  1467. find . -type f -not -iwholename "*.git*" \
  1468. -not -iwholename "*build*" \
  1469. -not -iwholename "*libfdt*" \
  1470. -not -iwholename "*libc*" \
  1471. -not -iwholename "*docs*" \
  1472. -not -iwholename "*.rst" \
  1473. -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
  1474. fi
  1475. checkpatch: locate-checkpatch
  1476. $(s)echo " CHECKING STYLE"
  1477. $(q)if test -n "${CHECKPATCH_OPTS}"; then \
  1478. echo " with ${CHECKPATCH_OPTS} option(s)"; \
  1479. fi
  1480. $(q)COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
  1481. for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \
  1482. do \
  1483. printf "\n[*] Checking style of '$$commit'\n\n"; \
  1484. ( git log --format=email "$$commit~..$$commit" \
  1485. -- ${CHECK_PATHS} ; \
  1486. git diff --format=email "$$commit~..$$commit" \
  1487. -- ${CHECK_PATHS}; ) | \
  1488. ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
  1489. done
  1490. certtool: ${CRTTOOL}
  1491. ${CRTTOOL}: FORCE
  1492. $(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
  1493. $(s)echo
  1494. $(s)echo "Built $@ successfully"
  1495. $(s)echo
  1496. ifneq (${GENERATE_COT},0)
  1497. certificates: ${CRT_DEPS} ${CRTTOOL}
  1498. $(q)${CRTTOOL} ${CRT_ARGS}
  1499. $(s)echo
  1500. $(s)echo "Built $@ successfully"
  1501. $(s)echo "Certificates can be found in ${BUILD_PLAT}"
  1502. $(s)echo
  1503. endif #(GENERATE_COT)
  1504. ${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
  1505. $(eval ${CHECK_FIP_CMD})
  1506. $(q)${FIPTOOL} create ${FIP_ARGS} $@
  1507. $(q)${FIPTOOL} info $@
  1508. $(s)echo
  1509. $(s)echo "Built $@ successfully"
  1510. $(s)echo
  1511. ifneq (${GENERATE_COT},0)
  1512. fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
  1513. $(q)${CRTTOOL} ${FWU_CRT_ARGS}
  1514. $(s)echo
  1515. $(s)echo "Built $@ successfully"
  1516. $(s)echo "FWU certificates can be found in ${BUILD_PLAT}"
  1517. $(s)echo
  1518. endif #(GENERATE_COT)
  1519. ${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
  1520. $(eval ${CHECK_FWU_FIP_CMD})
  1521. $(q)${FIPTOOL} create ${FWU_FIP_ARGS} $@
  1522. $(q)${FIPTOOL} info $@
  1523. $(s)echo
  1524. $(s)echo "Built $@ successfully"
  1525. $(s)echo
  1526. fiptool: ${FIPTOOL}
  1527. fip: ${BUILD_PLAT}/${FIP_NAME}
  1528. fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
  1529. ${FIPTOOL}: FORCE
  1530. ifdef UNIX_MK
  1531. $(q)${MAKE} PLAT=${PLAT} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${FIPTOOLPATH} all
  1532. else
  1533. # Clear the MAKEFLAGS as we do not want
  1534. # to pass the gnumake flags to nmake.
  1535. $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
  1536. endif #(UNIX_MK)
  1537. $(BUILD_PLAT)/romlib/romlib.bin $(BUILD_PLAT)/lib/libwrappers.a $&: $(BUILD_PLAT)/lib/libfdt.a $(BUILD_PLAT)/lib/libc.a $(CRYPTO_LIB)
  1538. $(q)${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} CRYPTO_SUPPORT=${CRYPTO_SUPPORT} ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES=$(call escape-shell,$(INCLUDES)) DEFINES=$(call escape-shell,$(DEFINES)) --no-print-directory -C ${ROMLIBPATH} all
  1539. memmap: all
  1540. ifdef UNIX_MK
  1541. $(q)PYTHONPATH=${CURDIR}/tools/memory \
  1542. ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
  1543. else
  1544. $(q)set PYTHONPATH=${CURDIR}/tools/memory && \
  1545. ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
  1546. endif
  1547. tl: ${BUILD_PLAT}/tl.bin
  1548. ${BUILD_PLAT}/tl.bin: ${HW_CONFIG}
  1549. $(if $(host-poetry),$(q)poetry -q install)
  1550. $(q)$(if $(host-poetry),poetry run )tlc create --fdt $< -s ${FW_HANDOFF_SIZE} $@
  1551. doc:
  1552. $(s)echo " BUILD DOCUMENTATION"
  1553. $(q)${MAKE} --no-print-directory -C ${DOCS_PATH} html
  1554. enctool: ${ENCTOOL}
  1555. ${ENCTOOL}: FORCE
  1556. $(q)${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} --no-print-directory -C ${ENCTOOLPATH} all
  1557. $(s)echo
  1558. $(s)echo "Built $@ successfully"
  1559. $(s)echo
  1560. cscope:
  1561. $(s)echo " CSCOPE"
  1562. $(q)find ${CURDIR} -name "*.[chsS]" > cscope.files
  1563. $(q)cscope -b -q -k
  1564. help:
  1565. $(s)echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
  1566. $(s)echo ""
  1567. $(s)echo "PLAT is used to specify which platform you wish to build."
  1568. $(s)echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
  1569. $(s)echo ""
  1570. $(s)echo "platform = ${PLATFORM_LIST}"
  1571. $(s)echo ""
  1572. $(s)echo "Please refer to the User Guide for a list of all supported options."
  1573. $(s)echo "Note that the build system doesn't track dependencies for build "
  1574. $(s)echo "options. Therefore, if any of the build options are changed "
  1575. $(s)echo "from a previous build, a clean build must be performed."
  1576. $(s)echo ""
  1577. $(s)echo "Supported Targets:"
  1578. $(s)echo " all Build all individual bootloader binaries"
  1579. $(s)echo " bl1 Build the BL1 binary"
  1580. $(s)echo " bl2 Build the BL2 binary"
  1581. $(s)echo " bl2u Build the BL2U binary"
  1582. $(s)echo " bl31 Build the BL31 binary"
  1583. $(s)echo " bl32 Build the BL32 binary. If ARCH=aarch32, then "
  1584. $(s)echo " this builds secure payload specified by AARCH32_SP"
  1585. $(s)echo " certificates Build the certificates (requires 'GENERATE_COT=1')"
  1586. $(s)echo " fip Build the Firmware Image Package (FIP)"
  1587. $(s)echo " fwu_fip Build the FWU Firmware Image Package (FIP)"
  1588. $(s)echo " checkcodebase Check the coding style of the entire source tree"
  1589. $(s)echo " checkpatch Check the coding style on changes in the current"
  1590. $(s)echo " branch against BASE_COMMIT (default origin/master)"
  1591. $(s)echo " clean Clean the build for the selected platform"
  1592. $(s)echo " cscope Generate cscope index"
  1593. $(s)echo " distclean Remove all build artifacts for all platforms"
  1594. $(s)echo " certtool Build the Certificate generation tool"
  1595. $(s)echo " enctool Build the Firmware encryption tool"
  1596. $(s)echo " fiptool Build the Firmware Image Package (FIP) creation tool"
  1597. $(s)echo " sp Build the Secure Partition Packages"
  1598. $(s)echo " sptool Build the Secure Partition Package creation tool"
  1599. $(s)echo " dtbs Build the Device Tree Blobs (if required for the platform)"
  1600. $(s)echo " memmap Print the memory map of the built binaries"
  1601. $(s)echo " doc Build html based documentation using Sphinx tool"
  1602. $(s)echo ""
  1603. $(s)echo "Note: most build targets require PLAT to be set to a specific platform."
  1604. $(s)echo ""
  1605. $(s)echo "example: build all targets for the FVP platform:"
  1606. $(s)echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
  1607. .PHONY: FORCE
  1608. FORCE:;