qualcommax: ipq807x: fix sysupgrade for ZBT-Z800AX
authorChukun Pan <amadeus@jmu.edu.cn>
Mon, 10 Jun 2024 15:18:19 +0000 (23:18 +0800)
committerRobert Marko <robimarko@gmail.com>
Thu, 13 Jun 2024 16:01:03 +0000 (18:01 +0200)
This router has two rootfs partitions and dualboot is used.
Vendor firmware may swap the rootfs partition location, u-boot append
'ubi.mtd=rootfs' in the end of cmdline. Since we use fixed-partitions,
force boot from the first rootfs partition to avoid boot failure.

Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn>
Link: https://github.com/openwrt/openwrt/pull/15700
Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq8072-zbt-z800ax.dts
target/linux/qualcommax/ipq807x/base-files/lib/upgrade/platform.sh

index c352b725676ba86db732106d8587fa0e5b1c0ff2..814a7cb2bd9df1da2c9345566bc7664f6ca61f27 100644 (file)
                        partition@60000 {
                                label = "0:bootconfig";
                                reg = <0x60000 0x20000>;
-                               read-only;
                        };
 
                        partition@80000 {
                                label = "0:bootconfig1";
                                reg = <0x80000 0x20000>;
-                               read-only;
                        };
 
                        partition@a0000 {
index 200833421365d2d376f0929e6190a99ee2743637..5d89554133fe1755af6c909e0e27a8808377c66e 100644 (file)
@@ -53,8 +53,7 @@ platform_do_upgrade() {
        netgear,sxs80|\
        netgear,wax218|\
        netgear,wax620|\
-       netgear,wax630|\
-       zbtlink,zbt-z800ax)
+       netgear,wax630)
                nand_do_upgrade "$1"
                ;;
        buffalo,wxr-5950ax12)
@@ -132,6 +131,18 @@ platform_do_upgrade() {
                fw_setenv upgrade_available 1
                nand_do_upgrade "$1"
                ;;
+       zbtlink,zbt-z800ax)
+               local mtdnum="$(find_mtd_index 0:bootconfig)"
+               local alt_mtdnum="$(find_mtd_index 0:bootconfig1)"
+               part_num="$(hexdump -e '1/1 "%01x|"' -n 1 -s 168 -C /dev/mtd$mtdnum | cut -f 1 -d "|" | head -n1)"
+               # vendor firmware may swap the rootfs partition location, u-boot append: ubi.mtd=rootfs
+               # since we use fixed-partitions, need to force boot from the first rootfs partition
+               if [ "$part_num" -eq "1" ]; then
+                       mtd erase /dev/mtd$mtdnum
+                       mtd erase /dev/mtd$alt_mtdnum
+               fi
+               nand_do_upgrade "$1"
+               ;;
        zte,mf269)
                CI_KERN_UBIPART="ubi_kernel"
                CI_ROOT_UBIPART="rootfs"