Hi,

On 10/5/21 3:41 PM, patrick.delau...@foss.st.com wrote:
Hi,


ST Restricted

-----Original Message-----
From: Marek Vasut <ma...@denx.de>
Sent: mardi 5 octobre 2021 15:33
To: patrick.delau...@foss.st.com; u-boot@lists.denx.de
Cc: 'Lukasz Majewski' <lu...@denx.de>
Subject: Re: [PATCH v2] dfu: dfu_sf: Add support for multiple flashes

On 10/5/21 2:50 PM, patrick.delau...@foss.st.com wrote:
Hi Marek,


ST Restricted

-----Original Message-----
From: U-Boot <u-boot-boun...@lists.denx.de> On Behalf Of Marek Vasut
Sent: mardi 5 octobre 2021 14:40
To: u-boot@lists.denx.de
Cc: Marek Vasut <ma...@denx.de>; Lukasz Majewski <lu...@denx.de>
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.
The syntax is as follows:

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

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

Signed-off-by: Marek Vasut <ma...@denx.de>
Cc: Lukasz Majewski <lu...@denx.de>
---
V2: Fix device string parsing in all cases
---
   drivers/dfu/dfu_sf.c | 31 ++++++++++++++++++++++++-------
   1 file changed, 24 insertions(+), 7 deletions(-)

diff --git a/drivers/dfu/dfu_sf.c b/drivers/dfu/dfu_sf.c index
b72493ced86..6d33497990a 100644
--- a/drivers/dfu/dfu_sf.c
+++ b/drivers/dfu/dfu_sf.c
@@ -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"))
--
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"
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

=> 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

Reply via email to