summaryrefslogtreecommitdiff
path: root/package/system/procd/files/nand-preinit.sh
diff options
context:
space:
mode:
authorJohn Crispin <john@openwrt.org>2014-12-03 14:32:32 +0000
committerJohn Crispin <john@openwrt.org>2014-12-03 14:32:32 +0000
commit68909fb081065094138ca02d23231902accb5171 (patch)
treec01696e5d6481c167e618fce210ff94dc087945f /package/system/procd/files/nand-preinit.sh
parent1e8a83e55388641e2769635cad6dca22cb05ecfe (diff)
downloadmtk-20170518-68909fb081065094138ca02d23231902accb5171.zip
mtk-20170518-68909fb081065094138ca02d23231902accb5171.tar.gz
mtk-20170518-68909fb081065094138ca02d23231902accb5171.tar.bz2
procd: firstboot nand/ubi takeover support
it is now possible to flash a initramfs kernel and a sysupgrade tar file inside the ubi partition. on first boot, the takeover script will find the tar file, extract and finally sysupgrade it. this allows us to flash owrt/ubi images in a 2 phase setup using ODM webuis that are not ubi aware. this is needed by some mediatek and brokencom devices. Signed-off-by: John Crispin <blogic@openwrt.org> SVN-Revision: 43505
Diffstat (limited to 'package/system/procd/files/nand-preinit.sh')
-rw-r--r--package/system/procd/files/nand-preinit.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/package/system/procd/files/nand-preinit.sh b/package/system/procd/files/nand-preinit.sh
new file mode 100644
index 0000000..bd2193c
--- /dev/null
+++ b/package/system/procd/files/nand-preinit.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Copyright (C) 2014 OpenWrt.org
+
+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
+ }
+}
+
+boot_hook_add initramfs nand_takeover