allwinner.rst 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. Allwinner ARMv8 SoCs
  2. ====================
  3. Trusted Firmware-A (TF-A) implements the EL3 firmware layer for Allwinner
  4. SoCs with ARMv8 cores. Only BL31 is used to provide proper EL3 setup and
  5. PSCI runtime services.
  6. Building TF-A
  7. -------------
  8. There is one build target per supported SoC:
  9. +------+-------------------+
  10. | SoC | TF-A build target |
  11. +======+===================+
  12. | A64 | sun50i_a64 |
  13. +------+-------------------+
  14. | H5 | sun50i_a64 |
  15. +------+-------------------+
  16. | H6 | sun50i_h6 |
  17. +------+-------------------+
  18. | H616 | sun50i_h616 |
  19. +------+-------------------+
  20. | H313 | sun50i_h616 |
  21. +------+-------------------+
  22. | T507 | sun50i_h616 |
  23. +------+-------------------+
  24. | R329 | sun50i_r329 |
  25. +------+-------------------+
  26. To build with the default settings for a particular SoC:
  27. .. code:: shell
  28. make CROSS_COMPILE=aarch64-linux-gnu- PLAT=<build target> DEBUG=1
  29. So for instance to build for a board with the Allwinner A64 SoC::
  30. make CROSS_COMPILE=aarch64-linux-gnu- PLAT=sun50i_a64 DEBUG=1
  31. Platform-specific build options
  32. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  33. The default build options should generate a working firmware image. There are
  34. some build options that allow to fine-tune the firmware, or to disable support
  35. for optional features.
  36. - ``SUNXI_PSCI_USE_NATIVE`` : Support direct control of the CPU cores powerdown
  37. and powerup sequence by BL31. This requires either support for a code snippet
  38. to be loaded into the ARISC SCP (A64, H5), or the power sequence control
  39. registers to be programmed directly (H6, H616). This supports only basic
  40. control, like core on/off and system off/reset.
  41. This option defaults to 1. If an active SCP supporting the SCPI protocol
  42. is detected at runtime, this control scheme will be ignored, and SCPI
  43. will be used instead, unless support has been explicitly disabled.
  44. - ``SUNXI_PSCI_USE_SCPI`` : Support control of the CPU cores powerdown and
  45. powerup sequence by talking to the SCP processor via the SCPI protocol.
  46. This allows more advanced power saving techniques, like suspend to RAM.
  47. This option defaults to 1 on SoCs that feature an SCP. If no SCP firmware
  48. using the SCPI protocol is detected, the native sequence will be used
  49. instead. If both native and SCPI methods are included, SCPI will be favoured
  50. if SCP support is detected.
  51. - ``SUNXI_SETUP_REGULATORS`` : On SoCs that typically ship with a PMIC
  52. power management controller, BL31 tries to set up all needed power rails,
  53. programming them to their respective voltages. That allows bootloader
  54. software like U-Boot to ignore power control via the PMIC.
  55. This setting defaults to 1. In some situations that enables too many
  56. regulators, or some regulators need to be enabled in a very specific
  57. sequence. To avoid problems with those boards, ``SUNXI_SETUP_REGULATORS``
  58. can bet set to ``0`` on the build command line, to skip the PMIC setup
  59. entirely. Any bootloader or OS would need to setup the PMIC on its own then.
  60. Installation
  61. ------------
  62. U-Boot's SPL acts as a loader, loading both BL31 and BL33 (typically U-Boot).
  63. Loading is done from SD card, eMMC or SPI flash, also via an USB debug
  64. interface (FEL).
  65. After building bl31.bin, the binary must be fed to the U-Boot build system
  66. to include it in the FIT image that the SPL loader will process.
  67. bl31.bin can be either copied (or sym-linked) into U-Boot's root directory,
  68. or the environment variable BL31 must contain the binary's path.
  69. See the respective `U-Boot documentation`_ for more details.
  70. .. _U-Boot documentation: https://gitlab.denx.de/u-boot/u-boot/-/blob/master/board/sunxi/README.sunxi64
  71. Memory layout
  72. -------------
  73. A64, H5 and H6 SoCs
  74. ~~~~~~~~~~~~~~~~~~~
  75. BL31 lives in SRAM A2, which is documented to be accessible from secure
  76. world only. Since this SRAM region is very limited (48 KB), we take
  77. several measures to reduce memory consumption. One of them is to confine
  78. BL31 to only 28 bits of virtual address space, which reduces the number
  79. of required page tables (each occupying 4KB of memory).
  80. The mapping we use on those SoCs is as follows:
  81. ::
  82. 0 64K 16M 1GB 1G+160M physical address
  83. +-+------+-+---+------+--...---+-------+----+------+----------
  84. |B| |S|///| |//...///| |////| |
  85. |R| SRAM |C|///| dev |//...///| (sec) |////| BL33 | DRAM ...
  86. |O| |P|///| MMIO |//...///| DRAM |////| |
  87. |M| | |///| |//...///| (32M) |////| |
  88. +-+------+-+---+------+--...---+-------+----+------+----------
  89. | | | | | | / / / /
  90. | | | | | | / / / /
  91. | | | | | | / / / /
  92. | | | | | | / // /
  93. | | | | | | / / /
  94. +-+------+-+---+------+--+-------+------+
  95. |B| |S|///| |//| | |
  96. |R| SRAM |C|///| dev |//| sec | BL33 |
  97. |O| |P|///| MMIO |//| DRAM | |
  98. |M| | |///| |//| | |
  99. +-+------+-+---+------+--+-------+------+
  100. 0 64K 16M 160M 192M 256M virtual address
  101. H616 SoC
  102. ~~~~~~~~
  103. The H616 lacks the secure SRAM region present on the other SoCs, also
  104. lacks the "ARISC" management processor (SCP) we use. BL31 thus needs to
  105. run from DRAM, which prevents our compressed virtual memory map described
  106. above. Since running in DRAM also lifts the restriction of the limited
  107. SRAM size, we use the normal 1:1 mapping with 32 bits worth of virtual
  108. address space. So the virtual addresses used in BL31 match the physical
  109. addresses as presented above.
  110. Trusted OS dispatcher
  111. ---------------------
  112. One can boot Trusted OS(OP-TEE OS, bl32 image) along side bl31 image on Allwinner A64.
  113. In order to include the 'opteed' dispatcher in the image, pass 'SPD=opteed' on the command line
  114. while compiling the bl31 image and make sure the loader (SPL) loads the Trusted OS binary to
  115. the beginning of DRAM (0x40000000).