Makefile 50 KB

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