Flash image

来自Firefly wiki
跳转至: 导航搜索

Introduction

This page describes how to flash the image file from the host to the development board's eMMC, via the Type-C cable or USB OTG + Type-C adapter(Hereinafter referred as Type-C).

Please choose the right way according to the host OS and the type of image file .

Before Start

What you need:

  • Firefly RK3288 development board
  • Image file
  • Host PC
  • Type-C Cable

There are two types of image file:

  • Packed image, often known as update.img, which contains the bootloader, parameter and all the partition image files. It is used for firmware release.
  • Non-packed image, like kernel.img, boot.img, recovery.img, etc, which are created during development.

You can download firmwares on compiled update.img, uncompress them after download. Or you can compile firmware by yourself according to Build Android .

Supported host OS:

  • Windows XP (32/64bit
  • Windows 7 (32/64bit)
  • Windows 8 (32/64bit)
  • Linux (32/64bit)

Windows

We used to need two utilities to flash rockchip image file:

  • RKBatchTool, used to flash update.img
  • RKDevelopTool, used to flash partition image file separately.

After that, Rockchip release new tool: AndroidTool. It is based on RKDevelopTool, but adds flashing support for update.img. So you can use this tool instead.

Before using the flashing utility, you need to install RK USB driver. If the driver is already installed, you can skip to next step.

Install RK USB Driver

Download Release_DriverAssistant.zip, uncompress it, then run DriverInstall.exe inside.

In order to use new driver for all the rockchip devices, please select "驱动卸载"(Driver uninstall), then "驱动安装"(Driver install).

driverassistant_install

Connect Device

There are two ways to switch the device to upgrade mode.

The first one, device is cut off all the power sources, such as power adapter and Type-C connection:

  1. Keep Type-A cable connected with host PC.
  2. Press and hold RECOVERY key.
  3. Connect Type-C cable to the device.
  4. After around two seconds, release RECOVERY key.

The other way:

  1. Use Type-C cable to connect host and device together.
  2. Press and hold RECOVERY key.
  3. Shortly press RESET key.
  4. After around two seconds, release RECOVERY key.

The host will prompt to have new device detected and configured. Open the Device Management, you'll find a new device name "Rockusb Device", as shown below. Return to previous step to reinstall driver if it is not shown.

devicemanager

Flash Image

Download AndroidTool. Uncompress it and change to directory AndroidTool_Release_v2.38.

AndroidTool defaults to display in Chinese. We need to change it to English. Open config.ini with an text editor (like notepad). The starting lines are:

#选择工具语言:Selected=1(中文);Selected=2(英文)
[Language]
Kinds=2
Selected=1
LangPath=Language\

Change "Selected=1" to "Selected=2", and save. From now on, AndroidTool will display in English.

Now, run AndroidTool.exe: (Note: If using Windows 7/8, you'll need to right click it, select to run it as Administrator)

AndroidTool

Flash update.img

Steps of flashing update.img:

  1. Switch to "Upgrade Firmware" tab page.
  2. Click "Firmware" button and open the image file. Detail information of the image file, like version and chip, is shown.
  3. Click "Upgrade" button to start flash.
  4. If upgrade fails, please try "LowerFormat" in the "Download Image" tab page first, then try again.

WARNING: If you flash firmware laoder different version of the original machine, please click "Erase Flash" before upgrading the firmware.

Android_Tool_burn

Steps of flashing partition images:

  1. Switch to "Download Image" tab page.
  2. Check the partitions you want.
  3. Make sure the image file's path is correct. Click the rightmost empty table cell to select new path if needed.
  4. Click "Run" button to start flashing. Device will reboot automatically when finish.
burn_partition

Linux

Rockchip provides a command line utility named "upgrade_tool" under Linux, which support flashing of both update.img and partition images.

We have two choices with regard to open source tools:

Both of them only support flashing partition images, not update.img. rkflashtool is a command line tool, and flashkit has a nice and easy to use GUI with command line support lately added. We only introduce rkflashkit below.

There is no need to install device driver. Just connect the device and host as described in the Windows section.

upgrade_tool

Download Linux_Upgrade_Tool, and install it to host filesystem:

   unzip Linux_Upgrade_Tool_v1.24.zip
   cd Linux_UpgradeTool_v1.24
   sudo mv upgrade_tool /usr/local/bin
   sudo chown root:root /usr/local/bin/upgrade_tool

NOTE: If you are prompted with the following error:

   upgrade_tool: error while loading shared libraries: libudev.so.1: cannot open shared object file: No such file or directory

You can use the following command to solve:

   sudo ln -sf /lib/i386-linux-gnu/libudev.so.0 /lib/i386-linux-gnu/libudev.so.1

Flash update.img:

   sudo upgrade_tool uf update.img

Flash partition images

   sudo upgrade_tool di -b /path/to/boot.img
   sudo upgrade_tool di -k /path/to/kernel.img
   sudo upgrade_tool di -s /path/to/system.img
   sudo upgrade_tool di -r /path/to/recovery.img
   sudo upgrade_tool di -m /path/to/misc.img
   sudo upgrade_tool di resource /path/to/resource.img
   sudo upgrade_tool di -p paramater   #flash parameter
   sudo upgrade_tool ul bootloader.bin #flash bootloader
   sudo upgrade_tool di trust /path/to/trust.img #flash trust

If errors occur due to flash problem, you can try to low format, or erase the flash:

   upgrade_tool lf   # low format flash
   upgrade_tool ef   # erase flash

rkflashkit

Install:

   sudo apt-get install build-essential fakeroot 
   git clone https://github.com/TeeFirefly/rkflashkit
   cd rkflashkit
   ./waf debian
   sudo apt-get install python-gtk2
   sudo dpkg -i rkflashkit_0.1.4_all.deb
  • GUI:
   sudo rkflashkit
rkflashkit
  • Command line:
$ rkflashkit --help
Usage: <cmd> [args] [<cmd> [args]...]

part                              List partition
flash @<PARTITION> <IMAGE FILE>   Flash partition with image file
cmp @<PARTITION> <IMAGE FILE>     Compare partition with image file
backup @<PARTITION> <IMAGE FILE>  Backup partition to image file
erase  @<PARTITION>               Erase partition
reboot                            Reboot device

For example, flash device with boot.img and kernel.img, then reboot:

sudo rkflashkit flash @boot boot.img @kernel.img kernel.img reboot

See the example above, which is really handy to flash multiple images then reboot device in one command, especially good for developers who will compile and flash kernel again and again.

FAQs

Q1: How to Enter MaskRom Mode?

A1: If Loader mode is not available and SD card boot also fails, you might need to enforce the device into MaskRom mode. Please check here.