aboutsummaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2015-03-31 21:16:19 +0000
committerRafał Miłecki <zajec5@gmail.com>2015-03-31 21:16:19 +0000
commit9c5aa7c528b45670a988a8c190acc06abe8a09c6 (patch)
tree5570cb85583247a9017b0110d9c1bf7df17c435b /target
parentf7ff5322396f277fabd193e1aa75c0b7df294478 (diff)
downloadupstream-9c5aa7c528b45670a988a8c190acc06abe8a09c6.tar.gz
upstream-9c5aa7c528b45670a988a8c190acc06abe8a09c6.tar.bz2
upstream-9c5aa7c528b45670a988a8c190acc06abe8a09c6.zip
brcm47xx: image: share function checking TRX in provided firmware
This will allow us to calculate crc32 in a shared code. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> SVN-Revision: 45202
Diffstat (limited to 'target')
-rw-r--r--target/linux/brcm47xx/base-files/lib/upgrade/platform.sh24
1 files changed, 18 insertions, 6 deletions
diff --git a/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh b/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh
index 8c09706ee8..f5b9bda690 100644
--- a/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh
@@ -77,6 +77,20 @@ brcm47xx_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
@@ -97,11 +111,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"')
@@ -113,11 +126,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")
;;