Re: [U-Boot] [PATCH v3 4/5] usb/gadget: add the fastboot gadget

2014-04-15 Thread Rob Herring
On Tue, Apr 15, 2014 at 10:41 AM, Lukasz Majewski
 wrote:
> Hi Rob,
>
>> From: Sebastian Siewior 
>>
>> This patch contains an implementation of the fastboot protocol on the
>> device side and a little of documentation.
>> The gadget expects the new-style gadget framework.
>> The gadget implements the getvar, reboot, download and reboot
>> commands. What is missing is the flash handling i.e. writting the
>> image to media.
>>
>> v3 (Rob Herring):
>> This is based on http://patchwork.ozlabs.org/patch/126798/ with the
>> following changes:
>> - Rebase to current mainline and updates for current gadget API
>> - Use SPDX identifiers for licenses
>> - Traced the history and added missing copyright to cmd_fastboot.c
>> - Use load_addr/load_size for transfer buffer
>> - Allow vendor strings to be optional

[snip]

> To sum up:
>
> It seems that you are using UDC driver + gadget approach for fastboot.
>
> However, current gadgets for downloading data (DFU, UMS, THOR) use UDC +
> composite gadget + function.
>
> Also they use common download code - g_dnl.c to implement their
> commands.
>
> I would be more than happy if you were willing to port the fastboot
> protocol to the existing framework.
> For overall picture of the current design please look into the following
> keynote:
> http://www.denx.de/wiki/pub/U-Boot/MiniSummitELCE2013/dfu_elce_u-boot.pdf
>
> Please let me know if you have any questions.

Thanks for your review. I have this working using the common g_dnl.c
code now. I have a bit more clean-up to do and I will post it. My
current branch is here:

git://git.linaro.org/people/rob.herring/u-boot.git fastboot-v2

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


Re: [U-Boot] [PATCH v3 4/5] usb/gadget: add the fastboot gadget

2014-04-15 Thread Lukasz Majewski
Hi Rob,

> From: Sebastian Siewior 
> 
> This patch contains an implementation of the fastboot protocol on the
> device side and a little of documentation.
> The gadget expects the new-style gadget framework.
> The gadget implements the getvar, reboot, download and reboot
> commands. What is missing is the flash handling i.e. writting the
> image to media.
> 
> v3 (Rob Herring):
> This is based on http://patchwork.ozlabs.org/patch/126798/ with the
> following changes:
> - Rebase to current mainline and updates for current gadget API
> - Use SPDX identifiers for licenses
> - Traced the history and added missing copyright to cmd_fastboot.c
> - Use load_addr/load_size for transfer buffer
> - Allow vendor strings to be optional

I could only propose to use common g_dnl.c code with CONFIG_G_DNL_*
defines.

