RK3588 Supports USB Installation

The Rockchip platform typically updates the system through flashing. However, during some project evaluations, clients often require the ability to install the system. To enable USB installation on the RK platform, slight modifications to U-Boot are necessary to ensure that the U-Boot stage can properly load the uImage, uInitrd, and dtb files from the USB drive. The main points are introduced as follows:

1. File List

RK3588 Supports USB Installation

This is the content of the USB installation files, mainly divided into:

boot directory contains the uImage and uInitrd required for U-Boot startup, as well as the extlinux.conf needed for sysboot startup. Mainly used for system installation startup.
casper directory contains the image files required for the Rockchip platform.
logo.bmp and logo_kernel.bmp are the boot images needed during installation. If you want to use other boot images, you can modify and replace these images individually.
autorun.inf and kylin.ico are the USB auto-run file and USB icon file.

1.1 extlinux.conf

The file content is as follows:

default install
menu title Installer
prompt 0
timeout 10
label install
 menu label kylinos installer
 linux /boot/uImage
 initrd /boot/uInitrd
 append console=tty0 loglevel=0

This sets the default startup for uImage and uInitrd.

1.2 parameter-kylin.txt

The file content is as follows:

FIRMWARE_VER: 1.0
MACHINE_MODEL: RK3588
MACHINE_ID: 007
MANUFACTURER: RK3588
MAGIC: 0x5041524B
ATAG: 0x00200800
MACHINE: 0xffffffff
CHECK_MASK: 0x80
PWR_HLD: 0,0,A,0,1
TYPE: GPT
CMDLINE: mtdparts=rk29xxnand:0x00004000@0x00004000(uboot),0x00002000@0x00008000(misc),0x00080000@0x0000a000(boot:bootable),0x00800000@0x0008a000(backup),0x01400000@0x0088a000(rootfs),-@0x01c8a000(userdata:grow)
uuid:rootfs=614e0000-0000-4b53-8000-1d28000054a9

This is the description file for the system partitions needed during installation, similar to the parameter.txt file of the RK platform.

1.3 uboot-usb.img

This is the U-Boot image that supports the machine’s default USB boot. If you need to use USB installation, you must update the original U-Boot image to this image. This image has additional measures based on U-Boot:

U-Boot has a built-in device tree to ensure USB functionality is normal.
U-Boot defaults to USB boot priority.
U-Boot defaults to support displaying boot images from the USB drive.

1.4 idblock.bin/rk3588_spl_loader_xxx.bin

These are the loader binary files for the RK platform. Two files need to be placed here: idblock.bin is used during installation, while rk3588_spl_loader_xxx.bin is used during flashing.

2. Boot Modification Points

2.1 U-Boot Configuration

diff --git a/configs/rockchip-linux.config b/configs/rockchip-linux.config
index 3003d81..cee40ce 100644
--- a/configs/rockchip-linux.config
+++ b/configs/rockchip-linux.config
@@ -5,3 +5,6 @@ CONFIG_DM_PCA953X=y
 CONFIG_SPL_FIT_IMAGE_KB=4096
 CONFIG_CHECK_VERSION_CHOOSE_DTB=y
 CONFIG_PHY_ROCKCHIP_NANENG_COMBOPHY=y
+CONFIG_EMBED_KERNEL_DTB=y
+CONFIG_EMBED_KERNEL_DTB_PATH="dts/rockchip-evb_rk3588.dtb"
+CONFIG_EMBED_KERNEL_DTB_ALWAYS=n
2.2 Display Specific Logo on Boot
diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index 9ed6b98..c1ec5e2 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -29,6 +29,7 @@
 #define BOOTENV_SHARED_BLKDEV_BODY(devtypel) \
 "if " #devtypel " dev ${devnum}; then " \
 "setenv devtype " #devtypel "; " \
+ "rockchip_show_logo;" \
 "run scan_dev_for_boot_part; " \
 "fi\0"

2.3 Default USB Boot

diff --git a/include/configs/rockchip-common.h b/include/configs/rockchip-common.h
index 002dcd6..0566ece 100644
--- a/include/configs/rockchip-common.h
+++ b/include/configs/rockchip-common.h
@@ -162,7 +162,14 @@
 "setenv devtype ramdisk; setenv devnum 0;" \
 "fi; \0"
-#if defined(CONFIG_AVB_VBMETA_PUBLIC_KEY_VALIDATE)
+#if defined(CONFIG_EMBED_KERNEL_DTB)
+#define RKIMG_BOOTCOMMAND \
+ "run usb_boot;" \
+ "boot_android ${devtype} ${devnum};" \
+ "boot_fit;" \
+ "bootrkp;" \
+ "run distro_bootcmd;"
+#elif defined(CONFIG_AVB_VBMETA_PUBLIC_KEY_VALIDATE)

2.4 Character Terminal Font

Modified: drivers/tty/vt/selection.c
Modified: drivers/tty/vt/vt.c
Modified: drivers/video/fbdev/core/bitblit.c
Modified: drivers/video/fbdev/core/fbcon.c
Modified: drivers/video/fbdev/core/fbcon.h
Modified: drivers/video/fbdev/core/fbcon_ccw.c
Modified: drivers/video/fbdev/core/fbcon_cw.c
Modified: drivers/video/fbdev/core/fbcon_rotate.c
Modified: drivers/video/fbdev/core/fbcon_ud.c
Modified: include/linux/fb.h
Modified: include/linux/font.h
Modified: lib/fonts/Kconfig
Modified: lib/fonts/Makefile
New file: lib/fonts/font_cjk_16x16.c
New file: lib/fonts/font_cjk_16x16.h
New file: lib/fonts/font_cjk_32x32.c
New file: lib/fonts/font_cjk_32x32.h
Modified: lib/fonts/fonts.c

