Makefile 54 KB

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