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