2.5 Default Log Screen Instead of Serial Port

diff --git a/arch/arm64/boot/dts/rockchip/rk3588s-pc.dtsi b/arch/arm64/boot/dts/rockchip/rk3588s-pc.dtsi
index e49f5fa..ff182b1 100644
--- a/arch/arm64/boot/dts/rockchip/rk3588s-pc.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3588s-pc.dtsi
@@ -10,7 +10,7 @@
/ {
 chosen: chosen {
- bootargs = "earlycon=uart8250,mmio32,0xfeb50000 console=ttyFIQ0 irqchip.gicv3_pseudo_nmi=0 root=PARTLABEL=rootfs rootfstype=ext4 ro rootwait overlayroot=device:dev=PARTLABEL=userdata,fstype=ext4,mkfs=1 coherent_pool=1m systemd.gpt_auto=0 cgroup_enable=memory swapaccount=1 net.ifnames=0";
+ bootargs = "earlycon=uart8250,mmio32,0xfeb50000 irqchip.gicv3_pseudo_nmi=0 root=PARTLABEL=rootfs rootfstype=ext4 ro rootwait overlayroot=device:dev=PARTLABEL=userdata,fstype=ext4,mkfs=1 coherent_pool=1m systemd.gpt_auto=0 cgroup_enable=memory swapaccount=1 net.ifnames=0";
 };

2.6 Support for exFAT

diff --git a/arch/arm64/configs/linux.config b/arch/arm64/configs/linux.config
index 9a23fc2..6c569cd 100644
--- a/arch/arm64/configs/linux.config
+++ b/arch/arm64/configs/linux.config
@@ -6,6 +6,7 @@ CONFIG_TOUCHSCREEN_HX83102=y
 CONFIG_CAN=y
 CONFIG_CANFD_ROCKCHIP=y
 CONFIG_OVERLAY_FS=y
+CONFIG_EXFAT_FS=y
 CONFIG_SND_SOC_FIREFLY_MULTICODECS=y

2.7 fit Support for Ramdisk Packaging

diff --git a/boot.its b/boot.its
index 755005c..885bfd1 100644
--- a/boot.its
+++ b/boot.its
@@ -45,6 +45,21 @@
 algo = "sha256";
 };
 };
+
+ ramdisk {
+ description = "Compressed Initramfs";
+ data = /incbin/("ramdisk");
+ type = "ramdisk";
+ arch = "arm64";
+ os = "linux";
+ compression = "none";
+ load = <0x00000000>;
+ entry = <0x00000000>;
+
+ hash {
+ algo = "sha256";
+ };
+ };
 };
configurations {
@@ -55,6 +70,7 @@
 fdt = "fdt";
 kernel = "kernel";
 multi = "resource";
+ ramdisk = "ramdisk";

3. Boot Script

Reference repository: <span>https://gitlab2.kylin.com/shanghai-team/ramdisk/-/tree/ramdisk-trial</span>

The boot process runs as follows:

function start_install()
{
 parse_cmdline
 prepare_iso

 if [ "${TRIAL}" == "true" ];then
 overlay_start
 return 0
 fi

while true
 do
 clear
 info "Thank you for using Kylin System, please select the installation mode"
 info "1) Try out"
 info "2) Install"
 info "3) Debug"
 info "4) Restart"
 info "Please enter:"
 read -s -n1 -t 30 -r option
 case ${option} in
 1)
 overlay_start
 return 0
 ;;
 2)
 _start_install
 ;;
 3)
 debug_shell
 ;;
 4)
 echo b &gt; /proc/sysrq-trigger
 info "Your system does not support restart"
 ;;
 *)
 [ -z ${option} ] &amp;&amp; _start_install
 ;;
 esac
done
}

4. Adaptation Process

  • Obtain the RK3588 product version image
  • Create a USB boot disk by any means
  • Flash the U-Boot of the target machine to uboot_usb.img using rkdevtool to support USB boot
  • Insert the USB drive into the device and power on → wait for the machine to display the green characters “Thank you for using Kylin System, please select the installation mode”
  • Select 1 to try out, select 2 to install, select 3 to debug, select 4 to restart

5. Development Process

  • Obtain the device U-Boot code
  • Embed the device tree in the dtb directory
  • Modify the CONFIG_EMBED_KERNEL_DTB_PATH variable to the specified dtb
  • Compile U-Boot to uboot-usb.img for USB boot version
  • Compile the native loader.bin into idblock.img and rkxxx.bin
  • Package ramdisk.img into the kernel
  • Clone the ramdisk.git repository to compile ramdisk.img/initrd.lz/initrd.img/uInitrd
  • Compile the kernel into boot.img/uImage
  • Place the boot images in the root directory of the boot disk logo_kernel.bmp/logo.bmp
  • Write parameter-kylin.txt for the project
  • Package the ISO

6. Conclusion

At this point, a complete solution for installing the system using USB on the RK3588 has been obtained. If clients require the device to support USB installation, they only need the U-Boot code and kernel code of the device to configure it properly. Version 49340 supports the U-Boot installation ISO image for a specific board.

For other articles, please follow the public account: Kylin Embedded

Leave a Comment