Skip to contentSkip to conversation

Implement "fastboot flash" for eMMC

PATCH Superseded Steve Rae 4 participants 21 messages Aug 23, 2014 – Aug 28, 2014 USB

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Steve Rae

author
#0 lore raw

v5 cover Implement "fastboot flash" for eMMC

This series implements the "fastboot flash" command for eMMC devices. It supports both raw and sparse images.

NOTES:
- the support for the "fastboot flash" command is enabled with CONFIG_FASTBOOT_FLASH
- the support for eMMC is enabled with CONFIG_FASTBOOT_FLASH_MMC_DEV
- (future) the support for NAND would be enabled with CONFIG_FASTBOOT_FLASH_NAND(???)

This has been tested on ARMv7.

----

This series depends on:
http://patchwork.ozlabs.org/patch/379438/
http://patchwork.ozlabs.org/patch/382443/ (to 382446)

Changes in v5:
- use the common/aboot.c for the "sparse format" handling

Changes in v4:
- rearranged this patchset so that "sparse_format.h" can be dropped (if we cannot resolve the copyright/licensing issues)
- update mmc_get_dev(...) to get_dev("mmc",....)
- update printf() to puts() where applicable
- update debug string as per feedback
- rearranged "sparse format" support in this patchset, in order to isolate...

Changes in v3:
- remove most references to 'mmc',
which leaves only one mmc specific function: mmc_get_dev()

Changes in v2:
- split large function into three
- improved handling of response messages
- additional partition size checking when writing sparse image
- update README.android-fastboot file
- new in v2

Steve Rae (4):
usb/gadget: fastboot: add eMMC support for flash command usb/gadget: fastboot: add support for flash command usb/gadget: fastboot: minor cleanup
usb/gadget: fastboot: implement sparse format

 README                          | 10 +++++
 common/Makefile                 |  6 +++
 common/cmd_fastboot.c           |  7 +--
 common/fb_mmc.c                 | 95 +++++++++++++++++++++++++++++++++++++++++
 doc/README.android-fastboot     |  5 ++-
 drivers/usb/gadget/f_fastboot.c | 44 +++++++++++++++++--
 include/fb_mmc.h                |  8 ++++
 7 files changed, 166 insertions(+), 9 deletions(-)
 create mode 100644 common/fb_mmc.c
 create mode 100644 include/fb_mmc.h
Signature · 1 line
1.8.5
author
#1 lore raw

PATCH v5 1/4 usb/gadget: fastboot: add eMMC support for flash command

- add support for 'fastboot flash' command for eMMC devices

---

Changes in v5: None
Changes in v4:
- rearranged this patchset so that "sparse_format.h" can be dropped (if we cannot resolve the copyright/licensing issues)
- update mmc_get_dev(...) to get_dev("mmc",....)
- update printf() to puts() where applicable

Changes in v3:
- remove most references to 'mmc',
which leaves only one mmc specific function: mmc_get_dev()

Changes in v2:
- split large function into three
- improved handling of response messages
- additional partition size checking when writing sparse image

 common/Makefile  |  5 ++++
 common/fb_mmc.c  | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/fb_mmc.h |  8 ++++++
 3 files changed, 95 insertions(+)
 create mode 100644 common/fb_mmc.c
 create mode 100644 include/fb_mmc.h
common/Makefile +5 -0
index de5cce8..daebe39 100644
@@ -266,4 +266,9 @@ obj-$(CONFIG_IO_TRACE) += iotrace.o
 obj-y += memsize.o
 obj-y += stdio.o
 
+# This option is not just y/n - it can have a numeric value
+ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+obj-y += fb_mmc.o
+endif
+
 CFLAGS_env_embedded.o := -Wa,--no-warn -DENV_CRC=$(shell tools/envcrc 2>/dev/null)
common/fb_mmc.c new file +82 -0

82 lines not on this page · raw message

