diff options
author | Adrian Schmutzler <freifunk@adrianschmutzler.de> | 2019-10-22 21:46:57 +0200 |
---|---|---|
committer | John Crispin <john@phrozen.org> | 2019-10-27 14:24:22 +0100 |
commit | 0130022baec0a90c6cb039a5cbe9b9c65c01672f (patch) | |
tree | 93815b43aaf2d13863c0beb78e95cf443c29606a /target/linux/ath79/generic/base-files/lib/upgrade/platform.sh | |
parent | c36ef5970b0342f01f1f3bfc7452b86992c7201b (diff) | |
download | upstream-0130022baec0a90c6cb039a5cbe9b9c65c01672f.tar.gz upstream-0130022baec0a90c6cb039a5cbe9b9c65c01672f.tar.bz2 upstream-0130022baec0a90c6cb039a5cbe9b9c65c01672f.zip |
ath79: split base-files into subtargets
While most of the target's contents are split into subtargets, the
base-files are maintained for the target as a whole.
However, OpenWrt already implements a mechanism that will use (and
even prefer) files in the subtargets' directories. This can be
exploited to make several scripts subtarget-specific and thus save
some space (especially helpful for the tiny devices).
The only script remaining in parent base-files is
/etc/hotplug.d/ieee80211/00-wifi-migration, everything else is
moved/split.
Note that this will increase overall code lines, but reduce code
per subtarget.
base-files ipk size reduction:
master (generic) 49135 B
split (generic) 48533 B (- 0.6 kiB)
split (tiny) 43337 B (- 5.7 kiB)
split (nand) 44423 B (- 4.6 kiB)
Tested on TL-WR1043ND v4 (generic) and TL-WR841N v12 (tiny).
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Diffstat (limited to 'target/linux/ath79/generic/base-files/lib/upgrade/platform.sh')
-rw-r--r-- | target/linux/ath79/generic/base-files/lib/upgrade/platform.sh | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh b/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh new file mode 100644 index 0000000000..83c4e78d25 --- /dev/null +++ b/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh @@ -0,0 +1,61 @@ +# +# Copyright (C) 2011 OpenWrt.org +# + +PART_NAME=firmware +REQUIRE_IMAGE_METADATA=1 + +redboot_fis_do_upgrade() { + local append + local sysup_file="$1" + local kern_part="$2" + local magic=$(get_magic_word "$sysup_file") + + if [ "$magic" = "4349" ]; then + local kern_length=0x$(dd if="$sysup_file" bs=2 skip=1 count=4 2>/dev/null) + + [ -f "$UPGRADE_BACKUP" ] && append="-j $UPGRADE_BACKUP" + dd if="$sysup_file" bs=64k skip=1 2>/dev/null | \ + mtd -r $append -F$kern_part:$kern_length:0x80060000,rootfs write - $kern_part:rootfs + + elif [ "$magic" = "7379" ]; then + local board_dir=$(tar tf $sysup_file | grep -m 1 '^sysupgrade-.*/$') + local kern_length=$(tar xf $sysup_file ${board_dir}kernel -O | wc -c) + + [ -f "$UPGRADE_BACKUP" ] && append="-j $UPGRADE_BACKUP" + tar xf $sysup_file ${board_dir}kernel ${board_dir}root -O | \ + mtd -r $append -F$kern_part:$kern_length:0x80060000,rootfs write - $kern_part:rootfs + + else + echo "Unknown image, aborting!" + return 1 + fi +} + +platform_check_image() { + return 0 +} + +platform_do_upgrade() { + local board=$(board_name) + + case "$board" in + adtran,bsap1800-v2|\ + adtran,bsap1840) + redboot_fis_do_upgrade "$1" vmlinux_2 + ;; + jjplus,ja76pf2) + echo "Sysupgrade disabled due bug FS#2428" + ;; + ubnt,routerstation|\ + ubnt,routerstation-pro) + echo "Sysupgrade disabled due bug FS#2428" + ;; + zyxel,nbg6716) + nand_do_upgrade "$1" + ;; + *) + default_do_upgrade "$1" + ;; + esac +} |