public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] tools/kwboot.c: Support UART fallback mode
@ 2015-08-31 20:30 Kevin Smith
  2015-09-01 12:52 ` Stefan Roese
  0 siblings, 1 reply; 4+ messages in thread
From: Kevin Smith @ 2015-08-31 20:30 UTC (permalink / raw)
  To: u-boot

On some processors such as Armada 38x, if the hardware-
configured boot mode fails, the CPU falls back to booting over
UART.  When this happens the chip prints a failure message, waits
for the magic sequence and, when it is received, prints a
"(boot)" message, then sends a NAK to start the transfer.

This breaks the current kwboot behavior because the xmodem
transfer only tries to read one character after the magic
sequence, looking for the NAK.  Instead it gets the "(boot)"
text, and retries the magic sequence.  The CPU thinks the
repeated sequence is part of the packet, stops NAKing, and one
side or another eventually times out.

This patch adds support for a fallback mode which continues to
scan for a NAK in the characters received after the sequence,
printing out any non-NAK characters.  This allows kwboot to skip
the "(boot)" message, find the NAK, and start the transfer
successfully.

Signed-off-by: Kevin Smith <kevin.smith@elecsyscorp.com>
---
 tools/kwboot.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/tools/kwboot.c b/tools/kwboot.c
index af7a6ee..6b58fc9 100644
--- a/tools/kwboot.c
+++ b/tools/kwboot.c
@@ -71,6 +71,7 @@ struct kwboot_block {
 #define KWBOOT_BLK_RSP_TIMEO 1000 /* ms */
 
 static int kwboot_verbose;
+static int support_fallback;
 
 static int msg_req_delay = KWBOOT_MSG_REQ_DELAY;
 static int msg_rsp_timeo = KWBOOT_MSG_RSP_TIMEO;
@@ -300,7 +301,15 @@ kwboot_bootmsg(int tty, void *msg)
 			continue;
 		}
 
-		rc = kwboot_tty_recv(tty, &c, 1, msg_rsp_timeo);
+		while (1) {
+			rc = kwboot_tty_recv(tty, &c, 1, msg_rsp_timeo);
+			if (support_fallback && rc == 0 && c != NAK) {
+				printf("%c", c);
+				fflush(stdout);
+				continue;
+			}
+			break;
+		}
 
 		kwboot_spinner();
 
@@ -657,7 +666,7 @@ static void
 kwboot_usage(FILE *stream, char *progname)
 {
 	fprintf(stream,
-		"Usage: %s [-d | -a | -q <req-delay> | -s <resp-timeo> | -b <image> | -D <image> ] [ -t ] [-B <baud> ] <TTY>\n",
+		"Usage: %s [-f] [-d | -a | -q <req-delay> | -s <resp-timeo> | -b <image> | -D <image> ] [ -t ] [-B <baud> ] <TTY>\n",
 		progname);
 	fprintf(stream, "\n");
 	fprintf(stream,
@@ -667,6 +676,7 @@ kwboot_usage(FILE *stream, char *progname)
 		"  -D <image>: boot <image> without preamble (Dove)\n");
 	fprintf(stream, "  -d: enter debug mode\n");
 	fprintf(stream, "  -a: use timings for Armada XP\n");
+	fprintf(stream, "  -f: support UART fallback after failed boot\n");
 	fprintf(stream, "  -q <req-delay>:  use specific request-delay\n");
 	fprintf(stream, "  -s <resp-timeo>: use specific response-timeout\n");
 	fprintf(stream, "\n");
@@ -701,7 +711,7 @@ main(int argc, char **argv)
 	kwboot_verbose = isatty(STDOUT_FILENO);
 
 	do {
-		int c = getopt(argc, argv, "hb:ptaB:dD:q:s:");
+		int c = getopt(argc, argv, "hb:ptfaB:dD:q:s:");
 		if (c < 0)
 			break;
 
@@ -728,6 +738,10 @@ main(int argc, char **argv)
 			term = 1;
 			break;
 
+		case 'f':
+			support_fallback = 1;
+			break;
+
 		case 'a':
 			msg_req_delay = KWBOOT_MSG_REQ_DELAY_AXP;
 			msg_rsp_timeo = KWBOOT_MSG_RSP_TIMEO_AXP;
-- 
2.4.6

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

end of thread, other threads:[~2016-03-29 15:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-31 20:30 [U-Boot] [PATCH] tools/kwboot.c: Support UART fallback mode Kevin Smith
2015-09-01 12:52 ` Stefan Roese
2016-03-24  9:29   ` Stefan Roese
2016-03-29 15:47     ` Kevin Smith

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox