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.
Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
---
common/Makefile |2 +
common/cmd_fastboot.c| 28 ++
doc/README.android-fastboot | 86 ++
doc/README.android-fastboot-protocol | 170 ++
drivers/usb/gadget/Makefile |5 +
drivers/usb/gadget/f_fastboot.c | 559 ++
drivers/usb/gadget/g_fastboot.h | 20 ++
drivers/usb/gadget/u_fastboot.c | 308 +++
include/usb/fastboot.h | 100 ++
9 files changed, 1278 insertions(+), 0 deletions(-)
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 1b672ad..9d6659e 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -162,6 +162,8 @@ COBJS-y += cmd_usb.o
COBJS-y += usb.o
COBJS-$(CONFIG_USB_STORAGE) += usb_storage.o
endif
+COBJS-$(CONFIG_CMD_FASTBOOT) += cmd_fastboot.o
+
COBJS-$(CONFIG_CMD_XIMG) += cmd_ximg.o
COBJS-$(CONFIG_YAFFS2) += cmd_yaffs2.o
diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c
new file mode 100644
index 000..9a656dd
--- /dev/null
+++ b/common/cmd_fastboot.c
@@ -0,0 +1,28 @@
+#include common.h
+#include command.h
+#include usb/fastboot.h
+
+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;
+ }
+ }
+
+ fastboot_shutdown();
+ return ret;
+}
+
+U_BOOT_CMD(
+ fastboot, 1, 1, do_fastboot,
+ fastboot- use USB Fastboot protocol\n,
+
+);
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_0451PID_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 be a kernel image for booting which could be around two MiB or a flash
+partition which could be slightly larger :)
+
+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. On the client side you can
+fetch the product name for instance:
+|fastboot getvar product
+|product: Default Product
+|finished. total time: 0.016s
+
+or initiate a reboot:
+|fastboot reboot
+
+and once the client comes back, the board should reset.
+
+You can also specify a kernel image to boot. You have to either specify
+the an image in Android format _or_ pass a binary kernel and