Makefile 54 KB

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