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