All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] At start of autoboot check, flush any pending RX bytes
@ 2015-12-21  2:07 Craig McQueen
  2016-01-11 16:59 ` Simon Glass
  0 siblings, 1 reply; 10+ messages in thread
From: Craig McQueen @ 2015-12-21  2:07 UTC (permalink / raw)
  To: u-boot

This is to avoid the boot sequence halting due to initial "junk"
received on serial input.

Signed-off-by: Craig McQueen <craig.mcqueen@innerrange.com>
---
I have found that on the BeagleBone Black, U-Boot occasionally halts at 
the U-Boot prompt at boot-up, whether power-up, warm external 
reset or software reset. I have seen other people report the same issue.

This seems to be due to U-Boot receiving "junk" data on the serial 
console. The BeagleBone Black has a pull-down resistor which was 
apparently added to try to mitigate this issue, but it doesn't entirely 
fix it.

 common/autoboot.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/common/autoboot.c b/common/autoboot.c
index c11fb31..3ab51d9 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -230,19 +230,29 @@ static int abortboot_normal(int bootdelay)
 		printf("Hit any key to stop autoboot: %2d ", bootdelay);
 #endif
 
-#if defined CONFIG_ZERO_BOOTDELAY_CHECK
 	/*
-	 * Check if key already pressed
-	 * Don't check if bootdelay < 0
+	 * Flush any pending input key presses.
+	 * On some systems, there might be some junk input.
+	 * No need if bootdelay < 0.
 	 */
 	if (bootdelay >= 0) {
-		if (tstc()) {	/* we got a key press	*/
+		ts = get_timer(0);
+		while (tstc()) {	/* we got a key press	*/
 			(void) getc();  /* consume input	*/
+#if defined CONFIG_ZERO_BOOTDELAY_CHECK
 			puts("\b\b\b 0");
 			abort = 1;	/* don't auto boot	*/
+			break;
+#else
+			/*
+			 * Sanity check just to avoid infinite loop. It should
+			 * never happen if hardware is working as expected.
+			 */
+			if (get_timer(ts) >= 1000)
+				break;
+#endif
 		}
 	}
-#endif
 
 	while ((bootdelay > 0) && (!abort)) {
 		--bootdelay;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-01-20 14:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-21  2:07 [U-Boot] [PATCH] At start of autoboot check, flush any pending RX bytes Craig McQueen
2016-01-11 16:59 ` Simon Glass
2016-01-14 17:31   ` Tom Rini
2016-01-14 17:48     ` Robert Nelson
2016-01-14 17:51       ` Tom Rini
2016-01-14 17:56         ` Robert Nelson
2016-01-14 18:03           ` Tom Rini
2016-01-19  6:46     ` Craig McQueen
2016-01-20  4:35       ` Simon Glass
2016-01-20 14:43         ` Robert Nelson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.