include/fb_mmc.h new file +8 -0
new file mode 100644
index 0000000..1ad1d13
@@ -0,0 +1,8 @@
+/*
+ * Copyright 2014 Broadcom Corporation.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+void fb_mmc_flash_write(const char *cmd, void *download_buffer,
+			unsigned int download_bytes, char *response);
Signature · 1 line
1.8.5
#2 lore raw

PATCH v5 1/4 usb/gadget: fastboot: add eMMC support for flash command

Hi Steve,

Quoted 85 lines

- add support for 'fastboot flash' command for eMMC devices

---

Changes in v5: None
Changes in v4:
- rearranged this patchset so that "sparse_format.h" can be dropped (if we cannot resolve the copyright/licensing issues)
- update mmc_get_dev(...) to get_dev("mmc",....)
- update printf() to puts() where applicable

Changes in v3:
- remove most references to 'mmc',
which leaves only one mmc specific function: mmc_get_dev()

Changes in v2:
- split large function into three
- improved handling of response messages
- additional partition size checking when writing sparse image

 common/Makefile  |  5 ++++
 common/fb_mmc.c  | 82
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/fb_mmc.h |  8 ++++++ 3 files changed, 95 insertions(+)
 create mode 100644 common/fb_mmc.c
 create mode 100644 include/fb_mmc.h
common/Makefile +5 -0
index de5cce8..daebe39 100644
@@ -266,4 +266,9 @@ obj-$(CONFIG_IO_TRACE) += iotrace.o
 obj-y += memsize.o
 obj-y += stdio.o
 
+# This option is not just y/n - it can have a numeric value
+ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+obj-y += fb_mmc.o
+endif
+
 CFLAGS_env_embedded.o := -Wa,--no-warn -DENV_CRC=$(shell

tools/envcrc 2>/dev/null) diff --git a/common/fb_mmc.c b/common/fb_mmc.c new file mode 100644
index 0000000..e559e2a

common/fb_mmc.c new file +22 -0
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2014 Broadcom Corporation.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <fb_mmc.h>
+#include <part.h>
+
+/* The 64 defined bytes plus the '\0' */
+#define RESPONSE_LEN	(64 + 1)
+
+static char *response_str;
+
+static void fastboot_resp(const char *s)
+{
+	strncpy(response_str, s, RESPONSE_LEN);
+	response_str[RESPONSE_LEN - 1] = '\0';
+}
+
+static void write_raw_image(block_dev_desc_t *dev_desc,

disk_partition_t *info,

common/fb_mmc.c new file +8 -0
+		const char *part_name, void *buffer,
+		unsigned int download_bytes)
+{
+	lbaint_t blkcnt;
+	lbaint_t blks;
+
+	/* determine number of blocks to write */
+	blkcnt = ((download_bytes + (info->blksz - 1)) &

~(info->blksz - 1));

common/fb_mmc.c new file +4 -0
+	blkcnt = blkcnt / info->blksz;
+
+	if (blkcnt > info->size) {
+		printf("%s: too large for partition: '%s'\n",

__func__,

common/fb_mmc.c

Quoted 1 line
common/fb_mmc.c new file +1 -0
+		       part_name);

I would opt for using error() here instead of printf().

common/fb_mmc.c line 46

Quoted 12 lines
common/fb_mmc.c new file +7 -0
+		fastboot_resp("FAILtoo large for partition");
+		return;
+	}
+
+	puts("Flashing Raw Image\n");
+
+	blks = dev_desc->block_write(dev_desc->dev, info->start,

blkcnt,

common/fb_mmc.c new file +4 -0
+				     buffer);
+	if (blks != blkcnt) {
+		printf("%s: failed writing to device %d\n", __func__,
+		       dev_desc->dev);
		printf() -> error()
Quoted 13 lines
common/fb_mmc.c new file +5 -0
+		fastboot_resp("FAILfailed writing to device");
+		return;
+	}
+
+	printf("........ wrote " LBAFU " bytes to '%s'\n", blkcnt *

info->blksz,

common/fb_mmc.c new file +7 -0
+	       part_name);
+	fastboot_resp("OKAY");
+}
+
+void fb_mmc_flash_write(const char *cmd, void *download_buffer,
+			unsigned int download_bytes, char *response)
+{

common/fb_mmc.c line 68

Quoted 10 lines
common/fb_mmc.c new file +10 -0
+	int ret;
+	block_dev_desc_t *dev_desc;
+	disk_partition_t info;
+
+	/* initialize the response buffer */
+	response_str = response;
+
+	dev_desc = get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
+	if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
+		printf("%s: invalid mmc device\n", __func__);
		printf() -> error()
Quoted 8 lines
common/fb_mmc.c new file +7 -0
+		fastboot_resp("FAILinvalid mmc device");
+		return;
+	}
+
+	ret = get_partition_info_efi_by_name(dev_desc, cmd, &info);
+	if (ret) {
+		printf("%s: cannot find partition: '%s'\n",

__func__, cmd);

		printf() -> error()
Quoted 21 lines
common/fb_mmc.c new file +7 -0
+		fastboot_resp("FAILcannot find partition");
+		return;
+	}
+
+	write_raw_image(dev_desc, &info, cmd, download_buffer,
+			download_bytes);
+}
include/fb_mmc.h new file +8 -0
new file mode 100644
index 0000000..1ad1d13
@@ -0,0 +1,8 @@
+/*
+ * Copyright 2014 Broadcom Corporation.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+void fb_mmc_flash_write(const char *cmd, void *download_buffer,
+			unsigned int download_bytes, char *response);
Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
#3 lore raw

PATCH v5 1/4 usb/gadget: fastboot: add eMMC support for flash command

Quoted 5 lines · Lukasz Majewski

Hi Steve,

Quoted 3 lines

- add support for 'fastboot flash' command for eMMC devices

If those are only small things, I think we can fix them up ourselves before applying, no? Let's do just that if Steve agrees, no ?

Best regards,
Marek Vasut

author
#4 lore raw

PATCH v5 1/4 usb/gadget: fastboot: add eMMC support for flash command

Steve agrees!!!
-- I have fixed them this time, see "v6",
However, I have no issue with you cleaning up the minor issues.... THANKS, Steve

Quoted 13 lines · Marek Vasut
Quoted 5 lines · Lukasz Majewski

Hi Steve,

Quoted 3 lines

- add support for 'fastboot flash' command for eMMC devices

If those are only small things, I think we can fix them up ourselves before applying, no? Let's do just that if Steve agrees, no ?

Best regards,
Marek Vasut

author
#5 lore raw

PATCH v5 2/4 usb/gadget: fastboot: add support for flash command

In reply to Steve Rae

- implement 'fastboot flash' for eMMC devices

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2:
- update README.android-fastboot file

 README                          | 10 ++++++++++
 doc/README.android-fastboot     |  5 +++--
 drivers/usb/gadget/f_fastboot.c | 31 +++++++++++++++++++++++++++++++
 3 files changed, 44 insertions(+), 2 deletions(-)
README +10 -0
index 1d71359..ed26884 100644
@@ -1623,6 +1623,16 @@ The following options need to be configured:
 		downloads. This buffer should be as large as possible for a
 		platform. Define this to the size available RAM for fastboot.
 
+		CONFIG_FASTBOOT_FLASH
+		The fastboot protocol includes a "flash" command for writing
+		the downloaded image to a non-volatile storage device. Define
+		this to enable the "fastboot flash" command.
+
+		CONFIG_FASTBOOT_FLASH_MMC_DEV
+		The fastboot "flash" command requires addition information
+		regarding the non-volatile storage device. Define this to
+		the eMMC device that fastboot should use to store the image.
+
 - Journaling Flash filesystem support:
 		CONFIG_JFFS2_NAND, CONFIG_JFFS2_NAND_OFF, CONFIG_JFFS2_NAND_SIZE,
 		CONFIG_JFFS2_NAND_DEV
doc/README.android-fastboot +3 -2
index 4045727..1677609 100644
@@ -6,8 +6,9 @@ Overview
 The protocol that is used over USB is described in
 README.android-fastboot-protocol in same directory.
 
-The current implementation does not yet support the flash and erase
-commands.
+The current implementation does not yet support the erase command or the
+"oem format" command, and there is minimal support for the flash command;
+it only supports eMMC devices.
 
 Client installation
 ===================
drivers/usb/gadget/f_fastboot.c +31 -0
index 7a1acb9..e2659fa 100644
@@ -19,6 +19,9 @@
 #include <linux/compiler.h>
 #include <version.h>
 #include <g_dnl.h>
+#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+#include <fb_mmc.h>
+#endif
 
 #define FASTBOOT_VERSION		"0.4"
 
@@ -469,6 +472,28 @@ static void cb_boot(struct usb_ep *ep, struct usb_request *req)
 	fastboot_tx_write_str("OKAY");
 }
 
+#ifdef CONFIG_FASTBOOT_FLASH
+static void cb_flash(struct usb_ep *ep, struct usb_request *req)
+{
+	char *cmd = req->buf;
+	char response[RESPONSE_LEN];
+
+	strsep(&cmd, ":");
+	if (!cmd) {
+		printf("%s: missing partition name\n", __func__);
+		fastboot_tx_write_str("FAILmissing partition name");
+		return;
+	}
+
+	strcpy(response, "FAILno flash device defined");
+#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+	fb_mmc_flash_write(cmd, (void *)CONFIG_USB_FASTBOOT_BUF_ADDR,
+			   download_bytes, response);
+#endif
+	fastboot_tx_write_str(response);
+}
+#endif
+
 struct cmd_dispatch_info {
 	char *cmd;
 	void (*cb)(struct usb_ep *ep, struct usb_request *req);
@@ -488,6 +513,12 @@ static const struct cmd_dispatch_info cmd_dispatch_info[] = {
 		.cmd = "boot",
 		.cb = cb_boot,
 	},
+#ifdef CONFIG_FASTBOOT_FLASH
+	{
+		.cmd = "flash",
+		.cb = cb_flash,
+	},
+#endif
 };
 
 static void rx_handler_command(struct usb_ep *ep, struct usb_request *req)
Signature · 1 line
1.8.5
#6 lore raw

PATCH v5 2/4 usb/gadget: fastboot: add support for flash command

Hi Steve,

Quoted 30 lines

- implement 'fastboot flash' for eMMC devices

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2:
- update README.android-fastboot file

 README                          | 10 ++++++++++
 doc/README.android-fastboot     |  5 +++--
 drivers/usb/gadget/f_fastboot.c | 31 +++++++++++++++++++++++++++++++
 3 files changed, 44 insertions(+), 2 deletions(-)
README +0 -0
index 1d71359..ed26884 100644
@@ -1623,6 +1623,16 @@ The following options need to be configured:
 		downloads. This buffer should be as large as

possible for a platform. Define this to the size available RAM for fastboot.

README +2 -0
+		CONFIG_FASTBOOT_FLASH
+		The fastboot protocol includes a "flash" command for

writing

README +1 -0
+		the downloaded image to a non-volatile storage

device. Define

README The following options need to be configured:

Quoted 4 lines
README +4 -0
+		this to enable the "fastboot flash" command.
+
+		CONFIG_FASTBOOT_FLASH_MMC_DEV
+		The fastboot "flash" command requires addition
						      ^^^^ additional?
Quoted 80 lines

information

README +1 -0
+		regarding the non-volatile storage device. Define

this to

README +1 -0
+		the eMMC device that fastboot should use to store

the image. +
- Journaling Flash filesystem support:
CONFIG_JFFS2_NAND, CONFIG_JFFS2_NAND_OFF,
CONFIG_JFFS2_NAND_SIZE, CONFIG_JFFS2_NAND_DEV

doc/README.android-fastboot +1 -2
index 4045727..1677609 100644
@@ -6,8 +6,9 @@ Overview
 The protocol that is used over USB is described in
 README.android-fastboot-protocol in same directory.
 
-The current implementation does not yet support the flash and erase
-commands.
+The current implementation does not yet support the erase command or

the +"oem format" command, and there is minimal support for the flash command; +it only supports eMMC devices.

Client installation
===================

(quoted diff) +0 -0

b/drivers/usb/gadget/f_fastboot.c index 7a1acb9..e2659fa 100644

drivers/usb/gadget/f_fastboot.c +31 -0
@@ -19,6 +19,9 @@
 #include <linux/compiler.h>
 #include <version.h>
 #include <g_dnl.h>
+#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+#include <fb_mmc.h>
+#endif
 
 #define FASTBOOT_VERSION		"0.4"
 
@@ -469,6 +472,28 @@ static void cb_boot(struct usb_ep *ep, struct
 usb_request *req) fastboot_tx_write_str("OKAY");
 }
 
+#ifdef CONFIG_FASTBOOT_FLASH
+static void cb_flash(struct usb_ep *ep, struct usb_request *req)
+{
+	char *cmd = req->buf;
+	char response[RESPONSE_LEN];
+
+	strsep(&cmd, ":");
+	if (!cmd) {
+		printf("%s: missing partition name\n", __func__);
+		fastboot_tx_write_str("FAILmissing partition name");
+		return;
+	}
+
+	strcpy(response, "FAILno flash device defined");
+#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+	fb_mmc_flash_write(cmd, (void *)CONFIG_USB_FASTBOOT_BUF_ADDR,
+			   download_bytes, response);
+#endif
+	fastboot_tx_write_str(response);
+}
+#endif
+
 struct cmd_dispatch_info {
 	char *cmd;
 	void (*cb)(struct usb_ep *ep, struct usb_request *req);
@@ -488,6 +513,12 @@ static const struct cmd_dispatch_info
 cmd_dispatch_info[] = { .cmd = "boot",
 		.cb = cb_boot,
 	},
+#ifdef CONFIG_FASTBOOT_FLASH
+	{
+		.cmd = "flash",
+		.cb = cb_flash,
+	},
+#endif
 };
 
 static void rx_handler_command(struct usb_ep *ep, struct usb_request
Quoted 1 line

*req)

Despite the minor misspelling.

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
author
#7 lore raw

PATCH v5 3/4 usb/gadget: fastboot: minor cleanup

In reply to Steve Rae

- update static function
- additional debugging statements
- update "fastboot command" information
- add missing include file
- update spelling

---

Changes in v5: None
Changes in v4:
- update debug string as per feedback

Changes in v3: None
Changes in v2:
- new in v2

 common/cmd_fastboot.c           |  7 ++++---
 drivers/usb/gadget/f_fastboot.c | 13 +++++++++----
 2 files changed, 13 insertions(+), 7 deletions(-)
common/cmd_fastboot.c +4 -3
index 83fa7bd..909616d 100644
@@ -30,7 +30,8 @@ static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 }
 
 U_BOOT_CMD(
-	fastboot,	1,	1,	do_fastboot,
-	"fastboot - enter USB Fastboot protocol",
-	""
+	fastboot,	1,	0,	do_fastboot,
+	"use USB Fastboot protocol",
+	"\n"
+	"    - run as a fastboot usb device"
 );
drivers/usb/gadget/f_fastboot.c +9 -4
index e2659fa..3b588a9 100644
@@ -10,6 +10,7 @@
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
+#include <config.h>
 #include <common.h>
 #include <errno.h>
 #include <malloc.h>
@@ -41,7 +42,7 @@
 struct f_fastboot {
 	struct usb_function usb_function;
 
-	/* IN/OUT EP's and correspoinding requests */
+	/* IN/OUT EP's and corresponding requests */
 	struct usb_ep *in_ep, *out_ep;
 	struct usb_request *in_req, *out_req;
 };
