Re: [U-Boot] [PATCH v7 14/18] mmc: Separate "mmc swrite" from fastboot

2018-05-25 Thread Alex Kiernan
On Fri, May 25, 2018 at 3:42 AM Simon Glass  wrote:

> Hi Alex,

> On 24 May 2018 at 07:29, Alex Kiernan  wrote:
> >
> > Introduce CONFIG_IMAGE_SPARSE and CONFIG_CMD_MMC_SWRITE so the "mmc
> > swrite" command is separated from the fastboot code.
> >
> > Move image-sparse from common to lib so it's clear it's library code.
> >
> > Rename CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE to
CONFIG_IMAGE_SPARSE_FILLBUF_SIZE
> > and migrate it to Kconfig.
> >
> > Signed-off-by: Alex Kiernan 
> > Acked-by: Jassi Brar 
> > ---
> >
> > Changes in v7: None
> > Changes in v6: None
> > Changes in v5:
> > - rename CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE to
CONFIG_IMAGE_SPARSE_FILLBUF_SIZE
> >   and migrate it to Kconfig.
> >
> > Changes in v4:
> > - new
> >
> > Changes in v3: None
> > Changes in v2: None
> >
> >  cmd/Kconfig|  8 
> >  cmd/mmc.c  | 12 ++--
> >  common/Makefile|  1 -
> >  drivers/fastboot/Kconfig   |  1 +
> >  lib/Kconfig| 11 +++
> >  lib/Makefile   |  1 +
> >  {common => lib}/image-sparse.c |  6 +-
> >  scripts/config_whitelist.txt   |  1 -
> >  8 files changed, 28 insertions(+), 13 deletions(-)
> >  rename {common => lib}/image-sparse.c (97%)

> Reviewed-by: Simon Glass 

> I'm not 100% sure about moving image-sparce to lib/ but I suppose it is
OK.


My reasoning was it's really a compression mechanism, and thats where we
have the other compression stuff (I should probably have written this in
the commit message).

-- 
Alex Kiernan
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v7 14/18] mmc: Separate "mmc swrite" from fastboot

2018-05-25 Thread Simon Glass
Hi Alex,

On 24 May 2018 at 07:29, Alex Kiernan  wrote:
>
> Introduce CONFIG_IMAGE_SPARSE and CONFIG_CMD_MMC_SWRITE so the "mmc
> swrite" command is separated from the fastboot code.
>
> Move image-sparse from common to lib so it's clear it's library code.
>
> Rename CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE to CONFIG_IMAGE_SPARSE_FILLBUF_SIZE
> and migrate it to Kconfig.
>
> Signed-off-by: Alex Kiernan 
> Acked-by: Jassi Brar 
> ---
>
> Changes in v7: None
> Changes in v6: None
> Changes in v5:
> - rename CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE to 
> CONFIG_IMAGE_SPARSE_FILLBUF_SIZE
>   and migrate it to Kconfig.
>
> Changes in v4:
> - new
>
> Changes in v3: None
> Changes in v2: None
>
>  cmd/Kconfig|  8 
>  cmd/mmc.c  | 12 ++--
>  common/Makefile|  1 -
>  drivers/fastboot/Kconfig   |  1 +
>  lib/Kconfig| 11 +++
>  lib/Makefile   |  1 +
>  {common => lib}/image-sparse.c |  6 +-
>  scripts/config_whitelist.txt   |  1 -
>  8 files changed, 28 insertions(+), 13 deletions(-)
>  rename {common => lib}/image-sparse.c (97%)

Reviewed-by: Simon Glass 

I'm not 100% sure about moving image-sparce to lib/ but I suppose it is OK.

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 14/18] mmc: Separate "mmc swrite" from fastboot

2018-05-24 Thread Alex Kiernan
Introduce CONFIG_IMAGE_SPARSE and CONFIG_CMD_MMC_SWRITE so the "mmc
swrite" command is separated from the fastboot code.

Move image-sparse from common to lib so it's clear it's library code.

Rename CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE to CONFIG_IMAGE_SPARSE_FILLBUF_SIZE
and migrate it to Kconfig.

Signed-off-by: Alex Kiernan 
Acked-by: Jassi Brar 
---

Changes in v7: None
Changes in v6: None
Changes in v5:
- rename CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE to CONFIG_IMAGE_SPARSE_FILLBUF_SIZE
  and migrate it to Kconfig.

Changes in v4:
- new

Changes in v3: None
Changes in v2: None

 cmd/Kconfig|  8 
 cmd/mmc.c  | 12 ++--
 common/Makefile|  1 -
 drivers/fastboot/Kconfig   |  1 +
 lib/Kconfig| 11 +++
 lib/Makefile   |  1 +
 {common => lib}/image-sparse.c |  6 +-
 scripts/config_whitelist.txt   |  1 -
 8 files changed, 28 insertions(+), 13 deletions(-)
 rename {common => lib}/image-sparse.c (97%)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 91f6dfef92..98763c9108 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -826,6 +826,14 @@ config CMD_MMC
