Please enable javascript, or click here to visit my ecommerce web site powered by Shopify.
Jump to: navigation, search

Difference between revisions of "Rockpi4/dev/u-boot"

< Rockpi4‎ | dev
(Method 2: Flash U-Boot to SPI Flash)
 
(8 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
{{rockpi4_header}}
 
{{rockpi4_header}}
 
{{Languages|rockpi4/dev/u-boot}}
 
{{Languages|rockpi4/dev/u-boot}}
     [[rockpi4 | ROCK Pi 4]] > [[rockpi4/dev | Development]] > [[rockpi4/dev/u-boot | U-boot]]
+
     [[rockpi4 | ROCK Pi 4]] > [[rockpi4/dev | Development]] > [[rockpi4/dev/u-boot | U-Boot]]
  
=Build U-boot and run it on ROCK Pi4=
+
=== Build U-Boot and run it on ROCK Pi 4 ===
 +
 
 +
This guide describes how to build U-Boot  and run it on ROCK Pi 4. U-Boot images could be installed into eMMC module, Micro SD Card and SPI Flash, etc.
 +
 
 +
==== Hardware required ====
  
=== Requirement ===
 
 
* ROCK Pi 4 mainboard
 
* ROCK Pi 4 mainboard
* A EMMC module or a microSD card
+
* An eMMC module or a MicroSD Card or SPI Flash soldered on board
 
* Power adapter
 
* Power adapter
* '''USB Male A to Male A cable'''(important) USB-C has been seen as not working, an adaptor for USB-C to USB-A has worked. [https://forum.radxa.com/t/otg-flashing-not-working/717 See discussion].
+
* '''USB Male A to Male A cable'''(important).
*A a PC/laptop running Linux
+
* A PC/laptop running Linux
 +
 
 +
==== Build U-Boot ====
  
==Step 1 Get the source code ==
+
===== Step 1: Get the source code =====
  
 
You need Git to get multiple git repositories to build the image.
 
You need Git to get multiple git repositories to build the image.
Line 18: Line 23:
 
Install Git if you don't have it.
 
Install Git if you don't have it.
  
     sudo apt-get update
+
     sudo apt-get update && sudo apt-get install -y git
    sudo apt-get install git
+
  
 
Clone the source code
 
Clone the source code
Line 42: Line 46:
 
** u-boot as the second stage bootloader
 
** u-boot as the second stage bootloader
  
==Step 2 Install tool-chain and other tools==
+
There are two branches for ROCK Pi 4 U-Boot. One is '''stable-4.4-rockpi4''' and the other is '''rk3399-pie-gms-express-baseline'''.
 +
<br />
 +
Specially the branch rk3399-pie-gms-express-baseline supports SPI-NVME-Boot.
  
    sudo apt-get install gcc-aarch64-linux-gnu device-tree-compiler libncurses5 libncurses5-dev build-essential libssl-dev mtools
+
===== Step 2: Install build tools =====
    sudo apt-get install bc python dosfstools
+
  
To build rkdeveloptool on a debain based Linux distribution, follow the instruction below:
+
  sudo apt-get install -y gcc-aarch64-linux-gnu device-tree-compiler libncurses5 libncurses5-dev
 +
  sudo apt-get install -y bc python dosfstools flex build-essential libssl-dev mtools
  
Install build dependecy:
+
===== Step 3: Build U-boot =====
  sudo apt-get install libudev-dev libusb-1.0-0-dev dh-autoreconf
+
  
Clone the source code and build:
+
*If you use the ROCK Pi 4A
  git clone https://github.com/rockchip-linux/rkdeveloptool
+
  cd rkdeveloptool
+
  autoreconf -i
+
  ./configure
+
  make
+
  
If you encounter compile error like below
+
  ./build/mk-uboot.sh rockpi4a
    ./configure: line 4269: syntax error near unexpected token `LIBUSB1,libusb-1.0'
+
    ./configure: line 4269: `PKG_CHECK_MODULES(LIBUSB1,libusb-1.0)'
+
  
 +
*If you use the ROCK Pi 4B
  
You should install pkg-config libusb-1.0
+
  ./build/mk-uboot.sh rockpi4b
    sudo apt-get install pkg-config libusb-1.0
+
  
Then re-run
+
*If you use the ROCK Pi 4C
    autoreconf -i
+
    ./configure
+
    make
+
  
Now you have rkdeveloptool executable at the current directory.
+
  ./build/mk-uboot.sh rockpi4c
  sudo cp rkdeveloptool /usr/local/bin/
+
  
==Step 3 Build U-boot==
+
And then you can get the directory, '''out''', of all the generated images.
  
*If you use the ROCK Pi4 A
+
==== Flash U-Boot ====
  
    ./build/mk-uboot.sh rockpi4a
+
The prepared tools are '''dd''' provided by coreutils and '''[https://wiki.radxa.com/Rockpi4/dev/spi-install  rkdeveloptool]'''.
 +
<br />
 +
dd is used for Micro SD Card and eMMC module while rkdeveloptool is used for eMMC moduel and SPI Flash.
  
*If you use the ROCK Pi4B
+
===== Method 1: Flash U-Boot  to eMMC module =====
  
    ./build/mk-uboot.sh rockpi4b
+
Insert an empty eMMC module on your ROCK Pi 4
  
And then you can get the directory 'out'.
+
Use the USB Male A to Male A cable to connected your PC and ROCK Pi4 and then type
  
==Flash and run U-boot on ROCK Pi4==
+
  rkdeveloptool ld
  
Insert a empty EMMC module or microSD card on your ROCK Pi4
+
You can see the output just like this
  
Use the USB Male A to Male A cable to connected your PC and ROCK Pi4 and then type
+
  DevNo=1 Vid=0x2207,Pid=0x330c,LocationID=302 Maskrom
  
    rkdeveloptool ld
+
You can using this command to flash U-boot
  
You can see the output just like this
+
  cd ./out/u-boot
 +
  sudo rkdeveloptool db ../../rkbin/bin/rk33/rk3399_loader_v1.12.112.bin
 +
  sudo rkdeveloptool wl 0x40 idbloader.img
 +
  sudo rkdeveloptool wl 0x4000 uboot.img
 +
  sudo rkdeveloptool wl 0x6000 trust.img
 +
  sudo rkdeveloptool rd
  
    DevNo=1 Vid=0x2207,Pid=0x330c,LocationID=302 Maskrom
+
===== Method 2: Flash U-Boot to SPI Flash =====
  
You can useing this command to flash U-boot
+
The u-boot SPI image are generated at '''out/u-boot/spi'''
 +
<pre>
 +
.
 +
├── idbloader-spi.img                    # first stage loader
 +
├── rk3399_loader_spinor_v1.15.114.bin    # USB downloader helper for SPI flash
 +
├── uboot-trust-spi.img                  # Packed SPI image with idbloader, u-boot.img and trust.img
 +
└── uboot-trust-spi.img.md5              # md5 checksum for the packed SPI image
 +
</pre>
  
    cd ./out/u-boot
+
The method of flashing U-Boot to SPI Flash is quite similar to eMMC module. See [[rockpi4/dev/spi-install | this guide]].
    sudo rkdeveloptool db ../../rkbin/bin/rk33/rk3399_loader_v1.12.112.bin
+
    sudo rkdeveloptool wl 0x40 idbloader.img
+
    sudo rkdeveloptool wl 0x4000 uboot.img
+
    sudo rkdeveloptool wl 0x6000 trust.img
+
    sudo rkdeveloptool rd
+
  
The U-boot were run on your ROCK Pi4 try to type 'help' or '?' to getting started!
+
===== Method 3: Update U-Boot on Micro SD Card/eMMC module =====
  
=U-boot Usage=
+
For Micro SD Card, need Micro SD Card Reader.
 +
 
 +
For eMMC module, both USB 3.0 eMMC Reader and eMMC to Micro SD Card Converter Board are available. Just choose one kind.
 +
 
 +
On Host Linux, the device is shown as /dev/sdx (x: a, b, c....)
 +
 
 +
  cd ./out/u-boot
 +
  sudo dd if=./idbloader.img of=/dev/sdx bs=512 seek=64
 +
  sudo dd if=./uboot.img of=/dev/sdx bs=512 seek=16384
 +
  sudo dd if=./trust.img of=/dev/sdx bs=512 seek=24576
 +
  sync
 +
 
 +
====U-boot Usage====
  
 
* [[Rockpi4/dev/u-boot/pxe | PXE boot]]
 
* [[Rockpi4/dev/u-boot/pxe | PXE boot]]
 +
* [[Rockpi4/Linux system runs on M.2 NVME SSD | SPI NVME boot]]
 +
 +
==== FAQs ====
 +
 +
1. [https://forum.radxa.com/t/otg-flashing-not-working/717 See discussion] about OTG Flashing not working.
 +
.
 +
 +
==== Troubleshooting ====
 +
 +
* Post your issue at the forum: https://forum.radxa.com/c/dev.

Latest revision as of 02:55, 25 February 2020

    ROCK Pi 4 >  Development >  U-Boot

Build U-Boot and run it on ROCK Pi 4

This guide describes how to build U-Boot and run it on ROCK Pi 4. U-Boot images could be installed into eMMC module, Micro SD Card and SPI Flash, etc.

Hardware required

  • ROCK Pi 4 mainboard
  • An eMMC module or a MicroSD Card or SPI Flash soldered on board
  • Power adapter
  • USB Male A to Male A cable(important).
  • A PC/laptop running Linux

Build U-Boot

Step 1: Get the source code

You need Git to get multiple git repositories to build the image.

Install Git if you don't have it.

   sudo apt-get update && sudo apt-get install -y git

Clone the source code

   git clone --recursive https://github.com/radxa/rockchip-bsp.git

You will get

   build  kernel  README.md  rkbin  rootfs  u-boot

Directories usage introductions:

  • build:
    • Some script files and configuration files for building u-boot, kernel and rootfs.
  • kernel:
    • kernel source code, current version is 4.4
  • rkbin:
    • Prebuilt Rockchip binaries, include first stage loader and ATF(Arm Trustzone Firmware).
  • rootfs:
    • Bootstrap a Debian based rootfs, support architechture armhf and arm64, support Debian Jessie and Stretch.
  • u-boot:
    • u-boot as the second stage bootloader

There are two branches for ROCK Pi 4 U-Boot. One is stable-4.4-rockpi4 and the other is rk3399-pie-gms-express-baseline.
Specially the branch rk3399-pie-gms-express-baseline supports SPI-NVME-Boot.

Step 2: Install build tools
 sudo apt-get install -y gcc-aarch64-linux-gnu device-tree-compiler libncurses5 libncurses5-dev
 sudo apt-get install -y bc python dosfstools flex build-essential libssl-dev mtools
Step 3: Build U-boot
  • If you use the ROCK Pi 4A
 ./build/mk-uboot.sh rockpi4a
  • If you use the ROCK Pi 4B
 ./build/mk-uboot.sh rockpi4b
  • If you use the ROCK Pi 4C
 ./build/mk-uboot.sh rockpi4c

And then you can get the directory, out, of all the generated images.

Flash U-Boot

The prepared tools are dd provided by coreutils and rkdeveloptool.
dd is used for Micro SD Card and eMMC module while rkdeveloptool is used for eMMC moduel and SPI Flash.

Method 1: Flash U-Boot to eMMC module

Insert an empty eMMC module on your ROCK Pi 4

Use the USB Male A to Male A cable to connected your PC and ROCK Pi4 and then type

 rkdeveloptool ld

You can see the output just like this

 DevNo=1	Vid=0x2207,Pid=0x330c,LocationID=302	Maskrom

You can using this command to flash U-boot

 cd ./out/u-boot
 sudo rkdeveloptool db ../../rkbin/bin/rk33/rk3399_loader_v1.12.112.bin
 sudo rkdeveloptool wl 0x40 idbloader.img
 sudo rkdeveloptool wl 0x4000 uboot.img
 sudo rkdeveloptool wl 0x6000 trust.img
 sudo rkdeveloptool rd
Method 2: Flash U-Boot to SPI Flash

The u-boot SPI image are generated at out/u-boot/spi

.
├── idbloader-spi.img                     # first stage loader
├── rk3399_loader_spinor_v1.15.114.bin    # USB downloader helper for SPI flash
├── uboot-trust-spi.img                   # Packed SPI image with idbloader, u-boot.img and trust.img
└── uboot-trust-spi.img.md5               # md5 checksum for the packed SPI image

The method of flashing U-Boot to SPI Flash is quite similar to eMMC module. See this guide.

Method 3: Update U-Boot on Micro SD Card/eMMC module

For Micro SD Card, need Micro SD Card Reader.

For eMMC module, both USB 3.0 eMMC Reader and eMMC to Micro SD Card Converter Board are available. Just choose one kind.

On Host Linux, the device is shown as /dev/sdx (x: a, b, c....)

 cd ./out/u-boot
 sudo dd if=./idbloader.img of=/dev/sdx bs=512 seek=64
 sudo dd if=./uboot.img of=/dev/sdx bs=512 seek=16384
 sudo dd if=./trust.img of=/dev/sdx bs=512 seek=24576
 sync

U-boot Usage

FAQs

1. See discussion about OTG Flashing not working. .

Troubleshooting