diff options
| author | Linus Walleij | 2026-01-29 22:40:50 +0000 |
|---|---|---|
| committer | Linus Walleij | 2026-02-11 07:47:45 +0000 |
| commit | 40b5a83fdb9934e92ee875668c828112cce61881 (patch) | |
| tree | 3d159e0ff9caa4aae281a69b29c3bf38769feab0 | |
| parent | 43547e93144432f535b1a852eb365fb37c66e401 (diff) | |
| download | openwrt-40b5a83fdb9934e92ee875668c828112cce61881.tar.gz | |
gemini: use tar stream to write firmware
The firmware update file can get big, so instead of extracting
the whole file into the tmp folder potentially running out of space
and make the upgrade fail, stream from tar xvf -O directly to the
mtd write command.
Refactor the checking of partitions and the actual upgrade into
two steps when we are at it.
Link: https://github.com/openwrt/openwrt/pull/21782
(cherry picked from commit 1977301b5f8f76b4d04b5950b09b2fd7cf607bc4)
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.sh | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/target/linux/gemini/base-files/lib/upgrade/platform.sh b/target/linux/gemini/base-files/lib/upgrade/platform.sh index f7620fd244..0547be8fb0 100644 --- a/target/linux/gemini/base-files/lib/upgrade/platform.sh +++ b/target/linux/gemini/base-files/lib/upgrade/platform.sh @@ -1,7 +1,7 @@ REQUIRE_IMAGE_METADATA=1 MTDSYSFS=/sys/class/mtd -gemini_do_platform_upgrade() { +gemini_check_redboot_parts() { MTD1OF=`cat ${MTDSYSFS}/mtd1/offset` MTD2OF=`cat ${MTDSYSFS}/mtd2/offset` MTD3OF=`cat ${MTDSYSFS}/mtd3/offset` @@ -54,19 +54,23 @@ gemini_do_platform_upgrade() { echo "MTD3 has wrong name, aborting" >&2 exit 1 fi +} + +gemini_do_platform_upgrade() { echo "Extract the three firmware parts" - tar xvfz "$1"; rm "$1" - sync echo 3 > /proc/sys/vm/drop_caches echo "COMMENCING UPGRADE. BE PATIENT, THIS IS NOT FAST!" - echo "Upgrade Kern partition (kernel part 1, $2 erase blocks)" - mtd write zImage Kern + KFSZ=$(tar xfz "$1" zImage -O | wc -c) + echo "Upgrade Kern partition (kernel part 1, size ${KFSZ})" + tar xfz "$1" zImage -O | mtd write - Kern [ $? -ne 0 ] && exit 1 - echo "Upgrade Ramdisk partition (kernel part 2, $3 erase blocks)" - mtd write rd.gz Ramdisk + RFSZ=$(tar xfz "$1" rd.gz -O | wc -c) + echo "Upgrade Ramdisk partition (kernel part 2, size ${RFSZ})" + tar xfz "$1" rd.gz -O | mtd write - Ramdisk [ $? -ne 0 ] && exit 1 - echo "Upgrade Application partition (rootfs, $4 erase blocks)" - mtd write hddapp.tgz Application + AFSZ=$(tar xfz "$1" hddapp.tgz -O | wc -c) + echo "Upgrade Application partition (rootfs, size ${AFSZ})" + tar xfz "$1" hddapp.tgz -O | mtd write - Application [ $? -ne 0 ] && exit 1 } @@ -98,10 +102,12 @@ platform_do_upgrade() { ;; itian,sq201|\ storlink,gemini324) - gemini_do_platform_upgrade "$1" 16 48 48 + gemini_check_redboot_parts "$1" 16 48 48 + gemini_do_platform_upgrade "$1" ;; raidsonic,ib-4220-b) - gemini_do_platform_upgrade "$1" 24 48 48 + gemini_check_redboot_parts "$1" 24 48 48 + gemini_do_platform_upgrade "$1" ;; esac } |