ar71xx: sysupgrade for My Net Wi-Fi Range Extender
authorjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Sat, 30 Nov 2013 18:31:03 +0000 (18:31 +0000)
committerjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Sat, 30 Nov 2013 18:31:03 +0000 (18:31 +0000)
This patch enables the convenient sysupgrade feature for
WD's Wi-Fi Range Extender.

Signed-off-by: Christian Lamparter <chunkeey@googlemail.com>
Patchwork: http://patchwork.openwrt.org/patch/4341/
[juhosg:
  - rename 'mynet_rext_check_image' function to 'cybertan_check_image'
    and move that into platform.sh,
  - remove the the model specific 'platform_do_upgrade_mynet_rext' function,
  - drop the mynet-rext.sh script,
  - remove the image/Makefile change,
  - update commit message]
[christian:
  - check all 8 bytes of the firmware/device magic]
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@38966 3c298f89-4303-0410-b956-a3cf2f4a3e73

target/linux/ar71xx/base-files/lib/ar71xx.sh
target/linux/ar71xx/base-files/lib/upgrade/platform.sh

index e0b8830..0b18d0c 100755 (executable)
@@ -53,6 +53,15 @@ wndr3700_board_detect() {
        AR71XX_MODEL="$machine"
 }
 
        AR71XX_MODEL="$machine"
 }
 
+cybertan_get_hw_magic() {
+       local part
+
+       part=$(find_mtd_part firmware)
+       [ -z "$part" ] && return 1
+
+       dd bs=8 count=1 skip=0 if=$part 2>/dev/null | hexdump -v -n 8 -e '1/1 "%02x"'
+}
+
 tplink_get_hwid() {
        local part
 
 tplink_get_hwid() {
        local part
 
index 839ba4e..9d42404 100755 (executable)
@@ -73,6 +73,22 @@ seama_get_type_magic() {
        get_image "$@" | dd bs=1 count=4 skip=53 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
 }
 
        get_image "$@" | dd bs=1 count=4 skip=53 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
 }
 
+cybertan_get_image_magic() {
+       get_image "$@" | dd bs=8 count=1 skip=0  2>/dev/null | hexdump -v -n 8 -e '1/1 "%02x"'
+}
+
+cybertan_check_image() {
+       local magic="$(cybertan_get_image_magic "$1")"
+       local fw_magic="$(cybertan_get_hw_magic)"
+
+       [ "$fw_magic" != "$magic" ] && {
+               echo "Invalid image, ID mismatch, got:$magic, but need:$fw_magic"
+               return 1
+       }
+
+       return 0
+}
+
 platform_check_image() {
        local board=$(ar71xx_board_name)
        local magic="$(get_magic_word "$1")"
 platform_check_image() {
        local board=$(ar71xx_board_name)
        local magic="$(get_magic_word "$1")"
@@ -155,6 +171,11 @@ platform_check_image() {
                dir825b_check_image "$1" && return 0
                ;;
 
                dir825b_check_image "$1" && return 0
                ;;
 
+       mynet-rext)
+               cybertan_check_image "$1" && return 0
+               return 1
+               ;;
+
        mynet-n600)
                [ "$magic_long" != "5ea3a417" ] && {
                        echo "Invalid image, bad magic: $magic_long"
        mynet-n600)
                [ "$magic_long" != "5ea3a417" ] && {
                        echo "Invalid image, bad magic: $magic_long"