summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij2026-01-25 18:01:45 +0000
committerLinus Walleij2026-02-11 07:47:45 +0000
commit26f776335a846f3b77ff06c61a6e1a2f3708273d (patch)
tree85ef240ce68c31c232cede17f7a53d863bd13467
parent0a5e9bc6629f7f76e024f69acb9f2a412fc7003d (diff)
downloadopenwrt-26f776335a846f3b77ff06c61a6e1a2f3708273d.tar.gz
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@kernel.org>
-rw-r--r--target/linux/gemini/base-files/lib/upgrade/platform.sh36
1 files 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