> - Set vendor/product ID from config defines
> - Allow Ctrl-C to exit fastboot mode
> 
> Signed-off-by: Sebastian Andrzej Siewior 
> Signed-off-by: Rob Herring 
> ---
>  common/Makefile  |   2 +
>  common/cmd_fastboot.c|  36 +++
>  doc/README.android-fastboot  |  86 ++
>  doc/README.android-fastboot-protocol | 170 +++
>  drivers/usb/gadget/Makefile  |   1 +
>  drivers/usb/gadget/f_fastboot.c  | 535
> +++
> drivers/usb/gadget/g_fastboot.h  |  15 +
> drivers/usb/gadget/u_fastboot.c  | 260 +
> include/usb/fastboot.h   |  36 +++ 9 files changed, 1141
> insertions(+) create mode 100644 common/cmd_fastboot.c
>  create mode 100644 doc/README.android-fastboot
>  create mode 100644 doc/README.android-fastboot-protocol
>  create mode 100644 drivers/usb/gadget/f_fastboot.c
>  create mode 100644 drivers/usb/gadget/g_fastboot.h
>  create mode 100644 drivers/usb/gadget/u_fastboot.c
>  create mode 100644 include/usb/fastboot.h
> 
> diff --git a/common/Makefile b/common/Makefile
> index da208f3..fe1d8b9 100644
> --- a/common/Makefile
> +++ b/common/Makefile
> @@ -167,6 +167,8 @@ obj-y += cmd_usb.o
>  obj-y += usb.o usb_hub.o
>  obj-$(CONFIG_USB_STORAGE) += usb_storage.o
>  endif
> +obj-$(CONFIG_CMD_FASTBOOT) += cmd_fastboot.o
> +
>  obj-$(CONFIG_CMD_USB_MASS_STORAGE) += cmd_usb_mass_storage.o
>  obj-$(CONFIG_CMD_THOR_DOWNLOAD) += cmd_thordown.o
>  obj-$(CONFIG_CMD_XIMG) += cmd_ximg.o
> diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c
> new file mode 100644
> index 000..fc8d9e0
> --- /dev/null
> +++ b/common/cmd_fastboot.c
> @@ -0,0 +1,36 @@
> +/*
> + * Copyright 2008 - 2009 Windriver, 
> + * Author: Tom Rix 
> + *
> + * SPDX-License-Identifier:  GPL-2.0+
> + */
> +#include 
> +#include 
> +#include 
> +
> +static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char
> *const argv[]) +{
> + int ret = 1;
> +
> + if (!fastboot_init()) {
> + printf("Fastboot entered...\n");

Please use puts();
> +
> + ret = 0;
> +
> + while (1) {
> + if (fastboot_poll())
> + break;
> + if (ctrlc())
> + break;
> + }
> + }
> +
> + fastboot_shutdown();
> + return ret;
> +}

For the fastboot command you could use the common gadget download code
(g_dnl.c). For reference please look into common/cmd_dfu.c 

> +
> +U_BOOT_CMD(
> + fastboot,   1,  1,  do_fastboot,
> + "fastboot - enter USB Fastboot protocol",
> + ""
> +);
> diff --git a/doc/README.android-fastboot b/doc/README.android-fastboot
> new file mode 100644
> index 000..4b2a9aa
> --- /dev/null
> +++ b/doc/README.android-fastboot
> @@ -0,0 +1,86 @@
> +Android Fastboot
> +
> +
> +Overview
> +
> +The protocol that is used over USB is described in
> +README.android-fastboot-protocol in same folder.
> +
> +The current implementation does not yet support the flash and erase
> +commands.

Flashing of received data can be performed with common dfu_write()
method.

