Signed-off-by: Cody P Schafer <[email protected]>
---
.../brcm47xx/base-files/lib/upgrade/platform.sh | 62 ++++++++++++++++++++--
1 file changed, 57 insertions(+), 5 deletions(-)
diff --git a/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh
b/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh
index 9921cf5..5aad6c0 100644
--- a/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh
@@ -1,14 +1,66 @@
PART_NAME=linux
+get_fw_mtd () {
+ grep "\"$PART_NAME\"" < /proc/mtd | cut -d':' -f1
+}
+
+get_current_magic_long () {
+ dd bs=4 count=1 2>/dev/null < /dev/"$(get_fw_mtd)" | hexdump -v -n 4 -e
'1/1 "%02x"'
+}
+
platform_check_image() {
[ "$ARGC" -gt 1 ] && return 1
- case "$(get_magic_word "$1")" in
- # .trx files
- 4844) return 0;;
- *)
- echo "Invalid image type. Please use only .trx files"
+ magic="$(get_magic_long "$1")"
+ # For Belkin support, check on magic in current image.
+ cmagic="$(get_current_magic_long)"
+
+ case "$cmagic" in
+ 48445230) # HDR0
+ case "$magic" in
+ # .trx files
+ 48445230) return 0;;
+ *)
+ echo "Invalid image type. Please use only .trx
files"
+ return 1
+ ;;
+ esac
+ ;;
+ 22031020) # F7D3301
+ if [ $magic = 22031020 ] || [ $magic = 78563412 ]; then
+ return 0
+ else
+ echo "Invalid image for this router."
+ echo "Either f7d3301 or f7dxxxx-qa .bin files required."
+ return 1
+ fi
+ ;;
+ 28090920) # F7D3302
+ if [ $magic = 28090920 ] || [ $magic = 78563412 ]; then
+ return 0
+ else
+ echo "Invalid image for this router."
+ echo "Either f7d3302 or f7dxxxx-qa .bin files required."
+ return 1
+ fi
+ ;;
+ 06101020) # F7D4302
+ if [ $magic = 06101020 ] || [ $magic = 78563412 ]; then
+ return 0
+ else
+ echo "Invalid image for this router."
+ echo "Either f7d4302 or f7dxxxx-qa .bin files required."
+ return 1
+ fi
+ ;;
+ 78563412) # Belkin F7Dx30x QA Firmware
+ if [ $magic = 78563412 ] ; then
+ return 0
+ else
+ echo "Potentially invalid image for this router."
+ echo "Please use a f7dxxxx-qa .bin file (or force)"
return 1
+ fi
;;
esac
}
--
1.8.4.2
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel