From patchwork Tue Dec 4 08:32:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [U-Boot,v2,10/10] tools: Add support for Dove to kwboot Date: Mon, 03 Dec 2012 22:32:03 -0000 From: Sebastian Hesselbarth X-Patchwork-Id: 203582 Message-Id: <1354609923-27320-11-git-send-email-sebastian.hesselbarth@gmail.com> To: Sebastian Hesselbarth Cc: Rabeeh Khoury , Luka Perkov , u-boot@lists.denx.de, Daniel Stodden , Andy Fleming On Dove kwboot can also be used to boot an u-boot image into RAM. In contrast to Kirkwood, Dove does not support the UART boot mode sequence but requires the UART boot mode to be selected through strap pins. The SolidRun CuBox has a push button to allow uart boot mode but fails on the boot sequence sent by kwboot. This patch adds another cmdline option to allow to send a boot image without the boot sequence and adds support for Dove. Signed-off-by: Sebastian Hesselbarth --- Changelog: v1->v2: - also update kwboot.1 manpage Cc: u-boot@lists.denx.de Cc: Sebastian Hesselbarth Cc: Rabeeh Khoury Cc: Albert Aribaud Cc: Prafulla Wadaskar Cc: Andy Fleming Cc: Joe Hershberger Cc: Daniel Stodden Cc: Luka Perkov --- doc/kwboot.1 | 13 ++++++++++--- tools/Makefile | 2 ++ tools/kwboot.c | 44 ++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/doc/kwboot.1 b/doc/kwboot.1 index ed08398..3e26acc 100644 --- a/doc/kwboot.1 +++ b/doc/kwboot.1 @@ -1,17 +1,18 @@ -.TH KWBOOT 1 "2012-05-19" +.TH KWBOOT 1 "2012-12-02" .SH NAME -kwboot \- Boot Marvell Kirkwood SoCs over a serial link. +kwboot \- Boot Marvell Kirkwood/Dove SoCs over a serial link. .SH SYNOPSIS .B kwboot .RB [ "-b \fIimage\fP" ] .RB [ "-p" ] .RB [ "-t" ] +.RB [ "-u" ] .RB [ "-B \fIbaudrate\fP" ] .RB \fITTY\fP .SH "DESCRIPTION" -The \fBmkimage\fP program boots boards based on Marvell's Kirkwood +The \fBmkimage\fP program boots boards based on Marvell's Kirkwood/Dove platform over their integrated UART. Boot image files will typically contain a second stage boot loader, such as U-Boot. The image file must conform to Marvell's BootROM firmware image format @@ -68,6 +69,12 @@ If standard I/O streams connect to a console, this mode will terminate after receiving 'ctrl-\\' followed by 'c' from console input. .TP +.BI "\-u" +Disables the UART boot mode sequence for platforms that do not support +it (e.g. Dove). Usually, the UART boot mode can be selected by pressing +a push button on power-up. + +.TP .BI "\-B \fIbaudrate\fP" Adjust the baud rate on \fITTY\fP. Default rate is 115200. diff --git a/tools/Makefile b/tools/Makefile index 686840a..845384f 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -73,6 +73,7 @@ BIN_FILES-$(CONFIG_MX28) += mxsboot$(SFX) BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX) BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX) BIN_FILES-$(CONFIG_KIRKWOOD) += kwboot$(SFX) +BIN_FILES-$(CONFIG_DOVE) += kwboot$(SFX) # Source files which exist outside the tools directory EXT_OBJ_FILES-$(CONFIG_BUILD_ENVCRC) += common/env_embedded.o @@ -104,6 +105,7 @@ NOPED_OBJ_FILES-y += os_support.o OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o NOPED_OBJ_FILES-y += ublimage.o OBJ_FILES-$(CONFIG_KIRKWOOD) += kwboot.o +OBJ_FILES-$(CONFIG_DOVE) += kwboot.o # Don't build by default #ifeq ($(ARCH),ppc) diff --git a/tools/kwboot.c b/tools/kwboot.c index e773f01..199678a 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -293,6 +293,30 @@ kwboot_bootmsg(int tty, void *msg) } static int +kwboot_bootmsg_uartmode(int tty) +{ + int rc; + char c; + + kwboot_printv("Please reboot the target into UART boot mode..."); + + do { + rc = tcflush(tty, TCIOFLUSH); + if (rc) + break; + + rc = kwboot_tty_recv(tty, &c, 1, KWBOOT_MSG_RSP_TIMEO); + + kwboot_spinner(); + + } while (rc || c != NAK); + + kwboot_printv("\n"); + + return rc; +} + +static int kwboot_xm_makeblock(struct kwboot_block *block, const void *data, size_t size, int pnum) { @@ -601,10 +625,11 @@ static void kwboot_usage(FILE *stream, char *progname) { fprintf(stream, - "Usage: %s -b [ -p ] [ -t ] " + "Usage: %s -b [ -p ] [ -t ] [ -u ] " "[-B ] \n", progname); fprintf(stream, "\n"); fprintf(stream, " -b : boot \n"); + fprintf(stream, " -u: target requires UART boot mode (e.g. Dove)\n"); fprintf(stream, " -p: patch to type 0x69 (uart boot)\n"); fprintf(stream, "\n"); fprintf(stream, " -t: mini terminal\n"); @@ -617,7 +642,7 @@ int main(int argc, char **argv) { const char *ttypath, *imgpath; - int rv, rc, tty, term, prot, patch; + int rv, rc, tty, uartmode, term, prot, patch; void *bootmsg; void *img; size_t size; @@ -628,6 +653,7 @@ main(int argc, char **argv) bootmsg = NULL; imgpath = NULL; img = NULL; + uartmode = 0; term = 0; patch = 0; size = 0; @@ -636,7 +662,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:ptuB:"); if (c < 0) break; @@ -654,6 +680,10 @@ main(int argc, char **argv) term = 1; break; + case 'u': + uartmode = 1; + break; + case 'B': speed = kwboot_tty_speed(atoi(optarg)); if (speed == -1) @@ -702,7 +732,13 @@ main(int argc, char **argv) } } - if (bootmsg) { + if (uartmode) { + rc = kwboot_bootmsg_uartmode(tty); + if (rc) { + perror("bootmsg"); + goto out; + } + } else if (bootmsg) { rc = kwboot_bootmsg(tty, bootmsg); if (rc) { perror("bootmsg");