> +
> +Client installation
> +===
> +The counterpart to this gadget is the fastboot client which can
> +be found in Android's platform/system/core repository in the fastboot
> +folder. It runs on Windows, Linux and even OSx. Linux user are lucky
> since +they only need libusb.
> +Windows users need to bring some time until they have Android SDK
> (currently +http://dl.google.com/android/installer_r12-windows.exe)
> installed. You +need to install ADB package which contains the
> required glue libraries for +accessing USB. Also you need "Google USB
> driver package" and "SDK platform +tools". Once installed the usb
> driver is placed in your SDK folder under +extras\google\usb_driver.
> The android_winusb.inf needs a line like +
> +   %SingleBootLoaderInterface% = USB_Install, USB\VID_0451&PID_D022
> +
> +either in the [Google.NTx86] section for 32bit Windows or
> [Google.NTamd64] +for 64bit Windows. VID and PID should match
> whatever the 

Re: [U-Boot] [PATCH v3 4/5] usb/gadget: add the fastboot gadget

2014-04-13 Thread Lukasz Majewski
Hi Marek,

> On Friday, April 11, 2014 at 02:55:31 PM, Rob Herring wrote:
> > On Fri, Apr 11, 2014 at 2:14 AM, Bo Shen 
> > wrote:
> > > Hi Rob Herring,
> > > 
> > >   I am just do a function testing on Atmel sama5d3xek board. And
> > > a small
> > > 
> > > comment as following.
> > > 
> > >   Btw, do you test to transfer big size file. I try a file bigger
> > > than
> > > 
> > > 100MiB, it will hang. However use DFU or RNDIS don't meet this
> > > issue.
> > 
> > How much RAM do you have? It will happily download into the end of
> > RAM overwriting u-boot if loadsize is not set. DFU at least has its
> > own buffer size configuration.
> 
> I really have to wonder ... why does android not use DFU

Unfortunately the DFU has its own limitations. The most notable one is
using only EP0 for transmission. As a result the transmission speed is
slow when compared with other solutions, which are using other EPs.

> instead and
> instead forces us to take in yet another (fourth ? ... CDC ethernet,
> DFU, Thor, Fastboot)

A little explanation:
1. UMS (CDC Ethernet) - export the content of the whole flash. It should
be regarded as a convenient debug option. It is somewhat clumsy
to use dd if=/u-boot.bin of=/dev/sda1  to store u-boot.

2. DFU it is the standard - devised at 2004 - rather outdated now. It is
slow but reliable - targeted to uC flashing.

3. Thor, fastboot - protocols devised to provide faster transmission
rates (they use other EPs for transmission).

> usb image download protocol someone invented
> without cooperating with the rest of the community on a common and
> functional solution? Sigh :'-(

I think, that this problem emerged because of the lack of DFU standard
update - adding better checksumming and possibility for using other EPs
would solve the problem.

In u-boot it is not a big problem, since we are using one backend
(dfu_write()) to store data on the medium. Moreover common gadget code
- g_dnl.c is available to reduce code duplication.

To add support for other gadget one needs to implement proper function
(like f_thor.c, f_dfu.c, f_fastboot.c).

> 
> Best regards,
> Marek Vasut



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3 4/5] usb/gadget: add the fastboot gadget

2014-04-13 Thread Bo Shen

Hi Rob,

On 04/11/2014 08:55 PM, Rob Herring wrote:

On Fri, Apr 11, 2014 at 2:14 AM, Bo Shen  wrote:

Hi Rob Herring,
   I am just do a function testing on Atmel sama5d3xek board. And a small
comment as following.

   Btw, do you test to transfer big size file. I try a file bigger than
100MiB, it will hang. However use DFU or RNDIS don't meet this issue.


How much RAM do you have? It will happily download into the end of RAM
overwriting u-boot if loadsize is not set. DFU at least has its own
buffer size configuration.


There are 512MiB RAM on board. So, it won't be a problem to load this 
file from the begin of the RAM (As the u-boot is relocated to top RAM).





On 04/11/2014 03:18 AM, Rob Herring wrote:


+static void fastboot_unbind(struct usb_gadget *gadget)
+{
+   usb_ep_free_request(gadget->ep0, ep0_req);
+   ep_in->driver_data = NULL;
+   ep_out->driver_data = NULL;
+
+   gadget_is_connected = 0;
+   usb_gadget_disconnect(gadget);
+}



[snip]



