aboutsummaryrefslogtreecommitdiffstats
path: root/package/system
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2014-12-03 14:32:32 +0000
committerJohn Crispin <blogic@openwrt.org>2014-12-03 14:32:32 +0000
commitb049c3f4af69006b96a6c1987b48a35015a01f3a (patch)
tree744cdeaf080f98811a14b92ab9ca7749c3c781ef /package/system
parenta1a8c1a6238ed68ce4f2562db6454e3424b7b04d (diff)
downloadupstream-b049c3f4af69006b96a6c1987b48a35015a01f3a.tar.gz
upstream-b049c3f4af69006b96a6c1987b48a35015a01f3a.tar.bz2
upstream-b049c3f4af69006b96a6c1987b48a35015a01f3a.zip
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> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@43505 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/system')
-rw-r--r--package/system/procd/Makefile14
-rw-r--r--package/system/procd/files/nand-preinit.sh17
2 files changed, 31 insertions, 0 deletions
diff --git a/package/system/procd/Makefile b/package/system/procd/Makefile
index 3ab194a9f0..545da4d0e0 100644
--- a/package/system/procd/Makefile
+++ b/package/system/procd/Makefile
@@ -43,6 +43,13 @@ define Package/procd-nand
TITLE:=OpenWrt sysupgrade nand helper
endef
+define Package/procd-nand-firstboot
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=procd-nand
+ TITLE:=OpenWrt firstboot nand helper
+endef
+
define Package/procd/config
menu "Configuration"
depends on PACKAGE_procd
@@ -85,5 +92,12 @@ define Package/procd-nand/install
$(INSTALL_DATA) ./files/nand.sh $(1)/lib/upgrade/
endef
+define Package/procd-nand-firstboot/install
+ $(INSTALL_DIR) $(1)/lib/preinit
+
+ $(INSTALL_DATA) ./files/nand-preinit.sh $(1)/lib/preinit/60-nand-firstboot.sh
+endef
+
$(eval $(call BuildPackage,procd))
$(eval $(call BuildPackage,procd-nand))
+$(eval $(call BuildPackage,procd-nand-firstboot))
diff --git a/package/system/procd/files/nand-preinit.sh b/package/system/procd/files/nand-preinit.sh
new file mode 100644
index 0000000000..bd2193c928
--- /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