Makefile 53 KB

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