Re: [U-Boot] [PATCH] kwboot: Boot Marvell Kirkwood SoCs over a serial link.

2012-04-25 Thread Luka Perkov
Hi Daniel,

On Wed, Apr 25, 2012 at 02:34:07PM +0200, Wolfgang Denk wrote:
> In message <1335325799.8304.15.camel@ramone> you wrote:
> >
> > > Why not use something like:
> > > 
> > > BIN_FILES-$(CONFIG_KIRKWOOD) += kwboot$(SFX)
> > 
> > Huh?
> > 
> > I don't know u-boot's build system very well, but normally CONFIG items
> > are employed to keep the target lean. Where the best you could ask from
> > down-config'd host toolset build would be to not accidentally miss sth?
> > This is all host code.
> > 
> > Is building that conditionally really best current practice? If so,
> > yeah, we sure can change that.
> > 
> > But would appreciate a clarification.
> 
> It makes no sense to build this tool on systems that will have no use
> for it - say, on Power architecture.  It only costs build time.

This is what I was talking about:

diff --git a/tools/Makefile b/tools/Makefile
index 8993fdd..8097d95 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -72,6 +72,7 @@ BIN_FILES-$(CONFIG_SMDK5250) += mksmdk5250spl$(SFX)
 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)
 
 # Source files which exist outside the tools directory
 EXT_OBJ_FILES-$(CONFIG_BUILD_ENVCRC) += common/env_embedded.o
@@ -101,6 +102,7 @@ OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
 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
 
 # Don't build by default
 #ifeq ($(ARCH),ppc)
@@ -234,6 +236,10 @@ $(obj)ncb$(SFX):   $(obj)ncb.o
 $(obj)ubsha1$(SFX):$(obj)os_support.o $(obj)sha1.o $(obj)ubsha1.o
$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
 
+$(obj)kwboot$(SFX): $(obj)kwboot.o
+   $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
+   $(HOSTSTRIP) $@
+
 # Some of the tool objects need to be accessed from outside the tools directory
 $(obj)%.o: $(SRCTREE)/common/%.c
$(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<

That worked for me. Please test this, merge it and resend patch v2.

When sending patch v2 please put me in CC because I don't look at the
mailing list regularly...

Regards,
Luka
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] kwboot: Boot Marvell Kirkwood SoCs over a serial link.

2012-04-25 Thread Wolfgang Denk
Dear Daniel Stodden,

In message <1335325799.8304.15.camel@ramone> you wrote:
>
> > Why not use something like:
> > 
> > BIN_FILES-$(CONFIG_KIRKWOOD) += kwboot$(SFX)
> 
> Huh?
> 
> I don't know u-boot's build system very well, but normally CONFIG items
> are employed to keep the target lean. Where the best you could ask from
> down-config'd host toolset build would be to not accidentally miss sth?
> This is all host code.
> 
> Is building that conditionally really best current practice? If so,
> yeah, we sure can change that.
> 
> But would appreciate a clarification.

It makes no sense to build this tool on systems that will have no use
for it - say, on Power architecture.  It only costs build time.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] kwboot: Boot Marvell Kirkwood SoCs over a serial link.

2012-04-25 Thread Prafulla Wadaskar


> -Original Message-
> From: u-boot-boun...@lists.denx.de [mailto:u-boot-
> boun...@lists.denx.de] On Behalf Of Daniel Stodden
> Sent: 24 April 2012 11:37
> To: U-Boot
> Subject: [U-Boot] [PATCH] kwboot: Boot Marvell Kirkwood SoCs over a
> serial link.

Hi Daniel

Pls maintain change log, each version information in the patch as per 
guidelines.

Regards..
Prafulla . . .
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] kwboot: Boot Marvell Kirkwood SoCs over a serial link.

2012-04-24 Thread Daniel Stodden
On Wed, 2012-04-25 at 02:08 +0200, Luka Perkov wrote:
> Hi Daniel,
> 
> I want to say that this works on my kirkwood board ib62x0. Nice work.
> 
> I have only a few suggestions...
> 
> On Mon, Apr 23, 2012 at 11:07:21PM -0700, Daniel Stodden wrote:
> > +.SH NAME
> > +kwboot \- Boot Marvell Kirkwood SoCs over a serial link.
> > +.SH SYNOPSIS
> > +.B kwboot
> > +.RB [ "-b \fIimage\fP" ]
> > +.RB [ "-t" ]
> > +.RB [...]
> 
> Why not put here -p and all other stuff instad ... ?