@@ -293,7 +294,7 @@ static int fastboot_add(struct usb_configuration *c)
 }
 DECLARE_GADGET_BIND_CALLBACK(usb_dnl_fastboot, fastboot_add);
 
-int fastboot_tx_write(const char *buffer, unsigned int buffer_size)
+static int fastboot_tx_write(const char *buffer, unsigned int buffer_size)
 {
 	struct usb_request *in_req = fastboot_func->in_req;
 	int ret;
@@ -341,6 +342,7 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req)
 
 	strsep(&cmd, ":");
 	if (!cmd) {
+		printf("%s: missing variable\n", __func__);
 		fastboot_tx_write_str("FAILmissing var");
 		return;
 	}
@@ -361,6 +363,7 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req)
 		else
 			strcpy(response, "FAILValue not set");
 	} else {
+		printf("%s: unknown variable: %s\n", __func__, cmd);
 		strcpy(response, "FAILVariable not implemented");
 	}
 	fastboot_tx_write_str(response);
@@ -534,10 +537,12 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req)
 		}
 	}
 
-	if (!func_cb)
+	if (!func_cb) {
+		printf("%s: unknown command: %s\n", __func__, cmdbuf);
 		fastboot_tx_write_str("FAILunknown command");
-	else
+	} else {
 		func_cb(ep, req);
+	}
 
 	if (req->status == 0) {
 		*cmdbuf = '\0';
Signature · 1 line
1.8.5
#8 lore raw

PATCH v5 3/4 usb/gadget: fastboot: minor cleanup

Hi Steve,

Quoted 68 lines

- update static function
- additional debugging statements
- update "fastboot command" information
- add missing include file
- update spelling

---

Changes in v5: None
Changes in v4:
- update debug string as per feedback

Changes in v3: None
Changes in v2:
- new in v2

 common/cmd_fastboot.c           |  7 ++++---
 drivers/usb/gadget/f_fastboot.c | 13 +++++++++----
 2 files changed, 13 insertions(+), 7 deletions(-)
common/cmd_fastboot.c +4 -3
index 83fa7bd..909616d 100644
@@ -30,7 +30,8 @@ static int do_fastboot(cmd_tbl_t *cmdtp, int flag,
 int argc, char *const argv[]) }
 
 U_BOOT_CMD(
-	fastboot,	1,	1,	do_fastboot,
-	"fastboot - enter USB Fastboot protocol",
-	""
+	fastboot,	1,	0,	do_fastboot,
+	"use USB Fastboot protocol",
+	"\n"
+	"    - run as a fastboot usb device"
 );