help
  MMC memory mapped support.
 
+config CMD_MMC_SWRITE
+   bool "mmc swrite"
+   depends on CMD_MMC && MMC_WRITE
+   select IMAGE_SPARSE
+   help
+ Enable support for the "mmc swrite" command to write Android sparse
+ images to eMMC.
+
 config CMD_NAND
bool "nand"
default y if NAND_SUNXI
diff --git a/cmd/mmc.c b/cmd/mmc.c
index cc445258c0..66c3ee008d 100644
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -308,8 +308,7 @@ static int do_mmc_read(cmd_tbl_t *cmdtp, int flag,
return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
 }
 
-#if CONFIG_IS_ENABLED(MMC_WRITE)
-#if defined(CONFIG_FASTBOOT_FLASH)
+#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE)
 static lbaint_t mmc_sparse_write(struct sparse_storage *info, lbaint_t blk,
 lbaint_t blkcnt, const void *buffer)
 {
@@ -374,6 +373,7 @@ static int do_mmc_sparse_write(cmd_tbl_t *cmdtp, int flag,
 }
 #endif
 
+#if CONFIG_IS_ENABLED(MMC_WRITE)
 static int do_mmc_write(cmd_tbl_t *cmdtp, int flag,
int argc, char * const argv[])
 {
@@ -868,10 +868,10 @@ static cmd_tbl_t cmd_mmc[] = {
U_BOOT_CMD_MKENT(read, 4, 1, do_mmc_read, "", ""),
 #if CONFIG_IS_ENABLED(MMC_WRITE)
U_BOOT_CMD_MKENT(write, 4, 0, do_mmc_write, "", ""),
-#if defined(CONFIG_FASTBOOT_FLASH)
-   U_BOOT_CMD_MKENT(swrite, 3, 0, do_mmc_sparse_write, "", ""),
-#endif
U_BOOT_CMD_MKENT(erase, 3, 0, do_mmc_erase, "", ""),
+#endif
+#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE)
+   U_BOOT_CMD_MKENT(swrite, 3, 0, do_mmc_sparse_write, "", ""),
 #endif
U_BOOT_CMD_MKENT(rescan, 1, 1, do_mmc_rescan, "", ""),
U_BOOT_CMD_MKENT(part, 1, 1, do_mmc_part, "", ""),
@@ -927,7 +927,7 @@ U_BOOT_CMD(
"info - display info of the current MMC device\n"
"mmc read addr blk# cnt\n"
"mmc write addr blk# cnt\n"
-#if defined(CONFIG_FASTBOOT_FLASH)
+#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE)
"mmc swrite addr blk#\n"
 #endif
"mmc erase blk# cnt\n"
diff --git a/common/Makefile b/common/Makefile
index 9ec40b9d27..b3da72ebb2 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -29,7 +29,6 @@ obj-$(CONFIG_CMD_BOOTI) += bootm.o bootm_os.o
 
 obj-$(CONFIG_CMD_BEDBUG) += bedbug.o
 obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o
-obj-$(CONFIG_FASTBOOT_FLASH) += image-sparse.o
 obj-$(CONFIG_MII) += miiphyutil.o
 obj-$(CONFIG_CMD_MII) += miiphyutil.o
 obj-$(CONFIG_PHYLIB) += miiphyutil.o
diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig
index 1d7caaff99..0c9ced53de 100644
--- a/drivers/fastboot/Kconfig
+++ b/drivers/fastboot/Kconfig
@@ -57,6 +57,7 @@ config FASTBOOT_FLASH
bool "Enable FASTBOOT FLASH command"
default y if ARCH_SUNXI
depends on MMC || (NAND && CMD_MTDPARTS)
+   select IMAGE_SPARSE
help
  The fastboot protocol includes a "flash" command for writing
  the downloaded image to a non-volatile storage device. Define
diff --git a/lib/Kconfig b/lib/Kconfig
index 1590f7afa4..15c6a52d4a 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -61,6 +61,17 @@ config SPL_STRTO
 config TPL_STRTO
bool
 
+config IMAGE_SPARSE
+   bool
+
+config IMAGE_SPARSE_FILLBUF_SIZE
+   hex "Android sparse image CHUNK_TYPE_FILL buffer size"
+   default 0x8
+   depends on IMAGE_SPARSE
+   help
+ Set the size of the fill buffer used when processing CHUNK_TYPE_FILL
+ chunks.
+
 config USE_PRIVATE_LIBGCC
bool "Use private libgcc"
depends on HAVE_PRIVATE_LIBGCC
diff --git a/lib/Makefile b/lib/Makefile
index d531ea54b3..a4bbe2fb48 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_FIT) += fdtdec_common.o
 obj-$(CONFIG_TEST_FDTDEC) +=