Good point. I used to have a couple more options which I later
discarded, right now they'd all fit on a single line anyway.

Fixed.

> > +.BI "\-p"
> > +In combination with \fB-b\fP, patches the header in \fIimage\fP prior
> > +to upload, to "UART boot" type.
> > +
> > +This option attempts on-the-fly conversion of some none-UART image
> > +types, such as images which were originally formatted to be stored in
> > +flash memory.
> > +
> > +Conversion is performed in memory. The contents of \fIimage\fP will
> > +not be altered.
> 
> I really like this -p feature :)


> > --- a/tools/Makefile
> > +++ b/tools/Makefile
> > @@ -68,6 +68,7 @@ BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
> >  BIN_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes$(SFX)
> >  BIN_FILES-y += mkenvimage$(SFX)
> >  BIN_FILES-y += mkimage$(SFX)
> > +BIN_FILES-y += kwboot$(SFX)
> 
> Why not use something like:
> 
> BIN_FILES-$(CONFIG_KIRKWOOD) += kwboot$(SFX)

Huh?

I don't know u-boot's build system very well, but normally CONFIG items
are employed to keep the target lean. Where the best you could ask from
down-config'd host toolset build would be to not accidentally miss sth?
This is all host code.

Is building that conditionally really best current practice? If so,
yeah, we sure can change that.

But would appreciate a clarification.

> >  NOPED_OBJ_FILES-y += os_support.o
> >  OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
> >  NOPED_OBJ_FILES-y += ublimage.o
> > +OBJ_FILES-y += kwboot.o
> 
> The same question here.
> 
> > +$(obj)kwboot$(SFX): $(obj)kwboot.o
> > +   $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
> > +   $(HOSTSTRIP) $@
> > +
> 
> And here.
> 
> > index 000..fbec8b6
> > --- /dev/null
> > +++ b/tools/kwboot.c
> > @@ -0,0 +1,750 @@
> > +/*
> > + * Boot a Marvell Kirkwood SoC, with Xmodem over UART0.
> > + *
> > + * (c) 2012 Daniel Stodden 
> > + *
> > + * References: marvell.com, "88F6180, 88F6190, 88F6192, and 88F6281
> > + *   Integrated Controller: Functional Specifications" December 2,
> > + *   2008. Chapter 24.2 "BootROM Firmware".
> 
>  ^^
> Are the spaces here on purpose?

Yup. :)

> ...
> 
> > +
> > +/*
> > + * Local variables:
> > + * mode: C
> > + * c-file-style: "Linux"
> > + * c-basic-offset: 8
> > + * tab-width: 8
> > + * indent-tabs-mode: t
> > + * End:
> > + */
> 
> Why not remove that completely?

Yup, removed.

Cheers,
Daniel

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] kwboot: Boot Marvell Kirkwood SoCs over a serial link.

2012-04-24 Thread Luka Perkov
Hi Daniel,

I want to say that this works on my kirkwood board ib62x0. Nice work.

I have only a few suggestions...

On Mon, Apr 23, 2012 at 11:07:21PM -0700, Daniel Stodden wrote:
> +.SH NAME
> +kwboot \- Boot Marvell Kirkwood SoCs over a serial link.
> +.SH SYNOPSIS
> +.B kwboot
> +.RB [ "-b \fIimage\fP" ]
> +.RB [ "-t" ]
> +.RB [...]

Why not put here -p and all other stuff instad ... ?

> +.BI "\-p"
> +In combination with \fB-b\fP, patches the header in \fIimage\fP prior
> +to upload, to "UART boot" type.
> +
> +This option attempts on-the-fly conversion of some none-UART image
> +types, such as images which were originally formatted to be stored in
> +flash memory.
> +
> +Conversion is performed in memory. The contents of \fIimage\fP will
> +not be altered.

