diff mbox

[OpenWrt-Devel,5/7] kirkwood: support Linksys boot counter on EA[34]500

Message ID 1446863354-3263-6-git-send-email-leitec@staticky.com
State Superseded
Headers show

Commit Message

Claudio Leite Nov. 7, 2015, 2:29 a.m. UTC
This is done with existing code from the WRT1900AC port.
It makes sure the "auto_recovery" bootloader option is set,
and resets the s_env boot counter after a successful boot.

This gives users without a serial console connection some
measure of safety.

Signed-off-by: Claudio Leite <leitec@staticky.com>
---
 package/system/mtd/src/Makefile                      |  1 +
 .../kirkwood/base-files/etc/init.d/linksys_recovery  | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)
 create mode 100755 target/linux/kirkwood/base-files/etc/init.d/linksys_recovery
diff mbox

Patch

diff --git a/package/system/mtd/src/Makefile b/package/system/mtd/src/Makefile
index 40a165e..1e02ce9 100644
--- a/package/system/mtd/src/Makefile
+++ b/package/system/mtd/src/Makefile
@@ -11,6 +11,7 @@  obj.bcm53xx = $(obj.brcm)
 obj.brcm63xx = imagetag.o
 obj.ramips = $(obj.seama)
 obj.mvebu = linksys_bootcount.o
+obj.kirkwood = linksys_bootcount.o
 
 ifdef FIS_SUPPORT
   obj += fis.o
diff --git a/target/linux/kirkwood/base-files/etc/init.d/linksys_recovery b/target/linux/kirkwood/base-files/etc/init.d/linksys_recovery
new file mode 100755
index 0000000..b291c3d
--- /dev/null
+++ b/target/linux/kirkwood/base-files/etc/init.d/linksys_recovery
@@ -0,0 +1,20 @@ 
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2015 OpenWrt.org
+
+START=97
+boot() {
+. /lib/functions.sh
+. /lib/kirkwood.sh
+
+case $(kirkwood_board_name) in
+	ea3500|ea4500)
+		# make sure auto_recovery in uboot is always on
+		AUTO_RECOVERY_ENA="`fw_printenv -n auto_recovery`"
+		if [ "$AUTO_RECOVERY_ENA" != "yes" ] ; then
+			fw_setenv auto_recovery yes
+		fi
+		# reset the boot counter
+		mtd resetbc s_env
+		;;
+esac
+}