platform.mk 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. #
  2. # Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved.
  3. #
  4. # SPDX-License-Identifier: BSD-3-Clause
  5. #
  6. include lib/libfdt/libfdt.mk
  7. include lib/xlat_tables_v2/xlat_tables.mk
  8. PLAT_INCLUDES := -Iplat/rpi/common/include \
  9. -Iplat/rpi/rpi3/include
  10. PLAT_BL_COMMON_SOURCES := drivers/ti/uart/aarch64/16550_console.S \
  11. drivers/arm/pl011/aarch64/pl011_console.S \
  12. drivers/gpio/gpio.c \
  13. drivers/delay_timer/delay_timer.c \
  14. drivers/rpi3/gpio/rpi3_gpio.c \
  15. plat/rpi/common/aarch64/plat_helpers.S \
  16. plat/rpi/common/rpi3_common.c \
  17. plat/rpi/common/rpi3_console_dual.c \
  18. ${XLAT_TABLES_LIB_SRCS}
  19. BL1_SOURCES += drivers/io/io_fip.c \
  20. drivers/io/io_memmap.c \
  21. drivers/io/io_storage.c \
  22. drivers/delay_timer/generic_delay_timer.c \
  23. lib/cpus/aarch64/cortex_a53.S \
  24. plat/common/aarch64/platform_mp_stack.S \
  25. plat/rpi/rpi3/rpi3_bl1_setup.c \
  26. plat/rpi/common/rpi3_io_storage.c \
  27. drivers/rpi3/mailbox/rpi3_mbox.c \
  28. plat/rpi/rpi3/rpi_mbox_board.c
  29. BL2_SOURCES += common/desc_image_load.c \
  30. drivers/io/io_fip.c \
  31. drivers/io/io_memmap.c \
  32. drivers/io/io_storage.c \
  33. drivers/delay_timer/generic_delay_timer.c \
  34. drivers/io/io_block.c \
  35. drivers/mmc/mmc.c \
  36. drivers/rpi3/sdhost/rpi3_sdhost.c \
  37. plat/common/aarch64/platform_mp_stack.S \
  38. plat/rpi/rpi3/aarch64/rpi3_bl2_mem_params_desc.c \
  39. plat/rpi/rpi3/rpi3_bl2_setup.c \
  40. plat/rpi/common/rpi3_image_load.c \
  41. plat/rpi/common/rpi3_io_storage.c
  42. BL31_SOURCES += lib/cpus/aarch64/cortex_a53.S \
  43. plat/common/plat_gicv2.c \
  44. plat/common/plat_psci_common.c \
  45. plat/rpi/rpi3/rpi3_bl31_setup.c \
  46. plat/rpi/common/rpi3_pm.c \
  47. plat/rpi/common/rpi3_topology.c \
  48. ${LIBFDT_SRCS}
  49. # Tune compiler for Cortex-A53
  50. ifeq ($($(ARCH)-cc-id),arm-clang)
  51. TF_CFLAGS_aarch64 += -mcpu=cortex-a53
  52. else ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
  53. TF_CFLAGS_aarch64 += -mcpu=cortex-a53
  54. else
  55. TF_CFLAGS_aarch64 += -mtune=cortex-a53
  56. endif
  57. # Platform Makefile target
  58. # ------------------------
  59. RPI3_BL1_PAD_BIN := ${BUILD_PLAT}/bl1_pad.bin
  60. RPI3_ARMSTUB8_BIN := ${BUILD_PLAT}/armstub8.bin
  61. # Add new default target when compiling this platform
  62. all: armstub
  63. # This target concatenates BL1 and the FIP so that the base addresses match the
  64. # ones defined in the memory map
  65. armstub: bl1 fip
  66. $(s)echo " CAT $@"
  67. $(q)cp ${BUILD_PLAT}/bl1.bin ${RPI3_BL1_PAD_BIN}
  68. $(q)truncate --size=131072 ${RPI3_BL1_PAD_BIN}
  69. $(q)cat ${RPI3_BL1_PAD_BIN} ${BUILD_PLAT}/fip.bin > ${RPI3_ARMSTUB8_BIN}
  70. $(s)echo
  71. $(s)echo "Built $@ successfully"
  72. $(s)echo
  73. # Build config flags
  74. # ------------------
  75. # Enable all errata workarounds for Cortex-A53
  76. ERRATA_A53_826319 := 1
  77. ERRATA_A53_835769 := 1
  78. ERRATA_A53_836870 := 1
  79. ERRATA_A53_843419 := 1
  80. ERRATA_A53_855873 := 1
  81. WORKAROUND_CVE_2017_5715 := 0
  82. # Disable stack protector by default
  83. ENABLE_STACK_PROTECTOR := 0
  84. # Reset to BL31 isn't supported
  85. RESET_TO_BL31 := 0
  86. # Have different sections for code and rodata
  87. SEPARATE_CODE_AND_RODATA := 1
  88. # Use Coherent memory
  89. USE_COHERENT_MEM := 1
  90. # Platform build flags
  91. # --------------------
  92. # BL33 images are in AArch64 by default
  93. RPI3_BL33_IN_AARCH32 := 0
  94. # Assume that BL33 isn't the Linux kernel by default
  95. RPI3_DIRECT_LINUX_BOOT := 0
  96. # UART to use at runtime. -1 means the runtime UART is disabled.
  97. # Any other value means the default UART will be used.
  98. RPI3_RUNTIME_UART := -1
  99. # Use normal memory mapping for ROM, FIP, SRAM and DRAM
  100. RPI3_USE_UEFI_MAP := 0
  101. # BL32 location
  102. RPI3_BL32_RAM_LOCATION := tdram
  103. ifeq (${RPI3_BL32_RAM_LOCATION}, tsram)
  104. RPI3_BL32_RAM_LOCATION_ID = SEC_SRAM_ID
  105. else ifeq (${RPI3_BL32_RAM_LOCATION}, tdram)
  106. RPI3_BL32_RAM_LOCATION_ID = SEC_DRAM_ID
  107. else
  108. $(error "Unsupported RPI3_BL32_RAM_LOCATION value")
  109. endif
  110. # Process platform flags
  111. # ----------------------
  112. $(eval $(call add_define,RPI3_BL32_RAM_LOCATION_ID))
  113. $(eval $(call add_define,RPI3_BL33_IN_AARCH32))
  114. $(eval $(call add_define,RPI3_DIRECT_LINUX_BOOT))
  115. ifdef RPI3_PRELOADED_DTB_BASE
  116. $(eval $(call add_define,RPI3_PRELOADED_DTB_BASE))
  117. endif
  118. $(eval $(call add_define,RPI3_RUNTIME_UART))
  119. $(eval $(call add_define,RPI3_USE_UEFI_MAP))
  120. # Verify build config
  121. # -------------------
  122. #
  123. ifneq (${RPI3_DIRECT_LINUX_BOOT}, 0)
  124. ifndef RPI3_PRELOADED_DTB_BASE
  125. $(error Error: RPI3_PRELOADED_DTB_BASE needed if RPI3_DIRECT_LINUX_BOOT=1)
  126. endif
  127. endif
  128. ifneq (${RESET_TO_BL31}, 0)
  129. $(error Error: rpi3 needs RESET_TO_BL31=0)
  130. endif
  131. ifeq (${ARCH},aarch32)
  132. $(error Error: AArch32 not supported on rpi3)
  133. endif
  134. ifneq ($(ENABLE_STACK_PROTECTOR), 0)
  135. PLAT_BL_COMMON_SOURCES += drivers/rpi3/rng/rpi3_rng.c \
  136. plat/rpi/common/rpi3_stack_protector.c
  137. endif
  138. ifeq (${SPD},opteed)
  139. BL2_SOURCES += \
  140. lib/optee/optee_utils.c
  141. endif
  142. # Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images
  143. # in the FIP if the platform requires.
  144. ifneq ($(BL32_EXTRA1),)
  145. $(eval $(call TOOL_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1))
  146. endif
  147. ifneq ($(BL32_EXTRA2),)
  148. $(eval $(call TOOL_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2))
  149. endif
  150. ifneq (${TRUSTED_BOARD_BOOT},0)
  151. include drivers/auth/mbedtls/mbedtls_crypto.mk
  152. include drivers/auth/mbedtls/mbedtls_x509.mk
  153. AUTH_SOURCES := drivers/auth/auth_mod.c \
  154. drivers/auth/crypto_mod.c \
  155. drivers/auth/img_parser_mod.c \
  156. drivers/auth/tbbr/tbbr_cot_common.c
  157. BL1_SOURCES += ${AUTH_SOURCES} \
  158. bl1/tbbr/tbbr_img_desc.c \
  159. plat/common/tbbr/plat_tbbr.c \
  160. plat/rpi/common/rpi3_trusted_boot.c \
  161. plat/rpi/common/rpi3_rotpk.S \
  162. drivers/auth/tbbr/tbbr_cot_bl1.c
  163. BL2_SOURCES += ${AUTH_SOURCES} \
  164. plat/common/tbbr/plat_tbbr.c \
  165. plat/rpi/common/rpi3_trusted_boot.c \
  166. plat/rpi/common/rpi3_rotpk.S \
  167. drivers/auth/tbbr/tbbr_cot_bl2.c
  168. ROT_KEY = $(BUILD_PLAT)/rot_key.pem
  169. ROTPK_HASH = $(BUILD_PLAT)/rotpk_sha256.bin
  170. $(eval $(call add_define_val,ROTPK_HASH,'"$(ROTPK_HASH)"'))
  171. $(BUILD_PLAT)/bl1/rpi3_rotpk.o: $(ROTPK_HASH)
  172. $(BUILD_PLAT)/bl2/rpi3_rotpk.o: $(ROTPK_HASH)
  173. certificates: $(ROT_KEY)
  174. $(ROT_KEY): | $$(@D)/
  175. $(s)echo " OPENSSL $@"
  176. $(q)${OPENSSL_BIN_PATH}/openssl genrsa 2048 > $@ 2>/dev/null
  177. $(ROTPK_HASH): $(ROT_KEY) | $$(@D)/
  178. $(s)echo " OPENSSL $@"
  179. $(q)${OPENSSL_BIN_PATH}/openssl rsa -in $< -pubout -outform DER 2>/dev/null |\
  180. ${OPENSSL_BIN_PATH}/openssl dgst -sha256 -binary > $@ 2>/dev/null
  181. endif