xref: /arm-trusted-firmware/docs/plat/rpi4.rst (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700SchasingluluRaspberry Pi 4
2*91f16700Schasinglulu==============
3*91f16700Schasinglulu
4*91f16700SchasingluluThe `Raspberry Pi 4`_ is an inexpensive single-board computer that contains four
5*91f16700SchasingluluArm Cortex-A72 cores. Also in contrast to previous Raspberry Pi versions this
6*91f16700Schasinglulumodel has a GICv2 interrupt controller.
7*91f16700Schasinglulu
8*91f16700SchasingluluThis port is a minimal port to support loading non-secure EL2 payloads such
9*91f16700Schasingluluas a 64-bit Linux kernel. Other payloads such as U-Boot or EDK-II should work
10*91f16700Schasingluluas well, but have not been tested at this point.
11*91f16700Schasinglulu
12*91f16700Schasinglulu**IMPORTANT NOTE**: This port isn't secure. All of the memory used is DRAM,
13*91f16700Schasingluluwhich is available from both the Non-secure and Secure worlds. The SoC does
14*91f16700Schasinglulunot seem to feature a secure memory controller of any kind, so portions of
15*91f16700SchasingluluDRAM can't be protected properly from the Non-secure world.
16*91f16700Schasinglulu
17*91f16700SchasingluluBuild Instructions
18*91f16700Schasinglulu------------------
19*91f16700Schasinglulu
20*91f16700SchasingluluThere are no real configuration options at this point, so there is only
21*91f16700Schasingluluone universal binary (bl31.bin), which can be built with:
22*91f16700Schasinglulu
23*91f16700Schasinglulu.. code:: shell
24*91f16700Schasinglulu
25*91f16700Schasinglulu    CROSS_COMPILE=aarch64-linux-gnu- make PLAT=rpi4 DEBUG=1
26*91f16700Schasinglulu
27*91f16700SchasingluluCopy the generated build/rpi4/debug/bl31.bin to the SD card, adding an entry
28*91f16700Schasinglulustarting with ``armstub=``, then followed by the respective file name to
29*91f16700Schasinglulu``config.txt``. You should have AArch64 code in the file loaded as the
30*91f16700Schasinglulu"kernel", as BL31 will drop into AArch64/EL2 to the respective load address.
31*91f16700Schasingluluarm64 Linux kernels are known to work this way.
32*91f16700Schasinglulu
33*91f16700SchasingluluOther options that should be set in ``config.txt`` to properly boot 64-bit
34*91f16700Schasinglulukernels are:
35*91f16700Schasinglulu
36*91f16700Schasinglulu::
37*91f16700Schasinglulu
38*91f16700Schasinglulu    enable_uart=1
39*91f16700Schasinglulu    arm_64bit=1
40*91f16700Schasinglulu    enable_gic=1
41*91f16700Schasinglulu
42*91f16700SchasingluluThe BL31 code will patch the provided device tree blob in memory to advertise
43*91f16700SchasingluluPSCI support, also will add a reserved-memory node to the DT to tell the
44*91f16700Schasinglulunon-secure payload to not touch the resident TF-A code.
45*91f16700Schasinglulu
46*91f16700SchasingluluIf you connect a serial cable between the Mini UART and your computer, and
47*91f16700Schasingluluconnect to it (for example, with ``screen /dev/ttyUSB0 115200``) you should
48*91f16700Schasinglulusee some text from BL31, followed by the output of the EL2 payload.
49*91f16700SchasingluluThe command line provided is read from the ``cmdline.txt`` file on the SD card.
50*91f16700Schasinglulu
51*91f16700SchasingluluTF-A port design
52*91f16700Schasinglulu----------------
53*91f16700Schasinglulu
54*91f16700SchasingluluIn contrast to the existing Raspberry Pi 3 port this one here is a BL31-only
55*91f16700Schasingluluport, also it deviates quite a lot from the RPi3 port in many other ways.
56*91f16700SchasingluluThere is not so much difference between the two models, so eventually those
57*91f16700Schasinglulutwo could be (more) unified in the future.
58*91f16700Schasinglulu
59*91f16700SchasingluluAs with the previous models, the GPU and its firmware are the first entity to
60*91f16700Schasinglulurun after the SoC gets its power. The on-chip Boot ROM loads the next stage
61*91f16700Schasinglulu(bootcode.bin) from flash (EEPROM), which is again GPU code.
62*91f16700SchasingluluThis part knows how to access the MMC controller and how to parse a FAT
63*91f16700Schasinglulufilesystem, so it will load further components and configuration files
64*91f16700Schasinglulufrom the first FAT partition on the SD card.
65*91f16700Schasinglulu
66*91f16700SchasingluluTo accommodate this existing way of configuring and setting up the board,
67*91f16700Schasingluluwe use as much of this workflow as possible.
68*91f16700SchasingluluIf bootcode.bin finds a file called ``armstub8.bin`` on the SD card or it gets
69*91f16700Schasinglulupointed to such code by finding a ``armstub=`` key in ``config.txt``, it will
70*91f16700Schasingluluload this file to the beginning of DRAM (address 0) and execute it in
71*91f16700SchasingluluAArch64 EL3.
72*91f16700SchasingluluBut before doing that, it will also load a "kernel" and the device tree into
73*91f16700Schasinglulumemory. The load addresses have a default, but can also be changed by
74*91f16700Schasinglulusetting them in ``config.txt``. If the GPU firmware finds a magic value in the
75*91f16700Schasingluluarmstub image file, it will put those two load addresses in memory locations
76*91f16700Schasinglulunear the beginning of memory, where TF-A code picks them up.
77*91f16700Schasinglulu
78*91f16700SchasingluluTo keep things simple, we will just use the kernel load address as the BL33
79*91f16700Schasingluluentry point, also put the DTB address in the x0 register, as requested by
80*91f16700Schasingluluthe arm64 Linux kernel boot protocol. This does not necessarily mean that
81*91f16700Schasingluluthe EL2 payload needs to be a Linux kernel, a bootloader or any other kernel
82*91f16700Schasingluluwould work as well, as long as it can cope with having the DT address in
83*91f16700Schasingluluregister x0. If the payload has other means of finding the device tree, it
84*91f16700Schasinglulucould ignore this address as well.
85