Hi Sean,

On 2021-12-28 08:59, Sean Anderson wrote:
Hi Angus,

NXP's mfgtool queies the mmc blocksize and splits a sparse image into
blocksize size pieces for the upload.

It's still not clear to me why this is necessary. fastboot (for example)
transfers in blocks of max-download-size. Using the actual block size
seems like it would result in unnecessary overhead.


The version of uuu that we are using requires the block-size for the sparse upload

https://source.puri.sm/Librem5/mfgtools/-/blob/pureos/amber/libuuu/fastboot.cpp#L501

It looks like the upstream version will default to 4096 if the block-size is not provided

https://github.com/NXPmicro/mfgtools/blob/5397913ad97db422c1d70f314dedff4cb7d976b9/libuuu/fastboot.cpp#L642

Instead of making assumptions about the block size wouldn't it be better to provide one if requested ?

We could also remove that being a required parameter from the uuu that we are using but that still leaves versions out there that won't work with a mainline u-boot.

Thanks
Angus

--Sean

Signed-off-by: Angus Ainslie <an...@akkea.ca>
---
  drivers/fastboot/fb_getvar.c | 21 +++++++++++++++++++++
  1 file changed, 21 insertions(+)

diff --git a/drivers/fastboot/fb_getvar.c b/drivers/fastboot/fb_getvar.c
index d43f2cfee6..3cb72b8a54 100644
--- a/drivers/fastboot/fb_getvar.c
+++ b/drivers/fastboot/fb_getvar.c
@@ -26,6 +26,7 @@ static void getvar_has_slot(char *var_parameter, char *response);
  #endif
  #if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
  static void getvar_partition_type(char *part_name, char *response);
+static void getvar_logical_blocksize(char *var_parameter, char *response);
  #endif
  #if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
  static void getvar_partition_size(char *part_name, char *response);
@@ -72,6 +73,9 @@ static const struct {
        }, {
                .variable = "partition-type",
                .dispatch = getvar_partition_type
+       }, {
+               .variable = "logical-block-size",
+               .dispatch = getvar_logical_blocksize
  #endif
  #if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
        }, {
@@ -232,6 +236,23 @@ static void getvar_partition_type(char *part_name, char *response)
                        fastboot_okay(fs_get_type_name(), response);
        }
  }
+
+static void getvar_logical_blocksize(char *var_parameter, char *response)
+{
+       u32 blksz;
+       struct blk_desc *dev_desc;
+
+       dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
+
+       if (!dev_desc) {
+               pr_err("** Block device mmc %d not supported\n",
+                      CONFIG_FASTBOOT_FLASH_MMC_DEV);
+               fastboot_fail("Get logical_blocksize failed", response);
+               return;
+       }
+
+       fastboot_response("OKAY", response, "0x%08x", dev_desc->blksz);
+}
  #endif

  #if CONFIG_IS_ENABLED(FASTBOOT_FLASH)

Reply via email to