Makefile 55 KB

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