summaryrefslogtreecommitdiff
path: root/target/linux/ar71xx/base-files/etc/uci-defaults/caldata-migration
diff options
context:
space:
mode:
authorcshore <cshore@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-09-06 18:15:26 +0000
committercshore <cshore@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-09-06 18:15:26 +0000
commit60244743f9a48fd9b6dc878d348b39e61181a58e (patch)
treea4368a76e4215905b6f2e28bbdadfd6af95d0716 /target/linux/ar71xx/base-files/etc/uci-defaults/caldata-migration
parent22a3f4be87c210387c01812b304df707f0f0468a (diff)
[ar71xx] dir825b1: Add image for DIR-825-B1 that uses the whole flash (must first be flashed with the 'standard' image) and an image to revert the change to allow reversion to stock firmware.
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@33326 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/ar71xx/base-files/etc/uci-defaults/caldata-migration')
-rw-r--r--target/linux/ar71xx/base-files/etc/uci-defaults/caldata-migration66
1 files changed, 66 insertions, 0 deletions
diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/caldata-migration b/target/linux/ar71xx/base-files/etc/uci-defaults/caldata-migration
new file mode 100644
index 0000000000..750ff405d3
--- /dev/null
+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/caldata-migration
@@ -0,0 +1,66 @@
+#!/bin/sh
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+
+. /lib/functions/uci-defaults.sh
+. /lib/ar71xx.sh
+
+board=$(ar71xx_board_name)
+
+findmtd() {
+ local partname="$1"
+ grep "\"$partname\"" /proc/mtd | awk -F: '{ print $1 }'
+}
+
+getcalmac() {
+ local partname="$1"
+ local offset="$2"
+
+ hexdump -e '17/1 "%c"' -s $offset -n 17 /dev/$(findmtd $partname) | tr -d : | tr 'A-Z' 'a-z'
+}
+
+calcmacX() {
+ local mac="$1"
+ local X="$2"
+
+ local oui="$(expr substr "$mac" 1 6)"
+ local end="$(expr substr "$mac" 7 12)"
+
+ echo -n $oui
+ expr substr "$(printf "%6lx" "$(($(printf "%lu" 0x${end}) + $X))")" 1 6
+}
+
+getifmac() {
+ local ifname="$1"
+
+ local ifmac
+
+ ifmac="$(ifconfig "$ifname" | grep HWaddr)"
+ ifmac="${ifmac#*HWaddr }"
+ ifmac="${ifmac%% *}"
+
+ echo "$ifmac" | tr -d : | tr 'A-Z' 'a-z'
+}
+
+case "$board" in
+dir-825-b1)
+ mac1="$(getcalmac caldata 65440)"
+ mac1="$(calcmacX "$mac1" 2)"
+ mac2="$(calcmacX "$mac1" 1)"
+
+ if grep -q '"owrt_caldata"' /proc/mtd && [ "$mac1" = "$(getifmac eth0)" ] && [ "$mac2" = "$(getifmac eth1)" ]; then
+ dd if=/dev/$(findmtd caldata) of=/dev/$(findmtd owrt_caldata) bs=65536 count=1
+ fi
+ ;;
+dir-825-b1-tostock)
+ mac1="$(getcalmac owrt_caldata 65440)"
+ mac1="$(calcmacX "$mac1" 2)"
+ mac2="$(calcmacX "$mac1" 1)"
+ if grep -q '"owrt_caldata"' /proc/mtd && [ "$mac1" = "$(getifmac eth0)" ] && [ "$mac2" = "$(getifmac eth1)" ]; then
+ dd if=/dev/$(findmtd owrt_caldata) of=/dev/$(findmtd caldata) bs=65536 count=1
+ fi
+ ;;
+esac
+
+return 0