7. Deploy a disk image#

This chapter describe how to write a disk image as generated in one of the previous chapters using Yocto or Debian to the module.

Note

The variable SDCARD_IMG must be already set as described in respective chapter.

Warning

Avoid having the disk image on both the SD Card and the internal eMMC of the module.

As the Linux kernel on the module uses PARTLABEL and PARTUUID to identify partitions to mount, it will be unpredictable whether the SD Card or the internal eMMC is used.

7.1. Deploy on SD Card#

Insert an SD card into the host PC and check dmesg -w to find out the device name that was used.

Then, run this command, replacing /dev/sdX with the real device name:

sudo dd bs=1M conv=nocreat oflag=direct status=progress if="$SDCARD_IMG" of=/dev/sdX

7.2. Deploy on internal eMMC#

7.2.1. Compile rkdeveloptool#

To write the image directly onto the on-board eMMC, the flashing tool rkdeveloptool is used, and it must be compiled on the host PC:

# Install compile dependencies
sudo apt-get -y install git libudev-dev libusb-1.0-0-dev dh-autoreconf pkg-config build-essential

# Download rkdeveloptool source code
git clone https://github.com/rockchip-linux/rkdeveloptool.git
cd rkdeveloptool || return

# Compile rkdeveloptool
autoreconf -i
CPPFLAGS=-Wno-format-truncation ./configure
make

# Download miniloaders used for flashing
git clone https://github.com/rockchip-linux/rkbin.git tools/rk_tools

# Build miniloader binaries
(
cd tools/rk_tools/ || return
./tools/boot_merger RKBOOT/PX30MINIALL.ini
)

# Make the resulting files available to later steps
export RKDEVELOPTOOL_DIR="$PWD"

This step should take about 1 minute total.

7.2.2. Enter USB flashing mode#

To enter the USB flashing mode, make sure the BOOT SW slider (see Fig. 3.1 HAIKOU CB-MINI-ITX with RINGNECK SOM-PX30-uQ7) is in BIOS Disable mode and there’s no SD card inserted in HAIKOU CB-MINI-ITX.

Then, insert a micro-USB cable into the USB-OTG port (see Fig. 3.8 USB 2.0 OTG port (dual-role port: can be used as a host or device interface)) on HAIKOU CB-MINI-ITX and into a USB port of your host PC.

Then, power cycle the device by unplugging and replugging the power supply or by pressing the Reset button. The lsusb command on your host PC should return the following:

$ lsusb -d 2207:330d
Bus 001 Device 028: ID 2207:330d Fuzhou Rockchip Electronics Company

Now, put the BOOT SW slider back into the Normal Boot mode.

7.2.3. Flash the eMMC#

Warning

The BOOT SW slider must be back in Normal Boot mode, otherwise the eMMC is inaccessible and stays empty. You will see rkdeveloptool making improbably quick write progress in this case.

To write the image file path stored in the variable SDCARD_IMG to the on-board eMMC, run:

cd "$RKDEVELOPTOOL_DIR" || return
sudo ./rkdeveloptool db tools/rk_tools/px30_loader_v*.bin && sleep 1
sudo ./rkdeveloptool wl 0 "$SDCARD_IMG"
sudo ./rkdeveloptool rd

This step should take about 1 minute for the Debian image.