diff mbox

[OpenWrt-Devel,RFC] brcm47xx: support for flashing CHK and CyberTAN images

Message ID 1418645867-14349-1-git-send-email-zajec5@gmail.com
State Accepted
Headers show

Commit Message

Rafał Miłecki Dec. 15, 2014, 12:17 p.m. UTC
This will allow simple sysupgrade-s including simpler reverting to the
original firmware.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
 .../brcm47xx/base-files/lib/upgrade/platform.sh    | 33 ++++++++++++++++++----
 1 file changed, 28 insertions(+), 5 deletions(-)

Comments

Rafał Miłecki Dec. 22, 2014, 3:32 p.m. UTC | #1
On 15 December 2014 at 13:17, Rafał Miłecki <zajec5@gmail.com> wrote:
> This will allow simple sysupgrade-s including simpler reverting to the
> original firmware.

I guess noone plans to NACK this? :)
diff mbox

Patch

diff --git a/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh b/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh
index 1cb11b5..be7d02a 100644
--- a/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh
@@ -41,14 +41,12 @@  platform_check_image() {
 			local board_id_len=$(($header_len - 40))
 			local board_id=$(dd if="$1" skip=40 bs=1 count=$board_id_len 2>/dev/null | hexdump -v -e '1/1 "%c"')
 			echo "Found CHK image with device board_id $board_id"
-			echo "Flashing CHK images in unsupported. Please use only .trx files."
-			return 1
+			return 0
 		;;
 		"cybertan")
 			local magic=$(dd if="$1" bs=1 count=4 2>/dev/null | hexdump -v -e '1/1 "%c"')
 			echo "Found CyberTAN image with device magic: $magic"
-			echo "Flashing CyberTAN images in unsupported. Please use only .trx files."
-			return 1
+			return 0
 		;;
 		"trx")
 			return 0
@@ -60,4 +58,29 @@  platform_check_image() {
 	esac
 }
 
-# use default for platform_do_upgrade()
+platform_do_upgrade_chk() {
+	local header_len=$((0x$(get_magic_long_at "$1" 4)))
+	local trx="/tmp/$1.trx"
+
+	dd if="$1" of="$trx" bs=$header_len skip=1
+	shift
+	default_do_upgrade "$trx" "$@"
+}
+
+platform_do_upgrade_cybertan() {
+	local trx="/tmp/$1.trx"
+
+	dd if="$1" of="$trx" bs=32 skip=1
+	shift
+	default_do_upgrade "$trx" "$@"
+}
+
+platform_do_upgrade() {
+	local file_type=$(brcm47xx_identify "$1")
+
+	case "$file_type" in
+		"chk")		platform_do_upgrade_chk "$ARGV";;
+		"cybertan")	platform_do_upgrade_cybertan "$ARGV";;
+		*)		default_do_upgrade "$ARGV";;
+	esac
+}