All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] Fastboot gadget, v2. repost
@ 2011-11-21 14:09 Sebastian Andrzej Siewior
  2011-11-21 14:09 ` [U-Boot] [PATCH 1/2] image: add support for Android's boot image format Sebastian Andrzej Siewior
  2011-11-21 14:09 ` [U-Boot] [PATCH 2/2] usb/gadget: add the fastboot gadget Sebastian Andrzej Siewior
  0 siblings, 2 replies; 17+ messages in thread
From: Sebastian Andrzej Siewior @ 2011-11-21 14:09 UTC (permalink / raw)
  To: u-boot

This is a repost of 19.10.2011. This series contains a small version of 
the fastboot gadget. I removed the flash/mmc/write to media part and
re-add once I'm through with this basic thing :)
This "basic" gadget supports the retrieval of variables (like serial
number), reboot functionality, download of binary data and booting them in
case the binary data is a bootable image.
I did not include the fastboot client in this series. Remy asked about
this. I could take it and stash it in tools if someone really wants this
to have. This would include the fastboot and libzipfile folder from
Andorid's system/core repository. An online version can be found at [0]. I
haven't seen the library somewhere else than Android. For basic testing,
the library could be excluded.

v1..v2:
  fixed all issues that came up so far, including:
  - s/andoir_img_get_kload/android_img_get_kload/ spotted by Mike
  - adjusted Copyright message to GPLv2 or later for f_fastboot.c and
    removed "change" comments.
  - removed two header files in example patch 3/3
  I believe that the "All rights reserved" problem got resolved.

[0] http://www.netmite.com/android/mydroid/system/core/


Sebastian

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 1/2] image: add support for Android's boot image format
  2011-11-21 14:09 [U-Boot] Fastboot gadget, v2. repost Sebastian Andrzej Siewior
@ 2011-11-21 14:09 ` Sebastian Andrzej Siewior
  2011-11-21 20:19   ` Wolfgang Denk
  2011-11-21 14:09 ` [U-Boot] [PATCH 2/2] usb/gadget: add the fastboot gadget Sebastian Andrzej Siewior
  1 sibling, 1 reply; 17+ messages in thread
From: Sebastian Andrzej Siewior @ 2011-11-21 14:09 UTC (permalink / raw)
  To: u-boot

This patch adds support for the Android boot-image format. The header
file is from the Android project and got slightly alterted so the struct +
its defines are not generic but have something like a namespace. The
header file is from bootloader/legacy/include/boot/bootimg.h. The header
parsing has been written from scratch and I looked at
bootloader/legacy/usbloader/usbloader.c for some details.
The image contains the physical address (load address) of the kernel and
ramdisk. This address is considered only for the kernel image.
The "second image" is currently ignored. I haven't found anything that
is creating this.

Cc: Wolfgang Denk <wd@denx.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 common/cmd_bootm.c      |   87 +++++++++++++++++++++++++++++++++++++++++++++-
 common/image.c          |   17 +++++++++
 include/android_image.h |   89 +++++++++++++++++++++++++++++++++++++++++++++++
 include/image.h         |    4 ++
 4 files changed, 196 insertions(+), 1 deletions(-)
 create mode 100644 include/android_image.h

diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index d301332..3a4efe4 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -36,6 +36,7 @@
 #include <lmb.h>
 #include <linux/ctype.h>
 #include <asm/byteorder.h>
+#include <android_image.h>
 
 #if defined(CONFIG_CMD_USB)
 #include <usb.h>
@@ -188,10 +189,33 @@ static void bootm_start_lmb(void)
 #endif
 }
 
+#ifdef CONFIG_ANDROID_BOOT_IMAGE
+static u32 android_img_get_end(struct andr_img_hdr *hdr)
+{
+	u32 size = 0;
+	/*
+	 * The header takes a full page, the remaining components are aligned
+	 * on page boundary
+	 */
+	size += hdr->page_size;
+	size += ALIGN(hdr->kernel_size, hdr->page_size);
+	size += ALIGN(hdr->ramdisk_size, hdr->page_size);
+	size += ALIGN(hdr->second_size, hdr->page_size);
+
+	return size;
+}
+
+static u32 android_img_get_kload(struct andr_img_hdr *hdr)
+{
+	return hdr->kernel_addr;
+}
+#endif
+
 static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	void		*os_hdr;
 	int		ret;
+	int		img_type;
 
 	memset((void *)&images, 0, sizeof(images));
 	images.verify = getenv_yesno("verify");
@@ -207,7 +231,8 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
 	}
 
 	/* get image parameters */
-	switch (genimg_get_format(os_hdr)) {
+	img_type = genimg_get_format(os_hdr);
+	switch (img_type) {
 	case IMAGE_FORMAT_LEGACY:
 		images.os.type = image_get_type(os_hdr);
 		images.os.comp = image_get_comp(os_hdr);
@@ -249,6 +274,16 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
 		}
 		break;
 #endif
+#ifdef CONFIG_ANDROID_BOOT_IMAGE
+	case IMAGE_FORMAT_ANDROID:
+		images.os.type = IH_TYPE_KERNEL;
+		images.os.comp = IH_COMP_NONE;
+		images.os.os = IH_OS_LINUX;
+
+		images.os.end = android_img_get_end(os_hdr);
+		images.os.load = android_img_get_kload(os_hdr);
+		break;
+#endif
 	default:
 		puts("ERROR: unknown image format type!\n");
 		return 1;
@@ -266,6 +301,10 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
 			return 1;
 		}
 #endif
+#ifdef CONFIG_ANDROID_BOOT_IMAGE
+	} else if (img_type == IMAGE_FORMAT_ANDROID) {
+		images.ep = images.os.load;
+#endif
 	} else {
 		puts("Could not find kernel entry point!\n");
 		return 1;
@@ -806,6 +845,36 @@ static int fit_check_kernel(const void *fit, int os_noffset, int verify)
 }
 #endif /* CONFIG_FIT */
 
+#ifdef CONFIG_ANDROID_BOOT_IMAGE
+static char andr_tmp_str[ANDR_BOOT_ARGS_SIZE + 1];
+static int android_image_get_kernel(struct andr_img_hdr *hdr, int verify)
+{
+	/*
+	 * Not all Android tools use the id field for signing the image with
+	 * sha1 (or anything) so we don't check it. It is not obvious that the
+	 * string is null terminated so we take care of this.
+	 */
+	strncpy(andr_tmp_str, hdr->name, ANDR_BOOT_NAME_SIZE);
+	andr_tmp_str[ANDR_BOOT_NAME_SIZE] = '\0';
+	if (strlen(andr_tmp_str))
+		printf("Android's image name: %s\n", andr_tmp_str);
+
+	printf("Kernel load addr 0x%08x size %u KiB\n",
+			hdr->kernel_addr, DIV_ROUND_UP(hdr->kernel_size, 1024));
+	strncpy(andr_tmp_str, hdr->cmdline, ANDR_BOOT_ARGS_SIZE);
+	andr_tmp_str[ANDR_BOOT_ARGS_SIZE] = '\0';
+	if (strlen(andr_tmp_str)) {
+		printf("Kernel command line: %s\n", andr_tmp_str);
+		setenv("bootargs", andr_tmp_str);
+	}
+	if (hdr->ramdisk_size)
+		printf("RAM disk load addr 0x%08x size %u KiB\n",
+				hdr->ramdisk_addr,
+				DIV_ROUND_UP(hdr->ramdisk_size, 1024));
+	return 0;
+}
+#endif
+
 /**
  * boot_get_kernel - find kernel image
  * @os_data: pointer to a ulong variable, will hold os data start address
@@ -833,6 +902,9 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
 	int		cfg_noffset;
 	int		os_noffset;
 #endif
+#ifdef CONFIG_ANDROID_BOOT_IMAGE
+	struct andr_img_hdr *ahdr;
+#endif
 
 	/* find out kernel image address */
 	if (argc < 2) {
@@ -976,6 +1048,19 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
 		images->fit_noffset_os = os_noffset;
 		break;
 #endif
+#ifdef CONFIG_ANDROID_BOOT_IMAGE
+	case IMAGE_FORMAT_ANDROID:
+		printf("## Booting Android Image at 0x%08lx ...\n", img_addr);
+		ahdr = (void *)img_addr;
+		if (android_image_get_kernel(ahdr, images->verify))
+			return NULL;
+
+		*os_data = img_addr;
+		*os_data += ahdr->page_size;
+		*os_len = ahdr->kernel_size;
+		images->ahdr = ahdr;
+		break;
+#endif
 	default:
 		printf("Wrong Image Format for %s command\n", cmdtp->name);
 		show_boot_progress(-108);
diff --git a/common/image.c b/common/image.c
index 555d9d9..0eba19a 100644
--- a/common/image.c
+++ b/common/image.c
@@ -26,6 +26,7 @@
 #ifndef USE_HOSTCC
 #include <common.h>
 #include <watchdog.h>
+#include <android_image.h>
 
 #ifdef CONFIG_SHOW_BOOT_PROGRESS
 #include <status_led.h>
@@ -672,7 +673,14 @@ int genimg_get_format(void *img_addr)
 			format = IMAGE_FORMAT_FIT;
 	}
 #endif
+#ifdef CONFIG_ANDROID_BOOT_IMAGE
+	if (format == IMAGE_FORMAT_INVALID) {
+		const struct andr_img_hdr *ahdr = img_addr;
 
+		if (!memcmp(ANDR_BOOT_MAGIC, ahdr->magic, ANDR_BOOT_MAGIC_SIZE))
+			format = IMAGE_FORMAT_ANDROID;
+	}
+#endif
 	return format;
 }
 
@@ -1006,6 +1014,15 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
 				(ulong)images->legacy_hdr_os);
 
 		image_multi_getimg(images->legacy_hdr_os, 1, &rd_data, &rd_len);
+#ifdef CONFIG_ANDROID_BOOT_IMAGE
+		if (images->ahdr && images->ahdr->ramdisk_size) {
+			rd_data = (unsigned long) images->ahdr;
+			rd_data += images->ahdr->page_size;
+			rd_data += ALIGN(images->ahdr->kernel_size,
+					images->ahdr->page_size);
+			rd_len = images->ahdr->ramdisk_size;
+		}
+#endif
 	} else {
 		/*
 		 * no initrd image
diff --git a/include/android_image.h b/include/android_image.h
new file mode 100644
index 0000000..b231b66
--- /dev/null
+++ b/include/android_image.h
@@ -0,0 +1,89 @@
+/*
+ * This is from the Android Project,
+ * bootloader/legacy/include/boot/bootimg.h
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ANDROID_IMAGE_H_
+#define _ANDROID_IMAGE_H_
+
+#define ANDR_BOOT_MAGIC "ANDROID!"
+#define ANDR_BOOT_MAGIC_SIZE 8
+#define ANDR_BOOT_NAME_SIZE 16
+#define ANDR_BOOT_ARGS_SIZE 512
+
+struct andr_img_hdr {
+	u8 magic[ANDR_BOOT_MAGIC_SIZE];
+
+	u32 kernel_size;	/* size in bytes */
+	u32 kernel_addr;	/* physical load addr */
+
+	u32 ramdisk_size;	/* size in bytes */
+	u32 ramdisk_addr;	/* physical load addr */
+
+	u32 second_size;	/* size in bytes */
+	u32 second_addr;	/* physical load addr */
+
+	u32 tags_addr;		/* physical addr for kernel tags */
+	u32 page_size;		/* flash page size we assume */
+	u32 unused[2];		/* future expansion: should be 0 */
+
+	u8 name[ANDR_BOOT_NAME_SIZE]; /* asciiz product name */
+
+	u8 cmdline[ANDR_BOOT_ARGS_SIZE];
+
+	u32 id[8]; /* timestamp / checksum / sha1 / etc */
+};
+
+/*
+ * +-----------------+
+ * | boot header     | 1 page
+ * +-----------------+
+ * | kernel          | n pages
+ * +-----------------+
+ * | ramdisk         | m pages
+ * +-----------------+
+ * | second stage    | o pages
+ * +-----------------+
+ *
+ * n = (kernel_size + page_size - 1) / page_size
+ * m = (ramdisk_size + page_size - 1) / page_size
+ * o = (second_size + page_size - 1) / page_size
+ *
+ * 0. all entities are page_size aligned in flash
+ * 1. kernel and ramdisk are required (size != 0)
+ * 2. second is optional (second_size == 0 -> no second)
+ * 3. load each element (kernel, ramdisk, second) at
+ *    the specified physical address (kernel_addr, etc)
+ * 4. prepare tags at tag_addr.  kernel_args[] is
+ *    appended to the kernel commandline in the tags.
+ * 5. r0 = 0, r1 = MACHINE_TYPE, r2 = tags_addr
+ * 6. if second_size != 0: jump to second_addr
+ *    else: jump to kernel_addr
+ */
+#endif
diff --git a/include/image.h b/include/image.h
index c56a18d..b2b580c 100644
--- a/include/image.h
+++ b/include/image.h
@@ -264,6 +264,9 @@ typedef struct bootm_headers {
 #ifdef CONFIG_LMB
 	struct lmb	lmb;		/* for memory mgmt */
 #endif
+#ifdef CONFIG_ANDROID_BOOT_IMAGE
+	struct andr_img_hdr	*ahdr;
+#endif
 } bootm_headers_t;
 
 /*
@@ -329,6 +332,7 @@ void genimg_print_size(uint32_t size);
 #define IMAGE_FORMAT_INVALID	0x00
 #define IMAGE_FORMAT_LEGACY	0x01	/* legacy image_header based format */
 #define IMAGE_FORMAT_FIT	0x02	/* new, libfdt based format */
+#define IMAGE_FORMAT_ANDROID	0x03	/* Android boot image */
 
 int genimg_get_format(void *img_addr);
 int genimg_has_config(bootm_headers_t *images);
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 2/2] usb/gadget: add the fastboot gadget
  2011-11-21 14:09 [U-Boot] Fastboot gadget, v2. repost Sebastian Andrzej Siewior
  2011-11-21 14:09 ` [U-Boot] [PATCH 1/2] image: add support for Android's boot image format Sebastian Andrzej Siewior