+static void fastboot_disconnect(struct usb_gadget *gadget)
+{
+   fastboot_disable_ep(gadget);
+   gadget_is_connected = 0;



Do this only in unbind, as unbind is really disconnect.


So, what should disconnect function do?


Maybe some misunderstanding. I mean the "gadget_is_connected" should be 
cleared in unbind function while not in disconnect function.



Rob



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


Re: [U-Boot] [PATCH v3 4/5] usb/gadget: add the fastboot gadget

2014-04-11 Thread Marek Vasut
On Thursday, April 10, 2014 at 09:18:06 PM, Rob Herring wrote:
> From: Sebastian Siewior 
[...]

> +++ b/doc/README.android-fastboot
> @@ -0,0 +1,86 @@
> +Android Fastboot
> +
> +
> +Overview
> +
> +The protocol that is used over USB is described in
> +README.android-fastboot-protocol in same folder.

"directory", this is not windows, so no folders here either ...

> +The current implementation does not yet support the flash and erase
> +commands.
> +
> +Client installation
> +===
> +The counterpart to this gadget is the fastboot client which can
> +be found in Android's platform/system/core repository in the fastboot
> +folder. It runs on Windows, Linux and even OSx. Linux user are lucky since
> +they only need libusb.

OSX is written like so, the X is also capital.

[...]

> +In Action
> +=
> +Enter into fastboot by executing the fastboot command in u-boot and you
> +should see:
> +|Fastboot entered...
> +
> +The gadget terminates once the is unplugged.

The above sentence makes zero sense to me.

[...]

> +
> +/* e1 */

This is a fine comment, but please make it sensible.

[...]

> +
> +static struct usb_request *ep0_req;
> +
> +struct usb_ep *ep_in;
> +struct usb_request *req_in;
> +
> +struct usb_ep *ep_out;
> +struct usb_request *req_out;

Please define all global variables at the top of the file.

[...]

> diff --git a/drivers/usb/gadget/g_fastboot.h
> b/drivers/usb/gadget/g_fastboot.h new file mode 100644
> index 000..733eb38
> --- /dev/null
> +++ b/drivers/usb/gadget/g_fastboot.h
> @@ -0,0 +1,15 @@
> +#ifndef _G_FASTBOOT_H_
> +#define _G_FASTBOOT_H_
> +
> +#define EP_BUFFER_SIZE   4096
> +
> +extern struct usb_ep *ep_in;
> +extern struct usb_request *req_in;
> +extern struct usb_ep *ep_out;
> +extern struct usb_request *req_out;

Ick, I really dislike how you're distributing the variables across the code. Is 
this really necessary ?

> +void rx_handler_command(struct usb_ep *ep, struct usb_request *req);
> +int fastboot_tx_write(const char *buffer, unsigned int buffer_size);
> +const char *fb_find_usb_string(unsigned int id);

Please produce a consistent naming for those function names, something that can 
also be identified that it's coming from the fastboot gadget. Otherwise, these 
function names look rather random and are hard to pair with particular part of 
U-Boot at first glance.

[...]

> +static int strcmp_l1(const char *s1, const char *s2)
> +{
> + return strncmp(s1, s2, strlen(s1));

I suspect someone will sooner or later call this function with non-null-
terminated string as $s1 . Can't you do some boundary checking here?

I'd hate to have some fastbleed bug here (sorry, bad pun).
[...]

> +static void rx_handler_dl_image(struct usb_ep *ep, struct usb_request
> *req) +{
> + char response[RESPONSE_LEN];
> + unsigned int transfer_size = download_size - download_bytes;
> + const unsigned char *buffer = req->buf;
> + unsigned int buffer_size = req->actual;
> +
> + if (req->status != 0) {
> + printf("Bad status: %d\n", req->status);
> + return;
> + }
> +
> + if (buffer_size < transfer_size)
> + transfer_size = buffer_size;
> +
> + memcpy((void *)load_addr + download_bytes, buffer, transfer_size);
> +
> + download_bytes += transfer_size;
> +
> + /* Check if transfer is done */
> + if (download_bytes >= download_size) {
> + /*
> +  * Reset global transfer variable, keep download_bytes because
> +  * it will be used in the next possible flashing command
> +  */
> + download_size = 0;
> + req->complete = rx_handler_command;
> + req->length = EP_BUFFER_SIZE;
> +
> + sprintf(response, "OKAY");
> + fastboot_tx_write_str(response);
> +
> + printf("\ndownloading of %d bytes finished\n", download_bytes);
> + } else {
> + req->length = rx_bytes_expected();
> + }
> +
> + if (download_bytes && !(download_bytes % BYTES_PER_DOT)) {
> + printf(".");

putc()

> + if (!(download_bytes % (74 * BYTES_PER_DOT)))
> + printf("\n");

putc()

> + }
> + req->actual = 0;
> + usb_ep_queue(ep, req, 0);
> +}
[...]

> +#define FB_STR_PRODUCT_IDX  1
> +#define FB_STR_SERIAL_IDX   2
> +#define FB_STR_CONFIG_IDX   3
> +#define FB_STR_INTERFACE_IDX4
> +#define FB_STR_MANUFACTURER_IDX 5
> +#define FB_STR_PROC_REV_IDX 6
> +#define FB_STR_PROC_TYPE_IDX7

Use enum {} for those for the sake of typechecking ?
[..]
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3 4/5] usb/gadget: add the fastboot gadget

2014-04-11 Thread Marek Vasut
On Friday, April 11, 2014 at 02:55:31 PM, Rob Herring wrote:
> On Fri, Apr 11, 2014 at 2:14 AM, Bo Shen  wrote:
> > Hi Rob Herring,
> > 
> >   I am just do a function testing on Atmel sama5d3xek board. And a small
> > 
> > comment as following.
> > 
> >   Btw, do you test to transfer big size file. I try a file bigger than
> > 
> > 100MiB, it will hang. However use DFU or RNDIS don't meet this issue.
> 
> How much RAM do you have? It will happily download into the end of RAM
> overwriting u-boot if loadsize is not set. DFU at least has its own
> buffer size configuration.

I really have to wonder ... why does android not use DFU instead and instead 
forces us to take in yet another (fourth ? ... CDC ethernet, DFU, Thor, 
Fastboot) usb image download protocol someone invented without cooperating with 
the rest of the community on a common and functional solution? Sigh :'-(

Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3 4/5] usb/gadget: add the fastboot gadget

