>From dea780ba779104cd1460efe3815c16990f5db959 Mon Sep 17 00:00:00 2001
From: Matthew Fatheree <matthew.fathe...@belkin.com>
Date: Sun, 4 May 2014 19:10:18 +0700
Subject: [PATCH 16/30] mamba mvebu: sysupgrade support for mamba + dual boot
 is supportted

Add platform specific support for sysupgrade. Mamba supports dual boot
implementation. The firmware can be flashed to Primary Boot partition or
Alternative Boot partition. The sysupgrade has the ping-pong effect:
when we are runnning the firmware from Primary partition and do
sysupgrade the new firmware is written to the Alternative partition, on
next reboot bootcmd is set to Alternative partition; when we are running
the firmware from Alternative partition and do sysupgrade, the new
firmware is written to the Primary partition, on next reboot bootcmd is
set to Primary partition. boot_part is used to distinguished between
Primary Boot partition and Alternative Boot partition

Signed-off-by: Matthew Fatheree <matthew.fathe...@belkin.com>
---
 .../files/lib/upgrade/platform.sh                  |   72 ++++++++++++++++++++
 1 file changed, 72 insertions(+)
 create mode 100755 package/linksys-base-files/files/lib/upgrade/platform.sh

diff --git a/package/linksys-base-files/files/lib/upgrade/platform.sh 
b/package/linksys-base-files/files/lib/upgrade/platform.sh
new file mode 100755
index 0000000..7cd1e20
--- /dev/null
+++ b/package/linksys-base-files/files/lib/upgrade/platform.sh
@@ -0,0 +1,72 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+
+. /lib/functions.sh
+
+get_update_kernel_label() {
+       cur_boot_part=`/usr/sbin/fw_printenv -n boot_part`
+       kernel_label=""
+       if [ "$cur_boot_part" -eq 1 ]
+       then
+               # current primary boot - update alt boot
+               kernel_label="alt_kernel"
+               fw_setenv boot_part 2
+               fw_setenv bootcmd "run altnandboot"
+       elif [ "$cur_boot_part" -eq 2 ]
+       then
+               # current alt boot - update primary boot
+               kernel_label="kernel"
+               fw_setenv boot_part 1
+               fw_setenv bootcmd "run nandboot"
+       else
+               # try to guess from bootarg, should not come here
+               grep -q "mtdblock5" /proc/cmdline && next_boot_part=2 \
+                       && kernel_label="alt_kernel" && next_bootcmd="run 
altnandboot"
+               grep -q "mtdblock7" /proc/cmdline && next_boot_part=1 \
+                       && kernel_label="kernel" && next_bootcmd="run nandboot"
+               fw_setenv boot_part $next_boot_part
+               fw_setenv bootcmd $next_bootcmd
+       fi
+       echo "$kernel_label"
+}
+
+platform_do_upgrade () {
+       mkdir -p /var/lock
+       touch /var/lock/fw_printenv.lock
+       local kern_label=$(get_update_kernel_label)
+
+       if [ ! -n "$kern_label" ]
+       then
+               echo "cannot find kernel partition"
+               exit 1
+       fi
+       echo "Mamba do upgrade on $kern_label"
+       get_image "$1" | mtd write - $kern_label
+}
+
+platform_check_image() {
+       # return 0 on valid image, 1 otherwise
+       echo "Mamba check image"
+       return 0
+}
+
+mamba_preupgrade() {
+       echo "Mamba preupgrade called..."
+       export RAMFS_COPY_BIN="${RAMFS_COPY_BIN} /usr/sbin/fw_printenv 
/usr/sbin/fw_setenv"
+       export RAMFS_COPY_BIN="${RAMFS_COPY_BIN} /bin/mkdir /bin/touch"
+       export RAMFS_COPY_DATA="${RAMFS_COPY_DATA} /etc/fw_env.config 
/var/lock/fw_printenv.lock"
+
+       rm -rf /overlay/*
+       # populate the backup configuration files to overlay ubifs
+       if [ -f "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 ]
+       then
+               tar -C /overlay/ -x${TAR_V}zf "$CONF_TAR"
+       fi
+
+       # umount overlay partition now
+       umount -l /overlay
+       umount -l /tmp/syscfg
+}
+
+append sysupgrade_pre_upgrade mamba_preupgrade
--
1.7.9.5



__________________________________________________________________ Confidential 
This e-mail and any files transmitted with it are the property of Belkin 
International, Inc. and/or its affiliates, are confidential, and are intended 
solely for the use of the individual or entity to whom this e-mail is 
addressed. If you are not one of the named recipients or otherwise have reason 
to believe that you have received this e-mail in error, please notify the 
sender and delete this message immediately from your computer. Any other use, 
retention, dissemination, forwarding, printing or copying of this e-mail is 
strictly prohibited. Pour la version française: 
http://www.belkin.com/email-notice/French.html Für die deutsche Übersetzung: 
http://www.belkin.com/email-notice/German.html 
__________________________________________________________________
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to