1*54fd6939SJiyong ParkAllwinner ARMv8 SoCs 2*54fd6939SJiyong Park==================== 3*54fd6939SJiyong Park 4*54fd6939SJiyong ParkTrusted Firmware-A (TF-A) implements the EL3 firmware layer for Allwinner 5*54fd6939SJiyong ParkSoCs with ARMv8 cores. Only BL31 is used to provide proper EL3 setup and 6*54fd6939SJiyong ParkPSCI runtime services. 7*54fd6939SJiyong Park 8*54fd6939SJiyong ParkBuilding TF-A 9*54fd6939SJiyong Park------------- 10*54fd6939SJiyong Park 11*54fd6939SJiyong ParkTo build for machines with an A64 or H5 SoC: 12*54fd6939SJiyong Park 13*54fd6939SJiyong Park.. code:: shell 14*54fd6939SJiyong Park 15*54fd6939SJiyong Park make CROSS_COMPILE=aarch64-linux-gnu- PLAT=sun50i_a64 DEBUG=1 bl31 16*54fd6939SJiyong Park 17*54fd6939SJiyong ParkTo build for machines with an H6 SoC: 18*54fd6939SJiyong Park 19*54fd6939SJiyong Park.. code:: shell 20*54fd6939SJiyong Park 21*54fd6939SJiyong Park make CROSS_COMPILE=aarch64-linux-gnu- PLAT=sun50i_h6 DEBUG=1 bl31 22*54fd6939SJiyong Park 23*54fd6939SJiyong ParkTo build for machines with an H616 or H313 SoC: 24*54fd6939SJiyong Park 25*54fd6939SJiyong Park.. code:: shell 26*54fd6939SJiyong Park 27*54fd6939SJiyong Park make CROSS_COMPILE=aarch64-linux-gnu- PLAT=sun50i_h616 DEBUG=1 bl31 28*54fd6939SJiyong Park 29*54fd6939SJiyong Park 30*54fd6939SJiyong ParkInstallation 31*54fd6939SJiyong Park------------ 32*54fd6939SJiyong Park 33*54fd6939SJiyong ParkU-Boot's SPL acts as a loader, loading both BL31 and BL33 (typically U-Boot). 34*54fd6939SJiyong ParkLoading is done from SD card, eMMC or SPI flash, also via an USB debug 35*54fd6939SJiyong Parkinterface (FEL). 36*54fd6939SJiyong Park 37*54fd6939SJiyong ParkAfter building bl31.bin, the binary must be fed to the U-Boot build system 38*54fd6939SJiyong Parkto include it in the FIT image that the SPL loader will process. 39*54fd6939SJiyong Parkbl31.bin can be either copied (or sym-linked) into U-Boot's root directory, 40*54fd6939SJiyong Parkor the environment variable BL31 must contain the binary's path. 41*54fd6939SJiyong ParkSee the respective `U-Boot documentation`_ for more details. 42*54fd6939SJiyong Park 43*54fd6939SJiyong Park.. _U-Boot documentation: https://gitlab.denx.de/u-boot/u-boot/-/blob/master/board/sunxi/README.sunxi64 44*54fd6939SJiyong Park 45*54fd6939SJiyong ParkMemory layout 46*54fd6939SJiyong Park------------- 47*54fd6939SJiyong Park 48*54fd6939SJiyong ParkA64, H5 and H6 SoCs 49*54fd6939SJiyong Park~~~~~~~~~~~~~~~~~~~ 50*54fd6939SJiyong Park 51*54fd6939SJiyong ParkBL31 lives in SRAM A2, which is documented to be accessible from secure 52*54fd6939SJiyong Parkworld only. Since this SRAM region is very limited (48 KB), we take 53*54fd6939SJiyong Parkseveral measures to reduce memory consumption. One of them is to confine 54*54fd6939SJiyong ParkBL31 to only 28 bits of virtual address space, which reduces the number 55*54fd6939SJiyong Parkof required page tables (each occupying 4KB of memory). 56*54fd6939SJiyong ParkThe mapping we use on those SoCs is as follows: 57*54fd6939SJiyong Park 58*54fd6939SJiyong Park:: 59*54fd6939SJiyong Park 60*54fd6939SJiyong Park 0 64K 16M 1GB 1G+160M physical address 61*54fd6939SJiyong Park +-+------+-+---+------+--...---+-------+----+------+---------- 62*54fd6939SJiyong Park |B| |S|///| |//...///| |////| | 63*54fd6939SJiyong Park |R| SRAM |C|///| dev |//...///| (sec) |////| BL33 | DRAM ... 64*54fd6939SJiyong Park |O| |P|///| MMIO |//...///| DRAM |////| | 65*54fd6939SJiyong Park |M| | |///| |//...///| (32M) |////| | 66*54fd6939SJiyong Park +-+------+-+---+------+--...---+-------+----+------+---------- 67*54fd6939SJiyong Park | | | | | | / / / / 68*54fd6939SJiyong Park | | | | | | / / / / 69*54fd6939SJiyong Park | | | | | | / / / / 70*54fd6939SJiyong Park | | | | | | / // / 71*54fd6939SJiyong Park | | | | | | / / / 72*54fd6939SJiyong Park +-+------+-+---+------+--+-------+------+ 73*54fd6939SJiyong Park |B| |S|///| |//| | | 74*54fd6939SJiyong Park |R| SRAM |C|///| dev |//| sec | BL33 | 75*54fd6939SJiyong Park |O| |P|///| MMIO |//| DRAM | | 76*54fd6939SJiyong Park |M| | |///| |//| | | 77*54fd6939SJiyong Park +-+------+-+---+------+--+-------+------+ 78*54fd6939SJiyong Park 0 64K 16M 160M 192M 256M virtual address 79*54fd6939SJiyong Park 80*54fd6939SJiyong Park 81*54fd6939SJiyong ParkH616 SoC 82*54fd6939SJiyong Park~~~~~~~~ 83*54fd6939SJiyong Park 84*54fd6939SJiyong ParkThe H616 lacks the secure SRAM region present on the other SoCs, also 85*54fd6939SJiyong Parklacks the "ARISC" management processor (SCP) we use. BL31 thus needs to 86*54fd6939SJiyong Parkrun from DRAM, which prevents our compressed virtual memory map described 87*54fd6939SJiyong Parkabove. Since running in DRAM also lifts the restriction of the limited 88*54fd6939SJiyong ParkSRAM size, we use the normal 1:1 mapping with 32 bits worth of virtual 89*54fd6939SJiyong Parkaddress space. So the virtual addresses used in BL31 match the physical 90*54fd6939SJiyong Parkaddresses as presented above. 91*54fd6939SJiyong Park 92*54fd6939SJiyong ParkTrusted OS dispatcher 93*54fd6939SJiyong Park--------------------- 94*54fd6939SJiyong Park 95*54fd6939SJiyong ParkOne can boot Trusted OS(OP-TEE OS, bl32 image) along side bl31 image on Allwinner A64. 96*54fd6939SJiyong Park 97*54fd6939SJiyong ParkIn order to include the 'opteed' dispatcher in the image, pass 'SPD=opteed' on the command line 98*54fd6939SJiyong Parkwhile compiling the bl31 image and make sure the loader (SPL) loads the Trusted OS binary to 99*54fd6939SJiyong Parkthe beginning of DRAM (0x40000000). 100