2014-04-11 Thread Tom Rini
On Thu, Apr 10, 2014 at 02:18:06PM -0500, Rob Herring wrote:

> From: Sebastian Siewior 
> 
> This patch contains an implementation of the fastboot protocol on the
> device side and a little of documentation.
> The gadget expects the new-style gadget framework.
> The gadget implements the getvar, reboot, download and reboot commands.
> What is missing is the flash handling i.e. writting the image to media.
> 
> v3 (Rob Herring):
> This is based on http://patchwork.ozlabs.org/patch/126798/ with the
> following changes:
> - Rebase to current mainline and updates for current gadget API
> - Use SPDX identifiers for licenses
> - Traced the history and added missing copyright to cmd_fastboot.c
> - Use load_addr/load_size for transfer buffer
> - Allow vendor strings to be optional
> - Set vendor/product ID from config defines
> - Allow Ctrl-C to exit fastboot mode
> 
> Signed-off-by: Sebastian Andrzej Siewior 
> Signed-off-by: Rob Herring 

I suspect Lukasz or Marek will have more in depth comments next week,
but please use puts rather than printf when we don't have format chars
in the string.  Things look generally speaking reasonable however.

-- 
Tom


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


Re: [U-Boot] [PATCH v3 4/5] usb/gadget: add the fastboot gadget

2014-04-11 Thread Rob Herring
On Fri, Apr 11, 2014 at 2:14 AM, Bo Shen  wrote:
> Hi Rob Herring,
>   I am just do a function testing on Atmel sama5d3xek board. And a small
> comment as following.
>
>   Btw, do you test to transfer big size file. I try a file bigger than
> 100MiB, it will hang. However use DFU or RNDIS don't meet this issue.

How much RAM do you have? It will happily download into the end of RAM
overwriting u-boot if loadsize is not set. DFU at least has its own
buffer size configuration.