@ 2011-11-21 14:09 ` Sebastian Andrzej Siewior
  2011-11-21 14:48   ` Stefan Schmidt
  2012-01-08  4:56   ` Mike Frysinger
  1 sibling, 2 replies; 17+ messages in thread
From: Sebastian Andrzej Siewior @ 2011-11-21 14:09 UTC (permalink / raw)
  To: u-boot

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 <bigeasy@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 0000000..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 0000000..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 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 let the
+fastboot client wrap the Android suite around it. On OMAP for instance you
+take zImage kernel and pass it to the fastboot client:
+
+|>fastboot -b 0x80000000 -c "console=ttyO2 earlyprintk root=/dev/ram0
+|	mem=128M" boot zImage
+|creating boot image...
+|creating boot image - 1847296 bytes
+|downloading 'boot.img'...
+|OKAY [  2.766s]
+|booting...
+|OKAY [ -0.000s]
+|finished. total time: 2.766s
+
+and on the gadget side you should see:
+|Starting download of 1847296 bytes
+|........................................................
+|downloading of 1847296 bytes finished
+|Booting kernel..
+|## Booting Android Image at 0x81000000 ...
+|Kernel load addr 0x80008000 size 1801 KiB
+|Kernel command line: console=ttyO2 earlyprintk root=/dev/ram0 mem=128M
+|   Loading Kernel Image ... OK
+|OK
+|
+|Starting kernel ...
diff --git a/doc/README.android-fastboot-protocol b/doc/README.android-fastboot-protocol
new file mode 100644
index 0000000..e9e7166
--- /dev/null
+++ b/doc/README.android-fastboot-protocol
@@ -0,0 +1,170 @@
+FastBoot  Version  0.4
+----------------------
+
+The fastboot protocol is a mechanism for communicating with bootloaders
+over USB.  It is designed to be very straightforward to implement, to
+allow it to be used across a wide range of devices and from hosts running
+Linux, Windows, or OSX.
+
+
+Basic Requirements
+------------------
+
+* Two bulk endpoints (in, out) are required
+* Max packet size must be 64 bytes for full-speed and 512 bytes for
+  high-speed USB
+* The protocol is entirely host-driven and synchronous (unlike the
+  multi-channel, bi-directional, asynchronous ADB protocol)
+
+
+Transport and Framing
+---------------------
+
+1. Host sends a command, which is an ascii string in a single
+   packet no greater than 64 bytes.
+
+2. Client response with a single packet no greater than 64 bytes.
+   The first four bytes of the response are "OKAY", "FAIL", "DATA",
+   or "INFO".  Additional bytes may contain an (ascii) informative
+   message.
+
+   a. INFO -> the remaining 60 bytes are an informative message
+      (providing progress or diagnostic messages).  They should
+      be displayed and then step #2 repeats
+
+   b. FAIL -> the requested command failed.  The remaining 60 bytes
+      of the response (if present) provide a textual failure message
+      to present to the user.  Stop.
+
+   c. OKAY -> the requested command completed successfully.  Go to #5
+
+   d. DATA -> the requested command is ready for the data phase.
+      A DATA response packet will be 12 bytes long, in the form of
+      DATA00000000 where the 8 digit hexidecimal number represents
+      the total data size to transfer.
+
+3. Data phase.  Depending on the command, the host or client will
+   send the indicated amount of data.  Short packets are always
+   acceptable and zero-length packets are ignored.  This phase continues
+   until the client has sent or received the number of bytes indicated
+   in the "DATA" response above.
+
+4. Client responds with a single packet no greater than 64 bytes.
+   The first four bytes of the response are "OKAY", "FAIL", or "INFO".
+   Similar to #2:
+
+   a. INFO -> display the remaining 60 bytes and return to #4
+
+   b. FAIL -> display the remaining 60 bytes (if present) as a failure
+      reason and consider the command failed.  Stop.
+
+   c. OKAY -> success.  Go to #5
+
+5. Success.  Stop.
+
+
+Example Session
+---------------
+
+Host:    "getvar:version"        request version variable
+
+Client:  "OKAY0.4"               return version "0.4"
+
+Host:    "getvar:nonexistant"    request some undefined variable
+
+Client:  "OKAY"                  return value ""
+
+Host:    "download:00001234"     request to send 0x1234 bytes of data
+
+Client:  "DATA00001234"          ready to accept data
+
+Host:    < 0x1234 bytes >        send data
+
+Client:  "OKAY"                  success
+
+Host:    "flash:bootloader"      request to flash the data to the bootloader
+
+Client:  "INFOerasing flash"     indicate status / progress
+         "INFOwriting flash"
+         "OKAY"                  indicate success
+
+Host:    "powerdown"             send a command
+
+Client:  "FAILunknown command"   indicate failure
+
+
+Command Reference
+-----------------
+
+* Command parameters are indicated by printf-style escape sequences.
+
+* Commands are ascii strings and sent without the quotes (which are
+  for illustration only here) and without a trailing 0 byte.
+
+* Commands that begin with a lowercase letter are reserved for this
+  specification.  OEM-specific commands should not begin with a
+  lowercase letter, to prevent incompatibilities with future specs.
+
+ "getvar:%s"           Read a config/version variable from the bootloader.
+                       The variable contents will be returned after the
+                       OKAY response.
+
+ "download:%08x"       Write data to memory which will be later used
+                       by "boot", "ramdisk", "flash", etc.  The client
+                       will reply with "DATA%08x" if it has enough
+                       space in RAM or "FAIL" if not.  The size of
+                       the download is remembered.
+
+  "verify:%08x"        Send a digital signature to verify the downloaded
+                       data.  Required if the bootloader is "secure"
+                       otherwise "flash" and "boot" will be ignored.
+
+  "flash:%s"           Write the previously downloaded image to the
+                       named partition (if possible).
+
+  "erase:%s"           Erase the indicated partition (clear to 0xFFs)
+
+  "boot"               The previously downloaded data is a boot.img
+                       and should be booted according to the normal
+                       procedure for a boot.img
+
+  "continue"           Continue booting as normal (if possible)
+
+  "reboot"             Reboot the device.
+
+  "reboot-bootloader"  Reboot back into the bootloader.
+                       Useful for upgrade processes that require upgrading
+                       the bootloader and then upgrading other partitions
+                       using the new bootloader.
+
+  "powerdown"          Power off the device.
+
+
+
+Client Variables
+----------------
+
+The "getvar:%s" command is used to read client variables which
+represent various information about the device and the software
+on it.
+
+The various currently defined names are:
+
+  version             Version of FastBoot protocol supported.
+                      It should be "0.3" for this document.
+
+  version-bootloader  Version string for the Bootloader.
+
+  version-baseband    Version string of the Baseband Software
+
+  product             Name of the product
+
+  serialno            Product serial number
+
+  secure              If the value is "yes", this is a secure
+                      bootloader requiring a signature before
+                      it will install or boot images.
+
+Names starting with a lowercase character are reserved by this
+specification.  OEM-specific names should not start with lowercase
+characters.
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 7d5b504..75d4a12 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -42,6 +42,11 @@ COBJS-$(CONFIG_SPEARUDC) += spr_udc.o
 endif
 endif
 
+ifdef CONFIG_CMD_FASTBOOT
+COBJS-y += f_fastboot.o u_fastboot.o
+COBJS-y += epautoconf.o usbstring.o
+endif
+
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
new file mode 100644
index 0000000..7570440
--- /dev/null
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -0,0 +1,559 @@
+/*
+ * (C) Copyright 2008 - 2009
+ * Windriver, <www.windriver.com>
+ * Tom Rix <Tom.Rix@windriver.com>
+ *
+ * Copyright (c) 2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+#include <common.h>
+#include <errno.h>
+#include <usb/fastboot.h>
+#include <linux/usb/ch9.h>
+#include <linux/usb/gadget.h>
+#include <linux/compiler.h>
+
+#include "g_fastboot.h"
+
+#define CONFIGURATION_NORMAL      1
+#define BULK_ENDPOINT 1
+#define RX_ENDPOINT_MAXIMUM_PACKET_SIZE_2_0  (0x0200)
+#define RX_ENDPOINT_MAXIMUM_PACKET_SIZE_1_1  (0x0040)
+#define TX_ENDPOINT_MAXIMUM_PACKET_SIZE      (0x0040)
+
+static struct usb_string def_usb_fb_strings[] = {
+	{ FB_STR_PRODUCT_IDX,		"Default Product" },
+	{ FB_STR_SERIAL_IDX,		"1234567890" },
+	{ FB_STR_CONFIG_IDX,		"Android Fastboot" },
+	{ FB_STR_INTERFACE_IDX,		"Android Fastboot" },
+	{ FB_STR_MANUFACTURER_IDX,	"Default Manufacturer" },
+	{ FB_STR_PROC_REV_IDX,		"Default 1.0" },
+	{ FB_STR_PROC_TYPE_IDX,		"Emulator" },
+	{  }
+};
+
+static struct usb_gadget_strings def_fb_strings = {
+	.language	= 0x0409, /* en-us */
+	.strings	= def_usb_fb_strings,
+};
+
+static struct usb_gadget_strings *vendor_fb_strings;
+
+static unsigned int gadget_is_connected;
+
+static u8 ep0_buffer[512];
+static u8 ep_out_buffer[EP_BUFFER_SIZE];
+static u8 ep_in_buffer[EP_BUFFER_SIZE];
+static int current_config;
+
+/* e1 */
+static struct usb_endpoint_descriptor fs_ep_in = {
+	.bLength            = USB_DT_ENDPOINT_SIZE,
+	.bDescriptorType    = USB_DT_ENDPOINT,
+	.bEndpointAddress   = USB_DIR_IN, /* IN */
+	.bmAttributes       = USB_ENDPOINT_XFER_BULK,
+	.wMaxPacketSize     = TX_ENDPOINT_MAXIMUM_PACKET_SIZE,
+	.bInterval          = 0x00,
+};
+
+/* e2 */
+static struct usb_endpoint_descriptor fs_ep_out = {
+	.bLength		= USB_DT_ENDPOINT_SIZE,
+	.bDescriptorType	= USB_DT_ENDPOINT,
+	.bEndpointAddress	= USB_DIR_OUT, /* OUT */
+	.bmAttributes		= USB_ENDPOINT_XFER_BULK,
+	.wMaxPacketSize		= RX_ENDPOINT_MAXIMUM_PACKET_SIZE_1_1,
+	.bInterval		= 0x00,
+};
+
+static struct usb_endpoint_descriptor hs_ep_out = {
+	.bLength		= USB_DT_ENDPOINT_SIZE,
+	.bDescriptorType	= USB_DT_ENDPOINT,
+	.bEndpointAddress	= USB_DIR_OUT, /* OUT */
+	.bmAttributes		= USB_ENDPOINT_XFER_BULK,
+	.wMaxPacketSize		= RX_ENDPOINT_MAXIMUM_PACKET_SIZE_2_0,
+	.bInterval		= 0x00,
+};
+
+const char *fb_find_usb_string(unsigned int id)
+{
+	struct usb_string *s;
+
+	for (s = vendor_fb_strings->strings; s && s->s; s++) {
+		if (s->id == id)
+			break;
+	}
+	if (!s || !s->s) {
+		for (s = def_fb_strings.strings; s && s->s; s++) {
+			if (s->id == id)
+				break;
+		}
+	}
+	if (!s)
+		return NULL;
+	return s->s;
+}
+
+static struct usb_gadget *g;
+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;
+
+static void fastboot_ep0_complete(struct usb_ep *ep, struct usb_request *req)
+{
+	int status = req->status;
+
+	if (!status)
+		return;
+	printf("ep0 status %d\n", status);
+}
+
+static int fastboot_bind(struct usb_gadget *gadget)
+{
+
+	g = gadget;
+	ep0_req = usb_ep_alloc_request(g->ep0, 0);
+	if (!ep0_req)
+		goto err;
+	ep0_req->buf = ep0_buffer;
+	ep0_req->complete = fastboot_ep0_complete;
+
+	ep_in = usb_ep_autoconfig(gadget, &fs_ep_in);
+	if (!ep_in)
+		goto err;
+	ep_in->driver_data = ep_in;
+
+	ep_out = usb_ep_autoconfig(gadget, &fs_ep_out);
+	if (!ep_out)
+		goto err;
+	ep_out->driver_data = ep_out;
+
+	hs_ep_out.bEndpointAddress = fs_ep_out.bEndpointAddress;
+	return 0;
+err:
+	return -1;
+}
+
+static void fastboot_unbind(struct usb_gadget *gadget)
+{
+	usb_ep_free_request(g->ep0, ep0_req);
+	ep_in->driver_data = NULL;
+	ep_out->driver_data = NULL;
+}
+
+/* This is the TI USB vendor id a product ID from TI's internal tree */
+#define DEVICE_VENDOR_ID  0x0451
+#define DEVICE_PRODUCT_ID 0xd022
+#define DEVICE_BCD        0x0100
+
+struct usb_device_descriptor fb_descriptor = {
+	.bLength            = sizeof(fb_descriptor),
+	.bDescriptorType    = USB_DT_DEVICE,
+	.bcdUSB             = 0x200,
+	.bMaxPacketSize0    = 0x40,
+	.idVendor           = DEVICE_VENDOR_ID,
+	.idProduct          = DEVICE_PRODUCT_ID,
+	.bcdDevice          = DEVICE_BCD,
+	.iManufacturer      = FB_STR_MANUFACTURER_IDX,
+	.iProduct           = FB_STR_PRODUCT_IDX,
+	.iSerialNumber      = FB_STR_SERIAL_IDX,
+	.bNumConfigurations = 1,
+};
+
+#define TOT_CFG_DESC_LEN	(USB_DT_CONFIG_SIZE + USB_DT_INTERFACE_SIZE + \
+		USB_DT_ENDPOINT_SIZE + USB_DT_ENDPOINT_SIZE)
+
+static struct usb_config_descriptor config_desc = {
+	.bLength		= USB_DT_CONFIG_SIZE,
+	.bDescriptorType	= USB_DT_CONFIG,
+	.wTotalLength		= cpu_to_le16(TOT_CFG_DESC_LEN),
+	.bNumInterfaces		= 1,
+	.bConfigurationValue	= CONFIGURATION_NORMAL,
+	.iConfiguration		= FB_STR_CONFIG_IDX,
+	.bmAttributes		= 0xc0,
+	.bMaxPower		= 0x32,
+};
+
+static struct usb_interface_descriptor interface_desc = {
+	.bLength		= USB_DT_INTERFACE_SIZE,
+	.bDescriptorType	= USB_DT_INTERFACE,
+	.bInterfaceNumber	= 0x00,
+	.bAlternateSetting	= 0x00,
+	.bNumEndpoints		= 0x02,
+	.bInterfaceClass	= FASTBOOT_INTERFACE_CLASS,
+	.bInterfaceSubClass	= FASTBOOT_INTERFACE_SUB_CLASS,
+	.bInterfaceProtocol	= FASTBOOT_INTERFACE_PROTOCOL,
+	.iInterface		= FB_STR_INTERFACE_IDX,
+};
+
+static struct usb_qualifier_descriptor qual_desc = {
+	.bLength		= sizeof(qual_desc),
+	.bDescriptorType	= USB_DT_DEVICE_QUALIFIER,
+	.bcdUSB			= 0x200,
+	.bMaxPacketSize0	= 0x40,
+	.bNumConfigurations	= 1,
+};
+
+static int fastboot_setup_get_descr(struct usb_gadget *gadget,
+		const struct usb_ctrlrequest *ctrl)
+{
+	u16 w_value	= le16_to_cpu(ctrl->wValue);
+	u16 w_length	= le16_to_cpu(ctrl->wLength);
+	u16 val;
+	int ret;
+	u32 bytes_remaining;
+	u32 bytes_total;
+	u32 this_inc;
+
+	val = w_value >> 8;
+
+	switch (val) {
+	case USB_DT_DEVICE:
+
+		memcpy(ep0_buffer, &fb_descriptor, sizeof(fb_descriptor));
+		ep0_req->length = min(w_length, sizeof(fb_descriptor));
+		ret = usb_ep_queue(gadget->ep0, ep0_req, 0);
+		break;
+
+	case USB_DT_CONFIG:
+
+		bytes_remaining = min(w_length, sizeof(ep0_buffer));
+		bytes_total = 0;
+
+		/* config */
+		this_inc = min(bytes_remaining, USB_DT_CONFIG_SIZE);
+		bytes_remaining -= this_inc;
+		memcpy(ep0_buffer + bytes_total, &config_desc, this_inc);
+		bytes_total += this_inc;
+
+		/* interface */
+		this_inc = min(bytes_remaining, USB_DT_INTERFACE_SIZE);
+		bytes_remaining -= this_inc;
+		memcpy(ep0_buffer + bytes_total, &interface_desc, this_inc);
+		bytes_total += this_inc;
+
+		/* ep in */
+		this_inc = min(bytes_remaining, USB_DT_ENDPOINT_SIZE);
+		bytes_remaining -= this_inc;
+		memcpy(ep0_buffer + bytes_total, &fs_ep_in, this_inc);
+		bytes_total += this_inc;
+
+		/* ep out */
+		this_inc = min(bytes_remaining, USB_DT_ENDPOINT_SIZE);
+
+		if (gadget->speed == USB_SPEED_HIGH)
+			memcpy(ep0_buffer + bytes_total, &hs_ep_out,
+					this_inc);
+		else
+			memcpy(ep0_buffer + bytes_total, &fs_ep_out,
+					this_inc);
+		bytes_total += this_inc;
+
+		ep0_req->length = bytes_total;
+		ret = usb_ep_queue(gadget->ep0, ep0_req, 0);
+		break;
+
+	case USB_DT_STRING:
+
+		ret = usb_gadget_get_string(vendor_fb_strings,
+				w_value & 0xff, ep0_buffer);
+		if (ret < 0)
+			ret = usb_gadget_get_string(&def_fb_strings,
+					w_value & 0xff, ep0_buffer);
+		if (ret < 0)
+			break;
+
+		ep0_req->length = ret;
+		ret = usb_ep_queue(gadget->ep0, ep0_req, 0);
+		break;
+
+	case USB_DT_DEVICE_QUALIFIER:
+
+		memcpy(ep0_buffer, &qual_desc, sizeof(qual_desc));
+		ep0_req->length = min(w_length, sizeof(qual_desc));
+		ret = usb_ep_queue(gadget->ep0, ep0_req, 0);
+		 break;
+	default:
+		ret = -EINVAL;
+	}
+	return ret;
+}
+
+static int fastboot_setup_get_conf(struct usb_gadget *gadget,
+		const struct usb_ctrlrequest *ctrl)
+{
+	u16 w_length	= le16_to_cpu(ctrl->wLength);
+
+	if (w_length == 0)
+		return -1;
+
+	ep0_buffer[0] = current_config;
+	ep0_req->length = 1;
+	return usb_ep_queue(gadget->ep0, ep0_req, 0);
+}
+
+static void fastboot_complete_in(struct usb_ep *ep, struct usb_request *req)
+{
+	int status = req->status;
+
+	if (status)
+		printf("status: %d ep_in trans: %d\n",
+				status,
+				req->actual);
+}
+
+static int fastboot_disable_ep(struct usb_gadget *gadget)
+{
+	if (req_out) {
+		usb_ep_free_request(ep_out, req_out);
+		req_out = NULL;
+	}
+	if (req_in) {
+		usb_ep_free_request(ep_in, req_in);
+		req_in = NULL;
+	}
+	usb_ep_disable(ep_out);
+	usb_ep_disable(ep_in);
+
+	return 0;
+}
+
+static int fastboot_enable_ep(struct usb_gadget *gadget)
+{
+	int ret;
+
+	/* make sure we don't enable the ep twice */
+	if (gadget->speed == USB_SPEED_HIGH)
+		ret = usb_ep_enable(ep_out, &hs_ep_out);
+	else
+		ret = usb_ep_enable(ep_out, &fs_ep_out);
+	if (ret) {
+		printf("failed to enable out ep\n");
+		goto err;
+	}
+
+	req_out = usb_ep_alloc_request(ep_out, 0);
+	if (!req_out) {
+		printf("failed to alloc out req\n");
+		goto err;
+	}
+
+	ret = usb_ep_enable(ep_in, &fs_ep_in);
+	if (ret) {
+		printf("failed to enable in ep\n");
+		goto err;
+	}
+	req_in = usb_ep_alloc_request(ep_in, 0);
+	if (!req_in) {
+		printf("failed alloc req in\n");
+		goto err;
+	}
+
+	req_out->complete = rx_handler_command;
+	req_out->buf = ep_out_buffer;
+	req_out->length = sizeof(ep_out_buffer);
+
+	req_in->buf = ep_in_buffer;
+	req_in->length = sizeof(ep_in_buffer);
+
+	ret = usb_ep_queue(ep_out, req_out, 0);
+	if (ret)
+		goto err;
+
+	return 0;
+err:
+	fastboot_disable_ep(gadget);
+	return -1;
+}
+
+static int fastboot_set_interface(struct usb_gadget *gadget, u32 enable)
+{
+	if (enable && req_out)
+		return 0;
+	if (!enable && !req_out)
+		return 0;
+
+	if (enable)
+		return fastboot_enable_ep(gadget);
+	else
+		return fastboot_disable_ep(gadget);
+}
+
+static int fastboot_setup_out_req(struct usb_gadget *gadget,
+		const struct usb_ctrlrequest *req)
+{
+	switch (req->bRequestType & USB_RECIP_MASK) {
+	case USB_RECIP_DEVICE:
+		switch (req->bRequest) {
+		case USB_REQ_SET_CONFIGURATION:
+
+			ep0_req->length = 0;
+			if (req->wValue == CONFIGURATION_NORMAL) {
+				current_config = CONFIGURATION_NORMAL;
+				fastboot_set_interface(gadget, 1);
+				return usb_ep_queue(gadget->ep0,
+						ep0_req, 0);
+			}
+			if (req->wValue == 0) {
+				current_config = 0;
+				fastboot_set_interface(gadget, 0);
+				return usb_ep_queue(gadget->ep0,
+						ep0_req, 0);
+			}
+			return -1;
+			break;
+		default:
+			return -1;
+		};
+
+	case USB_RECIP_INTERFACE:
+		switch (req->bRequest) {
+		case USB_REQ_SET_INTERFACE:
+
+			ep0_req->length = 0;
+			if (!fastboot_set_interface(gadget, 1))
+				return usb_ep_queue(gadget->ep0,
+						ep0_req, 0);
+			return -1;
+			break;
+		default:
+			return -1;
+		}
+
+	case USB_RECIP_ENDPOINT:
+		switch (req->bRequest) {
+		case USB_REQ_CLEAR_FEATURE:
+
+			return usb_ep_queue(gadget->ep0, ep0_req, 0);
+			break;
+		default:
+			return -1;
+		}
+	}
+	return -1;
+}
+
+static int fastboot_setup(struct usb_gadget *gadget,
+		const struct usb_ctrlrequest *req)
+{
+	if ((req->bRequestType & USB_TYPE_MASK) != USB_TYPE_STANDARD)
+		return -1;
+
+	if ((req->bRequestType & USB_DIR_IN) == 0)
+		/* host-to-device */
+		return fastboot_setup_out_req(gadget, req);
+
+	/* device-to-host */
+	if ((req->bRequestType & USB_RECIP_MASK) == USB_RECIP_DEVICE) {
+		switch (req->bRequest) {
+		case USB_REQ_GET_DESCRIPTOR:
+			return fastboot_setup_get_descr(gadget, req);
+			break;
+
+		case USB_REQ_GET_CONFIGURATION:
+			return fastboot_setup_get_conf(gadget, req);
+			break;
+		default:
+			return -1;
+		}
+	}
+	return -1;
+}
+
+static void fastboot_disconnect(struct usb_gadget *gadget)
+{
+	fastboot_disable_ep(gadget);
+	gadget_is_connected = 0;
+}
+
+struct usb_gadget_driver fast_gadget = {
+	.bind		= fastboot_bind,
+	.unbind		= fastboot_unbind,
+	.setup		= fastboot_setup,
+	.disconnect	= fastboot_disconnect,
+};
+
+static int udc_is_probbed;
+
+int fastboot_init(void)
+{
+	int ret;
+
+	ret = fastboot_board_init(&fb_cfg, &vendor_fb_strings);
+	if (ret)
+		return ret;
+	if (!vendor_fb_strings)
+		return -EINVAL;
+
+	ret = usb_gadget_init_udc();
+	if (ret) {
+		printf("gadget probe failed\n");
+		return 1;
+	}
+	udc_is_probbed = 1;
+
+	ret = usb_gadget_register_driver(&fast_gadget);
+	if (ret) {
+		printf("Add gadget failed\n");
+		goto err;
+	}
+
+	gadget_is_connected = 1;
+	usb_gadget_handle_interrupts();
+	return 0;
+
+err:
+	fastboot_shutdown();
+	return 1;
+}
+
+int fastboot_poll(void)
+{
+	usb_gadget_handle_interrupts();
+
+	if (gadget_is_connected)
+		return 0;
+	else
+		return 1;
+}
+
+void fastboot_shutdown(void)
+{
+	if (!udc_is_probbed)
+		return;
+	udc_is_probbed = 0;
+	usb_gadget_exit_udc();
+}
+
+int fastboot_tx_write(const char *buffer, unsigned int buffer_size)
+{
+	int ret;
+
+	if (req_in->complete == NULL)
+		req_in->complete = fastboot_complete_in;
+
+	memcpy(req_in->buf, buffer, buffer_size);
+	req_in->length = buffer_size;
+	ret = usb_ep_queue(ep_in, req_in, 0);
+	if (ret)
+		printf("Error %d on queue\n", ret);
+	return 0;
+}
diff --git a/drivers/usb/gadget/g_fastboot.h b/drivers/usb/gadget/g_fastboot.h
new file mode 100644
index 0000000..ff2621c
--- /dev/null
+++ b/drivers/usb/gadget/g_fastboot.h
@@ -0,0 +1,20 @@
+#ifndef _G_FASTBOOT_H_
+#define _G_FASTBOOT_H_
+
+#define EP_BUFFER_SIZE			4096
+#define FASTBOOT_INTERFACE_CLASS	0xff
+#define FASTBOOT_INTERFACE_SUB_CLASS	0x42
+#define FASTBOOT_INTERFACE_PROTOCOL	0x03
+#define FASTBOOT_VERSION		"0.4"
+
+extern struct fastboot_config fb_cfg;
+extern struct usb_ep *ep_in;
+extern struct usb_request *req_in;
+extern struct usb_ep *ep_out;
+extern struct usb_request *req_out;
+
+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);
+
+#endif
diff --git a/drivers/usb/gadget/u_fastboot.c b/drivers/usb/gadget/u_fastboot.c
new file mode 100644
index 0000000..00762aa
--- /dev/null
+++ b/drivers/usb/gadget/u_fastboot.c
@@ -0,0 +1,308 @@
+/*
+ * (C) Copyright 2008 - 2009
+ * Windriver, <www.windriver.com>
+ * Tom Rix <Tom.Rix@windriver.com>
+ *
+ * Copyright (c) 2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ * Part of the rx_handler were copied from the Android project.
+ * Specifically rx command parsing in the  usb_rx_data_complete
+ * function of the file bootable/bootloader/legacy/usbloader/usbloader.c
+ *
+ * The logical naming of flash comes from the Android project
+ * Thse structures and functions that look like fastboot_flash_*
+ * They come from bootable/bootloader/legacy/libboot/flash.c
+ *
+ * This is their Copyright:
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#include <common.h>
+#include <usb/fastboot.h>
+#include <linux/usb/ch9.h>
+#include <linux/usb/gadget.h>
+#include "g_fastboot.h"
+
+/* The 64 defined bytes plus \0 */
+#define RESPONSE_LEN	(64 + 1)
+
+struct fastboot_config fb_cfg;
+
+static unsigned int download_size;
+static unsigned int download_bytes;
+
+static int fastboot_tx_write_str(const char *buffer)
+{
+	return fastboot_tx_write(buffer, strlen(buffer));
+}
+
+static void compl_do_reset(struct usb_ep *ep, struct usb_request *req)
+{
+	do_reset(NULL, 0, 0, NULL);
+}
+
+static void cb_reboot(struct usb_ep *ep, struct usb_request *req)
+{
+	req_in->complete = compl_do_reset;
+	fastboot_tx_write_str("OKAY");
+}
+
+static int strcmp_l1(const char *s1, const char *s2)
+{
+	return strncmp(s1, s2, strlen(s1));
+}
+
+static void cb_getvar(struct usb_ep *ep, struct usb_request *req)
+{
+	char *cmd = req->buf;
+	char response[RESPONSE_LEN];
+	const char *s;
+
+	strcpy(response, "OKAY");
+	strsep(&cmd, ":");
+	if (!cmd) {
+		fastboot_tx_write_str("FAILmissing var");
+		return;
+	}
+
+	if (!strcmp_l1("version", cmd)) {
+		strncat(response, FASTBOOT_VERSION, sizeof(response));
+
+	} else if (!strcmp_l1("downloadsize", cmd)) {
+		char str_num[12];
+
+		sprintf(str_num, "%08x", fb_cfg.transfer_buffer_size);
+		strncat(response, str_num, sizeof(response));
+
+	} else if (!strcmp_l1("product", cmd)) {
+
+		s = fb_find_usb_string(FB_STR_PRODUCT_IDX);
+		if (s)
+			strncat(response, s, sizeof(response));
+		else
+			strcpy(response, "FAILValue not set");
+
+	} else if (!strcmp_l1("serialno", cmd)) {
+
+		s = fb_find_usb_string(FB_STR_SERIAL_IDX);
+		if (s)
+			strncat(response, s, sizeof(response));
+		else
+			strcpy(response, "FAILValue not set");
+
+	} else if (!strcmp_l1("cpurev", cmd)) {
+
+		s = fb_find_usb_string(FB_STR_PROC_REV_IDX);
+		if (s)
+			strncat(response, s, sizeof(response));
+		else
+			strcpy(response, "FAILValue not set");
+	} else if (!strcmp_l1("secure", cmd)) {
+
+		s = fb_find_usb_string(FB_STR_PROC_TYPE_IDX);
+		if (s)
+			strncat(response, s, sizeof(response));
+		else
+			strcpy(response, "FAILValue not set");
+	} else {
+		strcpy(response, "FAILVariable not implemented");
+	}
+	fastboot_tx_write_str(response);
+}
+
+static unsigned int rx_bytes_expected(void)
+{
+	int rx_remain = download_size - download_bytes;
+	if (rx_remain < 0)
+		return 0;
+	if (rx_remain > EP_BUFFER_SIZE)
+		return EP_BUFFER_SIZE;
+	return rx_remain;
+}
+
+#define BYTES_PER_DOT	32768
+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(fb_cfg.transfer_buffer + 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(".");
+		if (!(download_bytes % (74 * BYTES_PER_DOT)))
+				printf("\n");
+
+	}
+	req->actual = 0;
+	usb_ep_queue(ep, req, 0);
+}
+
+static void cb_download(struct usb_ep *ep, struct usb_request *req)
+{
+	char *cmd = req->buf;
+	char response[RESPONSE_LEN];
+
+	strsep(&cmd, ":");
+	download_size = simple_strtoul(cmd, NULL, 16);
+	download_bytes = 0;
+
+	printf("Starting download of %d bytes\n",
+			download_size);
+
+	if (0 == download_size) {
+		sprintf(response, "FAILdata invalid size");
+	} else if (download_size >
+			fb_cfg.transfer_buffer_size) {
+		download_size = 0;
+		sprintf(response, "FAILdata too large");
+	} else {
+		sprintf(response, "DATA%08x", download_size);
+		req->complete = rx_handler_dl_image;
+		req->length = rx_bytes_expected();
+	}
+	fastboot_tx_write_str(response);
+}
+
+static char boot_addr_start[32];
+static char *bootm_args[] = { "bootm", boot_addr_start, NULL };
+
+static void do_bootm_on_complete(struct usb_ep *ep, struct usb_request *req)
+{
+	req->complete = NULL;
+	fastboot_shutdown();
+	printf("Booting kernel..\n");
+
+	do_bootm(NULL, 0, 2, bootm_args);
+
+	/* This only happens if image is somehow faulty so we start over */
+	do_reset(NULL, 0, 0, NULL);
+}
+
+static void cb_boot(struct usb_ep *ep, struct usb_request *req)
+{
+	sprintf(boot_addr_start, "0x%p", fb_cfg.transfer_buffer);
+
+	req_in->complete = do_bootm_on_complete;
+	fastboot_tx_write_str("OKAY");
+	return;
+}
+
+struct cmd_dispatch_info {
+	char *cmd;
+	void (*cb)(struct usb_ep *ep, struct usb_request *req);
+};
+
+static struct cmd_dispatch_info cmd_dispatch_info[] = {
+	{
+		.cmd = "reboot",
+		.cb = cb_reboot,
+	}, {
+		.cmd = "getvar:",
+		.cb = cb_getvar,
+	}, {
+		.cmd = "download:",
+		.cb = cb_download,
+	}, {
+		.cmd = "boot",
+		.cb = cb_boot,
+	},
+};
+
+void rx_handler_command(struct usb_ep *ep, struct usb_request *req)
+{
+	char response[RESPONSE_LEN];
+	char *cmdbuf = req->buf;
+	void (*func_cb)(struct usb_ep *ep, struct usb_request *req) = NULL;
+	int i;
+
+	sprintf(response, "FAIL");
+
+	for (i = 0; i < ARRAY_SIZE(cmd_dispatch_info); i++) {
+		if (!strcmp_l1(cmd_dispatch_info[i].cmd, cmdbuf)) {
+			func_cb = cmd_dispatch_info[i].cb;
+			break;
+		}
+	}
+
+	if (!func_cb)
+		fastboot_tx_write_str("FAILunknown command");
+	else
+		func_cb(ep, req);
+
+	if (req->status == 0) {
+		*cmdbuf = '\0';
+		req->actual = 0;
+		usb_ep_queue(ep, req, 0);
+	}
+}
diff --git a/include/usb/fastboot.h b/include/usb/fastboot.h
new file mode 100644
index 0000000..e55149a
--- /dev/null
+++ b/include/usb/fastboot.h
@@ -0,0 +1,100 @@
+/*
+ * (C) Copyright 2008 - 2009
+ * Windriver, <www.windriver.com>
+ * Tom Rix <Tom.Rix@windriver.com>
+ *
+ * Copyright (c) 2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ * The logical naming of flash comes from the Android project
+ * Thse structures and functions that look like fastboot_flash_*
+ * They come from bootloader/legacy/include/boot/flash.h
+ *
+ * The boot_img_hdr structure and associated magic numbers also
+ * come from the Android project.  They are from
+ * bootloader/legacy/include/boot/bootimg.h
+ *
+ * Here are their copyrights
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#ifndef FASTBOOT_H
+#define FASTBOOT_H
+
+#include <common.h>
+#include <command.h>
+#include <linux/usb/ch9.h>
+#include <linux/usb/gadget.h>
+#include <android_image.h>
+
+struct fastboot_config {
+
+	/*
+	 * Transfer buffer for storing data sent by the client. It should be
+	 * able to hold a kernel image and flash partitions. Care should be
+	 * take so it does not overrun bootloader memory
+	 */
+	unsigned char *transfer_buffer;
+
+	/* Size of the buffer mentioned above */
+	unsigned int transfer_buffer_size;
+};
+
+#define FB_STR_PRODUCT_IDX      1
+#define FB_STR_SERIAL_IDX       2
+#define FB_STR_CONFIG_IDX       3
+#define FB_STR_INTERFACE_IDX    4
+#define FB_STR_MANUFACTURER_IDX 5
+#define FB_STR_PROC_REV_IDX     6
+#define FB_STR_PROC_TYPE_IDX    7
+
+#if (CONFIG_CMD_FASTBOOT)
+
+int fastboot_init(void);
+void fastboot_shutdown(void);
+int fastboot_poll(void);
+
+int fastboot_board_init(struct fastboot_config *interface,
+		struct usb_gadget_strings **str);
+#endif
+#endif
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 2/2] usb/gadget: add the fastboot gadget
  2011-11-21 14:09 ` [U-Boot] [PATCH 2/2] usb/gadget: add the fastboot gadget Sebastian Andrzej Siewior
