Author: rmilecki
Date: 2015-04-07 16:14:08 +0200 (Tue, 07 Apr 2015)
New Revision: 45292

Modified:
   trunk/target/linux/bcm53xx/base-files/lib/upgrade/platform.sh
Log:
bcm53xx: image: share function checking TRX in provided firmware

Signed-off-by: Rafa?\197?\130 Mi?\197?\130ecki <[email protected]>

Modified: trunk/target/linux/bcm53xx/base-files/lib/upgrade/platform.sh
===================================================================
--- trunk/target/linux/bcm53xx/base-files/lib/upgrade/platform.sh       
2015-04-07 14:14:02 UTC (rev 45291)
+++ trunk/target/linux/bcm53xx/base-files/lib/upgrade/platform.sh       
2015-04-07 14:14:08 UTC (rev 45292)
@@ -54,6 +54,20 @@
        echo "unknown"
 }
 
+# $(1): image that should contain trx
+# $(2): trx offset in image
+platform_check_image_trx() {
+       local magic=$(get_magic_long_at "$1" $2)
+
+       [ "$magic" != "48445230" ] && {
+               return 1
+       }
+
+       # TODO: Check crc32
+
+       return 0
+}
+
 platform_check_image() {
        [ "$#" -gt 1 ] && return 1
 
@@ -79,11 +93,10 @@
                                error=1
                        }
 
-                       magic=$(get_magic_long_at "$1" "$header_len")
-                       [ "$magic" != "48445230" ] && {
+                       if ! platform_check_image_trx "$1" "$header_len"; then
                                echo "No valid TRX firmware in the CHK image"
                                error=1
-                       }
+                       fi
                ;;
                "cybertan")
                        local pattern=$(dd if="$1" bs=1 count=4 2>/dev/null | 
hexdump -v -e '1/1 "%c"')
@@ -95,11 +108,10 @@
                                error=1
                        }
 
-                       magic=$(get_magic_long_at "$1" 32)
-                       [ "$magic" != "48445230" ] && {
+                       if ! platform_check_image_trx "$1" 32; then
                                echo "No valid TRX firmware in the CyberTAN 
image"
                                error=1
-                       }
+                       fi
                ;;
                "trx")
                ;;
_______________________________________________
openwrt-commits mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-commits

Reply via email to