aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm53xx/base-files/lib
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2015-04-07 14:14:08 +0000
committerRafał Miłecki <zajec5@gmail.com>2015-04-07 14:14:08 +0000
commit309d4f1ce2d59898c22c3642c740016c6ecd6109 (patch)
tree43d77f1d5fdd217268090fe09a2dd1731d6a2785 /target/linux/bcm53xx/base-files/lib
parent90bc0bce64e80fc107a91db326210257674ec1fe (diff)
downloadmaster-187ad058-309d4f1ce2d59898c22c3642c740016c6ecd6109.tar.gz
master-187ad058-309d4f1ce2d59898c22c3642c740016c6ecd6109.tar.bz2
master-187ad058-309d4f1ce2d59898c22c3642c740016c6ecd6109.zip
bcm53xx: image: share function checking TRX in provided firmware
Signed-off-by: Rafał Miłecki <zajec5@gmail.com> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@45292 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/bcm53xx/base-files/lib')
-rw-r--r--target/linux/bcm53xx/base-files/lib/upgrade/platform.sh24
1 files changed, 18 insertions, 6 deletions
diff --git a/target/linux/bcm53xx/base-files/lib/upgrade/platform.sh b/target/linux/bcm53xx/base-files/lib/upgrade/platform.sh
index 8055b4fa33..e174cc7beb 100644
--- a/target/linux/bcm53xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/bcm53xx/base-files/lib/upgrade/platform.sh
@@ -54,6 +54,20 @@ platform_identify() {
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 @@ platform_check_image() {
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 @@ platform_check_image() {
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")
;;