I really like this -p feature :)

> --- a/tools/Makefile
> +++ b/tools/Makefile
> @@ -68,6 +68,7 @@ BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
>  BIN_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes$(SFX)
>  BIN_FILES-y += mkenvimage$(SFX)
>  BIN_FILES-y += mkimage$(SFX)
> +BIN_FILES-y += kwboot$(SFX)

Why not use something like:

BIN_FILES-$(CONFIG_KIRKWOOD) += kwboot$(SFX)

>  NOPED_OBJ_FILES-y += os_support.o
>  OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
>  NOPED_OBJ_FILES-y += ublimage.o
> +OBJ_FILES-y += kwboot.o

The same question here.

> +$(obj)kwboot$(SFX): $(obj)kwboot.o
> + $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
> + $(HOSTSTRIP) $@
> +

And here.

> index 000..fbec8b6
> --- /dev/null
> +++ b/tools/kwboot.c
> @@ -0,0 +1,750 @@
> +/*
> + * Boot a Marvell Kirkwood SoC, with Xmodem over UART0.
> + *
> + * (c) 2012 Daniel Stodden 
> + *
> + * References: marvell.com, "88F6180, 88F6190, 88F6192, and 88F6281
> + *   Integrated Controller: Functional Specifications" December 2,
> + *   2008. Chapter 24.2 "BootROM Firmware".

 ^^
Are the spaces here on purpose?

...

> +
> +/*
> + * Local variables:
> + * mode: C
> + * c-file-style: "Linux"
> + * c-basic-offset: 8
> + * tab-width: 8
> + * indent-tabs-mode: t
> + * End:
> + */

Why not remove that completely?

Regards,
Luka
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] kwboot: Boot Marvell Kirkwood SoCs over a serial link.

2012-04-24 Thread Daniel Stodden
On Tue, 2012-04-24 at 22:28 +0200, Luka Perkov wrote:
> Hi Daniel,
> 
> On Mon, Apr 23, 2012 at 11:07:21PM -0700, Daniel Stodden wrote:
> > The kwboot program boots boards based on Marvell's Kirkwood platform
> > via Xmodem over their integrated UART.
> > 
> > Signed-off-by: Daniel Stodden 
> > ---
> >  doc/kwboot.1   |   84 +++
> >  tools/Makefile |6 +
> >  tools/kwboot.c |  750 
> > 
> >  3 files changed, 840 insertions(+)
> >  create mode 100644 doc/kwboot.1
> >  create mode 100644 tools/kwboot.c
> 
> I'm wondering if this tool does the same thing as this one:
> 
> http://www.solinno.co.uk/public/kwuartboot/
> 
> If yes I can test it and give my comment on the patch.

Yup, same thing.

I used the above for a while. Obviously -- same startup spinner.
|/-\ :). 

Then decided I wanted this packaged in u-boot-tools.

Rewrote after after playing with various timings, moving to mmap(), 
kwbimage.h, adding term mode, etc.

It works pretty reliably for me. Let me know if not find sth. Especially
if see more than a couple '+' chars popping up during upload (I never
do, unless I deliberately scratch the TX line. Should propbably have
tested with a longer cable.).

Thanks,
Daniel



___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] kwboot: Boot Marvell Kirkwood SoCs over a serial link.

2012-04-24 Thread Luka Perkov
Hi Daniel,

On Mon, Apr 23, 2012 at 11:07:21PM -0700, Daniel Stodden wrote:
> The kwboot program boots boards based on Marvell's Kirkwood platform
> via Xmodem over their integrated UART.
> 
> Signed-off-by: Daniel Stodden 
> ---
>  doc/kwboot.1   |   84 +++
>  tools/Makefile |6 +
>  tools/kwboot.c |  750 
> 
>  3 files changed, 840 insertions(+)
>  create mode 100644 doc/kwboot.1
>  create mode 100644 tools/kwboot.c

I'm wondering if this tool does the same thing as this one:

http://www.solinno.co.uk/public/kwuartboot/

If yes I can test it and give my comment on the patch.

Regards,
Luka
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] kwboot: Boot Marvell Kirkwood SoCs over a serial link.

