Skip to contentSkip to conversation

dfu: dfu_sf: Add support for multiple flashes

PATCH In review Marek Vasut 2 participants 6 messages Oct 5, 2021

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 dfu: dfu_sf: Add support for multiple flashes

Add dfu_alt_info option which allows specifying multiple SPI flashes as an alt info. The syntax is as follows:

altname sf bus:cs[:speed[:mode]]

Example:
dfu_alt_info=qspi0 sf 0:0;qspi1 sf 0:1

Cc Lukasz Majewski <[email protected]>

---
V2: Fix device string parsing in all cases

---
 drivers/dfu/dfu_sf.c | 31 ++++++++++++++++++++++++-------
 1 file changed, 24 insertions(+), 7 deletions(-)
drivers/dfu/dfu_sf.c +24 -7
index b72493ced86..6d33497990a 100644
@@ -168,30 +168,46 @@ static struct spi_flash *parse_dev(char *devstr)
 int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr, char *s)
 {
 	char *st;
-	char *devstr_bkup = strdup(devstr);
-
-	dfu->data.sf.dev = parse_dev(devstr_bkup);
-	free(devstr_bkup);
-	if (!dfu->data.sf.dev)
-		return -ENODEV;
 
 	dfu->dev_type = DFU_DEV_SF;
-	dfu->max_buf_size = dfu->data.sf.dev->sector_size;
 
 	st = strsep(&s, " ");
 	if (!strcmp(st, "raw")) {
+		char *devstr_bkup = strdup(devstr);
+		dfu->data.sf.dev = parse_dev(devstr_bkup);
+		free(devstr_bkup);
+		if (!dfu->data.sf.dev)
+			return -ENODEV;
+
 		dfu->layout = DFU_RAW_ADDR;
+		dfu->max_buf_size = dfu->data.sf.dev->sector_size;
 		dfu->data.sf.start = hextoul(s, &s);
 		s++;
 		dfu->data.sf.size = hextoul(s, &s);
+	} else if (!strcmp(st, "sf")) {
+		st = strsep(&s, " ");
+		dfu->data.sf.dev = parse_dev(st);
+		if (!dfu->data.sf.dev)
+			return -ENODEV;
+
+		dfu->layout = DFU_RAW_ADDR;
+		dfu->max_buf_size = dfu->data.sf.dev->sector_size;
+		dfu->data.sf.start = 0;
+		dfu->data.sf.size = dfu->data.sf.dev->size;
 	} else if (CONFIG_IS_ENABLED(DFU_SF_PART) &&
 		   (!strcmp(st, "part") || !strcmp(st, "partubi"))) {
+		char *devstr_bkup = strdup(devstr);
 		char mtd_id[32];
 		struct mtd_device *mtd_dev;
 		u8 part_num;
 		struct part_info *pi;
 		int ret, dev, part;
 
+		dfu->data.sf.dev = parse_dev(devstr_bkup);
+		free(devstr_bkup);
+		if (!dfu->data.sf.dev)
+			return -ENODEV;
+
 		dfu->layout = DFU_RAW_ADDR;
 
 		dev = dectoul(s, &s);
@@ -208,6 +224,7 @@ int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr, char *s)
 			printf("Could not locate '%s'\n", mtd_id);
 			return -1;
 		}
+		dfu->max_buf_size = dfu->data.sf.dev->sector_size;
 		dfu->data.sf.start = pi->offset;
 		dfu->data.sf.size = pi->size;
 		if (!strcmp(st, "partubi"))
Signature · 1 line
2.33.0
#1 lore raw

Hi Marek,

ST Restricted

Quoted 8 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Marek Vasut
Sent: mardi 5 octobre 2021 14:40
To: [email protected]
Cc: Marek Vasut <[email protected]>; Lukasz Majewski <[email protected]>
Subject: [PATCH v2] dfu: dfu_sf: Add support for multiple flashes

Add dfu_alt_info option which allows specifying multiple SPI flashes as an

alt info.

drivers/dfu/dfu_sf.c static struct spi_flash *parse_dev(char *devstr)

Quoted 20 lines

The syntax is as follows:

altname sf bus:cs[:speed[:mode]]

Example:
dfu_alt_info=qspi0 sf 0:0;qspi1 sf 0:1

Cc Lukasz Majewski <[email protected]>

---
V2: Fix device string parsing in all cases

