[U-Boot] [PATCH 6/6] km/common: check test_bank and testpin for testboot

Holger Brunck holger.brunck at keymile.com
Fri May 4 10:55:58 CEST 2012


From: Thomas Herzmann <thomas.herzmann at keymile.com>

If the testpin is asserted, first check if a test_bank
variable is defined before trying to boot this
test_bank.

Signed-off-by: Thomas Herzmann <thomas.herzmann at keymile.com>
Signed-off-by: Holger Brunck <holger.brunck at keymile.com>
---
 board/keymile/common/common.c       |   36 +++++++++++++++++++++++++++++++++++
 include/configs/km/keymile-common.h |    4 ++-
 2 files changed, 39 insertions(+), 1 deletions(-)

diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c
index f262306..1013f42 100644
--- a/board/keymile/common/common.c
+++ b/board/keymile/common/common.c
@@ -34,6 +34,9 @@
 #include <asm/io.h>
 #include <linux/ctype.h>
 
+#if defined(CONFIG_POST)
+#include "post.h"
+#endif
 #include "common.h"
 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
 #include <i2c.h>
@@ -390,3 +393,36 @@ U_BOOT_CMD(km_checkbidhwk, 2, 0, do_checkboardidhwk,
 		"\"boardIdListHex\" against stored boardid and hwkey "\
 		"from the IVM\n    v: verbose output"
 );
+
+/*
+ * command km_checktestboot
+ *  if the testpin of the board is asserted, return 1
+ *  *	else return 0
+ */
+int do_checktestboot(cmd_tbl_t *cmdtp, int flag, int argc,
+			char *const argv[])
+{
+	int testpin = 0;
+	char *s = NULL;
+	int testboot = 0;
+	int verbose = argc > 1 && *argv[1] == 'v';
+
+#if defined(CONFIG_POST)
+	testpin = post_hotkeys_pressed();
+	s = getenv("test_bank");
+#endif
+	/* when test_bank is not set, act as if testpin is not asserted */
+	testboot = (testpin != 0) && (s);
+	if (verbose) {
+		printf("testpin   = %d\n", testpin);
+		printf("test_bank = %s\n", s ? s : "not set");
+		printf("boot test app : %s\n", (testboot) ? "yes" : "no");
+	}
+	/* return 0 means: testboot, therefore we need the inversion */
+	return !testboot;
+}
+
+U_BOOT_CMD(km_checktestboot, 2, 0, do_checktestboot,
+		"check if testpin is asserted",
+		"[v]\n  v - verbose output"
+);
diff --git a/include/configs/km/keymile-common.h b/include/configs/km/keymile-common.h
index 04f39c1..b650539 100644
--- a/include/configs/km/keymile-common.h
+++ b/include/configs/km/keymile-common.h
@@ -245,7 +245,9 @@
 	CONFIG_KM_DEF_ENV_CONSTANTS					\
 	"altbootcmd=run bootcmd\0"					\
 	"bootcmd=km_checkbidhwk &&  "					\
-	"	setenv bootcmd \'setenv boot_bank ${actual_bank}; "	\
+		"setenv bootcmd \'if km_checktestboot; then; "          \
+				"setenv boot_bank ${test_bank}; else; " \
+				"setenv boot_bank ${actual_bank}; fi;"  \
 			"run ${subbootcmds}; reset\' && "		\
 		"setenv altbootcmd \'setenv boot_bank ${backup_bank}; "	\
 			"run ${subbootcmds}; reset\' && "		\
-- 
1.7.1



More information about the U-Boot mailing list