(quoted diff) +0 -0

b/drivers/usb/gadget/f_fastboot.c index e2659fa..3b588a9 100644

drivers/usb/gadget/f_fastboot.c +3 -2
@@ -10,6 +10,7 @@
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
+#include <config.h>
 #include <common.h>
 #include <errno.h>
 #include <malloc.h>
@@ -41,7 +42,7 @@
 struct f_fastboot {
 	struct usb_function usb_function;
 
-	/* IN/OUT EP's and correspoinding requests */
+	/* IN/OUT EP's and corresponding requests */
 	struct usb_ep *in_ep, *out_ep;
 	struct usb_request *in_req, *out_req;
 };
@@ -293,7 +294,7 @@ static int fastboot_add(struct usb_configuration
 *c) }
 DECLARE_GADGET_BIND_CALLBACK(usb_dnl_fastboot, fastboot_add);
 
-int fastboot_tx_write(const char *buffer, unsigned int buffer_size)
+static int fastboot_tx_write(const char *buffer, unsigned int
 buffer_size) {
 	struct usb_request *in_req = fastboot_func->in_req;
 	int ret;

drivers/usb/gadget/f_fastboot.c static void cb_getvar(struct usb_ep *ep, struct · line 345

Quoted 4 lines
drivers/usb/gadget/f_fastboot.c +1 -0
@@ -341,6 +342,7 @@ static void cb_getvar(struct usb_ep *ep, struct
 usb_request *req) 
 	strsep(&cmd, ":");
 	if (!cmd) {
+		printf("%s: missing variable\n", __func__);
	It is up to you if you would consider changing printf() to
	error().

drivers/usb/gadget/f_fastboot.c static void cb_getvar(struct usb_ep *ep, struct usb_request *req) · line 366

Quoted 8 lines
drivers/usb/gadget/f_fastboot.c +0 -0
 		fastboot_tx_write_str("FAILmissing var");
 		return;
 	}
@@ -361,6 +363,7 @@ static void cb_getvar(struct usb_ep *ep, struct

usb_request *req) else

drivers/usb/gadget/f_fastboot.c +1 -0
 			strcpy(response, "FAILValue not set");
 	} else {
+		printf("%s: unknown variable: %s\n", __func__, cmd);
	printf() -> error()
Quoted 18 lines
drivers/usb/gadget/f_fastboot.c +4 -2
 		strcpy(response, "FAILVariable not implemented");
 	}
 	fastboot_tx_write_str(response);
@@ -534,10 +537,12 @@ static void rx_handler_command(struct usb_ep
 *ep, struct usb_request *req) }
 	}
 
-	if (!func_cb)
+	if (!func_cb) {
+		printf("%s: unknown command: %s\n", __func__,
 cmdbuf); fastboot_tx_write_str("FAILunknown command");
-	else
+	} else {
 		func_cb(ep, req);
+	}
 
 	if (req->status == 0) {
 		*cmdbuf = '\0';
Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
author
#9 lore raw

PATCH v5 4/4 usb/gadget: fastboot: implement sparse format

In reply to Steve Rae

- add capability to "fastboot flash" with sparse format images

---

Changes in v5:
- use the common/aboot.c for the "sparse format" handling

Changes in v4:
- rearranged "sparse format" support in this patchset, in order to isolate...

Changes in v3: None
Changes in v2: None

 common/Makefile |  1 +
 common/fb_mmc.c | 33 +++++++++++++++++++++++----------
 2 files changed, 24 insertions(+), 10 deletions(-)
common/Makefile +1 -0
index daebe39..bc53078 100644
@@ -268,6 +268,7 @@ obj-y += stdio.o
 
 # This option is not just y/n - it can have a numeric value
 ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+obj-y += aboot.o
 obj-y += fb_mmc.o
 endif
 
common/fb_mmc.c +23 -10
index e559e2a..c2e896f 100644
@@ -7,16 +7,24 @@
 #include <common.h>
 #include <fb_mmc.h>
 #include <part.h>
+#include <aboot.h>
+#include <sparse_format.h>
 
 /* The 64 defined bytes plus the '\0' */
 #define RESPONSE_LEN	(64 + 1)
 
 static char *response_str;
 
-static void fastboot_resp(const char *s)
+void fastboot_fail(const char *s)
 {
-	strncpy(response_str, s, RESPONSE_LEN);
-	response_str[RESPONSE_LEN - 1] = '\0';
+	strncpy(response_str, "FAIL", 4);
+	strncat(response_str, s, RESPONSE_LEN - 4 - 1);
+}
+
+void fastboot_okay(const char *s)
+{
+	strncpy(response_str, "OKAY", 4);
+	strncat(response_str, s, RESPONSE_LEN - 4 - 1);
 }
 
 static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info,
@@ -33,7 +41,7 @@ static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info,
 	if (blkcnt > info->size) {
 		printf("%s: too large for partition: '%s'\n", __func__,
 		       part_name);
-		fastboot_resp("FAILtoo large for partition");
+		fastboot_fail("too large for partition");
 		return;
 	}
 
@@ -44,13 +52,13 @@ static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info,
 	if (blks != blkcnt) {
 		printf("%s: failed writing to device %d\n", __func__,
 		       dev_desc->dev);
-		fastboot_resp("FAILfailed writing to device");
+		fastboot_fail("failed writing to device");
 		return;
 	}
 
 	printf("........ wrote " LBAFU " bytes to '%s'\n", blkcnt * info->blksz,
 	       part_name);
-	fastboot_resp("OKAY");
+	fastboot_okay("");
 }
 
 void fb_mmc_flash_write(const char *cmd, void *download_buffer,
@@ -66,17 +74,22 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer,
 	dev_desc = get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
 	if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
 		printf("%s: invalid mmc device\n", __func__);
-		fastboot_resp("FAILinvalid mmc device");
+		fastboot_fail("invalid mmc device");
 		return;
 	}
 
 	ret = get_partition_info_efi_by_name(dev_desc, cmd, &info);
 	if (ret) {
 		printf("%s: cannot find partition: '%s'\n", __func__, cmd);
-		fastboot_resp("FAILcannot find partition");
+		fastboot_fail("cannot find partition");
 		return;
 	}
 
