Makefile 54 KB

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