Skip to contentSkip to conversation

Implement "fastboot flash" for eMMC

PATCH Superseded Steve Rae 3 participants 13 messages Aug 26, 2014 – Sep 25, 2014 USB

lore
Share & tools
lore

Steve Rae

author
#0 lore raw

v6 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/382443/ (to 382446)

Changes in v6:
- printf() to error()
- fix spelling
- remove excess braces

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                 | 92 +++++++++++++++++++++++++++++++++++++++++
 doc/README.android-fastboot     |  5 ++-
 drivers/usb/gadget/f_fastboot.c | 44 ++++++++++++++++++--
 include/fb_mmc.h                |  8 ++++
 7 files changed, 163 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 v6 1/4 usb/gadget: fastboot: add eMMC support for flash command

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

---

Changes in v6:
- printf() to error()

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  | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/fb_mmc.h |  8 ++++++
 3 files changed, 93 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 +80 -0

80 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 v6 1/4 usb/gadget: fastboot: add eMMC support for flash command

Quoted 3 lines · Steve Rae

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

Applied to u-boot/master, thanks!

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/20140925/3db97729/attachment.pgp>
author
#3 lore raw

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

In reply to Steve Rae

- implement 'fastboot flash' for eMMC devices

---

Changes in v6:
- fix spelling

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 14d6b22..5e8c9ed 100644
@@ -1624,6 +1624,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 additional 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
#4 lore raw

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

Quoted 5 lines · Steve Rae

- implement 'fastboot flash' for eMMC devices

Applied to u-boot/master, thanks!

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/20140925/28646e34/attachment.pgp>
author
#5 lore raw

PATCH v6 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 v6:
- printf() to error()

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 | 15 ++++++++++-----
 2 files changed, 14 insertions(+), 8 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 +10 -5
index e2659fa..38c0965 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) {
+		error("missing variable\n");
 		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 {
+		error("unknown variable: %s\n", cmd);
 		strcpy(response, "FAILVariable not implemented");
 	}
 	fastboot_tx_write_str(response);
@@ -480,7 +483,7 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req)
 
 	strsep(&cmd, ":");
 	if (!cmd) {
-		printf("%s: missing partition name\n", __func__);
+		error("missing partition name\n");
 		fastboot_tx_write_str("FAILmissing partition name");
 		return;
 	}
@@ -534,10 +537,12 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req)
 		}
 	}
 
