rpi4.rst 3.8 KB

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