ar71xx: add support for Fritz!Box 4020
[openwrt/staging/wigyori.git] / target / linux / ar71xx / base-files / lib / upgrade / platform.sh
index 29045353729833710095c0c061fe360ab45480e3..284582fa2b88770124309f9c825bd461b0db6748 100755 (executable)
@@ -93,6 +93,22 @@ tplink_get_image_boot_size() {
        get_image "$@" | dd bs=4 count=1 skip=37 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
 }
 
+tplink_pharos_check_support_list() {
+       local image="$1"
+       local offset="$2"
+       local model="$3"
+
+       # Here $image is given to dd directly instead of using get_image;
+       # otherwise the skip will take almost a second (as dd can't seek)
+       dd if="$image" bs=1 skip=$offset count=1024 2>/dev/null | (
+               while IFS= read -r line; do
+                       [ "$line" = "$model" ] && exit 0
+               done
+
+               exit 1
+       )
+}
+
 tplink_pharos_check_image() {
        local magic_long="$(get_magic_long "$1")"
        [ "$magic_long" != "7f454c46" ] && {
@@ -101,18 +117,10 @@ tplink_pharos_check_image() {
        }
 
        local model_string="$(tplink_pharos_get_model_string)"
-       local line
-
-       # Here $1 is given to dd directly instead of get_image as otherwise the skip
-       # will take almost a second (as dd can't seek then)
-       #
-       # This will fail if the image isn't local, but that's fine: as the
-       # read loop won't be executed at all, it will return true, so the image
-       # is accepted (loading the first 1.5M of a remote image for this check seems
-       # a bit extreme)
-       dd if="$1" bs=1 skip=1511432 count=1024 2>/dev/null | while read line; do
-               [ "$line" = "$model_string" ] && break
-       done || {
+
+       # New images have the support list at 7802888, old ones at 1511432
+       tplink_pharos_check_support_list "$1" 7802888 "$model_string" || \
+       tplink_pharos_check_support_list "$1" 1511432 "$model_string" || {
                echo "Unsupported image (model not in support-list)"
                return 1
        }
@@ -202,6 +210,7 @@ platform_check_image() {
        archer-c58-v1|\
        archer-c59-v1|\
        archer-c60-v1|\
+       archer-c60-v2|\
        archer-c7-v4|\
        bullet-m|\
        c-55|\
@@ -219,6 +228,7 @@ platform_check_image() {
        cpe505n|\
        cpe830|\
        cpe870|\
+       dap-1330-a1|\
        dgl-5500-a1|\
        dhp-1565-a1|\
        dir-505-a1|\
@@ -256,6 +266,7 @@ platform_check_image() {
        hiwifi-hc6361|\
        hornet-ub-x2|\
        jwap230|\
+       lbe-m5|\
        lima|\
        loco-m-xw|\
        mzk-w04nu|\
@@ -276,6 +287,7 @@ platform_check_image() {
        sc300m|\
        sc450|\
        sr3200|\
+       t830|\
        tew-632brp|\
        tew-712br|\
        tew-732br|\
@@ -391,12 +403,16 @@ platform_check_image() {
        el-m150|\
        el-mini|\
        gl-inet|\
+       lan-turtle|\
        mc-mac1200r|\
        minibox-v1|\
        omy-g1|\
        omy-x1|\
        onion-omega|\
-       oolite|\
+       oolite-v1|\
+       oolite-v5.2|\
+       oolite-v5.2-dev|\
+       packet-squirrel|\
        re355|\
        re450|\
        rut900|\
@@ -463,9 +479,11 @@ platform_check_image() {
        tl-wr842n-v3|\
        tl-wr902ac-v1|\
        tl-wr940n-v4|\
+       tl-wr940n-v6|\
        tl-wr941nd|\
        tl-wr941nd-v5|\
-       tl-wr941nd-v6)
+       tl-wr941nd-v6|\
+       wifi-pineapple-nano)
                local magic_ver="0100"
 
                case "$board" in
@@ -532,6 +550,7 @@ platform_check_image() {
        rb-951ui-2hnd|\
        rb-2011l|\
        rb-2011il|\
+       rb-2011ils|\
        rb-2011uas|\
        rb-2011uas-2hnd|\
        rb-2011uias|\
@@ -667,6 +686,7 @@ platform_check_image() {
                ;;
        # these boards use metadata images
        fritz300e|\
+       fritz4020|\
        rb-750-r2|\
        rb-750p-pbr2|\
        rb-750up-r2|\
@@ -825,6 +845,7 @@ platform_do_upgrade() {
        rb-951g-2hnd|\
        rb-951ui-2hnd|\
        rb-2011il|\
+       rb-2011ils|\
        rb-2011l|\
        rb-2011uas|\
        rb-2011uas-2hnd|\