-	if (!func_cb)
+	if (!func_cb) {
+		error("unknown command: %s\n", 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
#6 lore raw

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

Quoted 7 lines · Steve Rae

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

Applied to u-boot/master, thanks!

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/20140925/67ed2717/attachment.pgp>
author
#7 lore raw

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

In reply to Steve Rae

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

---

Changes in v6:
- remove excess braces

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 | 32 ++++++++++++++++++++++----------
 2 files changed, 23 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 +22 -10
index 14d3982..fb06d8a 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,
@@ -32,7 +40,7 @@ static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info,
 
 	if (blkcnt > info->size) {
 		error("too large for partition: '%s'\n", part_name);
-		fastboot_resp("FAILtoo large for partition");
+		fastboot_fail("too large for partition");
 		return;
 	}
 
@@ -42,13 +50,13 @@ static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info,
 				     buffer);
 	if (blks != blkcnt) {
 		error("failed writing to device %d\n", 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,
@@ -64,17 +72,21 @@ 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) {
 		error("invalid mmc device\n");
-		fastboot_resp("FAILinvalid mmc device");
+		fastboot_fail("invalid mmc device");
 		return;
 	}
 
 	ret = get_partition_info_efi_by_name(dev_desc, cmd, &info);
 	if (ret) {
 		error("cannot find partition: '%s'\n", 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
#8 lore raw

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

Hi

Il 26/ago/2014 20:46 "Steve Rae" <[email protected]> ha scritto:

Quoted 7 lines

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

---

Quoted 8 lines

Changes in v6:
- remove excess braces

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...

Quoted 35 lines

Changes in v3: None
Changes in v2: None

 common/Makefile |  1 +
 common/fb_mmc.c | 32 ++++++++++++++++++++++----------
 2 files changed, 23 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 +2 -0
index 14d3982..fb06d8a 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;

common/fb_mmc.c line 23

Quoted 10 lines
common/fb_mmc.c +5 -3
 
-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);
+}
+

Change not connect to bug description. If you remove static this should go in some header. For now it's only overhead.

common/fb_mmc.c line 29

Quoted 6 lines
common/fb_mmc.c +4 -0
+void fastboot_okay(const char *s)
+{
+       strncpy(response_str, "OKAY", 4);
+       strncat(response_str, s, RESPONSE_LEN - 4 - 1);
 }
 

Ditto

Michael

common/fb_mmc.c line 30

Quoted 1 line
common/fb_mmc.c +0 -0
 static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t

*info,

common/fb_mmc.c static void write_raw_image(block_dev_desc_t *dev_desc,

Quoted 1 line
common/fb_mmc.c +0 -0
@@ -32,7 +40,7 @@ static void write_raw_image(block_dev_desc_t *dev_desc,

disk_partition_t *info,

common/fb_mmc.c static void write_raw_image(block_dev_desc_t

Quoted 9 lines
common/fb_mmc.c +1 -1
        if (blkcnt > info->size) {
                error("too large for partition: '%s'\n", part_name);
-               fastboot_resp("FAILtoo large for partition");
+               fastboot_fail("too large for partition");
                return;
        }
 
@@ -42,13 +50,13 @@ static void write_raw_image(block_dev_desc_t

*dev_desc, disk_partition_t *info,

common/fb_mmc.c static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info,

Quoted 9 lines
common/fb_mmc.c +1 -1
                                     buffer);
        if (blks != blkcnt) {
                error("failed writing to device %d\n", 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,

common/fb_mmc.c void fb_mmc_flash_write(const char *cmd, void

Quoted 7 lines
common/fb_mmc.c +1 -1
               part_name);
-       fastboot_resp("OKAY");
+       fastboot_okay("");
 }
 
 void fb_mmc_flash_write(const char *cmd, void *download_buffer,
@@ -64,17 +72,21 @@ void fb_mmc_flash_write(const char *cmd, void

*download_buffer,

Quoted 32 lines
common/fb_mmc.c +8 -5
        dev_desc = get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
        if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
                error("invalid mmc device\n");
-               fastboot_resp("FAILinvalid mmc device");
+               fastboot_fail("invalid mmc device");
                return;
        }
 
        ret = get_partition_info_efi_by_name(dev_desc, cmd, &info);
        if (ret) {
                error("cannot find partition: '%s'\n", 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);
 }
--

1.8.5

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

author
#9 lore raw

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

Hi Michael

Quoted 55 lines · Michael Trimarchi

Hi

Il 26/ago/2014 20:46 "Steve Rae" <[email protected]> ha scritto:

Quoted 7 lines

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

---

Quoted 8 lines

Changes in v6:
- remove excess braces

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...

Quoted 36 lines

Changes in v3: None
Changes in v2: None

  common/Makefile |  1 +
  common/fb_mmc.c | 32 ++++++++++++++++++++++----------
  2 files changed, 23 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 +2 -0
index 14d3982..fb06d8a 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;
 
Quoted 12 lines

common/fb_mmc.c line 23

Quoted 9 lines
common/fb_mmc.c +5 -3
-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);
+}
+

Change not connect to bug description. If you remove static this should go in some header. For now it's only overhead.

Sorry for the confusion....
(1) the file "include/aboot.h" defines these two functions, and is part of the patchset that this series depends on (as documented in the cover letter):

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

(2) this is the implementation of those functions that are required by that patchset
(3) so I thought the the commit message was sufficient -- implying that in order to implement the "sparse format" (from aboot.c) that these changes are required...
If required, I could submit a "v7" with more information in the commit message....
Please let me know!
Thanks, Steve

Quoted 77 lines

common/fb_mmc.c line 29

Quoted 7 lines
common/fb_mmc.c +4 -0
+void fastboot_okay(const char *s)
+{
+       strncpy(response_str, "OKAY", 4);
+       strncat(response_str, s, RESPONSE_LEN - 4 - 1);
  }
 

Ditto

Michael

common/fb_mmc.c line 30

Quoted 1 line
common/fb_mmc.c +0 -0
  static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t

*info,

common/fb_mmc.c static void write_raw_image(block_dev_desc_t *dev_desc,

Quoted 1 line
common/fb_mmc.c +0 -0
@@ -32,7 +40,7 @@ static void write_raw_image(block_dev_desc_t *dev_desc,

disk_partition_t *info,

common/fb_mmc.c static void write_raw_image(block_dev_desc_t

Quoted 9 lines
common/fb_mmc.c +1 -1
         if (blkcnt > info->size) {
                 error("too large for partition: '%s'\n", part_name);
-               fastboot_resp("FAILtoo large for partition");
+               fastboot_fail("too large for partition");
                 return;
         }
 
@@ -42,13 +50,13 @@ static void write_raw_image(block_dev_desc_t

*dev_desc, disk_partition_t *info,

common/fb_mmc.c static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info,

Quoted 9 lines
common/fb_mmc.c +1 -1
                                      buffer);
         if (blks != blkcnt) {
                 error("failed writing to device %d\n", 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,

common/fb_mmc.c void fb_mmc_flash_write(const char *cmd, void

Quoted 7 lines
common/fb_mmc.c +1 -1
                part_name);
-       fastboot_resp("OKAY");
+       fastboot_okay("");
  }
 
  void fb_mmc_flash_write(const char *cmd, void *download_buffer,
@@ -64,17 +72,21 @@ void fb_mmc_flash_write(const char *cmd, void

*download_buffer,

Quoted 32 lines
common/fb_mmc.c +8 -5
         dev_desc = get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
         if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
                 error("invalid mmc device\n");
-               fastboot_resp("FAILinvalid mmc device");
+               fastboot_fail("invalid mmc device");
                 return;
         }
 
         ret = get_partition_info_efi_by_name(dev_desc, cmd, &info);
         if (ret) {
                 error("cannot find partition: '%s'\n", 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);
  }
--

1.8.5

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

#10 lore raw

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

Hi

Quoted 78 lines · Steve Rae

Hi Michael

Quoted 59 lines · Michael Trimarchi

Hi

Il 26/ago/2014 20:46 "Steve Rae" <[email protected]> ha scritto:

Quoted 8 lines

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

---

Quoted 8 lines

Changes in v6:
- remove excess braces

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...

Quoted 37 lines

Changes in v3: None
Changes in v2: None

  common/Makefile |  1 +
  common/fb_mmc.c | 32 ++++++++++++++++++++++----------
  2 files changed, 23 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 +2 -0
index 14d3982..fb06d8a 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;
 
Quoted 13 lines

common/fb_mmc.c line 23

Quoted 9 lines
common/fb_mmc.c +5 -3
-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);
+}
+

Change not connect to bug description. If you remove static this should go in some header. For now it's only overhead.

Quoted 14 lines

Sorry for the confusion....
(1) the file "include/aboot.h" defines these two functions, and is part of the patchset that this series depends on (as documented in the cover letter):
This series depends on:
http://patchwork.ozlabs.org/patch/382443/ (to 382446)
(2) this is the implementation of those functions that are required by that patchset
(3) so I thought the the commit message was sufficient -- implying that in order to implement the "sparse format" (from aboot.c) that these changes are required...
If required, I could submit a "v7" with more information in the commit message....
Please let me know!

No it's fine. Sorry

Michael

Quoted 93 lines

Thanks, Steve

Quoted 89 lines

common/fb_mmc.c line 29

Quoted 7 lines
common/fb_mmc.c +4 -0
+void fastboot_okay(const char *s)
+{
+       strncpy(response_str, "OKAY", 4);
+       strncat(response_str, s, RESPONSE_LEN - 4 - 1);
  }
 

Ditto

Michael

Quoted 2 lines
common/fb_mmc.c +0 -0
  static void write_raw_image(block_dev_desc_t *dev_desc,

disk_partition_t

*info,

common/fb_mmc.c static void write_raw_image(block_dev_desc_t *dev_desc,

Quoted 2 lines
common/fb_mmc.c +0 -0
@@ -32,7 +40,7 @@ static void write_raw_image(block_dev_desc_t *dev_desc,

disk_partition_t *info,

common/fb_mmc.c static void write_raw_image(block_dev_desc_t

Quoted 10 lines
common/fb_mmc.c +1 -1
         if (blkcnt > info->size) {
                 error("too large for partition: '%s'\n", part_name);
-               fastboot_resp("FAILtoo large for partition");
+               fastboot_fail("too large for partition");
                 return;
         }
 
@@ -42,13 +50,13 @@ static void write_raw_image(block_dev_desc_t

*dev_desc, disk_partition_t *info,

common/fb_mmc.c static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info,

Quoted 10 lines
common/fb_mmc.c +1 -1
                                      buffer);
         if (blks != blkcnt) {
                 error("failed writing to device %d\n", 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,

common/fb_mmc.c void fb_mmc_flash_write(const char *cmd, void

Quoted 8 lines
common/fb_mmc.c +1 -1
                part_name);
-       fastboot_resp("OKAY");
+       fastboot_okay("");
  }
 
  void fb_mmc_flash_write(const char *cmd, void *download_buffer,
@@ -64,17 +72,21 @@ void fb_mmc_flash_write(const char *cmd, void

*download_buffer,

Quoted 33 lines
common/fb_mmc.c +8 -5
         dev_desc = get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
         if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
                 error("invalid mmc device\n");
-               fastboot_resp("FAILinvalid mmc device");
+               fastboot_fail("invalid mmc device");
                 return;
         }
 
         ret = get_partition_info_efi_by_name(dev_desc, cmd, &info);
         if (ret) {
                 error("cannot find partition: '%s'\n", 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);
  }
--

1.8.5

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

Signature · 4 lines
| Michael Nazzareno Trimarchi                     Amarula Solutions BV |
| COO  -  Founder                                      Cruquiuskade 47 |
| +31(0)851119172                                 Amsterdam 1018 AM NL |
|                  [`as] http://www.amarulasolutions.com               |
#11 lore raw

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

In reply to Steve Rae
Quoted 4 lines · Steve Rae

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

Applied to u-boot/master, thanks!

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/20140925/5b0b1331/attachment.pgp>
author
#12 lore raw

v6 cover Implement "fastboot flash" for eMMC

In reply to Steve Rae

Hi Tom,

Quoted 8 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(???)

Quoted 6 lines

This has been tested on ARMv7.

----

This series depends on:

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

(which is now accepted)

Quoted 42 lines

Changes in v6:
- printf() to error()
- fix spelling
- remove excess braces

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                 | 92 +++++++++++++++++++++++++++++++++++++++++
  doc/README.android-fastboot     |  5 ++-
  drivers/usb/gadget/f_fastboot.c | 44 ++++++++++++++++++--
  include/fb_mmc.h                |  8 ++++
  7 files changed, 163 insertions(+), 9 deletions(-)
Quoted 3 lines

create mode 100644 common/fb_mmc.c
create mode 100644 include/fb_mmc.h

I assume that because of all the churn with the "Android sparse image" (BTW - thanks for accepting it...) it seems that this patchset got incorrectly marked as superseded in "Patchwork". I have corrected its status (to NEW).
Can this please be pulled ASAP! ?!?!?
Thanks in advance, Steve