>
>
> On 04/11/2014 03:18 AM, Rob Herring wrote:
>>
>> +static void fastboot_unbind(struct usb_gadget *gadget)
>> +{
>> +   usb_ep_free_request(gadget->ep0, ep0_req);
>> +   ep_in->driver_data = NULL;
>> +   ep_out->driver_data = NULL;
>> +
>> +   gadget_is_connected = 0;
>> +   usb_gadget_disconnect(gadget);
>> +}
>
>
> [snip]
>
>
>> +static void fastboot_disconnect(struct usb_gadget *gadget)
>> +{
>> +   fastboot_disable_ep(gadget);
>> +   gadget_is_connected = 0;
>
>
> Do this only in unbind, as unbind is really disconnect.

So, what should disconnect function do?

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


Re: [U-Boot] [PATCH v3 4/5] usb/gadget: add the fastboot gadget

2014-04-11 Thread Bo Shen

Hi Rob Herring,
  I am just do a function testing on Atmel sama5d3xek board. And a 
small comment as following.


  Btw, do you test to transfer big size file. I try a file bigger than 
100MiB, it will hang. However use DFU or RNDIS don't meet this issue.


On 04/11/2014 03:18 AM, Rob Herring wrote:

+static void fastboot_unbind(struct usb_gadget *gadget)
+{
+   usb_ep_free_request(gadget->ep0, ep0_req);
+   ep_in->driver_data = NULL;
+   ep_out->driver_data = NULL;
+
+   gadget_is_connected = 0;
+   usb_gadget_disconnect(gadget);
+}


[snip]


+static void fastboot_disconnect(struct usb_gadget *gadget)
+{
+   fastboot_disable_ep(gadget);
+   gadget_is_connected = 0;


Do this only in unbind, as unbind is really disconnect.


+}
+
+struct usb_gadget_driver fast_gadget = {
+   .speed  = USB_SPEED_HIGH,
+   .bind   = fastboot_bind,
+   .unbind = fastboot_unbind,
+   .setup  = fastboot_setup,
+   .disconnect = fastboot_disconnect,
+};


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


Re: [U-Boot] [PATCH v3 4/5] usb/gadget: add the fastboot gadget

2014-04-11 Thread Lukasz Majewski
Hi Rob,

Thanks for the patch. I've just glimpsed to them. I will provide a
thorough review in a near future (next week probably).

> This patch contains an implementation of the fastboot protocol on the
> device side and a little of documentation.
> The gadget expects the new-style gadget framework.

What do you mean by that? To which version of gadget framework from
linux does it correspond? The u-boot's gadget infrastructure, used by
UMS, DFU and THOR gadgets [*], is based on linux 2.6.36.

> The gadget implements the getvar, reboot, download and reboot
> commands. What is missing is the flash handling i.e. writting the
> image to media.

For the three above gadgets [*] one "flashing" backend is used. It is
done by dfu_write() function defined at ./drivers/dfu/dfu.c.

Additionally some common gadget handling code is already in the u-boot
tree. It is called g_dnl.c at drivers/usb/gadget, and is used by [*]
gadgets. Maybe fastboot gadget could reuse its code?

-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 4/5] usb/gadget: add the fastboot gadget

2014-04-10 Thread Rob Herring
From: Sebastian Siewior 

This patch contains an implementation of the fastboot protocol on the
device side and a little of documentation.
The gadget expects the new-style gadget framework.
The gadget implements the getvar, reboot, download and reboot commands.
What is missing is the flash handling i.e. writting the image to media.

v3 (Rob Herring):
This is based on http://patchwork.ozlabs.org/patch/126798/ with the
following changes:
- Rebase to current mainline and updates for current gadget API
- Use SPDX identifiers for licenses
- Traced the history and added missing copyright to cmd_fastboot.c
- Use load_addr/load_size for transfer buffer
- Allow vendor strings to be optional
- Set vendor/product ID from config defines
- Allow Ctrl-C to exit fastboot mode

