platform.mk 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. #
  2. # Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved.
  3. #
  4. # SPDX-License-Identifier: BSD-3-Clause
  5. #
  6. # Extra partitions used to find FIP, contains:
  7. # metadata (2) and the FIP partitions (default is 2).
  8. STM32_EXTRA_PARTS := 4
  9. include plat/st/common/common.mk
  10. ARM_CORTEX_A7 := yes
  11. ARM_WITH_NEON := yes
  12. USE_COHERENT_MEM := 0
  13. # Default Device tree
  14. DTB_FILE_NAME ?= stm32mp157c-ev1.dtb
  15. STM32MP13 ?= 0
  16. STM32MP15 ?= 0
  17. ifeq ($(STM32MP13),1)
  18. ifeq ($(STM32MP15),1)
  19. $(error Cannot enable both flags STM32MP13 and STM32MP15)
  20. endif
  21. STM32MP13 := 1
  22. STM32MP15 := 0
  23. else ifeq ($(STM32MP15),1)
  24. STM32MP13 := 0
  25. STM32MP15 := 1
  26. else ifneq ($(findstring stm32mp13,$(DTB_FILE_NAME)),)
  27. STM32MP13 := 1
  28. STM32MP15 := 0
  29. else ifneq ($(findstring stm32mp15,$(DTB_FILE_NAME)),)
  30. STM32MP13 := 0
  31. STM32MP15 := 1
  32. endif
  33. ifeq ($(STM32MP13),1)
  34. # Will use SRAM2 as mbedtls heap
  35. STM32MP_USE_EXTERNAL_HEAP := 1
  36. # DDR controller with single AXI port and 16-bit interface
  37. STM32MP_DDR_DUAL_AXI_PORT:= 0
  38. STM32MP_DDR_32BIT_INTERFACE:= 0
  39. ifeq (${TRUSTED_BOARD_BOOT},1)
  40. # PKA algo to include
  41. PKA_USE_NIST_P256 := 1
  42. PKA_USE_BRAINPOOL_P256T1:= 1
  43. endif
  44. # STM32 image header version v2.0
  45. STM32_HEADER_VERSION_MAJOR:= 2
  46. STM32_HEADER_VERSION_MINOR:= 0
  47. endif
  48. ifeq ($(STM32MP15),1)
  49. # DDR controller with dual AXI port and 32-bit interface
  50. STM32MP_DDR_DUAL_AXI_PORT:= 1
  51. STM32MP_DDR_32BIT_INTERFACE:= 1
  52. # STM32 image header version v1.0
  53. STM32_HEADER_VERSION_MAJOR:= 1
  54. STM32_HEADER_VERSION_MINOR:= 0
  55. STM32MP_CRYPTO_ROM_LIB := 1
  56. # Decryption support
  57. ifneq ($(DECRYPTION_SUPPORT),none)
  58. $(error "DECRYPTION_SUPPORT not supported on STM32MP15")
  59. endif
  60. endif
  61. PKA_USE_NIST_P256 ?= 0
  62. PKA_USE_BRAINPOOL_P256T1 ?= 0
  63. ifeq ($(AARCH32_SP),sp_min)
  64. # Disable Neon support: sp_min runtime may conflict with non-secure world
  65. TF_CFLAGS += -mfloat-abi=soft
  66. endif
  67. # Not needed for Cortex-A7
  68. WORKAROUND_CVE_2017_5715:= 0
  69. WORKAROUND_CVE_2022_23960:= 0
  70. ifeq ($(STM32MP13),1)
  71. STM32_HASH_VER := 4
  72. STM32_RNG_VER := 4
  73. else # Assuming STM32MP15
  74. STM32_HASH_VER := 2
  75. STM32_RNG_VER := 2
  76. endif
  77. # Download load address for serial boot devices
  78. DWL_BUFFER_BASE ?= 0xC7000000
  79. # Device tree
  80. ifeq ($(STM32MP13),1)
  81. BL2_DTSI := stm32mp13-bl2.dtsi
  82. FDT_SOURCES := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl2.dts,$(DTB_FILE_NAME)))
  83. else
  84. BL2_DTSI := stm32mp15-bl2.dtsi
  85. FDT_SOURCES := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl2.dts,$(DTB_FILE_NAME)))
  86. ifeq ($(AARCH32_SP),sp_min)
  87. BL32_DTSI := stm32mp15-bl32.dtsi
  88. FDT_SOURCES += $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl32.dts,$(DTB_FILE_NAME)))
  89. endif
  90. endif
  91. # Macros and rules to build TF binary
  92. STM32_TF_STM32 := $(addprefix ${BUILD_PLAT}/tf-a-, $(patsubst %.dtb,%.stm32,$(DTB_FILE_NAME)))
  93. STM32_LD_FILE := plat/st/stm32mp1/stm32mp1.ld.S
  94. STM32_BINARY_MAPPING := plat/st/stm32mp1/stm32mp1.S
  95. ifeq ($(AARCH32_SP),sp_min)
  96. # BL32 is built only if using SP_MIN
  97. BL32_DEP := bl32
  98. ASFLAGS += -DBL32_BIN_PATH=\"${BUILD_PLAT}/bl32.bin\"
  99. endif
  100. STM32MP_FW_CONFIG_NAME := $(patsubst %.dtb,%-fw-config.dtb,$(DTB_FILE_NAME))
  101. STM32MP_FW_CONFIG := ${BUILD_PLAT}/fdts/$(STM32MP_FW_CONFIG_NAME)
  102. ifneq (${AARCH32_SP},none)
  103. FDT_SOURCES += $(addprefix fdts/, $(patsubst %.dtb,%.dts,$(STM32MP_FW_CONFIG_NAME)))
  104. endif
  105. # Add the FW_CONFIG to FIP and specify the same to certtool
  106. $(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_FW_CONFIG},--fw-config))
  107. ifeq ($(GENERATE_COT),1)
  108. STM32MP_CFG_CERT := $(BUILD_PLAT)/stm32mp_cfg_cert.crt
  109. # Add the STM32MP_CFG_CERT to FIP and specify the same to certtool
  110. $(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_CFG_CERT},--stm32mp-cfg-cert))
  111. endif
  112. ifeq ($(AARCH32_SP),sp_min)
  113. STM32MP_TOS_FW_CONFIG := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl32.dtb,$(DTB_FILE_NAME)))
  114. $(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_TOS_FW_CONFIG},--tos-fw-config))
  115. endif
  116. # Enable flags for C files
  117. $(eval $(call assert_booleans,\
  118. $(sort \
  119. PKA_USE_BRAINPOOL_P256T1 \
  120. PKA_USE_NIST_P256 \
  121. STM32MP_CRYPTO_ROM_LIB \
  122. STM32MP_DDR_32BIT_INTERFACE \
  123. STM32MP_DDR_DUAL_AXI_PORT \
  124. STM32MP_USE_EXTERNAL_HEAP \
  125. STM32MP13 \
  126. STM32MP15 \
  127. )))
  128. $(eval $(call assert_numerics,\
  129. $(sort \
  130. PLAT_PARTITION_MAX_ENTRIES \
  131. STM32_HASH_VER \
  132. STM32_HEADER_VERSION_MAJOR \
  133. STM32_RNG_VER \
  134. STM32_TF_A_COPIES \
  135. )))
  136. $(eval $(call add_defines,\
  137. $(sort \
  138. DWL_BUFFER_BASE \
  139. PKA_USE_BRAINPOOL_P256T1 \
  140. PKA_USE_NIST_P256 \
  141. PLAT_PARTITION_MAX_ENTRIES \
  142. PLAT_TBBR_IMG_DEF \
  143. STM32_HASH_VER \
  144. STM32_HEADER_VERSION_MAJOR \
  145. STM32_RNG_VER \
  146. STM32_TF_A_COPIES \
  147. STM32MP_CRYPTO_ROM_LIB \
  148. STM32MP_DDR_32BIT_INTERFACE \
  149. STM32MP_DDR_DUAL_AXI_PORT \
  150. STM32MP_USE_EXTERNAL_HEAP \
  151. STM32MP13 \
  152. STM32MP15 \
  153. )))
  154. # Include paths and source files
  155. PLAT_INCLUDES += -Iplat/st/stm32mp1/include/
  156. PLAT_BL_COMMON_SOURCES += plat/st/stm32mp1/stm32mp1_private.c
  157. PLAT_BL_COMMON_SOURCES += drivers/st/uart/aarch32/stm32_console.S
  158. ifneq (${ENABLE_STACK_PROTECTOR},0)
  159. PLAT_BL_COMMON_SOURCES += plat/st/stm32mp1/stm32mp1_stack_protector.c
  160. endif
  161. PLAT_BL_COMMON_SOURCES += lib/cpus/aarch32/cortex_a7.S
  162. PLAT_BL_COMMON_SOURCES += drivers/arm/tzc/tzc400.c \
  163. drivers/st/bsec/bsec2.c \
  164. drivers/st/ddr/stm32mp1_ddr_helpers.c \
  165. drivers/st/i2c/stm32_i2c.c \
  166. drivers/st/iwdg/stm32_iwdg.c \
  167. drivers/st/pmic/stm32mp_pmic.c \
  168. drivers/st/pmic/stpmic1.c \
  169. drivers/st/reset/stm32mp1_reset.c \
  170. plat/st/stm32mp1/stm32mp1_dbgmcu.c \
  171. plat/st/stm32mp1/stm32mp1_helper.S \
  172. plat/st/stm32mp1/stm32mp1_syscfg.c
  173. ifeq ($(STM32MP13),1)
  174. PLAT_BL_COMMON_SOURCES += drivers/st/clk/clk-stm32-core.c \
  175. drivers/st/clk/clk-stm32mp13.c \
  176. drivers/st/crypto/stm32_rng.c
  177. else
  178. PLAT_BL_COMMON_SOURCES += drivers/st/clk/stm32mp1_clk.c
  179. endif
  180. BL2_SOURCES += plat/st/stm32mp1/plat_bl2_mem_params_desc.c \
  181. plat/st/stm32mp1/stm32mp1_fconf_firewall.c
  182. BL2_SOURCES += drivers/st/crypto/stm32_hash.c \
  183. plat/st/stm32mp1/bl2_plat_setup.c
  184. ifeq (${TRUSTED_BOARD_BOOT},1)
  185. ifeq ($(STM32MP13),1)
  186. BL2_SOURCES += drivers/st/crypto/stm32_pka.c
  187. BL2_SOURCES += drivers/st/crypto/stm32_saes.c
  188. endif
  189. endif
  190. ifneq ($(filter 1,${STM32MP_EMMC} ${STM32MP_SDMMC}),)
  191. BL2_SOURCES += drivers/st/mmc/stm32_sdmmc2.c
  192. endif
  193. ifeq (${STM32MP_RAW_NAND},1)
  194. BL2_SOURCES += drivers/st/fmc/stm32_fmc2_nand.c
  195. endif
  196. ifneq ($(filter 1,${STM32MP_SPI_NAND} ${STM32MP_SPI_NOR}),)
  197. BL2_SOURCES += drivers/st/spi/stm32_qspi.c
  198. endif
  199. ifneq ($(filter 1,${STM32MP_RAW_NAND} ${STM32MP_SPI_NAND} ${STM32MP_SPI_NOR}),)
  200. BL2_SOURCES += plat/st/stm32mp1/stm32mp1_boot_device.c
  201. endif
  202. ifeq (${STM32MP_UART_PROGRAMMER},1)
  203. BL2_SOURCES += drivers/st/uart/stm32_uart.c
  204. endif
  205. ifeq (${STM32MP_USB_PROGRAMMER},1)
  206. #The DFU stack uses only one end point, reduce the USB stack footprint
  207. $(eval $(call add_define_val,CONFIG_USBD_EP_NB,1U))
  208. BL2_SOURCES += drivers/st/usb/stm32mp1_usb.c \
  209. plat/st/stm32mp1/stm32mp1_usb_dfu.c
  210. endif
  211. BL2_SOURCES += drivers/st/ddr/stm32mp1_ddr.c \
  212. drivers/st/ddr/stm32mp1_ram.c
  213. BL2_SOURCES += plat/st/stm32mp1/plat_ddr.c
  214. ifeq ($(AARCH32_SP),sp_min)
  215. # Create DTB file for BL32
  216. ${BUILD_PLAT}/fdts/%-bl32.dts: fdts/%.dts fdts/${BL32_DTSI} | $$(@D)/
  217. $(q)echo '#include "$(patsubst fdts/%,%,$<)"' > $@
  218. $(q)echo '#include "${BL32_DTSI}"' >> $@
  219. ${BUILD_PLAT}/fdts/%-bl32.dtb: ${BUILD_PLAT}/fdts/%-bl32.dts | $$(@D)/
  220. endif
  221. include plat/st/common/common_rules.mk