2012-04-23 Thread Daniel Stodden
The kwboot program boots boards based on Marvell's Kirkwood platform
via Xmodem over their integrated UART.

Signed-off-by: Daniel Stodden 
---
 doc/kwboot.1   |   84 +++
 tools/Makefile |6 +
 tools/kwboot.c |  750 
 3 files changed, 840 insertions(+)
 create mode 100644 doc/kwboot.1
 create mode 100644 tools/kwboot.c

diff --git a/doc/kwboot.1 b/doc/kwboot.1
new file mode 100644
index 000..7cb6fd9
--- /dev/null
+++ b/doc/kwboot.1
@@ -0,0 +1,84 @@
+.TH KWBOOT 1 "2012-03-05"
+
+.SH NAME
+kwboot \- Boot Marvell Kirkwood SoCs over a serial link.
+.SH SYNOPSIS
+.B kwboot
+.RB [ "-b \fIimage\fP" ]
+.RB [ "-t" ]
+.RB [...]
+.RB [\fITTY\fP]
+.SH "DESCRIPTION"
+
+The
+.B kwboot
+program boots boards based on Marvell's Kirkwood 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 (\fIkwbimage\fP), created
+using a tool such as
+.B mkimage.
+
+Following power-up or a system reset, system BootROM code polls the
+UART for a brief period of time, sensing a handshake message which
+initiates an image upload. This program sends this boot message until
+it receives a positive acknowledgement. The image is transfered using
+Xmodem.
+
+Additionally, this program implements a minimal terminal mode, which
+can be used either standalone, or entered immediately following boot
+image transfer completion. This is often useful to catch early boot
+messages, or to manually interrupt a default boot procedure performed
+by the second-stage loader.
+
+.SH "OPTIONS"
+
+.TP
+.BI "\-b \fIimage\fP"
+Handshake; then upload file \fIimage\fP over \fITTY\fP.
+
+Note that for the encapsulated boot code to be executed, \fIimage\fP
+must be of type "UART boot" (0x69). Boot images of different types,
+such as backup images of vendor firmware downloaded from flash memory
+(type 0x8B), will not work (or not as expected). See \fB-p\fP for a
+workaround.
+
+This mode writes handshake status and upload progress indication to
+stdout.
+
+.TP
+.BI "\-p"
+In combination with \fB-b\fP, patches the header in \fIimage\fP prior
+to upload, to "UART boot" type.
+
+This option attempts on-the-fly conversion of some none-UART image
+types, such as images which were originally formatted to be stored in
+flash memory.
+
+Conversion is performed in memory. The contents of \fIimage\fP will
+not be altered.
+
+.TP
+.BI "\-t"
+Run a terminal program, connecting standard input and output to
+.RB \fITTY\fP.
+
+If used in combination with \fB-b\fP, terminal mode is entered
+immediately following a successful image upload.
+
+If standard I/O streams connect to a console, this mode will terminate
+after receiving 'ctrl-\\' followed by 'c' from console input.
+
+.TP
+.BI "\-B \fIbaudrate\fP"
+Adjust the baud rate on \fITTY\fP. Default rate is 115200.
+
+.SH "SEE ALSO"
+.PP
+\fBmkimage\fP(1)
+
+.SH "AUTHORS"
+
+Daniel Stodden 
+
+
diff --git a/tools/Makefile b/tools/Makefile
index 8993fdd..2a976f7 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -68,6 +68,7 @@ BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
 BIN_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes$(SFX)
 BIN_FILES-y += mkenvimage$(SFX)
 BIN_FILES-y += mkimage$(SFX)
+BIN_FILES-y += kwboot$(SFX)
 BIN_FILES-$(CONFIG_SMDK5250) += mksmdk5250spl$(SFX)
 BIN_FILES-$(CONFIG_MX28) += mxsboot$(SFX)
 BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)
@@ -101,6 +102,7 @@ OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
 NOPED_OBJ_FILES-y += os_support.o
 OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
 NOPED_OBJ_FILES-y += ublimage.o
+OBJ_FILES-y += kwboot.o
 
 # Don't build by default
 #ifeq ($(ARCH),ppc)