Signed-off-by: Sebastian Andrzej Siewior 
Signed-off-by: Rob Herring 
---
 common/Makefile  |   2 +
 common/cmd_fastboot.c|  36 +++
 doc/README.android-fastboot  |  86 ++
 doc/README.android-fastboot-protocol | 170 +++
 drivers/usb/gadget/Makefile  |   1 +
 drivers/usb/gadget/f_fastboot.c  | 535 +++
 drivers/usb/gadget/g_fastboot.h  |  15 +
 drivers/usb/gadget/u_fastboot.c  | 260 +
 include/usb/fastboot.h   |  36 +++
 9 files changed, 1141 insertions(+)
 create mode 100644 common/cmd_fastboot.c
 create mode 100644 doc/README.android-fastboot
 create mode 100644 doc/README.android-fastboot-protocol
 create mode 100644 drivers/usb/gadget/f_fastboot.c
 create mode 100644 drivers/usb/gadget/g_fastboot.h
 create mode 100644 drivers/usb/gadget/u_fastboot.c
 create mode 100644 include/usb/fastboot.h

diff --git a/common/Makefile b/common/Makefile
index da208f3..fe1d8b9 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -167,6 +167,8 @@ obj-y += cmd_usb.o
 obj-y += usb.o usb_hub.o
 obj-$(CONFIG_USB_STORAGE) += usb_storage.o
 endif
+obj-$(CONFIG_CMD_FASTBOOT) += cmd_fastboot.o
+
 obj-$(CONFIG_CMD_USB_MASS_STORAGE) += cmd_usb_mass_storage.o
 obj-$(CONFIG_CMD_THOR_DOWNLOAD) += cmd_thordown.o
 obj-$(CONFIG_CMD_XIMG) += cmd_ximg.o
diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c
new file mode 100644
index 000..fc8d9e0
--- /dev/null
+++ b/common/cmd_fastboot.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 - 2009 Windriver, 
+ * Author: Tom Rix 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+#include 
+#include 
+#include 
+
+static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const 
argv[])
+{
+   int ret = 1;
+
+   if (!fastboot_init()) {
+   printf("Fastboot entered...\n");
+
+   ret = 0;
+
+   while (1) {
+   if (fastboot_poll())
+   break;
+   if (ctrlc())
+   break;
+   }
+   }
+
+   fastboot_shutdown();
+   return ret;
+}
+
+U_BOOT_CMD(
+   fastboot,   1,  1,  do_fastboot,
+   "fastboot - enter USB Fastboot protocol",
+   ""
+);
diff --git a/doc/README.android-fastboot b/doc/README.android-fastboot
new file mode 100644
index 000..4b2a9aa
--- /dev/null
+++ b/doc/README.android-fastboot
@@ -0,0 +1,86 @@
+Android Fastboot
+
+
+Overview
+
+The protocol that is used over USB is described in
+README.android-fastboot-protocol in same folder.
+
+The current implementation does not yet support the flash and erase
+commands.
+
+Client installation
+===
+The counterpart to this gadget is the fastboot client which can
+be found in Android's platform/system/core repository in the fastboot
+folder. It runs on Windows, Linux and even OSx. Linux user are lucky since
+they only need libusb.
+Windows users need to bring some time until they have Android SDK (currently
+http://dl.google.com/android/installer_r12-windows.exe) installed. You
+need to install ADB package which contains the required glue libraries for
+accessing USB. Also you need "Google USB driver package" and "SDK platform
+tools". Once installed the usb driver is placed in your SDK folder under
+extras\google\usb_driver. The android_winusb.inf needs a line like
+
+   %SingleBootLoaderInterface% = USB_Install, USB\VID_0451&PID_D022
+
+either in the [Google.NTx86] section for 32bit Windows or [Google.NTamd64]
+for 64bit Windows. VID and PID should match whatever the fastboot is
+advertising.
+
+Board specific
+==
+The gadget calls at probe time the function fastboot_board_init() which
+should be provided by the board to setup its specific configuration.
+It is possible here to overwrite specific strings like Vendor or Serial
+number. Strings which are not specified here will return a default value.
+This init function must also provide a memory area for the
+"transfer_buffer" and its size. This buffer should be large enough to hold
+whatever the download commands is willing to send or it will fail. This
+can