Difference between revisions of "RK3399 boot sequence"

From PINE64
Jump to navigation Jump to search
(→‎Boot sequence details: add link to describe TPL)
Line 4: Line 4:
== Boot sequence details ==
== Boot sequence details ==


There are two types of internal memory inside RK3399:
There are two types of internal memory inside RK3399 that are used during boot:


* 32KB BootROM - containing a small program which loads initial bootloader. It supports loading it from SPI, eMMC, SD and USB OTG in so-called maskrom mode.  
* 32 KiB BootROM - containing a small program which loads initial bootloader. It supports loading it from SPI, eMMC, SD and USB OTG in so-called maskrom mode.  
* 200KB SRAM
* 200 KiB SRAM: 192 KiB main SRAM, 8 KiB PMU SRAM (used to resume from suspend-to-RAM)


Actual boot sequence:
Actual boot sequence for bootloaders derived from (mainline) U-Boot (including Tow-Boot):


1. BootROM loads U-Boot TPL into SRAM. Its [https://www.denx.de/wiki/pub/U-Boot/MiniSummitELCE2013/tpl-presentation.pdf job] is to initialize main system RAM.<br>
# BootROM loads U-Boot TPL into SRAM. Its [https://www.denx.de/wiki/pub/U-Boot/MiniSummitELCE2013/tpl-presentation.pdf job] is to initialize DRAM (main system memory).
2. Control goes back from U-Boot TPL to BootROM.<br>
# Control goes back from U-Boot TPL to BootROM.
3. BootROM loads U-Boot SPL.<br>
# BootROM loads U-Boot SPL into low DRAM.
4. U-Boot SPL loads ATF and U-Boot itself into main memory.<br>
# U-Boot SPL loads TF-A and U-Boot itself into DRAM, and certain parts of TF-A into main and PMU SRAM.
5. ATF runs U-Boot.<br>
# Control is given to TF-A, which then runs U-Boot in EL2.
6. U-Boot loads payload (eg. EFI binaries, grub). Direct Linux kernel load is also supported.
# U-Boot loads payload (eg. EFI binaries, grub). Direct Linux kernel load is also supported.<br>U-Boot can boot from many sources - eMMC, SD, USB, NVMe.


U-boot can boot from many sources - eMMC, SD, USB, NVMe.
U-Boot-based bootloaders usually come in 2 images:


'''idbloader.img''' contains TPL and SPL.<br>
* '''idbloader.img''' contains TPL and SPL.
'''u-boot.itb''' contains ATF and U-Boot.
* '''u-boot.itb''' contains TF-A and U-Boot.


== Description ==
== Description ==

Revision as of 13:52, 25 April 2022

Rockchip RK3399 boot sequence

This is for the Pine64 ROCKPro64 single board computer, and the Pinebook Pro laptop boot sequence details. While some of this may also apply to other RK3399 computers, that is up to the reader to make any appropriate changes.

Boot sequence details

There are two types of internal memory inside RK3399 that are used during boot:

  • 32 KiB BootROM - containing a small program which loads initial bootloader. It supports loading it from SPI, eMMC, SD and USB OTG in so-called maskrom mode.
  • 200 KiB SRAM: 192 KiB main SRAM, 8 KiB PMU SRAM (used to resume from suspend-to-RAM)

Actual boot sequence for bootloaders derived from (mainline) U-Boot (including Tow-Boot):

  1. BootROM loads U-Boot TPL into SRAM. Its job is to initialize DRAM (main system memory).
  2. Control goes back from U-Boot TPL to BootROM.
  3. BootROM loads U-Boot SPL into low DRAM.
  4. U-Boot SPL loads TF-A and U-Boot itself into DRAM, and certain parts of TF-A into main and PMU SRAM.
  5. Control is given to TF-A, which then runs U-Boot in EL2.
  6. U-Boot loads payload (eg. EFI binaries, grub). Direct Linux kernel load is also supported.
    U-Boot can boot from many sources - eMMC, SD, USB, NVMe.

U-Boot-based bootloaders usually come in 2 images:

  • idbloader.img contains TPL and SPL.
  • u-boot.itb contains TF-A and U-Boot.

Description

There are 3 sections for the boot loader. They are in order, without gap, though their is no need to use all the space in each section.
Here are the details:

Start in
sectors
Size in
sectors
Name Description
64 16320 IDBLoader SoC initialization code
16384 8192 OS loader Generally U-Boot
24576 8192 TrustedFirmware-A  

General maintenance

If a new U-Boot is supplied, it is generally installed similar to this:

# dd if=/boot/idbloader.img conv=notrunc seek=64    of=/dev/mmcblkX
# dd if=/boot/u-boot.itb    conv=notrunc seek=16384 of=/dev/mmcblkX

Different devices

The RK3399 boots to multiple devices. Boot device selection is done in the following order, and it cannot be changed.
If a device is blank / unused, the SoC code moves on to the next device in the list.

  • SPI
  • eMMC
  • SD card

However, whence the user boot code runs, it can then give priority to other devices, if available. The following devices are not directly bootable:

  • NVMe
  • USB 3
  • WiFi

They can be made bootable by using one of the other devices as an initial bootloader. For example, several people have gotten their NVMe drives to be bootable with "/boot" and "/" on the NMVe. This either entails using the SPI or eMMC as the initial bootloader, with code to support PCIe NVMe devices.

Boot loader development

There are several projects that have their own versions of U-Boot, with different features. Here are some of the more common ones at present, 2020/06/14:

  • Rockchip
  • The original default Debian
  • Manjaro
  • U-Boot mainline

Grub as the target of the bootloader

It is possible to use Grub as the target of U-Boot. This would allow;

  • Selecting a different boot device
  • Choosing a partition on a boot device for booting
  • Different kernels
  • Changes in kernel command line options

However, at present, Grub does not support the video & keyboard of the Pinebook Pro. So, any selection is done through the serial console.