brcm47xx: detect (and still reject for now) CyberTAN fw format
authorRafał Miłecki <zajec5@gmail.com>
Mon, 15 Dec 2014 09:59:44 +0000 (09:59 +0000)
committerRafał Miłecki <zajec5@gmail.com>
Mon, 15 Dec 2014 09:59:44 +0000 (09:59 +0000)
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
SVN-Revision: 43714

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

index d216ca4d04e3f7dd5ff7d5a32d2e6c0cbc60333e..412d6daaff40356434ad1fe049c05dc4cf85c3a6 100644 (file)
@@ -1,5 +1,11 @@
 PART_NAME=firmware
 
+# $(1): file to read magic from
+# $(2): offset in bytes
+get_magic_long_at() {
+       dd if="$1" skip=$2 bs=1 count=4 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
+}
+
 brcm47xx_identify() {
        local magic
 
@@ -15,6 +21,12 @@ brcm47xx_identify() {
                        ;;
        esac
 
+       magic=$(get_magic_long_at "$1" 14)
+       [ "$magic" = "55324e44" ] && {
+               echo "cybertan"
+               return
+       }
+
        echo "unknown"
 }