Signed-off-by: André Valentin <[email protected]>
---
 .../base-files/lib/upgrade/platform.sh             |  108 ++++++++++++++++++++
 1 file changed, 108 insertions(+)
 create mode 100755 target/linux/bcm53xx_brcm/base-files/lib/upgrade/platform.sh

diff --git a/target/linux/bcm53xx_brcm/base-files/lib/upgrade/platform.sh 
b/target/linux/bcm53xx_brcm/base-files/lib/upgrade/platform.sh
new file mode 100755
index 0000000..0c7680e
--- /dev/null
+++ b/target/linux/bcm53xx_brcm/base-files/lib/upgrade/platform.sh
@@ -0,0 +1,108 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+
+#. /lib/ar71xx.sh
+
+PART_NAME=firmware
+#RAMFS_COPY_DATA=/lib/ar71xx.sh
+
+CI_BLKSZ=131072
+CI_LDADR=0x80060000
+
+platform_find_partitions() {
+       local first dev size erasesize name
+       while read dev size erasesize name; do
+               name=${name#'"'}; name=${name%'"'}
+               case "$name" in
+                       
vmlinux.bin.l7|vmlinux|kernel|linux|linux.bin|rootfs|filesystem)
+                               if [ -z "$first" ]; then
+                                       first="$name"
+                               else
+                                       echo "$erasesize:$first:$name"
+                                       break
+                               fi
+                       ;;
+               esac
+       done < /proc/mtd
+}
+
+platform_find_kernelpart() {
+       local part
+       for part in "${1%:*}" "${1#*:}"; do
+               case "$part" in
+                       vmlinux.bin.l7|vmlinux|kernel|linux|linux.bin)
+                               echo "$part"
+                               break
+                       ;;
+               esac
+       done
+}
+
+platform_do_upgrade_nand() {
+        set -x
+       local fw_mtd_kfs=$1
+       local fw_mtd=$2
+       local fw_file=$3
+
+       if [ -n "$fw_mtd" ]; then
+                sleep 2
+                VOL=$(ubi info|grep -B1 ' rootfs$'|grep -- '- ubi'|awk '{ 
print $3 }')
+                [ -n $VOL ] || {
+                    echo "UBI Volume rootfs not found, upgrade failed."
+                    return 1
+                }
+
+                ROOTFS_SIZE=$(tar -tvf $fw_file rootfs |awk '{ print $3 }')
+                echo Starting rootfs ubiupdate, volume size: $ROOTFS_SIZE
+                tar -xOf $fw_file rootfs | \
+                ubiupdatevol /dev/$VOL - -s $ROOTFS_SIZE || {
+                    echo "ubiupdatevol failed."
+                    return 1
+                }
+
+                [ -f /tmp/sysupgrade.tgz ] && {
+                    busybox mkdir /tmp/sysupgrade-mount
+                    mount -t ubifs /dev/$VOL /tmp/sysupgrade-mount
+                    cp /tmp/sysupgrade.tgz /tmp/sysupgrade-mount/
+                    umount /tmp/sysupgrade-mount
+                }
+
+                echo Starting kernelupdate:
+                tar -xOf $fw_file linux | \
+                mtd write - /dev/mtd2 || {
+                    echo "mtd2 kernelupdate failed."
+                    return 1
+                }
+
+                return 0
+       fi
+}
+
+platform_check_image() {
+       local magic="$(get_magic_word "$1")"
+       local magic_long="$(get_magic_long "$1")"
+
+       [ "$ARGC" -gt 1 ] && return 1
+
+        tar -tvf "$1" linux rootfs >/dev/null && {
+            return 0
+        }
+
+       echo "Sysupgrade is not yet supported on $board."
+       return 1
+}
+
+platform_do_upgrade() {
+        platform_do_upgrade_nand "linux" "rootfs" "$ARGV"
+}
+
+disable_watchdog() {
+       killall watchdog
+       ( ps | grep -v 'grep' | grep '/dev/watchdog' ) && {
+               echo 'Could not disable watchdog'
+               return 1
+       }
+}
+
+append sysupgrade_pre_upgrade disable_watchdog
-- 
1.7.10.4
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to