From patchwork Fri Jun 27 09:55:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 364842 X-Patchwork-Delegate: prafulla@marvell.com 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 2E7C61400E8 for ; Fri, 27 Jun 2014 19:58:38 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2DC484B85C; Fri, 27 Jun 2014 11:58:27 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 3do56WggQKan; Fri, 27 Jun 2014 11:58:26 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4C6B74B83E; Fri, 27 Jun 2014 11:55:32 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3A91BA7811 for ; Fri, 27 Jun 2014 11:55:17 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 JkRQKtQcCNDF for ; Fri, 27 Jun 2014 11:55:13 +0200 (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 mo4-p04-ob.smtp.rzone.de (mo4-p04-ob.smtp.rzone.de [81.169.146.178]) by theia.denx.de (Postfix) with ESMTPS id 468FCA77ED for ; Fri, 27 Jun 2014 11:54:48 +0200 (CEST) X-RZG-CLASS-ID: mo04 X-RZG-AUTH: :IW0NeWC7b/q2i6W/qstXb1SBUuFnrGohfvxEndrDXKjzPMsB3oimjD61I4fPQhgcxmp3 Received: from stefan-work.domain_not_set.invalid (b9168f11.cgn.dg-w.de [185.22.143.17]) by post.strato.de (RZmta 34.5 SBL|AUTH) with ESMTPA id R07c6dq5R9sfoMq; Fri, 27 Jun 2014 11:54:41 +0200 (CEST) From: Stefan Roese To: u-boot@lists.denx.de Date: Fri, 27 Jun 2014 11:55:08 +0200 Message-Id: <1403862911-6138-23-git-send-email-sr@denx.de> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1403862911-6138-1-git-send-email-sr@denx.de> References: <1403862911-6138-1-git-send-email-sr@denx.de> Cc: trini@ti.com Subject: [U-Boot] [PATCH v1 22/25] tools/kwboot: Sync with latest barebox version to support Armada XP X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de The barebox version of the kwboot tool has evolved a bit. To support Armada XP and Dove. Additionally a few minor fixes have been applied. So lets sync with the latest barebox version. Please note that the main difference between both versions now is, that the U-Boot version still supports the -p option, to dynamically patch an image for UART boot mode. I didn't test it now though. Signed-off-by: Stefan Roese --- tools/kwboot.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 83 insertions(+), 14 deletions(-) diff --git a/tools/kwboot.c b/tools/kwboot.c index e773f01..c47970e 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -1,5 +1,6 @@ /* - * Boot a Marvell Kirkwood SoC, with Xmodem over UART0. + * Boot a Marvell SoC, with Xmodem over UART0. + * supports Kirkwood, Dove, Armada 370, Armada XP * * (c) 2012 Daniel Stodden * @@ -37,8 +38,12 @@ static unsigned char kwboot_msg_boot[] = { 0xBB, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; -#define KWBOOT_MSG_REQ_DELAY 10 /* ms */ -#define KWBOOT_MSG_RSP_TIMEO 50 /* ms */ +static unsigned char kwboot_msg_debug[] = { + 0xDD, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 +}; + +#define KWBOOT_MSG_REQ_DELAY 1000 /* ms */ +#define KWBOOT_MSG_RSP_TIMEO 1000 /* ms */ /* * Xmodem Transfers @@ -184,6 +189,9 @@ kwboot_tty_send(int fd, const void *buf, size_t len) int rc; ssize_t n; + if (!buf) + return 0; + rc = -1; do { @@ -268,7 +276,10 @@ kwboot_bootmsg(int tty, void *msg) int rc; char c; - kwboot_printv("Sending boot message. Please reboot the target..."); + if (msg == NULL) + kwboot_printv("Please reboot the target into UART boot mode..."); + else + kwboot_printv("Sending boot message. Please reboot the target..."); do { rc = tcflush(tty, TCIOFLUSH); @@ -293,6 +304,37 @@ kwboot_bootmsg(int tty, void *msg) } static int +kwboot_debugmsg(int tty, void *msg) +{ + int rc; + + kwboot_printv("Sending debug message. Please reboot the target..."); + + do { + char buf[16]; + + rc = tcflush(tty, TCIOFLUSH); + if (rc) + break; + + rc = kwboot_tty_send(tty, msg, 8); + if (rc) { + usleep(KWBOOT_MSG_REQ_DELAY * 1000); + continue; + } + + rc = kwboot_tty_recv(tty, buf, 16, KWBOOT_MSG_RSP_TIMEO); + + kwboot_spinner(); + + } while (rc); + + kwboot_printv("\n"); + + return rc; +} + +static int kwboot_xm_makeblock(struct kwboot_block *block, const void *data, size_t size, int pnum) { @@ -300,6 +342,7 @@ kwboot_xm_makeblock(struct kwboot_block *block, const void *data, size_t n; int i; + block->soh = SOH; block->pnum = pnum; block->_pnum = ~block->pnum; @@ -326,9 +369,15 @@ kwboot_xm_sendblock(int fd, struct kwboot_block *block) if (rc) break; - rc = kwboot_tty_recv(fd, &c, 1, KWBOOT_BLK_RSP_TIMEO); - if (rc) - break; + do { + rc = kwboot_tty_recv(fd, &c, 1, KWBOOT_BLK_RSP_TIMEO); + if (rc) + break; + + if (c != ACK && c != NAK && c != CAN) + printf("%c", c); + + } while (c != ACK && c != NAK && c != CAN); if (c != ACK) kwboot_progress(-1, '+'); @@ -511,7 +560,6 @@ kwboot_mmap_image(const char *path, size_t *size, int prot) void *img; rc = -1; - fd = -1; img = NULL; fd = open(path, O_RDONLY); @@ -601,11 +649,15 @@ static void kwboot_usage(FILE *stream, char *progname) { fprintf(stream, - "Usage: %s -b [ -p ] [ -t ] " - "[-B ] \n", progname); + "Usage: %s [-d | -b | -D ] [ -t ] [-B ] \n", + progname); fprintf(stream, "\n"); - fprintf(stream, " -b : boot \n"); + fprintf(stream, + " -b : boot with preamble (Kirkwood, Armada 370/XP)\n"); fprintf(stream, " -p: patch to type 0x69 (uart boot)\n"); + fprintf(stream, + " -D : boot without preamble (Dove)\n"); + fprintf(stream, " -d: enter debug mode\n"); fprintf(stream, "\n"); fprintf(stream, " -t: mini terminal\n"); fprintf(stream, "\n"); @@ -619,6 +671,7 @@ main(int argc, char **argv) const char *ttypath, *imgpath; int rv, rc, tty, term, prot, patch; void *bootmsg; + void *debugmsg; void *img; size_t size; speed_t speed; @@ -626,6 +679,7 @@ main(int argc, char **argv) rv = 1; tty = -1; bootmsg = NULL; + debugmsg = NULL; imgpath = NULL; img = NULL; term = 0; @@ -636,7 +690,7 @@ main(int argc, char **argv) kwboot_verbose = isatty(STDOUT_FILENO); do { - int c = getopt(argc, argv, "hb:ptB:"); + int c = getopt(argc, argv, "hb:ptB:dD:"); if (c < 0) break; @@ -646,6 +700,15 @@ main(int argc, char **argv) imgpath = optarg; break; + case 'D': + bootmsg = NULL; + imgpath = optarg; + break; + + case 'd': + debugmsg = kwboot_msg_debug; + break; + case 'p': patch = 1; break; @@ -667,7 +730,7 @@ main(int argc, char **argv) } } while (1); - if (!bootmsg && !term) + if (!bootmsg && !term && !debugmsg) goto usage; if (patch && !imgpath) @@ -702,7 +765,13 @@ main(int argc, char **argv) } } - if (bootmsg) { + if (debugmsg) { + rc = kwboot_debugmsg(tty, debugmsg); + if (rc) { + perror("debugmsg"); + goto out; + } + } else { rc = kwboot_bootmsg(tty, bootmsg); if (rc) { perror("bootmsg");