Skip to contentSkip to conversation

Add more support for NXP's mfgtool

PATCH Superseded Angus Ainslie 3 participants 9 messages Dec 17, 2021 – Dec 19, 2021

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Add more support for NXP's mfgtool

NXP's mfgtool needs some additional switches to deal with the whole mmc device.

Angus Ainslie (2):
fastboot: fb_getvar: Add getvar_logical_blocksize for MXP mfgtool
fastboot: fb_mmc: Add mfgtool all partition size

 drivers/fastboot/fb_getvar.c | 27 +++++++++++++++++++++++++++
 drivers/fastboot/fb_mmc.c    |  7 +++++++
 2 files changed, 34 insertions(+)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/2 fastboot: fb_getvar: Add getvar_logical_blocksize for MXP mfgtool

uuu uses the blocksize to determine the upload size

---
 drivers/fastboot/fb_getvar.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
drivers/fastboot/fb_getvar.c +27 -0
index d43f2cfee6..ff5f0d3d40 100644
@@ -31,6 +31,7 @@ static void getvar_partition_type(char *part_name, char *response);
 static void getvar_partition_size(char *part_name, char *response);
 #endif
 static void getvar_is_userspace(char *var_parameter, char *response);
+static void getvar_logical_blocksize(char *var_parameter, char *response);
 
 static const struct {
 	const char *variable;
@@ -81,6 +82,9 @@ static const struct {
 	}, {
 		.variable = "is-userspace",
 		.dispatch = getvar_is_userspace
+	}, {
+		.variable = "logical-block-size",
+		.dispatch = getvar_logical_blocksize
 	}
 };
 
@@ -140,6 +144,29 @@ static void getvar_downloadsize(char *var_parameter, char *response)
 	fastboot_response("OKAY", response, "0x%08x", fastboot_buf_size);
 }
 
+static int fb_get_block_size(void)
+{
+	int dev_no = 0;
+	struct blk_desc *dev_desc;
+
+	dev_desc = blk_get_dev("mmc", 0);
+
+	if (!dev_desc) {
+		printf("** Block device %s %d not supported\n",
+		       "mmc", 0);
+		return 0;
+	}
+	return dev_desc->blksz;
+}
+
+static void getvar_logical_blocksize(char *var_parameter, char *response)
+{
+	u32 blksz;
+
+	blksz = fb_get_block_size();
+	fastboot_response("OKAY", response, "0x%08x", blksz);
+}
+
 static void getvar_serialno(char *var_parameter, char *response)
 {
 	const char *tmp = env_get("serial#");
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH 1/2] fastboot: fb_getvar: Add getvar_logical_blocksize for MXP mfgtool

Hi Angus,

Quoted 1 line · Angus Ainslie

uuu uses the blocksize to determine the upload size

Can you please elaborate on this more?

Quoted 29 lines
---
  drivers/fastboot/fb_getvar.c | 27 +++++++++++++++++++++++++++
  1 file changed, 27 insertions(+)
drivers/fastboot/fb_getvar.c +4 -0
index d43f2cfee6..ff5f0d3d40 100644
@@ -31,6 +31,7 @@ static void getvar_partition_type(char *part_name, char *response);
  static void getvar_partition_size(char *part_name, char *response);
  #endif
  static void getvar_is_userspace(char *var_parameter, char *response);
+static void getvar_logical_blocksize(char *var_parameter, char *response);
 
  static const struct {
  	const char *variable;
@@ -81,6 +82,9 @@ static const struct {
  	}, {
  		.variable = "is-userspace",
  		.dispatch = getvar_is_userspace
+	}, {
+		.variable = "logical-block-size",
+		.dispatch = getvar_logical_blocksize
  	}
  };
 

drivers/fastboot/fb_getvar.c static void getvar_downloadsize(char *var_parameter, char *response) · line 152

Quoted 9 lines
drivers/fastboot/fb_getvar.c +6 -0
@@ -140,6 +144,29 @@ static void getvar_downloadsize(char *var_parameter, char *response)
  	fastboot_response("OKAY", response, "0x%08x", fastboot_buf_size);
  }
 
