a3700_common.mk 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. #
  2. # Copyright (C) 2018-2021 Marvell International Ltd.
  3. #
  4. # SPDX-License-Identifier: BSD-3-Clause
  5. # https://spdx.org/licenses
  6. #
  7. MARVELL_PLAT_BASE := plat/marvell/armada
  8. MARVELL_PLAT_INCLUDE_BASE := include/plat/marvell/armada
  9. PLAT_FAMILY := a3k
  10. PLAT_FAMILY_BASE := $(MARVELL_PLAT_BASE)/$(PLAT_FAMILY)
  11. PLAT_INCLUDE_BASE := $(MARVELL_PLAT_INCLUDE_BASE)/$(PLAT_FAMILY)
  12. PLAT_COMMON_BASE := $(PLAT_FAMILY_BASE)/common
  13. MARVELL_DRV_BASE := drivers/marvell
  14. MARVELL_COMMON_BASE := $(MARVELL_PLAT_BASE)/common
  15. ERRATA_A53_1530924 := 1
  16. include plat/marvell/marvell.mk
  17. #*********** A3700 *************
  18. # GICV3
  19. $(eval $(call add_define,CONFIG_GICV3))
  20. # CCI-400
  21. $(eval $(call add_define,USE_CCI))
  22. # Include GICv3 driver files
  23. include drivers/arm/gic/v3/gicv3.mk
  24. MARVELL_GIC_SOURCES := ${GICV3_SOURCES} \
  25. plat/common/plat_gicv3.c
  26. PLAT_INCLUDES := -I$(PLAT_FAMILY_BASE)/$(PLAT) \
  27. -I$(PLAT_COMMON_BASE)/include \
  28. -I$(PLAT_INCLUDE_BASE)/common \
  29. -I$(MARVELL_DRV_BASE) \
  30. -I$/drivers/arm/gic/common/
  31. PLAT_BL_COMMON_SOURCES := $(PLAT_COMMON_BASE)/aarch64/a3700_common.c \
  32. $(PLAT_COMMON_BASE)/aarch64/a3700_clock.S \
  33. $(MARVELL_DRV_BASE)/uart/a3700_console.S
  34. BL1_SOURCES += $(PLAT_COMMON_BASE)/aarch64/plat_helpers.S \
  35. lib/cpus/aarch64/cortex_a53.S
  36. MARVELL_DRV := $(MARVELL_DRV_BASE)/comphy/phy-comphy-3700.c
  37. BL31_SOURCES += lib/cpus/aarch64/cortex_a53.S \
  38. $(PLAT_COMMON_BASE)/aarch64/plat_helpers.S \
  39. $(PLAT_COMMON_BASE)/plat_cci.c \
  40. $(PLAT_COMMON_BASE)/plat_pm.c \
  41. $(PLAT_COMMON_BASE)/dram_win.c \
  42. $(PLAT_COMMON_BASE)/io_addr_dec.c \
  43. $(PLAT_COMMON_BASE)/marvell_plat_config.c \
  44. $(PLAT_FAMILY_BASE)/$(PLAT)/plat_bl31_setup.c \
  45. $(MARVELL_COMMON_BASE)/marvell_cci.c \
  46. $(MARVELL_COMMON_BASE)/marvell_ddr_info.c \
  47. $(MARVELL_COMMON_BASE)/marvell_gicv3.c \
  48. $(MARVELL_GIC_SOURCES) \
  49. drivers/arm/cci/cci.c \
  50. $(PLAT_COMMON_BASE)/a3700_sip_svc.c \
  51. $(MARVELL_DRV)
  52. ifeq ($(HANDLE_EA_EL3_FIRST_NS),1)
  53. BL31_SOURCES += $(PLAT_COMMON_BASE)/a3700_ea.c
  54. endif
  55. ifeq ($(CM3_SYSTEM_RESET),1)
  56. BL31_SOURCES += $(PLAT_COMMON_BASE)/cm3_system_reset.c
  57. endif
  58. ifeq ($(A3720_DB_PM_WAKEUP_SRC),1)
  59. BL31_SOURCES += $(PLAT_FAMILY_BASE)/$(PLAT)/board/pm_src.c
  60. endif
  61. ifdef WTP
  62. # Do not remove! Following checks are required to ensure correct TF-A builds, removing these checks leads to broken TF-A builds
  63. $(if $(wildcard $(value WTP)/*),,$(error "'WTP=$(value WTP)' was specified, but '$(value WTP)' directory does not exist"))
  64. $(if $(shell git -C $(value WTP) rev-parse --show-cdup 2>&1),$(error "'WTP=$(value WTP)' was specified, but '$(value WTP)' does not contain valid A3700-utils-marvell git repository"))
  65. TBB := $(WTP)/wtptp/src/TBB_Linux/release/TBB_linux
  66. BUILD_UART := uart-images
  67. UART_IMAGE := $(BUILD_UART).tgz.bin
  68. ifeq ($(MARVELL_SECURE_BOOT),1)
  69. TIM_CFG := $(BUILD_PLAT)/atf-tim.txt
  70. TIM_UART_CFG := $(BUILD_PLAT)/$(BUILD_UART)/atf-tim.txt
  71. IMAGESPATH := $(WTP)/tim/trusted
  72. TIMN_CFG := $(BUILD_PLAT)/atf-timN.txt
  73. TIMN_UART_CFG := $(BUILD_PLAT)/$(BUILD_UART)/atf-timN.txt
  74. TIMN_SIG := $(IMAGESPATH)/timnsign.txt
  75. TIM2IMGARGS := -i $(TIM_CFG) -n $(TIMN_CFG)
  76. TIMN_UART_IMAGE := $$(grep "Image Filename:" -m 1 $(TIMN_UART_CFG) | cut -c 17-)
  77. else #MARVELL_SECURE_BOOT
  78. TIM_CFG := $(BUILD_PLAT)/atf-ntim.txt
  79. TIM_UART_CFG := $(BUILD_PLAT)/$(BUILD_UART)/atf-ntim.txt
  80. IMAGESPATH := $(WTP)/tim/untrusted
  81. TIM2IMGARGS := -i $(TIM_CFG)
  82. endif #MARVELL_SECURE_BOOT
  83. TIM_UART_IMAGE := $$(grep "Image Filename:" -m 1 $(TIM_UART_CFG) | cut -c 17-)
  84. TIMBUILD := $(WTP)/script/buildtim.sh
  85. TIM2IMG := $(WTP)/script/tim2img.pl
  86. TIMDDRTOOL := $(WTP)/tim/ddr/ddr_tool
  87. $(TIMBUILD): $(TIMDDRTOOL)
  88. # WTMI_IMG is used to specify the customized RTOS image running over
  89. # Service CPU (CM3 processor). By the default, it points to a
  90. # baremetal binary of fuse programming in A3700_utils.
  91. WTMI_IMG := $(WTP)/wtmi/fuse/build/fuse.bin
  92. # WTMI_MULTI_IMG is composed of CM3 RTOS image (WTMI_IMG)
  93. # and sys-init image.
  94. WTMI_MULTI_IMG := $(WTP)/wtmi/build/wtmi.bin
  95. WTMI_ENC_IMG := wtmi-enc.bin
  96. SRCPATH := $(dir $(BL33))
  97. CLOCKSPRESET ?= CPU_800_DDR_800
  98. DDR_TOPOLOGY ?= 0
  99. BOOTDEV ?= SPINOR
  100. PARTNUM ?= 0
  101. TIMBLDARGS := $(MARVELL_SECURE_BOOT) $(BOOTDEV) $(IMAGESPATH) $(WTP) $(CLOCKSPRESET) \
  102. $(DDR_TOPOLOGY) $(PARTNUM) $(DEBUG) $(TIM_CFG) $(TIMN_CFG) $(TIMN_SIG) 1
  103. TIMBLDUARTARGS := $(MARVELL_SECURE_BOOT) UART $(IMAGESPATH) $(WTP) $(CLOCKSPRESET) \
  104. $(DDR_TOPOLOGY) 0 0 $(TIM_UART_CFG) $(TIMN_UART_CFG) $(TIMN_SIG) 0
  105. UART_IMAGES := $(BUILD_UART)/$(TIM_UART_IMAGE)
  106. ifeq ($(MARVELL_SECURE_BOOT),1)
  107. UART_IMAGES += $(BUILD_UART)/$(TIMN_UART_IMAGE)
  108. endif
  109. UART_IMAGES += $(BUILD_UART)/wtmi_h.bin $(BUILD_UART)/boot-image_h.bin
  110. CRYPTOPP_LIBDIR ?= $(CRYPTOPP_PATH)
  111. CRYPTOPP_INCDIR ?= $(CRYPTOPP_PATH)
  112. $(TBB): FORCE
  113. # Do not remove! Following checks are required to ensure correct TF-A builds, removing these checks leads to broken TF-A builds
  114. $(if $(CRYPTOPP_LIBDIR),,$(error "Platform '$(PLAT)' for WTP image tool requires CRYPTOPP_PATH or CRYPTOPP_LIBDIR. Please set CRYPTOPP_PATH or CRYPTOPP_LIBDIR to point to the right directory"))
  115. $(if $(CRYPTOPP_INCDIR),,$(error "Platform '$(PLAT)' for WTP image tool requires CRYPTOPP_PATH or CRYPTOPP_INCDIR. Please set CRYPTOPP_PATH or CRYPTOPP_INCDIR to point to the right directory"))
  116. $(if $(wildcard $(CRYPTOPP_LIBDIR)/*),,$(error "Either 'CRYPTOPP_PATH' or 'CRYPTOPP_LIB' was set to '$(CRYPTOPP_LIBDIR)', but '$(CRYPTOPP_LIBDIR)' does not exist"))
  117. $(if $(wildcard $(CRYPTOPP_INCDIR)/*),,$(error "Either 'CRYPTOPP_PATH' or 'CRYPTOPP_INCDIR' was set to '$(CRYPTOPP_INCDIR)', but '$(CRYPTOPP_INCDIR)' does not exist"))
  118. ifdef CRYPTOPP_PATH
  119. $(q)$(MAKE) --no-print-directory -C $(CRYPTOPP_PATH) -f GNUmakefile
  120. endif
  121. $(q)$(MAKE) --no-print-directory -C $(WTP)/wtptp/src/TBB_Linux -f TBB_linux.mak LIBDIR=$(CRYPTOPP_LIBDIR) INCDIR=$(CRYPTOPP_INCDIR)
  122. $(WTMI_MULTI_IMG): FORCE
  123. $(q)$(MAKE) --no-print-directory -C $(WTP) WTMI_IMG=$(WTMI_IMG) DDR_TOPOLOGY=$(DDR_TOPOLOGY) CLOCKSPRESET=$(CLOCKSPRESET) WTMI
  124. $(BUILD_PLAT)/wtmi.bin: $(WTMI_MULTI_IMG)
  125. $(q)cp -a $(WTMI_MULTI_IMG) $(BUILD_PLAT)/wtmi.bin
  126. $(TIMDDRTOOL): FORCE
  127. # Do not remove! Following checks are required to ensure correct TF-A builds, removing these checks leads to broken TF-A builds
  128. $(if $(value MV_DDR_PATH),,$(error "Platform '${PLAT}' for ddr tool requires MV_DDR_PATH. Please set MV_DDR_PATH to point to the right directory"))
  129. $(if $(wildcard $(value MV_DDR_PATH)/*),,$(error "'MV_DDR_PATH=$(value MV_DDR_PATH)' was specified, but '$(value MV_DDR_PATH)' directory does not exist"))
  130. $(if $(shell git -C $(value MV_DDR_PATH) rev-parse --show-cdup 2>&1),$(error "'MV_DDR_PATH=$(value MV_DDR_PATH)' was specified, but '$(value MV_DDR_PATH)' does not contain valid mv-ddr-marvell git repository"))
  131. $(q)$(MAKE) --no-print-directory -C $(WTP) MV_DDR_PATH=$(MV_DDR_PATH) DDR_TOPOLOGY=$(DDR_TOPOLOGY) mv_ddr
  132. $(BUILD_PLAT)/$(UART_IMAGE): $(BUILD_PLAT)/$(BOOT_IMAGE) $(BUILD_PLAT)/wtmi.bin $(TBB) $(TIMBUILD) $(TIMDDRTOOL) | $(BUILD_PLAT)/$(BUILD_UART)/ $$(@D)/
  133. $(s)echo
  134. $(s)echo "Building uart images"
  135. $(q)cp -a $(BUILD_PLAT)/wtmi.bin $(BUILD_PLAT)/$(BUILD_UART)/wtmi.bin
  136. $(q)cp -a $(BUILD_PLAT)/$(BOOT_IMAGE) $(BUILD_PLAT)/$(BUILD_UART)/$(BOOT_IMAGE)
  137. $(q)cd $(BUILD_PLAT)/$(BUILD_UART) && $(TIMBUILD) $(TIMBLDUARTARGS)
  138. $(q)sed -i 's|WTMI_IMG|wtmi.bin|1' $(TIM_UART_CFG)
  139. $(q)sed -i 's|BOOT_IMAGE|$(BOOT_IMAGE)|1' $(TIM_UART_CFG)
  140. ifeq ($(MARVELL_SECURE_BOOT),1)
  141. $(q)sed -i 's|WTMI_IMG|wtmi.bin|1' $(TIMN_UART_CFG)
  142. $(q)sed -i 's|BOOT_IMAGE|$(BOOT_IMAGE)|1' $(TIMN_UART_CFG)
  143. endif
  144. $(q)cd $(BUILD_PLAT)/$(BUILD_UART) && $(TBB) -r $(TIM_UART_CFG) -v -D
  145. ifeq ($(MARVELL_SECURE_BOOT),1)
  146. $(q)cd $(BUILD_PLAT)/$(BUILD_UART) && $(TBB) -r $(TIMN_UART_CFG)
  147. endif
  148. $(q)tar czf $(BUILD_PLAT)/$(UART_IMAGE) -C $(BUILD_PLAT) $(UART_IMAGES)
  149. $(s)echo
  150. $(s)echo "Built $@ successfully"
  151. $(s)echo
  152. $(BUILD_PLAT)/$(FLASH_IMAGE): $(BUILD_PLAT)/$(BOOT_IMAGE) $(BUILD_PLAT)/wtmi.bin $(TBB) $(TIMBUILD) $(TIMDDRTOOL) $(TIM2IMG)
  153. $(s)echo
  154. $(s)echo "Building flash image"
  155. $(q)cd $(BUILD_PLAT) && $(TIMBUILD) $(TIMBLDARGS)
  156. $(q)sed -i 's|WTMI_IMG|wtmi.bin|1' $(TIM_CFG)
  157. $(q)sed -i 's|BOOT_IMAGE|$(BOOT_IMAGE)|1' $(TIM_CFG)
  158. ifeq ($(MARVELL_SECURE_BOOT),1)
  159. $(q)sed -i 's|WTMI_IMG|wtmi.bin|1' $(TIMN_CFG)
  160. $(q)sed -i 's|BOOT_IMAGE|$(BOOT_IMAGE)|1' $(TIMN_CFG)
  161. $(s)echo
  162. $(s)echo "=======================================================";
  163. $(s)echo " Secure boot. Encrypting wtmi and boot-image";
  164. $(s)echo "=======================================================";
  165. $(s)echo
  166. $(q)cp $(BUILD_PLAT)/wtmi.bin $(BUILD_PLAT)/wtmi-align.bin
  167. $(q)truncate -s %16 $(BUILD_PLAT)/wtmi-align.bin
  168. $(q)${OPENSSL_BIN_PATH}/openssl enc -aes-256-cbc -e -in $(BUILD_PLAT)/wtmi-align.bin \
  169. -out $(BUILD_PLAT)/$(WTMI_ENC_IMG) \
  170. -K `cat $(IMAGESPATH)/aes-256.txt` -nosalt \
  171. -iv `cat $(IMAGESPATH)/iv.txt` -p
  172. $(q)truncate -s %16 $(BUILD_PLAT)/$(BOOT_IMAGE);
  173. $(q)${OPENSSL_BIN_PATH}/openssl enc -aes-256-cbc -e -in $(BUILD_PLAT)/$(BOOT_IMAGE) \
  174. -out $(BUILD_PLAT)/$(BOOT_ENC_IMAGE) \
  175. -K `cat $(IMAGESPATH)/aes-256.txt` -nosalt \
  176. -iv `cat $(IMAGESPATH)/iv.txt` -p
  177. endif
  178. $(q)cd $(BUILD_PLAT) && $(TBB) -r $(TIM_CFG) -v -D
  179. ifeq ($(MARVELL_SECURE_BOOT),1)
  180. $(q)cd $(BUILD_PLAT) && $(TBB) -r $(TIMN_CFG)
  181. $(q)sed -i 's|wtmi.bin|$(WTMI_ENC_IMG)|1' $(TIMN_CFG)
  182. $(q)sed -i 's|$(BOOT_IMAGE)|$(BOOT_ENC_IMAGE)|1' $(TIMN_CFG)
  183. endif
  184. $(q)cd $(BUILD_PLAT) && $(TIM2IMG) $(TIM2IMGARGS) -o $(BUILD_PLAT)/$(FLASH_IMAGE)
  185. $(s)echo
  186. $(s)echo "Built $@ successfully"
  187. $(s)echo
  188. clean realclean distclean: mrvl_clean
  189. .PHONY: mrvl_clean
  190. mrvl_clean:
  191. -$(q)$(MAKE) --no-print-directory -C $(WTP) MV_DDR_PATH=$(MV_DDR_PATH) clean
  192. -$(q)$(MAKE) --no-print-directory -C $(WTP)/wtptp/src/TBB_Linux -f TBB_linux.mak clean
  193. ifdef CRYPTOPP_PATH
  194. -$(q)$(MAKE) --no-print-directory -C $(CRYPTOPP_PATH) -f GNUmakefile clean
  195. endif
  196. else # WTP
  197. $(BUILD_PLAT)/$(UART_IMAGE) $(BUILD_PLAT)/$(FLASH_IMAGE):
  198. $(error "Platform '${PLAT}' for target '$@' requires WTP. Please set WTP to point to the right directory")
  199. endif # WTP
  200. .PHONY: mrvl_uart
  201. mrvl_uart: $(BUILD_PLAT)/$(UART_IMAGE)