RK3568 Linux updateEngine升级方案落地

简介:Rockchip Linux 平台支持两种启动方案,Recovery 模式和Linux A/B 模式:

  1. Recovery 模式,设备上有一个单独的分区(recovery)用于升级操作。
  2. Linux A/B 模式,设备上有两套固件,可切换使用。这两种启动模式各有优缺点,用户根据需求选择使用。

工作目标:

实现 Recovery 模式下本地升级固件

工作内容:

1.增加 misc 和 recovery 分区

diff --git a/device/rockchip/rk356x/parameter-buildroot-proav-slc-nand-128M.txt b/device/rockchip/rk356x/parameter-buildroot-proav-slc-nand-128M.txt
index b32e3977c..bf06eb17f 100755
--- a/device/rockchip/rk356x/parameter-buildroot-proav-slc-nand-128M.txt
+++ b/device/rockchip/rk356x/parameter-buildroot-proav-slc-nand-128M.txt
@@ -8,5 +8,5 @@ MACHINE: 0xffffffff
 CHECK_MASK: 0x80
 PWR_HLD: 0,0,A,0,1
 TYPE: GPT
-CMDLINE: mtdparts=rk29xxnand:0x00000800@0x00004000(vnvm),0x00002000@0x00004800(uboot),0x00007000@0x00006800(boot),0x0002a000@0x0000d800(rootfs),-@0x00037800(userdata:grow)
+CMDLINE: mtdparts=rk29xxnand:0x00000800@0x00004000(vnvm),0x00002000@0x00004800(uboot),0x00000200@0x00006800(misc),0x00007000@0x00006a00(boot),0x0000e000@0x0000da00(recovery),0x00018000@0x0001ba00(rootfs),-@0x00033a00(userdata:grow)
 uuid:rootfs=614e0000-0000-4b53-8000-1d28000054a9

2. 增加分区后,记得修改 dts 中的 ubi.mtd 参数

diff --git a/kernel/arch/arm64/boot/dts/rockchip/rk3566-proav-tx-wh300b-linux-spi-nand.dts b/kernel/arch/arm64/boot/dts/rockchip/rk3566-proav-tx-wh300b-linux-spi-nand.dts
index c28d3de33..dec39660e 100755
--- a/kernel/arch/arm64/boot/dts/rockchip/rk3566-proav-tx-wh300b-linux-spi-nand.dts
+++ b/kernel/arch/arm64/boot/dts/rockchip/rk3566-proav-tx-wh300b-linux-spi-nand.dts
@@ -13,7 +13,7 @@
        compatible = "rockchip,rk3568-nvr-demo-ddr4-v10-linux-spi-nand", "rockchip,rk3568";
 
        chosen {
-               bootargs = "earlycon=uart8250,mmio32,0xfe660000 console=ttyFIQ0 ubi.mtd=3 root=ubi0:rootfs rootfstype=ubifs";
+               bootargs = "earlycon=uart8250,mmio32,0xfe660000 console=ttyFIQ0 ubi.mtd=5 root=ubi0:rootfs rootfstype=ubifs";
        };

3. Buildroot:rootfs 配置文件选择如下(make menuconfig)

BR2_PACKAGE_RECOVERY=y #开启升级相关功能
BR2_PACKAGE_RECOVERY_USE_UPDATEENGINE=y #使用新升级程序
BR2_PACKAGE_RECOVERY_UPDATEENGINEBIN=y #编译新升级程序
BR2_PACKAGE_RECOVERY_NO_UI=y # 关掉UI(不带屏)

4. 编译

 1. source envsetup.sh
 2. 选择某一个平台的rootfs配置
 3. ./build.sh allsave
 4. 重新烧写固件

5. OTA升级

本地升级,且可指定要升级的分区,在normal系统运行如下命令:

updateEngine --image_url=/userdata/update.img --misc=update \--savepath=/userdata/update.img --reboot &

流程介绍:

  1. 固件版本比较(–version_url)
  2. 下载固件(–image_url),并保存到本地(–savepath)
  3. 升级recovery 分区
  4. 重启(–reboot)
  5. 进入recovery模式,升级指定的分区(–partition)
  6. 升级成功,重启进入normal系统

可缺省参数:

  1. –version_url:远程地址或本地地址,没有设置该参数,则不会进行版本比较
  2. –savepath:固件保存地址,缺省时为/tmp/update.img,建议传入/userdata/update.img
  3. –partition:设置将要升级的分区,建议使用0x3FFC00,不支持升级parameter 和loader分区。详见 参数说明章节。
  4. –reboot:升级recovery 完后,重启进入recovery模式

6. 以升级 boot 为例:

  1. 修改 rk356x-package-file 文件
+++ b/tools/linux/Linux_Pack_Firmware/rockdev/rk356x-package-file
@@ -5,15 +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
 #resource      Image/resource.img
 #kernel        Image/kernel.img
 boot           Image/boot.img
 #recovery      Image/recovery.img
 #rootfs         Image/rootfs.img
 #oem           Image/oem.img
 #userdata      Image/userdata.img
  1. 执行命令 ./build.sh updateimg 打包出 update.img 固件
kuli@swdev21:~/rk356x/rockdev$ ls -alh update.img 
-rw-rw-r-- 1 kuli kuli 12M Jul 23 09:38 update.img
  1. 升级命令如下:
updateEngine --image_url=/userdata/update.img --misc=update --savepath=/tmp/update.img --partition=0x80000 --reboot &

7. updateEngine主要包含升级分区和写Misc配置功能,支持命令参数如下:

*** update_engine: Version V1.1.0 ***.
–misc=now Linux A/B mode: Setting the current partition to bootable.
–misc=other Linux A/B mode: Setting another partition to bootable.
–misc=update Recovery mode: Setting the partition to be upgraded.
–misc=wipe_userdata Format data partition.–update Upgrade mode.
–partition=0x3FFC00 Set the partition to be upgraded.(NOTICE: OTA not supportupgrade loader and parameter)
0x3FFC00: 0011 1111 1111 1100 0000 0000.
uboot trust boot recovery rootfs oemuboot_a uboot_b boot_a boot_b system_a system_b.
000000000000000000000000: reserved
100000000000000000000000: Upgrade loader
010000000000000000000000: Upgrade parameter
001000000000000000000000: Upgrade uboot
000100000000000000000000: Upgrade trust
000010000000000000000000: Upgrade boot
000001000000000000000000: Upgrade recovery
000000100000000000000000: Upgrade rootfs
000000010000000000000000: Upgrade oem
000000001000000000000000: Upgrade uboot_a
000000000100000000000000: Upgrade uboot_b
000000000010000000000000: Upgrade boot_a
000000000001000000000000: Upgrade boot_b
000000000000100000000000: Upgrade system_a
000000000000010000000000: Upgrade system_b
000000000000001000000000: Upgrade misc
000000000000000100000000: Upgrade userdata
–reboot Restart the machine at the end of the program.
–version_url=url The path to the file of version.
–image_url=url Path to upgrade firmware.
–savepath=url save the update.img to url.
在这里插入图片描述

参考文档

Rockchip_Developer_Guide_Linux_Upgrade_CN.pdf

  • 25
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值