aboutsummaryrefslogtreecommitdiffstats
path: root/package/system
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2014-12-03 20:22:37 +0000
committerJohn Crispin <blogic@openwrt.org>2014-12-03 20:22:37 +0000
commit05ebabab1006b3d8a144ccc9bcae66598dc9b6d8 (patch)
tree28c35db357e8d77f0a64a3c72a12c13b908c7c43 /package/system
parent41c3bf1931ec651d64a1fbad949da5ec13b4b096 (diff)
downloadmaster-187ad058-05ebabab1006b3d8a144ccc9bcae66598dc9b6d8.tar.gz
master-187ad058-05ebabab1006b3d8a144ccc9bcae66598dc9b6d8.tar.bz2
master-187ad058-05ebabab1006b3d8a144ccc9bcae66598dc9b6d8.zip
procd: more nand takeover fixes
if the initramfs kernel and payload were flashed in one block, the payload might not be at the start of the ubi partition due to bad blocks inside the kernel partition. Signed-off-by: John Crispin <blogic@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@43513 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/system')
-rw-r--r--package/system/procd/files/nand-preinit.sh20
1 files changed, 12 insertions, 8 deletions
diff --git a/package/system/procd/files/nand-preinit.sh b/package/system/procd/files/nand-preinit.sh
index bd2193c928..cf596246d1 100644
--- a/package/system/procd/files/nand-preinit.sh
+++ b/package/system/procd/files/nand-preinit.sh
@@ -4,14 +4,18 @@
nand_takeover() {
. /lib/upgrade/nand.sh
mtd=$(find_mtd_index "$CI_UBIPART")
- local file_type="$(identify $2)"
- mtd -l 400 dump /dev/mtd$mtd > /tmp/takeover.hdr
- MAGIC=$(dd if=/tmp/takeover.hdr bs=1 skip=261 count=5 2> /dev/null)
- SIZE=$(printf "%d" 0x$(dd if=/tmp/takeover.hdr bs=4 count=1 2> /dev/null | hexdump -v -n 4 -e '1/1 "%02x"'))
- [ "$MAGIC" = "ustar" ] && {
- mtd -l $((SIZE + 4)) dump /dev/mtd$mtd | dd bs=1 skip=4 of=/tmp/sysupgrade.tar
- nand_do_upgrade_stage2 /tmp/sysupgrade.tar
- }
+ esize=$(cat /proc/mtd | grep mtd$mtd |cut -d" " -f 3)
+ [ -z "$esize" ] && return 1
+ esize=$(printf "%d" 0x$esize)
+ for a in `seq 0 64`; do
+ mtd -o $((a * esize)) -l 400 dump /dev/mtd$mtd > /tmp/takeover.hdr
+ MAGIC=$(dd if=/tmp/takeover.hdr bs=1 skip=261 count=5 2> /dev/null)
+ SIZE=$(printf "%d" 0x$(dd if=/tmp/takeover.hdr bs=4 count=1 2> /dev/null | hexdump -v -n 4 -e '1/1 "%02x"'))
+ [ "$MAGIC" = "ustar" ] && {
+ mtd -o $((a * esize)) -l $((SIZE + 4)) dump /dev/mtd$mtd | dd bs=1 skip=4 of=/tmp/sysupgrade.tar
+ nand_do_upgrade_stage2 /tmp/sysupgrade.tar
+ }
+ done
}
boot_hook_add initramfs nand_takeover