Makefile 55 KB

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