@@ -234,6 +236,10 @@ $(obj)ncb$(SFX):   $(obj)ncb.o
 $(obj)ubsha1$(SFX):$(obj)os_support.o $(obj)sha1.o $(obj)ubsha1.o
$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
 
+$(obj)kwboot$(SFX): $(obj)kwboot.o
+   $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
+   $(HOSTSTRIP) $@
+
 # Some of the tool objects need to be accessed from outside the tools directory
 $(obj)%.o: $(SRCTREE)/common/%.c
$(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
diff --git a/tools/kwboot.c b/tools/kwboot.c
new file mode 100644
index 000..fbec8b6
--- /dev/null
+++ b/tools/kwboot.c
@@ -0,0 +1,750 @@
+/*
+ * Boot a Marvell Kirkwood SoC, with Xmodem over UART0.
+ *
+ * (c) 2012 Daniel Stodden 
+ *
+ * References: marvell.com, "88F6180, 88F6190, 88F6192, and 88F6281
+ *   Integrated Controller: Functional Specifications" December 2,
+ *   2008. Chapter 24.2 "BootROM Firmware".
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "kwbimage.h"
+
+#ifdef __GNUC__
+#define PACKED __attribute((packed))
+#else
+#define PACKED
+#endif
+
+/*
+ * Marvell BootROM UART Sensing
+ */
+
+static unsigned char kwboot_msg_boot[] = {
+   0xBB,

Re: [U-Boot] [PATCH] kwboot: Boot Marvell Kirkwood SoCs over a serial link.

2012-04-23 Thread Daniel Stodden
Hi.

Thanks for the instructions.

Latest kwboot patch follow here, fully reindented and thereby passing
checkpatch without warnings.

Thanks,
Daniel

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] kwboot: Boot Marvell Kirkwood SoCs over a serial link.

2012-04-23 Thread Wolfgang Denk
Dear Daniel Stodden,

In message <1335128131-25552-1-git-send-email-daniel.stod...@googlemail.com> 
you wrote:
> The kwboot program boots boards based on Marvell's Kirkwood platform
> via Xmodem over their integrated UART.
> 
> Signed-off-by: Daniel Stodden 
> ---
>  doc/kwboot.1   |   84 +++
>  tools/Makefile |6 +
>  tools/kwboot.c |  750 
> 
>  3 files changed, 840 insertions(+)
>  create mode 100644 doc/kwboot.1
>  create mode 100644 tools/kwboot.c

Please run your patch through checkpatch, clean up, and resubmit.  As
is, checkpatch complains:

total: 217 errors, 477 warnings, 858 lines checked


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
Another dream that failed.  There's nothing sadder.
-- Kirk, "This side of Paradise", stardate 3417.3
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] kwboot: Boot Marvell Kirkwood SoCs over a serial link.

2012-04-22 Thread Daniel Stodden
The kwboot program boots boards based on Marvell's Kirkwood platform
via Xmodem over their integrated UART.

Signed-off-by: Daniel Stodden 
---
 doc/kwboot.1   |   84 +++
 tools/Makefile |6 +
 tools/kwboot.c |  750 
 3 files changed, 840 insertions(+)
 create mode 100644 doc/kwboot.1
 create mode 100644 tools/kwboot.c