@ 2011-11-21 14:48   ` Stefan Schmidt
  2011-11-23 10:27     ` Sebastian Andrzej Siewior
  2012-01-08  4:56   ` Mike Frysinger
  1 sibling, 1 reply; 17+ messages in thread
From: Stefan Schmidt @ 2011-11-21 14:48 UTC (permalink / raw)
  To: u-boot

Hello.

On Mon, 2011-11-21 at 15:09, Sebastian Andrzej Siewior wrote:
> 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.

Which what hardware do you test this? So far I have only seen patches
(not applied yet) for the Samsung UDC controller that are providing
the usb_gadget_register_driver() functions. Consumer is only ether.c
so far.

Any other hardware platforms that support the new style gadget
framework yet? Do'n get me wrong, I like it and would like to see more
drivers moving to it but I wonder what support on a hardware driver
level we have for it yet.

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

You may have seen the DFU patches on this list recently. There is also
a split between the DFU protocol and the flashing backend. Would it
make sense to see if fastboot and DFU could use the same flashing
backend and platform specific bits?

regards
Stefan Schmidt

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 1/2] image: add support for Android's boot image format
  2011-11-21 14:09 ` [U-Boot] [PATCH 1/2] image: add support for Android's boot image format Sebastian Andrzej Siewior
@ 2011-11-21 20:19   ` Wolfgang Denk
  2011-11-22 12:30     ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 17+ messages in thread
From: Wolfgang Denk @ 2011-11-21 20:19 UTC (permalink / raw)
  To: u-boot

Dear Sebastian Andrzej Siewior,

In message <1321884575-2993-2-git-send-email-bigeasy@linutronix.de> you wrote:
> This patch adds support for the Android boot-image format. The header
> file is from the Android project and got slightly alterted so the struct +
> its defines are not generic but have something like a namespace. The
> header file is from bootloader/legacy/include/boot/bootimg.h. The header
> parsing has been written from scratch and I looked at
> bootloader/legacy/usbloader/usbloader.c for some details.
> The image contains the physical address (load address) of the kernel and
> ramdisk. This address is considered only for the kernel image.
> The "second image" is currently ignored. I haven't found anything that
> is creating this.

Please provide _exact_ reference where this code has been copied from,
see bullet 4 etc. at
http://www.denx.de/wiki/view/U-Boot/Patches#Attributing_Code_Copyrights_Sign

Also please provide exact information about the applicable licenses
for this copied code.

...
>  	/* get image parameters */
> -	switch (genimg_get_format(os_hdr)) {
> +	img_type = genimg_get_format(os_hdr);
> +	switch (img_type) {
...
> +#ifdef CONFIG_ANDROID_BOOT_IMAGE
> +	} else if (img_type == IMAGE_FORMAT_ANDROID) {
> +		images.ep = images.os.load;
> +#endif

Why don't you handle the Andoid image case inside the switch() ?

> +#ifdef CONFIG_ANDROID_BOOT_IMAGE
> +static char andr_tmp_str[ANDR_BOOT_ARGS_SIZE + 1];
> +static int android_image_get_kernel(struct andr_img_hdr *hdr, int verify)
> +{
> +	/*
> +	 * Not all Android tools use the id field for signing the image with
> +	 * sha1 (or anything) so we don't check it. It is not obvious that the
> +	 * string is null terminated so we take care of this.
> +	 */
> +	strncpy(andr_tmp_str, hdr->name, ANDR_BOOT_NAME_SIZE);
> +	andr_tmp_str[ANDR_BOOT_NAME_SIZE] = '\0';
> +	if (strlen(andr_tmp_str))
> +		printf("Android's image name: %s\n", andr_tmp_str);
> +
> +	printf("Kernel load addr 0x%08x size %u KiB\n",
> +			hdr->kernel_addr, DIV_ROUND_UP(hdr->kernel_size, 1024));
> +	strncpy(andr_tmp_str, hdr->cmdline, ANDR_BOOT_ARGS_SIZE);
> +	andr_tmp_str[ANDR_BOOT_ARGS_SIZE] = '\0';
> +	if (strlen(andr_tmp_str)) {
> +		printf("Kernel command line: %s\n", andr_tmp_str);
> +		setenv("bootargs", andr_tmp_str);
> +	}
> +	if (hdr->ramdisk_size)
> +		printf("RAM disk load addr 0x%08x size %u KiB\n",
> +				hdr->ramdisk_addr,
> +				DIV_ROUND_UP(hdr->ramdisk_size, 1024));
> +	return 0;
> +}
> +#endif

This and similar Android image related code shoudl eventually go into
a separate file, exposing only a few functions.


> +#ifdef CONFIG_ANDROID_BOOT_IMAGE
> +	if (format == IMAGE_FORMAT_INVALID) {
> +		const struct andr_img_hdr *ahdr = img_addr;
>  
> +		if (!memcmp(ANDR_BOOT_MAGIC, ahdr->magic, ANDR_BOOT_MAGIC_SIZE))
> +			format = IMAGE_FORMAT_ANDROID;
> +	}
> +#endif

This is all we have for testing for a valid image?

> index 0000000..b231b66
> --- /dev/null
> +++ b/include/android_image.h
> @@ -0,0 +1,89 @@
> +/*
> + * This is from the Android Project,
> + * bootloader/legacy/include/boot/bootimg.h
> + *
> + * Copyright (C) 2008 The Android Open Source Project
> + * All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + *  * Redistributions of source code must retain the above copyright
> + *    notice, this list of conditions and the following disclaimer.
> + *  * Redistributions in binary form must reproduce the above copyright
> + *    notice, this list of conditions and the following disclaimer in
> + *    the documentation and/or other materials provided with the
> + *    distribution.

Sorry, but this is not GPL compatible.



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: wd at denx.de
Making files is easy under  the  UNIX  operating  system.  Therefore,
users  tend  to  create  numerous  files  using large amounts of file
space. It has been said that the only standard thing about  all  UNIX
systems  is  the  message-of-the-day  telling users to clean up their
files.                             - System V.2 administrator's guide

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 1/2] image: add support for Android's boot image format
  2011-11-21 20:19   ` Wolfgang Denk
