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-a3cf2f4a3e73master
parent
90bc0bce64
commit
309d4f1ce2
|
@ -54,6 +54,20 @@ platform_identify() {
|
||||||
echo "unknown"
|
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() {
|
platform_check_image() {
|
||||||
[ "$#" -gt 1 ] && return 1
|
[ "$#" -gt 1 ] && return 1
|
||||||
|
|
||||||
|
@ -79,11 +93,10 @@ platform_check_image() {
|
||||||
error=1
|
error=1
|
||||||
}
|
}
|
||||||
|
|
||||||
magic=$(get_magic_long_at "$1" "$header_len")
|
if ! platform_check_image_trx "$1" "$header_len"; then
|
||||||
[ "$magic" != "48445230" ] && {
|
|
||||||
echo "No valid TRX firmware in the CHK image"
|
echo "No valid TRX firmware in the CHK image"
|
||||||
error=1
|
error=1
|
||||||
}
|
fi
|
||||||
;;
|
;;
|
||||||
"cybertan")
|
"cybertan")
|
||||||
local pattern=$(dd if="$1" bs=1 count=4 2>/dev/null | hexdump -v -e '1/1 "%c"')
|
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
|
error=1
|
||||||
}
|
}
|
||||||
|
|
||||||
magic=$(get_magic_long_at "$1" 32)
|
if ! platform_check_image_trx "$1" 32; then
|
||||||
[ "$magic" != "48445230" ] && {
|
|
||||||
echo "No valid TRX firmware in the CyberTAN image"
|
echo "No valid TRX firmware in the CyberTAN image"
|
||||||
error=1
|
error=1
|
||||||
}
|
fi
|
||||||
;;
|
;;
|
||||||
"trx")
|
"trx")
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in New Issue