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/usb-install"

< Rockpi4‎ | dev
(Requirement)
 
(28 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 
{{rockpi4_header}}
 
{{rockpi4_header}}
 
{{Languages|rockpi4/dev/usb-install}}
 
{{Languages|rockpi4/dev/usb-install}}
     [[rockpi4 | ROCK Pi 4]] > [[rockpi4/dev | Development]] > [[rockpi4/dev/usb-install | Install from USB OTG port]]
+
     [[rockpi4 | ROCK Pi 4]] > [[rockpi4/dev | Development]] > [[rockpi4/dev/usb-install | Install image to eMMC from USB OTG port]]
  
ROCK Pi supports maskrom mode, which is a special running mode the CPU is waiting for command from USB OTG port. The PC tool we use to communicate with ROCK Pi in maskrom mode is rkdevelop tool, an open source tool by Rockchip.
+
== Install image to eMMC from USB OTG port ==
 +
ROCK Pi 4 supports Maskrom mode, which is a special operation mode for CPU to wait for USB OTG port command.  
 +
The Linux/macOS PC tool we use to communicate with ROCK Pi in Maskrom mode are the '''rkdeveloptool''' and '''RKDevTool'''.
 +
We use tool rkdeveloptool in Linux/macOS and RKDevTool tool under Windows.
  
 
=== Requirement ===
 
=== Requirement ===
 
* ROCK Pi 4 mainboard
 
* ROCK Pi 4 mainboard
* eMMC module
+
** ROCK Pi 4A
 +
** ROCK Pi 4A Plus
 +
** ROCK Pi 4B
 +
** ROCK Pi 4B Plus
 +
** ROCK Pi 4C
 +
* eMMC on board or eMMC module
 
* 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) USB C to USB A cable does not working on all PCs. [https://forum.radxa.com/t/otg-flashing-not-working/717 See discussion].
  
=== Make sure rkdeveloptool is set up on host computer ===
+
=== Install Tools&Drivers ===
==== Linux====
+
Please check this guide, [[rockpi4/install/rockchip-flash-tools | Install rockchip flash tools,  rkdeveloptool/RKDevTool, under Windows/Linux/MacOS PC]].
To build rkdeveloptool on a debain based Linux distribution, follow the instruction below:
+
  
Install build dependecy:
+
=== Boot the board to maskrom mode ===
  sudo apt-get install libudev-dev libusb-1.0-0-dev dh-autoreconf
+
  
Clone the source code and build:
+
To boot ROCK Pi 4 into maskrom mode is simple:
  git clone https://github.com/rockchip-linux/rkdeveloptool
+
  cd rkdeveloptool
+
  autoreconf -i
+
  ./configure
+
  make
+
  
If you encounter compile error like below
+
* 1. Power off the board
    ./configure: line 4269: syntax error near unexpected token `LIBUSB1,libusb-1.0'
+
* 2. Short-circuit SPI Nor Flash if there is one SPI Nor Flash on board.
    ./configure: line 4269: `PKG_CHECK_MODULES(LIBUSB1,libusb-1.0)'
+
  
 +
[[File:Spi_clk_gnd.jpg | 200px]]
  
You should install pkg-config libusb-1.0
+
* 3. Remove microSD card
    sudo apt-get install pkg-config libusb-1.0
+
* 4. Insert removable eMMC module ( Skip this when there in one eMMC on board)
 +
* 5. Plug the USB Male A to Male A cable to ROCK Pi 4 OTG port(the upper USB3 port), the other side to PC
 +
* 6. Press and hold the Maskrom key if your board is Plus version with soldered eMMC (1: Reset 2: Maskrom 3: Recovery)
  
Then re-run
+
[[File:Rockpi4bplus_key.jpg|400px]]
    autoreconf -i
+
    ./configure
+
    make
+
  
Now you have rkdeveloptool executable at the current directory.
+
* 7. Power on the board and release the maskrom key(important)
  sudo cp rkdeveloptool /usr/local/bin/
+
  
==== MacOS ====
+
* 8. Confirm that ROCK Pi 4 is in Maskrom mode .
 +
** For macOS host: lsusb result: '''Bus 000 Device 004: ID 2207:330c Fuzhou Rockchip Electronics Co., Ltd. Composite Device'''
 +
** For Linux host: lsusb result: '''Bus 001 Device 112: ID 2207:330c Fuzhou Rockchip Electronics Company'''
 +
** For Windows host: Open RKDevTool and you would see the device is in '''Found One MASKROM Device'''.
 +
[[File:AndroidTool1.PNG | 800px]]
  
To build rkdeveloptool on macOS, you need [https://brew.sh/ homebrew](or similar package manager) to install required packages.
+
Alternatively, if you are running Android and can access ADB, you can reboot the device to loader mode `adb reboot bootloader` then use the rkdeveloptool to reset the device into maskrom mode `rkdeveloptool rd 3` or Windows AndroidTool '''Switch''' button to go to maskrom mode.
  
Install build dependency:
+
=== Begin Installation USB -> eMMC ===
 +
<div class="toccolours mw-collapsible " style="width:800px; overflow:auto;">
 +
==== Linux/macOS ====
 +
<div class="mw-collapsible-content">
 +
On your PC, run the rkdeveloptool
  
    brew install automake autoconf libusb
+
sudo rkdeveloptool ld        # List the device
 +
DevNo=1 Vid=0x2207,Pid=0x330c,LocationID=305 Maskrom
  
Clone the source code and build:
+
Download the loader (flash helper) to init the ram and prepare the flashing environment etc. If you don't have it, you can download it from [https://dl.radxa.com/rockpi/images/loader/rk3399_loader_v1.27.126.bin here]
  
    git clone https://github.com/rockchip-linux/rkdeveloptool
+
sudo rkdeveloptool db rk3399_loader_v1.27.126.bin
    cd rkdeveloptool
+
    autoreconf -i
+
    ./configure
+
    make
+
  
If you encounter compile error like below
+
Write the GPT image to eMMC, start to write from offset '''0'''.
    ./configure: line 4269: syntax error near unexpected token `LIBUSB1,libusb-1.0'
+
    ./configure: line 4269: `PKG_CHECK_MODULES(LIBUSB1,libusb-1.0)'
+
  
 +
sudo rkdeveloptool wl 0 /path/to/rockpi4b-xxx-gpt.img
  
You should install pkg-config libusb-1.0
+
Reboot the device
    brew install pkg-config
+
  
Then re-run
+
sudo rkdeveloptool rd
    autoreconf -i
+
    ./configure
+
    make
+
  
Now you have rkdeveloptool executable at the current directory.
+
Now the device should boot the new image on eMMC.
  
    sudo cp rkdeveloptool /usr/local/bin/
+
Please note that when you want to erase eMMC on board, you can use these commands.
  
=== Boot the board to maskrom mode ===
+
dd if=/dev/zero of=./zero.img bs=1M count=64
To boot ROCK Pi into maskrom mode is simple, you don't need to press any key
+
sudo rkdeveloptool db rk3399_loader_v1.27.126.bin
 +
sudo rkdeveloptool wl 0 zero.img
  
* Power off the board and '''remove any bootable storage media''', remove microSD card, remove eMMC module.
+
</div>
* Plug the USB Male A to Mail A cable to ROCK Pi 4 OTG port(the upper USB3 port), the other side to PC
+
</div>
* Power on the board
+
  
Now on your Linux PC, '''lsusb''' command show show the following usb devices
+
<div class="toccolours mw-collapsible" style="width:800px; overflow:auto;">
  
    Bus 003 Device 005: ID 2207:330c
+
==== Windows ====
 +
<div class="mw-collapsible-content">
  
It means the device is in '''maskrom mode''' now.
+
Double click the '''RKDevTool.exe''' and you will see the following interface:
 +
If your ROCK Pi 4 is in maskrom mode and connects to PC, you can see that the program detect it, as the red box shown below:
  
* Now plug the eMMC module and proceed the next step to flash.
+
[[File:AndroidTool1.PNG | 1000px]]
  
=== Install to eMMC via USB ===
+
===== Step 1: Select Loader =====
On your PC, run the rkdeveloptool
+
  
    rkdeveloptool ld        # List the device
+
Next, click the button in the red box on the right last columns select the loader "rk3399_ loader_ xxxxx.bin ",  
    DevNo=1 Vid=0x2207,Pid=0x330c,LocationID=305 Maskrom
+
  
Download the loader (flash helper) to init the ram and prepare the flashing environment etc. If you don't have it, you can download it from [https://dl.radxa.com/rockpi/images/loader/ here]
+
[[File:AndroidTool8.PNG | 1000px]]
  
    rkdeveloptool db rk3399_loader_vxxxx.bin
+
''Note:'' the loader (flash helper) is used to init the ram and prepare the flashing environment etc. If you don't have it, you can download it from [https://dl.radxa.com/rockpi/images/loader/ here]
  
Write the GPT image to eMMC, start to write from offset '''0'''.
+
===== Step 2: Select Image =====
  
    rkdeveloptool wl 0 /path/to/rockpi4b-xxx-gpt.img
+
Then click the right last columns to in the Image row and choose the image you want to flash.
  
Reboot the device
+
''Note'': Normally the image name should ends with xxx-gpt.img. If the image name ends with xxx-rkupdate.img, you can not flash with this method.
 +
 
 +
===== Step 3: Run =====
  
    rkdeveloptool rd
+
Finally, click the "run" button in the red box below, and you will see the content in the red box on the right. When the progress reaches 100%, the download is completed.
  
Now the device should boot the new image on eMMC
+
[[File:Androidtool5.PNG | 1000px]]
 +
</div>
 +
</div>
  
=== Install by partitions(optional) ===
+
=== Install by partitions(Advanced) ===
 +
<div class="toccolours mw-collapsible mw-collapsed" style="width:800px; overflow:auto;">
 +
==== Linux/macOS ====
 +
<div class="mw-collapsible-content">
 
Sometimes we only want to update a partition of the image, for example only the boot partition to update kernel only. We can flash by partitions
 
Sometimes we only want to update a partition of the image, for example only the boot partition to update kernel only. We can flash by partitions
  
Line 124: Line 130:
 
When the board is in maskrom mode, flash the partitions with the following command and offset:
 
When the board is in maskrom mode, flash the partitions with the following command and offset:
  
     rkdeveloptool db rk3399_loader_*.bin
+
     sudo rkdeveloptool db rk3399_loader_*.bin
     rkdeveloptool wl 64 idbloader.img
+
     sudo rkdeveloptool wl 64 idbloader.img
     rkdeveloptool wl 16384 uboot.img
+
     sudo rkdeveloptool wl 16384 uboot.img
     rkdeveloptool wl 24576 trust.img
+
     sudo rkdeveloptool wl 24576 trust.img
     rkdeveloptool wl 32768 boot.img
+
     sudo rkdeveloptool wl 32768 boot.img
     rkdeveloptool wl 262144 rootfs.img
+
     sudo rkdeveloptool wl 262144 rootfs.img
 +
</div>
 +
</div>
 +
 
 +
<div class="toccolours mw-collapsible" style="width:800px; overflow:auto;">
 +
==== Windows ====
 +
<div class="mw-collapsible-content">
 +
TBD.
 +
</div>
 +
</div>
 +
 
 +
=== FAQ ===
 +
If you meet such these situations, you can try to change the bin file by [https://dl.radxa.com/rockpi/images/loader/rk3399_loader_v1.27.126.bin rk3399_loader_v1.27.126.bin]
 +
 
 +
[[File:error-loader1.png | 1000px]]
 +
 
 +
[[File:error-loader2.png | 1000px]]
  
 
=== Troubleshooting ===
 
=== Troubleshooting ===
  
 
* If you have issue with flashing via USB OTG, start a new post on the forum. https://forum.radxa.com/c/dev
 
* If you have issue with flashing via USB OTG, start a new post on the forum. https://forum.radxa.com/c/dev

Latest revision as of 07:50, 14 January 2023

    ROCK Pi 4 >  Development >  Install image to eMMC from USB OTG port

Install image to eMMC from USB OTG port

ROCK Pi 4 supports Maskrom mode, which is a special operation mode for CPU to wait for USB OTG port command. The Linux/macOS PC tool we use to communicate with ROCK Pi 4 in Maskrom mode are the rkdeveloptool and RKDevTool. We use tool rkdeveloptool in Linux/macOS and RKDevTool tool under Windows.

Requirement

  • ROCK Pi 4 mainboard
    • ROCK Pi 4A
    • ROCK Pi 4A Plus
    • ROCK Pi 4B
    • ROCK Pi 4B Plus
    • ROCK Pi 4C
  • eMMC on board or eMMC module
  • Power adapter
  • USB Male A to Male A cable(important) USB C to USB A cable does not working on all PCs. See discussion.

Install Tools&Drivers

Please check this guide, Install rockchip flash tools, rkdeveloptool/RKDevTool, under Windows/Linux/MacOS PC.

Boot the board to maskrom mode

To boot ROCK Pi 4 into maskrom mode is simple:

  • 1. Power off the board
  • 2. Short-circuit SPI Nor Flash if there is one SPI Nor Flash on board.

Spi clk gnd.jpg

  • 3. Remove microSD card
  • 4. Insert removable eMMC module ( Skip this when there in one eMMC on board)
  • 5. Plug the USB Male A to Male A cable to ROCK Pi 4 OTG port(the upper USB3 port), the other side to PC
  • 6. Press and hold the Maskrom key if your board is Plus version with soldered eMMC (1: Reset 2: Maskrom 3: Recovery)

Rockpi4bplus key.jpg

  • 7. Power on the board and release the maskrom key(important)
  • 8. Confirm that ROCK Pi 4 is in Maskrom mode .
    • For macOS host: lsusb result: Bus 000 Device 004: ID 2207:330c Fuzhou Rockchip Electronics Co., Ltd. Composite Device
    • For Linux host: lsusb result: Bus 001 Device 112: ID 2207:330c Fuzhou Rockchip Electronics Company
    • For Windows host: Open RKDevTool and you would see the device is in Found One MASKROM Device.

AndroidTool1.PNG

Alternatively, if you are running Android and can access ADB, you can reboot the device to loader mode `adb reboot bootloader` then use the rkdeveloptool to reset the device into maskrom mode `rkdeveloptool rd 3` or Windows AndroidTool Switch button to go to maskrom mode.

Begin Installation USB -> eMMC

Linux/macOS

On your PC, run the rkdeveloptool

sudo rkdeveloptool ld        # List the device
DevNo=1	Vid=0x2207,Pid=0x330c,LocationID=305	Maskrom

Download the loader (flash helper) to init the ram and prepare the flashing environment etc. If you don't have it, you can download it from here

sudo rkdeveloptool db rk3399_loader_v1.27.126.bin

Write the GPT image to eMMC, start to write from offset 0.

sudo rkdeveloptool wl 0 /path/to/rockpi4b-xxx-gpt.img

Reboot the device

sudo rkdeveloptool rd

Now the device should boot the new image on eMMC.

Please note that when you want to erase eMMC on board, you can use these commands.

dd if=/dev/zero of=./zero.img bs=1M count=64
sudo rkdeveloptool db rk3399_loader_v1.27.126.bin
sudo rkdeveloptool wl 0 zero.img

Windows

Double click the RKDevTool.exe and you will see the following interface: If your ROCK Pi 4 is in maskrom mode and connects to PC, you can see that the program detect it, as the red box shown below:

AndroidTool1.PNG

Step 1: Select Loader

Next, click the button in the red box on the right last columns select the loader "rk3399_ loader_ xxxxx.bin ",

AndroidTool8.PNG

Note: the loader (flash helper) is used to init the ram and prepare the flashing environment etc. If you don't have it, you can download it from here

Step 2: Select Image

Then click the right last columns to in the Image row and choose the image you want to flash.

Note: Normally the image name should ends with xxx-gpt.img. If the image name ends with xxx-rkupdate.img, you can not flash with this method.

Step 3: Run

Finally, click the "run" button in the red box below, and you will see the content in the red box on the right. When the progress reaches 100%, the download is completed.

Androidtool5.PNG

Install by partitions(Advanced)

Linux/macOS

Sometimes we only want to update a partition of the image, for example only the boot partition to update kernel only. We can flash by partitions

| Part Number | Offset | Name    | Description                |
| ----------- | ------ | ------- | -------------------------- |
| 1           | 32KB   | loader1 | First stage loader         |
| 2           | 8MB    | loader2 | U-boot image               |
| 3           | 12MB   | trust   | ATF                        |
| 4           | 16MB   | boot    | Kernel partition, bootable |
| 5           | 128MB  | rootfs  | Rootfs                     |

When the board is in maskrom mode, flash the partitions with the following command and offset:

   sudo rkdeveloptool db rk3399_loader_*.bin
   sudo rkdeveloptool wl 64 idbloader.img
   sudo rkdeveloptool wl 16384 uboot.img
   sudo rkdeveloptool wl 24576 trust.img
   sudo rkdeveloptool wl 32768 boot.img
   sudo rkdeveloptool wl 262144 rootfs.img

Windows

TBD.

FAQ

If you meet such these situations, you can try to change the bin file by rk3399_loader_v1.27.126.bin

Error-loader1.png

Error-loader2.png

Troubleshooting