diff --git a/doc/kwboot.1 b/doc/kwboot.1
new file mode 100644
index 000..0d3eccd
--- /dev/null
+++ b/doc/kwboot.1
@@ -0,0 +1,84 @@
+.TH KWBOOT 1 "2012-03-05"
+
+.SH NAME
+kwboot \- Boot Marvell Kirkwood SoCs over a serial link.
+.SH SYNOPSIS
+.B kwboot
+.RB [ "-b \fIimage\fP" ]
+.RB [ "-t" ]
+.RB [...]
+.RB [\fITTY\fP]
+.SH "DESCRIPTION"
+
+The
+.B kwboot
+program boots boards based on Marvell's Kirkwood 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 (\fIkwbimage\fP), created
+using a tool such as
+.B mkimage.
+
+Following power-up or a system reset, system BootROM code polls the
+UART for a brief period of time, sensing a handshake message which
+initiates an image upload. This program sends this boot message until
+it receives a positive acknowledgement. The image is transfered using
+Xmodem.
+
+Additionally, this program implements a minimal terminal mode, which
+can be used either standalone, or entered immediately following boot
+image transfer completion. This is often useful to catch early boot
+messages, or to manually interrupt a default boot procedure performed
+by the second-stage loader.
+
+.SH "OPTIONS"
+
+.TP
+.BI "\-b \fIimage\fP"
+Handshake; then upload file \fIimage\fP over \fITTY\fP. 
+
+Note that for the encapsulated boot code to be executed, \fIimage\fP
+must be of type "UART boot" (0x69). Boot images of different types,
+such as backup images of vendor firmware downloaded from flash memory
+(type 0x8B), will not work (or not as expected). See \fB-p\fP for a
+workaround.
+
+Unless \fB-q\fP is provided, this mode writes handshake status and
+upload progress indication to stdout.
+
+.TP
+.BI "\-p"
+In combination with \fB-b\fP, patches the header in \fIimage\fP prior
+to upload, to "UART boot" type.
+
+This option attempts on-the-fly conversion of some none-UART image
+types, such as images which were originally formatted to be stored in
+flash memory.
+
+Conversion is performed in-core. The contents of \fIimage\fP will not
+be altered.
+
+.TP
+.BI "\-t"
+Run a terminal program, connecting standard input and output to
+.RB \fITTY\fP.
+
+If used in combination with \fB-b\fP, terminal mode is entered
+immediately following a successful image upload.
+
+If standard I/O streams connect to a console, this mode will terminate
+after receiving 'ctrl-\\' followed by 'c' from console input.
+
+.TP
+.BI "\-B \fIbaudrate\fP"
+Adjust the baud rate on \fITTY\fP. Default rate is 115200.
+
+.SH "SEE ALSO"
+.PP
+\fBmkimage\fP(1)
+
+.SH "AUTHORS"
+
+Daniel Stodden 
+
+
diff --git a/tools/Makefile b/tools/Makefile
index 8993fdd..2a976f7 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -68,6 +68,7 @@ BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
 BIN_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes$(SFX)
 BIN_FILES-y += mkenvimage$(SFX)
 BIN_FILES-y += mkimage$(SFX)
+BIN_FILES-y += kwboot$(SFX)
 BIN_FILES-$(CONFIG_SMDK5250) += mksmdk5250spl$(SFX)
 BIN_FILES-$(CONFIG_MX28) += mxsboot$(SFX)
 BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)
@@ -101,6 +102,7 @@ OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
 NOPED_OBJ_FILES-y += os_support.o
 OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
 NOPED_OBJ_FILES-y += ublimage.o
+OBJ_FILES-y += kwboot.o
 
 # Don't build by default
 #ifeq ($(ARCH),ppc)
@@ -234,6 +236,10 @@ $(obj)ncb$(SFX):   $(obj)ncb.o
 $(obj)ubsha1$(SFX):$(obj)os_support.o $(obj)sha1.o $(obj)ubsha1.o
$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
 
+$(obj)kwboot$(SFX): $(obj)kwboot.o
+   $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
+   $(HOSTSTRIP) $@
+
 # Some of the tool objects need to be accessed from outside the tools directory
 $(obj)%.o: $(SRCTREE)/common/%.c
$(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
diff --git a/tools/kwboot.c b/tools/kwboot.c
new file mode 100644
index 000..65c50d2
--- /dev/null
+++ b/tools/kwboot.c
@@ -0,0 +1,750 @@
+/*
+ * Boot a Marvell Kirkwood SoC, with Xmodem over UART0.
+ *
+ * (c) 2012 Daniel Stodden 
+ *
+ * References: marvell.com, "88F6180, 88F6190, 88F6192, and 88F6281
+ *   Integrated Controller: Functional Specifications" December 2,
+ *   2008. Chapter 24.2 "BootROM Firmware".
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "kwbimage.h"
+
+#ifdef __GNUC__
+#define PACKED __attribute((packed))
+#else
+#define PACKED
+#endif
+
+/*
+ * Marvell BootROM UART Sensing
+ */
+
+static unsigned char kwboot_