public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: <patrick.delaunay@foss.st.com>
To: 'Marek Vasut' <marex@denx.de>, <u-boot@lists.denx.de>
Cc: 'Lukasz Majewski' <lukma@denx.de>
Subject: RE: [PATCH v2] dfu: dfu_sf: Add support for multiple flashes
Date: Tue, 5 Oct 2021 14:50:27 +0200	[thread overview]
Message-ID: <000f01d7b9e7$92c72e70$b8558b50$@foss.st.com> (raw)
In-Reply-To: <20211005124020.444967-1-marex@denx.de>

Hi Marek,


ST Restricted

> -----Original Message-----
> From: U-Boot <u-boot-bounces@lists.denx.de> On Behalf Of Marek Vasut
> Sent: mardi 5 octobre 2021 14:40
> To: u-boot@lists.denx.de
> Cc: Marek Vasut <marex@denx.de>; Lukasz Majewski <lukma@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 <marex@denx.de>
> Cc: Lukasz Majewski <lukma@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"


  reply	other threads:[~2021-10-05 12:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-05 12:40 [PATCH v2] dfu: dfu_sf: Add support for multiple flashes Marek Vasut
2021-10-05 12:50 ` patrick.delaunay [this message]
2021-10-05 13:32   ` Marek Vasut
2021-10-05 13:41     ` patrick.delaunay
2021-10-05 15:07       ` Patrick DELAUNAY
2021-10-05 13:01 ` patrick.delaunay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000f01d7b9e7$92c72e70$b8558b50$@foss.st.com' \
    --to=patrick.delaunay@foss.st.com \
    --cc=lukma@denx.de \
    --cc=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox