From patchwork Mon Aug 31 20:30:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Smith X-Patchwork-Id: 512589 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 7712E140081 for ; Tue, 1 Sep 2015 06:54:35 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A806F4B739; Mon, 31 Aug 2015 22:54:28 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id b1t_M3qXbzMf; Mon, 31 Aug 2015 22:54:27 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2B98E4B676; Mon, 31 Aug 2015 22:54:26 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DEDBE4B6EA for ; Mon, 31 Aug 2015 22:54:09 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0-dcA_MU4iEG for ; Mon, 31 Aug 2015 22:54:09 +0200 (CEST) X-Greylist: delayed 1411 seconds by postgrey-1.34 at theia; Mon, 31 Aug 2015 22:54:06 CEST X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from p01c11o145.mxlogic.net (p01c11o145.mxlogic.net [208.65.144.68]) by theia.denx.de (Postfix) with ESMTPS id 092654B676 for ; Mon, 31 Aug 2015 22:54:06 +0200 (CEST) Received: from unknown [64.198.156.98] (EHLO ELECSYS-MAIL.dci.local) by p01c11o145.mxlogic.net(mxl_mta-8.4.0-3) with ESMTP id 1feb4e55.2b027b411940.1520938.00-591.4049088.p01c11o145.mxlogic.net (envelope-from ); Mon, 31 Aug 2015 14:54:09 -0600 (MDT) X-MXL-Hash: 55e4bef13f332c38-3e419b4bd623db57b38dc7cda64a412ab05da620 Received: from unknown [64.198.156.98] (EHLO ELECSYS-MAIL.dci.local) by p01c11o145.mxlogic.net(mxl_mta-8.4.0-3) over TLS secured channel with ESMTP id 869b4e55.0.1503693.00-327.3998344.p01c11o145.mxlogic.net (envelope-from ); Mon, 31 Aug 2015 14:30:44 -0600 (MDT) X-MXL-Hash: 55e4b9743b3ca286-53ba5cbfa4090aee1ca09aa13eedb159498e2f55 Received: from ELECSYS-MAIL.dci.local ([fe80::f963:2d15:a0de:5ad0]) by ELECSYS-MAIL.dci.local ([fe80::f963:2d15:a0de:5ad0%12]) with mapi id 14.03.0248.002; Mon, 31 Aug 2015 15:30:32 -0500 From: Kevin Smith To: "u-boot@lists.denx.de" Thread-Topic: [PATCH] tools/kwboot.c: Support UART fallback mode Thread-Index: AQHQ5Cvhbb/yC3LbEki4cB1aItnbxg== Date: Mon, 31 Aug 2015 20:30:30 +0000 Message-ID: <1441052989-14603-1-git-send-email-kevin.smith@elecsyscorp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.63.192.85] MIME-Version: 1.0 X-AnalysisOut: [v=2.1 cv=PK8b+JaC c=1 sm=1 tr=0 a=51qEjsKpZkmECDgIwGerrA==] X-AnalysisOut: [:117 a=51qEjsKpZkmECDgIwGerrA==:17 a=LfzEU8aZAAAA:8 a=YlVT] X-AnalysisOut: [AMxIAAAA:8 a=HrcsFxVtGSEA:10 a=8nJEP1OIZ-IA:10 a=xqWC_Br6k] X-AnalysisOut: [Y4A:10 a=uRRa74qj2VoA:10 a=kv2Q4OqgsbtGz_adcdgA:9 a=wPNLvf] X-AnalysisOut: [GTeEIA:10] X-Spam: [F=0.5200000000; CM=0.500; MH=0.520(2015083116); S=0.200(2015072901)] X-MAIL-FROM: X-SOURCE-IP: [64.198.156.98] Cc: "sr@denx.de" Subject: [U-Boot] [PATCH] tools/kwboot.c: Support UART fallback mode X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "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 Reviewed-by: Stefan Roese --- 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 | -s | -b | -D ] [ -t ] [-B ] \n", + "Usage: %s [-f] [-d | -a | -q | -s | -b | -D ] [ -t ] [-B ] \n", progname); fprintf(stream, "\n"); fprintf(stream, @@ -667,6 +676,7 @@ kwboot_usage(FILE *stream, char *progname) " -D : boot 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 : use specific request-delay\n"); fprintf(stream, " -s : 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;