+static int fb_get_block_size(void)
+{
+	int dev_no = 0;
+	struct blk_desc *dev_desc;
+
+	dev_desc = blk_get_dev("mmc", 0);

And what if your block device is not mmc 0? This code is not specific to fastboot mmc. What about nand?

drivers/fastboot/fb_getvar.c static void getvar_downloadsize(char *var_parameter, char *response) · line 157

Quoted 5 lines
drivers/fastboot/fb_getvar.c +5 -0
+
+	if (!dev_desc) {
+		printf("** Block device %s %d not supported\n",
+		       "mmc", 0);
+		return 0;

Why return 0? This should result in an error fastboot_response.

drivers/fastboot/fb_getvar.c static void getvar_downloadsize(char *var_parameter, char *response) · line 167

Quoted 10 lines
drivers/fastboot/fb_getvar.c +10 -0
+	}
+	return dev_desc->blksz;
+}
+
+static void getvar_logical_blocksize(char *var_parameter, char *response)
+{
+	u32 blksz;
+
+	blksz = fb_get_block_size();
+	fastboot_response("OKAY", response, "0x%08x", blksz);

Can we combine these functions?

--Sean

Quoted 6 lines
drivers/fastboot/fb_getvar.c +2 -0
+}
+
  static void getvar_serialno(char *var_parameter, char *response)
  {
  	const char *tmp = env_get("serial#");
#3 lore raw

Re: [PATCH 1/2] fastboot: fb_getvar: Add getvar_logical_blocksize for MXP mfgtool

Hi Sean,

Quoted 72 lines · Sean Anderson

Hi Angus,

Quoted 1 line · Angus Ainslie

uuu uses the blocksize to determine the upload size

Can you please elaborate on this more?

Quoted 34 lines
---
  drivers/fastboot/fb_getvar.c | 27 +++++++++++++++++++++++++++
  1 file changed, 27 insertions(+)
drivers/fastboot/fb_getvar.c +1 -0
index d43f2cfee6..ff5f0d3d40 100644
@@ -31,6 +31,7 @@ static void getvar_partition_type(char *part_name, 
 char *response);
  static void getvar_partition_size(char *part_name, char *response);
  #endif
  static void getvar_is_userspace(char *var_parameter, char 
 *response);
+static void getvar_logical_blocksize(char *var_parameter, char 
 *response);
    static const struct {

const char *variable;

drivers/fastboot/fb_getvar.c +3 -0
@@ -81,6 +82,9 @@ static const struct {
  	}, {
  		.variable = "is-userspace",
  		.dispatch = getvar_is_userspace
+	}, {
+		.variable = "logical-block-size",
+		.dispatch = getvar_logical_blocksize
  	}
  };
  @@ -140,6 +144,29 @@ static void getvar_downloadsize(char 

*var_parameter, char *response)
fastboot_response("OKAY", response, "0x%08x", fastboot_buf_size);
}
+static int fb_get_block_size(void)

drivers/fastboot/fb_getvar.c static void getvar_downloadsize(char *var_parameter, char *response) · line 152

Quoted 5 lines
drivers/fastboot/fb_getvar.c +5 -0
+{
+	int dev_no = 0;
+	struct blk_desc *dev_desc;
+
+	dev_desc = blk_get_dev("mmc", 0);

And what if your block device is not mmc 0? This code is not specific to fastboot mmc. What about nand?

drivers/fastboot/fb_getvar.c static void getvar_downloadsize(char *var_parameter, char *response) · line 157

Quoted 5 lines
drivers/fastboot/fb_getvar.c +5 -0
+
+	if (!dev_desc) {
+		printf("** Block device %s %d not supported\n",
+		       "mmc", 0);
+		return 0;

Why return 0? This should result in an error fastboot_response.

drivers/fastboot/fb_getvar.c static void getvar_downloadsize(char *var_parameter, char *response) · line 167

Quoted 11 lines
drivers/fastboot/fb_getvar.c +5 -0
+	}
+	return dev_desc->blksz;
+}
+
+static void getvar_logical_blocksize(char *var_parameter, char 

*response)

