Difference between revisions of "U-Boot"

From Rockchip open source Document
Jump to: navigation, search
Line 1: Line 1:
 
U-Boot Guide
 
 
== Contents ==
 
 
 [[[hide]]] 
 
 
*[http://opensource.rock-chips.com/index.php?title=U-Boot&oldid=1551#Download_U-Boot 1Download U-Boot]
 
**[http://opensource.rock-chips.com/index.php?title=U-Boot&oldid=1551#Upstream_U-Boot 1.1Upstream U-Boot]
 
**[http://opensource.rock-chips.com/index.php?title=U-Boot&oldid=1551#Rockchip_U-Boot 1.2Rockchip U-Boot] 
 
*[http://opensource.rock-chips.com/index.php?title=U-Boot&oldid=1551#Supported_Devices 2Supported Devices]
 
*[http://opensource.rock-chips.com/index.php?title=U-Boot&oldid=1551#Configure_U-Boot 3Configure U-Boot]
 
*[http://opensource.rock-chips.com/index.php?title=U-Boot&oldid=1551#Build_U-Boot 4Build U-Boot]
 
**[http://opensource.rock-chips.com/index.php?title=U-Boot&oldid=1551#Get_a_toolchain 4.1Get a toolchain]
 
**[http://opensource.rock-chips.com/index.php?title=U-Boot&oldid=1551#Build 4.2Build] 
 
*[http://opensource.rock-chips.com/index.php?title=U-Boot&oldid=1551#Install_U-Boot 5Install U-Boot]
 
**[http://opensource.rock-chips.com/index.php?title=U-Boot&oldid=1551#Using_U-Boot_SPL 5.1Using U-Boot SPL]
 
**[http://opensource.rock-chips.com/index.php?title=U-Boot&oldid=1551#Support_ATF_with_SPL_FIT_image 5.2Support ATF with SPL FIT image]
 
**[http://opensource.rock-chips.com/index.php?title=U-Boot&oldid=1551#Using_Rockchip_miniloader 5.3Using Rockchip miniloader]
 
**[http://opensource.rock-chips.com/index.php?title=U-Boot&oldid=1551#Boot_up 5.4Boot up] 
 
*[http://opensource.rock-chips.com/index.php?title=U-Boot&oldid=1551#Boot_cmd 6Boot cmd]
 
**[http://opensource.rock-chips.com/index.php?title=U-Boot&oldid=1551#Distro_boot 6.1Distro boot]
 
**[http://opensource.rock-chips.com/index.php?title=U-Boot&oldid=1551#EFI_boot 6.2EFI boot] 
 
*[http://opensource.rock-chips.com/index.php?title=U-Boot&oldid=1551#Firmware_download_in_U-Boot 7Firmware download in U-Boot]
 
**[http://opensource.rock-chips.com/index.php?title=U-Boot&oldid=1551#fastboot 7.1fastboot]
 
**[http://opensource.rock-chips.com/index.php?title=U-Boot&oldid=1551#ums 7.2ums]
 
**[http://opensource.rock-chips.com/index.php?title=U-Boot&oldid=1551#rockusb 7.3rockusb] 
 
  
 
= Download U-Boot =
 
= Download U-Boot =
Line 50: Line 23:
  
 
RK3036, RK3188, [http://opensource.rock-chips.com/wiki_RK3288 RK3288], [http://opensource.rock-chips.com/wiki_RK3328 RK3328], [http://opensource.rock-chips.com/wiki_RK3399 RK3399]
 
RK3036, RK3188, [http://opensource.rock-chips.com/wiki_RK3288 RK3288], [http://opensource.rock-chips.com/wiki_RK3328 RK3328], [http://opensource.rock-chips.com/wiki_RK3399 RK3399]
 
 
 
  
 
*RK3036 boards supported:  
 
*RK3036 boards supported:  
Line 81: Line 52:
 
#EVB RK3399 - use evb-rk3399 configuration  
 
#EVB RK3399 - use evb-rk3399 configuration  
  
 
+
= Get a toolchain =
 +
 
 +
If you haven't done so before, get a suitable toolchain installed and add it to your PATH.
 +
 
 +
In Ubuntu 14.04, you can use below command to install cross compiler for armv7:
 +
<pre>sudo apt-get install gcc-arm-linux-gnueabi</pre>
 +
 
 +
Or for ARM64
 +
<pre>sudo apt-get install gcc-aarch64-linux-gnu
 +
</pre>
  
&nbsp;
+
Note that the latest U-Boot require version gcc-5.0 and later, we recommand to use linaro 6.3.1.
 +
<pre>https://github.com/rockchip-linux/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf.git</pre>
 +
<pre>https://github.com/rockchip-linux/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu.git</pre>
  
 
= Configure U-Boot =
 
= Configure U-Boot =
Line 90: Line 72:
  
 
When you have determined what <board_name> you want to build, configure:
 
When you have determined what <board_name> you want to build, configure:
<pre>make CROSS_COMPILE=arm-linux-gnueabi-&nbsp;<board_name>_defconfig</pre>
+
<pre>make CROSS_COMPILE=arm-linux-gnueabi- <board_name>_defconfig</pre>
  
 
You may need to change the U-Boot function/feature support by modify the defconfig file or,
 
You may need to change the U-Boot function/feature support by modify the defconfig file or,
  
 
there is also menuconfig to play with settings if you feel like it:
 
there is also menuconfig to play with settings if you feel like it:
<pre>make CROSS_COMPILE=arm-linux-gnueabi- menuconfig</pre>
+
<pre>make CROSS_COMPILE=arm-linux-gnueabi- menuconfig
 
+
</pre>
&nbsp;
 
  
 
&nbsp;
 
&nbsp;
Line 103: Line 84:
 
= Build U-Boot =
 
= Build U-Boot =
  
== Get a toolchain ==
+
== Buid Rockchip U-Boot ==
  
If you haven't done so before, get a suitable&nbsp;toolchain&nbsp;installed and add it&nbsp;to your PATH.
+
For&nbsp;convenience, Rockchip provide a &nbsp;script 'make.sh' to make it easy to get everything before kernel, this script need toolchain and [[rkbin]] support.
 +
<pre>├── prebuilts
 +
│  └── gcc
 +
│      └── linux-x86
 +
│          ├── aarch64
 +
│          └── arm
 +
├── rkbin
 +
├── u-boot</pre>
  
In Ubuntu 14.04, you can use below command to install cross compiler for armv7:
+
expample for build rk3399:
<pre>sudo apt-get install gcc-arm-linux-gnueabi</pre>
+
<pre>./make.sh rk3399</pre>
  
Or for ARM64
+
and&nbsp;use './make.sh -h' for more option.
<pre>sudo apt-get install gcc-aarch64-linux-gnu
 
</pre>
 
  
&nbsp;
+
The output will including pre-loader, trust and u-boot,&nbsp;
 +
<pre>u-boot/
 +
├── rk3399_loader_v1.09.112.bin
 +
├── trust.img
 +
└── uboot.img</pre>
  
&nbsp;
+
== Common Build Steps ==
  
== Build ==
+
This is common and available for both Upstream U-Boot and Rockchip U-Boot.
  
 
For armv7:
 
For armv7:
Line 126: Line 116:
 
<pre>make ARCH=arm CROSS_COMPILE=aarch64-linux-gnu-</pre>
 
<pre>make ARCH=arm CROSS_COMPILE=aarch64-linux-gnu-</pre>
  
In order to support debug in ARM DS-5, you may need add ctags in make command:
+
In order to support debug symbol in ARM DS-5, you may need add ctags in make command:
 
<pre>CFLAGS='-gdwarf-3'</pre>
 
<pre>CFLAGS='-gdwarf-3'</pre>
 +
 +
You can get available u-boot.bin, spl/u-boot-spl.bin, tpl/u-boot-tpl.bin at this step, and you can use it later as describe at&nbsp;[http://opensource.rock-chips.com/wiki_Boot_option boot option].
 +
 +
'''Support ATF with SPL FIT image'''
  
 
For trust support, we are using FIT image with 'mkimage' cmd in Makefile and its script defined in defconfig:
 
For trust support, we are using FIT image with 'mkimage' cmd in Makefile and its script defined in defconfig:
Line 141: Line 135:
  
 
Rockchip bootrom supports SPL back to bootrom and bootrom load the U-Boot, so the SPL for Rockchip SoCs can option to back to bootrom, usually decided by if the IRAM is enough&nbsp;for driver to load U-Boot.
 
Rockchip bootrom supports SPL back to bootrom and bootrom load the U-Boot, so the SPL for Rockchip SoCs can option to back to bootrom, usually decided by if the IRAM is enough&nbsp;for driver to load U-Boot.
 
&nbsp;
 
  
 
&nbsp;
 
&nbsp;
Line 149: Line 141:
  
 
After build&nbsp;complete, U-Boot with SPL support will generate a spl folder with&nbsp;<var>u-boot-spl.bin</var>&nbsp;inside
 
After build&nbsp;complete, U-Boot with SPL support will generate a spl folder with&nbsp;<var>u-boot-spl.bin</var>&nbsp;inside
<pre>tools/mkimage -n rk3288 -T rksd -d spl/u-boot-spl.bin rk3288_idb.img</pre>
+
<pre>tools/mkimage -n rk3288 -T rksd -d spl/u-boot-spl.bin idbloader.img</pre>
  
 
'''This image is supposed to flash to offset 0x40.'''
 
'''This image is supposed to flash to offset 0x40.'''
  
 
For&nbsp;<var>u-boot.bin</var>, it's different for SPL back to bootrom or not, if enable&nbsp;CONFIG_ROCKCHIP_SPL_BACK_TO_BROM, we can append the U-Boot to IDB data:
 
For&nbsp;<var>u-boot.bin</var>, it's different for SPL back to bootrom or not, if enable&nbsp;CONFIG_ROCKCHIP_SPL_BACK_TO_BROM, we can append the U-Boot to IDB data:
<pre>cat u-boot.bin >> rk3288_idb.img</pre>
+
<pre>cat u-boot.bin >> idbloader.img</pre>
  
 
<code>If&nbsp;</code>CONFIG_ROCKCHIP_SPL_BACK_TO_BROM&nbsp;not enabled, no more package operation is need for u-boot-dtb.bin, and it need to flalsh to 0x200 which is decide by&nbsp;CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR.
 
<code>If&nbsp;</code>CONFIG_ROCKCHIP_SPL_BACK_TO_BROM&nbsp;not enabled, no more package operation is need for u-boot-dtb.bin, and it need to flalsh to 0x200 which is decide by&nbsp;CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR.
 
== Support ATF with SPL FIT image ==
 
 
&nbsp;
 
 
&nbsp;
 
  
 
== Using Rockchip miniloader ==
 
== Using Rockchip miniloader ==
Line 172: Line 158:
  
 
According to the&nbsp;[http://opensource.rock-chips.com/wiki_Partitions partitions]&nbsp;definition, the miniloader should write to offset 0x40 and &nbsp;this uboot.img should write to offset 0x4000.
 
According to the&nbsp;[http://opensource.rock-chips.com/wiki_Partitions partitions]&nbsp;definition, the miniloader should write to offset 0x40 and &nbsp;this uboot.img should write to offset 0x4000.
 
&nbsp;
 
 
&nbsp;
 
  
 
&nbsp;
 
&nbsp;
Line 185: Line 167:
 
= Boot cmd =
 
= Boot cmd =
  
== Distro boot ==
+
Rockchip U-Boot Android boot, Rockchip RKIMG boot and Distro boot.
  
== EFI boot ==
+
Upstream U-Boot suppot distro boot.
  
 
= Firmware download in U-Boot =
 
= Firmware download in U-Boot =
Line 196: Line 178:
  
 
See&nbsp;[http://opensource.rock-chips.com/wiki_Fastboot fastboot]
 
See&nbsp;[http://opensource.rock-chips.com/wiki_Fastboot fastboot]
 
== ums ==
 
  
 
== rockusb ==
 
== rockusb ==

Revision as of 07:38, 13 July 2018

Download U-Boot

Upstream U-Boot

You can clone the u-boot repository by running:

git clone git://git.denx.de/u-boot.git

Alternatively you can use u-boot-rockchip instead which may with some patches not get in mainline:

git clone git://git.denx.de/u-boot-rockchip.git

 

Rockchip U-Boot

You can clone the u-boot repository by running:

git clone https://github.com/rockchip-linux/u-boot.git

Supported Devices

Upstream U-Boot support Rockchip SoCs:

RK3036, RK3188, RK3288RK3328RK3399

  • RK3036 boards supported:
  1. EVB RK3036 - use evb-rk3036 configuration
  2. Kylin - use kylin_rk3036 configuration
  • RK3288 boards supported:
  1. EVB RK3288 - use evb-rk3288 configuration
  2. Fennec RK3288 - use fennec-rk3288 configuration
  3. Firefly RK3288 - use firefly-rk3288 configuration
  4. Hisense Chromebook - use chromebook_jerry configuration
  5. Miniarm RK3288 - use miniarm-rk3288 configuration
  6. PopMetal RK3288 - use popmetal-rk3288 configuration
  7. Radxa Rock 2 - use rock2 configuration
  8. ASUS Tinker
  • RK3188 boards supported:
  1. Radxa Rock - use rock configuration
  • RK3328 boards supported:
  1. EVB RK3328 - use evb-rk3328 configuration
  • RK3399 boards supported:
  1. EVB RK3399 - use evb-rk3399 configuration

Get a toolchain

If you haven't done so before, get a suitable toolchain installed and add it to your PATH.

In Ubuntu 14.04, you can use below command to install cross compiler for armv7:

sudo apt-get install gcc-arm-linux-gnueabi

Or for ARM64

sudo apt-get install gcc-aarch64-linux-gnu

Note that the latest U-Boot require version gcc-5.0 and later, we recommand to use linaro 6.3.1.

https://github.com/rockchip-linux/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf.git
https://github.com/rockchip-linux/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu.git

Configure U-Boot

First you need to choose a correct defconfig for your board;

When you have determined what <board_name> you want to build, configure:

make CROSS_COMPILE=arm-linux-gnueabi- <board_name>_defconfig

You may need to change the U-Boot function/feature support by modify the defconfig file or,

there is also menuconfig to play with settings if you feel like it:

make CROSS_COMPILE=arm-linux-gnueabi- menuconfig

 

Build U-Boot

Buid Rockchip U-Boot

For convenience, Rockchip provide a  script 'make.sh' to make it easy to get everything before kernel, this script need toolchain and rkbin support.

├── prebuilts
│   └── gcc
│       └── linux-x86 
│           ├── aarch64
│           └── arm
├── rkbin
├── u-boot

expample for build rk3399:

./make.sh rk3399

and use './make.sh -h' for more option.

The output will including pre-loader, trust and u-boot, 

u-boot/
├── rk3399_loader_v1.09.112.bin
├── trust.img
└── uboot.img

Common Build Steps

This is common and available for both Upstream U-Boot and Rockchip U-Boot.

For armv7:

make CROSS_COMPILE=arm-linux-gnueabi-

or for ARM64:

make ARCH=arm CROSS_COMPILE=aarch64-linux-gnu-

In order to support debug symbol in ARM DS-5, you may need add ctags in make command:

CFLAGS='-gdwarf-3'

You can get available u-boot.bin, spl/u-boot-spl.bin, tpl/u-boot-tpl.bin at this step, and you can use it later as describe at boot option.

Support ATF with SPL FIT image

For trust support, we are using FIT image with 'mkimage' cmd in Makefile and its script defined in defconfig:

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).

The u-boot.itb including u-boot-nodtb.bin, board.dtb, and trust binaries.

Install U-Boot

Rockchip SoCs's bootrom need special format named IDBlock at special offset 0x40 block for boot, so we need to package SPL(or Rockchip miniloader)  in IDB format.

Rockchip bootrom supports SPL back to bootrom and bootrom load the U-Boot, so the SPL for Rockchip SoCs can option to back to bootrom, usually decided by if the IRAM is enough for driver to load U-Boot.

 

Using U-Boot SPL

After build complete, U-Boot with SPL support will generate a spl folder with u-boot-spl.bin inside

tools/mkimage -n rk3288 -T rksd -d spl/u-boot-spl.bin idbloader.img

This image is supposed to flash to offset 0x40.

For u-boot.bin, it's different for SPL back to bootrom or not, if enable CONFIG_ROCKCHIP_SPL_BACK_TO_BROM, we can append the U-Boot to IDB data:

cat u-boot.bin >> idbloader.img

If CONFIG_ROCKCHIP_SPL_BACK_TO_BROM not enabled, no more package operation is need for u-boot-dtb.bin, and it need to flalsh to 0x200 which is decide by CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR.

Using Rockchip miniloader

Alternatively, you can use Rockchip miniloader and U-Boot instead which do not need SPL.

The miniloader is package as IDBlock, and the u-boot.bin need to package with rockchip tool:

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

According to the partitions definition, the miniloader should write to offset 0x40 and  this uboot.img should write to offset 0x4000.

 

Boot up

See boot option about how to boot from eMMC/SD card.

Boot cmd

Rockchip U-Boot Android boot, Rockchip RKIMG boot and Distro boot.

Upstream U-Boot suppot distro boot.

Firmware download in U-Boot

In U-Boot, there are multi way to update image for system, you can chose any of one easy use for you.

fastboot

See fastboot

rockusb