[openwrt/openwrt] gemini: Fix up sysupgrade platform.sh script

LEDE Commits lede-commits at lists.infradead.org
Tue Feb 10 23:48:19 PST 2026


linusw pushed a commit to openwrt/openwrt.git, branch openwrt-25.12:
https://git.openwrt.org/26f776335a846f3b77ff06c61a6e1a2f3708273d

commit 26f776335a846f3b77ff06c61a6e1a2f3708273d
Author: Linus Walleij <linusw at kernel.org>
AuthorDate: Sun Jan 25 19:01:45 2026 +0100

    gemini: Fix up sysupgrade platform.sh script
    
    The Storlink reference designs sometimes fail upgrade because
    not the entire partition is used, so the size isn't equal to
    the actual flash space available for the partition.
    
    Fix this by calculating the actual partition sizes by measuring
    across the partition offsets instead.
    
    Link: https://github.com/openwrt/openwrt/pull/21750
    (cherry picked from commit 04bc0b6d3f440cc139d6e320cba165b37cda9c9b)
    Link: https://github.com/openwrt/openwrt/pull/21973
    Signed-off-by: Linus Walleij <linusw at kernel.org>
---
 .../gemini/base-files/lib/upgrade/platform.sh      | 36 ++++++++++++----------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/target/linux/gemini/base-files/lib/upgrade/platform.sh b/target/linux/gemini/base-files/lib/upgrade/platform.sh
index 9fb57a2826..f7620fd244 100644
--- a/target/linux/gemini/base-files/lib/upgrade/platform.sh
+++ b/target/linux/gemini/base-files/lib/upgrade/platform.sh
@@ -2,18 +2,26 @@ REQUIRE_IMAGE_METADATA=1
 MTDSYSFS=/sys/class/mtd
 
 gemini_do_platform_upgrade() {
+	MTD1OF=`cat ${MTDSYSFS}/mtd1/offset`
+	MTD2OF=`cat ${MTDSYSFS}/mtd2/offset`
+	MTD3OF=`cat ${MTDSYSFS}/mtd3/offset`
+	MTD4OF=`cat ${MTDSYSFS}/mtd4/offset`
+	MTD1SZ=$((${MTD2OF} - ${MTD1OF}))
+	MTD2SZ=$((${MTD3OF} - ${MTD2OF}))
+	MTD3SZ=$((${MTD4OF} - ${MTD3OF}))
 	ESZ=`cat ${MTDSYSFS}/mtd1/erasesize`
 	if test ${ESZ} == 131072 ; then
-		echo "MTD1 has 128kb EB size..."
+		echo "MTD has 128kb EB size"
 	else
-		echo "MTD1 has wrong EB size!"
+		echo "MTD has wrong EB size!"
 	fi
-	NAME=`cat ${MTDSYSFS}/mtd1/name`
-	SZ=`cat ${MTDSYSFS}/mtd1/size`
 	KSZ=$(($ESZ * $2))
+	RSZ=$(($ESZ * $3))
+	ASZ=$(($ESZ * $4))
+	NAME=`cat ${MTDSYSFS}/mtd1/name`
 	if test "x${NAME}" == "xKern" ; then
-		if test ${SZ} == ${KSZ} ; then
-			echo "MTD1 OK..."
+		if test ${MTD1SZ} == ${KSZ} ; then
+			echo "MTD1 Kern ${MTD1SZ} OK..."
 		else
 			echo "MTD1 is wrong size, aborting" >&2
 			exit 1
@@ -23,13 +31,11 @@ gemini_do_platform_upgrade() {
 		exit 1
 	fi
 	NAME=`cat ${MTDSYSFS}/mtd2/name`
-	SZ=`cat ${MTDSYSFS}/mtd2/size`
-	RSZ=$(($ESZ * $3))
 	if test "x${NAME}" == "xRamdisk" ; then
-		if test ${SZ} == ${RSZ} ; then
-			echo "MTD2 OK..."
+		if test ${MTD2SZ} == ${RSZ} ; then
+			echo "MTD2 Ramdisk ${MTD2SZ} OK..."
 		else
-			echo "MTD2 is wrong size, aborting" >&2
+			echo "MTD2 is at wrong offset, aborting" >&2
 			exit 1
 		fi
 	else
@@ -37,13 +43,11 @@ gemini_do_platform_upgrade() {
 		exit 1
 	fi
 	NAME=`cat ${MTDSYSFS}/mtd3/name`
-	SZ=`cat ${MTDSYSFS}/mtd3/size`
-	ASZ=$(($ESZ * $4))
 	if test "x${NAME}" == "xApplication" ; then
-		if test ${SZ} == ${ASZ} ; then
-			echo "MTD3 OK..."
+		if test ${MTD3SZ} == ${ASZ} ; then
+			echo "MTD3 Application ${MTD3SZ} OK..."
 		else
-			echo "MTD3 is wrong size, aborting" >&2
+			echo "MTD3 is at wrong offset, aborting" >&2
 			exit 1
 		fi
 	else




More information about the lede-commits mailing list