-	write_raw_image(dev_desc, &info, cmd, download_buffer,
-			download_bytes);
+	if (is_sparse_image(download_buffer)) {
+		write_sparse_image(dev_desc, &info, cmd, download_buffer,
+				   download_bytes);
+	} else {
+		write_raw_image(dev_desc, &info, cmd, download_buffer,
+				download_bytes);
+	}
 }
Signature · 1 line
1.8.5
#10 lore raw

PATCH v5 4/4 usb/gadget: fastboot: implement sparse format

Hi Steve,

Quoted 115 lines

- add capability to "fastboot flash" with sparse format images

---

Changes in v5:
- use the common/aboot.c for the "sparse format" handling

Changes in v4:
- rearranged "sparse format" support in this patchset, in order to isolate...

Changes in v3: None
Changes in v2: None

 common/Makefile |  1 +
 common/fb_mmc.c | 33 +++++++++++++++++++++++----------
 2 files changed, 24 insertions(+), 10 deletions(-)
common/Makefile +1 -0
index daebe39..bc53078 100644
@@ -268,6 +268,7 @@ obj-y += stdio.o
 
 # This option is not just y/n - it can have a numeric value
 ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+obj-y += aboot.o
 obj-y += fb_mmc.o
 endif
 
common/fb_mmc.c +11 -3
index e559e2a..c2e896f 100644
@@ -7,16 +7,24 @@
 #include <common.h>
 #include <fb_mmc.h>
 #include <part.h>
+#include <aboot.h>
+#include <sparse_format.h>
 
 /* The 64 defined bytes plus the '\0' */
 #define RESPONSE_LEN	(64 + 1)
 
 static char *response_str;
 
-static void fastboot_resp(const char *s)
+void fastboot_fail(const char *s)
 {
-	strncpy(response_str, s, RESPONSE_LEN);
-	response_str[RESPONSE_LEN - 1] = '\0';
+	strncpy(response_str, "FAIL", 4);
+	strncat(response_str, s, RESPONSE_LEN - 4 - 1);
+}
+
+void fastboot_okay(const char *s)
+{
+	strncpy(response_str, "OKAY", 4);
+	strncat(response_str, s, RESPONSE_LEN - 4 - 1);
 }
 
 static void write_raw_image(block_dev_desc_t *dev_desc,

disk_partition_t *info, @@ -33,7 +41,7 @@ static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info, if (blkcnt > info->size) { printf("%s: too large for partition:
'%s'\n", __func__, part_name);

common/fb_mmc.c +3 -3
-		fastboot_resp("FAILtoo large for partition");
+		fastboot_fail("too large for partition");
 		return;
 	}
@@ -44,13 +52,13 @@ static void write_raw_image(block_dev_desc_t
 *dev_desc, disk_partition_t *info, if (blks != blkcnt) {
 		printf("%s: failed writing to device %d\n", __func__,
 		       dev_desc->dev);
-		fastboot_resp("FAILfailed writing to device");
+		fastboot_fail("failed writing to device");
 		return;
 	}
 
 	printf("........ wrote " LBAFU " bytes to '%s'\n", blkcnt *
 info->blksz, part_name);
-	fastboot_resp("OKAY");
+	fastboot_okay("");
 }
 
 void fb_mmc_flash_write(const char *cmd, void *download_buffer,
@@ -66,17 +74,22 @@ void fb_mmc_flash_write(const char *cmd, void
 *download_buffer, dev_desc = get_dev("mmc",

CONFIG_FASTBOOT_FLASH_MMC_DEV); if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) { printf("%s: invalid mmc device\n", __func__);

common/fb_mmc.c +1 -1
-		fastboot_resp("FAILinvalid mmc device");
+		fastboot_fail("invalid mmc device");
 		return;
 	}
 
 	ret = get_partition_info_efi_by_name(dev_desc, cmd, &info);
 	if (ret) {
 		printf("%s: cannot find partition: '%s'\n",

__func__, cmd);

common/fb_mmc.c +3 -3
-		fastboot_resp("FAILcannot find partition");
+		fastboot_fail("cannot find partition");
 		return;
 	}
 
-	write_raw_image(dev_desc, &info, cmd, download_buffer,
-			download_bytes);
+	if (is_sparse_image(download_buffer)) {
+		write_sparse_image(dev_desc, &info, cmd,

download_buffer,

common/fb_mmc.c +3 -0
+				   download_bytes);
+	} else {
+		write_raw_image(dev_desc, &info, cmd,

download_buffer,

common/fb_mmc.c

Quoted 2 lines
common/fb_mmc.c +2 -0
+				download_bytes);
+	}

In the above if parenthesis are not needed.

Quoted 1 line

}

Despite of this,

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
#11 lore raw

v5 cover Implement "fastboot flash" for eMMC

In reply to Steve Rae
Quoted 10 lines · Steve Rae

This series implements the "fastboot flash" command for eMMC devices. It supports both raw and sparse images.

NOTES:
- the support for the "fastboot flash" command is enabled with CONFIG_FASTBOOT_FLASH - the support for eMMC is enabled with CONFIG_FASTBOOT_FLASH_MMC_DEV - (future) the support for NAND would be enabled with CONFIG_FASTBOOT_FLASH_NAND(???)

This has been tested on ARMv7.

Lukasz, can you please pick this for this MW and send me a PR? Thanks!

Best regards,
Marek Vasut

#12 lore raw

v5 cover Implement "fastboot flash" for eMMC

Hi Marek,

Quoted 10 lines · Steve Rae
Quoted 9 lines

This series implements the "fastboot flash" command for eMMC devices. It supports both raw and sparse images.

NOTES:
- the support for the "fastboot flash" command is enabled with CONFIG_FASTBOOT_FLASH - the support for eMMC is enabled with CONFIG_FASTBOOT_FLASH_MMC_DEV - (future) the support for NAND would be enabled with CONFIG_FASTBOOT_FLASH_NAND(???)

Quoted 3 lines
Quoted 1 line

This has been tested on ARMv7.

Lukasz, can you please pick this for this MW and send me a PR? Thanks!

No problem, I can pull this code to u-boot-dfu tree.

However, since I've been CCed to this patch series very recently I'd like to look into this code closely as it goes through my tree.

I hope that nobody minds this :-)

Quoted 3 lines

Best regards,
Marek Vasut

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
#13 lore raw

v5 cover Implement "fastboot flash" for eMMC

Quoted 14 lines · Lukasz Majewski

Hi Marek,

Quoted 12 lines · Steve Rae
Quoted 10 lines

This series implements the "fastboot flash" command for eMMC devices. It supports both raw and sparse images.

NOTES:
- the support for the "fastboot flash" command is enabled with CONFIG_FASTBOOT_FLASH - the support for eMMC is enabled with CONFIG_FASTBOOT_FLASH_MMC_DEV - (future) the support for NAND would be enabled with CONFIG_FASTBOOT_FLASH_NAND(???)

This has been tested on ARMv7.

Quoted 8 lines
Quoted 1 line

Lukasz, can you please pick this for this MW and send me a PR? Thanks!

No problem, I can pull this code to u-boot-dfu tree.

However, since I've been CCed to this patch series very recently I'd like to look into this code closely as it goes through my tree.

I hope that nobody minds this :-)