@ 2011-11-22 12:30     ` Sebastian Andrzej Siewior
  2011-11-22 19:04       ` Wolfgang Denk
  0 siblings, 1 reply; 17+ messages in thread
From: Sebastian Andrzej Siewior @ 2011-11-22 12:30 UTC (permalink / raw)
  To: u-boot

* Wolfgang Denk | 2011-11-21 21:19:07 [+0100]:

>Dear Sebastian Andrzej Siewior,
Hi Wolfgang,

>Please provide _exact_ reference where this code has been copied from,
>see bullet 4 etc. at
>http://www.denx.de/wiki/view/U-Boot/Patches#Attributing_Code_Copyrights_Sign
>
>Also please provide exact information about the applicable licenses
>for this copied code.

I added a detailed description to the repository and the commit head
where I took it from.

>...
>>  	/* get image parameters */
>> -	switch (genimg_get_format(os_hdr)) {
>> +	img_type = genimg_get_format(os_hdr);
>> +	switch (img_type) {
>...
>> +#ifdef CONFIG_ANDROID_BOOT_IMAGE
>> +	} else if (img_type == IMAGE_FORMAT_ANDROID) {
>> +		images.ep = images.os.load;
>> +#endif
>
>Why don't you handle the Andoid image case inside the switch() ?

Because the code flow looks like:
|         if (images.legacy_hdr_valid) {
|                 images.ep = image_get_ep(&images.legacy_hdr_os_copy);
| #if defined(CONFIG_FIT)
|         } else if (images.fit_uname_os) {
...
|                 }
| #endif
| #ifdef CONFIG_ANDROID_BOOT_IMAGE
...
| #endif
|         } else {
|                 puts("Could not find kernel entry point!\n");
|                 return 1;
|         }
|

So if I don't add an extra android block here, I end up in this else
part complaining about the entrypoint.
I guess that this part could be merged into the previous switch
statement if you want me to.

>> +#ifdef CONFIG_ANDROID_BOOT_IMAGE
>> +static char andr_tmp_str[ANDR_BOOT_ARGS_SIZE + 1];
>> +static int android_image_get_kernel(struct andr_img_hdr *hdr, int verify)
>> +{
>> +	/*
>> +	 * Not all Android tools use the id field for signing the image with
>> +	 * sha1 (or anything) so we don't check it. It is not obvious that the
>> +	 * string is null terminated so we take care of this.
>> +	 */
>> +	strncpy(andr_tmp_str, hdr->name, ANDR_BOOT_NAME_SIZE);
>> +	andr_tmp_str[ANDR_BOOT_NAME_SIZE] = '\0';
>> +	if (strlen(andr_tmp_str))
>> +		printf("Android's image name: %s\n", andr_tmp_str);
>> +
>> +	printf("Kernel load addr 0x%08x size %u KiB\n",
>> +			hdr->kernel_addr, DIV_ROUND_UP(hdr->kernel_size, 1024));
>> +	strncpy(andr_tmp_str, hdr->cmdline, ANDR_BOOT_ARGS_SIZE);
>> +	andr_tmp_str[ANDR_BOOT_ARGS_SIZE] = '\0';
>> +	if (strlen(andr_tmp_str)) {
>> +		printf("Kernel command line: %s\n", andr_tmp_str);
>> +		setenv("bootargs", andr_tmp_str);
>> +	}
>> +	if (hdr->ramdisk_size)
>> +		printf("RAM disk load addr 0x%08x size %u KiB\n",
>> +				hdr->ramdisk_addr,
>> +				DIV_ROUND_UP(hdr->ramdisk_size, 1024));
>> +	return 0;
>> +}
>> +#endif
>
>This and similar Android image related code shoudl eventually go into
>a separate file, exposing only a few functions.
Okay.

>> +#ifdef CONFIG_ANDROID_BOOT_IMAGE
>> +	if (format == IMAGE_FORMAT_INVALID) {
>> +		const struct andr_img_hdr *ahdr = img_addr;
>>  
>> +		if (!memcmp(ANDR_BOOT_MAGIC, ahdr->magic, ANDR_BOOT_MAGIC_SIZE))
>> +			format = IMAGE_FORMAT_ANDROID;
>> +	}
>> +#endif
>
>This is all we have for testing for a valid image?

More or less, yes. The fastboot client [0] does nothing else if you
provide it a kernel (and it creates the ANDROID image out of it).
The comment field is used by mkbootimg/mkbootimg.c tool to stash a sha1
checksum. The format how to create the sha1 checksum (i.e. pad, don't
pad, include header or not, ...) isn't documented (atleast I did not
find anything) so the only source of documentation is
the source code wich is under Apache2 license which is compatible with
GPLv3 but not with v2 so I can't look at it.

