All of lore.kernel.org
 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

* [U-Boot] [PATCH] tools/kwboot.c: Support UART fallback mode
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Roese @ 2015-09-01 12:52 UTC (permalink / raw)
  To: u-boot

Hi Kevin,

(Added Luka to Cc, as the Marvell / MVEBU custodian)

On 31.08.2015 22:30, Kevin Smith wrote:
> 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>

I've not seen this "(boot)" yet. But the patch looks good. So:

Reviewed-by: Stefan Roese <sr@denx.de>

BTW: Please always keep Luka on MVEBU related patches on Cc.

Thanks,
Stefan

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

* [U-Boot] [PATCH] tools/kwboot.c: Support UART fallback mode
  2015-09-01 12:52 ` Stefan Roese
@ 2016-03-24  9:29   ` Stefan Roese
  2016-03-29 15:47     ` Kevin Smith
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Roese @ 2016-03-24  9:29 UTC (permalink / raw)
  To: u-boot

Hi Kevin,

On 01.09.2015 14:52, Stefan Roese wrote:
> Hi Kevin,
>
> (Added Luka to Cc, as the Marvell / MVEBU custodian)
>
> On 31.08.2015 22:30, Kevin Smith wrote:
>> 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>
>
> I've not seen this "(boot)" yet. But the patch looks good. So:
>
> Reviewed-by: Stefan Roese <sr@denx.de>

Is this patch still needed (or helpful)? If yes, please rebase
on top of latest u-boot-marvell/master and send a new version
so that I can pick it up.

Thanks,
Stefan

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

* [U-Boot] [PATCH] tools/kwboot.c: Support UART fallback mode
  2016-03-24  9:29   ` Stefan Roese
@ 2016-03-29 15:47     ` Kevin Smith
  0 siblings, 0 replies; 4+ messages in thread
From: Kevin Smith @ 2016-03-29 15:47 UTC (permalink / raw)
  To: u-boot

Hi Stefan,

On 03/24/2016 04:29 AM, Stefan Roese wrote:
> Hi Kevin,
>
> On 01.09.2015 14:52, Stefan Roese wrote:
>> Hi Kevin,
>>
>> (Added Luka to Cc, as the Marvell / MVEBU custodian)
>>
>> On 31.08.2015 22:30, Kevin Smith wrote:
>>> 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>
>>
>> I've not seen this "(boot)" yet. But the patch looks good. So:
>>
>> Reviewed-by: Stefan Roese <sr@denx.de>
>
> Is this patch still needed (or helpful)? If yes, please rebase
> on top of latest u-boot-marvell/master and send a new version
> so that I can pick it up.
>
> Thanks,
> Stefan
>
I don't think this is needed in most cases.  I will leave it out to 
avoid cluttering up the program.  If that changes, I will resubmit.

Thank you,
Kevin

^ permalink raw reply	[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 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.