[U-Boot] [PATCH v6 0/4] 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

- add support for 'fastboot flash' command for eMMC devices
Signed-off-by: Steve Rae srae@broadcom.com ---
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
diff --git a/common/Makefile b/common/Makefile index de5cce8..daebe39 100644 --- a/common/Makefile +++ b/common/Makefile @@ -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..14d3982 --- /dev/null +++ b/common/fb_mmc.c @@ -0,0 +1,80 @@ +/* + * 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, + 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)); + blkcnt = blkcnt / info->blksz; + + if (blkcnt > info->size) { + error("too large for partition: '%s'\n", part_name); + fastboot_resp("FAILtoo large for partition"); + return; + } + + puts("Flashing Raw Image\n"); + + blks = dev_desc->block_write(dev_desc->dev, info->start, blkcnt, + buffer); + if (blks != blkcnt) { + error("failed writing to device %d\n", dev_desc->dev); + fastboot_resp("FAILfailed writing to device"); + return; + } + + printf("........ wrote " LBAFU " bytes to '%s'\n", blkcnt * info->blksz, + part_name); + fastboot_resp("OKAY"); +} + +void fb_mmc_flash_write(const char *cmd, void *download_buffer, + unsigned int download_bytes, char *response) +{ + 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) { + error("invalid mmc device\n"); + fastboot_resp("FAILinvalid 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"); + return; + } + + write_raw_image(dev_desc, &info, cmd, download_buffer, + download_bytes); +} diff --git a/include/fb_mmc.h b/include/fb_mmc.h new file mode 100644 index 0000000..1ad1d13 --- /dev/null +++ b/include/fb_mmc.h @@ -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);

On Tue, Aug 26, 2014 at 11:47:27AM -0700, Steve Rae wrote:
- add support for 'fastboot flash' command for eMMC devices
Signed-off-by: Steve Rae srae@broadcom.com
Applied to u-boot/master, thanks!

- implement 'fastboot flash' for eMMC devices
Signed-off-by: Steve Rae srae@broadcom.com Acked-by: Lukasz Majewski l.majewski@samsung.com Reviewed-by: Marek Vasut marex@denx.de ---
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(-)
diff --git a/README b/README index 14d6b22..5e8c9ed 100644 --- a/README +++ b/README @@ -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 diff --git a/doc/README.android-fastboot b/doc/README.android-fastboot index 4045727..1677609 100644 --- a/doc/README.android-fastboot +++ b/doc/README.android-fastboot @@ -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 =================== diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 7a1acb9..e2659fa 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -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)

On Tue, Aug 26, 2014 at 11:47:28AM -0700, Steve Rae wrote:
- implement 'fastboot flash' for eMMC devices
Signed-off-by: Steve Rae srae@broadcom.com Acked-by: Lukasz Majewski l.majewski@samsung.com Reviewed-by: Marek Vasut marex@denx.de
Applied to u-boot/master, thanks!

- update static function - additional debugging statements - update "fastboot command" information - add missing include file - update spelling
Signed-off-by: Steve Rae srae@broadcom.com ---
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(-)
diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c index 83fa7bd..909616d 100644 --- a/common/cmd_fastboot.c +++ b/common/cmd_fastboot.c @@ -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" ); diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index e2659fa..38c0965 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -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';

On Tue, Aug 26, 2014 at 11:47:29AM -0700, Steve Rae wrote:
- update static function
- additional debugging statements
- update "fastboot command" information
- add missing include file
- update spelling
Signed-off-by: Steve Rae srae@broadcom.com
Applied to u-boot/master, thanks!

- add capability to "fastboot flash" with sparse format images
Signed-off-by: Steve Rae srae@broadcom.com Acked-by: Lukasz Majewski l.majewski@samsung.com ---
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(-)
diff --git a/common/Makefile b/common/Makefile index daebe39..bc53078 100644 --- a/common/Makefile +++ b/common/Makefile @@ -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
diff --git a/common/fb_mmc.c b/common/fb_mmc.c index 14d3982..fb06d8a 100644 --- a/common/fb_mmc.c +++ b/common/fb_mmc.c @@ -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); }

Hi
Il 26/ago/2014 20:46 "Steve Rae" srae@broadcom.com ha scritto:
- add capability to "fastboot flash" with sparse format images
Signed-off-by: Steve Rae srae@broadcom.com Acked-by: Lukasz Majewski l.majewski@samsung.com
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(-)
diff --git a/common/Makefile b/common/Makefile index daebe39..bc53078 100644 --- a/common/Makefile +++ b/common/Makefile @@ -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
diff --git a/common/fb_mmc.c b/common/fb_mmc.c index 14d3982..fb06d8a 100644 --- a/common/fb_mmc.c +++ b/common/fb_mmc.c @@ -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);
+}
Change not connect to bug description. If you remove static this should go in some header. For now it's only overhead.
+void fastboot_okay(const char *s) +{
strncpy(response_str, "OKAY", 4);
strncat(response_str, s, RESPONSE_LEN - 4 - 1);
}
Ditto
Michael
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);
}
1.8.5
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

Hi Michael
On 14-08-26 10:07 PM, Michael Trimarchi wrote:
Hi
Il 26/ago/2014 20:46 "Steve Rae" srae@broadcom.com ha scritto:
- add capability to "fastboot flash" with sparse format images
Signed-off-by: Steve Rae srae@broadcom.com Acked-by: Lukasz Majewski l.majewski@samsung.com
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(-)
diff --git a/common/Makefile b/common/Makefile index daebe39..bc53078 100644 --- a/common/Makefile +++ b/common/Makefile @@ -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
diff --git a/common/fb_mmc.c b/common/fb_mmc.c index 14d3982..fb06d8a 100644 --- a/common/fb_mmc.c +++ b/common/fb_mmc.c @@ -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);
+}
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
+void fastboot_okay(const char *s) +{
strncpy(response_str, "OKAY", 4);
}strncat(response_str, s, RESPONSE_LEN - 4 - 1);
Ditto
Michael
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);
-- 1.8.5
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

Hi
On Wed, Aug 27, 2014 at 7:43 PM, Steve Rae srae@broadcom.com wrote:
Hi Michael
On 14-08-26 10:07 PM, Michael Trimarchi wrote:
Hi
Il 26/ago/2014 20:46 "Steve Rae" srae@broadcom.com ha scritto:
- add capability to "fastboot flash" with sparse format images
Signed-off-by: Steve Rae srae@broadcom.com Acked-by: Lukasz Majewski l.majewski@samsung.com
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(-)
diff --git a/common/Makefile b/common/Makefile index daebe39..bc53078 100644 --- a/common/Makefile +++ b/common/Makefile @@ -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
diff --git a/common/fb_mmc.c b/common/fb_mmc.c index 14d3982..fb06d8a 100644 --- a/common/fb_mmc.c +++ b/common/fb_mmc.c @@ -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);
+}
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!
No it's fine. Sorry
Michael
Thanks, Steve
+void fastboot_okay(const char *s) +{
strncpy(response_str, "OKAY", 4);
}strncat(response_str, s, RESPONSE_LEN - 4 - 1);
Ditto
Michael
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);
-- 1.8.5
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

On Tue, Aug 26, 2014 at 11:47:30AM -0700, Steve Rae wrote:
- add capability to "fastboot flash" with sparse format images
Signed-off-by: Steve Rae srae@broadcom.com Acked-by: Lukasz Majewski l.majewski@samsung.com
Applied to u-boot/master, thanks!

Hi Tom,
On 14-08-26 11:47 AM, Steve Rae wrote:
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)
(which is now accepted)
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
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
participants (3)
-
Michael Trimarchi
-
Steve Rae
-
Tom Rini