aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/brcm47xx
diff options
context:
space:
mode:
authorDan Haab <dan.haab@legrand.com>2019-09-16 09:18:37 -0600
committerRafał Miłecki <rafal@milecki.pl>2019-09-16 21:37:33 +0200
commit95240c4933607544ad1788c2ed19843dd96bccbb (patch)
treecd8f379d6705195ecfe424822834c40c61a3e0e7 /target/linux/brcm47xx
parentbc5db7364d1e00be5bbe5444e81c40571fbd696d (diff)
downloadupstream-95240c4933607544ad1788c2ed19843dd96bccbb.tar.gz
upstream-95240c4933607544ad1788c2ed19843dd96bccbb.tar.bz2
upstream-95240c4933607544ad1788c2ed19843dd96bccbb.zip
brcm47xx: sysupgrade: support Luxul firmware format
Allow flashing Luxul devices using vendor firmware format. Signed-off-by: Dan Haab <dan.haab@legrand.com>
Diffstat (limited to 'target/linux/brcm47xx')
-rw-r--r--target/linux/brcm47xx/base-files/lib/upgrade/platform.sh82
1 files changed, 82 insertions, 0 deletions
diff --git a/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh b/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh
index 537bac2328..3e1b834327 100644
--- a/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh
@@ -1,11 +1,19 @@
PART_NAME=firmware
+LXL_FLAGS_VENDOR_LUXUL=0x00000001
+
# $(1): file to read magic from
# $(2): offset in bytes
get_magic_long_at() {
dd if="$1" skip=$2 bs=1 count=4 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
}
+# $(1): file to read LE long number from
+# $(2): offset in bytes
+get_le_long_at() {
+ echo $((0x$(dd if="$1" skip=$2 bs=1 count=4 2>/dev/null | hexdump -v -e '1/4 "%02x"')))
+}
+
platform_expected_image() {
local machine=$(board_name)
@@ -49,6 +57,16 @@ platform_expected_image() {
"Linksys WRT310N V2") echo "cybertan 310N"; return;;
"Linksys WRT610N V1") echo "cybertan 610N"; return;;
"Linksys WRT610N V2") echo "cybertan 610N"; return;;
+ "Luxul XAP-310 V1") echo "lxl XAP-310"; return;;
+ "Luxul XAP-1210 V1") echo "lxl XAP-1210"; return;;
+ "Luxul XAP-1230 V1") echo "lxl XAP-1230"; return;;
+ "Luxul XAP-1240 V1") echo "lxl XAP-1240"; return;;
+ "Luxul XAP-1500 V1") echo "lxl XAP-1500"; return;;
+ "Luxul ABR-4400 V1") echo "lxl ABR-4400"; return;;
+ "Luxul XBR-4400 V1") echo "lxl XBR-4400"; return;;
+ "Luxul XVW-P30 V1") echo "lxl XVW-P30"; return;;
+ "Luxul XWR-600 V1") echo "lxl XWR-600"; return;;
+ "Luxul XWR-1750 V1") echo "lxl XWR-1750"; return;;
esac
}
@@ -65,6 +83,10 @@ brcm47xx_identify() {
echo "chk"
return
;;
+ "4c584c23")
+ echo "lxl"
+ return
+ ;;
esac
magic=$(get_magic_long_at "$1" 14)
@@ -73,6 +95,12 @@ brcm47xx_identify() {
return
}
+ magic=$(get_magic_long_at "$1" 60)
+ [ "$magic" = "4c584c23" ] && {
+ echo "lxlold"
+ return
+ }
+
echo "unknown"
}
@@ -122,6 +150,48 @@ platform_check_image() {
notify_firmware_test_result "trx_valid" 1
fi
;;
+ "lxl")
+ local hdr_len=$(get_le_long_at "$1" 8)
+ local flags=$(get_le_long_at "$1" 12)
+ local board=$(dd if="$1" skip=16 bs=1 count=16 2>/dev/null | hexdump -v -e '1/1 "%c"')
+ local dev_board=$(platform_expected_image)
+ echo "Found Luxul image for board $board"
+
+ [ -n "$dev_board" -a "lxl $board" != "$dev_board" ] && {
+ echo "Firmware ($board) doesn't match device ($dev_board)"
+ error=1
+ }
+
+ [ $((flags & LXL_FLAGS_VENDOR_LUXUL)) -gt 0 ] && notify_firmware_no_backup
+
+ if ! otrx check "$1" -o "$hdr_len"; then
+ echo "No valid TRX firmware in the Luxul image"
+ notify_firmware_test_result "trx_valid" 0
+ error=1
+ else
+ notify_firmware_test_result "trx_valid" 1
+ fi
+ ;;
+ "lxlold")
+ local board_id=$(dd if="$1" skip=48 bs=1 count=12 2>/dev/null | hexdump -v -e '1/1 "%c"')
+ local dev_board_id=$(platform_expected_image)
+ echo "Found Luxul image with device board_id $board_id"
+
+ [ -n "$dev_board_id" -a "lxl $board_id" != "$dev_board_id" ] && {
+ echo "Firmware board_id doesn't match device board_id ($dev_board_id)"
+ error=1
+ }
+
+ notify_firmware_no_backup
+
+ if ! otrx check "$1" -o 64; then
+ echo "No valid TRX firmware in the Luxul image"
+ notify_firmware_test_result "trx_valid" 0
+ error=1
+ else
+ notify_firmware_test_result "trx_valid" 1
+ fi
+ ;;
"trx")
if ! otrx check "$1"; then
echo "Invalid (corrupted?) TRX firmware"
@@ -151,6 +221,16 @@ platform_trx_from_cybertan_cmd() {
echo -n dd bs=32 skip=1
}
+platform_trx_from_lxl_cmd() {
+ local hdr_len=$(get_le_long_at "$1" 8)
+
+ echo -n dd skip=$hdr_len iflag=skip_bytes
+}
+
+platform_trx_from_lxlold_cmd() {
+ echo -n dd bs=64 skip=1
+}
+
platform_do_upgrade() {
local file_type=$(brcm47xx_identify "$1")
local trx="$1"
@@ -159,6 +239,8 @@ platform_do_upgrade() {
case "$file_type" in
"chk") cmd=$(platform_trx_from_chk_cmd "$trx");;
"cybertan") cmd=$(platform_trx_from_cybertan_cmd "$trx");;
+ "lxl") cmd=$(platform_trx_from_lxl_cmd "$trx");;
+ "lxlold") cmd=$(platform_trx_from_lxlold_cmd "$trx");;
esac
default_do_upgrade "$trx" "$cmd"