Makefile 53 KB

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