aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2015-06-06 17:23:03 +0000
committerRafał Miłecki <zajec5@gmail.com>2015-06-06 17:23:03 +0000
commit8ffc27998a2e755ad3e7aa1ff808324e40c2d355 (patch)
tree31cfedbe8bc8f5275c797f8d172ff539eec1335b
parent2abf42fc3119613296bded933e1767dabbce6c00 (diff)
downloadmaster-187ad058-8ffc27998a2e755ad3e7aa1ff808324e40c2d355.tar.gz
master-187ad058-8ffc27998a2e755ad3e7aa1ff808324e40c2d355.tar.bz2
master-187ad058-8ffc27998a2e755ad3e7aa1ff808324e40c2d355.zip
bcm53xx: extract TRX from image on the fly
Extracting TRX to separated file in /tmp/ just wastes some RAM while we can just pass a proper extracting command to the default_do_upgrade. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@45912 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r--target/linux/bcm53xx/base-files/lib/upgrade/platform.sh27
1 files changed, 14 insertions, 13 deletions
diff --git a/target/linux/bcm53xx/base-files/lib/upgrade/platform.sh b/target/linux/bcm53xx/base-files/lib/upgrade/platform.sh
index 4920b55caf..7251a9a417 100644
--- a/target/linux/bcm53xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/bcm53xx/base-files/lib/upgrade/platform.sh
@@ -109,16 +109,6 @@ platform_check_image() {
return $error
}
-platform_extract_trx_from_chk() {
- local header_len=$((0x$(get_magic_long_at "$1" 4)))
-
- dd if="$1" of="$2" bs=$header_len skip=1
-}
-
-platform_extract_trx_from_cybertan() {
- dd if="$1" of="$2" bs=32 skip=1
-}
-
platform_pre_upgrade() {
local file_type=$(platform_identify "$1")
local dir="/tmp/sysupgrade-bcm53xx"
@@ -179,19 +169,30 @@ platform_pre_upgrade() {
nand_do_upgrade /tmp/root.ubi
}
+platform_trx_from_chk_cmd() {
+ local header_len=$((0x$(get_magic_long_at "$1" 4)))
+
+ echo -n dd bs=$header_len skip=1
+}
+
+platform_trx_from_cybertan_cmd() {
+ echo -n dd bs=32 skip=1
+}
+
platform_do_upgrade() {
local file_type=$(platform_identify "$1")
local trx="$1"
+ local cmd=
[ "$(platform_flash_type)" == "nand" ] && {
echo "Writing whole image to NAND flash. All erase counters will be lost."
}
case "$file_type" in
- "chk") trx="/tmp/$(basename $1).trx"; platform_extract_trx_from_chk "$1" "$trx";;
- "cybertan") trx="/tmp/$(basename $1).trx"; platform_extract_trx_from_cybertan "$1" "$trx";;
+ "chk") cmd=$(platform_trx_from_chk_cmd "$trx");;
+ "cybertan") cmd=$(platform_trx_from_cybertan_cmd "$trx");;
esac
shift
- default_do_upgrade "$trx" "$@"
+ default_do_upgrade "$trx" "$cmd"
}