Difference between revisions of "U-Boot"

From Rockchip open source Document
Jump to: navigation, search
Line 12: Line 12:
 
<pre>git clone git://git.denx.de/u-boot-rockchip.git</pre>
 
<pre>git clone git://git.denx.de/u-boot-rockchip.git</pre>
  
 +
&nbsp;
  
 
== Rockchip U-Boot ==
 
== Rockchip U-Boot ==
Line 62: Line 63:
 
&nbsp;
 
&nbsp;
  
 +
&nbsp;
  
 
= Configure U-Boot =
 
= Configure U-Boot =
Line 80: Line 82:
  
 
= Build U-Boot =
 
= Build U-Boot =
 
  
 
== Get a toolchain ==
 
== Get a toolchain ==
Line 106: Line 107:
 
<pre>CFLAGS='-gdwarf-3'</pre>
 
<pre>CFLAGS='-gdwarf-3'</pre>
  
 
+
&nbsp;
  
 
= Istall U-Boot =
 
= Istall U-Boot =
Line 116: Line 117:
 
&nbsp;
 
&nbsp;
  
 +
&nbsp;
  
 
== Using U-Boot SPL ==
 
== Using U-Boot SPL ==
Line 130: Line 132:
  
 
== Support ATF with SPL FIT image ==
 
== Support ATF with SPL FIT image ==
 +
 +
&nbsp;
  
 
== Using Rockchip miniloader ==
 
== Using Rockchip miniloader ==
Line 136: Line 140:
  
 
The miniloader is package as IDBlock, and the u-boot.bin need to package with rockchip tool:
 
The miniloader is package as IDBlock, and the u-boot.bin need to package with rockchip tool:
<pre>loaderimage --pack --uboot u-boot.bin rk3288_uboot.img</pre>
+
<pre>loaderimage --pack --uboot u-boot.bin uboot.img</pre>
  
According to the [[Partitions|partitions]] definition, this output should write to offset 0x4000.
+
According to the [[Partitions|partitions]] definition, the miniloader should write to offset 0x64 and &nbsp;this uboot.img should write to offset 0x4000.
  
= Boot =
+
&nbsp;
  
 +
== Boot up ==
  
== Boot from eMMC ==
+
See [[Boot_option|boot option]] about how to boot from eMMC/SD card.
  
 +
= Boot cmd =
  
