build.rst 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. TF-A Build Instructions for Marvell Platforms
  2. =============================================
  3. This section describes how to compile the Trusted Firmware-A (TF-A) project for Marvell's platforms.
  4. Build Instructions
  5. ------------------
  6. (1) Set the cross compiler
  7. .. code:: shell
  8. > export CROSS_COMPILE=/path/to/toolchain/aarch64-linux-gnu-
  9. (2) Set path for FIP images:
  10. Set U-Boot image path (relatively to TF-A root or absolute path)
  11. .. code:: shell
  12. > export BL33=path/to/u-boot.bin
  13. For example: if U-Boot project (and its images) is located at ``~/project/u-boot``,
  14. BL33 should be ``~/project/u-boot/u-boot.bin``
  15. .. note::
  16. *u-boot.bin* should be used and not *u-boot-spl.bin*
  17. Set MSS/SCP image path (mandatory only for A7K/A8K/CN913x when MSS_SUPPORT=1)
  18. .. code:: shell
  19. > export SCP_BL2=path/to/mrvl_scp_bl2*.img
  20. (3) Armada-37x0 build requires WTP tools installation.
  21. See below in the section "Tools and external components installation".
  22. Install ARM 32-bit cross compiler, which is required for building WTMI image for CM3
  23. .. code:: shell
  24. > sudo apt-get install gcc-arm-linux-gnueabi
  25. (4) Clean previous build residuals (if any)
  26. .. code:: shell
  27. > make distclean
  28. (5) Build TF-A
  29. There are several build options:
  30. - PLAT
  31. Supported Marvell platforms are:
  32. - a3700 - A3720 DB, EspressoBin and Turris MOX
  33. - a70x0
  34. - a70x0_amc - AMC board
  35. - a70x0_mochabin - Globalscale MOCHAbin
  36. - a80x0
  37. - a80x0_mcbin - MacchiatoBin
  38. - a80x0_puzzle - IEI Puzzle-M801
  39. - t9130 - CN913x
  40. - t9130_cex7_eval - CN913x CEx7 Evaluation Board
  41. - DEBUG
  42. Default is without debug information (=0). in order to enable it use ``DEBUG=1``.
  43. Can be enabled also when building UART recovery images, there is no issue with it.
  44. Production TF-A images should be built without this debug option!
  45. - LOG_LEVEL
  46. Defines the level of logging which will be purged to the default output port.
  47. - 0 - LOG_LEVEL_NONE
  48. - 10 - LOG_LEVEL_ERROR
  49. - 20 - LOG_LEVEL_NOTICE (default for DEBUG=0)
  50. - 30 - LOG_LEVEL_WARNING
  51. - 40 - LOG_LEVEL_INFO (default for DEBUG=1)
  52. - 50 - LOG_LEVEL_VERBOSE
  53. - USE_COHERENT_MEM
  54. This flag determines whether to include the coherent memory region in the
  55. BL memory map or not. Enabled by default.
  56. - LLC_ENABLE
  57. Flag defining the LLC (L3) cache state. The cache is enabled by default (``LLC_ENABLE=1``).
  58. - LLC_SRAM
  59. Flag enabling the LLC (L3) cache SRAM support. The LLC SRAM is activated and used
  60. by Trusted OS (OP-TEE OS, BL32). The TF-A only prepares CCU address translation windows
  61. for SRAM address range at BL31 execution stage with window target set to DRAM-0.
  62. When Trusted OS activates LLC SRAM, the CCU window target is changed to SRAM.
  63. There is no reason to enable this feature if OP-TEE OS built with CFG_WITH_PAGER=n.
  64. Only set LLC_SRAM=1 if OP-TEE OS is built with CFG_WITH_PAGER=y.
  65. - MARVELL_SECURE_BOOT
  66. Build trusted(=1)/non trusted(=0) image, default is non trusted.
  67. This parameter is used only for ``mrvl_flash`` and ``mrvl_uart`` targets.
  68. - MV_DDR_PATH
  69. This parameter is required for ``mrvl_flash`` and ``mrvl_uart`` targets.
  70. For A7K/A8K/CN913x it is used for BLE build and for Armada37x0 it used
  71. for ddr_tool build.
  72. Specify path to the full checkout of Marvell mv-ddr-marvell git
  73. repository. Checkout must contain also .git subdirectory because
  74. mv-ddr build process calls git commands.
  75. Do not remove any parts of git checkout becuase build process and other
  76. applications need them for correct building and version determination.
  77. CN913x specific build options:
  78. - CP_NUM
  79. Total amount of CPs (South Bridge) connected to AP. When the parameter is omitted,
  80. the build uses the default number of CPs, which is a number of embedded CPs inside the
  81. package: 1 or 2 depending on the SoC used. The parameter is valid for OcteonTX2 CN913x SoC
  82. family (PLAT=t9130), which can have external CPs connected to the MCI ports. Valid
  83. values with CP_NUM are in a range of 1 to 3.
  84. A7K/A8K/CN913x specific build options:
  85. - BLE_PATH
  86. Points to BLE (Binary ROM extension) sources folder.
  87. The parameter is optional, its default value is ``plat/marvell/armada/a8k/common/ble``
  88. which uses TF-A in-tree BLE implementation.
  89. - MSS_SUPPORT
  90. When ``MSS_SUPPORT=1``, then TF-A includes support for Management SubSystem (MSS).
  91. When enabled it is required to specify path to the MSS firmware image via ``SCP_BL2``
  92. option.
  93. This option is by default enabled.
  94. - SCP_BL2
  95. Specify path to the MSS fimware image binary which will run on Cortex-M3 coprocessor.
  96. It is available in Marvell binaries-marvell git repository. Required when ``MSS_SUPPORT=1``.
  97. Globalscale MOCHAbin specific build options:
  98. - DDR_TOPOLOGY
  99. The DDR topology map index/name, default is 0.
  100. Supported Options:
  101. - 0 - DDR4 1CS 2GB
  102. - 1 - DDR4 1CS 4GB
  103. - 2 - DDR4 2CS 8GB
  104. Armada37x0 specific build options:
  105. - HANDLE_EA_EL3_FIRST_NS
  106. When ``HANDLE_EA_EL3_FIRST_NS=1``, External Aborts and SError Interrupts, resulting from errors
  107. in NS world, will be always trapped in TF-A. TF-A in this case enables dirty hack / workaround for
  108. a bug found in U-Boot and Linux kernel PCIe controller driver pci-aardvark.c, traps and then masks
  109. SError interrupt caused by AXI SLVERR on external access (syndrome 0xbf000002).
  110. Otherwise when ``HANDLE_EA_EL3_FIRST_NS=0``, these exceptions will be trapped in the current
  111. exception level (or in EL1 if the current exception level is EL0). So exceptions caused by
  112. U-Boot will be trapped in U-Boot, exceptions caused by Linux kernel (or user applications)
  113. will be trapped in Linux kernel.
  114. Mentioned bug in pci-aardvark.c driver is fixed in U-Boot version v2021.07 and Linux kernel
  115. version v5.13 (workarounded since Linux kernel version 5.9) and also backported in Linux
  116. kernel stable releases since versions v5.12.13, v5.10.46, v5.4.128, v4.19.198, v4.14.240.
  117. If target system has already patched version of U-Boot and Linux kernel then it is strongly
  118. recommended to not enable this workaround as it disallows propagating of all External Aborts
  119. to running Linux kernel and makes correctable errors as fatal aborts.
  120. This option is now disabled by default. In past this option has different name "HANDLE_EA_EL3_FIRST" and
  121. was enabled by default in TF-A versions v2.2, v2.3, v2.4 and v2.5.
  122. - CM3_SYSTEM_RESET
  123. When ``CM3_SYSTEM_RESET=1``, the Cortex-M3 secure coprocessor will be used for system reset.
  124. TF-A will send command 0x0009 with a magic value via the rWTM mailbox interface to the
  125. Cortex-M3 secure coprocessor.
  126. The firmware running in the coprocessor must either implement this functionality or
  127. ignore the 0x0009 command (which is true for the firmware from A3700-utils-marvell
  128. repository). If this option is enabled but the firmware does not support this command,
  129. an error message will be printed prior trying to reboot via the usual way.
  130. This option is needed on Turris MOX as a workaround to a HW bug which causes reset to
  131. sometime hang the board.
  132. - A3720_DB_PM_WAKEUP_SRC
  133. For Armada 3720 Development Board only, when ``A3720_DB_PM_WAKEUP_SRC=1``,
  134. TF-A will setup PM wake up src configuration. This option is disabled by default.
  135. Armada37x0 specific build options for ``mrvl_flash`` and ``mrvl_uart`` targets:
  136. - DDR_TOPOLOGY
  137. The DDR topology map index/name, default is 0.
  138. Supported Options:
  139. - 0 - DDR3 1CS 512MB (DB-88F3720-DDR3-Modular, EspressoBin V3-V5)
  140. - 1 - DDR4 1CS 512MB (DB-88F3720-DDR4-Modular)
  141. - 2 - DDR3 2CS 1GB (EspressoBin V3-V5)
  142. - 3 - DDR4 2CS 4GB (DB-88F3720-DDR4-Modular)
  143. - 4 - DDR3 1CS 1GB (DB-88F3720-DDR3-Modular, EspressoBin V3-V5)
  144. - 5 - DDR4 1CS 1GB (EspressoBin V7, EspressoBin-Ultra)
  145. - 6 - DDR4 2CS 2GB (EspressoBin V7)
  146. - 7 - DDR3 2CS 2GB (EspressoBin V3-V5)
  147. - CUST - CUSTOMER BOARD (Customer board settings)
  148. - CLOCKSPRESET
  149. The clock tree configuration preset including CPU and DDR frequency,
  150. default is CPU_800_DDR_800.
  151. - CPU_600_DDR_600 - CPU at 600 MHz, DDR at 600 MHz
  152. - CPU_800_DDR_800 - CPU at 800 MHz, DDR at 800 MHz
  153. - CPU_1000_DDR_800 - CPU at 1000 MHz, DDR at 800 MHz
  154. - CPU_1200_DDR_750 - CPU at 1200 MHz, DDR at 750 MHz
  155. Look at Armada37x0 chip package marking on board to identify correct CPU frequency.
  156. The last line on package marking (next line after the 88F37x0 line) should contain:
  157. - C080 or I080 - chip with 800 MHz CPU - use ``CLOCKSPRESET=CPU_800_DDR_800``
  158. - C100 or I100 - chip with 1000 MHz CPU - use ``CLOCKSPRESET=CPU_1000_DDR_800``
  159. - C120 - chip with 1200 MHz CPU - use ``CLOCKSPRESET=CPU_1200_DDR_750``
  160. - BOOTDEV
  161. The flash boot device, default is ``SPINOR``.
  162. Currently, Armada37x0 only supports ``SPINOR``, ``SPINAND``, ``EMMCNORM`` and ``SATA``:
  163. - SPINOR - SPI NOR flash boot
  164. - SPINAND - SPI NAND flash boot
  165. - EMMCNORM - eMMC Download Mode
  166. Download boot loader or program code from eMMC flash into CM3 or CA53
  167. Requires full initialization and command sequence
  168. - SATA - SATA device boot
  169. Image needs to be stored at disk LBA 0 or at disk partition with
  170. MBR type 0x4d (ASCII 'M' as in Marvell) or at disk partition with
  171. GPT partition type GUID ``6828311A-BA55-42A4-BCDE-A89BB5EDECAE``.
  172. - PARTNUM
  173. The boot partition number, default is 0.
  174. To boot from eMMC, the value should be aligned with the parameter in
  175. U-Boot with name of ``CONFIG_SYS_MMC_ENV_PART``, whose value by default is
  176. 1. For details about CONFIG_SYS_MMC_ENV_PART, please refer to the U-Boot
  177. build instructions.
  178. - WTMI_IMG
  179. The path of the binary can point to an image which
  180. does nothing, an image which supports EFUSE or a customized CM3 firmware
  181. binary. The default image is ``fuse.bin`` that built from sources in WTP
  182. folder, which is the next option. If the default image is OK, then this
  183. option should be skipped.
  184. Please note that this is not a full WTMI image, just a main loop without
  185. hardware initialization code. Final WTMI image is built from this WTMI_IMG
  186. binary and sys-init code from the WTP directory which sets DDR and CPU
  187. clocks according to DDR_TOPOLOGY and CLOCKSPRESET options.
  188. CZ.NIC as part of Turris project released free and open source WTMI
  189. application firmware ``wtmi_app.bin`` for all Armada 3720 devices.
  190. This firmware includes additional features like access to Hardware
  191. Random Number Generator of Armada 3720 SoC which original Marvell's
  192. ``fuse.bin`` image does not have.
  193. CZ.NIC's Armada 3720 Secure Firmware is available at website:
  194. https://gitlab.nic.cz/turris/mox-boot-builder/
  195. - WTP
  196. Specify path to the full checkout of Marvell A3700-utils-marvell git
  197. repository. Checkout must contain also .git subdirectory because WTP
  198. build process calls git commands.
  199. WTP build process uses also Marvell mv-ddr-marvell git repository
  200. specified in MV_DDR_PATH option.
  201. Do not remove any parts of git checkout becuase build process and other
  202. applications need them for correct building and version determination.
  203. - CRYPTOPP_PATH
  204. Use this parameter to point to Crypto++ source code
  205. directory. If this option is specified then Crypto++ source code in
  206. CRYPTOPP_PATH directory will be automatically compiled. Crypto++ library
  207. is required for building WTP image tool. Either CRYPTOPP_PATH or
  208. CRYPTOPP_LIBDIR with CRYPTOPP_INCDIR needs to be specified for Armada37x0.
  209. - CRYPTOPP_LIBDIR
  210. Use this parameter to point to the directory with
  211. compiled Crypto++ library. By default it points to the CRYPTOPP_PATH.
  212. On Debian systems it is possible to install system-wide Crypto++ library
  213. via command ``apt install libcrypto++-dev`` and specify CRYPTOPP_LIBDIR
  214. to ``/usr/lib/``.
  215. - CRYPTOPP_INCDIR
  216. Use this parameter to point to the directory with
  217. header files of Crypto++ library. By default it points to the CRYPTOPP_PATH.
  218. On Debian systems it is possible to install system-wide Crypto++ library
  219. via command ``apt install libcrypto++-dev`` and specify CRYPTOPP_INCDIR
  220. to ``/usr/include/crypto++/``.
  221. For example, in order to build the image in debug mode with log level up to 'notice' level run
  222. .. code:: shell
  223. > make DEBUG=1 USE_COHERENT_MEM=0 LOG_LEVEL=20 PLAT=<MARVELL_PLATFORM> mrvl_flash
  224. And if we want to build a Armada37x0 image in debug mode with log level up to 'notice' level,
  225. the image has the preset CPU at 1000 MHz, preset DDR3 at 800 MHz, the DDR topology of DDR4 2CS,
  226. the image boot from SPI NOR flash partition 0, and the image is non trusted in WTP, the command
  227. line is as following
  228. .. code:: shell
  229. > make DEBUG=1 USE_COHERENT_MEM=0 LOG_LEVEL=20 CLOCKSPRESET=CPU_1000_DDR_800 \
  230. MARVELL_SECURE_BOOT=0 DDR_TOPOLOGY=3 BOOTDEV=SPINOR PARTNUM=0 PLAT=a3700 \
  231. MV_DDR_PATH=/path/to/mv-ddr-marvell/ WTP=/path/to/A3700-utils-marvell/ \
  232. CRYPTOPP_PATH=/path/to/cryptopp/ BL33=/path/to/u-boot.bin \
  233. all fip mrvl_bootimage mrvl_flash mrvl_uart
  234. To build just TF-A without WTMI image (useful for A3720 Turris MOX board), run following command:
  235. .. code:: shell
  236. > make USE_COHERENT_MEM=0 PLAT=a3700 CM3_SYSTEM_RESET=1 BL33=/path/to/u-boot.bin \
  237. CROSS_COMPILE=aarch64-linux-gnu- mrvl_bootimage
  238. Here is full example how to build production release of Marvell firmware image (concatenated
  239. binary of Marvell's A3720 sys-init, CZ.NIC's Armada 3720 Secure Firmware, TF-A and U-Boot) for
  240. EspressoBin board (PLAT=a3700) with 1GHz CPU (CLOCKSPRESET=CPU_1000_DDR_800) and
  241. 1GB DDR4 RAM (DDR_TOPOLOGY=5):
  242. .. code:: shell
  243. > git clone https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git
  244. > git clone https://source.denx.de/u-boot/u-boot.git
  245. > git clone https://github.com/weidai11/cryptopp.git
  246. > git clone https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell.git
  247. > git clone https://github.com/MarvellEmbeddedProcessors/A3700-utils-marvell.git
  248. > git clone https://gitlab.nic.cz/turris/mox-boot-builder.git
  249. > make -C u-boot CROSS_COMPILE=aarch64-linux-gnu- mvebu_espressobin-88f3720_defconfig u-boot.bin
  250. > make -C mox-boot-builder CROSS_CM3=arm-linux-gnueabi- wtmi_app.bin
  251. > make -C trusted-firmware-a CROSS_COMPILE=aarch64-linux-gnu- CROSS_CM3=arm-linux-gnueabi- \
  252. USE_COHERENT_MEM=0 PLAT=a3700 CLOCKSPRESET=CPU_1000_DDR_800 DDR_TOPOLOGY=5 \
  253. MV_DDR_PATH=$PWD/mv-ddr-marvell/ WTP=$PWD/A3700-utils-marvell/ \
  254. CRYPTOPP_PATH=$PWD/cryptopp/ BL33=$PWD/u-boot/u-boot.bin \
  255. WTMI_IMG=$PWD/mox-boot-builder/wtmi_app.bin FIP_ALIGN=0x100 mrvl_flash
  256. Produced Marvell firmware flash image: ``trusted-firmware-a/build/a3700/release/flash-image.bin``
  257. Special Build Flags
  258. --------------------
  259. - PLAT_RECOVERY_IMAGE_ENABLE
  260. When set this option to enable secondary recovery function when build atf.
  261. In order to build UART recovery image this operation should be disabled for
  262. A7K/A8K/CN913x because of hardware limitation (boot from secondary image
  263. can interrupt UART recovery process). This MACRO definition is set in
  264. ``plat/marvell/armada/a8k/common/include/platform_def.h`` file.
  265. - DDR32
  266. In order to work in 32bit DDR, instead of the default 64bit ECC DDR,
  267. this flag should be set to 1.
  268. For more information about build options, please refer to the
  269. :ref:`Build Options` document.
  270. Build output
  271. ------------
  272. Marvell's TF-A compilation generates 8 files:
  273. - ble.bin - BLe image (not available for Armada37x0)
  274. - bl1.bin - BL1 image
  275. - bl2.bin - BL2 image
  276. - bl31.bin - BL31 image
  277. - fip.bin - FIP image (contains BL2, BL31 & BL33 (U-Boot) images)
  278. - boot-image.bin - TF-A image (contains BL1 and FIP images)
  279. - flash-image.bin - Flashable Marvell firmware image. For Armada37x0 it
  280. contains TIM, WTMI and boot-image.bin images. For other platforms it contains
  281. BLe and boot-image.bin images. Should be placed on the boot flash/device.
  282. - uart-images.tgz.bin - GZIPed TAR archive which contains Armada37x0 images
  283. for booting via UART. Could be loaded via Marvell's WtpDownload tool from
  284. A3700-utils-marvell repository.
  285. Additional make target ``mrvl_bootimage`` produce ``boot-image.bin`` file. Target
  286. ``mrvl_flash`` produce final ``flash-image.bin`` file and target ``mrvl_uart``
  287. produce ``uart-images.tgz.bin`` file.
  288. Tools and external components installation
  289. ------------------------------------------
  290. Armada37x0 Builds require installation of additional components
  291. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  292. (1) ARM cross compiler capable of building images for the service CPU (CM3).
  293. This component is usually included in the Linux host packages.
  294. On Debian/Ubuntu hosts the default GNU ARM tool chain can be installed
  295. using the following command
  296. .. code:: shell
  297. > sudo apt-get install gcc-arm-linux-gnueabi
  298. Only if required, the default tool chain prefix ``arm-linux-gnueabi-`` can be
  299. overwritten using the environment variable ``CROSS_CM3``.
  300. Example for BASH shell
  301. .. code:: shell
  302. > export CROSS_CM3=/opt/arm-cross/bin/arm-linux-gnueabi
  303. (2) DDR initialization library sources (mv_ddr) available at the following repository
  304. (use the "master" branch):
  305. https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell.git
  306. (3) Armada3700 tools available at the following repository
  307. (use the "master" branch):
  308. https://github.com/MarvellEmbeddedProcessors/A3700-utils-marvell.git
  309. (4) Crypto++ library available at the following repository:
  310. https://github.com/weidai11/cryptopp.git
  311. (5) Optional CZ.NIC's Armada 3720 Secure Firmware:
  312. https://gitlab.nic.cz/turris/mox-boot-builder.git
  313. Armada70x0, Armada80x0 and CN913x Builds require installation of additional components
  314. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  315. (1) DDR initialization library sources (mv_ddr) available at the following repository
  316. (use the "master" branch):
  317. https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell.git
  318. (2) MSS Management SubSystem Firmware available at the following repository
  319. (use the "binaries-marvell-armada-SDK10.0.1.0" branch):
  320. https://github.com/MarvellEmbeddedProcessors/binaries-marvell.git