blob: 6e83fd7303e964a38e59b91aa48ed3f33c724558 [file] [log] [blame]
Andre Przywarae6d5fee2019-07-22 10:31:10 +01001Raspberry Pi 4
2==============
3
4The `Raspberry Pi 4`_ is an inexpensive single-board computer that contains four
5Arm Cortex-A72 cores. Also in contrast to previous Raspberry Pi versions this
6model has a GICv2 interrupt controller.
7
8This port is a minimal port to support loading non-secure EL2 payloads such
9as a 64-bit Linux kernel. Other payloads such as U-Boot or EDK-II should work
10as well, but have not been tested at this point.
11
12**IMPORTANT NOTE**: This port isn't secure. All of the memory used is DRAM,
13which is available from both the Non-secure and Secure worlds. The SoC does
14not seem to feature a secure memory controller of any kind, so portions of
15DRAM can't be protected properly from the Non-secure world.
16
17Build Instructions
18------------------
19
20There are no real configuration options at this point, so there is only
21one universal binary (bl31.bin), which can be built with:
22
23.. code:: shell
24
Mark Dykesef3a4562020-01-08 20:37:18 +000025 CROSS_COMPILE=aarch64-linux-gnu- make PLAT=rpi4 DEBUG=1
Andre Przywarae6d5fee2019-07-22 10:31:10 +010026
Jan Kiszka9cc8cde2019-12-09 12:48:42 +010027Copy the generated build/rpi4/debug/bl31.bin to the SD card, adding an entry
28starting with ``armstub=``, then followed by the respective file name to
29``config.txt``. You should have AArch64 code in the file loaded as the
30"kernel", as BL31 will drop into AArch64/EL2 to the respective load address.
Andre Przywarae6d5fee2019-07-22 10:31:10 +010031arm64 Linux kernels are known to work this way.
32
33Other options that should be set in ``config.txt`` to properly boot 64-bit
34kernels are:
35
36::
37
38 enable_uart=1
39 arm_64bit=1
40 enable_gic=1
41
42The BL31 code will patch the provided device tree blob in memory to advertise
43PSCI support, also will add a reserved-memory node to the DT to tell the
44non-secure payload to not touch the resident TF-A code.
45
46If you connect a serial cable between the Mini UART and your computer, and
47connect to it (for example, with ``screen /dev/ttyUSB0 115200``) you should
48see some text from BL31, followed by the output of the EL2 payload.
49The command line provided is read from the ``cmdline.txt`` file on the SD card.
50
51TF-A port design
52----------------
53
54In contrast to the existing Raspberry Pi 3 port this one here is a BL31-only
55port, also it deviates quite a lot from the RPi3 port in many other ways.
56There is not so much difference between the two models, so eventually those
57two could be (more) unified in the future.
58
59As with the previous models, the GPU and its firmware are the first entity to
60run after the SoC gets its power. The on-chip Boot ROM loads the next stage
61(bootcode.bin) from flash (EEPROM), which is again GPU code.
62This part knows how to access the MMC controller and how to parse a FAT
David Horstmannb2cc35f2021-01-21 12:29:59 +000063filesystem, so it will load further components and configuration files
Andre Przywarae6d5fee2019-07-22 10:31:10 +010064from the first FAT partition on the SD card.
65
66To accommodate this existing way of configuring and setting up the board,
67we use as much of this workflow as possible.
68If bootcode.bin finds a file called ``armstub8.bin`` on the SD card or it gets
69pointed to such code by finding a ``armstub=`` key in ``config.txt``, it will
70load this file to the beginning of DRAM (address 0) and execute it in
71AArch64 EL3.
72But before doing that, it will also load a "kernel" and the device tree into
73memory. The load addresses have a default, but can also be changed by
74setting them in ``config.txt``. If the GPU firmware finds a magic value in the
75armstub image file, it will put those two load addresses in memory locations
76near the beginning of memory, where TF-A code picks them up.
77
78To keep things simple, we will just use the kernel load address as the BL33
79entry point, also put the DTB address in the x0 register, as requested by
80the arm64 Linux kernel boot protocol. This does not necessarily mean that
81the EL2 payload needs to be a Linux kernel, a bootloader or any other kernel
82would work as well, as long as it can cope with having the DT address in
83register x0. If the payload has other means of finding the device tree, it
84could ignore this address as well.