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