Sure. Btw. trimming the CC list ...

Best regards,
Marek Vasut

#14 lore raw

v5 cover Implement "fastboot flash" for eMMC

In reply to Steve Rae

Hi Steve,

Quoted 10 lines

This series implements the "fastboot flash" command for eMMC devices. It supports both raw and sparse images.

NOTES:
- the support for the "fastboot flash" command is enabled with CONFIG_FASTBOOT_FLASH
- the support for eMMC is enabled with CONFIG_FASTBOOT_FLASH_MMC_DEV
- (future) the support for NAND would be enabled with CONFIG_FASTBOOT_FLASH_NAND(???)

Quoted 6 lines

This has been tested on ARMv7.

----

This series depends on:
http://patchwork.ozlabs.org/patch/379438/

This patch is already applied.

Quoted 1 line

http://patchwork.ozlabs.org/patch/382443/ (to 382446)

Could you resend the above patch series one more time?

From the links it seems that in PATCH 1/4 you add the ./common/aboot.c file and at PATCH 2/4 you remove it.

Is this done on purpose?

(I've also trimmed down the CC list).

Quoted 41 lines

Changes in v5:
- use the common/aboot.c for the "sparse format" handling

Changes in v4:
- rearranged this patchset so that "sparse_format.h" can be dropped (if we cannot resolve the copyright/licensing issues)
- update mmc_get_dev(...) to get_dev("mmc",....)
- update printf() to puts() where applicable
- update debug string as per feedback
- rearranged "sparse format" support in this patchset, in order to isolate...

Changes in v3:
- remove most references to 'mmc',
which leaves only one mmc specific function: mmc_get_dev()

Changes in v2:
- split large function into three
- improved handling of response messages
- additional partition size checking when writing sparse image
- update README.android-fastboot file
- new in v2

Steve Rae (4):
usb/gadget: fastboot: add eMMC support for flash command usb/gadget: fastboot: add support for flash command usb/gadget: fastboot: minor cleanup
usb/gadget: fastboot: implement sparse format

 README                          | 10 +++++
 common/Makefile                 |  6 +++
 common/cmd_fastboot.c           |  7 +--
 common/fb_mmc.c                 | 95
+++++++++++++++++++++++++++++++++++++++++
doc/README.android-fastboot     |  5 ++-
drivers/usb/gadget/f_fastboot.c | 44 +++++++++++++++++--
include/fb_mmc.h                |  8 ++++ 7 files changed, 166
insertions(+), 9 deletions(-) create mode 100644 common/fb_mmc.c
 create mode 100644 include/fb_mmc.h
Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
author
#15 lore raw

v5 cover Implement "fastboot flash" for eMMC

Quoted 12 lines · Lukasz Majewski

Hi Steve,

Quoted 10 lines

This series implements the "fastboot flash" command for eMMC devices. It supports both raw and sparse images.

NOTES:
- the support for the "fastboot flash" command is enabled with CONFIG_FASTBOOT_FLASH
- the support for eMMC is enabled with CONFIG_FASTBOOT_FLASH_MMC_DEV
- (future) the support for NAND would be enabled with CONFIG_FASTBOOT_FLASH_NAND(???)

Quoted 8 lines
Quoted 6 lines

This has been tested on ARMv7.

----

This series depends on:

   http://patchwork.ozlabs.org/patch/379438/

This patch is already applied.

Correct
(But it wasn't when I was preparing this....)

Quoted 9 lines
Quoted 2 lines
   http://patchwork.ozlabs.org/patch/382443/ (to 382446)

Could you resend the above patch series one more time?

From the links it seems that in PATCH 1/4 you add the ./common/aboot.c
file and at PATCH 2/4 you remove it.

Is this done on purpose?

yes: done on purpose (in order to see the history of the changes to the file....) -- see the comments in the cover letter to that patch-series!!!

Quoted 47 lines

(I've also trimmed down the CC list).

Quoted 41 lines

Changes in v5:
- use the common/aboot.c for the "sparse format" handling

Changes in v4:
- rearranged this patchset so that "sparse_format.h" can be dropped (if we cannot resolve the copyright/licensing issues)
- update mmc_get_dev(...) to get_dev("mmc",....)
- update printf() to puts() where applicable
- update debug string as per feedback
- rearranged "sparse format" support in this patchset, in order to isolate...

Changes in v3:
- remove most references to 'mmc',
which leaves only one mmc specific function: mmc_get_dev()

Changes in v2:
- split large function into three
- improved handling of response messages
- additional partition size checking when writing sparse image
- update README.android-fastboot file
- new in v2

Steve Rae (4):
usb/gadget: fastboot: add eMMC support for flash command usb/gadget: fastboot: add support for flash command usb/gadget: fastboot: minor cleanup
usb/gadget: fastboot: implement sparse format

  README                          | 10 +++++
  common/Makefile                 |  6 +++
  common/cmd_fastboot.c           |  7 +--
  common/fb_mmc.c                 | 95
+++++++++++++++++++++++++++++++++++++++++
doc/README.android-fastboot     |  5 ++-
drivers/usb/gadget/f_fastboot.c | 44 +++++++++++++++++--
include/fb_mmc.h                |  8 ++++ 7 files changed, 166

insertions(+), 9 deletions(-) create mode 100644 common/fb_mmc.c
create mode 100644 include/fb_mmc.h

Thanks, Steve

#16 lore raw

v5 cover Implement "fastboot flash" for eMMC

Hi Steve,

Quoted 32 lines · Lukasz Majewski
Quoted 13 lines

Hi Steve,

Quoted 11 lines

This series implements the "fastboot flash" command for eMMC devices. It supports both raw and sparse images.

NOTES:
- the support for the "fastboot flash" command is enabled with CONFIG_FASTBOOT_FLASH
- the support for eMMC is enabled with CONFIG_FASTBOOT_FLASH_MMC_DEV
- (future) the support for NAND would be enabled with CONFIG_FASTBOOT_FLASH_NAND(???)

Quoted 8 lines
Quoted 6 lines

This has been tested on ARMv7.

----

This series depends on:

   http://patchwork.ozlabs.org/patch/379438/

This patch is already applied.

Correct
(But it wasn't when I was preparing this....)

Quoted 5 lines
Quoted 2 lines
   http://patchwork.ozlabs.org/patch/382443/ (to 382446)

Could you resend the above patch series one more time?

Quoted 7 lines
Quoted 4 lines

From the links it seems that in PATCH 1/4 you add
the ./common/aboot.c file and at PATCH 2/4 you remove it.

Is this done on purpose?

yes: done on purpose (in order to see the history of the changes to the file....) -- see the comments in the cover letter to that patch-series!!!

Ok, Now it is clear.

Is fair as I know bsd-3L-clause license is compatible with GPL.

However, to be 100% sure I'd like to ask Tom (as he has much more legal experience than me) to confirm that this code can be added to u-boot.

Quoted 49 lines
Quoted 48 lines

(I've also trimmed down the CC list).

Quoted 41 lines

Changes in v5:
- use the common/aboot.c for the "sparse format" handling

Changes in v4:
- rearranged this patchset so that "sparse_format.h" can be dropped (if we cannot resolve the copyright/licensing issues)
- update mmc_get_dev(...) to get_dev("mmc",....)
- update printf() to puts() where applicable
- update debug string as per feedback
- rearranged "sparse format" support in this patchset, in order to isolate...

Changes in v3:
- remove most references to 'mmc',
which leaves only one mmc specific function: mmc_get_dev()

Changes in v2:
- split large function into three
- improved handling of response messages
- additional partition size checking when writing sparse image
- update README.android-fastboot file
- new in v2

Steve Rae (4):
usb/gadget: fastboot: add eMMC support for flash command usb/gadget: fastboot: add support for flash command usb/gadget: fastboot: minor cleanup
usb/gadget: fastboot: implement sparse format

  README                          | 10 +++++
  common/Makefile                 |  6 +++
  common/cmd_fastboot.c           |  7 +--
  common/fb_mmc.c                 | 95
+++++++++++++++++++++++++++++++++++++++++
doc/README.android-fastboot     |  5 ++-
drivers/usb/gadget/f_fastboot.c | 44 +++++++++++++++++--
include/fb_mmc.h                |  8 ++++ 7 files changed, 166

insertions(+), 9 deletions(-) create mode 100644 common/fb_mmc.c
create mode 100644 include/fb_mmc.h

Thanks, Steve

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
author
#17 lore raw

v5 cover Implement "fastboot flash" for eMMC

Quoted 42 lines · Lukasz Majewski

Hi Steve,

Quoted 32 lines · Lukasz Majewski
Quoted 13 lines

Hi Steve,

Quoted 11 lines

This series implements the "fastboot flash" command for eMMC devices. It supports both raw and sparse images.

NOTES:
- the support for the "fastboot flash" command is enabled with CONFIG_FASTBOOT_FLASH
- the support for eMMC is enabled with CONFIG_FASTBOOT_FLASH_MMC_DEV
- (future) the support for NAND would be enabled with CONFIG_FASTBOOT_FLASH_NAND(???)

Quoted 8 lines
Quoted 6 lines

This has been tested on ARMv7.

----

This series depends on:

    http://patchwork.ozlabs.org/patch/379438/

This patch is already applied.

Correct
(But it wasn't when I was preparing this....)

Quoted 5 lines
Quoted 2 lines
    http://patchwork.ozlabs.org/patch/382443/ (to 382446)

Could you resend the above patch series one more time?

Quoted 7 lines
Quoted 4 lines

From the links it seems that in PATCH 1/4 you add
the ./common/aboot.c file and at PATCH 2/4 you remove it.

Is this done on purpose?

yes: done on purpose (in order to see the history of the changes to the file....) -- see the comments in the cover letter to that patch-series!!!

Quoted 8 lines

Ok, Now it is clear.

Is fair as I know bsd-3L-clause license is compatible with GPL.

However, to be 100% sure I'd like to ask Tom (as he has much more legal experience than me) to confirm that this code can be added to u-boot.

OK -- note that this "bsd-3L-clause" clause is almost identical to the existing "bsd-3-clause"....
Thanks, Steve

Quoted 52 lines
Quoted 49 lines
Quoted 48 lines

(I've also trimmed down the CC list).

Quoted 41 lines

Changes in v5:
- use the common/aboot.c for the "sparse format" handling

Changes in v4:
- rearranged this patchset so that "sparse_format.h" can be dropped (if we cannot resolve the copyright/licensing issues)
- update mmc_get_dev(...) to get_dev("mmc",....)
- update printf() to puts() where applicable
- update debug string as per feedback
- rearranged "sparse format" support in this patchset, in order to isolate...

Changes in v3:
- remove most references to 'mmc',
which leaves only one mmc specific function: mmc_get_dev()

Changes in v2:
- split large function into three
- improved handling of response messages
- additional partition size checking when writing sparse image
- update README.android-fastboot file
- new in v2

Steve Rae (4):
usb/gadget: fastboot: add eMMC support for flash command usb/gadget: fastboot: add support for flash command usb/gadget: fastboot: minor cleanup usb/gadget: fastboot: implement sparse format

   README                          | 10 +++++
   common/Makefile                 |  6 +++
   common/cmd_fastboot.c           |  7 +--
   common/fb_mmc.c                 | 95
+++++++++++++++++++++++++++++++++++++++++
doc/README.android-fastboot     |  5 ++-
drivers/usb/gadget/f_fastboot.c | 44 +++++++++++++++++--
include/fb_mmc.h                |  8 ++++ 7 files changed, 166

insertions(+), 9 deletions(-) create mode 100644 common/fb_mmc.c
create mode 100644 include/fb_mmc.h

Thanks, Steve

#18 lore raw

v5 cover Implement "fastboot flash" for eMMC

Hi Steve,

Quoted 47 lines · Lukasz Majewski
Quoted 44 lines

Hi Steve,

Quoted 32 lines · Lukasz Majewski
Quoted 13 lines

Hi Steve,

Quoted 11 lines

This series implements the "fastboot flash" command for eMMC devices. It supports both raw and sparse images.

NOTES:
- the support for the "fastboot flash" command is enabled with CONFIG_FASTBOOT_FLASH
- the support for eMMC is enabled with CONFIG_FASTBOOT_FLASH_MMC_DEV
- (future) the support for NAND would be enabled with CONFIG_FASTBOOT_FLASH_NAND(???)

Quoted 8 lines
Quoted 6 lines

This has been tested on ARMv7.

----

This series depends on:

    http://patchwork.ozlabs.org/patch/379438/

This patch is already applied.

Correct
(But it wasn't when I was preparing this....)

Quoted 5 lines
Quoted 2 lines
    http://patchwork.ozlabs.org/patch/382443/ (to 382446)

Could you resend the above patch series one more time?

Quoted 7 lines
Quoted 4 lines

From the links it seems that in PATCH 1/4 you add
the ./common/aboot.c file and at PATCH 2/4 you remove it.

Is this done on purpose?

yes: done on purpose (in order to see the history of the changes to the file....) -- see the comments in the cover letter to that patch-series!!!

Ok, Now it is clear.

Quoted 8 lines
Quoted 6 lines

Is fair as I know bsd-3L-clause license is compatible with GPL.

However, to be 100% sure I'd like to ask Tom (as he has much more legal experience than me) to confirm that this code can be added to u-boot.

OK -- note that this "bsd-3L-clause" clause is almost identical to the existing "bsd-3-clause"....

Tom, could you give your opinion on this?

Quoted 53 lines

Thanks, Steve

Quoted 52 lines
Quoted 49 lines
Quoted 48 lines

(I've also trimmed down the CC list).

Quoted 41 lines

Changes in v5:
- use the common/aboot.c for the "sparse format" handling

Changes in v4:
- rearranged this patchset so that "sparse_format.h" can be dropped (if we cannot resolve the copyright/licensing issues)
- update mmc_get_dev(...) to get_dev("mmc",....)
- update printf() to puts() where applicable
- update debug string as per feedback
- rearranged "sparse format" support in this patchset, in order to isolate...

Changes in v3:
- remove most references to 'mmc',
which leaves only one mmc specific function: mmc_get_dev()

Changes in v2:
- split large function into three
- improved handling of response messages
- additional partition size checking when writing sparse image
- update README.android-fastboot file
- new in v2

Steve Rae (4):
usb/gadget: fastboot: add eMMC support for flash command usb/gadget: fastboot: add support for flash command usb/gadget: fastboot: minor cleanup usb/gadget: fastboot: implement sparse format

   README                          | 10 +++++
   common/Makefile                 |  6 +++
   common/cmd_fastboot.c           |  7 +--
   common/fb_mmc.c                 | 95
+++++++++++++++++++++++++++++++++++++++++
doc/README.android-fastboot     |  5 ++-
drivers/usb/gadget/f_fastboot.c | 44 +++++++++++++++++--
include/fb_mmc.h                |  8 ++++ 7 files changed, 166

insertions(+), 9 deletions(-) create mode 100644 common/fb_mmc.c
create mode 100644 include/fb_mmc.h

Thanks, Steve

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
#19 lore raw

v5 cover Implement "fastboot flash" for eMMC

Quoted 51 lines · Lukasz Majewski

Hi Steve,

Quoted 49 lines · Lukasz Majewski
Quoted 46 lines

Hi Steve,

Quoted 32 lines · Lukasz Majewski
Quoted 13 lines

Hi Steve,

Quoted 11 lines

This series implements the "fastboot flash" command for eMMC devices. It supports both raw and sparse images.

NOTES:
- the support for the "fastboot flash" command is enabled with CONFIG_FASTBOOT_FLASH
- the support for eMMC is enabled with CONFIG_FASTBOOT_FLASH_MMC_DEV
- (future) the support for NAND would be enabled with CONFIG_FASTBOOT_FLASH_NAND(???)

Quoted 8 lines
Quoted 6 lines

This has been tested on ARMv7.

----

This series depends on:

    http://patchwork.ozlabs.org/patch/379438/

This patch is already applied.

Correct
(But it wasn't when I was preparing this....)

Quoted 5 lines
Quoted 2 lines
    http://patchwork.ozlabs.org/patch/382443/ (to 382446)

Could you resend the above patch series one more time?

Quoted 7 lines
Quoted 4 lines

From the links it seems that in PATCH 1/4 you add
the ./common/aboot.c file and at PATCH 2/4 you remove it.

Is this done on purpose?

yes: done on purpose (in order to see the history of the changes to the file....) -- see the comments in the cover letter to that patch-series!!!

Ok, Now it is clear.

Is fair as I know bsd-3L-clause license is compatible with GPL.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

However, to be 100% sure I'd like to ask Tom (as he has much more legal experience than me) to confirm that this code can be added to u-boot.

OK -- note that this "bsd-3L-clause" clause is almost identical to the existing "bsd-3-clause"....

Tom, could you give your opinion on this?

So, upstream made a slight (and likely unintentional) change to the normal BSD 3 clause license and changed the last clause from "the copyright holders" to "The Linux Foundation". I've poked our legal dept about this but I suspect the best answer is to go back up to Android folks and ask them to fix this quite likely unintentional change.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140828/0cd7bf76/attachment.pgp>
author
#20 lore raw

v5 cover Implement "fastboot flash" for eMMC

Quoted 12 lines · Tom Rini
Quoted 11 lines · Lukasz Majewski

Hi Steve,

Quoted 9 lines · Lukasz Majewski
Quoted 6 lines

Hi Steve,

Quoted 4 lines · Lukasz Majewski

[.. snip ...]

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 7 lines

Is fair as I know bsd-3L-clause license is compatible with GPL.

However, to be 100% sure I'd like to ask Tom (as he has much more legal experience than me) to confirm that this code can be added to u-boot.

OK -- note that this "bsd-3L-clause" clause is almost identical to the existing "bsd-3-clause"....

Quoted 8 lines
Quoted 1 line

Tom, could you give your opinion on this?

So, upstream made a slight (and likely unintentional) change to the normal BSD 3 clause license and changed the last clause from "the copyright holders" to "The Linux Foundation". I've poked our legal dept about this but I suspect the best answer is to go back up to Android folks and ask them to fix this quite likely unintentional change.

Actually, there are three diffs, and I am thinking that they were intentional (especially the last one!):

$ diff bsd-3-clause.txt bsd-3L-clause.txt
5,6c5
<    notice, this list of conditions, and the following disclaimer,
<    without modification.
---
Quoted 1 line

notice, this list of conditions and the following disclaimer.

10,12c9,12
< 3. The names of the above-listed copyright holders may not be used
< to endorse or promote products derived from this software without
< specific prior written permission.
---

Quoted 4 lines

3. Neither the name of The Linux Foundation nor
the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

16,17c16,17
< THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR < PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
---

Quoted 1 line

THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR

PURPOSE AND

Quoted 1 line

NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR

So, would U-Boot accept this BSD-3L-Clause, or should I contact Colin Cross to attempt to get a BSD-3-Clause version, or ????

Thanks, Steve