System Upgrade via OTA on RK3588 Platform

With the continuous development of AI technologies, system upgrades are crucial for enhancing features and maintaining performance. This document will guide you step by step on how to use OTA technology for system upgrades on the RK3588 platform, helping developers better understand the upgrade process and note key considerations.

1. Check if the system contains the userdata partition

Execute the following command on the board to check if /userdata exists:

ls /userdata

If the userdata partition does not exist, you will need to enable this partition in the SDK configuration.

Enable userdata partition
Modify the parameter.txt configuration file in the SDK:
File path: SDK/Linux_Pack_Firmware/rockdev/rk3588-package-file

--- a/device/rockchip/rk3588/parameter.txt
+++ b/device/rockchip/rk3588/parameter.txt
@@ -8,6 +8,6 @@ MACHINE: 0xffffffff
 CHECK_MASK: 0x80
 PWR_HLD: 0,0,A,0,1
 TYPE: GPT
-CMDLINE: mtdparts=rk29xxnand:0x00000800@0x00001800(env),0x00002000@0x00004000(uboot),0x00002000@0x00006000(misc),0x00020000@0x00008000(boot),0x00040000@0x00028000(recovery),0x00010000@0x00068000(backup),-@0x00078000(rootfs:grow)
+CMDLINE: mtdparts=rk29xxnand:0x00002000@0x00004000(uboot),0x00002000@0x00006000(misc),0x00020000@0x00008000(boot),0x00040000@0x00028000(recovery),0x00010000@0x00068000(backup),0x01c00000@0x00078000(rootfs),0x00040000@0x01c78000(oem),-@0x01cb8000(userdata:grow)
 uuid:rootfs=614e0000-0000-4b53-8000-1d28000054a9
 uuid:boot=7A3F0000-0000-446A-8000-702F00006273

Modify the rk3588-package-file configuration file in the SDK:

--- a/tools/linux/Linux_Pack_Firmware/rockdev/rk3588-package-file
+++ b/tools/linux/Linux_Pack_Firmware/rockdev/rk3588-package-file
@@ -12,7 +12,8 @@ misc          Image/misc.img
 boot           Image/boot.img
 recovery       Image/recovery.img
 rootfs         Image/rootfs.img
+userdata      Image/userdata.img

If you are using the Ubuntu filesystem, you also need to modify the fstab configuration file in the SDK:

--- a/ubuntu/overlay/etc/fstab
+++ b/ubuntu//overlay/etc/fstab
@@ -9,4 +9,4 @@ sysfs                           /sys                    sysfs           defaults                0       0
 debugfs        /sys/kernel/debug       debugfs defaults        0 0
 pstore /sys/fs/pstore  pstore  defaults        0 0
 #PARTLABEL=oem /oem    ext2    defaults        0 2
-#PARTLABEL=userdata    /userdata       ext2    defaults        0 2
+PARTLABEL=userdata     /userdata       ext2    defaults        0 2

2. Compile Recovery Related Programs

  • external/recovery: Mainly generates the recovery binary bin program, which is the key program in recovery mode.
  • external/rkupdate: Mainly generates the rkupdate binary bin program, which parses the update.img firmware and performs upgrades for each partition. This program is called internally by the recovery binary bin program.

To compile after modifying these two directories’ source files:

1. source envsetup.sh
2. Choose the recovery configuration for a platform
3. make recovery-dirclean && make recovery
4. make rkupdate-dirclean && make rkupdate
5. ./build.sh recovery
6. ./mkfirmware.sh
7. Write recovery.img

3. Upgrade Process

3.1 Compile Each Component

./build.sh // Compile uboot, kernel, and rootfs
./build.sh debian // Compile Debian filesystem; if Ubuntu filesystem, run ./build.sh focal

3.2 Package Complete Firmware

./build.sh updateimg // Generate the complete firmware `update.img`, saved in SDK/rockdev/update.img

3.3 Check the Compatible Field After Upgrade

cat /proc/device-tree/compatible

It should display something like neardi,lkd3588-linux-f04,rockchip,rk3588.

4. OTA Upgrade Package Preparation

Modify the tools/linux/Linux_Pack_Firmware/rockdev/package-file file based on the partitions you need to upgrade. The upgrade package can contain only certain partitions to reduce the package size.

Note:

  • The recovery.img in the upgrade package will not be upgraded in recovery mode to avoid partition damage in case of power failure. This partition will be upgraded in normal system mode.
  • It is not recommended to include the misc partition in the upgrade package, as it will be cleared after a successful upgrade.
  • If the upgrade package is stored in the userdata partition, ensure that the userdata.img is not included in the package-file to avoid filesystem corruption.

Example: Upgrade only boot.img

Modify the Device Tree
Edit the device tree file kernel/arch/arm64/boot/dts/rockchip/rk3588-neardi-linux-lkd3588-f0.dts:

--- a/kernel/arch/arm64/boot/dts/rockchip/rk3588-neardi-linux-lkd3588-f0.dts
+++ b/kernel/arch/arm64/boot/dts/rockchip/rk3588-neardi-linux-lkd3588-f0.dts
@@ -24,5 +24,5 @@
 #include "rk3588-neardi-linux-ld160-ov13855-os04a10-dphy1.dtsi"  //dphy1
 / {
        model = "Rockchip RK3588 NEARDI LKD3588 Board";
-       compatible = "neardi,lkd3588-linux-f04,", "rockchip,rk3588";
+       compatible = "neardi,lkd3588-linux-f05,", "rockchip,rk3588";
 };

Compile the Kernel

./build.sh kernel

Modify the rk3588-package-file
In the tools/linux/Linux_Pack_Firmware/rockdev/rk3588-package-file, keep only boot.img:

--- a/tools/linux/Linux_Pack_Firmware/rockdev/rk3588-package-file
+++ b/tools/linux/Linux_Pack_Firmware/rockdev/rk3588-package-file
@@ -5,14 +5,15 @@ package-file  package-file
 bootloader     Image/MiniLoaderAll.bin
 parameter      Image/parameter.txt
 #trust         Image/trust.img
-uboot          Image/uboot.img
-misc           Image/misc.img
+#uboot         Image/uboot.img
+#misc          Image/misc.img
 #resource      Image/resource.img
 #kernel        Image/kernel.img
 boot           Image/boot.img
 recovery       Image/recovery.img
-rootfs         Image/rootfs.img
+#rootfs        Image/rootfs.img
+#oem           Image/oem.img
+#userdata      Image/userdata.img

Package the Upgrade Package

./build.sh updateimg

5. Perform the Upgrade

Copy the update.img generated on the build server to the device’s /userdata directory:

sudo scp neardi@192.168.1.200:~/sdk/rk3588/linux/rk3588-linux/rockdev/update.img /userdata/

Run the OTA Upgrade Command:

sudo update ota /userdata/update.img

Monitor the upgrade process through serial debugging:

Checking in progress on 1 disk (24.2% complete)
Checking in progress on 1 disk (25.6% complete)

After the upgrade is completed, verify if the compatible field is updated:

cat /proc/device-tree/compatible

If it displays neardi,lkd3588-linux-f05, the upgrade was successful.