---
 drivers/dfu/dfu_sf.c | 31 ++++++++++++++++++++++++-------
 1 file changed, 24 insertions(+), 7 deletions(-)
drivers/dfu/dfu_sf.c index renamed from drivers/dfu/dfu_sf.c +0 -0

b72493ced86..6d33497990a 100644

drivers/dfu/dfu_sf.c +0 -0
@@ -168,30 +168,46 @@ static struct spi_flash *parse_dev(char *devstr)

int

drivers/dfu/dfu_sf.c int dfu_fill_entity_sf(struct dfu_entity *dfu, char

Quoted 53 lines
drivers/dfu/dfu_sf.c +23 -7
 dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr, char *s)  {
 	char *st;
-	char *devstr_bkup = strdup(devstr);
-
-	dfu->data.sf.dev = parse_dev(devstr_bkup);
-	free(devstr_bkup);
-	if (!dfu->data.sf.dev)
-		return -ENODEV;
 
 	dfu->dev_type = DFU_DEV_SF;
-	dfu->max_buf_size = dfu->data.sf.dev->sector_size;
 
 	st = strsep(&s, " ");
 	if (!strcmp(st, "raw")) {
+		char *devstr_bkup = strdup(devstr);
+		dfu->data.sf.dev = parse_dev(devstr_bkup);
+		free(devstr_bkup);
+		if (!dfu->data.sf.dev)
+			return -ENODEV;
+
 		dfu->layout = DFU_RAW_ADDR;
+		dfu->max_buf_size = dfu->data.sf.dev->sector_size;
 		dfu->data.sf.start = hextoul(s, &s);
 		s++;
 		dfu->data.sf.size = hextoul(s, &s);
+	} else if (!strcmp(st, "sf")) {
+		st = strsep(&s, " ");
+		dfu->data.sf.dev = parse_dev(st);
+		if (!dfu->data.sf.dev)
+			return -ENODEV;
+
+		dfu->layout = DFU_RAW_ADDR;
+		dfu->max_buf_size = dfu->data.sf.dev->sector_size;
+		dfu->data.sf.start = 0;
+		dfu->data.sf.size = dfu->data.sf.dev->size;
 	} else if (CONFIG_IS_ENABLED(DFU_SF_PART) &&
 		   (!strcmp(st, "part") || !strcmp(st, "partubi"))) {
+		char *devstr_bkup = strdup(devstr);
 		char mtd_id[32];
 		struct mtd_device *mtd_dev;
 		u8 part_num;
 		struct part_info *pi;
 		int ret, dev, part;
 
+		dfu->data.sf.dev = parse_dev(devstr_bkup);
+		free(devstr_bkup);
+		if (!dfu->data.sf.dev)
+			return -ENODEV;
+
 		dfu->layout = DFU_RAW_ADDR;
 
 		dev = dectoul(s, &s);
@@ -208,6 +224,7 @@ int dfu_fill_entity_sf(struct dfu_entity *dfu, char

*devstr,

Quoted 10 lines
drivers/dfu/dfu_sf.c +1 -0
 char *s)
 			printf("Could not locate '%s'\n", mtd_id);
 			return -1;
 		}
+		dfu->max_buf_size = dfu->data.sf.dev->sector_size;
 		dfu->data.sf.start = pi->offset;
 		dfu->data.sf.size = pi->size;

if (!strcmp(st, "partubi"))
--
2.33.0

The same use case can be supported with mtd backend

https://elixir.bootlin.com/u-boot/latest/source/doc/usage/dfu.rst

U-Boot> env set dfu_alt_info \
"mtd nor0=spl part 1;u-boot part 2;u-boot-env part 3&"\
"mtd nand0=UBI partubi 1"

#2 lore raw
Quoted 102 lines · On 10/5/21 2:50 PM, [email protected] wrote:

Hi Marek,

ST Restricted

Quoted 8 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Marek Vasut
Sent: mardi 5 octobre 2021 14:40
To: [email protected]
Cc: Marek Vasut <[email protected]>; Lukasz Majewski <[email protected]>
Subject: [PATCH v2] dfu: dfu_sf: Add support for multiple flashes

Add dfu_alt_info option which allows specifying multiple SPI flashes as an

alt info.

drivers/dfu/dfu_sf.c static struct spi_flash *parse_dev(char *devstr)

Quoted 20 lines

The syntax is as follows:

altname sf bus:cs[:speed[:mode]]

Example:
dfu_alt_info=qspi0 sf 0:0;qspi1 sf 0:1

Cc Lukasz Majewski <[email protected]>

---
V2: Fix device string parsing in all cases

---
  drivers/dfu/dfu_sf.c | 31 ++++++++++++++++++++++++-------
  1 file changed, 24 insertions(+), 7 deletions(-)
drivers/dfu/dfu_sf.c index renamed from drivers/dfu/dfu_sf.c +0 -0

b72493ced86..6d33497990a 100644

drivers/dfu/dfu_sf.c +0 -0
@@ -168,30 +168,46 @@ static struct spi_flash *parse_dev(char *devstr)

int

drivers/dfu/dfu_sf.c int dfu_fill_entity_sf(struct dfu_entity *dfu, char

Quoted 53 lines
drivers/dfu/dfu_sf.c +23 -7
 dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr, char *s)  {
  	char *st;
-	char *devstr_bkup = strdup(devstr);
-
-	dfu->data.sf.dev = parse_dev(devstr_bkup);
-	free(devstr_bkup);
-	if (!dfu->data.sf.dev)
-		return -ENODEV;
 
  	dfu->dev_type = DFU_DEV_SF;
-	dfu->max_buf_size = dfu->data.sf.dev->sector_size;
 
  	st = strsep(&s, " ");
  	if (!strcmp(st, "raw")) {
+		char *devstr_bkup = strdup(devstr);
+		dfu->data.sf.dev = parse_dev(devstr_bkup);
+		free(devstr_bkup);
+		if (!dfu->data.sf.dev)
+			return -ENODEV;
+
  		dfu->layout = DFU_RAW_ADDR;
+		dfu->max_buf_size = dfu->data.sf.dev->sector_size;
  		dfu->data.sf.start = hextoul(s, &s);
  		s++;
  		dfu->data.sf.size = hextoul(s, &s);
+	} else if (!strcmp(st, "sf")) {
+		st = strsep(&s, " ");
+		dfu->data.sf.dev = parse_dev(st);
+		if (!dfu->data.sf.dev)
+			return -ENODEV;
+
+		dfu->layout = DFU_RAW_ADDR;
+		dfu->max_buf_size = dfu->data.sf.dev->sector_size;
+		dfu->data.sf.start = 0;
+		dfu->data.sf.size = dfu->data.sf.dev->size;
  	} else if (CONFIG_IS_ENABLED(DFU_SF_PART) &&
  		   (!strcmp(st, "part") || !strcmp(st, "partubi"))) {
+		char *devstr_bkup = strdup(devstr);
  		char mtd_id[32];
  		struct mtd_device *mtd_dev;
  		u8 part_num;
  		struct part_info *pi;
  		int ret, dev, part;
 
+		dfu->data.sf.dev = parse_dev(devstr_bkup);
+		free(devstr_bkup);
+		if (!dfu->data.sf.dev)
+			return -ENODEV;
+
  		dfu->layout = DFU_RAW_ADDR;
 
  		dev = dectoul(s, &s);
@@ -208,6 +224,7 @@ int dfu_fill_entity_sf(struct dfu_entity *dfu, char

*devstr,

Quoted 10 lines
drivers/dfu/dfu_sf.c +1 -0
 char *s)
  			printf("Could not locate '%s'\n", mtd_id);
  			return -1;
  		}
+		dfu->max_buf_size = dfu->data.sf.dev->sector_size;
  		dfu->data.sf.start = pi->offset;
  		dfu->data.sf.size = pi->size;

if (!strcmp(st, "partubi"))
--
2.33.0

The same use case can be supported with mtd backend

Quoted 6 lines

https://elixir.bootlin.com/u-boot/latest/source/doc/usage/dfu.rst

U-Boot> env set dfu_alt_info \
"mtd nor0=spl part 1;u-boot part 2;u-boot-env part 3&"\
"mtd nand0=UBI partubi 1"

Does it work for multiple SPI NORs at the same time ?

#3 lore raw

Hi,

ST Restricted

Quoted 113 lines

-----Original Message-----
From: Marek Vasut <[email protected]>
Sent: mardi 5 octobre 2021 15:33
To: [email protected]; [email protected]
Cc: 'Lukasz Majewski' <[email protected]>
Subject: Re: [PATCH v2] dfu: dfu_sf: Add support for multiple flashes

Quoted 105 lines · On 10/5/21 2:50 PM, [email protected] wrote:

Hi Marek,

ST Restricted

Quoted 9 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Marek Vasut
Sent: mardi 5 octobre 2021 14:40
To: [email protected]
Cc: Marek Vasut <[email protected]>; Lukasz Majewski <[email protected]>
Subject: [PATCH v2] dfu: dfu_sf: Add support for multiple flashes

Add dfu_alt_info option which allows specifying multiple SPI flashes as an

alt info.

Quoted 20 lines

The syntax is as follows:

altname sf bus:cs[:speed[:mode]]

Example:
dfu_alt_info=qspi0 sf 0:0;qspi1 sf 0:1

Cc Lukasz Majewski <[email protected]>

---
V2: Fix device string parsing in all cases

---
  drivers/dfu/dfu_sf.c | 31 ++++++++++++++++++++++++-------
  1 file changed, 24 insertions(+), 7 deletions(-)
drivers/dfu/dfu_sf.c index renamed from drivers/dfu/dfu_sf.c +0 -0

b72493ced86..6d33497990a 100644

drivers/dfu/dfu_sf.c static struct spi_flash *parse_dev(char · line 168

Quoted 1 line
drivers/dfu/dfu_sf.c +0 -0
@@ -168,30 +168,46 @@ static struct spi_flash *parse_dev(char
 *devstr)

int

Quoted 53 lines
drivers/dfu/dfu_sf.c +23 -7
 dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr, char *s)  {
  	char *st;
-	char *devstr_bkup = strdup(devstr);
-
-	dfu->data.sf.dev = parse_dev(devstr_bkup);
-	free(devstr_bkup);
-	if (!dfu->data.sf.dev)
-		return -ENODEV;
 
  	dfu->dev_type = DFU_DEV_SF;
-	dfu->max_buf_size = dfu->data.sf.dev->sector_size;
 
  	st = strsep(&s, " ");
  	if (!strcmp(st, "raw")) {
+		char *devstr_bkup = strdup(devstr);
+		dfu->data.sf.dev = parse_dev(devstr_bkup);
+		free(devstr_bkup);
+		if (!dfu->data.sf.dev)
+			return -ENODEV;
+
  		dfu->layout = DFU_RAW_ADDR;
+		dfu->max_buf_size = dfu->data.sf.dev->sector_size;
  		dfu->data.sf.start = hextoul(s, &s);
  		s++;
  		dfu->data.sf.size = hextoul(s, &s);
+	} else if (!strcmp(st, "sf")) {
+		st = strsep(&s, " ");
+		dfu->data.sf.dev = parse_dev(st);
+		if (!dfu->data.sf.dev)
+			return -ENODEV;
+
+		dfu->layout = DFU_RAW_ADDR;
+		dfu->max_buf_size = dfu->data.sf.dev->sector_size;
+		dfu->data.sf.start = 0;
+		dfu->data.sf.size = dfu->data.sf.dev->size;
  	} else if (CONFIG_IS_ENABLED(DFU_SF_PART) &&
  		   (!strcmp(st, "part") || !strcmp(st, "partubi"))) {
+		char *devstr_bkup = strdup(devstr);
  		char mtd_id[32];
  		struct mtd_device *mtd_dev;
  		u8 part_num;
  		struct part_info *pi;
  		int ret, dev, part;
 
+		dfu->data.sf.dev = parse_dev(devstr_bkup);
+		free(devstr_bkup);
+		if (!dfu->data.sf.dev)
+			return -ENODEV;
+
  		dfu->layout = DFU_RAW_ADDR;
 
  		dev = dectoul(s, &s);
@@ -208,6 +224,7 @@ int dfu_fill_entity_sf(struct dfu_entity *dfu,
Quoted 1 line

char

*devstr,

Quoted 10 lines

char *s)
printf("Could not locate '%s'\n", mtd_id); return -1;
}

drivers/dfu/dfu_sf.c +1 -1
+		dfu->max_buf_size = dfu->data.sf.dev->sector_size;
  		dfu->data.sf.start = pi->offset;
  		dfu->data.sf.size = pi->size;
  		if (!strcmp(st, "partubi"))
--

2.33.0

The same use case can be supported with mtd backend

Quoted 8 lines
Quoted 6 lines

https://elixir.bootlin.com/u-boot/latest/source/doc/usage/dfu.rst

U-Boot> env set dfu_alt_info \
"mtd nor0=spl part 1;u-boot part 2;u-boot-env part 3&"\
"mtd nand0=UBI partubi 1"

Does it work for multiple SPI NORs at the same time ?

If it is support on mtd side, yes it is supported in dfu...

And I think it is supported now (with u-class UCLASS_SPI_FLASH). I need to check.deeper

Patrick

#4 lore raw

Hi,

Quoted 140 lines · On 10/5/21 3:41 PM, [email protected] wrote:

Hi,

ST Restricted

Quoted 112 lines

-----Original Message-----
From: Marek Vasut <[email protected]>
Sent: mardi 5 octobre 2021 15:33
To: [email protected]; [email protected]
Cc: 'Lukasz Majewski' <[email protected]>
Subject: Re: [PATCH v2] dfu: dfu_sf: Add support for multiple flashes

Quoted 104 lines · On 10/5/21 2:50 PM, [email protected] wrote:

Hi Marek,

ST Restricted

Quoted 9 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Marek Vasut
Sent: mardi 5 octobre 2021 14:40
To: [email protected]
Cc: Marek Vasut <[email protected]>; Lukasz Majewski <[email protected]>
Subject: [PATCH v2] dfu: dfu_sf: Add support for multiple flashes

Add dfu_alt_info option which allows specifying multiple SPI flashes as an

alt info.

Quoted 20 lines

The syntax is as follows:

altname sf bus:cs[:speed[:mode]]

Example:
dfu_alt_info=qspi0 sf 0:0;qspi1 sf 0:1

Cc Lukasz Majewski <[email protected]>

---
V2: Fix device string parsing in all cases

---
   drivers/dfu/dfu_sf.c | 31 ++++++++++++++++++++++++-------
   1 file changed, 24 insertions(+), 7 deletions(-)
drivers/dfu/dfu_sf.c index renamed from drivers/dfu/dfu_sf.c +0 -0

b72493ced86..6d33497990a 100644

drivers/dfu/dfu_sf.c static struct spi_flash *parse_dev(char · line 168

Quoted 1 line
drivers/dfu/dfu_sf.c +0 -0
@@ -168,30 +168,46 @@ static struct spi_flash *parse_dev(char
 *devstr)

int

Quoted 53 lines
drivers/dfu/dfu_sf.c +23 -7
 dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr, char *s)  {
   	char *st;
-	char *devstr_bkup = strdup(devstr);
-
-	dfu->data.sf.dev = parse_dev(devstr_bkup);
-	free(devstr_bkup);
-	if (!dfu->data.sf.dev)
-		return -ENODEV;
 
   	dfu->dev_type = DFU_DEV_SF;
-	dfu->max_buf_size = dfu->data.sf.dev->sector_size;
 
   	st = strsep(&s, " ");
   	if (!strcmp(st, "raw")) {
+		char *devstr_bkup = strdup(devstr);
+		dfu->data.sf.dev = parse_dev(devstr_bkup);
+		free(devstr_bkup);
+		if (!dfu->data.sf.dev)
+			return -ENODEV;
+
   		dfu->layout = DFU_RAW_ADDR;
+		dfu->max_buf_size = dfu->data.sf.dev->sector_size;
   		dfu->data.sf.start = hextoul(s, &s);
   		s++;
   		dfu->data.sf.size = hextoul(s, &s);
+	} else if (!strcmp(st, "sf")) {
+		st = strsep(&s, " ");
+		dfu->data.sf.dev = parse_dev(st);
+		if (!dfu->data.sf.dev)
+			return -ENODEV;
+
+		dfu->layout = DFU_RAW_ADDR;
+		dfu->max_buf_size = dfu->data.sf.dev->sector_size;
+		dfu->data.sf.start = 0;
+		dfu->data.sf.size = dfu->data.sf.dev->size;
   	} else if (CONFIG_IS_ENABLED(DFU_SF_PART) &&
   		   (!strcmp(st, "part") || !strcmp(st, "partubi"))) {
+		char *devstr_bkup = strdup(devstr);
   		char mtd_id[32];
   		struct mtd_device *mtd_dev;
   		u8 part_num;
   		struct part_info *pi;
   		int ret, dev, part;
 
+		dfu->data.sf.dev = parse_dev(devstr_bkup);
+		free(devstr_bkup);
+		if (!dfu->data.sf.dev)
+			return -ENODEV;
+
   		dfu->layout = DFU_RAW_ADDR;
 
   		dev = dectoul(s, &s);
@@ -208,6 +224,7 @@ int dfu_fill_entity_sf(struct dfu_entity *dfu,
Quoted 1 line

char

*devstr,

Quoted 10 lines

char *s)

   			printf("Could not locate '%s'\n", mtd_id);
   			return -1;
   		}
drivers/dfu/dfu_sf.c +1 -1
+		dfu->max_buf_size = dfu->data.sf.dev->sector_size;
   		dfu->data.sf.start = pi->offset;
   		dfu->data.sf.size = pi->size;
   		if (!strcmp(st, "partubi"))
--

2.33.0

The same use case can be supported with mtd backend

Quoted 7 lines
Quoted 6 lines

https://elixir.bootlin.com/u-boot/latest/source/doc/usage/dfu.rst

U-Boot> env set dfu_alt_info \
"mtd nor0=spl part 1;u-boot part 2;u-boot-env part 3&"\
"mtd nand0=UBI partubi 1"

Does it work for multiple SPI NORs at the same time ?

If it is support on mtd side, yes it is supported in dfu...

And I think it is supported now (with u-class UCLASS_SPI_FLASH). I need to check.deeper

Patrick

with '&' in dfu_alt_info you can have several dfu backend...

something as (not tested) :

U-Boot> env set dfu_alt_info "sf 0:0=raw 0x0 <size>&sf 0:1=raw 0x0 <size>"

'&' It is working for ANY existing backend

Quoted 7 lines

=> used today in STM32MP15x
+ stm32prog command as backend when flashlayout is parsed to update any device.
+ for dfu command (board/st/common/stm32mp_dfu.c) => all devices are exported (mtd nand0 and mtd nor0)

Patrick

Test with dfu MTD backend + export of all device present on STM32MP157C-EV1

dfu_alt_info=ram 0=uImage ram 0xc2000000 0x2000000;devicetree.dtb ram 0xc4000000 0x100000;uramdisk.image.gz ram 0xc4400000 0x10000000&mmc 0=mmc0_fsbl1 part 0 1;mmc0_fsbl2 part 0 2;mmc0_fip part 0 3;mmc0_boot part 0 4;mmc0_vendorfs part 0 5;mmc0_rootfs part 0 6;mmc0_userfs part 0 7&mmc 1=mmc1_boot1 raw 0x0 0x200000 mmcpart 1;mmc1_boot2 raw 0x0 0x200000 mmcpart 2;mmc1_fip part 1 1;mmc1_bootfs part 1 2;mmc1_vendorfs part 1 3;mmc1_rootfs part 1 4;mmc1_userfs part 1 5&mtd nor0=nor0 raw 0x0 0x4000000 &mtd nor1=nor1 raw 0x0 0x4000000 &mtd nand0=nand0 raw 0x0 0x40000000

$> dfu-util -l

dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc. Copyright 2010-2016 Tormod Volden and Stefan Schmidt This program is Free Software and has ABSOLUTELY NO WARRANTY Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Found DFU: [0483:df11] ver=0200, devnum=9, cfg=1, intf=0, path="1-5.4.2", alt=19, name="nand0", serial="004700223338511534383330" Found DFU: [0483:df11] ver=0200, devnum=9, cfg=1, intf=0, path="1-5.4.2", alt=18, name="nor1", serial="004700223338511534383330" Found DFU: [0483:df11] ver=0200, devnum=9, cfg=1, intf=0, path="1-5.4.2", alt=17, name="nor0", serial="004700223338511534383330" Found DFU: [0483:df11] ver=0200, devnum=9, cfg=1, intf=0, path="1-5.4.2", alt=16, name="mmc1_userfs", serial="004700223338511534383330" Found DFU: [0483:df11] ver=0200, devnum=9, cfg=1, intf=0, path="1-5.4.2", alt=15, name="mmc1_rootfs", serial="004700223338511534383330" Found DFU: [0483:df11] ver=0200, devnum=9, cfg=1, intf=0, path="1-5.4.2", alt=14, name="mmc1_vendorfs", serial="004700223338511534383330" Found DFU: [0483:df11] ver=0200, devnum=9, cfg=1, intf=0, path="1-5.4.2", alt=13, name="mmc1_bootfs", serial="004700223338511534383330" Found DFU: [0483:df11] ver=0200, devnum=9, cfg=1, intf=0, path="1-5.4.2", alt=12, name="mmc1_fip", serial="004700223338511534383330" Found DFU: [0483:df11] ver=0200, devnum=9, cfg=1, intf=0, path="1-5.4.2", alt=11, name="mmc1_boot2", serial="004700223338511534383330" Found DFU: [0483:df11] ver=0200, devnum=9, cfg=1, intf=0, path="1-5.4.2", alt=10, name="mmc1_boot1", serial="004700223338511534383330" Found DFU: [0483:df11] ver=0200, devnum=9, cfg=1, intf=0, path="1-5.4.2", alt=9, name="mmc0_userfs", serial="004700223338511534383330" Found DFU: [0483:df11] ver=0200, devnum=9, cfg=1, intf=0, path="1-5.4.2", alt=8, name="mmc0_rootfs", serial="004700223338511534383330" Found DFU: [0483:df11] ver=0200, devnum=9, cfg=1, intf=0, path="1-5.4.2", alt=7, name="mmc0_vendorfs", serial="004700223338511534383330" Found DFU: [0483:df11] ver=0200, devnum=9, cfg=1, intf=0, path="1-5.4.2", alt=6, name="mmc0_boot", serial="004700223338511534383330" Found DFU: [0483:df11] ver=0200, devnum=9, cfg=1, intf=0, path="1-5.4.2", alt=5, name="mmc0_fip", serial="004700223338511534383330" Found DFU: [0483:df11] ver=0200, devnum=9, cfg=1, intf=0, path="1-5.4.2", alt=4, name="mmc0_fsbl2", serial="004700223338511534383330" Found DFU: [0483:df11] ver=0200, devnum=9, cfg=1, intf=0, path="1-5.4.2", alt=3, name="mmc0_fsbl1", serial="004700223338511534383330" Found DFU: [0483:df11] ver=0200, devnum=9, cfg=1, intf=0, path="1-5.4.2", alt=2, name="uramdisk.image.gz", serial="004700223338511534383330" Found DFU: [0483:df11] ver=0200, devnum=9, cfg=1, intf=0, path="1-5.4.2", alt=1, name="devicetree.dtb", serial="004700223338511534383330" Found DFU: [0483:df11] ver=0200, devnum=9, cfg=1, intf=0, path="1-5.4.2", alt=0, name="uImage", serial="004700223338511534383330"

and I can dump the nor content of the 2 instance:

$> dfu-util -a 17 -U nor0.bin

$> dfu-util -a 18 -U nor1.bin

the more simple configuration is

STMP32MP1> env set dfu_alt_info "mtd nor0=nor0 raw 0x0 0x4000000 &mtd nor1=nor1 raw 0x0 0x4000000"

For me normally it is working as SPI reconfiguration is now managed in MTD side

it wasn't the case in previosu U-boot version.

-----------------------------------------------------------------------------------------------------------------------------

It can be done also with sf backend => but I don't sure it is safe ...  sf probe issue ?

The command that I use is:

STM32MP> env set dfu_alt_info "sf 0:0=nor0 raw 0x0 0x4000000&sf 0:1=nor1 raw 0x0 0x4000000" STM32MP> dfu 0

$> dfu-util -l
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc. Copyright 2010-2016 Tormod Volden and Stefan Schmidt This program is Free Software and has ABSOLUTELY NO WARRANTY Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Found DFU: [0483:df11] ver=0200, devnum=11, cfg=1, intf=0, path="1-5.4.2", alt=1, name="nor1", serial="004700223338511534383330" Found DFU: [0483:df11] ver=0200, devnum=11, cfg=1, intf=0, path="1-5.4.2", alt=0, name="nor0", serial="004700223338511534383330"

Regards

Patrick

#5 lore raw
In reply to Marek Vasut

Hi,

ST Restricted

Quoted 8 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: mardi 5 octobre 2021 14:50
To: 'Marek Vasut' <[email protected]>; '[email protected]' <u- [email protected]>
Cc: 'Lukasz Majewski' <[email protected]>
Subject: RE: [PATCH v2] dfu: dfu_sf: Add support for multiple flashes

Quoted 13 lines

Hi Marek,

ST Restricted

Quoted 8 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Marek Vasut
Sent: mardi 5 octobre 2021 14:40
To: [email protected]
Cc: Marek Vasut <[email protected]>; Lukasz Majewski <[email protected]>
Subject: [PATCH v2] dfu: dfu_sf: Add support for multiple flashes

Add dfu_alt_info option which allows specifying multiple SPI flashes as

an alt

Quoted 87 lines

info.

Quoted 80 lines

The syntax is as follows:

altname sf bus:cs[:speed[:mode]]

Example:
dfu_alt_info=qspi0 sf 0:0;qspi1 sf 0:1

Cc Lukasz Majewski <[email protected]>

---
V2: Fix device string parsing in all cases

---
 drivers/dfu/dfu_sf.c | 31 ++++++++++++++++++++++++-------
 1 file changed, 24 insertions(+), 7 deletions(-)
drivers/dfu/dfu_sf.c index renamed from drivers/dfu/dfu_sf.c +0 -0

b72493ced86..6d33497990a 100644

drivers/dfu/dfu_sf.c +24 -7
@@ -168,30 +168,46 @@ static struct spi_flash *parse_dev(char *devstr)
 int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr, char *s)  {
 	char *st;
-	char *devstr_bkup = strdup(devstr);
-
-	dfu->data.sf.dev = parse_dev(devstr_bkup);
-	free(devstr_bkup);
-	if (!dfu->data.sf.dev)
-		return -ENODEV;
 
 	dfu->dev_type = DFU_DEV_SF;
-	dfu->max_buf_size = dfu->data.sf.dev->sector_size;
 
 	st = strsep(&s, " ");
 	if (!strcmp(st, "raw")) {
+		char *devstr_bkup = strdup(devstr);
+		dfu->data.sf.dev = parse_dev(devstr_bkup);
+		free(devstr_bkup);
+		if (!dfu->data.sf.dev)
+			return -ENODEV;
+
 		dfu->layout = DFU_RAW_ADDR;
+		dfu->max_buf_size = dfu->data.sf.dev->sector_size;
 		dfu->data.sf.start = hextoul(s, &s);
 		s++;
 		dfu->data.sf.size = hextoul(s, &s);
+	} else if (!strcmp(st, "sf")) {
+		st = strsep(&s, " ");
+		dfu->data.sf.dev = parse_dev(st);
+		if (!dfu->data.sf.dev)
+			return -ENODEV;
+
+		dfu->layout = DFU_RAW_ADDR;
+		dfu->max_buf_size = dfu->data.sf.dev->sector_size;
+		dfu->data.sf.start = 0;
+		dfu->data.sf.size = dfu->data.sf.dev->size;
 	} else if (CONFIG_IS_ENABLED(DFU_SF_PART) &&
 		   (!strcmp(st, "part") || !strcmp(st, "partubi"))) {
+		char *devstr_bkup = strdup(devstr);
 		char mtd_id[32];
 		struct mtd_device *mtd_dev;
 		u8 part_num;
 		struct part_info *pi;
 		int ret, dev, part;
 
+		dfu->data.sf.dev = parse_dev(devstr_bkup);
+		free(devstr_bkup);
+		if (!dfu->data.sf.dev)
+			return -ENODEV;
+
 		dfu->layout = DFU_RAW_ADDR;
 
 		dev = dectoul(s, &s);
@@ -208,6 +224,7 @@ int dfu_fill_entity_sf(struct dfu_entity *dfu,
 char *devstr, char *s)
 			printf("Could not locate '%s'\n", mtd_id);
 			return -1;
 		}
+		dfu->max_buf_size = dfu->data.sf.dev->sector_size;
 		dfu->data.sf.start = pi->offset;
 		dfu->data.sf.size = pi->size;
Quoted 3 lines

if (!strcmp(st, "partubi"))
--
2.33.0

The same use case can be supported with mtd backend

Quoted 6 lines

https://elixir.bootlin.com/u-boot/latest/source/doc/usage/dfu.rst

U-Boot> env set dfu_alt_info \
"mtd nor0=spl part 1;u-boot part 2;u-boot-env part 3&"\
"mtd nand0=UBI partubi 1"

with '&' in dfu_alt_info you can have several dfu backend...

something as (not tested) :

U-Boot> env set dfu_alt_info "sf 0:0=raw 0x0 <size>&sf 0:1=raw 0x0 <size>"

'&' It is working for ANY existing backend

=> used today in STM32MP15x
+ stm32prog command as backend when flashlayout is parsed to update any device.
+ for dfu command (board/st/common/stm32mp_dfu.c) => all devices are exported (mtd nand0 and mtd nor0)

Patrick