Makefile 53 KB

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