summaryrefslogtreecommitdiffhomepage
path: root/contrib/package/sysupgrade-atheros/files/lib/upgrade
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2009-06-20 20:27:32 +0000
committerJo-Philipp Wich <jow@openwrt.org>2009-06-20 20:27:32 +0000
commit94322a831539b23fbf0433bf2fe2bbe92c3122da (patch)
tree3cc6d0ae5cf0b7c773b45cd8c0b07043577078e2 /contrib/package/sysupgrade-atheros/files/lib/upgrade
parent4f6fca3be9238b6b125f0a97345996a72c17e1ce (diff)
contrib/package: add experimental sysupgrade support for the atheros target
Diffstat (limited to 'contrib/package/sysupgrade-atheros/files/lib/upgrade')
-rw-r--r--contrib/package/sysupgrade-atheros/files/lib/upgrade/platform.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/contrib/package/sysupgrade-atheros/files/lib/upgrade/platform.sh b/contrib/package/sysupgrade-atheros/files/lib/upgrade/platform.sh
new file mode 100644
index 0000000000..87a3248104
--- /dev/null
+++ b/contrib/package/sysupgrade-atheros/files/lib/upgrade/platform.sh
@@ -0,0 +1,32 @@
+platform_check_image() {
+ [ "$ARGC" -gt 1 ] && return 1
+
+ case "$(get_magic_word "$1")" in
+ # Freifunk .img files
+ 4646) return 0;;
+ *)
+ echo "Invalid image. Use Freifunk .img files on this platform"
+ return 1
+ ;;
+ esac
+}
+
+platform_do_upgrade() {
+ local kern_length=$((0x$(dd if="$1" bs=2 skip=1 count=4 2>/dev/null)/65536))
+ local kern_name=$(dd if="$1" bs=2 skip=5 count=8 2>/dev/null); kern_name="${kern_name%% *}"
+ local root_length=$((0x$(dd if="$1" bs=2 skip=13 count=4 2>/dev/null)/65536))
+ local root_name=$(dd if="$1" bs=2 skip=17 count=8 2>/dev/null); root_name="${root_name%% *}"
+
+ local append=""
+ [ -f "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 ] && append="-j $CONF_TAR"
+
+ if [ -n "$kern_name" -a -n "$root_name" ] && \
+ [ ${kern_length:-0} -gt 0 -a ${root_length:-0} -gt ${kern_length:-0} ];
+ then
+ dd if="$1" bs=65536 skip=1 count=$kern_length 2>/dev/null | \
+ mtd -e $kern_name write - $kern_name
+
+ dd if="$1" bs=65536 skip=$((1+$kern_length)) count=$root_length 2>/dev/null | \
+ mtd -e $root_name $append write - $root_name
+ fi
+}