drivers/fastboot/fb_getvar.c +5 -0
+{
+	u32 blksz;
+
+	blksz = fb_get_block_size();
+	fastboot_response("OKAY", response, "0x%08x", blksz);

Can we combine these functions?

Quoted 1 line

--Sean

Thanks for the comments. I'll fix them up for v2.

Angus

Quoted 7 lines
Quoted 7 lines
drivers/fastboot/fb_getvar.c +2 -0
+}
+
  static void getvar_serialno(char *var_parameter, char *response)
  {
  	const char *tmp = env_get("serial#");
#4 lore raw

PATCH 2/2 fastboot: fb_mmc: Add mfgtool all partition size

In reply to Angus Ainslie

NXP mfgtool uses all to specify the entire partition

---
 drivers/fastboot/fb_mmc.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/fastboot/fb_mmc.c +7 -0
index 2738dc836e..9ebf392252 100644
@@ -84,6 +84,13 @@ static int do_get_part_info(struct blk_desc **dev_desc, const char *name,
 	/* First try partition names on the default device */
 	*dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
 	if (*dev_desc) {
+		if (!strncmp(name, "all", strlen("all"))) {
+			info->blksz = (*dev_desc)->blksz;
+			info->size = (*dev_desc)->lba;
+			info->start = 0;
+			return 0;
+		}
+
 		ret = part_get_info_by_name(*dev_desc, name, info);
 		if (ret >= 0)
 			return ret;
Signature · 1 line
2.25.1
#5 lore raw

Re: [PATCH 2/2] fastboot: fb_mmc: Add mfgtool all partition size

Quoted 16 lines · Angus Ainslie

NXP mfgtool uses all to specify the entire partition

---
  drivers/fastboot/fb_mmc.c | 7 +++++++
  1 file changed, 7 insertions(+)
drivers/fastboot/fb_mmc.c +0 -0
index 2738dc836e..9ebf392252 100644
@@ -84,6 +84,13 @@ static int do_get_part_info(struct blk_desc **dev_desc, const char *name,
  	/* First try partition names on the default device */
  	*dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
  	if (*dev_desc) {

drivers/fastboot/fb_mmc.c static int do_get_part_info(struct blk_desc **dev_desc, const char *name, · line 96

Quoted 10 lines
drivers/fastboot/fb_mmc.c +7 -0
+		if (!strncmp(name, "all", strlen("all"))) {
+			info->blksz = (*dev_desc)->blksz;
+			info->size = (*dev_desc)->lba;
+			info->start = 0;
+			return 0;
+		}
+
  		ret = part_get_info_by_name(*dev_desc, name, info);
  		if (ret >= 0)
  			return ret;

This can be done with "partition" 0. If you need compatibility, use an alias.

--Sean

#6 lore raw
In reply to Angus Ainslie

Hello Angus!
What is the use-case for these patches?

Would you mind defining why the current implementation is not enough? Used like that:

Quoted 19 lines

FB: flash -raw2sparse mmc0 emmc.wic

17 груд. 2021 р. о 17:41 Angus Ainslie <[email protected]> написав(ла):

NXP's mfgtool needs some additional switches to deal with the whole mmc device.

Angus Ainslie (2):
fastboot: fb_getvar: Add getvar_logical_blocksize for MXP mfgtool
fastboot: fb_mmc: Add mfgtool all partition size

drivers/fastboot/fb_getvar.c | 27 +++++++++++++++++++++++++++
drivers/fastboot/fb_mmc.c | 7 +++++++

2 files changed, 34 insertions(+)
Signature · 1 line
2.25.1
#7 lore raw

Hi Oleh

Quoted 8 lines · Oleh Kravchenko

Hello Angus!
What is the use-case for these patches?

Would you mind defining why the current implementation is not enough? Used like that:

Quoted 1 line

FB: flash -raw2sparse mmc0 emmc.wic

Thanks, it looks like the way I'm using fastboot is causing the issue.

FB: ucmd setenv fastboot_dev mmc
FB: ucmd setenv mmcdev 0
FB: flash -raw2sparse all <image>

using your syntax I likely won't need these patches.

FB: flash -raw2sparse mmc0 <image>

Cheers
Angus

#8 lore raw

18.12.21 16:34, Angus Ainslie пише:

Quoted 12 lines

Hi Oleh

Quoted 8 lines · Oleh Kravchenko

Hello Angus!
What is the use-case for these patches?

Would you mind defining why the current implementation is not enough? Used like that:

Quoted 1 line

FB: flash -raw2sparse mmc0 emmc.wic

Quoted 7 lines

Thanks, it looks like the way I'm using fastboot is causing the issue.

FB: ucmd setenv fastboot_dev mmc
FB: ucmd setenv mmcdev 0
FB: flash -raw2sparse all <image>

using your syntax I likely won't need these patches.

Just make sure you have these configs enabled:

Quoted 8 lines

CONFIG_FASTBOOT_MMC_USER_SUPPORT=y
CONFIG_FASTBOOT_MMC_BOOT_SUPPORT=y # enable this if you planning flash boot area too

FB: flash -raw2sparse mmc0 <image>

Cheers
Angus

Signature · 2 lines
Best regards,
Oleh Kravchenko