=== &nbsp;To get tool and firmware ===
+
== Distro boot ==
 
 
[http://rockchip.wikidot.com/tools tools]
 
 
 
=== Flash&nbsp;to the board by USB ===
 
 
 
In order to&nbsp;flash&nbsp;by USB,you must get your board into ROM boot mode, either by erasing<br/> your MMC or holding the maskrom button when you boot the board.
 
 
 
 
 
 
 
==== RK3288(upgrade_tool) ====
 
 
 
To create a suitable image and flash&nbsp;it to the board:<br/> default&nbsp;: with CONFIG_ROCKCHIP_SPL_BACK_TO_BROM
 
 
 
<pre>tools/mkimage -n rk3288 -T rksd -d spl/u-boot-spl-dtb.bin out<br/> cat u-boot-dtb.bin >> out<br/> sudo upgrade_tool db&nbsp; ../rkbin/rk32/RK3288UbootLoader_V2.30.06.bin<br/> sudo upgrade_tool wl 64 out<br/> sudo upgrade_tool rd</pre>
 
 
 
<br/> others&nbsp;: firefly(Recommend using sd card)
 
 
 
 
 
 
 
==== RK3036 ====
 
 
 
To create a suitable image and flash&nbsp;it to the board:
 
<pre><code>tools/mkimage -n rk3036 -T rksd -d spl/u-boot-spl-dtb.bin out
 
cat u-boot-dtb.bin >> out
 
sudo upgrade_tool db  ../rkbin/rk30/RK3036MiniLoaderAll_V2.19.bin
 
sudo upgrade_tool wl 64 out
 
sudo upgrade_tool rd</code>
 
</pre>
 
 
 
==== RK3399 ====
 
<pre><code>cd ..
 
./rkbin/tools/trust_merger ./rkbin/tools/RK3399TRUST.ini
 
cd uboot
 
 
 
../rkbin/tools/loaderimage --pack --uboot u-boot-dtb.bin uboot.img
 
 
 
sudo upgrade_tool UL  ../rkbin/rk33/RK3399MiniLoaderAll_V1.05.bin
 
sudo upgrade_tool DI uboot uboot.img  ../rkbin/tools/rk3399_parameter.txt
 
sudo upgrade_tool DI trust ../trust.img  ../rkbin/tools/rk3399_parameter.txt
 
sudo upgrade_tool rd</code>
 
</pre>
 
 
 
 
 
=== &nbsp;To flash kernel and rootfs ===
 
 
 
Enter into the uboot and issue the following command on uboot: (otg should be connected)
 
<pre><code>gpt write mmc 0 $partitions
 
ums 0 mmc 0</code>
 
</pre>
 
 
 
<br/> Now the board will act as an USB-drive.<br/> In host: (assuming sdb is ur device)
 
<pre><code>sudo mkfs.fat /dev/sdb6</code>
 
</pre>
 
 
 
<br/> Copy zimage and dts file to dev/sdb6
 
<pre><code>cp arch/arm/boot/zImage /media/chen/9F35-9565/
 
cp arch/arm/boot/dts/rk3288-fennec.dtb /media/chen/9F35-9565/rk3288-fennec.dtb</code>
 
</pre>
 
 
 
Add extlinux/extlinux.conf to dev/sdb6<br/> (Please notice "mmcblk2p7" and "115200n8" is decide on your chip, Please refer to&nbsp;[http://rockchip.wikidot.com/linux-user-guide#toc1 config table])
 
<pre><code>label kernel-4.4
 
    kernel /zImage
 
    fdt /rk3288-fennec.dtb
 
    append  earlyprintk console=tty1 console=ttyS2,115200n8 rw root=/dev/mmcblk2p7 rootfstype=ext4 init=/sbin/init</code>
 
</pre>
 
 
 
<br/> To flash rootfs
 
<pre><code>sudo dd if=linaro-rootfs.img of=/dev/sdb7 conv=notrunc</code></pre>
 
 
 
== Boot from SD/TF Card ==
 
 
 
 
 
=== Creating Image ===
 
 
 
Follow&nbsp;[http://rockchip.wikidot.com/linux-user-guide linux-user-guide]&nbsp;to build kernel and U-Boot.<br/> get uboot-spl.img and u-boot-dtb.img
 
<pre><code>tools/mkimage -n rk3288 -T rksd -d spl/u-boot-spl-dtb.bin uboot-spl.img</code>
 
</pre>
 
 
 
=== <br/> <var>build boot.img</var> ===
 
<pre><code>sudo dd if=/dev/zero of=boot.img bs=1M count=128
 
sudo mkfs.fat boot.img
 
mkdir boot
 
sudo mount  boot.img boot
 
sudo cp zImage boot
 
sudo cp rk3288-fennec.dtb boot
 
sudo mkdir boot/extlinux
 
sudo cp extlinux.conf boot/extlinux
 
sudo umount boot</code>
 
</pre>
 
 
 
Download rootfs image and rename it
 
<pre><code>mv linaro-rootfs.img rootfs.img</code>
 
</pre>
 
 
 
=== Making a SD Card for updating ===
 
 
 
Download&nbsp;[https://github.com/wzyy2/rk-initrd-build ramdisk source]&nbsp;and build.
 
<pre><code>sh ./mk-initrd.sh</code>
 
</pre>
 
 
 
Format SD card
 
<pre><code>chen@chen-HP-ProDesk-680-G1-TWR:~/work/linaro-alip/ramdisk/update$ sudo gdisk /dev/sdb
 
GPT fdisk (gdisk) version 0.8.8
 
 
 
Partition table scan:
 
  MBR: protective
 
  BSD: not present
 
  APM: not present
 
  GPT: present
 
 
 
Found valid GPT with protective MBR; using GPT.
 
 
 
Command (? for help): o
 
This option deletes all partitions and creates a new protective MBR.
 
Proceed? (Y/N): y
 
  
Command (? for help): n
+
== EFI boot ==
Partition number (1-128, default 1): 1
 
First sector (34-126613470, default = 2048) or {+-}size{KMGTP}: 8192
 
Last sector (8192-126613470, default = 126613470) or {+-}size{KMGTP}:
 
Current type is 'Linux filesystem'
 
Hex code or GUID (L to show codes, Enter = 8300):
 
Changed type of partition to 'Linux filesystem'
 
  
Command (? for help): w
+
= Firmware download in U-Boot =
 
 
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
 
PARTITIONS!!
 
 
 
Do you want to proceed? (Y/N): y
 
OK; writing new GUID partition table (GPT) to /dev/sdc.
 
Warning: The kernel is still using the old partition table.
 
The new table will be used at the next reboot.
 
The operation has completed successfully.</code>
 
</pre>
 
<pre><code>sudo umount /dev/sdb1
 
sudo mkfs.fat /dev/sdb1</code>
 
</pre>
 
<pre><code>tools/mkimage -n rk3288 -T rksd -d spl/u-boot-spl-dtb.bin out&&
 
sudo dd if=out of=/dev/sdb seek=64&&sudo dd if=u-boot-dtb.img of=/dev/sdb seek=256</code>
 
</pre>
 
 
 
Copy zimage, dts and ramdisk to /dev/sdb1
 
<pre><code>cp arch/arm/boot/zImage /media/chen/9F35-9565/
 
cp arch/arm/boot/dts/rk3288-fennec.dtb /media/chen/9F35-9565/rk3288-fennec.dtb
 
cp ../rk-initrd-build/initrd.img /media/chen/9F35-9565/</code>
 
</pre>
 
 
 
Add extlinux/extlinux.conf to /dev/sdb1
 
<pre><code>label kernel-4.4
 
    kernel /zImage
 
    fdt /rk3288-fennec.dtb
 
    initrd /initrd.img
 
    append  earlyprintk console=ttyS2,115200n8 rw root=/dev/ram0 rootfstype=ext4 init=/sbin/init ramdisk_size=49152</code>
 
</pre>
 
 
 
Copy u-boot-dtb.img uboot-spl.img boot.img rootfs.img and&nbsp;[https://github.com/wzyy2/rk-initrd-build/blob/master/update/update.sh update.sh]&nbsp;to /dev/sdb1
 
<pre><code>mkdir /media/chen/9F35-9565/update
 
cp u-boot-dtb.img /media/chen/9F35-9565/update
 
cp uboot-spl.img /media/chen/9F35-9565/update
 
cp boot.img /media/chen/9F35-9565/update
 
cp rootfs.img /media/chen/9F35-9565/update
 
cp update.sh /media/chen/9F35-9565/update</code>
 
</pre>
 
 
 
=== Updating the board ===
 
 
 
Boot the board and it will flash image to eMMC
 
 
 
 
 
== Boot from USB-Disk ==
 
 
 
Same as&nbsp;[http://rockchip.wikidot.com/boot-from-sdcard boot-from-sdcard], but please note that U-Boot aren't allowed to boot from usb-disk because of restrict of maskrom, only kernel and rootfs can load from USB-Disk.
 
 
 
Difference:
 
<pre><code>label kernel-4.4
 
    kernel /zImage
 
    fdt /rk3288-fennec.dtb
 
    append  earlyprintk console=ttyS2,115200n8 rw root=/dev/sda1 rootfstype=ext4 init=/sbin/init</code>
 
</pre>
 
<pre><code>gpt write usb 0 $partitions
 
ums 0 usb 0</code></pre>
 
 
 
== Netboot/TFTP ==
 
 
 
== Distro boot ==
 
 
 
= U-Boot download =
 
  
 
In U-Boot, there are multi way to update image for system, you can chose any of one easy use for you.
 
In U-Boot, there are multi way to update image for system, you can chose any of one easy use for you.
Line 340: Line 162:
 
== fastboot ==
 
== fastboot ==
  
See [[fastboot]]
+
See [[Fastboot|fastboot]]
  
 
== ums ==
 
== ums ==
 +
 +
== rockusb ==

Revision as of 09:17, 17 March 2017

U-Boot Guide

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, RK3288, RK3328, RK3399

 

  • 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

 

 

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

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

 

Build

For armv7:

make CROSS_COMPILE=arm-linux-gnueabi-

or for ARM64:

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

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

CFLAGS='-gdwarf-3'

 

Istall U-Boot

Rockchip SoCs's bootrom need special format named IDBlock at special offset 0x64 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  rk3288_idb.img

This image is supposed to flash to offset 0x64.

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

Support ATF with SPL FIT image

 

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 0x64 and  this uboot.img should write to offset 0x4000.

 

Boot up

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

Boot cmd

Distro boot

EFI 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

ums

rockusb