Difference between revisions of "Boot option"

From Rockchip open source Document
Jump to: navigation, search
(Adjust the organization of the SPL and u-boot sections, following the boot order.)
(26 intermediate revisions by 4 users not shown)
Line 3: Line 3:
  
 
 
 
 
 +
 +
 
 +
 +
 
 +
  
 
= Boot introduce =
 
= Boot introduce =
Line 12: Line 17:
 
Then we need to know about how the image should packaged, where the image locate;
 
Then we need to know about how the image should packaged, where the image locate;
  
At lase, we will explain how to write to different media and boot from there.
+
At last, we will explain how to write to different media and boot from there.
 +
 
 +
Here is Rockchip pre-released binaries which may be mentioned later:
 +
 
 +
[https://github.com/rockchip-linux/rkbin https://github.com/rockchip-linux/rkbin]
 +
 
 +
And [http://opensource.rock-chips.com/wiki_Partitions Rockcip Linux GPT partition] here.
  
 
 
 
 
  
== Boot stage ==
+
== Boot flow ==
  
 
Here is a table show the detail what we may use in Rockchip platform, for 2 boot stage:
 
Here is a table show the detail what we may use in Rockchip platform, for 2 boot stage:
Line 22: Line 33:
 
- use U-Boot SPL;
 
- use U-Boot SPL;
  
-  use Rockchp idbLoader which is combinded by Rockchip ddr init bin and miniloader bin;
+
- use Rockchp idbLoader which is combinded by Rockchip ddr init bin and miniloader bin;
 
<pre>+--------+----------------+----------+-------------+---------+
 
<pre>+--------+----------------+----------+-------------+---------+
 
| Boot  | Terminology #1 | Actual  | Rockchip    |        |
 
| Boot  | Terminology #1 | Actual  | Rockchip    |        |
Line 32: Line 43:
 
|        |  Loader        |          |            |        |
 
|        |  Loader        |          |            |        |
 
|        |                |          |            |        |
 
|        |                |          |            |        |
| 2      |  Secondary    | U-Boot  |idbloader.img| 0x40    |
+
| 2      |  Secondary    | U-Boot  |idbloader.img| 0x40    |including u-boot if not use miniloader
 
|        |  Program      | SPL      |idbspl.img  |        |
 
|        |  Program      | SPL      |idbspl.img  |        |
 
|        |  Loader (SPL)  |          |            |        |
 
|        |  Loader (SPL)  |          |            |        |
 
|        |                |          |            |        |
 
|        |                |          |            |        |
| 3      |  -            | U-Boot  | bl3.itb     | 0x200  | including bl31 and u-boot
+
| 3      |  -            | U-Boot  | u-boot.itb | 0x4000  | including u-boot and atf
|        |                |          | u-boot.bin  | 0x200  |
+
|        |                |          | u-boot.bin  | 0x4000  |
|        |                |          | uboot.img  | 0x4000  | only used with rk miniloader
+
|        |                |          | uboot.img  | 0x4000  | only used with miniloader
 
|        |                |          |            |        |
 
|        |                |          |            |        |
|        |                | atf     | trust.img  | 0x6000  | only used with rk miniloader for armv8
+
|        |                | ATF     | trust.img  | 0x6000  | only used with miniloader for armv8
 
|        |                |          |            |        |
 
|        |                |          |            |        |
 
| 4      |  -            | kernel  | boot.img    | 0x8000  |
 
| 4      |  -            | kernel  | boot.img    | 0x8000  |
Line 56: Line 67:
 
*Boot from U-Disk means firmware for stage 4 and 5(not including SPL and U-Boot) in Disk, optionally only including stage 5;  
 
*Boot from U-Disk means firmware for stage 4 and 5(not including SPL and U-Boot) in Disk, optionally only including stage 5;  
 
*Boot from net/tftp means firmeware for stage 4 and 5(not including SPL and U-Boot) on the network;  
 
*Boot from net/tftp means firmeware for stage 4 and 5(not including SPL and U-Boot) on the network;  
 +
 +
&nbsp;
 +
 +
[[File:Rockchip bootflow.jpg|1000x1000px|Rockchip bootflow.jpg]]
 +
 +
Boot Flow 1 is typical Rockchip boot flow with Rockchip miniloader;<br/> Boot Flow 2 is used for most SoCs with U-Boot TPL for ddr init and SPL for trust(ATF/OP-TEE) load and run into next stage;<br/> Boot Flow 3 is use only for RK3399 with SPL ATF support;<br/> Boot Flow 4 is used for armv7 SoCs which do not support trust;<br/> <br/> Note 1. If loader1 have more than 1 stage, program will back to bootrom and bootrom load and run into next stage. eg. If loader1 is tpl and spl, the bootrom will run into tpl first, tpl init ddr and back to bootrom, bootrom then load and run into spl.<br/> Note 2. If trust is enabled, loader1 need to load both trust and u-boot, and then run into trust in secure mode(EL3 in armv8), trust do the initialize and run into U-Boot in non-secure mode(EL2 in armv8).<br/> Note 3. For trust(in trust.img or u-boot.itb), armv7 has only one tee.bin with or without ta, armv8 has bl31.elf and option with bl32.<br/> Note 4. In boot.img, content can be zImage and its dtb for Linux, and can optionally be grub.efi, and can be AOSP boot.img, ramdisk is option;
 +
 +
 +
 +
  
 
== Package option ==
 
== Package option ==
Line 64: Line 85:
  
 
*From source code:  
 
*From source code:  
**From U-Boot: u-boot-spl.bin, u-boot.bin(may use u-boot-nodtb.bin and u-boot.dtb instead),  
+
**From U-Boot: '''u-boot-spl.bin''', '''u-boot.bin'''(may use u-boot-nodtb.bin and u-boot.dtb instead),  
**From kernel: kernel Image/zImage file, kernel dtb,  
+
**From kernel: kernel '''Image/zImage''' file, kernel dtb,  
**From ATF: bl31.bin;   
+
**From ATF: '''bl31.elf''';   
 
*From Rockchip binary:  
 
*From Rockchip binary:  
**ddr, usbplug, miniloader, bl31, (all with&nbsp;chip 'rkxx_'&nbsp; prefix and with version '_x.xx.bin' postfix);   
+
**ddr, usbplug, miniloader, bl31/op-tee, (all with&nbsp;chip 'rkxx_'&nbsp; prefix and with version '_x.xx.bin' postfix);   
  
Here are the types to&nbsp;package image from those files:
+
We offer two different boot-loader methods for different solutions, the steps and request files are also complete different. But not all the platforms supports the both boot-loader methods. Here are the types to&nbsp;package image from those files:
  
=== idbspl.img ===
+
=== The Pre-bootloader(TBL/SPL) ===
 +
 
 +
==== idbspl.img ====
  
 
U-Boot SPL, with&nbsp;SPL_BACK_TO_BROM option '''disabled'''.
 
U-Boot SPL, with&nbsp;SPL_BACK_TO_BROM option '''disabled'''.
Line 79: Line 102:
 
Flash the idbspl.img to offset 0x40 which only including stage 2, and need flash stage 3 &nbsp;image to 0x200(which is defineded by CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR), the stage 3 image may be&nbsp;u-boot.bin directly(when there no ATF requirement), or FIT image bl3.itb(for ATF load from SPL, including bl31.bin, u-boot-nodtb.bin and u-boot.dtb).
 
Flash the idbspl.img to offset 0x40 which only including stage 2, and need flash stage 3 &nbsp;image to 0x200(which is defineded by CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR), the stage 3 image may be&nbsp;u-boot.bin directly(when there no ATF requirement), or FIT image bl3.itb(for ATF load from SPL, including bl31.bin, u-boot-nodtb.bin and u-boot.dtb).
  
=== idbloader.img ===
+
&nbsp;
 +
 
 +
==== idbloader.img ====
  
 
U-Boot SPL, with&nbsp;SPL_BACK_TO_BROM option '''enabled''':
 
U-Boot SPL, with&nbsp;SPL_BACK_TO_BROM option '''enabled''':
Line 86: Line 111:
  
 
Flash the idbloader.img to offset 0x40 which including boot stage 2 and 3.
 
Flash the idbloader.img to offset 0x40 which including boot stage 2 and 3.
 +
 +
==== Rockchip Miniloader ====
  
 
Package the image from Rockchip binary:
 
Package the image from Rockchip binary:
 +
<pre>dd if=rkxx_ddr_vx.xx.bin of=ddr.bin bs=4 skip=1
 +
tools/mkimage -n rkxxxx -T rksd -d ddr.bin idbloader.img
 +
rm ddr.bin
 +
cat rkxx_miniloader_vx.xx.bin >> idbloader.img</pre>
 +
 +
The ddr binary files for ARM64 platforms from Rockchip, likes RK3399 and RK3328 should not skip first 4 bytes.
 
<pre>tools/mkimage -n rkxxxx -T rksd -d rkxx_ddr_vx.xx.bin idbloader.img
 
<pre>tools/mkimage -n rkxxxx -T rksd -d rkxx_ddr_vx.xx.bin idbloader.img
 +
rm ddr.bin
 
cat rkxx_miniloader_vx.xx.bin >> idbloader.img</pre>
 
cat rkxx_miniloader_vx.xx.bin >> idbloader.img</pre>
  
 
Flash the idbloader.img to offset 0x40 which including stage 2, and you will need a uboot.img for boot stage 3.
 
Flash the idbloader.img to offset 0x40 which including stage 2, and you will need a uboot.img for boot stage 3.
  
=== bl3.itb ===
+
=== U-Boot ===
  
When using SPL to load the ATF, package the bl31.bin, u-boot-nodtb.bin and uboot.dtb into one FIT image.
+
==== u-boot.itb ====
<pre>tools/mkimage -f fit4spl.its -E bl3.itb
+
 
 +
When using SPL to load the ATF/OP-TEE, package the bl31.bin, u-boot-nodtb.bin and uboot.dtb into one FIT image. You can skip the step to package the Trust image and flash that image in the next section.
 +
<pre>make u-boot.itb
 
</pre>
 
</pre>
  
Flash the bl3.itb to offset 0x200, while&nbsp;need idbspl.img flasht to offset 0x40.
+
Note: please copy the trust binary() to u-boot root directory and rename it to tee.bin(armv7) or bl31.elf(armv8).
  
=== uboot.img ===
+
Flash the u-boot.itb to offset 0x4000, while&nbsp;need idbspl.img flash&nbsp;to offset 0x40.
 +
 
 +
==== uboot.img ====
  
 
When using idbLoader from&nbsp;Rockchip miniloader, need package u-boot.bin into miniloader loadable format by Rockchip tool loaderimage.
 
When using idbLoader from&nbsp;Rockchip miniloader, need package u-boot.bin into miniloader loadable format by Rockchip tool loaderimage.
Line 108: Line 146:
 
Flash the uboot.img to offset 0x4000 which is stage 3;
 
Flash the uboot.img to offset 0x4000 which is stage 3;
  
=== trust.img ===
+
=== Trust ===
  
 
When using idbLoader from&nbsp;Rockchip miniloader, need package bl31.bin into miniloader loadable format by Rockchip tool trustmerge.
 
When using idbLoader from&nbsp;Rockchip miniloader, need package bl31.bin into miniloader loadable format by Rockchip tool trustmerge.
Line 114: Line 152:
  
 
Flash the trust.img to offset 0x6000 which is for using Rockchip miniloader
 
Flash the trust.img to offset 0x6000 which is for using Rockchip miniloader
 
&nbsp;
 
 
=== rkxx_loader_vx.xx.xxx.bin ===
 
 
This is provide by Rockchip in binary mode, which is used for firmware upgrade to eMMC with [[Rkdevelptool|rkdeveloptool]], can not be wirte to media device directly.
 
 
This is a package from ddr.bin, usbplug.bin, miniloader.bin, Rockchip tool ''DB ''command will make usbplug.bin running in target which perform as a Rockusb device.
 
  
 
=== boot.img ===
 
=== boot.img ===
Line 133: Line 163:
 
=== rootfs.img ===
 
=== rootfs.img ===
  
Flash the rootfs.img to offset 0x40000 which is stage 5.
+
Flash the rootfs.img to offset 0x40000 which is stage 5. As long as the kernel you chosen can support that filesystem, there is not limit in the format of the image.
 +
 
 +
=== rkxx_loader_vx.xx.xxx.bin ===
 +
 
 +
This is provide by Rockchip in binary mode, which is used for firmware upgrade to eMMC with [[Rkdeveloptool|rkdeveloptool]], can not be wirte to media device directly.
  
&nbsp;
+
This is a package from ddr.bin, usbplug.bin, miniloader.bin, Rockchip tool ''DB ''command will make usbplug.bin running in target which perform as a Rockusb device. You can skip to package this image, Rockchip will offer this image at the most of time.
  
 
= Flash and boot from Media device =
 
= Flash and boot from Media device =
Line 168: Line 202:
 
**boot.img or&nbsp;boot folder with Image, dtb and exitlinulx inside  
 
**boot.img or&nbsp;boot folder with Image, dtb and exitlinulx inside  
 
**rootfs.img   
 
**rootfs.img   
 +
 +
&nbsp;
 +
 +
&nbsp;
  
 
&nbsp;
 
&nbsp;
Line 177: Line 215:
 
*Get the board into [[Rockusb#Maskrom_mode|maskrom mode]];  
 
*Get the board into [[Rockusb#Maskrom_mode|maskrom mode]];  
 
*Connect the target to PC with USB cable;  
 
*Connect the target to PC with USB cable;  
*Flash the image to eMMC with [[Rkdevelptool|rkdeveloptool]]  
+
*Flash the image to eMMC with [[Rkdeveloptool|rkdeveloptool]]  
  
 
Example commands for flash image to target.
 
Example commands for flash image to target.
 +
 +
Flash the gpt partition to target:
 +
<pre style="margin-left: 40px;">rkdeveloptool db rkxx_loader_vx.xx.bin
 +
rkdeveloptool gpt parameter_gpt.txt</pre>
  
 
*For armv7 with SPL with SPL_BACK_TO_BROM option enabled(rk3036, rk3188, rk3288):  
 
*For armv7 with SPL with SPL_BACK_TO_BROM option enabled(rk3036, rk3188, rk3288):  
Line 223: Line 265:
 
rkdeveloptool wl 0x8000 boot.img
 
rkdeveloptool wl 0x8000 boot.img
 
rkdeveloptool wl 0x40000 rootfs.img
 
rkdeveloptool wl 0x40000 rootfs.img
rkdeveloptool r</pre>
+
rkdeveloptool rd</pre>
 +
 
 +
&nbsp;
  
 
&nbsp;
 
&nbsp;
Line 234: Line 278:
  
 
*For armv7 with SPL with SPL_BACK_TO_BROM option enabled(rk3036, rk3188, rk3288):  
 
*For armv7 with SPL with SPL_BACK_TO_BROM option enabled(rk3036, rk3188, rk3288):  
<pre style="margin-left: 40px">dd if=idbloader.img of=sdb seek=0x40
+
<pre style="margin-left: 40px">dd if=idbloader.img of=sdb seek=64
dd if=boot.img of=sdb seek=0x8000
+
dd if=boot.img of=sdb seek=32768
dd if=rootfs.img of=sdb seek=0x40000
+
dd if=rootfs.img of=sdb seek=262144
 
</pre>
 
</pre>
  
 
*For armv7 with SPL with SPL_BACK_TO_BROM option disabled(rk3288):  
 
*For armv7 with SPL with SPL_BACK_TO_BROM option disabled(rk3288):  
<pre style="margin-left: 40px">dd if=idbspl.img of=sdb seek=0x40
+
<pre style="margin-left: 40px">dd if=idbspl.img of=sdb seek=64
dd if=u-boot.bin of=sdb seek=0x200
+
dd if=u-boot.bin of=sdb seek=512
dd if=boot.img of=sdb seek=0x8000
+
dd if=boot.img of=sdb seek=32768
dd if=rootfs.img of=sdb seek=0x40000
+
dd if=rootfs.img of=sdb seek=262144
 
</pre>
 
</pre>
  
 
*For armv7 with miniloader(rk3036, rk3188, rk3288)  
 
*For armv7 with miniloader(rk3036, rk3188, rk3288)  
<pre style="margin-left: 40px">dd if=idbloader.img of=sdb seek=0x40
+
<pre style="margin-left: 40px">dd if=idbloader.img of=sdb seek=64
dd if=uboot.img of=sdb seek=0x4000
+
dd if=uboot.img of=sdb seek=16384
dd if=boot.img of=sdb seek=0x8000
+
dd if=boot.img of=sdb seek=32768
dd if=rootfs.img of=sdb seek=0x40000
+
dd if=rootfs.img of=sdb seek=262144
 
</pre>
 
</pre>
  
 
*For armv8 with SPL(rk3399):  
 
*For armv8 with SPL(rk3399):  
<pre style="margin-left: 40px">dd if=idbspl.img of=sdb seek=0x40
+
<pre style="margin-left: 40px">dd if=idbspl.img of=sdb seek=64
dd if=bl3.itb of=sdb seek=0x200
+
dd if=bl3.itb of=sdb seek=512
dd if=boot.img of=sdb seek=0x8000
+
dd if=boot.img of=sdb seek=32768
dd if=rootfs.img of=sdb seek=0x40000
+
dd if=rootfs.img of=sdb seek=262144
 
</pre>
 
</pre>
  
 
*For armv8 with miniloader(rk3399, rk3328)  
 
*For armv8 with miniloader(rk3399, rk3328)  
<pre style="margin-left: 40px">dd if=idbloader.img of=sdb seek=0x40
+
<pre style="margin-left: 40px">dd if=idbloader.img of=sdb seek=64
dd if=uboot.img of=sdb seek=0x4000
+
dd if=uboot.img of=sdb seek=16384
dd if=trust.img of=sdb seek=0x6000
+
dd if=trust.img of=sdb seek=24576
dd if=boot.img of=sdb seek=0x8000
+
dd if=boot.img of=sdb seek=32768
dd if=rootfs.img of=sdb seek=0x40000</pre>
+
dd if=rootfs.img of=sdb seek=262144</pre>
  
 
In order to make sure everything has write to SD card before unpluged, recommand to run below command:
 
In order to make sure everything has write to SD card before unpluged, recommand to run below command:
Line 291: Line 335:
 
</pre>
 
</pre>
  
= Boot from Network =
+
== Boot from Network ==
  
 
&nbsp;
 
&nbsp;
 +
 +
&nbsp;
 +
 +
= See also =
 +
 +
[[Rkdeveloptool|rkdeveloptool]]
 +
 +
[[Rockusb|rockusb]]
 +
 +
[[Partitions|Rockchip Linux partition definition]]

Revision as of 02:40, 7 December 2017

 

 

 

 


Boot introduce

 

First, let's make the concept clear, there are many boot stages when we boot up a Linux OS;

Then we need to know about how the image should packaged, where the image locate;

At last, we will explain how to write to different media and boot from there.

Here is Rockchip pre-released binaries which may be mentioned later:

https://github.com/rockchip-linux/rkbin

And Rockcip Linux GPT partition here.

 

Boot flow

Here is a table show the detail what we may use in Rockchip platform, for 2 boot stage:

- use U-Boot SPL;

- use Rockchp idbLoader which is combinded by Rockchip ddr init bin and miniloader bin;

+--------+----------------+----------+-------------+---------+
| Boot   | Terminology #1 | Actual   | Rockchip    |         |
| stage  |                | program  |  Image      |         |
| number |                | name     |   Name      |         |
+--------+----------------+----------+-------------+---------+
| 1      |  Primary       | ROM code | BootRom     |         |
|        |  Program       |          |             |         |
|        |  Loader        |          |             |         |
|        |                |          |             |         |
| 2      |  Secondary     | U-Boot   |idbloader.img| 0x40    |including u-boot if not use miniloader
|        |  Program       | SPL      |idbspl.img   |         |
|        |  Loader (SPL)  |          |             |         |
|        |                |          |             |         |
| 3      |  -             | U-Boot   | u-boot.itb  | 0x4000  | including u-boot and atf
|        |                |          | u-boot.bin  | 0x4000  |
|        |                |          | uboot.img   | 0x4000  | only used with miniloader
|        |                |          |             |         |
|        |                | ATF      | trust.img   | 0x6000  | only used with miniloader for armv8
|        |                |          |             |         |
| 4      |  -             | kernel   | boot.img    | 0x8000  |
|        |                |          |             |         |
| 5      |  -             | rootfs   | rootfs.img  | 0x40000 |
+--------+----------------+----------+-------------+---------+

Then when we talking about boot from eMMC/SD/U-Disk/net, they are in different concept:

  • Stage 1 is always in boot rom, it loads stage 2 and may load stage 3(when SPL_BACK_TO_BROM option enabled).
  • Boot from SPI flash means firmware for stage 2 and 3(SPL and U-Boot only) in SPI flash and stage 4/5 in other place;
  • Boot from eMMC means all the firmware(including stage 2, 3, 4, 5) in eMMC;
  • Boot from SD card means all the firmware(including stage 2, 3, 4, 5) in SD card;
  • Boot from U-Disk means firmware for stage 4 and 5(not including SPL and U-Boot) in Disk, optionally only including stage 5;
  • Boot from net/tftp means firmeware for stage 4 and 5(not including SPL and U-Boot) on the network;

 

Rockchip bootflow.jpg

Boot Flow 1 is typical Rockchip boot flow with Rockchip miniloader;
Boot Flow 2 is used for most SoCs with U-Boot TPL for ddr init and SPL for trust(ATF/OP-TEE) load and run into next stage;
Boot Flow 3 is use only for RK3399 with SPL ATF support;
Boot Flow 4 is used for armv7 SoCs which do not support trust;

Note 1. If loader1 have more than 1 stage, program will back to bootrom and bootrom load and run into next stage. eg. If loader1 is tpl and spl, the bootrom will run into tpl first, tpl init ddr and back to bootrom, bootrom then load and run into spl.
Note 2. If trust is enabled, loader1 need to load both trust and u-boot, and then run into trust in secure mode(EL3 in armv8), trust do the initialize and run into U-Boot in non-secure mode(EL2 in armv8).
Note 3. For trust(in trust.img or u-boot.itb), armv7 has only one tee.bin with or without ta, armv8 has bl31.elf and option with bl32.
Note 4. In boot.img, content can be zImage and its dtb for Linux, and can optionally be grub.efi, and can be AOSP boot.img, ramdisk is option;



Package option

After we know about the boot stages,

Here are the file list before package for stage 2~4:

  • From source code:
    • From U-Boot: u-boot-spl.bin, u-boot.bin(may use u-boot-nodtb.bin and u-boot.dtb instead),
    • From kernel: kernel Image/zImage file, kernel dtb,
    • From ATF: bl31.elf;
  • From Rockchip binary:
    • ddr, usbplug, miniloader, bl31/op-tee, (all with chip 'rkxx_'  prefix and with version '_x.xx.bin' postfix);

We offer two different boot-loader methods for different solutions, the steps and request files are also complete different. But not all the platforms supports the both boot-loader methods. Here are the types to package image from those files:

The Pre-bootloader(TBL/SPL)

idbspl.img

U-Boot SPL, with SPL_BACK_TO_BROM option disabled.

mkimage -n rkxxxx -T rksd -d spl/u-boot-spl.bin idbspl.img

Flash the idbspl.img to offset 0x40 which only including stage 2, and need flash stage 3  image to 0x200(which is defineded by CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR), the stage 3 image may be u-boot.bin directly(when there no ATF requirement), or FIT image bl3.itb(for ATF load from SPL, including bl31.bin, u-boot-nodtb.bin and u-boot.dtb).

 

idbloader.img

U-Boot SPL, with SPL_BACK_TO_BROM option enabled:

tools/mkimage -n rkxxxx -T rksd -d spl/u-boot-spl.bin idbloader.img
cat u-boot.bin >> idbloader.img

Flash the idbloader.img to offset 0x40 which including boot stage 2 and 3.

Rockchip Miniloader

Package the image from Rockchip binary:

dd if=rkxx_ddr_vx.xx.bin of=ddr.bin bs=4 skip=1
tools/mkimage -n rkxxxx -T rksd -d ddr.bin idbloader.img
rm ddr.bin
cat rkxx_miniloader_vx.xx.bin >> idbloader.img

The ddr binary files for ARM64 platforms from Rockchip, likes RK3399 and RK3328 should not skip first 4 bytes.

tools/mkimage -n rkxxxx -T rksd -d rkxx_ddr_vx.xx.bin idbloader.img
rm ddr.bin
cat rkxx_miniloader_vx.xx.bin >> idbloader.img

Flash the idbloader.img to offset 0x40 which including stage 2, and you will need a uboot.img for boot stage 3.

U-Boot

u-boot.itb

When using SPL to load the ATF/OP-TEE, package the bl31.bin, u-boot-nodtb.bin and uboot.dtb into one FIT image. You can skip the step to package the Trust image and flash that image in the next section.

make u-boot.itb

Note: please copy the trust binary() to u-boot root directory and rename it to tee.bin(armv7) or bl31.elf(armv8).

Flash the u-boot.itb to offset 0x4000, while need idbspl.img flash to offset 0x40.

uboot.img

When using idbLoader from Rockchip miniloader, need package u-boot.bin into miniloader loadable format by Rockchip tool loaderimage.

tools/loaderimage --pack --uboot u-boot.bin uboot.img

Flash the uboot.img to offset 0x4000 which is stage 3;

Trust

When using idbLoader from Rockchip miniloader, need package bl31.bin into miniloader loadable format by Rockchip tool trustmerge.

tools/trustmerge tools/rk_tools/RKTRUST_RKXXXXTRUST.ini

Flash the trust.img to offset 0x6000 which is for using Rockchip miniloader

boot.img

This image is package the kernel Image and dtb file into a know filesystem(FAT or EXT2) image for distro boot.

See Install kernel for detail about generate boot.img from kernel zImage/Image, dtb.

Flash the boot.img to offset 0x8000 which is stage 4.

rootfs.img

Flash the rootfs.img to offset 0x40000 which is stage 5. As long as the kernel you chosen can support that filesystem, there is not limit in the format of the image.

rkxx_loader_vx.xx.xxx.bin

This is provide by Rockchip in binary mode, which is used for firmware upgrade to eMMC with rkdeveloptool, can not be wirte to media device directly.

This is a package from ddr.bin, usbplug.bin, miniloader.bin, Rockchip tool DB command will make usbplug.bin running in target which perform as a Rockusb device. You can skip to package this image, Rockchip will offer this image at the most of time.

Flash and boot from Media device

Here we introduce how to write image to different Medeia device.

Get image Ready:

  • For armv7 with SPL with SPL_BACK_TO_BROM option enabled:
    • idbLoader.img
    • boot.img or boot folder with zImage, dtb and exitlinulx inside
    • rootfs.img
  • For armv7 with SPL with SPL_BACK_TO_BROM option disabled:
    • idbspl.img
    • u-boot.bin
    • boot.img or boot folder with zImage, dtb and exitlinulx inside
    • rootfs.img
  • For armv7 with miniloader
    • idbLoader.img
    • uboot.img
    • boot.img or boot folder with zImage, dtb and exitlinulx inside
    • rootfs.img
  • For armv8 with SPL:
    • idbspl.img
    • bl3.itb
    • boot.img or boot folder with Image, dtb and exitlinulx inside
    • rootfs.img
  • For armv8 with miniloader
    • idbLoader.img
    • uboot.img
    • trust.img
    • boot.img or boot folder with Image, dtb and exitlinulx inside
    • rootfs.img

 

 

 

Boot from eMMC

The eMMC is on the hardware board, so we need:

Example commands for flash image to target.

Flash the gpt partition to target:

rkdeveloptool db rkxx_loader_vx.xx.bin
rkdeveloptool gpt parameter_gpt.txt
  • For armv7 with SPL with SPL_BACK_TO_BROM option enabled(rk3036, rk3188, rk3288):
rkdeveloptool db rkxx_loader_vx.xx.bin
rkdeveloptool wl 0x40 idbloader.img
rkdeveloptool wl 0x8000 boot.img
rkdeveloptool wl 0x40000 rootfs.img
rkdeveloptool rd
  • For armv7 with SPL with SPL_BACK_TO_BROM option disabled(rk3288):
rkdeveloptool db rkxx_loader_vx.xx.bin
rkdeveloptool wl 0x40 idbspl.img
rkdeveloptool wl 0x200 u-boot.bin
rkdeveloptool wl 0x8000 boot.img
rkdeveloptool wl 0x40000 rootfs.img
rkdeveloptool rd
  • For armv7 with miniloader(rk3036, rk3188, rk3288)
rkdeveloptool db rkxx_loader_vx.xx.bin
rkdeveloptool wl 0x40 idbloader.img
rkdeveloptool wl 0x4000 uboot.img
rkdeveloptool wl 0x8000 boot.img
rkdeveloptool wl 0x40000 rootfs.img
rkdeveloptool rd
  • For armv8 with SPL(rk3399):
rkdeveloptool db rkxx_loader_vx.xx.bin
rkdeveloptool wl 0x40 idbspl.img
rkdeveloptool wl 0x200 bl3.itb
rkdeveloptool wl 0x8000 boot.img
rkdeveloptool wl 0x40000 rootfs.img
rkdeveloptool rd
  • For armv8 with miniloader(rk3399, rk3328)
rkdeveloptool db rkxx_loader_vx.xx.bin
rkdeveloptool wl 0x40 idbloader.img
rkdeveloptool wl 0x4000 uboot.img
rkdeveloptool wl 0x6000 trust.img
rkdeveloptool wl 0x8000 boot.img
rkdeveloptool wl 0x40000 rootfs.img
rkdeveloptool rd

 

 

Boot from SD/TF Card

We can write SD/TF card with Linux PC dd command very easily.

Insert SD card to PC and we assume the /dev/sdb is the SD card device.

  • For armv7 with SPL with SPL_BACK_TO_BROM option enabled(rk3036, rk3188, rk3288):
dd if=idbloader.img of=sdb seek=64
dd if=boot.img of=sdb seek=32768
dd if=rootfs.img of=sdb seek=262144
  • For armv7 with SPL with SPL_BACK_TO_BROM option disabled(rk3288):
dd if=idbspl.img of=sdb seek=64
dd if=u-boot.bin of=sdb seek=512
dd if=boot.img of=sdb seek=32768
dd if=rootfs.img of=sdb seek=262144
  • For armv7 with miniloader(rk3036, rk3188, rk3288)
dd if=idbloader.img of=sdb seek=64
dd if=uboot.img of=sdb seek=16384
dd if=boot.img of=sdb seek=32768
dd if=rootfs.img of=sdb seek=262144
  • For armv8 with SPL(rk3399):
dd if=idbspl.img of=sdb seek=64
dd if=bl3.itb of=sdb seek=512
dd if=boot.img of=sdb seek=32768
dd if=rootfs.img of=sdb seek=262144
  • For armv8 with miniloader(rk3399, rk3328)
dd if=idbloader.img of=sdb seek=64
dd if=uboot.img of=sdb seek=16384
dd if=trust.img of=sdb seek=24576
dd if=boot.img of=sdb seek=32768
dd if=rootfs.img of=sdb seek=262144

In order to make sure everything has write to SD card before unpluged, recommand to run below command:

sync

Note, when using boot from SD card, need to update the kernel cmdline(which is in extlinux.conf) for the correct root value.

append  earlyprintk console=ttyS2,115200n8 rw root=/dev/mmcblk1p7 rootwait rootfstype=ext4 init=/sbin/init

Write GPT partition table to SD card in U-Boot, and then U-Boot can find the boot partition and run into kernel.

gpt write mmc 0 $partitions

 

Boot from U-Disk

Same as boot-from-sdcard, but please note that U-Disk only support stage 4 and 5, see Boot Stage for detail.

If U-Disk used for stage 4 and 5, format the U-Disk in gpt format and at least 2 partitions, write boot.img and rootfs.img in those partitions;

if U-Dist is only used for stage 5, we can dd the rootfs.img to U-Disk device directly.

Note, need to update the kernel cmdline(which is in extlinux.conf) for the correct root value.

    append  earlyprintk console=ttyS2,115200n8 rw root=/dev/sda1 rootwait rootfstype=ext4 init=/sbin/init

Boot from Network

 

 

See also

rkdeveloptool

rockusb

Rockchip Linux partition definition