[0] http://android-dls.com/wiki/index.php?title=Fastboot

>> index 0000000..b231b66
>> --- /dev/null
>> +++ b/include/android_image.h
>> @@ -0,0 +1,89 @@
>> +/*
>> + * This is from the Android Project,
>> + * bootloader/legacy/include/boot/bootimg.h
>> + *
>> + * Copyright (C) 2008 The Android Open Source Project
>> + * All rights reserved.
>> + *
>> + * Redistribution and use in source and binary forms, with or without
>> + * modification, are permitted provided that the following conditions
>> + * are met:
>> + *  * Redistributions of source code must retain the above copyright
>> + *    notice, this list of conditions and the following disclaimer.
>> + *  * Redistributions in binary form must reproduce the above copyright
>> + *    notice, this list of conditions and the following disclaimer in
>> + *    the documentation and/or other materials provided with the
>> + *    distribution.
>
>Sorry, but this is not GPL compatible.

Ehm. Is this the All rights reserved issue? If so then I assumed that I
cleared up things in
  http://lists.denx.de/pipermail/u-boot/2011-September/101793.html

>
>Best regards,
>
>Wolfgang Denk

Sebastian

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 1/2] image: add support for Android's boot image format
  2011-11-22 12:30     ` Sebastian Andrzej Siewior
@ 2011-11-22 19:04       ` Wolfgang Denk
  2011-11-23 10:03         ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 17+ messages in thread
From: Wolfgang Denk @ 2011-11-22 19:04 UTC (permalink / raw)
  To: u-boot

Dear Sebastian Andrzej Siewior,

In message <20111122123007.GA5755@linutronix.de> you wrote:
> 
> >> + * Redistribution and use in source and binary forms, with or without
> >> + * modification, are permitted provided that the following conditions
> >> + * are met:
> >> + *  * Redistributions of source code must retain the above copyright
> >> + *    notice, this list of conditions and the following disclaimer.
> >> + *  * Redistributions in binary form must reproduce the above copyright
> >> + *    notice, this list of conditions and the following disclaimer in
> >> + *    the documentation and/or other materials provided with the
> >> + *    distribution.
> >
> >Sorry, but this is not GPL compatible.
> 
> Ehm. Is this the All rights reserved issue? If so then I assumed that I
> cleared up things in

No, it's the "Redistributions in binary form must reproduce..."
clause.

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: wd at denx.de
If I don't document something, it's usually either for a good reason,
or a bad reason.  In this case it's a good reason.  :-)
                 - Larry Wall in <1992Jan17.005405.16806@netlabs.com>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 1/2] image: add support for Android's boot image format
  2011-11-22 19:04       ` Wolfgang Denk
@ 2011-11-23 10:03         ` Sebastian Andrzej Siewior
  2012-01-17  9:16           ` Aneesh V
  2012-03-17 22:04           ` Wolfgang Denk
  0 siblings, 2 replies; 17+ messages in thread
From: Sebastian Andrzej Siewior @ 2011-11-23 10:03 UTC (permalink / raw)
  To: u-boot

* Wolfgang Denk | 2011-11-22 20:04:47 [+0100]:

>Dear Sebastian Andrzej Siewior,
>
>In message <20111122123007.GA5755@linutronix.de> you wrote:
>> 
>> >> + * Redistribution and use in source and binary forms, with or without
>> >> + * modification, are permitted provided that the following conditions
>> >> + * are met:
>> >> + *  * Redistributions of source code must retain the above copyright
>> >> + *    notice, this list of conditions and the following disclaimer.
>> >> + *  * Redistributions in binary form must reproduce the above copyright
>> >> + *    notice, this list of conditions and the following disclaimer in
>> >> + *    the documentation and/or other materials provided with the
>> >> + *    distribution.
>> >
>> >Sorry, but this is not GPL compatible.
>> 
>> Ehm. Is this the All rights reserved issue? If so then I assumed that I
>> cleared up things in
>
>No, it's the "Redistributions in binary form must reproduce..."
>clause.

How so? If you distribute it as source nothing changes. I don't see much
difference in binary form either: section 1 of the GPL says 

|.. keep intact all the notices that refer to this License and to the
|absence of any warranty; and give any other recipients of the Program a
|copy of this License along with the Program.

and this is no different. It does not mention whether the software has
to be passed in source or binary form. The BSD part does not push any
restrictions on the GPL, it "wants" the same thing. Section 6 of the GPL
says that by redistributing the receiptient should receive a copy of
this license. The section you mentioed is no different. If you
distribute GPL in binary code you have let the receiptient know, that he
is using GPL code. A note in the documentation is enough as far as I
know [if remeber correctly Harald went after a few companies which were
using Linux and were not letting the customers know about it].

If you look at the fresh released Quake3 source [0] you see that there
is a readme file which points out that it is GPL code and enumerates
various other licenses.

So right now, I don't see why those two should not be compatible. Plus
the FSF claims that they are [1].

[0] https://github.com/TTimo/doom3.gpl
[1] http://www.gnu.org/licenses/license-list.html#FreeBSD

>Best regards,
>
>Wolfgang Denk

Sebastian

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 2/2] usb/gadget: add the fastboot gadget
  2011-11-21 14:48   ` Stefan Schmidt
@ 2011-11-23 10:27     ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 17+ messages in thread
From: Sebastian Andrzej Siewior @ 2011-11-23 10:27 UTC (permalink / raw)
  To: u-boot

* Stefan Schmidt | 2011-11-21 15:48:29 [+0100]:

>Hello.
Hi,

>On Mon, 2011-11-21 at 15:09, Sebastian Andrzej Siewior wrote:
>> 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.
>
>Which what hardware do you test this? So far I have only seen patches
>(not applied yet) for the Samsung UDC controller that are providing
>the usb_gadget_register_driver() functions. Consumer is only ether.c
>so far.

DWC3. This one is new and already merged into the linux kernel. This one
is on my list once I have the fastboot part merged :)
There should be an at91 udc driver in the uboot-usb git tree. The last
time I checked, the at91 driver was in the next branch.

>Any other hardware platforms that support the new style gadget
>framework yet? Do'n get me wrong, I like it and would like to see more
>drivers moving to it but I wonder what support on a hardware driver
>level we have for it yet.

All drivers in u-boot are using the old style interface which is linux
from the late 2.4 time frame or very early 2.6. The dwc3 for which I
plan to have fastboot is a huge usb3 drd controller. Having two
different codebases does not make much sense.

>> The gadget implements the getvar, reboot, download and reboot commands.
>> What is missing is the flash handling i.e. writting the image to media.
>
>You may have seen the DFU patches on this list recently. There is also
>a split between the DFU protocol and the flashing backend. Would it
>make sense to see if fastboot and DFU could use the same flashing
>backend and platform specific bits?

I haven't seen it yet. From the protocol layer it is simple: You are
told to receive X bytes. Once you sucked it up are told where you have
to write it. The destination address is a partition name. So what I
planned to do is to add the android partition format which is efi/guid
based I think and then simply execute a "nand write data partition"
command. If there is code that can be shared between DFU and this
fastboot thingy then I'm the last person that does not want it.

>regards
>Stefan Schmidt

Sebastian

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 2/2] usb/gadget: add the fastboot gadget
  2011-11-21 14:09 ` [U-Boot] [PATCH 2/2] usb/gadget: add the fastboot gadget Sebastian Andrzej Siewior
  2011-11-21 14:48   ` Stefan Schmidt
@ 2012-01-08  4:56   ` Mike Frysinger
  2012-05-28 13:50     ` [U-Boot] [PATCH 2/3] " Macpaul Lin
  1 sibling, 1 reply; 17+ messages in thread
From: Mike Frysinger @ 2012-01-08  4:56 UTC (permalink / raw)
  To: u-boot

On Monday 21 November 2011 09:09:35 Sebastian Andrzej Siewior wrote:
> --- a/common/Makefile
> +++ b/common/Makefile
>
>  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

no newline here

> --- /dev/null
> +++ b/common/cmd_fastboot.c
> @@ -0,0 +1,28 @@
> +#include <common.h>
> +#include <command.h>
> +#include <usb/fastboot.h>

missing comment block with license/copyright/etc...
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120107/4c91f803/attachment.pgp>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 1/2] image: add support for Android's boot image format
  2011-11-23 10:03         ` Sebastian Andrzej Siewior
@ 2012-01-17  9:16           ` Aneesh V
  2012-02-02  9:28             ` Aneesh V
  2012-03-17 22:05             ` Wolfgang Denk
  2012-03-17 22:04           ` Wolfgang Denk
  1 sibling, 2 replies; 17+ messages in thread
From: Aneesh V @ 2012-01-17  9:16 UTC (permalink / raw)
  To: u-boot

Dear Wolfgang,

On Wednesday 23 November 2011 03:33 PM, Sebastian Andrzej Siewior wrote:
> * Wolfgang Denk | 2011-11-22 20:04:47 [+0100]:
>
>> Dear Sebastian Andrzej Siewior,
>>
>> In message<20111122123007.GA5755@linutronix.de>  you wrote:
>>>
>>>>> + * Redistribution and use in source and binary forms, with or without
>>>>> + * modification, are permitted provided that the following conditions
>>>>> + * are met:
>>>>> + *  * Redistributions of source code must retain the above copyright
>>>>> + *    notice, this list of conditions and the following disclaimer.
>>>>> + *  * Redistributions in binary form must reproduce the above copyright
>>>>> + *    notice, this list of conditions and the following disclaimer in
>>>>> + *    the documentation and/or other materials provided with the
>>>>> + *    distribution.
>>>>
>>>> Sorry, but this is not GPL compatible.
>>>
>>> Ehm. Is this the All rights reserved issue? If so then I assumed that I
>>> cleared up things in
>>
>> No, it's the "Redistributions in binary form must reproduce..."
>> clause.
>
> How so? If you distribute it as source nothing changes. I don't see much
> difference in binary form either: section 1 of the GPL says
>
> |.. keep intact all the notices that refer to this License and to the
> |absence of any warranty; and give any other recipients of the Program a
> |copy of this License along with the Program.
>
> and this is no different. It does not mention whether the software has
> to be passed in source or binary form. The BSD part does not push any
> restrictions on the GPL, it "wants" the same thing. Section 6 of the GPL
> says that by redistributing the receiptient should receive a copy of
> this license. The section you mentioed is no different. If you
> distribute GPL in binary code you have let the receiptient know, that he
> is using GPL code. A note in the documentation is enough as far as I
> know [if remeber correctly Harald went after a few companies which were
> using Linux and were not letting the customers know about it].
>
> If you look at the fresh released Quake3 source [0] you see that there
> is a readme file which points out that it is GPL code and enumerates
> various other licenses.
>
> So right now, I don't see why those two should not be compatible. Plus
> the FSF claims that they are [1].
>
> [0] https://github.com/TTimo/doom3.gpl
> [1] http://www.gnu.org/licenses/license-list.html#FreeBSD

What is your final call on this? The above arguments sound convincing
to me, but I have to admit that I am no legal expert. Either way, it
will be great to have a closure on this. Lack of fastboot support was
the greatest impediment to adoption of mainline U-Boot in our previous
platforms. It will be really unfortunate if the same happens to OMAP5
that has just arrived.

best regards,
Aneesh

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 1/2] image: add support for Android's boot image format
  2012-01-17  9:16           ` Aneesh V
@ 2012-02-02  9:28             ` Aneesh V
  2012-02-08 17:36               ` Tom Rini
  2012-03-17 22:05             ` Wolfgang Denk
  1 sibling, 1 reply; 17+ messages in thread
From: Aneesh V @ 2012-02-02  9:28 UTC (permalink / raw)
  To: u-boot

Dear Wolfgang,

On Tuesday 17 January 2012 02:46 PM, Aneesh V wrote:
> Dear Wolfgang,
>
> On Wednesday 23 November 2011 03:33 PM, Sebastian Andrzej Siewior wrote:
>> * Wolfgang Denk | 2011-11-22 20:04:47 [+0100]:
>>
>>> Dear Sebastian Andrzej Siewior,
>>>
>>> In message<20111122123007.GA5755@linutronix.de> you wrote:
>>>>
>>>>>> + * Redistribution and use in source and binary forms, with or
>>>>>> without
>>>>>> + * modification, are permitted provided that the following
>>>>>> conditions
>>>>>> + * are met:
>>>>>> + * * Redistributions of source code must retain the above copyright
>>>>>> + * notice, this list of conditions and the following disclaimer.
>>>>>> + * * Redistributions in binary form must reproduce the above
>>>>>> copyright
>>>>>> + * notice, this list of conditions and the following disclaimer in
>>>>>> + * the documentation and/or other materials provided with the
>>>>>> + * distribution.
>>>>>
>>>>> Sorry, but this is not GPL compatible.
>>>>
>>>> Ehm. Is this the All rights reserved issue? If so then I assumed that I
>>>> cleared up things in
>>>
>>> No, it's the "Redistributions in binary form must reproduce..."
>>> clause.
>>
>> How so? If you distribute it as source nothing changes. I don't see much
>> difference in binary form either: section 1 of the GPL says
>>
>> |.. keep intact all the notices that refer to this License and to the
>> |absence of any warranty; and give any other recipients of the Program a
>> |copy of this License along with the Program.
>>
>> and this is no different. It does not mention whether the software has
>> to be passed in source or binary form. The BSD part does not push any
>> restrictions on the GPL, it "wants" the same thing. Section 6 of the GPL
>> says that by redistributing the receiptient should receive a copy of
>> this license. The section you mentioed is no different. If you
>> distribute GPL in binary code you have let the receiptient know, that he
>> is using GPL code. A note in the documentation is enough as far as I
>> know [if remeber correctly Harald went after a few companies which were
>> using Linux and were not letting the customers know about it].
>>
>> If you look at the fresh released Quake3 source [0] you see that there
>> is a readme file which points out that it is GPL code and enumerates
>> various other licenses.
>>
>> So right now, I don't see why those two should not be compatible. Plus
>> the FSF claims that they are [1].
>>
>> [0] https://github.com/TTimo/doom3.gpl
>> [1] http://www.gnu.org/licenses/license-list.html#FreeBSD
>
> What is your final call on this? The above arguments sound convincing
> to me, but I have to admit that I am no legal expert. Either way, it
> will be great to have a closure on this. Lack of fastboot support was
> the greatest impediment to adoption of mainline U-Boot in our previous
> platforms. It will be really unfortunate if the same happens to OMAP5
> that has just arrived.

Ping.

br,
Aneesh

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 1/2] image: add support for Android's boot image format
  2012-02-02  9:28             ` Aneesh V
@ 2012-02-08 17:36               ` Tom Rini
  0 siblings, 0 replies; 17+ messages in thread
From: Tom Rini @ 2012-02-08 17:36 UTC (permalink / raw)
  To: u-boot

On Thu, Feb 2, 2012 at 2:28 AM, Aneesh V <aneesh@ti.com> wrote:
> Dear Wolfgang,
>
>
> On Tuesday 17 January 2012 02:46 PM, Aneesh V wrote:
>>
>> Dear Wolfgang,
>>
>> On Wednesday 23 November 2011 03:33 PM, Sebastian Andrzej Siewior wrote:
>>>
>>> * Wolfgang Denk | 2011-11-22 20:04:47 [+0100]:
>>>
>>>> Dear Sebastian Andrzej Siewior,
>>>>
>>>> In message<20111122123007.GA5755@linutronix.de> you wrote:
>>>>>
>>>>>
>>>>>>> + * Redistribution and use in source and binary forms, with or
>>>>>>> without
>>>>>>> + * modification, are permitted provided that the following
>>>>>>> conditions
>>>>>>> + * are met:
>>>>>>> + * * Redistributions of source code must retain the above copyright
>>>>>>> + * notice, this list of conditions and the following disclaimer.
>>>>>>> + * * Redistributions in binary form must reproduce the above
>>>>>>> copyright
>>>>>>> + * notice, this list of conditions and the following disclaimer in
>>>>>>> + * the documentation and/or other materials provided with the
>>>>>>> + * distribution.
>>>>>>
>>>>>>
>>>>>> Sorry, but this is not GPL compatible.
>>>>>
>>>>>
>>>>> Ehm. Is this the All rights reserved issue? If so then I assumed that I
>>>>> cleared up things in
>>>>
>>>>
>>>> No, it's the "Redistributions in binary form must reproduce..."
>>>> clause.
>>>
>>>
>>> How so? If you distribute it as source nothing changes. I don't see much
>>> difference in binary form either: section 1 of the GPL says
>>>
>>> |.. keep intact all the notices that refer to this License and to the
>>> |absence of any warranty; and give any other recipients of the Program a
>>> |copy of this License along with the Program.
>>>
>>> and this is no different. It does not mention whether the software has
>>> to be passed in source or binary form. The BSD part does not push any
>>> restrictions on the GPL, it "wants" the same thing. Section 6 of the GPL
>>> says that by redistributing the receiptient should receive a copy of
>>> this license. The section you mentioed is no different. If you
>>> distribute GPL in binary code you have let the receiptient know, that he
>>> is using GPL code. A note in the documentation is enough as far as I
>>> know [if remeber correctly Harald went after a few companies which were
>>> using Linux and were not letting the customers know about it].
>>>
>>> If you look at the fresh released Quake3 source [0] you see that there
>>> is a readme file which points out that it is GPL code and enumerates
>>> various other licenses.
>>>
>>> So right now, I don't see why those two should not be compatible. Plus
>>> the FSF claims that they are [1].
>>>
>>> [0] https://github.com/TTimo/doom3.gpl
>>> [1] http://www.gnu.org/licenses/license-list.html#FreeBSD
>>
>>
>> What is your final call on this? The above arguments sound convincing
>> to me, but I have to admit that I am no legal expert. Either way, it
>> will be great to have a closure on this. Lack of fastboot support was
>> the greatest impediment to adoption of mainline U-Boot in our previous
>> platforms. It will be really unfortunate if the same happens to OMAP5
>> that has just arrived.
>
>
> Ping.

Part of the feedback (see http://patchwork.ozlabs.org/patch/126797/)
was not addressed, namely the complete reference (including hash)
where the code came from.

-- 
Tom

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 1/2] image: add support for Android's boot image format
  2011-11-23 10:03         ` Sebastian Andrzej Siewior
  2012-01-17  9:16           ` Aneesh V
@ 2012-03-17 22:04           ` Wolfgang Denk
  1 sibling, 0 replies; 17+ messages in thread
From: Wolfgang Denk @ 2012-03-17 22:04 UTC (permalink / raw)
  To: u-boot

Dear Sebastian,

In message <20111123100316.GA6654@linutronix.de> you wrote:
> 
> >No, it's the "Redistributions in binary form must reproduce..."
> >clause.
...
> So right now, I don't see why those two should not be compatible. Plus
> the FSF claims that they are [1].

Sorry, my fault.  I confused the "reproduce the above copyright
notice" with the "must display the following acknowledgement" phrase
of the 4-clause original BSD license.

So please ignore this part of my remarks.

However,  I still ask you to change the commit message to include
_exact_ information where the code was derived from, as explained in 
bullet 4 etc. at
http://www.denx.de/wiki/view/U-Boot/Patches#Attributing_Code_Copyrights_Sign

Mind the part "provide terse but precise information which exact
version or even commit ID was used."

Thanks.

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: wd at denx.de
You don't have to stay up nights to succeed; you have to  stay  awake
days.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 1/2] image: add support for Android's boot image format
  2012-01-17  9:16           ` Aneesh V
  2012-02-02  9:28             ` Aneesh V
@ 2012-03-17 22:05             ` Wolfgang Denk
  2012-04-12 14:54               ` Aneesh V
  1 sibling, 1 reply; 17+ messages in thread
From: Wolfgang Denk @ 2012-03-17 22:05 UTC (permalink / raw)
  To: u-boot

Dear Aneesh V,

In message <4F153C83.20703@ti.com> you wrote:
> 
> What is your final call on this? The above arguments sound convincing
> to me, but I have to admit that I am no legal expert. Either way, it
> will be great to have a closure on this. Lack of fastboot support was
> the greatest impediment to adoption of mainline U-Boot in our previous
> platforms. It will be really unfortunate if the same happens to OMAP5
> that has just arrived.

The license issue was a mistake on my side.

However, there is still cleanup needed for the commit message.

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: wd at denx.de
It would be illogical to kill without reason
	-- Spock, "Journey to Babel", stardate 3842.4

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 1/2] image: add support for Android's boot image format
  2012-03-17 22:05             ` Wolfgang Denk
@ 2012-04-12 14:54               ` Aneesh V
  0 siblings, 0 replies; 17+ messages in thread
From: Aneesh V @ 2012-04-12 14:54 UTC (permalink / raw)
  To: u-boot

On 03/17/2012 03:05 PM, Wolfgang Denk wrote:
> Dear Aneesh V,
>
> In message<4F153C83.20703@ti.com>  you wrote:
>>
>> What is your final call on this? The above arguments sound convincing
>> to me, but I have to admit that I am no legal expert. Either way, it
>> will be great to have a closure on this. Lack of fastboot support was
>> the greatest impediment to adoption of mainline U-Boot in our previous
>> platforms. It will be really unfortunate if the same happens to OMAP5
>> that has just arrived.
> > The license issue was a mistake on my side.
>
> However, there is still cleanup needed for the commit message.

Thanks. I will see if somebody can take it forward.

br,
Aneesh

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 2/3] usb/gadget: add the fastboot gadget
  2012-01-08  4:56   ` Mike Frysinger
@ 2012-05-28 13:50     ` Macpaul Lin
  0 siblings, 0 replies; 17+ messages in thread
From: Macpaul Lin @ 2012-05-28 13:50 UTC (permalink / raw)
  To: u-boot

Hi Wolfgang and Mike,

> > missing comment block with license/copyright/etc...
> > -mike
> >
[strip]
> Are you 100% sure this is a GPLv2+ compatible license??? I don't think
> so...
[strip]
>
> For U-Boot, we need GPLv2+.  Please see bullet # 3 at
> http://www.denx.de/wiki/view/U Boot/Patches#Attributing_Code_Copyrights_Sign
> and note # 1 at http://www.denx.de/wiki/view/U-Boot/Patches#Notes
>
> Best regards,
>
> Wolfgang Denk

I have encountered some requests of porting Google's Fastboot protocol
to u-boot from customers.
As your comment about supporting fastboot in uboot in
http://lists.linaro.org/pipermail/linaro-dev/2011-April/004136.html
I think the problem of supporting fastboot in uboot might not only be
the license problem.

For clarifying the license issue, I think we may present some history
as follows.

The original BSD license (4-clause license) was indeed incompatible with GPLv2.
However, this conflict has finally be resolved in "The new BSD
license" (2-clause license). After revising, the 2-clause BSD license
is almost exactly the same as MIT X license, which is also compatible
with GPLv2.
In detail, please check about the the page about the 3rd advertisement clause.
http://www.gnu.org/philosophy/bsd.html
And the content of the 4th clause which has been removed was "Neither
the name of the University nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission."

The license of Google's fastboot is exactly 2-clause BSD license.
http://www.opensource.org/licenses/bsd-license.php

I think the well-known event of merging
BSD/GPL code in QEMU could be a reference.
The well-known Open Source Licensing and Patent consultant of Redhat
-- Richard Fontana has also helped on this problem.
In order to merge SLiRP into QEMU, Richard has written e-mail to the
author of SLiRP, which is "Danny Gasparovski" and the maintainer
"Kelly Price" to get the agreement of removing the incompatible
clauses.
And after the revising of license, they've successfully merged SLiRP.
http://lists.gnu.org/archive/html/qemu-devel/2009-01/msg01765.html

Since the license of fastboot.c doesn't have the problem above, I
think there is no compatible problem for merging "Google's fastboot".


-- 
Best regards,
Macpaul Lin

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2012-05-28 13:50 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-21 14:09 [U-Boot] Fastboot gadget, v2. repost Sebastian Andrzej Siewior
2011-11-21 14:09 ` [U-Boot] [PATCH 1/2] image: add support for Android's boot image format Sebastian Andrzej Siewior
2011-11-21 20:19   ` Wolfgang Denk
2011-11-22 12:30     ` Sebastian Andrzej Siewior
2011-11-22 19:04       ` Wolfgang Denk
2011-11-23 10:03         ` Sebastian Andrzej Siewior
2012-01-17  9:16           ` Aneesh V
2012-02-02  9:28             ` Aneesh V
2012-02-08 17:36               ` Tom Rini
2012-03-17 22:05             ` Wolfgang Denk
2012-04-12 14:54               ` Aneesh V
2012-03-17 22:04           ` Wolfgang Denk
2011-11-21 14:09 ` [U-Boot] [PATCH 2/2] usb/gadget: add the fastboot gadget Sebastian Andrzej Siewior
2011-11-21 14:48   ` Stefan Schmidt
2011-11-23 10:27     ` Sebastian Andrzej Siewior
2012-01-08  4:56   ` Mike Frysinger
2012-05-28 13:50     ` [U-Boot] [PATCH 2/3] " Macpaul Lin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.