Makefile 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818
  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-builtin -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. # SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
  753. ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
  754. $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
  755. endif
  756. # If pointer authentication is used in the firmware, make sure that all the
  757. # registers associated to it are also saved and restored.
  758. # Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
  759. ifeq ($(ENABLE_PAUTH),1)
  760. ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
  761. $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
  762. endif
  763. endif #(ENABLE_PAUTH)
  764. ifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
  765. ifneq (${ARCH},aarch64)
  766. $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
  767. endif
  768. endif #(CTX_INCLUDE_PAUTH_REGS)
  769. ifeq ($(FEATURE_DETECTION),1)
  770. $(info FEATURE_DETECTION is an experimental feature)
  771. endif #(FEATURE_DETECTION)
  772. ifneq ($(ENABLE_SME2_FOR_NS), 0)
  773. ifeq (${ENABLE_SME_FOR_NS}, 0)
  774. $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \
  775. to be set")
  776. $(warning "Forced ENABLE_SME_FOR_NS=1")
  777. override ENABLE_SME_FOR_NS := 1
  778. endif
  779. endif #(ENABLE_SME2_FOR_NS)
  780. ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
  781. ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
  782. $(error "ALLOW_RO_XLAT_TABLES requires translation tables \
  783. library v2")
  784. endif
  785. endif #(ARM_XLAT_TABLES_LIB_V1)
  786. ifneq (${DECRYPTION_SUPPORT},none)
  787. ifeq (${TRUSTED_BOARD_BOOT}, 0)
  788. $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \
  789. to be set)
  790. endif
  791. endif #(DECRYPTION_SUPPORT)
  792. # Ensure that no Aarch64-only features are enabled in Aarch32 build
  793. ifeq (${ARCH},aarch32)
  794. # SME/SVE only supported on AArch64
  795. ifneq (${ENABLE_SME_FOR_NS},0)
  796. $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
  797. endif
  798. ifeq (${ENABLE_SVE_FOR_NS},1)
  799. # Warning instead of error due to CI dependency on this
  800. $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
  801. endif
  802. # BRBE is not supported in AArch32
  803. ifeq (${ENABLE_BRBE_FOR_NS},1)
  804. $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
  805. endif
  806. # FEAT_RNG_TRAP is not supported in AArch32
  807. ifeq (${ENABLE_FEAT_RNG_TRAP},1)
  808. $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
  809. endif
  810. endif #(ARCH=aarch32)
  811. ifneq (${ENABLE_SME_FOR_NS},0)
  812. ifeq (${ENABLE_SVE_FOR_NS},0)
  813. $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS")
  814. endif
  815. endif #(ENABLE_SME_FOR_NS)
  816. # Secure SME/SVE requires the non-secure component as well
  817. ifeq (${ENABLE_SME_FOR_SWD},1)
  818. ifeq (${ENABLE_SME_FOR_NS},0)
  819. $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
  820. endif
  821. ifeq (${ENABLE_SVE_FOR_SWD},0)
  822. $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD")
  823. endif
  824. endif #(ENABLE_SME_FOR_SWD)
  825. # Enabling SVE for SWD requires enabling SVE for NWD due to ENABLE_FEAT
  826. # mechanism.
  827. ifeq (${ENABLE_SVE_FOR_SWD},1)
  828. ifeq (${ENABLE_SVE_FOR_NS},0)
  829. $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
  830. endif
  831. endif
  832. # Enabling SVE for both the worlds typically requires the context
  833. # management of SVE registers. The only exception being SPMC at S-EL2.
  834. ifeq (${ENABLE_SVE_FOR_SWD}, 1)
  835. ifneq (${ENABLE_SVE_FOR_NS}, 0)
  836. ifeq (${CTX_INCLUDE_SVE_REGS}-$(SPMD_SPM_AT_SEL2),0-0)
  837. $(warning "ENABLE_SVE_FOR_SWD and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
  838. endif
  839. endif
  840. endif
  841. # Enabling SVE in either world while enabling CTX_INCLUDE_FPREGS requires
  842. # CTX_INCLUDE_SVE_REGS to be enabled due to architectural dependency between FP
  843. # and SVE registers.
  844. ifeq (${CTX_INCLUDE_FPREGS}, 1)
  845. ifneq (${ENABLE_SVE_FOR_NS},0)
  846. ifeq (${CTX_INCLUDE_SVE_REGS},0)
  847. # Warning instead of error due to CI dependency on this
  848. $(warning "CTX_INCLUDE_FPREGS and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
  849. $(warning "Forced ENABLE_SVE_FOR_NS=0")
  850. override ENABLE_SVE_FOR_NS := 0
  851. endif
  852. endif
  853. endif #(CTX_INCLUDE_FPREGS)
  854. # SVE context management is only required if secure world has access to SVE/FP
  855. # functionality.
  856. ifeq (${CTX_INCLUDE_SVE_REGS},1)
  857. ifeq (${ENABLE_SVE_FOR_SWD},0)
  858. $(error "CTX_INCLUDE_SVE_REGS requires ENABLE_SVE_FOR_SWD to also be enabled")
  859. endif
  860. endif
  861. # SME cannot be used with CTX_INCLUDE_FPREGS since SPM does its own context
  862. # management including FPU registers.
  863. ifeq (${CTX_INCLUDE_FPREGS},1)
  864. ifneq (${ENABLE_SME_FOR_NS},0)
  865. $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
  866. endif
  867. endif #(CTX_INCLUDE_FPREGS)
  868. ifeq ($(DRTM_SUPPORT),1)
  869. $(info DRTM_SUPPORT is an experimental feature)
  870. endif
  871. ifeq (${TRANSFER_LIST},1)
  872. $(info TRANSFER_LIST is an experimental feature)
  873. endif
  874. ifeq (${ENABLE_RME},1)
  875. ifneq (${SEPARATE_CODE_AND_RODATA},1)
  876. $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
  877. endif
  878. endif
  879. ifeq ($(PSA_CRYPTO),1)
  880. $(info PSA_CRYPTO is an experimental feature)
  881. endif
  882. ifeq ($(DICE_PROTECTION_ENVIRONMENT),1)
  883. $(info DICE_PROTECTION_ENVIRONMENT is an experimental feature)
  884. endif
  885. ################################################################################
  886. # Process platform overrideable behaviour
  887. ################################################################################
  888. ifdef BL1_SOURCES
  889. NEED_BL1 := yes
  890. endif #(BL1_SOURCES)
  891. ifdef BL2_SOURCES
  892. NEED_BL2 := yes
  893. # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
  894. # Certificate generation tools. This flag can be overridden by the platform.
  895. ifdef EL3_PAYLOAD_BASE
  896. # If booting an EL3 payload there is no need for a BL33 image
  897. # in the FIP file.
  898. NEED_BL33 := no
  899. else
  900. ifdef PRELOADED_BL33_BASE
  901. # If booting a BL33 preloaded image there is no need of
  902. # another one in the FIP file.
  903. NEED_BL33 := no
  904. else
  905. NEED_BL33 ?= yes
  906. endif
  907. endif
  908. endif #(BL2_SOURCES)
  909. ifdef BL2U_SOURCES
  910. NEED_BL2U := yes
  911. endif #(BL2U_SOURCES)
  912. # If SCP_BL2 is given, we always want FIP to include it.
  913. ifdef SCP_BL2
  914. NEED_SCP_BL2 := yes
  915. endif #(SCP_BL2)
  916. # For AArch32, BL31 is not currently supported.
  917. ifneq (${ARCH},aarch32)
  918. ifdef BL31_SOURCES
  919. # When booting an EL3 payload, there is no need to compile the BL31
  920. # image nor put it in the FIP.
  921. ifndef EL3_PAYLOAD_BASE
  922. NEED_BL31 := yes
  923. endif
  924. endif
  925. endif #(ARCH=aarch64)
  926. # Process TBB related flags
  927. ifneq (${GENERATE_COT},0)
  928. # Common cert_create options
  929. ifneq (${CREATE_KEYS},0)
  930. $(eval CRT_ARGS += -n)
  931. $(eval FWU_CRT_ARGS += -n)
  932. ifneq (${SAVE_KEYS},0)
  933. $(eval CRT_ARGS += -k)
  934. $(eval FWU_CRT_ARGS += -k)
  935. endif
  936. endif
  937. # Include TBBR makefile (unless the platform indicates otherwise)
  938. ifeq (${INCLUDE_TBBR_MK},1)
  939. include make_helpers/tbbr/tbbr_tools.mk
  940. endif
  941. endif #(GENERATE_COT)
  942. ifneq (${FIP_ALIGN},0)
  943. FIP_ARGS += --align ${FIP_ALIGN}
  944. endif #(FIP_ALIGN)
  945. ifdef FDT_SOURCES
  946. NEED_FDT := yes
  947. endif #(FDT_SOURCES)
  948. ################################################################################
  949. # Include libraries' Makefile that are used in all BL
  950. ################################################################################
  951. include lib/stack_protector/stack_protector.mk
  952. ################################################################################
  953. # Include BL specific makefiles
  954. ################################################################################
  955. ifeq (${NEED_BL1},yes)
  956. include bl1/bl1.mk
  957. endif
  958. ifeq (${NEED_BL2},yes)
  959. include bl2/bl2.mk
  960. endif
  961. ifeq (${NEED_BL2U},yes)
  962. include bl2u/bl2u.mk
  963. endif
  964. ifeq (${NEED_BL31},yes)
  965. include bl31/bl31.mk
  966. endif
  967. ################################################################################
  968. # Build options checks
  969. ################################################################################
  970. # Boolean_Flags
  971. $(eval $(call assert_booleans,\
  972. $(sort \
  973. ALLOW_RO_XLAT_TABLES \
  974. BL2_ENABLE_SP_LOAD \
  975. COLD_BOOT_SINGLE_CPU \
  976. CREATE_KEYS \
  977. CTX_INCLUDE_AARCH32_REGS \
  978. CTX_INCLUDE_FPREGS \
  979. CTX_INCLUDE_SVE_REGS \
  980. CTX_INCLUDE_EL2_REGS \
  981. CTX_INCLUDE_MPAM_REGS \
  982. DEBUG \
  983. DYN_DISABLE_AUTH \
  984. EL3_EXCEPTION_HANDLING \
  985. ENABLE_AMU_AUXILIARY_COUNTERS \
  986. ENABLE_AMU_FCONF \
  987. AMU_RESTRICT_COUNTERS \
  988. ENABLE_ASSERTIONS \
  989. ENABLE_PIE \
  990. ENABLE_PMF \
  991. ENABLE_PSCI_STAT \
  992. ENABLE_RUNTIME_INSTRUMENTATION \
  993. ENABLE_SME_FOR_SWD \
  994. ENABLE_SVE_FOR_SWD \
  995. ENABLE_FEAT_RAS \
  996. FFH_SUPPORT \
  997. ERROR_DEPRECATED \
  998. FAULT_INJECTION_SUPPORT \
  999. GENERATE_COT \
  1000. GICV2_G0_FOR_EL3 \
  1001. HANDLE_EA_EL3_FIRST_NS \
  1002. HARDEN_SLS \
  1003. HW_ASSISTED_COHERENCY \
  1004. MEASURED_BOOT \
  1005. DICE_PROTECTION_ENVIRONMENT \
  1006. RMMD_ENABLE_EL3_TOKEN_SIGN \
  1007. DRTM_SUPPORT \
  1008. NS_TIMER_SWITCH \
  1009. OVERRIDE_LIBC \
  1010. PL011_GENERIC_UART \
  1011. PROGRAMMABLE_RESET_ADDRESS \
  1012. PSCI_EXTENDED_STATE_ID \
  1013. PSCI_OS_INIT_MODE \
  1014. RESET_TO_BL31 \
  1015. SAVE_KEYS \
  1016. SEPARATE_CODE_AND_RODATA \
  1017. SEPARATE_BL2_NOLOAD_REGION \
  1018. SEPARATE_NOBITS_REGION \
  1019. SEPARATE_RWDATA_REGION \
  1020. SEPARATE_SIMD_SECTION \
  1021. SPIN_ON_BL1_EXIT \
  1022. SPM_MM \
  1023. SPMC_AT_EL3 \
  1024. SPMC_AT_EL3_SEL0_SP \
  1025. SPMD_SPM_AT_SEL2 \
  1026. ENABLE_SPMD_LP \
  1027. TRANSFER_LIST \
  1028. TRUSTED_BOARD_BOOT \
  1029. USE_COHERENT_MEM \
  1030. USE_DEBUGFS \
  1031. ARM_IO_IN_DTB \
  1032. SDEI_IN_FCONF \
  1033. SEC_INT_DESC_IN_FCONF \
  1034. USE_ROMLIB \
  1035. USE_TBBR_DEFS \
  1036. WARMBOOT_ENABLE_DCACHE_EARLY \
  1037. RESET_TO_BL2 \
  1038. BL2_IN_XIP_MEM \
  1039. BL2_INV_DCACHE \
  1040. USE_SPINLOCK_CAS \
  1041. ENCRYPT_BL31 \
  1042. ENCRYPT_BL32 \
  1043. ERRATA_SPECULATIVE_AT \
  1044. RAS_TRAP_NS_ERR_REC_ACCESS \
  1045. COT_DESC_IN_DTB \
  1046. USE_SP804_TIMER \
  1047. PSA_FWU_SUPPORT \
  1048. PSA_FWU_METADATA_FW_STORE_DESC \
  1049. ENABLE_MPMM \
  1050. ENABLE_MPMM_FCONF \
  1051. FEATURE_DETECTION \
  1052. TRNG_SUPPORT \
  1053. ERRATA_ABI_SUPPORT \
  1054. ERRATA_NON_ARM_INTERCONNECT \
  1055. CONDITIONAL_CMO \
  1056. PSA_CRYPTO \
  1057. ENABLE_CONSOLE_GETC \
  1058. INIT_UNUSED_NS_EL2 \
  1059. PLATFORM_REPORT_CTX_MEM_USE \
  1060. EARLY_CONSOLE \
  1061. PRESERVE_DSU_PMU_REGS \
  1062. )))
  1063. # Numeric_Flags
  1064. $(eval $(call assert_numerics,\
  1065. $(sort \
  1066. ARM_ARCH_MAJOR \
  1067. ARM_ARCH_MINOR \
  1068. BRANCH_PROTECTION \
  1069. CTX_INCLUDE_PAUTH_REGS \
  1070. CTX_INCLUDE_NEVE_REGS \
  1071. CRYPTO_SUPPORT \
  1072. DISABLE_MTPMU \
  1073. ENABLE_BRBE_FOR_NS \
  1074. ENABLE_TRBE_FOR_NS \
  1075. ENABLE_BTI \
  1076. ENABLE_PAUTH \
  1077. ENABLE_FEAT_AMU \
  1078. ENABLE_FEAT_AMUv1p1 \
  1079. ENABLE_FEAT_CSV2_2 \
  1080. ENABLE_FEAT_CSV2_3 \
  1081. ENABLE_FEAT_DEBUGV8P9 \
  1082. ENABLE_FEAT_DIT \
  1083. ENABLE_FEAT_ECV \
  1084. ENABLE_FEAT_FGT \
  1085. ENABLE_FEAT_FGT2 \
  1086. ENABLE_FEAT_HCX \
  1087. ENABLE_FEAT_LS64_ACCDATA \
  1088. ENABLE_FEAT_MTE2 \
  1089. ENABLE_FEAT_PAN \
  1090. ENABLE_FEAT_RNG \
  1091. ENABLE_FEAT_RNG_TRAP \
  1092. ENABLE_FEAT_SEL2 \
  1093. ENABLE_FEAT_TCR2 \
  1094. ENABLE_FEAT_THE \
  1095. ENABLE_FEAT_SB \
  1096. ENABLE_FEAT_S2PIE \
  1097. ENABLE_FEAT_S1PIE \
  1098. ENABLE_FEAT_S2POE \
  1099. ENABLE_FEAT_S1POE \
  1100. ENABLE_FEAT_SCTLR2 \
  1101. ENABLE_FEAT_D128 \
  1102. ENABLE_FEAT_GCS \
  1103. ENABLE_FEAT_VHE \
  1104. ENABLE_FEAT_MPAM \
  1105. ENABLE_RME \
  1106. ENABLE_SPE_FOR_NS \
  1107. ENABLE_SYS_REG_TRACE_FOR_NS \
  1108. ENABLE_SME_FOR_NS \
  1109. ENABLE_SME2_FOR_NS \
  1110. ENABLE_SVE_FOR_NS \
  1111. ENABLE_TRF_FOR_NS \
  1112. FW_ENC_STATUS \
  1113. NR_OF_FW_BANKS \
  1114. NR_OF_IMAGES_IN_FW_BANK \
  1115. TWED_DELAY \
  1116. ENABLE_FEAT_TWED \
  1117. SVE_VECTOR_LEN \
  1118. IMPDEF_SYSREG_TRAP \
  1119. )))
  1120. ifdef KEY_SIZE
  1121. $(eval $(call assert_numeric,KEY_SIZE))
  1122. endif
  1123. ifeq ($(filter $(SANITIZE_UB), on off trap),)
  1124. $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
  1125. endif
  1126. ################################################################################
  1127. # Add definitions to the cpp preprocessor based on the current build options.
  1128. # This is done after including the platform specific makefile to allow the
  1129. # platform to overwrite the default options
  1130. ################################################################################
  1131. $(eval $(call add_defines,\
  1132. $(sort \
  1133. ALLOW_RO_XLAT_TABLES \
  1134. ARM_ARCH_MAJOR \
  1135. ARM_ARCH_MINOR \
  1136. BL2_ENABLE_SP_LOAD \
  1137. COLD_BOOT_SINGLE_CPU \
  1138. CTX_INCLUDE_AARCH32_REGS \
  1139. CTX_INCLUDE_FPREGS \
  1140. CTX_INCLUDE_SVE_REGS \
  1141. CTX_INCLUDE_PAUTH_REGS \
  1142. CTX_INCLUDE_MPAM_REGS \
  1143. EL3_EXCEPTION_HANDLING \
  1144. CTX_INCLUDE_EL2_REGS \
  1145. CTX_INCLUDE_NEVE_REGS \
  1146. DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
  1147. DISABLE_MTPMU \
  1148. ENABLE_FEAT_AMU \
  1149. ENABLE_AMU_AUXILIARY_COUNTERS \
  1150. ENABLE_AMU_FCONF \
  1151. AMU_RESTRICT_COUNTERS \
  1152. ENABLE_ASSERTIONS \
  1153. ENABLE_BTI \
  1154. ENABLE_FEAT_DEBUGV8P9 \
  1155. ENABLE_FEAT_MPAM \
  1156. ENABLE_PAUTH \
  1157. ENABLE_PIE \
  1158. ENABLE_PMF \
  1159. ENABLE_PSCI_STAT \
  1160. ENABLE_RME \
  1161. RMMD_ENABLE_EL3_TOKEN_SIGN \
  1162. ENABLE_RUNTIME_INSTRUMENTATION \
  1163. ENABLE_SME_FOR_NS \
  1164. ENABLE_SME2_FOR_NS \
  1165. ENABLE_SME_FOR_SWD \
  1166. ENABLE_SPE_FOR_NS \
  1167. ENABLE_SVE_FOR_NS \
  1168. ENABLE_SVE_FOR_SWD \
  1169. ENABLE_FEAT_RAS \
  1170. FFH_SUPPORT \
  1171. ENCRYPT_BL31 \
  1172. ENCRYPT_BL32 \
  1173. ERROR_DEPRECATED \
  1174. FAULT_INJECTION_SUPPORT \
  1175. GICV2_G0_FOR_EL3 \
  1176. HANDLE_EA_EL3_FIRST_NS \
  1177. HW_ASSISTED_COHERENCY \
  1178. LOG_LEVEL \
  1179. MEASURED_BOOT \
  1180. DICE_PROTECTION_ENVIRONMENT \
  1181. DRTM_SUPPORT \
  1182. NS_TIMER_SWITCH \
  1183. PL011_GENERIC_UART \
  1184. PLAT_${PLAT} \
  1185. PROGRAMMABLE_RESET_ADDRESS \
  1186. PSCI_EXTENDED_STATE_ID \
  1187. PSCI_OS_INIT_MODE \
  1188. RESET_TO_BL31 \
  1189. RME_GPT_BITLOCK_BLOCK \
  1190. RME_GPT_MAX_BLOCK \
  1191. SEPARATE_CODE_AND_RODATA \
  1192. SEPARATE_BL2_NOLOAD_REGION \
  1193. SEPARATE_NOBITS_REGION \
  1194. SEPARATE_RWDATA_REGION \
  1195. SEPARATE_SIMD_SECTION \
  1196. RECLAIM_INIT_CODE \
  1197. SPD_${SPD} \
  1198. SPIN_ON_BL1_EXIT \
  1199. SPM_MM \
  1200. SPMC_AT_EL3 \
  1201. SPMC_AT_EL3_SEL0_SP \
  1202. SPMD_SPM_AT_SEL2 \
  1203. TRANSFER_LIST \
  1204. TRUSTED_BOARD_BOOT \
  1205. CRYPTO_SUPPORT \
  1206. TRNG_SUPPORT \
  1207. ERRATA_ABI_SUPPORT \
  1208. ERRATA_NON_ARM_INTERCONNECT \
  1209. USE_COHERENT_MEM \
  1210. USE_DEBUGFS \
  1211. ARM_IO_IN_DTB \
  1212. SDEI_IN_FCONF \
  1213. SEC_INT_DESC_IN_FCONF \
  1214. USE_ROMLIB \
  1215. USE_TBBR_DEFS \
  1216. WARMBOOT_ENABLE_DCACHE_EARLY \
  1217. RESET_TO_BL2 \
  1218. BL2_RUNS_AT_EL3 \
  1219. BL2_IN_XIP_MEM \
  1220. BL2_INV_DCACHE \
  1221. USE_SPINLOCK_CAS \
  1222. ERRATA_SPECULATIVE_AT \
  1223. RAS_TRAP_NS_ERR_REC_ACCESS \
  1224. COT_DESC_IN_DTB \
  1225. USE_SP804_TIMER \
  1226. ENABLE_FEAT_RNG \
  1227. ENABLE_FEAT_RNG_TRAP \
  1228. ENABLE_FEAT_SB \
  1229. ENABLE_FEAT_DIT \
  1230. NR_OF_FW_BANKS \
  1231. NR_OF_IMAGES_IN_FW_BANK \
  1232. PSA_FWU_SUPPORT \
  1233. PSA_FWU_METADATA_FW_STORE_DESC \
  1234. ENABLE_BRBE_FOR_NS \
  1235. ENABLE_TRBE_FOR_NS \
  1236. ENABLE_SYS_REG_TRACE_FOR_NS \
  1237. ENABLE_TRF_FOR_NS \
  1238. ENABLE_FEAT_HCX \
  1239. ENABLE_MPMM \
  1240. ENABLE_MPMM_FCONF \
  1241. ENABLE_FEAT_FGT \
  1242. ENABLE_FEAT_FGT2 \
  1243. ENABLE_FEAT_ECV \
  1244. ENABLE_FEAT_AMUv1p1 \
  1245. ENABLE_FEAT_SEL2 \
  1246. ENABLE_FEAT_VHE \
  1247. ENABLE_FEAT_CSV2_2 \
  1248. ENABLE_FEAT_CSV2_3 \
  1249. ENABLE_FEAT_LS64_ACCDATA \
  1250. ENABLE_FEAT_PAN \
  1251. ENABLE_FEAT_TCR2 \
  1252. ENABLE_FEAT_THE \
  1253. ENABLE_FEAT_S2PIE \
  1254. ENABLE_FEAT_S1PIE \
  1255. ENABLE_FEAT_S2POE \
  1256. ENABLE_FEAT_S1POE \
  1257. ENABLE_FEAT_SCTLR2 \
  1258. ENABLE_FEAT_D128 \
  1259. ENABLE_FEAT_GCS \
  1260. ENABLE_FEAT_MTE2 \
  1261. FEATURE_DETECTION \
  1262. TWED_DELAY \
  1263. ENABLE_FEAT_TWED \
  1264. CONDITIONAL_CMO \
  1265. IMPDEF_SYSREG_TRAP \
  1266. SVE_VECTOR_LEN \
  1267. ENABLE_SPMD_LP \
  1268. PSA_CRYPTO \
  1269. ENABLE_CONSOLE_GETC \
  1270. INIT_UNUSED_NS_EL2 \
  1271. PLATFORM_REPORT_CTX_MEM_USE \
  1272. EARLY_CONSOLE \
  1273. PRESERVE_DSU_PMU_REGS \
  1274. )))
  1275. ifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1)
  1276. ifeq (${DEBUG}, 0)
  1277. $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only")
  1278. override PLATFORM_REPORT_CTX_MEM_USE := 0
  1279. endif
  1280. endif
  1281. ifeq (${SANITIZE_UB},trap)
  1282. $(eval $(call add_define,MONITOR_TRAPS))
  1283. endif #(SANITIZE_UB)
  1284. # Define the EL3_PAYLOAD_BASE flag only if it is provided.
  1285. ifdef EL3_PAYLOAD_BASE
  1286. $(eval $(call add_define,EL3_PAYLOAD_BASE))
  1287. else
  1288. # Define the PRELOADED_BL33_BASE flag only if it is provided and
  1289. # EL3_PAYLOAD_BASE is not defined, as it has priority.
  1290. ifdef PRELOADED_BL33_BASE
  1291. $(eval $(call add_define,PRELOADED_BL33_BASE))
  1292. endif
  1293. endif #(EL3_PAYLOAD_BASE)
  1294. # Define the DYN_DISABLE_AUTH flag only if set.
  1295. ifeq (${DYN_DISABLE_AUTH},1)
  1296. $(eval $(call add_define,DYN_DISABLE_AUTH))
  1297. endif
  1298. ifeq ($($(ARCH)-ld-id),arm-link)
  1299. $(eval $(call add_define,USE_ARM_LINK))
  1300. endif
  1301. # Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
  1302. ifeq (${SPD},spmd)
  1303. ifdef SP_LAYOUT_FILE
  1304. -include $(BUILD_PLAT)/sp_gen.mk
  1305. FIP_DEPS += sp
  1306. CRT_DEPS += sp
  1307. NEED_SP_PKG := yes
  1308. else
  1309. ifeq (${SPMD_SPM_AT_SEL2},1)
  1310. $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
  1311. endif
  1312. endif #(SP_LAYOUT_FILE)
  1313. endif #(SPD)
  1314. ################################################################################
  1315. # Build targets
  1316. ################################################################################
  1317. .PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp tl fwu_fip certtool dtbs memmap doc enctool
  1318. .SUFFIXES:
  1319. all: msg_start
  1320. msg_start:
  1321. $(s)echo "Building ${PLAT}"
  1322. ifeq (${ERROR_DEPRECATED},0)
  1323. # Check if deprecated declarations and cpp warnings should be treated as error or not.
  1324. ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
  1325. CPPFLAGS += -Wno-error=deprecated-declarations
  1326. else
  1327. CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp
  1328. endif
  1329. endif #(!ERROR_DEPRECATED)
  1330. $(eval $(call MAKE_LIB,c))
  1331. # Expand build macros for the different images
  1332. ifeq (${NEED_BL1},yes)
  1333. BL1_SOURCES := $(sort ${BL1_SOURCES})
  1334. $(eval $(call MAKE_BL,bl1))
  1335. endif #(NEED_BL1)
  1336. ifeq (${NEED_BL2},yes)
  1337. ifeq (${RESET_TO_BL2}, 0)
  1338. FIP_BL2_ARGS := tb-fw
  1339. endif
  1340. BL2_SOURCES := $(sort ${BL2_SOURCES})
  1341. $(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
  1342. $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
  1343. endif #(NEED_BL2)
  1344. ifeq (${NEED_SCP_BL2},yes)
  1345. $(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
  1346. endif #(NEED_SCP_BL2)
  1347. ifeq (${NEED_BL31},yes)
  1348. BL31_SOURCES += ${SPD_SOURCES}
  1349. # Sort BL31 source files to remove duplicates
  1350. BL31_SOURCES := $(sort ${BL31_SOURCES})
  1351. ifneq (${DECRYPTION_SUPPORT},none)
  1352. $(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
  1353. $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
  1354. else
  1355. $(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
  1356. $(eval $(call MAKE_BL,bl31,soc-fw)))
  1357. endif #(DECRYPTION_SUPPORT)
  1358. endif #(NEED_BL31)
  1359. # If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
  1360. # build system will call TOOL_ADD_IMG to print a warning message and abort the
  1361. # process. Note that the dependency on BL32 applies to the FIP only.
  1362. ifeq (${NEED_BL32},yes)
  1363. # Sort BL32 source files to remove duplicates
  1364. BL32_SOURCES := $(sort ${BL32_SOURCES})
  1365. BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
  1366. ifneq (${DECRYPTION_SUPPORT},none)
  1367. $(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
  1368. $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
  1369. else
  1370. $(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
  1371. $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
  1372. endif #(DECRYPTION_SUPPORT)
  1373. endif #(NEED_BL32)
  1374. # If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
  1375. # needs to be built from RMM_SOURCES.
  1376. ifeq (${NEED_RMM},yes)
  1377. # Sort RMM source files to remove duplicates
  1378. RMM_SOURCES := $(sort ${RMM_SOURCES})
  1379. BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
  1380. $(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
  1381. $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
  1382. endif #(NEED_RMM)
  1383. # Add the BL33 image if required by the platform
  1384. ifeq (${NEED_BL33},yes)
  1385. $(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
  1386. endif #(NEED_BL33)
  1387. ifeq (${NEED_BL2U},yes)
  1388. $(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
  1389. $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
  1390. endif #(NEED_BL2U)
  1391. # Expand build macros for the different images
  1392. ifeq (${NEED_FDT},yes)
  1393. $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
  1394. endif #(NEED_FDT)
  1395. # Add Secure Partition packages
  1396. ifeq (${NEED_SP_PKG},yes)
  1397. $(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | $$(@D)/
  1398. $(q)${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
  1399. sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
  1400. $(s)echo
  1401. $(s)echo "Built SP Images successfully"
  1402. $(s)echo
  1403. endif #(NEED_SP_PKG)
  1404. locate-checkpatch:
  1405. ifndef CHECKPATCH
  1406. $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
  1407. else
  1408. ifeq (,$(wildcard ${CHECKPATCH}))
  1409. $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
  1410. endif
  1411. endif #(CHECKPATCH)
  1412. clean:
  1413. $(s)echo " CLEAN"
  1414. $(call SHELL_REMOVE_DIR,${BUILD_PLAT})
  1415. ifdef UNIX_MK
  1416. $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
  1417. else
  1418. # Clear the MAKEFLAGS as we do not want
  1419. # to pass the gnumake flags to nmake.
  1420. $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
  1421. endif #(UNIX_MK)
  1422. $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
  1423. $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
  1424. $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
  1425. realclean distclean:
  1426. $(s)echo " REALCLEAN"
  1427. $(call SHELL_REMOVE_DIR,${BUILD_BASE})
  1428. $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
  1429. ifdef UNIX_MK
  1430. $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
  1431. else
  1432. # Clear the MAKEFLAGS as we do not want
  1433. # to pass the gnumake flags to nmake.
  1434. $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean
  1435. endif #(UNIX_MK)
  1436. $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
  1437. $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
  1438. $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
  1439. checkcodebase: locate-checkpatch
  1440. $(s)echo " CHECKING STYLE"
  1441. $(q)if test -d .git ; then \
  1442. git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \
  1443. while read GIT_FILE ; \
  1444. do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
  1445. done ; \
  1446. else \
  1447. find . -type f -not -iwholename "*.git*" \
  1448. -not -iwholename "*build*" \
  1449. -not -iwholename "*libfdt*" \
  1450. -not -iwholename "*libc*" \
  1451. -not -iwholename "*docs*" \
  1452. -not -iwholename "*.rst" \
  1453. -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
  1454. fi
  1455. checkpatch: locate-checkpatch
  1456. $(s)echo " CHECKING STYLE"
  1457. $(q)if test -n "${CHECKPATCH_OPTS}"; then \
  1458. echo " with ${CHECKPATCH_OPTS} option(s)"; \
  1459. fi
  1460. $(q)COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
  1461. for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \
  1462. do \
  1463. printf "\n[*] Checking style of '$$commit'\n\n"; \
  1464. ( git log --format=email "$$commit~..$$commit" \
  1465. -- ${CHECK_PATHS} ; \
  1466. git diff --format=email "$$commit~..$$commit" \
  1467. -- ${CHECK_PATHS}; ) | \
  1468. ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
  1469. done
  1470. certtool: ${CRTTOOL}
  1471. ${CRTTOOL}: FORCE
  1472. $(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
  1473. $(s)echo
  1474. $(s)echo "Built $@ successfully"
  1475. $(s)echo
  1476. ifneq (${GENERATE_COT},0)
  1477. certificates: ${CRT_DEPS} ${CRTTOOL}
  1478. $(q)${CRTTOOL} ${CRT_ARGS}
  1479. $(s)echo
  1480. $(s)echo "Built $@ successfully"
  1481. $(s)echo "Certificates can be found in ${BUILD_PLAT}"
  1482. $(s)echo
  1483. endif #(GENERATE_COT)
  1484. ${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
  1485. $(eval ${CHECK_FIP_CMD})
  1486. $(q)${FIPTOOL} create ${FIP_ARGS} $@
  1487. $(q)${FIPTOOL} info $@
  1488. $(s)echo
  1489. $(s)echo "Built $@ successfully"
  1490. $(s)echo
  1491. ifneq (${GENERATE_COT},0)
  1492. fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
  1493. $(q)${CRTTOOL} ${FWU_CRT_ARGS}
  1494. $(s)echo
  1495. $(s)echo "Built $@ successfully"
  1496. $(s)echo "FWU certificates can be found in ${BUILD_PLAT}"
  1497. $(s)echo
  1498. endif #(GENERATE_COT)
  1499. ${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
  1500. $(eval ${CHECK_FWU_FIP_CMD})
  1501. $(q)${FIPTOOL} create ${FWU_FIP_ARGS} $@
  1502. $(q)${FIPTOOL} info $@
  1503. $(s)echo
  1504. $(s)echo "Built $@ successfully"
  1505. $(s)echo
  1506. fiptool: ${FIPTOOL}
  1507. fip: ${BUILD_PLAT}/${FIP_NAME}
  1508. fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
  1509. ${FIPTOOL}: FORCE
  1510. ifdef UNIX_MK
  1511. $(q)${MAKE} PLAT=${PLAT} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${FIPTOOLPATH} all
  1512. else
  1513. # Clear the MAKEFLAGS as we do not want
  1514. # to pass the gnumake flags to nmake.
  1515. $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
  1516. endif #(UNIX_MK)
  1517. romlib.bin: libraries FORCE
  1518. $(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
  1519. memmap: all
  1520. ifdef UNIX_MK
  1521. $(q)PYTHONPATH=${CURDIR}/tools/memory \
  1522. ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
  1523. else
  1524. $(q)set PYTHONPATH=${CURDIR}/tools/memory && \
  1525. ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
  1526. endif
  1527. tl: ${BUILD_PLAT}/tl.bin
  1528. ${BUILD_PLAT}/tl.bin: ${HW_CONFIG}
  1529. $(if $(host-poetry),$(q)poetry -q install)
  1530. $(q)$(if $(host-poetry),poetry run )tlc create --fdt $< -s ${FW_HANDOFF_SIZE} $@
  1531. doc:
  1532. $(s)echo " BUILD DOCUMENTATION"
  1533. $(q)${MAKE} --no-print-directory -C ${DOCS_PATH} html
  1534. enctool: ${ENCTOOL}
  1535. ${ENCTOOL}: FORCE
  1536. $(q)${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} --no-print-directory -C ${ENCTOOLPATH} all
  1537. $(s)echo
  1538. $(s)echo "Built $@ successfully"
  1539. $(s)echo
  1540. cscope:
  1541. $(s)echo " CSCOPE"
  1542. $(q)find ${CURDIR} -name "*.[chsS]" > cscope.files
  1543. $(q)cscope -b -q -k
  1544. help:
  1545. $(s)echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
  1546. $(s)echo ""
  1547. $(s)echo "PLAT is used to specify which platform you wish to build."
  1548. $(s)echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
  1549. $(s)echo ""
  1550. $(s)echo "platform = ${PLATFORM_LIST}"
  1551. $(s)echo ""
  1552. $(s)echo "Please refer to the User Guide for a list of all supported options."
  1553. $(s)echo "Note that the build system doesn't track dependencies for build "
  1554. $(s)echo "options. Therefore, if any of the build options are changed "
  1555. $(s)echo "from a previous build, a clean build must be performed."
  1556. $(s)echo ""
  1557. $(s)echo "Supported Targets:"
  1558. $(s)echo " all Build all individual bootloader binaries"
  1559. $(s)echo " bl1 Build the BL1 binary"
  1560. $(s)echo " bl2 Build the BL2 binary"
  1561. $(s)echo " bl2u Build the BL2U binary"
  1562. $(s)echo " bl31 Build the BL31 binary"
  1563. $(s)echo " bl32 Build the BL32 binary. If ARCH=aarch32, then "
  1564. $(s)echo " this builds secure payload specified by AARCH32_SP"
  1565. $(s)echo " certificates Build the certificates (requires 'GENERATE_COT=1')"
  1566. $(s)echo " fip Build the Firmware Image Package (FIP)"
  1567. $(s)echo " fwu_fip Build the FWU Firmware Image Package (FIP)"
  1568. $(s)echo " checkcodebase Check the coding style of the entire source tree"
  1569. $(s)echo " checkpatch Check the coding style on changes in the current"
  1570. $(s)echo " branch against BASE_COMMIT (default origin/master)"
  1571. $(s)echo " clean Clean the build for the selected platform"
  1572. $(s)echo " cscope Generate cscope index"
  1573. $(s)echo " distclean Remove all build artifacts for all platforms"
  1574. $(s)echo " certtool Build the Certificate generation tool"
  1575. $(s)echo " enctool Build the Firmware encryption tool"
  1576. $(s)echo " fiptool Build the Firmware Image Package (FIP) creation tool"
  1577. $(s)echo " sp Build the Secure Partition Packages"
  1578. $(s)echo " sptool Build the Secure Partition Package creation tool"
  1579. $(s)echo " dtbs Build the Device Tree Blobs (if required for the platform)"
  1580. $(s)echo " memmap Print the memory map of the built binaries"
  1581. $(s)echo " doc Build html based documentation using Sphinx tool"
  1582. $(s)echo ""
  1583. $(s)echo "Note: most build targets require PLAT to be set to a specific platform."
  1584. $(s)echo ""
  1585. $(s)echo "example: build all targets for the FVP platform:"
  1586. $(s)echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
  1587. .PHONY: FORCE
  1588. FORCE:;