All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3 00/15] dfu: update dfu stack and add MTD backend
@ 2019-10-14  7:27 Patrick Delaunay
  2019-10-14  7:27 ` [U-Boot] [PATCH v3 01/15] dfu: cosmetic: cleanup sf to avoid checkpatch error Patrick Delaunay
                   ` (14 more replies)
  0 siblings, 15 replies; 26+ messages in thread
From: Patrick Delaunay @ 2019-10-14  7:27 UTC (permalink / raw)
  To: u-boot


This serie based on v2019.10 propose updates on the DFU stack:
- add capability to have several DFU backend running in parallel
- add MTD backend for update of NAND, NOR or SPI-NAND
- add VIRTUAL backend for board/command specific behavior
- add some weak callback

This v2 patchset:
+ solves compilation for dependancy with CONFIG_CMD_MTDPARTS
+ solves bad block management for NAND in the erase loops
  (copied from MTD command), the previous was functional only on
  SPI-NAND. But I detect issue for NAND; when bad block is
  detected fail_addr is not updated.
  See the complete analysis on the issue (reproduced in MTD
  command) in http://patchwork.ozlabs.org/patch/1165056/
  "cmd: mtd: solve bad block support in erase command"
  The better solution is a MTD backport from Linux, but udpate the
  loop is functional for SPI-NAND and NAND.

To test the new features and as example, I update the stm32mp1
board to use the new features; I test them with the command
"dfu 0" (for test I have dependency with patch
 http://patchwork.ozlabs.org/patch/1162076/)

The expected target of the dfu part for this serie is v2020.01.
I will merge the stm32mp1 part when they will be accepted by dfu
maintainers.

This serie prepares the DFU backend for the coming 'stm32prog' command
and for STM32CubeProgrammer on stm32mp1 platform.
This STMicroelectronics tool is based on DFU protocol and allows to
update all the boot devices and the OTPs on the ST boards
(so several DFU target in parallel, including spi nand).

Build result for dfu_v3 branch can be found in
https://travis-ci.org/patrickdelaunay/u-boot/builds/596684593

only one error for sheevaplug, but not reproduced on my side

     arm:  +   sheevaplug
+u-boot.kwb exceeds file size limit:
+  limit:  524288 bytes
+  actual: 524320 bytes
+  excess: 32 bytes

$> tools/buildman/buildman sheevaplug

boards.cfg is up to date. Nothing to do.
Building current source for 1 boards (1 thread, 12 jobs per thread)
       arm:  w+   sheevaplug
+===================== WARNING ======================
+This board does not use CONFIG_DM_MMC. Please update
+the board to use CONFIG_DM_MMC before the v2019.04 release.
+Failure to update by the deadline may result in board removal.
+See doc/driver-model/MIGRATION.txt for more info.
+====================================================
+This board does not use CONFIG_DM_USB. Please update
+the board to use CONFIG_DM_USB before the v2019.07 release.
+This board does use CONFIG_MVSATA_IDE which is not
+ported to driver-model (DM) yet. Please update the storage
+controller driver to use CONFIG_AHCI before the v2019.07
+release.
+This board does not use CONFIG_DM_ETH (Driver Model
+for Ethernet drivers). Please update the board to use
+CONFIG_DM_ETH before the v2020.07 release. Failure to
+update by the deadline may result in board removal.
+See doc/driver-model/migration.rst for more info.
    0    1    0 /1      sheevaplug

Regards

Patrick


Changes in v3:
- Add CONFIG_DFU_SF_PART and solve compilation issue,
  dependancy with CONFIG_MTDPARTS
- update bad block support in erase loop
- Update loop management for erase
- rebase on v2019.10
- remove previous patch 16/16 pushed by error in v2
  http://patchwork.ozlabs.org/patch/1162076/

Changes in v2:
- Add dfu documentation
- Update dfu documentation for callbacks
- Add dfu documentation for several device
- Update commit message
- Update commit message
- Update dfu documentation for MTD
- Update dfu documentation for MTD
- Update dfu documentation for virtual backend
- Update dfu documentation for callbacks
- Update callbacks comment after Lukasz review
- Update after Lukasz Majewski comments

Patrick Delaunay (15):
  dfu: cosmetic: cleanup sf to avoid checkpatch error
  doc: dfu: Add dfu documentation
  dfu: sf: add partition support for nor backend
  dfu: prepare the support of multiple interface
  dfu: allow to manage DFU on several devices
  dfu: allow read with no data without error for EOF indication
  dfu: add backend for MTD device
  dfu: add partition support for MTD backend
  dfu: add DFU virtual backend
  dfu: add callback for flush and initiated operation
  stm32mp1: activate DFU support and command MTD
  stm32mp1: activate SET_DFU_ALT_INFO
  stm32mp1: configs: activate CONFIG_MTD_SPI_NAND
  stm32mp1: board: add spi nand support
  stm32mp1: add support for virtual partition read

 board/st/stm32mp1/README            | 111 ++++++++++
 board/st/stm32mp1/stm32mp1.c        | 164 ++++++++++++++-
 cmd/dfu.c                           |  21 +-
 configs/stm32mp15_basic_defconfig   |   6 +
 configs/stm32mp15_optee_defconfig   |   6 +
 configs/stm32mp15_trusted_defconfig |   6 +
 doc/README.dfu                      | 270 ++++++++++++++++++++++++
 drivers/dfu/Kconfig                 |  21 ++
 drivers/dfu/Makefile                |   2 +
 drivers/dfu/dfu.c                   | 145 +++++++++++--
 drivers/dfu/dfu_mtd.c               | 311 ++++++++++++++++++++++++++++
 drivers/dfu/dfu_sf.c                |  56 ++++-
 drivers/dfu/dfu_virt.c              |  49 +++++
 include/configs/stm32mp1.h          |  42 +++-
 include/dfu.h                       |  71 +++++++
 15 files changed, 1251 insertions(+), 30 deletions(-)
 create mode 100644 doc/README.dfu
 create mode 100644 drivers/dfu/dfu_mtd.c
 create mode 100644 drivers/dfu/dfu_virt.c

-- 
2.17.1

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot] [PATCH v3 01/15] dfu: cosmetic: cleanup sf to avoid checkpatch error
  2019-10-14  7:27 [U-Boot] [PATCH v3 00/15] dfu: update dfu stack and add MTD backend Patrick Delaunay
@ 2019-10-14  7:27 ` Patrick Delaunay
  2019-10-14  7:27 ` [U-Boot] [PATCH v3 02/15] doc: dfu: Add dfu documentation Patrick Delaunay
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 26+ messages in thread
From: Patrick Delaunay @ 2019-10-14  7:27 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Acked-by: Lukasz Majewski <lukma@denx.de>
---

Changes in v3: None
Changes in v2: None

 drivers/dfu/dfu.c    | 7 ++++---
 drivers/dfu/dfu_sf.c | 4 ++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index d2b67b18cf..e9db7f8d66 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -478,14 +478,15 @@ int dfu_config_entities(char *env, char *interface, char *devstr)
 
 const char *dfu_get_dev_type(enum dfu_device_type t)
 {
-	const char *dev_t[] = {NULL, "eMMC", "OneNAND", "NAND", "RAM", "SF" };
+	const char *const dev_t[] = {NULL, "eMMC", "OneNAND", "NAND", "RAM",
+				     "SF"};
 	return dev_t[t];
 }
 
 const char *dfu_get_layout(enum dfu_layout l)
 {
-	const char *dfu_layout[] = {NULL, "RAW_ADDR", "FAT", "EXT2",
-					   "EXT3", "EXT4", "RAM_ADDR" };
+	const char *const dfu_layout[] = {NULL, "RAW_ADDR", "FAT", "EXT2",
+					  "EXT3", "EXT4", "RAM_ADDR" };
 	return dfu_layout[l];
 }
 
diff --git a/drivers/dfu/dfu_sf.c b/drivers/dfu/dfu_sf.c
index 066e7670d1..b78fcfd3a1 100644
--- a/drivers/dfu/dfu_sf.c
+++ b/drivers/dfu/dfu_sf.c
@@ -19,7 +19,7 @@ static int dfu_get_medium_size_sf(struct dfu_entity *dfu, u64 *size)
 }
 
 static int dfu_read_medium_sf(struct dfu_entity *dfu, u64 offset, void *buf,
-		long *len)
+			      long *len)
 {
 	return spi_flash_read(dfu->data.sf.dev, dfu->data.sf.start + offset,
 		*len, buf);
@@ -32,7 +32,7 @@ static u64 find_sector(struct dfu_entity *dfu, u64 start, u64 offset)
 }
 
 static int dfu_write_medium_sf(struct dfu_entity *dfu,
-		u64 offset, void *buf, long *len)
+			       u64 offset, void *buf, long *len)
 {
 	int ret;
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [U-Boot] [PATCH v3 02/15] doc: dfu: Add dfu documentation
  2019-10-14  7:27 [U-Boot] [PATCH v3 00/15] dfu: update dfu stack and add MTD backend Patrick Delaunay
  2019-10-14  7:27 ` [U-Boot] [PATCH v3 01/15] dfu: cosmetic: cleanup sf to avoid checkpatch error Patrick Delaunay
@ 2019-10-14  7:27 ` Patrick Delaunay
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 03/15] dfu: sf: add partition support for nor backend Patrick Delaunay
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 26+ messages in thread
From: Patrick Delaunay @ 2019-10-14  7:27 UTC (permalink / raw)
  To: u-boot

Add documentation for dfu stack and "dfu" command.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

Changes in v3: None
Changes in v2:
- Add dfu documentation

 doc/README.dfu | 144 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 144 insertions(+)
 create mode 100644 doc/README.dfu

diff --git a/doc/README.dfu b/doc/README.dfu
new file mode 100644
index 0000000000..f5344e236c
--- /dev/null
+++ b/doc/README.dfu
@@ -0,0 +1,144 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+Device Firmware Upgrade (DFU)
+
+Overview:
+
+  The Device Firmware Upgrade (DFU) allows to download and upload firmware
+  to/from U-Boot connected over USB.
+
+  U-boot follows the Universal Serial Bus Device Class Specification for
+  Device Firmware Upgrade Version 1.1 the USB forum (DFU v1.1 in www.usb.org).
+
+  U-Boot implements this DFU capability (CONFIG_DFU) with the command dfu
+  (cmd/dfu.c / CONFIG_CMD_DFU) based on:
+  - the DFU stack (common/dfu.c and common/spl/spl_dfu.c), based on the
+    USB DFU download gadget (drivers/usb/gadget/f_dfu.c)
+  - The access to mediums is done in DFU backends (driver/dfu)
+
+  Today the supported DFU backends are:
+  - MMC (RAW or FAT / EXT2 / EXT3 / EXT4 file system)
+  - NAND
+  - RAM
+  - SF (serial flash)
+
+  These DFU backends are also used by
+  - the dfutftp (see README.dfutftp)
+  - the thordown command (cmd/thordown.c and gadget/f_thor.c)
+
+Configuration Options:
+  CONFIG_DFU
+  CONFIG_DFU_OVER_USB
+  CONFIG_DFU_MMC
+  CONFIG_DFU_NAND
+  CONFIG_DFU_RAM
+  CONFIG_DFU_SF
+  CONFIG_CMD_DFU
+
+Environment variables:
+  the dfu command use 3 environments variables:
+  "dfu_alt_info" : the DFU setting for the USB download gadget with a comma
+                   separated string of information on each alternate:
+                   dfu_alt_info="<alt1>;<alt2>;....;<altN>"
+
+  "dfu_bufsiz" : size of the DFU buffer, when absent, use
+                 CONFIG_SYS_DFU_DATA_BUF_SIZE (8MiB by default)
+
+  "dfu_hash_algo" : name of the hash algorithm to use
+
+Commands:
+  dfu <USB_controller> <interface> <dev> list
+    list the alternate device defined in "dfu_alt_info"
+
+  dfu <USB_controller> <interface> <dev>
+    start the dfu stack on the USB instance with the selected medium
+    backend and use the "dfu_alt_info" variable to configure the
+    alternate setting and link each one with the medium
+    The dfu command continue until receive a ^C in console or
+    a DFU detach transaction from HOST.
+
+  The possible values of <interface> are :
+  (with <USB controller> = 0 in the dfu command example)
+
+  "mmc" (for eMMC and SD card)
+    cmd: dfu 0 mmc <dev>
+    each element in "dfu_alt_info" =
+      <name> raw <offset> <size>   raw access to mmc device
+      <name> part <dev> <part_id>  raw acces to partition
+      <name> fat <dev> <part_id>   file in FAT partition
+      <name> ext4 <dev> <part_id>  file in EXT4 partition
+
+      with <partid> is the GPT or DOS partition index
+
+  "nand" (raw slc nand device)
+    cmd: dfu 0 nand <dev>
+    each element in "dfu_alt_info" =
+      <name> raw <offset> <size>   raw access to mmc device
+      <name> part <dev> <part_id>  raw acces to partition
+      <name> partubi <dev> <part_id>  raw acces to ubi partition
+
+      with <partid> is the MTD partition index
+
+  "ram"
+    cmd: dfu 0 ram <dev>
+    (<dev> is not used for RAM target)
+    each element in "dfu_alt_info" =
+      <name> ram <offset> <size>  raw access to ram
+
+  "sf" (serial flash : NOR)
+    cmd: dfu 0 sf <dev>
+    each element in "dfu_alt_info" =
+      <name> ram <offset> <size>  raw access to sf device
+
+Host tools:
+  When U-Boot runs the dfu stack, the DFU host tools can be used
+  to send/receive firmwares on each configurated alternate.
+
+  For example dfu-util is a host side implementation of the DFU 1.1
+  specifications(http://dfu-util.sourceforge.net/) which works with U-Boot.
+
+Usage:
+  Example for firmware located in eMMC or SD card, with:
+  - alternate 1 (alt=1) for SPL partition (GPT partition 1)
+  - alternate 2 (alt=2) for U-Boot partition (GPT partition 2)
+
+  The U-Boot configuration is:
+
+  U-Boot> env set dfu_alt_info "spl part 0 1;u-boot part 0 2"
+
+  U-Boot> dfu 0 mmc 0 list
+  DFU alt settings list:
+  dev: eMMC alt: 0 name: spl layout: RAW_ADDR
+  dev: eMMC alt: 1 name: u-boot layout: RAW_ADDR
+
+  Boot> dfu 0 mmc 0
+
+  On the Host side:
+
+  list the available alternate setting:
+
+  $> 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:5720] ver=0200, devnum=45, cfg=1, intf=0, path="3-1.3.1", \
+     alt=1, name="u-boot", serial="003A00203438510D36383238"
+  Found DFU: [0483:5720] ver=0200, devnum=45, cfg=1, intf=0, path="3-1.3.1", \
+     alt=0, name="spl", serial="003A00203438510D36383238"
+
+  To download to U-Boot, use -D option
+
+  $> dfu-util -a 0 -D u-boot-spl.bin
+  $> dfu-util -a 1 -D u-boot.bin
+
+  To upload from U-Boot, use -U option
+
+  $> dfu-util -a 0 -U u-boot-spl.bin
+  $> dfu-util -a 1 -U u-boot.bin
+
+  To request a DFU detach and reset the USB connection:
+  $> dfu-util -a 0 -e  -R
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [U-Boot] [PATCH v3 03/15] dfu: sf: add partition support for nor backend
  2019-10-14  7:27 [U-Boot] [PATCH v3 00/15] dfu: update dfu stack and add MTD backend Patrick Delaunay
  2019-10-14  7:27 ` [U-Boot] [PATCH v3 01/15] dfu: cosmetic: cleanup sf to avoid checkpatch error Patrick Delaunay
  2019-10-14  7:27 ` [U-Boot] [PATCH v3 02/15] doc: dfu: Add dfu documentation Patrick Delaunay
@ 2019-10-14  7:28 ` Patrick Delaunay
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 04/15] dfu: prepare the support of multiple interface Patrick Delaunay
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 26+ messages in thread
From: Patrick Delaunay @ 2019-10-14  7:28 UTC (permalink / raw)
  To: u-boot

Copy the partition support from NAND backend to SF,
support part and partubi option.
In case of ubi partition, erase the rest of the
partition as it is mandatory for UBI.

The added code is under compilation flag CONFIG_DFU_SF_PART
activated by default.

for example:

U-Boot> env set dfu_alt_info "spl part 0 1;\
u-boot part 0 2;u-boot-env part 0 3;UBI partubi 0 4"
U-Boot> dfu 0 sf 0:0:10000000:0

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

Changes in v3:
- Add CONFIG_DFU_SF_PART and solve compilation issue,
  dependancy with CONFIG_MTDPARTS

Changes in v2:
- Update dfu documentation for callbacks

 doc/README.dfu       |  5 +++++
 drivers/dfu/Kconfig  |  8 +++++++
 drivers/dfu/dfu_sf.c | 52 ++++++++++++++++++++++++++++++++++++++++++++
 include/dfu.h        |  2 ++
 4 files changed, 67 insertions(+)

diff --git a/doc/README.dfu b/doc/README.dfu
index f5344e236c..7a2b5f1d4b 100644
--- a/doc/README.dfu
+++ b/doc/README.dfu
@@ -33,6 +33,7 @@ Configuration Options:
   CONFIG_DFU_NAND
   CONFIG_DFU_RAM
   CONFIG_DFU_SF
+  CONFIG_DFU_SF_PART
   CONFIG_CMD_DFU
 
 Environment variables:
@@ -89,6 +90,10 @@ Commands:
     cmd: dfu 0 sf <dev>
     each element in "dfu_alt_info" =
       <name> ram <offset> <size>  raw access to sf device
+      <name> part <dev> <part_id>  raw acces to partition
+      <name> partubi <dev> <part_id>  raw acces to ubi partition
+
+      with <partid> is the MTD partition index
 
 Host tools:
   When U-Boot runs the dfu stack, the DFU host tools can be used
diff --git a/drivers/dfu/Kconfig b/drivers/dfu/Kconfig
index 4692736c9d..1cbec81128 100644
--- a/drivers/dfu/Kconfig
+++ b/drivers/dfu/Kconfig
@@ -46,5 +46,13 @@ config DFU_SF
 	  This option enables using DFU to read and write to SPI flash based
 	  storage.
 
+config DFU_SF_PART
+	bool "MTD partition support for SPI flash back end"
+	depends on DFU_SF && CMD_MTDPARTS
+	default y
+	help
+	  This option enables the support of "part" and "partubi" target in
+	  SPI flash DFU back end.
+
 endif
 endmenu
diff --git a/drivers/dfu/dfu_sf.c b/drivers/dfu/dfu_sf.c
index b78fcfd3a1..0fdbfae434 100644
--- a/drivers/dfu/dfu_sf.c
+++ b/drivers/dfu/dfu_sf.c
@@ -10,6 +10,8 @@
 #include <dfu.h>
 #include <spi.h>
 #include <spi_flash.h>
+#include <jffs2/load_kernel.h>
+#include <linux/mtd/mtd.h>
 
 static int dfu_get_medium_size_sf(struct dfu_entity *dfu, u64 *size)
 {
@@ -52,11 +54,33 @@ static int dfu_write_medium_sf(struct dfu_entity *dfu,
 
 static int dfu_flush_medium_sf(struct dfu_entity *dfu)
 {
+	u64 off, length;
+
+	if (!CONFIG_IS_ENABLED(DFU_SF_PART) || !dfu->data.sf.ubi)
+		return 0;
+
+	/* in case of ubi partition, erase rest of the partition */
+	off = find_sector(dfu, dfu->data.sf.start, dfu->offset);
+	/* last write ended with unaligned length jump to next */
+	if (off != dfu->data.sf.start + dfu->offset)
+		off += dfu->data.sf.dev->sector_size;
+	length = dfu->data.sf.start + dfu->data.sf.size - off;
+	if (length)
+		return spi_flash_erase(dfu->data.sf.dev, off, length);
+
 	return 0;
 }
 
 static unsigned int dfu_polltimeout_sf(struct dfu_entity *dfu)
 {
+	/*
+	 * Currently, Poll Timeout != 0 is only needed on nand
+	 * ubi partition, as sectors which are not used need
+	 * to be erased
+	 */
+	if (CONFIG_IS_ENABLED(DFU_SF_PART) && dfu->data.sf.ubi)
+		return DFU_MANIFEST_POLL_TIMEOUT;
+
 	return DFU_DEFAULT_POLL_TIMEOUT;
 }
 
@@ -133,6 +157,34 @@ int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr, char *s)
 		dfu->data.sf.start = simple_strtoul(s, &s, 16);
 		s++;
 		dfu->data.sf.size = simple_strtoul(s, &s, 16);
+	} else if (CONFIG_IS_ENABLED(DFU_SF_PART) &&
+		   (!strcmp(st, "part") || !strcmp(st, "partubi"))) {
+		char mtd_id[32];
+		struct mtd_device *mtd_dev;
+		u8 part_num;
+		struct part_info *pi;
+		int ret, dev, part;
+
+		dfu->layout = DFU_RAW_ADDR;
+
+		dev = simple_strtoul(s, &s, 10);
+		s++;
+		part = simple_strtoul(s, &s, 10);
+
+		sprintf(mtd_id, "%s%d,%d", "nor", dev, part - 1);
+		printf("using id '%s'\n", mtd_id);
+
+		mtdparts_init();
+
+		ret = find_dev_and_part(mtd_id, &mtd_dev, &part_num, &pi);
+		if (ret != 0) {
+			printf("Could not locate '%s'\n", mtd_id);
+			return -1;
+		}
+		dfu->data.sf.start = pi->offset;
+		dfu->data.sf.size = pi->size;
+		if (!strcmp(st, "partubi"))
+			dfu->data.sf.ubi = 1;
 	} else {
 		printf("%s: Memory layout (%s) not supported!\n", __func__, st);
 		spi_flash_free(dfu->data.sf.dev);
diff --git a/include/dfu.h b/include/dfu.h
index 145a1576a3..bf51ab74a5 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -77,6 +77,8 @@ struct sf_internal_data {
 	/* RAW programming */
 	u64 start;
 	u64 size;
+	/* for sf/ubi use */
+	unsigned int ubi;
 };
 
 #define DFU_NAME_SIZE			32
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [U-Boot] [PATCH v3 04/15] dfu: prepare the support of multiple interface
  2019-10-14  7:27 [U-Boot] [PATCH v3 00/15] dfu: update dfu stack and add MTD backend Patrick Delaunay
                   ` (2 preceding siblings ...)
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 03/15] dfu: sf: add partition support for nor backend Patrick Delaunay
@ 2019-10-14  7:28 ` Patrick Delaunay
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 05/15] dfu: allow to manage DFU on several devices Patrick Delaunay
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 26+ messages in thread
From: Patrick Delaunay @ 2019-10-14  7:28 UTC (permalink / raw)
  To: u-boot

Split the function dfu_config_entities with 2 new functions
- dfu_alt_init
- dfu_alt_add

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

Changes in v3: None
Changes in v2: None

 drivers/dfu/dfu.c | 51 ++++++++++++++++++++++++++++++++++++-----------
 include/dfu.h     |  2 ++
 2 files changed, 41 insertions(+), 12 deletions(-)

diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index e9db7f8d66..900a844d15 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -439,13 +439,12 @@ void dfu_free_entities(void)
 	alt_num_cnt = 0;
 }
 
-int dfu_config_entities(char *env, char *interface, char *devstr)
+int dfu_alt_init(int num, struct dfu_entity **dfu)
 {
-	struct dfu_entity *dfu;
-	int i, ret;
 	char *s;
+	int ret;
 
-	dfu_alt_num = dfu_find_alt_num(env);
+	dfu_alt_num = num;
 	debug("%s: dfu_alt_num=%d\n", __func__, dfu_alt_num);
 
 	dfu_hash_algo = NULL;
@@ -456,21 +455,49 @@ int dfu_config_entities(char *env, char *interface, char *devstr)
 			pr_err("Hash algorithm %s not supported\n", s);
 	}
 
-	dfu = calloc(sizeof(*dfu), dfu_alt_num);
-	if (!dfu)
+	*dfu = calloc(sizeof(struct dfu_entity), dfu_alt_num);
+	if (!*dfu)
+		return -1;
+
+	return 0;
+}
+
+int dfu_alt_add(struct dfu_entity *dfu, char *interface, char *devstr, char *s)
+{
+	struct dfu_entity *p_dfu;
+	int ret;
+
+	if (alt_num_cnt >= dfu_alt_num)
+		return -1;
+
+	p_dfu = &dfu[alt_num_cnt];
+	ret = dfu_fill_entity(p_dfu, s, alt_num_cnt, interface, devstr);
+	if (ret)
 		return -1;
-	for (i = 0; i < dfu_alt_num; i++) {
 
+	list_add_tail(&p_dfu->list, &dfu_list);
+	alt_num_cnt++;
+
+	return 0;
+}
+
+int dfu_config_entities(char *env, char *interface, char *devstr)
+{
+	struct dfu_entity *dfu;
+	int i, ret;
+	char *s;
+
+	ret = dfu_alt_init(dfu_find_alt_num(env), &dfu);
+	if (ret)
+		return -1;
+
+	for (i = 0; i < dfu_alt_num; i++) {
 		s = strsep(&env, ";");
-		ret = dfu_fill_entity(&dfu[i], s, alt_num_cnt, interface,
-				      devstr);
+		ret = dfu_alt_add(dfu, interface, devstr, s);
 		if (ret) {
 			/* We will free "dfu" in dfu_free_entities() */
 			return -1;
 		}
-
-		list_add_tail(&dfu[i].list, &dfu_list);
-		alt_num_cnt++;
 	}
 
 	return 0;
diff --git a/include/dfu.h b/include/dfu.h
index bf51ab74a5..7d60ffc228 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -143,6 +143,8 @@ struct dfu_entity {
 #ifdef CONFIG_SET_DFU_ALT_INFO
 void set_dfu_alt_info(char *interface, char *devstr);
 #endif
+int dfu_alt_init(int num, struct dfu_entity **dfu);
+int dfu_alt_add(struct dfu_entity *dfu, char *interface, char *devstr, char *s);
 int dfu_config_entities(char *s, char *interface, char *devstr);
 void dfu_free_entities(void);
 void dfu_show_entities(void);
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [U-Boot] [PATCH v3 05/15] dfu: allow to manage DFU on several devices
  2019-10-14  7:27 [U-Boot] [PATCH v3 00/15] dfu: update dfu stack and add MTD backend Patrick Delaunay
                   ` (3 preceding siblings ...)
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 04/15] dfu: prepare the support of multiple interface Patrick Delaunay
@ 2019-10-14  7:28 ` Patrick Delaunay
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 06/15] dfu: allow read with no data without error for EOF indication Patrick Delaunay
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 26+ messages in thread
From: Patrick Delaunay @ 2019-10-14  7:28 UTC (permalink / raw)
  To: u-boot

Add support of DFU for several interface/device
with one command.

The format for "dfu_alt_info" in this case is :
- <interface> <dev>'='alternate list (';' separated)
- each interface is separated by '&'

The previous behavior is always supported.

One example for NOR (bootloaders) + NAND (rootfs in UBI):

U-Boot> env set dfu_alt_info \
"sf 0:0:10000000:0=spl part 0 1;u-boot part 0 2; \
u-boot-env part 0 3&nand 0=UBI partubi 0,3"

U-Boot> dfu 0 list

DFU alt settings list:
dev: SF alt: 0 name: spl layout: RAW_ADDR
dev: SF alt: 1 name: ssbl layout: RAW_ADDR
dev: SF alt: 2 name: u-boot-env layout: RAW_ADDR
dev: NAND alt: 3 name: UBI layout: RAW_ADDR

U-Boot> dfu 0

$> dfu-util -l

Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\
 intf=0, alt=3, name="UBI", serial="002700333338511934383330"
Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\
 intf=0, alt=2, name="u-boot-env", serial="002700333338511934383330"
Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\
 intf=0, alt=1, name="u-boot", serial="002700333338511934383330"
Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\
 intf=0, alt=0, name="spl", serial="002700333338511934383330"

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

Changes in v3: None
Changes in v2:
- Add dfu documentation for several device

 cmd/dfu.c         | 21 ++++++++++-------
 doc/README.dfu    | 58 ++++++++++++++++++++++++++++++++++++++++++---
 drivers/dfu/dfu.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 127 insertions(+), 12 deletions(-)

diff --git a/cmd/dfu.c b/cmd/dfu.c
index 91a750a4fc..33491d0bc9 100644
--- a/cmd/dfu.c
+++ b/cmd/dfu.c
@@ -21,23 +21,28 @@
 static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 
-	if (argc < 4)
+	if (argc < 2)
 		return CMD_RET_USAGE;
 
 #ifdef CONFIG_DFU_OVER_USB
 	char *usb_controller = argv[1];
 #endif
 #if defined(CONFIG_DFU_OVER_USB) || defined(CONFIG_DFU_OVER_TFTP)
-	char *interface = argv[2];
-	char *devstring = argv[3];
+	char *interface = NULL;
+	char *devstring = NULL;
+
+	if (argc >= 4) {
+		interface = argv[2];
+		devstring = argv[3];
+	}
 #endif
 
 	int ret = 0;
 #ifdef CONFIG_DFU_OVER_TFTP
 	unsigned long addr = 0;
 	if (!strcmp(argv[1], "tftp")) {
-		if (argc == 5)
-			addr = simple_strtoul(argv[4], NULL, 0);
+		if (argc == 5 || argc == 3)
+			addr = simple_strtoul(argv[argc - 1], NULL, 0);
 
 		return update_tftp(addr, interface, devstring);
 	}
@@ -48,7 +53,7 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		goto done;
 
 	ret = CMD_RET_SUCCESS;
-	if (argc > 4 && strcmp(argv[4], "list") == 0) {
+	if (strcmp(argv[argc - 1], "list") == 0) {
 		dfu_show_entities();
 		goto done;
 	}
@@ -67,7 +72,7 @@ U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu,
 	"Device Firmware Upgrade",
 	""
 #ifdef CONFIG_DFU_OVER_USB
-	"<USB_controller> <interface> <dev> [list]\n"
+	"<USB_controller> [<interface> <dev>] [list]\n"
 	"  - device firmware upgrade via <USB_controller>\n"
 	"    on device <dev>, attached to interface\n"
 	"    <interface>\n"
@@ -77,7 +82,7 @@ U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu,
 #ifdef CONFIG_DFU_OVER_USB
 	"dfu "
 #endif
-	"tftp <interface> <dev> [<addr>]\n"
+	"tftp [<interface> <dev>] [<addr>]\n"
 	"  - device firmware upgrade via TFTP\n"
 	"    on device <dev>, attached to interface\n"
 	"    <interface>\n"
diff --git a/doc/README.dfu b/doc/README.dfu
index 7a2b5f1d4b..d1ef7e4064 100644
--- a/doc/README.dfu
+++ b/doc/README.dfu
@@ -42,16 +42,25 @@ Environment variables:
                    separated string of information on each alternate:
                    dfu_alt_info="<alt1>;<alt2>;....;<altN>"
 
+                   when only several device are used, the format is:
+                   - <interface> <dev>'='alternate list (';' separated)
+                   - each interface is separated by '&'
+                dfu_alt_info=\
+                   "<interface1> <dev1>=<alt1>;....;<altN>&"\
+                   "<interface2> <dev2>=<altN+1>;....;<altM>&"\
+                   ...\
+                   "<interfaceI> <devI>=<altY+1>;....;<altZ>&"
+
   "dfu_bufsiz" : size of the DFU buffer, when absent, use
                  CONFIG_SYS_DFU_DATA_BUF_SIZE (8MiB by default)
 
   "dfu_hash_algo" : name of the hash algorithm to use
 
 Commands:
-  dfu <USB_controller> <interface> <dev> list
+  dfu <USB_controller> [<interface> <dev>] list
     list the alternate device defined in "dfu_alt_info"
 
-  dfu <USB_controller> <interface> <dev>
+  dfu <USB_controller> [<interface> <dev>]
     start the dfu stack on the USB instance with the selected medium
     backend and use the "dfu_alt_info" variable to configure the
     alternate setting and link each one with the medium
@@ -95,6 +104,18 @@ Commands:
 
       with <partid> is the MTD partition index
 
+  <interface> and <dev> are absent:
+    the dfu command to use multiple devices
+    cmd: dfu 0 list
+    cmd: dfu 0
+   "dfu_alt_info" variable provides the list of <interface> <dev> with
+   alternate list separated by '&' with the same format for each <alt>
+       mmc <dev>=<alt1>;....;<altN>
+       nand <dev>=<alt1>;....;<altN>
+       ram <dev>=<alt1>;....;<altN>
+       sf <dev>=<alt1>;....;<altN>
+
+
 Host tools:
   When U-Boot runs the dfu stack, the DFU host tools can be used
   to send/receive firmwares on each configurated alternate.
@@ -103,7 +124,7 @@ Host tools:
   specifications(http://dfu-util.sourceforge.net/) which works with U-Boot.
 
 Usage:
-  Example for firmware located in eMMC or SD card, with:
+  Example 1: firmware located in eMMC or SD card, with:
   - alternate 1 (alt=1) for SPL partition (GPT partition 1)
   - alternate 2 (alt=2) for U-Boot partition (GPT partition 2)
 
@@ -147,3 +168,34 @@ Usage:
 
   To request a DFU detach and reset the USB connection:
   $> dfu-util -a 0 -e  -R
+
+
+  Example 2: firmware located in NOR (sf) and NAND, with:
+  - alternate 1 (alt=1) for SPL partition (NOR GPT partition 1)
+  - alternate 2 (alt=2) for U-Boot partition (NOR GPT partition 2)
+  - alternate 3 (alt=3) for U-Boot-env partition (NOR GPT partition 3)
+  - alternate 4 (alt=4) for UBI partition (NAND GPT partition 1)
+
+  U-Boot> env set dfu_alt_info \
+  "sf 0:0:10000000:0=spl part 0 1;u-boot part 0 2; \
+  u-boot-env part 0 3&nand 0=UBI partubi 0,1"
+
+  U-Boot> dfu 0 list
+
+  DFU alt settings list:
+  dev: SF alt: 0 name: spl layout: RAW_ADDR
+  dev: SF alt: 1 name: ssbl layout: RAW_ADDR
+  dev: SF alt: 2 name: u-boot-env layout: RAW_ADDR
+  dev: NAND alt: 3 name: UBI layout: RAW_ADDR
+
+  U-Boot> dfu 0
+
+  $> dfu-util -l
+  Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\
+     intf=0, alt=3, name="UBI", serial="002700333338511934383330"
+  Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\
+     intf=0, alt=2, name="u-boot-env", serial="002700333338511934383330"
+  Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\
+     intf=0, alt=1, name="u-boot", serial="002700333338511934383330"
+  Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\
+     intf=0, alt=0, name="spl", serial="002700333338511934383330"
diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 900a844d15..8bd5216017 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -53,6 +53,54 @@ static int dfu_find_alt_num(const char *s)
 	return ++i;
 }
 
+/*
+ * treat dfu_alt_info with several interface information
+ * to allow DFU on several device with one command,
+ * the string format is
+ * interface devstring'='alternate list (';' separated)
+ * and each interface separated by '&'
+ */
+int dfu_config_interfaces(char *env)
+{
+	struct dfu_entity *dfu;
+	char *s, *i, *d, *a, *part;
+	int ret = -EINVAL;
+	int n = 1;
+
+	s = env;
+	for (; *s; s++) {
+		if (*s == ';')
+			n++;
+		if (*s == '&')
+			n++;
+	}
+	ret = dfu_alt_init(n, &dfu);
+	if (ret)
+		return ret;
+
+	s = env;
+	while (s) {
+		ret = -EINVAL;
+		i = strsep(&s, " ");
+		if (!i)
+			break;
+		d = strsep(&s, "=");
+		if (!d)
+			break;
+		a = strsep(&s, "&");
+		if (!a)
+			a = s;
+		do {
+			part = strsep(&a, ";");
+			ret = dfu_alt_add(dfu, i, d, part);
+			if (ret)
+				return ret;
+		} while (a);
+	}
+
+	return ret;
+}
+
 int dfu_init_env_entities(char *interface, char *devstr)
 {
 	const char *str_env;
@@ -69,7 +117,11 @@ int dfu_init_env_entities(char *interface, char *devstr)
 	}
 
 	env_bkp = strdup(str_env);
-	ret = dfu_config_entities(env_bkp, interface, devstr);
+	if (!interface && !devstr)
+		ret = dfu_config_interfaces(env_bkp);
+	else
+		ret = dfu_config_entities(env_bkp, interface, devstr);
+
 	if (ret) {
 		pr_err("DFU entities configuration failed!\n");
 		pr_err("(partition table does not match dfu_alt_info?)\n");
@@ -83,6 +135,7 @@ done:
 
 static unsigned char *dfu_buf;
 static unsigned long dfu_buf_size;
+static enum dfu_device_type dfu_buf_device_type;
 
 unsigned char *dfu_free_buf(void)
 {
@@ -100,6 +153,10 @@ unsigned char *dfu_get_buf(struct dfu_entity *dfu)
 {
 	char *s;
 
+	/* manage several entity with several contraint */
+	if (dfu_buf && dfu->dev_type != dfu_buf_device_type)
+		dfu_free_buf();
+
 	if (dfu_buf != NULL)
 		return dfu_buf;
 
@@ -118,6 +175,7 @@ unsigned char *dfu_get_buf(struct dfu_entity *dfu)
 		printf("%s: Could not memalign 0x%lx bytes\n",
 		       __func__, dfu_buf_size);
 
+	dfu_buf_device_type = dfu->dev_type;
 	return dfu_buf;
 }
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [U-Boot] [PATCH v3 06/15] dfu: allow read with no data without error for EOF indication
  2019-10-14  7:27 [U-Boot] [PATCH v3 00/15] dfu: update dfu stack and add MTD backend Patrick Delaunay
                   ` (4 preceding siblings ...)
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 05/15] dfu: allow to manage DFU on several devices Patrick Delaunay
@ 2019-10-14  7:28 ` Patrick Delaunay
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 07/15] dfu: add backend for MTD device Patrick Delaunay
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 26+ messages in thread
From: Patrick Delaunay @ 2019-10-14  7:28 UTC (permalink / raw)
  To: u-boot

This patch allows the DFU backend to indicate that that it can't
provide no more data to fill the DFU buffer, by setting b_left =0
without error, even if the size of received data is lower of the
expected total size indicated by get_medium_size.

For USB DFU stack point of view, it is acceptable:
the read length < requested size in DFU_UPLOAD and the
transaction is stopped.

That avoid infinite loop issue in dfu_read_buffer_fill because the
size for the DFU read is limited by get_medium_size = r_left
and the DFU stack expects that read is allowed up to this size.

This issue never occurs for current flash device (where chunk are
always completely read, and b_left will be never 0) but it is useful for
virtual partition when the backend only know the max size of this
alternate, the real size of the data are only known in the read
treatment.

PS: for file access on mmc, EOF is never reached as
    dfu_get_medium_size_mmc returns the exact size of the file.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

Changes in v3: None
Changes in v2:
- Update commit message

 drivers/dfu/dfu.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 8bd5216017..50919fcae9 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -396,6 +396,8 @@ static int dfu_read_buffer_fill(struct dfu_entity *dfu, void *buf, int size)
 				debug("%s: Read error!\n", __func__);
 				return ret;
 			}
+			if (dfu->b_left == 0)
+				break;
 			dfu->offset += dfu->b_left;
 			dfu->r_left -= dfu->b_left;
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [U-Boot] [PATCH v3 07/15] dfu: add backend for MTD device
  2019-10-14  7:27 [U-Boot] [PATCH v3 00/15] dfu: update dfu stack and add MTD backend Patrick Delaunay
                   ` (5 preceding siblings ...)
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 06/15] dfu: allow read with no data without error for EOF indication Patrick Delaunay
@ 2019-10-14  7:28 ` Patrick Delaunay
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 08/15] dfu: add partition support for MTD backend Patrick Delaunay
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 26+ messages in thread
From: Patrick Delaunay @ 2019-10-14  7:28 UTC (permalink / raw)
  To: u-boot

Add DFU backend for MTD device: allow to read
and write on all MTD device (NAND, SPI-NOR,
SPI-NAND,...)

For example :
> set dfu_alt_info "nand_raw raw 0x0 0x100000"
> dfu 0 mtd nand0

This MTD backend provides the same level than dfu nand
backend for NAND and dfu sf backend for SPI-NOR;
So it can replace booth of them but it also
add support of spi-nand.

> set dfu_alt_info "nand_raw raw 0x0 0x100000"
> dfu 0 mtd spi-nand0

The backend code is based on the "mtd" command
introduced by commit 5db66b3aee6f ("cmd: mtd:
add 'mtd' command")

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

Changes in v3:
- update bad block support in erase loop

Changes in v2:
- Update commit message
- Update dfu documentation for MTD

 doc/README.dfu        |  10 ++
 drivers/dfu/Kconfig   |   6 ++
 drivers/dfu/Makefile  |   1 +
 drivers/dfu/dfu.c     |   5 +-
 drivers/dfu/dfu_mtd.c | 232 ++++++++++++++++++++++++++++++++++++++++++
 include/dfu.h         |  21 ++++
 6 files changed, 274 insertions(+), 1 deletion(-)
 create mode 100644 drivers/dfu/dfu_mtd.c

diff --git a/doc/README.dfu b/doc/README.dfu
index d1ef7e4064..96bced39d8 100644
--- a/doc/README.dfu
+++ b/doc/README.dfu
@@ -21,6 +21,7 @@ Overview:
   - NAND
   - RAM
   - SF (serial flash)
+  - MTD (all MTD device: NAND, SPI-NOR, SPI-NAND,...)
 
   These DFU backends are also used by
   - the dfutftp (see README.dfutftp)
@@ -30,6 +31,7 @@ Configuration Options:
   CONFIG_DFU
   CONFIG_DFU_OVER_USB
   CONFIG_DFU_MMC
+  CONFIG_DFU_MTD
   CONFIG_DFU_NAND
   CONFIG_DFU_RAM
   CONFIG_DFU_SF
@@ -104,6 +106,13 @@ Commands:
 
       with <partid> is the MTD partition index
 
+  "mtd" (all MTD device: NAND, SPI-NOR, SPI-NAND,...)
+    cmd: dfu 0 mtd <dev>
+      with <dev> the mtd identifier as defined in mtd command
+      (nand0, nor0, spi-nand0,...)
+    each element in "dfu_alt_info" =
+      <name> raw <offset> <size>  raw access to mtd device
+
   <interface> and <dev> are absent:
     the dfu command to use multiple devices
     cmd: dfu 0 list
@@ -114,6 +123,7 @@ Commands:
        nand <dev>=<alt1>;....;<altN>
        ram <dev>=<alt1>;....;<altN>
        sf <dev>=<alt1>;....;<altN>
+       mtd <dev>=<alt1>;....;<altN>
 
 
 Host tools:
diff --git a/drivers/dfu/Kconfig b/drivers/dfu/Kconfig
index 1cbec81128..1e1dff33d2 100644
--- a/drivers/dfu/Kconfig
+++ b/drivers/dfu/Kconfig
@@ -54,5 +54,11 @@ config DFU_SF_PART
 	  This option enables the support of "part" and "partubi" target in
 	  SPI flash DFU back end.
 
+config DFU_MTD
+	bool "MTD back end for DFU"
+	depends on MTD
+	help
+	  This option enables using DFU to read and write to on any MTD device.
+
 endif
 endmenu
diff --git a/drivers/dfu/Makefile b/drivers/dfu/Makefile
index 4164f342ac..ebb119f398 100644
--- a/drivers/dfu/Makefile
+++ b/drivers/dfu/Makefile
@@ -5,6 +5,7 @@
 
 obj-$(CONFIG_$(SPL_)DFU) += dfu.o
 obj-$(CONFIG_$(SPL_)DFU_MMC) += dfu_mmc.o
+obj-$(CONFIG_$(SPL_)DFU_MTD) += dfu_mtd.o
 obj-$(CONFIG_$(SPL_)DFU_NAND) += dfu_nand.o
 obj-$(CONFIG_$(SPL_)DFU_RAM) += dfu_ram.o
 obj-$(CONFIG_$(SPL_)DFU_SF) += dfu_sf.o
diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 50919fcae9..4f4a07b790 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -462,6 +462,9 @@ static int dfu_fill_entity(struct dfu_entity *dfu, char *s, int alt,
 	if (strcmp(interface, "mmc") == 0) {
 		if (dfu_fill_entity_mmc(dfu, devstr, s))
 			return -1;
+	} else if (strcmp(interface, "mtd") == 0) {
+		if (dfu_fill_entity_mtd(dfu, devstr, s))
+			return -1;
 	} else if (strcmp(interface, "nand") == 0) {
 		if (dfu_fill_entity_nand(dfu, devstr, s))
 			return -1;
@@ -566,7 +569,7 @@ int dfu_config_entities(char *env, char *interface, char *devstr)
 const char *dfu_get_dev_type(enum dfu_device_type t)
 {
 	const char *const dev_t[] = {NULL, "eMMC", "OneNAND", "NAND", "RAM",
-				     "SF"};
+				     "SF", "MTD"};
 	return dev_t[t];
 }
 
diff --git a/drivers/dfu/dfu_mtd.c b/drivers/dfu/dfu_mtd.c
new file mode 100644
index 0000000000..13fc837c69
--- /dev/null
+++ b/drivers/dfu/dfu_mtd.c
@@ -0,0 +1,232 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * dfu_mtd.c -- DFU for MTD device.
+ *
+ * Copyright (C) 2019,STMicroelectronics - All Rights Reserved
+ *
+ * Based on dfu_nand.c
+ */
+
+#include <common.h>
+#include <dfu.h>
+#include <mtd.h>
+
+static bool mtd_is_aligned_with_block_size(struct mtd_info *mtd, u64 size)
+{
+	return !do_div(size, mtd->erasesize);
+}
+
+static int mtd_block_op(enum dfu_op op, struct dfu_entity *dfu,
+			u64 offset, void *buf, long *len)
+{
+	u64 off, lim, remaining;
+	struct mtd_info *mtd = dfu->data.mtd.info;
+	struct mtd_oob_ops io_op = {};
+	int ret = 0;
+	bool has_pages = mtd->type == MTD_NANDFLASH ||
+			 mtd->type == MTD_MLCNANDFLASH;
+
+	/* if buf == NULL return total size of the area */
+	if (!buf) {
+		*len = dfu->data.mtd.size;
+		return 0;
+	}
+
+	off = dfu->data.mtd.start + offset + dfu->bad_skip;
+	lim = dfu->data.mtd.start + dfu->data.mtd.size;
+
+	if (off >= lim) {
+		printf("Limit reached 0x%llx\n", lim);
+		*len = 0;
+		return op == DFU_OP_READ ? 0 : -EIO;
+	}
+	/* limit request with the available size */
+	if (off + *len >= lim)
+		*len = lim - off;
+
+	if (!mtd_is_aligned_with_block_size(mtd, off)) {
+		printf("Offset not aligned with a block (0x%x)\n",
+		       mtd->erasesize);
+		return 0;
+	}
+
+	/* first erase */
+	if (op == DFU_OP_WRITE) {
+		struct erase_info erase_op = {};
+
+		remaining = round_up(*len, mtd->erasesize);
+		erase_op.mtd = mtd;
+		erase_op.addr = off;
+		erase_op.len = mtd->erasesize;
+		erase_op.scrub = 0;
+
+		while (remaining) {
+			if (erase_op.addr + remaining > lim) {
+				printf("Limit reached 0x%llx while erasing at offset 0x%llx\n",
+				       lim, off);
+				return -EIO;
+			}
+
+			ret = mtd_erase(mtd, &erase_op);
+
+			if (ret) {
+				/* Abort if its not a bad block error */
+				if (ret != -EIO) {
+					printf("Failure while erasing at offset 0x%llx\n",
+					       erase_op.fail_addr);
+					return 0;
+				}
+				printf("Skipping bad block at 0x%08llx\n",
+				       erase_op.addr);
+			} else {
+				remaining -= mtd->erasesize;
+			}
+
+			/* Continue erase behind bad block */
+			erase_op.addr += mtd->erasesize;
+		}
+	}
+
+	io_op.mode = MTD_OPS_AUTO_OOB;
+	io_op.len = *len;
+	if (has_pages && io_op.len > mtd->writesize)
+		io_op.len = mtd->writesize;
+	io_op.ooblen = 0;
+	io_op.datbuf = buf;
+	io_op.oobbuf = NULL;
+
+	/* Loop over to do the actual read/write */
+	remaining = *len;
+	while (remaining) {
+		if (off + remaining > lim) {
+			printf("Limit reached 0x%llx while %s at offset 0x%llx\n",
+			       lim, op == DFU_OP_READ ? "reading" : "writing",
+			       off);
+			if (op == DFU_OP_READ) {
+				*len -= remaining;
+				return 0;
+			} else {
+				return -EIO;
+			}
+		}
+
+		/* Skip the block if it is bad */
+		if (mtd_is_aligned_with_block_size(mtd, off) &&
+		    mtd_block_isbad(mtd, off)) {
+			off += mtd->erasesize;
+			dfu->bad_skip += mtd->erasesize;
+			continue;
+		}
+
+		if (op == DFU_OP_READ)
+			ret = mtd_read_oob(mtd, off, &io_op);
+		else
+			ret = mtd_write_oob(mtd, off, &io_op);
+
+		if (ret) {
+			printf("Failure while %s at offset 0x%llx\n",
+			       op == DFU_OP_READ ? "reading" : "writing", off);
+			return -EIO;
+		}
+
+		off += io_op.retlen;
+		remaining -= io_op.retlen;
+		io_op.datbuf += io_op.retlen;
+		io_op.len = remaining;
+		if (has_pages && io_op.len > mtd->writesize)
+			io_op.len = mtd->writesize;
+	}
+
+	return ret;
+}
+
+static int dfu_get_medium_size_mtd(struct dfu_entity *dfu, u64 *size)
+{
+	*size = dfu->data.mtd.info->size;
+
+	return 0;
+}
+
+static int dfu_read_medium_mtd(struct dfu_entity *dfu, u64 offset, void *buf,
+			       long *len)
+{
+	int ret = -1;
+
+	switch (dfu->layout) {
+	case DFU_RAW_ADDR:
+		ret = mtd_block_op(DFU_OP_READ, dfu, offset, buf, len);
+		break;
+	default:
+		printf("%s: Layout (%s) not (yet) supported!\n", __func__,
+		       dfu_get_layout(dfu->layout));
+	}
+
+	return ret;
+}
+
+static int dfu_write_medium_mtd(struct dfu_entity *dfu,
+				u64 offset, void *buf, long *len)
+{
+	int ret = -1;
+
+	switch (dfu->layout) {
+	case DFU_RAW_ADDR:
+		ret = mtd_block_op(DFU_OP_WRITE, dfu, offset, buf, len);
+		break;
+	default:
+		printf("%s: Layout (%s) not (yet) supported!\n", __func__,
+		       dfu_get_layout(dfu->layout));
+	}
+
+	return ret;
+}
+
+static int dfu_flush_medium_mtd(struct dfu_entity *dfu)
+{
+	return 0;
+}
+
+static unsigned int dfu_polltimeout_mtd(struct dfu_entity *dfu)
+{
+	return DFU_DEFAULT_POLL_TIMEOUT;
+}
+
+int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char *s)
+{
+	char *st;
+	struct mtd_info *mtd;
+	bool has_pages;
+
+	mtd = get_mtd_device_nm(devstr);
+	if (IS_ERR_OR_NULL(mtd))
+		return -ENODEV;
+	put_mtd_device(mtd);
+
+	dfu->dev_type = DFU_DEV_MTD;
+	dfu->data.mtd.info = mtd;
+
+	has_pages = mtd->type == MTD_NANDFLASH || mtd->type == MTD_MLCNANDFLASH;
+	dfu->max_buf_size = has_pages ? mtd->erasesize : 0;
+
+	st = strsep(&s, " ");
+	if (!strcmp(st, "raw")) {
+		dfu->layout = DFU_RAW_ADDR;
+		dfu->data.mtd.start = simple_strtoul(s, &s, 16);
+		s++;
+		dfu->data.mtd.size = simple_strtoul(s, &s, 16);
+	} else {
+		printf("%s: (%s) not supported!\n", __func__, st);
+		return -1;
+	}
+
+	dfu->get_medium_size = dfu_get_medium_size_mtd;
+	dfu->read_medium = dfu_read_medium_mtd;
+	dfu->write_medium = dfu_write_medium_mtd;
+	dfu->flush_medium = dfu_flush_medium_mtd;
+	dfu->poll_timeout = dfu_polltimeout_mtd;
+
+	/* initial state */
+	dfu->inited = 0;
+
+	return 0;
+}
diff --git a/include/dfu.h b/include/dfu.h
index 7d60ffc228..924952f805 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -22,6 +22,7 @@ enum dfu_device_type {
 	DFU_DEV_NAND,
 	DFU_DEV_RAM,
 	DFU_DEV_SF,
+	DFU_DEV_MTD,
 };
 
 enum dfu_layout {
@@ -55,6 +56,14 @@ struct mmc_internal_data {
 	unsigned int part;
 };
 
+struct mtd_internal_data {
+	struct mtd_info *info;
+
+	/* RAW programming */
+	u64 start;
+	u64 size;
+};
+
 struct nand_internal_data {
 	/* RAW programming */
 	u64 start;
@@ -105,6 +114,7 @@ struct dfu_entity {
 
 	union {
 		struct mmc_internal_data mmc;
+		struct mtd_internal_data mtd;
 		struct nand_internal_data nand;
 		struct ram_internal_data ram;
 		struct sf_internal_data sf;
@@ -249,6 +259,17 @@ static inline int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr,
 }
 #endif
 
+#if CONFIG_IS_ENABLED(DFU_MTD)
+int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char *s);
+#else
+static inline int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr,
+				      char *s)
+{
+	puts("MTD support not available!\n");
+	return -1;
+}
+#endif
+
 /**
  * dfu_tftp_write - Write TFTP data to DFU medium
  *
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [U-Boot] [PATCH v3 08/15] dfu: add partition support for MTD backend
  2019-10-14  7:27 [U-Boot] [PATCH v3 00/15] dfu: update dfu stack and add MTD backend Patrick Delaunay
                   ` (6 preceding siblings ...)
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 07/15] dfu: add backend for MTD device Patrick Delaunay
@ 2019-10-14  7:28 ` Patrick Delaunay
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 09/15] dfu: add DFU virtual backend Patrick Delaunay
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 26+ messages in thread
From: Patrick Delaunay @ 2019-10-14  7:28 UTC (permalink / raw)
  To: u-boot

Add the support of MTD partition for the MTD backend.

The expected dfu_alt_info for one alternate on the mtd device :
	<name> part <part_id>
        <name> partubi <part_id>

"partubi" also erase up to the end of the partition after write operation.

For example: dfu_alt_info = "spl part 1;u-boot part 2; UBI partubi 3"

U-Boot> dfu 0 mtd nand0

Acked-by: Lukasz Majewski <lukma@denx.de>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

Changes in v3:
- Update loop management for erase

Changes in v2:
- Update dfu documentation for MTD

 doc/README.dfu        | 21 +++++++++++
 drivers/dfu/dfu_mtd.c | 81 ++++++++++++++++++++++++++++++++++++++++++-
 include/dfu.h         |  2 ++
 3 files changed, 103 insertions(+), 1 deletion(-)

diff --git a/doc/README.dfu b/doc/README.dfu
index 96bced39d8..92a7695be2 100644
--- a/doc/README.dfu
+++ b/doc/README.dfu
@@ -112,6 +112,10 @@ Commands:
       (nand0, nor0, spi-nand0,...)
     each element in "dfu_alt_info" =
       <name> raw <offset> <size>  raw access to mtd device
+      <name> part <dev> <part_id>  raw acces to partition
+      <name> partubi <dev> <part_id>  raw acces to ubi partition
+
+      with <partid> is the MTD partition index
 
   <interface> and <dev> are absent:
     the dfu command to use multiple devices
@@ -209,3 +213,20 @@ Usage:
      intf=0, alt=1, name="u-boot", serial="002700333338511934383330"
   Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\
      intf=0, alt=0, name="spl", serial="002700333338511934383330"
+
+  Same example with MTD backend
+
+   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"
+
+  U-Boot> dfu 0 list
+  using id 'nor0,0'
+  using id 'nor0,1'
+  using id 'nor0,2'
+  using id 'nand0,0'
+  DFU alt settings list:
+  dev: MTD alt: 0 name: spl layout: RAW_ADDR
+  dev: MTD alt: 1 name: u-boot layout: RAW_ADDR
+  dev: MTD alt: 2 name: u-boot-env layout: RAW_ADDR
+  dev: MTD alt: 3 name: UBI layout: RAW_ADDR
diff --git a/drivers/dfu/dfu_mtd.c b/drivers/dfu/dfu_mtd.c
index 13fc837c69..9528a7b4ee 100644
--- a/drivers/dfu/dfu_mtd.c
+++ b/drivers/dfu/dfu_mtd.c
@@ -10,6 +10,7 @@
 #include <common.h>
 #include <dfu.h>
 #include <mtd.h>
+#include <jffs2/load_kernel.h>
 
 static bool mtd_is_aligned_with_block_size(struct mtd_info *mtd, u64 size)
 {
@@ -183,11 +184,52 @@ static int dfu_write_medium_mtd(struct dfu_entity *dfu,
 
 static int dfu_flush_medium_mtd(struct dfu_entity *dfu)
 {
+	struct mtd_info *mtd = dfu->data.mtd.info;
+	u64 remaining;
+	int ret;
+
+	/* in case of ubi partition, erase rest of the partition */
+	if (dfu->data.nand.ubi) {
+		struct erase_info erase_op = {};
+
+		erase_op.mtd = dfu->data.mtd.info;
+		erase_op.addr = round_up(dfu->data.mtd.start + dfu->offset +
+					 dfu->bad_skip, mtd->erasesize);
+		erase_op.len = mtd->erasesize;
+		erase_op.scrub = 0;
+
+		remaining = dfu->data.mtd.start + dfu->data.mtd.size -
+			    erase_op.addr;
+
+		while (remaining) {
+			ret = mtd_erase(mtd, &erase_op);
+
+			if (ret) {
+				/* Abort if its not a bad block error */
+				if (ret != -EIO)
+					break;
+				printf("Skipping bad block at 0x%08llx\n",
+				       erase_op.addr);
+			}
+
+			/* Skip bad block and continue behind it */
+			erase_op.addr += mtd->erasesize;
+			remaining -= mtd->erasesize;
+		}
+	}
 	return 0;
 }
 
 static unsigned int dfu_polltimeout_mtd(struct dfu_entity *dfu)
 {
+	/*
+	 * Currently, Poll Timeout != 0 is only needed on nand
+	 * ubi partition, as sectors which are not used need
+	 * to be erased
+	 */
+	if (dfu->data.nand.ubi)
+		return DFU_MANIFEST_POLL_TIMEOUT;
+
 	return DFU_DEFAULT_POLL_TIMEOUT;
 }
 
@@ -196,6 +238,7 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char *s)
 	char *st;
 	struct mtd_info *mtd;
 	bool has_pages;
+	int ret, part;
 
 	mtd = get_mtd_device_nm(devstr);
 	if (IS_ERR_OR_NULL(mtd))
@@ -214,11 +257,47 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char *s)
 		dfu->data.mtd.start = simple_strtoul(s, &s, 16);
 		s++;
 		dfu->data.mtd.size = simple_strtoul(s, &s, 16);
+	} else if ((!strcmp(st, "part")) || (!strcmp(st, "partubi"))) {
+		char mtd_id[32];
+		struct mtd_device *mtd_dev;
+		u8 part_num;
+		struct part_info *pi;
+
+		dfu->layout = DFU_RAW_ADDR;
+
+		part = simple_strtoul(s, &s, 10);
+
+		sprintf(mtd_id, "%s,%d", devstr, part - 1);
+		printf("using id '%s'\n", mtd_id);
+
+		mtdparts_init();
+
+		ret = find_dev_and_part(mtd_id, &mtd_dev, &part_num, &pi);
+		if (ret != 0) {
+			printf("Could not locate '%s'\n", mtd_id);
+			return -1;
+		}
+
+		dfu->data.mtd.start = pi->offset;
+		dfu->data.mtd.size = pi->size;
+		if (!strcmp(st, "partubi"))
+			dfu->data.mtd.ubi = 1;
 	} else {
-		printf("%s: (%s) not supported!\n", __func__, st);
+		printf("%s: Memory layout (%s) not supported!\n", __func__, st);
 		return -1;
 	}
 
+	if (!mtd_is_aligned_with_block_size(mtd, dfu->data.mtd.start)) {
+		printf("Offset not aligned with a block (0x%x)\n",
+		       mtd->erasesize);
+		return -EINVAL;
+	}
+	if (!mtd_is_aligned_with_block_size(mtd, dfu->data.mtd.size)) {
+		printf("Size not aligned with a block (0x%x)\n",
+		       mtd->erasesize);
+		return -EINVAL;
+	}
+
 	dfu->get_medium_size = dfu_get_medium_size_mtd;
 	dfu->read_medium = dfu_read_medium_mtd;
 	dfu->write_medium = dfu_write_medium_mtd;
diff --git a/include/dfu.h b/include/dfu.h
index 924952f805..a90732cc43 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -62,6 +62,8 @@ struct mtd_internal_data {
 	/* RAW programming */
 	u64 start;
 	u64 size;
+	/* for ubi partition */
+	unsigned int ubi;
 };
 
 struct nand_internal_data {
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [U-Boot] [PATCH v3 09/15] dfu: add DFU virtual backend
  2019-10-14  7:27 [U-Boot] [PATCH v3 00/15] dfu: update dfu stack and add MTD backend Patrick Delaunay
                   ` (7 preceding siblings ...)
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 08/15] dfu: add partition support for MTD backend Patrick Delaunay
@ 2019-10-14  7:28 ` Patrick Delaunay
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 10/15] dfu: add callback for flush and initiated operation Patrick Delaunay
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 26+ messages in thread
From: Patrick Delaunay @ 2019-10-14  7:28 UTC (permalink / raw)
  To: u-boot

Add a virtual DFU backend to allow board specific read and write
(for OTP update for example).

Acked-by: Lukasz Majewski <lukma@denx.de>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

Changes in v3: None
Changes in v2:
- Update dfu documentation for virtual backend

 doc/README.dfu         | 32 ++++++++++++++++++++++++++-
 drivers/dfu/Kconfig    |  7 ++++++
 drivers/dfu/Makefile   |  1 +
 drivers/dfu/dfu.c      |  5 ++++-
 drivers/dfu/dfu_virt.c | 49 ++++++++++++++++++++++++++++++++++++++++++
 include/dfu.h          | 22 +++++++++++++++++++
 6 files changed, 114 insertions(+), 2 deletions(-)
 create mode 100644 drivers/dfu/dfu_virt.c

diff --git a/doc/README.dfu b/doc/README.dfu
index 92a7695be2..43a6f311d6 100644
--- a/doc/README.dfu
+++ b/doc/README.dfu
@@ -22,11 +22,18 @@ Overview:
   - RAM
   - SF (serial flash)
   - MTD (all MTD device: NAND, SPI-NOR, SPI-NAND,...)
+  - virtual
 
   These DFU backends are also used by
   - the dfutftp (see README.dfutftp)
   - the thordown command (cmd/thordown.c and gadget/f_thor.c)
 
+  The "virtual" backend is a generic DFU backend to support a board specific
+  target (for example OTP), only based on the weak functions:
+  - dfu_write_medium_virt
+  - dfu_get_medium_size_virt
+  - dfu_read_medium_virt
+
 Configuration Options:
   CONFIG_DFU
   CONFIG_DFU_OVER_USB
@@ -36,6 +43,7 @@ Configuration Options:
   CONFIG_DFU_RAM
   CONFIG_DFU_SF
   CONFIG_DFU_SF_PART
+  CONFIG_DFU_VIRTUAL
   CONFIG_CMD_DFU
 
 Environment variables:
@@ -117,6 +125,11 @@ Commands:
 
       with <partid> is the MTD partition index
 
+  "virt"
+    cmd: dfu 0 virt <dev>
+    each element in "dfu_alt_info" =
+      <name>
+
   <interface> and <dev> are absent:
     the dfu command to use multiple devices
     cmd: dfu 0 list
@@ -128,7 +141,7 @@ Commands:
        ram <dev>=<alt1>;....;<altN>
        sf <dev>=<alt1>;....;<altN>
        mtd <dev>=<alt1>;....;<altN>
-
+       virt <dev>=<alt1>;....;<altN>
 
 Host tools:
   When U-Boot runs the dfu stack, the DFU host tools can be used
@@ -230,3 +243,20 @@ Usage:
   dev: MTD alt: 1 name: u-boot layout: RAW_ADDR
   dev: MTD alt: 2 name: u-boot-env layout: RAW_ADDR
   dev: MTD alt: 3 name: UBI layout: RAW_ADDR
+
+  Example 3: firmware located in SD Card (mmc) and virtual partition on
+             OTP and PMIC not volatile memory
+  - alternate 1 (alt=1) for scard
+  - alternate 2 (alt=2) for OTP (virtual)
+  - alternate 3 (alt=3) for PMIC NVM (virtual)
+
+   U-Boot> env set dfu_alt_info \
+      "mmc 0=sdcard raw 0 0x100000&"\
+      "virt 0=otp" \
+      "virt 1=pmic"
+
+   U-Boot> dfu 0 list
+   DFU alt settings list:
+   dev: eMMC alt: 0 name: sdcard layout: RAW_ADDR
+   dev: VIRT alt: 1 name: otp layout: RAW_ADDR
+   dev: VIRT alt: 2 name: pmic layout: RAW_ADDR
diff --git a/drivers/dfu/Kconfig b/drivers/dfu/Kconfig
index 1e1dff33d2..9fe5bc0f58 100644
--- a/drivers/dfu/Kconfig
+++ b/drivers/dfu/Kconfig
@@ -60,5 +60,12 @@ config DFU_MTD
 	help
 	  This option enables using DFU to read and write to on any MTD device.
 
+config DFU_VIRT
+	bool "VIRTUAL flash back end for DFU"
+	help
+	  This option enables using DFU to read and write to VIRTUAL device
+	  used at board level to manage specific behavior
+	  (OTP update for example).
+
 endif
 endmenu
diff --git a/drivers/dfu/Makefile b/drivers/dfu/Makefile
index ebb119f398..0d7925c083 100644
--- a/drivers/dfu/Makefile
+++ b/drivers/dfu/Makefile
@@ -10,3 +10,4 @@ obj-$(CONFIG_$(SPL_)DFU_NAND) += dfu_nand.o
 obj-$(CONFIG_$(SPL_)DFU_RAM) += dfu_ram.o
 obj-$(CONFIG_$(SPL_)DFU_SF) += dfu_sf.o
 obj-$(CONFIG_$(SPL_)DFU_TFTP) += dfu_tftp.o
+obj-$(CONFIG_$(SPL_)DFU_VIRT) += dfu_virt.o
diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 4f4a07b790..2697235c24 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -474,6 +474,9 @@ static int dfu_fill_entity(struct dfu_entity *dfu, char *s, int alt,
 	} else if (strcmp(interface, "sf") == 0) {
 		if (dfu_fill_entity_sf(dfu, devstr, s))
 			return -1;
+	} else if (strcmp(interface, "virt") == 0) {
+		if (dfu_fill_entity_virt(dfu, devstr, s))
+			return -1;
 	} else {
 		printf("%s: Device %s not (yet) supported!\n",
 		       __func__,  interface);
@@ -569,7 +572,7 @@ int dfu_config_entities(char *env, char *interface, char *devstr)
 const char *dfu_get_dev_type(enum dfu_device_type t)
 {
 	const char *const dev_t[] = {NULL, "eMMC", "OneNAND", "NAND", "RAM",
-				     "SF", "MTD"};
+				     "SF", "MTD", "VIRT"};
 	return dev_t[t];
 }
 
diff --git a/drivers/dfu/dfu_virt.c b/drivers/dfu/dfu_virt.c
new file mode 100644
index 0000000000..ea8c71f100
--- /dev/null
+++ b/drivers/dfu/dfu_virt.c
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
+/*
+ * Copyright (C) 2019, STMicroelectronics - All Rights Reserved
+ */
+#include <common.h>
+#include <dfu.h>
+#include <errno.h>
+#include <malloc.h>
+
+int __weak dfu_write_medium_virt(struct dfu_entity *dfu, u64 offset,
+				 void *buf, long *len)
+{
+	debug("%s: off=0x%llx, len=0x%x\n", __func__, offset, (u32)*len);
+
+	return 0;
+}
+
+int __weak dfu_get_medium_size_virt(struct dfu_entity *dfu, u64 *size)
+{
+	*size = 0;
+
+	return 0;
+}
+
+int __weak dfu_read_medium_virt(struct dfu_entity *dfu, u64 offset,
+				void *buf, long *len)
+{
+	debug("%s: off=0x%llx, len=0x%x\n", __func__, offset, (u32)*len);
+	*len = 0;
+
+	return 0;
+}
+
+int dfu_fill_entity_virt(struct dfu_entity *dfu, char *devstr, char *s)
+{
+	debug("%s: devstr = %s\n", __func__, devstr);
+
+	dfu->dev_type = DFU_DEV_VIRT;
+	dfu->layout = DFU_RAW_ADDR;
+	dfu->data.virt.dev_num = simple_strtoul(devstr, NULL, 10);
+
+	dfu->write_medium = dfu_write_medium_virt;
+	dfu->get_medium_size = dfu_get_medium_size_virt;
+	dfu->read_medium = dfu_read_medium_virt;
+
+	dfu->inited = 0;
+
+	return 0;
+}
diff --git a/include/dfu.h b/include/dfu.h
index a90732cc43..4de7d35914 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -23,6 +23,7 @@ enum dfu_device_type {
 	DFU_DEV_RAM,
 	DFU_DEV_SF,
 	DFU_DEV_MTD,
+	DFU_DEV_VIRT,
 };
 
 enum dfu_layout {
@@ -92,6 +93,10 @@ struct sf_internal_data {
 	unsigned int ubi;
 };
 
+struct virt_internal_data {
+	int dev_num;
+};
+
 #define DFU_NAME_SIZE			32
 #ifndef CONFIG_SYS_DFU_DATA_BUF_SIZE
 #define CONFIG_SYS_DFU_DATA_BUF_SIZE		(1024*1024*8)	/* 8 MiB */
@@ -120,6 +125,7 @@ struct dfu_entity {
 		struct nand_internal_data nand;
 		struct ram_internal_data ram;
 		struct sf_internal_data sf;
+		struct virt_internal_data virt;
 	} data;
 
 	int (*get_medium_size)(struct dfu_entity *dfu, u64 *size);
@@ -272,6 +278,22 @@ static inline int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr,
 }
 #endif
 
+#ifdef CONFIG_DFU_VIRT
+int dfu_fill_entity_virt(struct dfu_entity *dfu, char *devstr, char *s);
+int dfu_write_medium_virt(struct dfu_entity *dfu, u64 offset,
+			  void *buf, long *len);
+int dfu_get_medium_size_virt(struct dfu_entity *dfu, u64 *size);
+int dfu_read_medium_virt(struct dfu_entity *dfu, u64 offset,
+			 void *buf, long *len);
+#else
+static inline int dfu_fill_entity_virt(struct dfu_entity *dfu, char *devstr,
+				       char *s)
+{
+	puts("VIRT support not available!\n");
+	return -1;
+}
+#endif
+
 /**
  * dfu_tftp_write - Write TFTP data to DFU medium
  *
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [U-Boot] [PATCH v3 10/15] dfu: add callback for flush and initiated operation
  2019-10-14  7:27 [U-Boot] [PATCH v3 00/15] dfu: update dfu stack and add MTD backend Patrick Delaunay
                   ` (8 preceding siblings ...)
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 09/15] dfu: add DFU virtual backend Patrick Delaunay
@ 2019-10-14  7:28 ` Patrick Delaunay
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 11/15] stm32mp1: activate DFU support and command MTD Patrick Delaunay
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 26+ messages in thread
From: Patrick Delaunay @ 2019-10-14  7:28 UTC (permalink / raw)
  To: u-boot

Add weak callback to allow board specific behavior
- flush
- initiated

This patch prepare usage of DFU back end for communication with
STM32CubeProgrammer on stm32mp1 platform with stm32prog command.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

Changes in v3: None
Changes in v2:
- Update dfu documentation for callbacks
- Update callbacks comment after Lukasz review

 doc/README.dfu    |  8 ++++++++
 drivers/dfu/dfu.c | 19 +++++++++++++++++++
 include/dfu.h     | 22 ++++++++++++++++++++++
 3 files changed, 49 insertions(+)

diff --git a/doc/README.dfu b/doc/README.dfu
index 43a6f311d6..558d347c26 100644
--- a/doc/README.dfu
+++ b/doc/README.dfu
@@ -143,6 +143,14 @@ Commands:
        mtd <dev>=<alt1>;....;<altN>
        virt <dev>=<alt1>;....;<altN>
 
+Callbacks:
+  The weak callback functions can be implemented to manage specific behavior
+  - dfu_initiated_callback  : called when the DFU transaction is started,
+                              used to initiase the device
+  - dfu_flush_callback      : called at the end of the DFU write after DFU
+                              manifestation, used to manage the device when
+                              DFU transaction is closed
+
 Host tools:
   When U-Boot runs the dfu stack, the DFU host tools can be used
   to send/receive firmwares on each configurated alternate.
diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 2697235c24..38aecd3a05 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -22,6 +22,22 @@ static int dfu_alt_num;
 static int alt_num_cnt;
 static struct hash_algo *dfu_hash_algo;
 
+/*
+ * The purpose of the dfu_flush_callback() function is to
+ * provide callback for dfu user
+ */
+__weak void dfu_flush_callback(struct dfu_entity *dfu)
+{
+}
+
+/*
+ * The purpose of the dfu_initiated_callback() function is to
+ * provide callback for dfu user
+ */
+__weak void dfu_initiated_callback(struct dfu_entity *dfu)
+{
+}
+
 /*
  * The purpose of the dfu_usb_get_reset() function is to
  * provide information if after USB_DETACH request
@@ -263,6 +279,7 @@ int dfu_transaction_initiate(struct dfu_entity *dfu, bool read)
 	}
 
 	dfu->inited = 1;
+	dfu_initiated_callback(dfu);
 
 	return 0;
 }
@@ -282,6 +299,8 @@ int dfu_flush(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num)
 		printf("\nDFU complete %s: 0x%08x\n", dfu_hash_algo->name,
 		       dfu->crc);
 
+	dfu_flush_callback(dfu);
+
 	dfu_transaction_cleanup(dfu);
 
 	return ret;
diff --git a/include/dfu.h b/include/dfu.h
index 4de7d35914..564966333f 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -183,6 +183,28 @@ int dfu_read(struct dfu_entity *de, void *buf, int size, int blk_seq_num);
 int dfu_write(struct dfu_entity *de, void *buf, int size, int blk_seq_num);
 int dfu_flush(struct dfu_entity *de, void *buf, int size, int blk_seq_num);
 
+/**
+ * dfu_initiated_callback - weak callback called on DFU transaction start
+ *
+ * It is a callback function called by DFU stack when a DFU transaction is
+ * initiated. This function allows to manage some board specific behavior on
+ * DFU targets.
+ *
+ * @param dfu - pointer to the dfu_entity, which should be initialized
+ *
+ */
+void dfu_initiated_callback(struct dfu_entity *dfu);
+/**
+ * dfu_flush_callback - weak callback called at the end of the DFU write
+ *
+ * It is a callback function called by DFU stack after DFU manifestation.
+ * This function allows to manage some board specific behavior on DFU targets
+ *
+ * @param dfu - pointer to the dfu_entity, which should be flushed
+ *
+ */
+void dfu_flush_callback(struct dfu_entity *dfu);
+
 /*
  * dfu_defer_flush - pointer to store dfu_entity for deferred flashing.
  *		     It should be NULL when not used.
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [U-Boot] [PATCH v3 11/15] stm32mp1: activate DFU support and command MTD
  2019-10-14  7:27 [U-Boot] [PATCH v3 00/15] dfu: update dfu stack and add MTD backend Patrick Delaunay
                   ` (9 preceding siblings ...)
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 10/15] dfu: add callback for flush and initiated operation Patrick Delaunay
@ 2019-10-14  7:28 ` Patrick Delaunay
  2019-10-23  9:12   ` [U-Boot] [Uboot-stm32] " Patrice CHOTARD
  2019-11-27 13:39   ` [U-Boot] " Patrick DELAUNAY
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 12/15] stm32mp1: activate SET_DFU_ALT_INFO Patrick Delaunay
                   ` (3 subsequent siblings)
  14 siblings, 2 replies; 26+ messages in thread
From: Patrick Delaunay @ 2019-10-14  7:28 UTC (permalink / raw)
  To: u-boot

Add support of DFU for MMC, MTD, RAM and MTD command.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

Changes in v3: None
Changes in v2: None

 configs/stm32mp15_basic_defconfig   | 4 ++++
 configs/stm32mp15_optee_defconfig   | 4 ++++
 configs/stm32mp15_trusted_defconfig | 4 ++++
 3 files changed, 12 insertions(+)

diff --git a/configs/stm32mp15_basic_defconfig b/configs/stm32mp15_basic_defconfig
index f6c68feb6f..cd4fc20ca5 100644
--- a/configs/stm32mp15_basic_defconfig
+++ b/configs/stm32mp15_basic_defconfig
@@ -34,6 +34,7 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_MTD=y
 CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_SPI=y
@@ -62,6 +63,9 @@ CONFIG_ENV_UBI_PART="UBI"
 CONFIG_ENV_UBI_VOLUME="uboot_config"
 CONFIG_ENV_UBI_VOLUME_REDUND="uboot_config_r"
 CONFIG_STM32_ADC=y
+CONFIG_DFU_MMC=y
+CONFIG_DFU_RAM=y
+CONFIG_DFU_MTD=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0xC0000000
 CONFIG_FASTBOOT_BUF_SIZE=0x02000000
diff --git a/configs/stm32mp15_optee_defconfig b/configs/stm32mp15_optee_defconfig
index 177cbc7d5f..8d3d2e8508 100644
--- a/configs/stm32mp15_optee_defconfig
+++ b/configs/stm32mp15_optee_defconfig
@@ -23,6 +23,7 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_MTD=y
 CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_SPI=y
@@ -49,6 +50,9 @@ CONFIG_ENV_UBI_PART="UBI"
 CONFIG_ENV_UBI_VOLUME="uboot_config"
 CONFIG_ENV_UBI_VOLUME_REDUND="uboot_config_r"
 CONFIG_STM32_ADC=y
+CONFIG_DFU_MMC=y
+CONFIG_DFU_RAM=y
+CONFIG_DFU_MTD=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0xC0000000
 CONFIG_FASTBOOT_BUF_SIZE=0x02000000
diff --git a/configs/stm32mp15_trusted_defconfig b/configs/stm32mp15_trusted_defconfig
index 71ad1157ec..8da8c4e22a 100644
--- a/configs/stm32mp15_trusted_defconfig
+++ b/configs/stm32mp15_trusted_defconfig
@@ -22,6 +22,7 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_MTD=y
 CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_SPI=y
@@ -48,6 +49,9 @@ CONFIG_ENV_UBI_PART="UBI"
 CONFIG_ENV_UBI_VOLUME="uboot_config"
 CONFIG_ENV_UBI_VOLUME_REDUND="uboot_config_r"
 CONFIG_STM32_ADC=y
+CONFIG_DFU_MMC=y
+CONFIG_DFU_RAM=y
+CONFIG_DFU_MTD=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0xC0000000
 CONFIG_FASTBOOT_BUF_SIZE=0x02000000
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [U-Boot] [PATCH v3 12/15] stm32mp1: activate SET_DFU_ALT_INFO
  2019-10-14  7:27 [U-Boot] [PATCH v3 00/15] dfu: update dfu stack and add MTD backend Patrick Delaunay
                   ` (10 preceding siblings ...)
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 11/15] stm32mp1: activate DFU support and command MTD Patrick Delaunay
@ 2019-10-14  7:28 ` Patrick Delaunay
  2019-10-23  9:15   ` [U-Boot] [Uboot-stm32] " Patrice CHOTARD
  2019-11-27 13:39   ` [U-Boot] " Patrick DELAUNAY
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 13/15] stm32mp1: configs: activate CONFIG_MTD_SPI_NAND Patrick Delaunay
                   ` (2 subsequent siblings)
  14 siblings, 2 replies; 26+ messages in thread
From: Patrick Delaunay @ 2019-10-14  7:28 UTC (permalink / raw)
  To: u-boot

Generate automatically dfu_alt_info for the supported device.
The simple command "dfu 0" allows to start the dfu stack on usb 0
for the supported devices:
- dfu mtd for nand0
- dfu mtd for nor0
- dfu mmc for SDCard
- dfu mmc for eMMC
- dfu ram for images in DDR

The DUF alternate use the "part", "partubi" and "mmcpart" options
to select the correct MTD or GPT partition or the eMMC hw boot partition.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

Changes in v3: None
Changes in v2: None

 board/st/stm32mp1/README     | 111 +++++++++++++++++++++++++++++++++++
 board/st/stm32mp1/stm32mp1.c |  51 ++++++++++++++++
 include/configs/stm32mp1.h   |  32 ++++++++++
 3 files changed, 194 insertions(+)

diff --git a/board/st/stm32mp1/README b/board/st/stm32mp1/README
index c807e0842e..f2069bcefa 100644
--- a/board/st/stm32mp1/README
+++ b/board/st/stm32mp1/README
@@ -390,3 +390,114 @@ B/ Automatically by using FIT feature and generic DISTRO bootcmd
     the correct configuration
 	=> stm32mp157c-ev1-m4
 	=> stm32mp157c-dk2-m4
+
+11. DFU support
+===============
+
+The DFU is supported on ST board.
+The env variable dfu_alt_info is automatically build, and all
+the memory present on the ST boards are exported.
+
+The mode is started by
+
+STM32MP> dfu 0
+
+On EV1 board:
+
+STM32MP> dfu 0 list
+
+DFU alt settings list:
+dev: RAM alt: 0 name: uImage layout: RAM_ADDR
+dev: RAM alt: 1 name: devicetree.dtb layout: RAM_ADDR
+dev: RAM alt: 2 name: uramdisk.image.gz layout: RAM_ADDR
+dev: eMMC alt: 3 name: sdcard_fsbl1 layout: RAW_ADDR
+dev: eMMC alt: 4 name: sdcard_fsbl2 layout: RAW_ADDR
+dev: eMMC alt: 5 name: sdcard_ssbl layout: RAW_ADDR
+dev: eMMC alt: 6 name: sdcard_bootfs layout: RAW_ADDR
+dev: eMMC alt: 7 name: sdcard_vendorfs layout: RAW_ADDR
+dev: eMMC alt: 8 name: sdcard_rootfs layout: RAW_ADDR
+dev: eMMC alt: 9 name: sdcard_userfs layout: RAW_ADDR
+dev: eMMC alt: 10 name: emmc_fsbl1 layout: RAW_ADDR
+dev: eMMC alt: 11 name: emmc_fsbl2 layout: RAW_ADDR
+dev: eMMC alt: 12 name: emmc_ssbl layout: RAW_ADDR
+dev: eMMC alt: 13 name: emmc_bootfs layout: RAW_ADDR
+dev: eMMC alt: 14 name: emmc_vendorfs layout: RAW_ADDR
+dev: eMMC alt: 15 name: emmc_rootfs layout: RAW_ADDR
+dev: eMMC alt: 16 name: emmc_userfs layout: RAW_ADDR
+dev: MTD alt: 17 name: nor_fsbl1 layout: RAW_ADDR
+dev: MTD alt: 18 name: nor_fsbl2 layout: RAW_ADDR
+dev: MTD alt: 19 name: nor_ssbl layout: RAW_ADDR
+dev: MTD alt: 20 name: nor_env layout: RAW_ADDR
+dev: MTD alt: 21 name: nand_fsbl layout: RAW_ADDR
+dev: MTD alt: 22 name: nand_ssbl1 layout: RAW_ADDR
+dev: MTD alt: 23 name: nand_ssbl2 layout: RAW_ADDR
+dev: MTD alt: 24 name: nand_UBI layout: RAW_ADDR
+dev: VIRT alt: 25 name: OTP layout: RAW_ADDR
+dev: VIRT alt: 26 name: PMIC layout: RAW_ADDR
+
+All the supported device are exported for dfu-util tool:
+
+$> dfu-util -l
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=26, name="PMIC", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=25, name="OTP", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=24, name="nand_UBI", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=23, name="nand_ssbl2", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=22, name="nand_ssbl1", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=21, name="nand_fsbl", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=20, name="nor_env", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=19, name="nor_ssbl", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=18, name="nor_fsbl2", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=17, name="nor_fsbl1", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=16, name="emmc_userfs", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=15, name="emmc_rootfs", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=14, name="emmc_vendorfs", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=13, name="emmc_bootfs", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=12, name="emmc_ssbl", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=11, name="emmc_fsbl2", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=10, name="emmc_fsbl1", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=9, name="sdcard_userfs", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=8, name="sdcard_rootfs", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=7, name="sdcard_vendorfs", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=6, name="sdcard_bootfs", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=5, name="sdcard_ssbl", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=4, name="sdcard_fsbl2", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=3, name="sdcard_fsbl1", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=2, name="uramdisk.image.gz", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=1, name="devicetree.dtb", serial="002700333338511934383330"
+Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=0, name="uImage", serial="002700333338511934383330"
+
+You can update the boot device:
+
+#SDCARD
+$> dfu-util -d 0483:5720 -a 3 -D tf-a-stm32mp157c-ev1-trusted.stm32
+$> dfu-util -d 0483:5720 -a 4 -D tf-a-stm32mp157c-ev1-trusted.stm32
+$> dfu-util -d 0483:5720 -a 5 -D u-boot-stm32mp157c-ev1-trusted.img
+$> dfu-util -d 0483:5720 -a 6 -D st-image-bootfs-openstlinux-weston-stm32mp1.ext4
+$> dfu-util -d 0483:5720 -a 7 -D st-image-vendorfs-openstlinux-weston-stm32mp1.ext4
+$> dfu-util -d 0483:5720 -a 8 -D st-image-weston-openstlinux-weston-stm32mp1.ext4
+$> dfu-util -d 0483:5720 -a 9 -D st-image-userfs-openstlinux-weston-stm32mp1.ext4
+
+#EMMC
+$> dfu-util -d 0483:5720 -a 10 -D tf-a-stm32mp157c-ev1-trusted.stm32
+$> dfu-util -d 0483:5720 -a 11 -D tf-a-stm32mp157c-ev1-trusted.stm32
+$> dfu-util -d 0483:5720 -a 12 -D u-boot-stm32mp157c-ev1-trusted.img
+$> dfu-util -d 0483:5720 -a 13 -D st-image-bootfs-openstlinux-weston-stm32mp1.ext4
+$> dfu-util -d 0483:5720 -a 14 -D st-image-vendorfs-openstlinux-weston-stm32mp1.ext4
+$> dfu-util -d 0483:5720 -a 15 -D st-image-weston-openstlinux-weston-stm32mp1.ext4
+$> dfu-util -d 0483:5720 -a 16 -D st-image-userfs-openstlinux-weston-stm32mp1.ext4
+
+#NOR
+$> dfu-util -d 0483:5720 -a 17 -D tf-a-stm32mp157c-ev1-trusted.stm32
+$> dfu-util -d 0483:5720 -a 18 -D tf-a-stm32mp157c-ev1-trusted.stm32
+$> dfu-util -d 0483:5720 -a 19 -D u-boot-stm32mp157c-ev1-trusted.img
+
+#NAND (UBI partition used for NAND only boot or NOR + NAND boot)
+$> dfu-util -d 0483:5720 -a 21 -D tf-a-stm32mp157c-ev1-trusted.stm32
+$> dfu-util -d 0483:5720 -a 22 -D u-boot-stm32mp157c-ev1-trusted.img
+$> dfu-util -d 0483:5720 -a 23 -D u-boot-stm32mp157c-ev1-trusted.img
+$> dfu-util -d 0483:5720 -a 24 -D st-image-weston-openstlinux-weston-stm32mp1_nand_4_256_multivolume.ubi
+
+And you can also dump the OTP and the PMIC NVM with:
+
+$> dfu-util -d 0483:5720 -a 25 -U otp.bin
+$> dfu-util -d 0483:5720 -a 26 -U pmic.bin
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 18f9b84876..62855988e9 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -14,6 +14,7 @@
 #include <generic-phy.h>
 #include <i2c.h>
 #include <led.h>
+#include <memalign.h>
 #include <misc.h>
 #include <mtd.h>
 #include <mtd_node.h>
@@ -903,6 +904,56 @@ int ft_board_setup(void *blob, bd_t *bd)
 }
 #endif
 
+#ifdef CONFIG_SET_DFU_ALT_INFO
+#define DFU_ALT_BUF_LEN SZ_1K
+
+static void board_get_alt_info(const char *dev, char *buff)
+{
+	char var_name[32] = "dfu_alt_info_";
+	int ret;
+
+	ALLOC_CACHE_ALIGN_BUFFER(char, tmp_alt, DFU_ALT_BUF_LEN);
+
+	/* name of env variable to read = dfu_alt_info_<dev> */
+	strcat(var_name, dev);
+	ret = env_get_f(var_name, tmp_alt, DFU_ALT_BUF_LEN);
+	if (ret) {
+		if (buff[0] != '\0')
+			strcat(buff, "&");
+		strncat(buff, tmp_alt, DFU_ALT_BUF_LEN);
+	}
+}
+
+void set_dfu_alt_info(char *interface, char *devstr)
+{
+	struct udevice *dev;
+
+	ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN);
+
+	if (env_get("dfu_alt_info"))
+		return;
+
+	memset(buf, 0, sizeof(buf));
+
+	board_get_alt_info("ram", buf);
+
+	if (!uclass_get_device(UCLASS_MMC, 0, &dev))
+		board_get_alt_info("mmc0", buf);
+
+	if (!uclass_get_device(UCLASS_MMC, 1, &dev))
+		board_get_alt_info("mmc1", buf);
+
+	if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev))
+		board_get_alt_info("nor0", buf);
+
+	if (!uclass_get_device(UCLASS_MTD, 0, &dev))
+		board_get_alt_info("nand0", buf);
+
+	env_set("dfu_alt_info", buf);
+	puts("DFU alt info setting: done\n");
+}
+#endif
+
 static void board_copro_image_process(ulong fw_image, size_t fw_size)
 {
 	int ret, id = 0; /* Copro id fixed to 0 as only one coproc on mp1 */
diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h
index 92660fe2a0..4f9024229e 100644
--- a/include/configs/stm32mp1.h
+++ b/include/configs/stm32mp1.h
@@ -83,6 +83,8 @@
 #define CONFIG_SYS_MTDPARTS_RUNTIME
 #endif
 
+#define CONFIG_SET_DFU_ALT_INFO
+
 /*****************************************************************************/
 #ifdef CONFIG_DISTRO_DEFAULTS
 /*****************************************************************************/
@@ -136,6 +138,34 @@
 #define STM32MP_MTDPARTS
 #endif
 
+#define STM32MP_DFU_ALT_RAM \
+	"dfu_alt_info_ram=ram 0=" \
+		"uImage ram ${kernel_addr_r} 0x2000000;" \
+		"devicetree.dtb ram ${fdt_addr_r} 0x100000;" \
+		"uramdisk.image.gz ram ${ramdisk_addr_r} 0x10000000\0"
+
+#ifdef CONFIG_SET_DFU_ALT_INFO
+#define STM32MP_DFU_ALT_INFO \
+	"dfu_alt_info_nor0=mtd nor0=" \
+		"nor_fsbl1 part 1;nor_fsbl2 part 2;" \
+		"nor_ssbl part 3;nor_env part 4\0" \
+	"dfu_alt_info_nand0=mtd nand0="\
+		"nand_fsbl part 1;nand_ssbl1 part 2;" \
+		"nand_ssbl2 part 3;nand_UBI partubi 4\0" \
+	"dfu_alt_info_mmc0=mmc 0=" \
+		"sdcard_fsbl1 part 0 1;sdcard_fsbl2 part 0 2;" \
+		"sdcard_ssbl part 0 3;sdcard_bootfs part 0 4;" \
+		"sdcard_vendorfs part 0 5;sdcard_rootfs part 0 6;" \
+		"sdcard_userfs part 0 7\0" \
+	"dfu_alt_info_mmc1=mmc 1=" \
+		"emmc_fsbl1 raw 0x0 0x200 mmcpart 1;" \
+		"emmc_fsbl2 raw 0x0 0x200 mmcpart 2;emmc_ssbl part 1 1;" \
+		"emmc_bootfs part 1 2;emmc_vendorfs part 1 3;" \
+		"emmc_rootfs part 1 4;emmc_userfs part 1 5\0"
+#else
+#define STM32MP_DFU_ALT_INFO
+#endif
+
 /*
  * memory layout for 32M uncompressed/compressed kernel,
  * 1M fdt, 1M script, 1M pxe and 1M for splashimage
@@ -157,6 +187,8 @@
 		" then env set env_default 0;env save;fi\0" \
 	STM32MP_BOOTCMD \
 	STM32MP_MTDPARTS \
+	STM32MP_DFU_ALT_RAM \
+	STM32MP_DFU_ALT_INFO \
 	BOOTENV \
 	"boot_net_usb_start=true\0"
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [U-Boot] [PATCH v3 13/15] stm32mp1: configs: activate CONFIG_MTD_SPI_NAND
  2019-10-14  7:27 [U-Boot] [PATCH v3 00/15] dfu: update dfu stack and add MTD backend Patrick Delaunay
                   ` (11 preceding siblings ...)
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 12/15] stm32mp1: activate SET_DFU_ALT_INFO Patrick Delaunay
@ 2019-10-14  7:28 ` Patrick Delaunay
  2019-10-23  9:16   ` [U-Boot] [Uboot-stm32] " Patrice CHOTARD
  2019-11-27 13:39   ` [U-Boot] " Patrick DELAUNAY
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 14/15] stm32mp1: board: add spi nand support Patrick Delaunay
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 15/15] stm32mp1: add support for virtual partition read Patrick Delaunay
  14 siblings, 2 replies; 26+ messages in thread
From: Patrick Delaunay @ 2019-10-14  7:28 UTC (permalink / raw)
  To: u-boot

Activate the support of SPI NAND in stm32mp1 U-Boot.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

Changes in v3: None
Changes in v2: None

 configs/stm32mp15_basic_defconfig   | 1 +
 configs/stm32mp15_optee_defconfig   | 1 +
 configs/stm32mp15_trusted_defconfig | 1 +
 3 files changed, 3 insertions(+)

diff --git a/configs/stm32mp15_basic_defconfig b/configs/stm32mp15_basic_defconfig
index cd4fc20ca5..699e687891 100644
--- a/configs/stm32mp15_basic_defconfig
+++ b/configs/stm32mp15_basic_defconfig
@@ -86,6 +86,7 @@ CONFIG_STM32_SDMMC2=y
 CONFIG_MTD=y
 CONFIG_NAND=y
 CONFIG_NAND_STM32_FMC2=y
+CONFIG_MTD_SPI_NAND=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_MACRONIX=y
diff --git a/configs/stm32mp15_optee_defconfig b/configs/stm32mp15_optee_defconfig
index 8d3d2e8508..387de0ad35 100644
--- a/configs/stm32mp15_optee_defconfig
+++ b/configs/stm32mp15_optee_defconfig
@@ -73,6 +73,7 @@ CONFIG_STM32_SDMMC2=y
 CONFIG_MTD=y
 CONFIG_NAND=y
 CONFIG_NAND_STM32_FMC2=y
+CONFIG_MTD_SPI_NAND=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_MACRONIX=y
diff --git a/configs/stm32mp15_trusted_defconfig b/configs/stm32mp15_trusted_defconfig
index 8da8c4e22a..29c23c634d 100644
--- a/configs/stm32mp15_trusted_defconfig
+++ b/configs/stm32mp15_trusted_defconfig
@@ -72,6 +72,7 @@ CONFIG_STM32_SDMMC2=y
 CONFIG_MTD=y
 CONFIG_NAND=y
 CONFIG_NAND_STM32_FMC2=y
+CONFIG_MTD_SPI_NAND=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_MACRONIX=y
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [U-Boot] [PATCH v3 14/15] stm32mp1: board: add spi nand support
  2019-10-14  7:27 [U-Boot] [PATCH v3 00/15] dfu: update dfu stack and add MTD backend Patrick Delaunay
                   ` (12 preceding siblings ...)
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 13/15] stm32mp1: configs: activate CONFIG_MTD_SPI_NAND Patrick Delaunay
@ 2019-10-14  7:28 ` Patrick Delaunay
  2019-10-23  9:20   ` [U-Boot] [Uboot-stm32] " Patrice CHOTARD
  2019-11-27 13:40   ` [U-Boot] " Patrick DELAUNAY
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 15/15] stm32mp1: add support for virtual partition read Patrick Delaunay
  14 siblings, 2 replies; 26+ messages in thread
From: Patrick Delaunay @ 2019-10-14  7:28 UTC (permalink / raw)
  To: u-boot

This patch adds the support of the spi nand device in mtdparts command
and in dfu_alt_info.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

Changes in v3: None
Changes in v2: None

 board/st/stm32mp1/stm32mp1.c | 32 +++++++++++++++++++++++++++++---
 include/configs/stm32mp1.h   | 10 ++++++++--
 2 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 62855988e9..e4bdf05cd7 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -862,8 +862,9 @@ static void board_get_mtdparts(const char *dev,
 
 void board_mtdparts_default(const char **mtdids, const char **mtdparts)
 {
+	struct mtd_info *mtd;
 	struct udevice *dev;
-	static char parts[2 * MTDPARTS_LEN + 1];
+	static char parts[3 * MTDPARTS_LEN + 1];
 	static char ids[MTDIDS_LEN + 1];
 	static bool mtd_initialized;
 
@@ -876,8 +877,24 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
 	memset(parts, 0, sizeof(parts));
 	memset(ids, 0, sizeof(ids));
 
-	if (!uclass_get_device(UCLASS_MTD, 0, &dev))
+	/* probe all MTD devices */
+	for (uclass_first_device(UCLASS_MTD, &dev);
+	     dev;
+	     uclass_next_device(&dev)) {
+		pr_debug("mtd device = %s\n", dev->name);
+	}
+
+	mtd = get_mtd_device_nm("nand0");
+	if (!IS_ERR_OR_NULL(mtd)) {
 		board_get_mtdparts("nand0", ids, parts);
+		put_mtd_device(mtd);
+	}
+
+	mtd = get_mtd_device_nm("spi-nand0");
+	if (!IS_ERR_OR_NULL(mtd)) {
+		board_get_mtdparts("spi-nand0", ids, parts);
+		put_mtd_device(mtd);
+	}
 
 	if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev))
 		board_get_mtdparts("nor0", ids, parts);
@@ -927,6 +944,7 @@ static void board_get_alt_info(const char *dev, char *buff)
 void set_dfu_alt_info(char *interface, char *devstr)
 {
 	struct udevice *dev;
+	struct mtd_info *mtd;
 
 	ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN);
 
@@ -935,6 +953,9 @@ void set_dfu_alt_info(char *interface, char *devstr)
 
 	memset(buf, 0, sizeof(buf));
 
+	/* probe all MTD devices */
+	mtd_probe_devices();
+
 	board_get_alt_info("ram", buf);
 
 	if (!uclass_get_device(UCLASS_MMC, 0, &dev))
@@ -946,9 +967,14 @@ void set_dfu_alt_info(char *interface, char *devstr)
 	if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev))
 		board_get_alt_info("nor0", buf);
 
-	if (!uclass_get_device(UCLASS_MTD, 0, &dev))
+	mtd = get_mtd_device_nm("nand0");
+	if (!IS_ERR_OR_NULL(mtd))
 		board_get_alt_info("nand0", buf);
 
+	mtd = get_mtd_device_nm("spi-nand0");
+	if (!IS_ERR_OR_NULL(mtd))
+		board_get_alt_info("spi-nand0", buf);
+
 	env_set("dfu_alt_info", buf);
 	puts("DFU alt info setting: done\n");
 }
diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h
index 4f9024229e..145a644efa 100644
--- a/include/configs/stm32mp1.h
+++ b/include/configs/stm32mp1.h
@@ -124,12 +124,15 @@
 /* with OPTEE: define specific MTD partitions = teeh, teed, teex */
 #define STM32MP_MTDPARTS \
 	"mtdparts_nor0=256k(fsbl1),256k(fsbl2),2m(ssbl),256k(u-boot-env),256k(teeh),256k(teed),256k(teex),-(nor_user)\0" \
-	"mtdparts_nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),512k(teeh),512k(teed),512k(teex),-(UBI)\0"
+	"mtdparts_nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),512k(teeh),512k(teed),512k(teex),-(UBI)\0" \
+	"mtdparts_spi-nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),"\
+		"512k(teeh),512k(teed),512k(teex),-(UBI)\0"
 
 #else /* CONFIG_STM32MP1_OPTEE */
 #define STM32MP_MTDPARTS \
 	"mtdparts_nor0=256k(fsbl1),256k(fsbl2),2m(ssbl),256k(u-boot-env),-(nor_user)\0" \
-	"mtdparts_nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),-(UBI)\0"
+	"mtdparts_nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),-(UBI)\0" \
+	"mtdparts_spi-nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),-(UBI)\0"
 
 #endif /* CONFIG_STM32MP1_OPTEE */
 
@@ -152,6 +155,9 @@
 	"dfu_alt_info_nand0=mtd nand0="\
 		"nand_fsbl part 1;nand_ssbl1 part 2;" \
 		"nand_ssbl2 part 3;nand_UBI partubi 4\0" \
+	"dfu_alt_info_spi-nand0=mtd spi-nand0="\
+		"spi-nand_fsbl part 1;spi-nand_ssbl1 part 2;" \
+		"spi-nand_ssbl2 part 3;spi-nand_UBI partubi 4\0" \
 	"dfu_alt_info_mmc0=mmc 0=" \
 		"sdcard_fsbl1 part 0 1;sdcard_fsbl2 part 0 2;" \
 		"sdcard_ssbl part 0 3;sdcard_bootfs part 0 4;" \
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [U-Boot] [PATCH v3 15/15] stm32mp1: add support for virtual partition read
  2019-10-14  7:27 [U-Boot] [PATCH v3 00/15] dfu: update dfu stack and add MTD backend Patrick Delaunay
                   ` (13 preceding siblings ...)
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 14/15] stm32mp1: board: add spi nand support Patrick Delaunay
@ 2019-10-14  7:28 ` Patrick Delaunay
  2019-10-23  9:27   ` [U-Boot] [Uboot-stm32] " Patrice CHOTARD
  2019-11-27 13:41   ` [U-Boot] " Patrick DELAUNAY
  14 siblings, 2 replies; 26+ messages in thread
From: Patrick Delaunay @ 2019-10-14  7:28 UTC (permalink / raw)
  To: u-boot

Add read for OTP and PMIC NVM with alternates
on virtual DFU device.

Serie-cc: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

Changes in v3:
- rebase on v2019.10
- remove previous patch 16/16 pushed by error in v2
  http://patchwork.ozlabs.org/patch/1162076/

Changes in v2:
- Update after Lukasz Majewski comments

 board/st/stm32mp1/stm32mp1.c        | 83 +++++++++++++++++++++++++++++
 configs/stm32mp15_basic_defconfig   |  1 +
 configs/stm32mp15_optee_defconfig   |  1 +
 configs/stm32mp15_trusted_defconfig |  1 +
 4 files changed, 86 insertions(+)

diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index e4bdf05cd7..6045850c05 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -975,9 +975,92 @@ void set_dfu_alt_info(char *interface, char *devstr)
 	if (!IS_ERR_OR_NULL(mtd))
 		board_get_alt_info("spi-nand0", buf);
 
+#ifdef CONFIG_DFU_VIRT
+	strncat(buf, "&virt 0=OTP", DFU_ALT_BUF_LEN);
+
+	if (IS_ENABLED(CONFIG_PMIC_STPMIC1))
+		strncat(buf, "&virt 1=PMIC", DFU_ALT_BUF_LEN);
+#endif
+
 	env_set("dfu_alt_info", buf);
 	puts("DFU alt info setting: done\n");
 }
+
+#if CONFIG_IS_ENABLED(DFU_VIRT)
+#include <dfu.h>
+#include <power/stpmic1.h>
+
+int dfu_otp_read(u64 offset, u8 *buffer, long *size)
+{
+	struct udevice *dev;
+	int ret;
+
+	ret = uclass_get_device_by_driver(UCLASS_MISC,
+					  DM_GET_DRIVER(stm32mp_bsec),
+					  &dev);
+	if (ret)
+		return ret;
+
+	ret = misc_read(dev, offset + STM32_BSEC_OTP_OFFSET, buffer, *size);
+	if (ret >= 0) {
+		*size = ret;
+		ret = 0;
+	}
+
+	return 0;
+}
+
+int dfu_pmic_read(u64 offset, u8 *buffer, long *size)
+{
+	int ret;
+#ifdef CONFIG_PMIC_STPMIC1
+	struct udevice *dev;
+
+	ret = uclass_get_device_by_driver(UCLASS_MISC,
+					  DM_GET_DRIVER(stpmic1_nvm),
+					  &dev);
+	if (ret)
+		return ret;
+
+	ret = misc_read(dev, 0xF8 + offset, buffer, *size);
+	if (ret >= 0) {
+		*size = ret;
+		ret = 0;
+	}
+	if (ret == -EACCES) {
+		*size = 0;
+		ret = 0;
+	}
+#else
+	pr_err("PMIC update not supported");
+	ret = -EOPNOTSUPP;
+#endif
+
+	return ret;
+}
+
+int dfu_read_medium_virt(struct dfu_entity *dfu, u64 offset,
+			 void *buf, long *len)
+{
+	switch (dfu->data.virt.dev_num) {
+	case 0x0:
+		return dfu_otp_read(offset, buf, len);
+	case 0x1:
+		return dfu_pmic_read(offset, buf, len);
+	}
+	*len = 0;
+	return 0;
+}
+
+int __weak dfu_get_medium_size_virt(struct dfu_entity *dfu, u64 *size)
+{
+	*size = SZ_1K;
+
+	return 0;
+}
+
+#endif
+
 #endif
 
 static void board_copro_image_process(ulong fw_image, size_t fw_size)
diff --git a/configs/stm32mp15_basic_defconfig b/configs/stm32mp15_basic_defconfig
index 699e687891..29e697ee67 100644
--- a/configs/stm32mp15_basic_defconfig
+++ b/configs/stm32mp15_basic_defconfig
@@ -66,6 +66,7 @@ CONFIG_STM32_ADC=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
 CONFIG_DFU_MTD=y
+CONFIG_DFU_VIRT=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0xC0000000
 CONFIG_FASTBOOT_BUF_SIZE=0x02000000
diff --git a/configs/stm32mp15_optee_defconfig b/configs/stm32mp15_optee_defconfig
index 387de0ad35..3b8a90de2d 100644
--- a/configs/stm32mp15_optee_defconfig
+++ b/configs/stm32mp15_optee_defconfig
@@ -53,6 +53,7 @@ CONFIG_STM32_ADC=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
 CONFIG_DFU_MTD=y
+CONFIG_DFU_VIRT=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0xC0000000
 CONFIG_FASTBOOT_BUF_SIZE=0x02000000
diff --git a/configs/stm32mp15_trusted_defconfig b/configs/stm32mp15_trusted_defconfig
index 29c23c634d..bcbd8a5c4e 100644
--- a/configs/stm32mp15_trusted_defconfig
+++ b/configs/stm32mp15_trusted_defconfig
@@ -52,6 +52,7 @@ CONFIG_STM32_ADC=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
 CONFIG_DFU_MTD=y
+CONFIG_DFU_VIRT=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0xC0000000
 CONFIG_FASTBOOT_BUF_SIZE=0x02000000
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [U-Boot] [Uboot-stm32] [PATCH v3 11/15] stm32mp1: activate DFU support and command MTD
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 11/15] stm32mp1: activate DFU support and command MTD Patrick Delaunay
@ 2019-10-23  9:12   ` Patrice CHOTARD
  2019-11-27 13:39   ` [U-Boot] " Patrick DELAUNAY
  1 sibling, 0 replies; 26+ messages in thread
From: Patrice CHOTARD @ 2019-10-23  9:12 UTC (permalink / raw)
  To: u-boot

Hi Patrick

On 10/14/19 9:28 AM, Patrick Delaunay wrote:
> Add support of DFU for MMC, MTD, RAM and MTD command.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  configs/stm32mp15_basic_defconfig   | 4 ++++
>  configs/stm32mp15_optee_defconfig   | 4 ++++
>  configs/stm32mp15_trusted_defconfig | 4 ++++
>  3 files changed, 12 insertions(+)
>
> diff --git a/configs/stm32mp15_basic_defconfig b/configs/stm32mp15_basic_defconfig
> index f6c68feb6f..cd4fc20ca5 100644
> --- a/configs/stm32mp15_basic_defconfig
> +++ b/configs/stm32mp15_basic_defconfig
> @@ -34,6 +34,7 @@ CONFIG_CMD_GPIO=y
>  CONFIG_CMD_GPT=y
>  CONFIG_CMD_I2C=y
>  CONFIG_CMD_MMC=y
> +CONFIG_CMD_MTD=y
>  CONFIG_CMD_REMOTEPROC=y
>  CONFIG_CMD_SF=y
>  CONFIG_CMD_SPI=y
> @@ -62,6 +63,9 @@ CONFIG_ENV_UBI_PART="UBI"
>  CONFIG_ENV_UBI_VOLUME="uboot_config"
>  CONFIG_ENV_UBI_VOLUME_REDUND="uboot_config_r"
>  CONFIG_STM32_ADC=y
> +CONFIG_DFU_MMC=y
> +CONFIG_DFU_RAM=y
> +CONFIG_DFU_MTD=y
>  CONFIG_USB_FUNCTION_FASTBOOT=y
>  CONFIG_FASTBOOT_BUF_ADDR=0xC0000000
>  CONFIG_FASTBOOT_BUF_SIZE=0x02000000
> diff --git a/configs/stm32mp15_optee_defconfig b/configs/stm32mp15_optee_defconfig
> index 177cbc7d5f..8d3d2e8508 100644
> --- a/configs/stm32mp15_optee_defconfig
> +++ b/configs/stm32mp15_optee_defconfig
> @@ -23,6 +23,7 @@ CONFIG_CMD_GPIO=y
>  CONFIG_CMD_GPT=y
>  CONFIG_CMD_I2C=y
>  CONFIG_CMD_MMC=y
> +CONFIG_CMD_MTD=y
>  CONFIG_CMD_REMOTEPROC=y
>  CONFIG_CMD_SF=y
>  CONFIG_CMD_SPI=y
> @@ -49,6 +50,9 @@ CONFIG_ENV_UBI_PART="UBI"
>  CONFIG_ENV_UBI_VOLUME="uboot_config"
>  CONFIG_ENV_UBI_VOLUME_REDUND="uboot_config_r"
>  CONFIG_STM32_ADC=y
> +CONFIG_DFU_MMC=y
> +CONFIG_DFU_RAM=y
> +CONFIG_DFU_MTD=y
>  CONFIG_USB_FUNCTION_FASTBOOT=y
>  CONFIG_FASTBOOT_BUF_ADDR=0xC0000000
>  CONFIG_FASTBOOT_BUF_SIZE=0x02000000
> diff --git a/configs/stm32mp15_trusted_defconfig b/configs/stm32mp15_trusted_defconfig
> index 71ad1157ec..8da8c4e22a 100644
> --- a/configs/stm32mp15_trusted_defconfig
> +++ b/configs/stm32mp15_trusted_defconfig
> @@ -22,6 +22,7 @@ CONFIG_CMD_GPIO=y
>  CONFIG_CMD_GPT=y
>  CONFIG_CMD_I2C=y
>  CONFIG_CMD_MMC=y
> +CONFIG_CMD_MTD=y
>  CONFIG_CMD_REMOTEPROC=y
>  CONFIG_CMD_SF=y
>  CONFIG_CMD_SPI=y
> @@ -48,6 +49,9 @@ CONFIG_ENV_UBI_PART="UBI"
>  CONFIG_ENV_UBI_VOLUME="uboot_config"
>  CONFIG_ENV_UBI_VOLUME_REDUND="uboot_config_r"
>  CONFIG_STM32_ADC=y
> +CONFIG_DFU_MMC=y
> +CONFIG_DFU_RAM=y
> +CONFIG_DFU_MTD=y
>  CONFIG_USB_FUNCTION_FASTBOOT=y
>  CONFIG_FASTBOOT_BUF_ADDR=0xC0000000
>  CONFIG_FASTBOOT_BUF_SIZE=0x02000000

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>

Thanks

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot] [Uboot-stm32] [PATCH v3 12/15] stm32mp1: activate SET_DFU_ALT_INFO
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 12/15] stm32mp1: activate SET_DFU_ALT_INFO Patrick Delaunay
@ 2019-10-23  9:15   ` Patrice CHOTARD
  2019-11-27 13:39   ` [U-Boot] " Patrick DELAUNAY
  1 sibling, 0 replies; 26+ messages in thread
From: Patrice CHOTARD @ 2019-10-23  9:15 UTC (permalink / raw)
  To: u-boot

Hi Patrick

On 10/14/19 9:28 AM, Patrick Delaunay wrote:
> Generate automatically dfu_alt_info for the supported device.
> The simple command "dfu 0" allows to start the dfu stack on usb 0
> for the supported devices:
> - dfu mtd for nand0
> - dfu mtd for nor0
> - dfu mmc for SDCard
> - dfu mmc for eMMC
> - dfu ram for images in DDR
>
> The DUF alternate use the "part", "partubi" and "mmcpart" options
> to select the correct MTD or GPT partition or the eMMC hw boot partition.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  board/st/stm32mp1/README     | 111 +++++++++++++++++++++++++++++++++++
>  board/st/stm32mp1/stm32mp1.c |  51 ++++++++++++++++
>  include/configs/stm32mp1.h   |  32 ++++++++++
>  3 files changed, 194 insertions(+)
>
> diff --git a/board/st/stm32mp1/README b/board/st/stm32mp1/README
> index c807e0842e..f2069bcefa 100644
> --- a/board/st/stm32mp1/README
> +++ b/board/st/stm32mp1/README
> @@ -390,3 +390,114 @@ B/ Automatically by using FIT feature and generic DISTRO bootcmd
>      the correct configuration
>  	=> stm32mp157c-ev1-m4
>  	=> stm32mp157c-dk2-m4
> +
> +11. DFU support
> +===============
> +
> +The DFU is supported on ST board.
> +The env variable dfu_alt_info is automatically build, and all
> +the memory present on the ST boards are exported.
> +
> +The mode is started by
> +
> +STM32MP> dfu 0
> +
> +On EV1 board:
> +
> +STM32MP> dfu 0 list
> +
> +DFU alt settings list:
> +dev: RAM alt: 0 name: uImage layout: RAM_ADDR
> +dev: RAM alt: 1 name: devicetree.dtb layout: RAM_ADDR
> +dev: RAM alt: 2 name: uramdisk.image.gz layout: RAM_ADDR
> +dev: eMMC alt: 3 name: sdcard_fsbl1 layout: RAW_ADDR
> +dev: eMMC alt: 4 name: sdcard_fsbl2 layout: RAW_ADDR
> +dev: eMMC alt: 5 name: sdcard_ssbl layout: RAW_ADDR
> +dev: eMMC alt: 6 name: sdcard_bootfs layout: RAW_ADDR
> +dev: eMMC alt: 7 name: sdcard_vendorfs layout: RAW_ADDR
> +dev: eMMC alt: 8 name: sdcard_rootfs layout: RAW_ADDR
> +dev: eMMC alt: 9 name: sdcard_userfs layout: RAW_ADDR
> +dev: eMMC alt: 10 name: emmc_fsbl1 layout: RAW_ADDR
> +dev: eMMC alt: 11 name: emmc_fsbl2 layout: RAW_ADDR
> +dev: eMMC alt: 12 name: emmc_ssbl layout: RAW_ADDR
> +dev: eMMC alt: 13 name: emmc_bootfs layout: RAW_ADDR
> +dev: eMMC alt: 14 name: emmc_vendorfs layout: RAW_ADDR
> +dev: eMMC alt: 15 name: emmc_rootfs layout: RAW_ADDR
> +dev: eMMC alt: 16 name: emmc_userfs layout: RAW_ADDR
> +dev: MTD alt: 17 name: nor_fsbl1 layout: RAW_ADDR
> +dev: MTD alt: 18 name: nor_fsbl2 layout: RAW_ADDR
> +dev: MTD alt: 19 name: nor_ssbl layout: RAW_ADDR
> +dev: MTD alt: 20 name: nor_env layout: RAW_ADDR
> +dev: MTD alt: 21 name: nand_fsbl layout: RAW_ADDR
> +dev: MTD alt: 22 name: nand_ssbl1 layout: RAW_ADDR
> +dev: MTD alt: 23 name: nand_ssbl2 layout: RAW_ADDR
> +dev: MTD alt: 24 name: nand_UBI layout: RAW_ADDR
> +dev: VIRT alt: 25 name: OTP layout: RAW_ADDR
> +dev: VIRT alt: 26 name: PMIC layout: RAW_ADDR
> +
> +All the supported device are exported for dfu-util tool:
> +
> +$> dfu-util -l
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=26, name="PMIC", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=25, name="OTP", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=24, name="nand_UBI", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=23, name="nand_ssbl2", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=22, name="nand_ssbl1", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=21, name="nand_fsbl", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=20, name="nor_env", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=19, name="nor_ssbl", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=18, name="nor_fsbl2", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=17, name="nor_fsbl1", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=16, name="emmc_userfs", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=15, name="emmc_rootfs", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=14, name="emmc_vendorfs", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=13, name="emmc_bootfs", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=12, name="emmc_ssbl", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=11, name="emmc_fsbl2", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=10, name="emmc_fsbl1", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=9, name="sdcard_userfs", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=8, name="sdcard_rootfs", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=7, name="sdcard_vendorfs", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=6, name="sdcard_bootfs", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=5, name="sdcard_ssbl", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=4, name="sdcard_fsbl2", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=3, name="sdcard_fsbl1", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=2, name="uramdisk.image.gz", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=1, name="devicetree.dtb", serial="002700333338511934383330"
> +Found DFU: [0483:5720] ver=9999, devnum=99, cfg=1, intf=0, alt=0, name="uImage", serial="002700333338511934383330"
> +
> +You can update the boot device:
> +
> +#SDCARD
> +$> dfu-util -d 0483:5720 -a 3 -D tf-a-stm32mp157c-ev1-trusted.stm32
> +$> dfu-util -d 0483:5720 -a 4 -D tf-a-stm32mp157c-ev1-trusted.stm32
> +$> dfu-util -d 0483:5720 -a 5 -D u-boot-stm32mp157c-ev1-trusted.img
> +$> dfu-util -d 0483:5720 -a 6 -D st-image-bootfs-openstlinux-weston-stm32mp1.ext4
> +$> dfu-util -d 0483:5720 -a 7 -D st-image-vendorfs-openstlinux-weston-stm32mp1.ext4
> +$> dfu-util -d 0483:5720 -a 8 -D st-image-weston-openstlinux-weston-stm32mp1.ext4
> +$> dfu-util -d 0483:5720 -a 9 -D st-image-userfs-openstlinux-weston-stm32mp1.ext4
> +
> +#EMMC
> +$> dfu-util -d 0483:5720 -a 10 -D tf-a-stm32mp157c-ev1-trusted.stm32
> +$> dfu-util -d 0483:5720 -a 11 -D tf-a-stm32mp157c-ev1-trusted.stm32
> +$> dfu-util -d 0483:5720 -a 12 -D u-boot-stm32mp157c-ev1-trusted.img
> +$> dfu-util -d 0483:5720 -a 13 -D st-image-bootfs-openstlinux-weston-stm32mp1.ext4
> +$> dfu-util -d 0483:5720 -a 14 -D st-image-vendorfs-openstlinux-weston-stm32mp1.ext4
> +$> dfu-util -d 0483:5720 -a 15 -D st-image-weston-openstlinux-weston-stm32mp1.ext4
> +$> dfu-util -d 0483:5720 -a 16 -D st-image-userfs-openstlinux-weston-stm32mp1.ext4
> +
> +#NOR
> +$> dfu-util -d 0483:5720 -a 17 -D tf-a-stm32mp157c-ev1-trusted.stm32
> +$> dfu-util -d 0483:5720 -a 18 -D tf-a-stm32mp157c-ev1-trusted.stm32
> +$> dfu-util -d 0483:5720 -a 19 -D u-boot-stm32mp157c-ev1-trusted.img
> +
> +#NAND (UBI partition used for NAND only boot or NOR + NAND boot)
> +$> dfu-util -d 0483:5720 -a 21 -D tf-a-stm32mp157c-ev1-trusted.stm32
> +$> dfu-util -d 0483:5720 -a 22 -D u-boot-stm32mp157c-ev1-trusted.img
> +$> dfu-util -d 0483:5720 -a 23 -D u-boot-stm32mp157c-ev1-trusted.img
> +$> dfu-util -d 0483:5720 -a 24 -D st-image-weston-openstlinux-weston-stm32mp1_nand_4_256_multivolume.ubi
> +
> +And you can also dump the OTP and the PMIC NVM with:
> +
> +$> dfu-util -d 0483:5720 -a 25 -U otp.bin
> +$> dfu-util -d 0483:5720 -a 26 -U pmic.bin
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index 18f9b84876..62855988e9 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -14,6 +14,7 @@
>  #include <generic-phy.h>
>  #include <i2c.h>
>  #include <led.h>
> +#include <memalign.h>
>  #include <misc.h>
>  #include <mtd.h>
>  #include <mtd_node.h>
> @@ -903,6 +904,56 @@ int ft_board_setup(void *blob, bd_t *bd)
>  }
>  #endif
>  
> +#ifdef CONFIG_SET_DFU_ALT_INFO
> +#define DFU_ALT_BUF_LEN SZ_1K
> +
> +static void board_get_alt_info(const char *dev, char *buff)
> +{
> +	char var_name[32] = "dfu_alt_info_";
> +	int ret;
> +
> +	ALLOC_CACHE_ALIGN_BUFFER(char, tmp_alt, DFU_ALT_BUF_LEN);
> +
> +	/* name of env variable to read = dfu_alt_info_<dev> */
> +	strcat(var_name, dev);
> +	ret = env_get_f(var_name, tmp_alt, DFU_ALT_BUF_LEN);
> +	if (ret) {
> +		if (buff[0] != '\0')
> +			strcat(buff, "&");
> +		strncat(buff, tmp_alt, DFU_ALT_BUF_LEN);
> +	}
> +}
> +
> +void set_dfu_alt_info(char *interface, char *devstr)
> +{
> +	struct udevice *dev;
> +
> +	ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN);
> +
> +	if (env_get("dfu_alt_info"))
> +		return;
> +
> +	memset(buf, 0, sizeof(buf));
> +
> +	board_get_alt_info("ram", buf);
> +
> +	if (!uclass_get_device(UCLASS_MMC, 0, &dev))
> +		board_get_alt_info("mmc0", buf);
> +
> +	if (!uclass_get_device(UCLASS_MMC, 1, &dev))
> +		board_get_alt_info("mmc1", buf);
> +
> +	if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev))
> +		board_get_alt_info("nor0", buf);
> +
> +	if (!uclass_get_device(UCLASS_MTD, 0, &dev))
> +		board_get_alt_info("nand0", buf);
> +
> +	env_set("dfu_alt_info", buf);
> +	puts("DFU alt info setting: done\n");
> +}
> +#endif
> +
>  static void board_copro_image_process(ulong fw_image, size_t fw_size)
>  {
>  	int ret, id = 0; /* Copro id fixed to 0 as only one coproc on mp1 */
> diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h
> index 92660fe2a0..4f9024229e 100644
> --- a/include/configs/stm32mp1.h
> +++ b/include/configs/stm32mp1.h
> @@ -83,6 +83,8 @@
>  #define CONFIG_SYS_MTDPARTS_RUNTIME
>  #endif
>  
> +#define CONFIG_SET_DFU_ALT_INFO
> +
>  /*****************************************************************************/
>  #ifdef CONFIG_DISTRO_DEFAULTS
>  /*****************************************************************************/
> @@ -136,6 +138,34 @@
>  #define STM32MP_MTDPARTS
>  #endif
>  
> +#define STM32MP_DFU_ALT_RAM \
> +	"dfu_alt_info_ram=ram 0=" \
> +		"uImage ram ${kernel_addr_r} 0x2000000;" \
> +		"devicetree.dtb ram ${fdt_addr_r} 0x100000;" \
> +		"uramdisk.image.gz ram ${ramdisk_addr_r} 0x10000000\0"
> +
> +#ifdef CONFIG_SET_DFU_ALT_INFO
> +#define STM32MP_DFU_ALT_INFO \
> +	"dfu_alt_info_nor0=mtd nor0=" \
> +		"nor_fsbl1 part 1;nor_fsbl2 part 2;" \
> +		"nor_ssbl part 3;nor_env part 4\0" \
> +	"dfu_alt_info_nand0=mtd nand0="\
> +		"nand_fsbl part 1;nand_ssbl1 part 2;" \
> +		"nand_ssbl2 part 3;nand_UBI partubi 4\0" \
> +	"dfu_alt_info_mmc0=mmc 0=" \
> +		"sdcard_fsbl1 part 0 1;sdcard_fsbl2 part 0 2;" \
> +		"sdcard_ssbl part 0 3;sdcard_bootfs part 0 4;" \
> +		"sdcard_vendorfs part 0 5;sdcard_rootfs part 0 6;" \
> +		"sdcard_userfs part 0 7\0" \
> +	"dfu_alt_info_mmc1=mmc 1=" \
> +		"emmc_fsbl1 raw 0x0 0x200 mmcpart 1;" \
> +		"emmc_fsbl2 raw 0x0 0x200 mmcpart 2;emmc_ssbl part 1 1;" \
> +		"emmc_bootfs part 1 2;emmc_vendorfs part 1 3;" \
> +		"emmc_rootfs part 1 4;emmc_userfs part 1 5\0"
> +#else
> +#define STM32MP_DFU_ALT_INFO
> +#endif
> +
>  /*
>   * memory layout for 32M uncompressed/compressed kernel,
>   * 1M fdt, 1M script, 1M pxe and 1M for splashimage
> @@ -157,6 +187,8 @@
>  		" then env set env_default 0;env save;fi\0" \
>  	STM32MP_BOOTCMD \
>  	STM32MP_MTDPARTS \
> +	STM32MP_DFU_ALT_RAM \
> +	STM32MP_DFU_ALT_INFO \
>  	BOOTENV \
>  	"boot_net_usb_start=true\0"
>  

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>

Thanks

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot] [Uboot-stm32] [PATCH v3 13/15] stm32mp1: configs: activate CONFIG_MTD_SPI_NAND
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 13/15] stm32mp1: configs: activate CONFIG_MTD_SPI_NAND Patrick Delaunay
@ 2019-10-23  9:16   ` Patrice CHOTARD
  2019-11-27 13:39   ` [U-Boot] " Patrick DELAUNAY
  1 sibling, 0 replies; 26+ messages in thread
From: Patrice CHOTARD @ 2019-10-23  9:16 UTC (permalink / raw)
  To: u-boot

Hi Patrick

On 10/14/19 9:28 AM, Patrick Delaunay wrote:
> Activate the support of SPI NAND in stm32mp1 U-Boot.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  configs/stm32mp15_basic_defconfig   | 1 +
>  configs/stm32mp15_optee_defconfig   | 1 +
>  configs/stm32mp15_trusted_defconfig | 1 +
>  3 files changed, 3 insertions(+)
>
> diff --git a/configs/stm32mp15_basic_defconfig b/configs/stm32mp15_basic_defconfig
> index cd4fc20ca5..699e687891 100644
> --- a/configs/stm32mp15_basic_defconfig
> +++ b/configs/stm32mp15_basic_defconfig
> @@ -86,6 +86,7 @@ CONFIG_STM32_SDMMC2=y
>  CONFIG_MTD=y
>  CONFIG_NAND=y
>  CONFIG_NAND_STM32_FMC2=y
> +CONFIG_MTD_SPI_NAND=y
>  CONFIG_DM_SPI_FLASH=y
>  CONFIG_SPI_FLASH=y
>  CONFIG_SPI_FLASH_MACRONIX=y
> diff --git a/configs/stm32mp15_optee_defconfig b/configs/stm32mp15_optee_defconfig
> index 8d3d2e8508..387de0ad35 100644
> --- a/configs/stm32mp15_optee_defconfig
> +++ b/configs/stm32mp15_optee_defconfig
> @@ -73,6 +73,7 @@ CONFIG_STM32_SDMMC2=y
>  CONFIG_MTD=y
>  CONFIG_NAND=y
>  CONFIG_NAND_STM32_FMC2=y
> +CONFIG_MTD_SPI_NAND=y
>  CONFIG_DM_SPI_FLASH=y
>  CONFIG_SPI_FLASH=y
>  CONFIG_SPI_FLASH_MACRONIX=y
> diff --git a/configs/stm32mp15_trusted_defconfig b/configs/stm32mp15_trusted_defconfig
> index 8da8c4e22a..29c23c634d 100644
> --- a/configs/stm32mp15_trusted_defconfig
> +++ b/configs/stm32mp15_trusted_defconfig
> @@ -72,6 +72,7 @@ CONFIG_STM32_SDMMC2=y
>  CONFIG_MTD=y
>  CONFIG_NAND=y
>  CONFIG_NAND_STM32_FMC2=y
> +CONFIG_MTD_SPI_NAND=y
>  CONFIG_DM_SPI_FLASH=y
>  CONFIG_SPI_FLASH=y
>  CONFIG_SPI_FLASH_MACRONIX=y

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot] [Uboot-stm32] [PATCH v3 14/15] stm32mp1: board: add spi nand support
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 14/15] stm32mp1: board: add spi nand support Patrick Delaunay
@ 2019-10-23  9:20   ` Patrice CHOTARD
  2019-11-27 13:40   ` [U-Boot] " Patrick DELAUNAY
  1 sibling, 0 replies; 26+ messages in thread
From: Patrice CHOTARD @ 2019-10-23  9:20 UTC (permalink / raw)
  To: u-boot

Hi Patrick

On 10/14/19 9:28 AM, Patrick Delaunay wrote:
> This patch adds the support of the spi nand device in mtdparts command
> and in dfu_alt_info.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  board/st/stm32mp1/stm32mp1.c | 32 +++++++++++++++++++++++++++++---
>  include/configs/stm32mp1.h   | 10 ++++++++--
>  2 files changed, 37 insertions(+), 5 deletions(-)
>
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index 62855988e9..e4bdf05cd7 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -862,8 +862,9 @@ static void board_get_mtdparts(const char *dev,
>  
>  void board_mtdparts_default(const char **mtdids, const char **mtdparts)
>  {
> +	struct mtd_info *mtd;
>  	struct udevice *dev;
> -	static char parts[2 * MTDPARTS_LEN + 1];
> +	static char parts[3 * MTDPARTS_LEN + 1];
>  	static char ids[MTDIDS_LEN + 1];
>  	static bool mtd_initialized;
>  
> @@ -876,8 +877,24 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
>  	memset(parts, 0, sizeof(parts));
>  	memset(ids, 0, sizeof(ids));
>  
> -	if (!uclass_get_device(UCLASS_MTD, 0, &dev))
> +	/* probe all MTD devices */
> +	for (uclass_first_device(UCLASS_MTD, &dev);
> +	     dev;
> +	     uclass_next_device(&dev)) {
> +		pr_debug("mtd device = %s\n", dev->name);
> +	}
> +
> +	mtd = get_mtd_device_nm("nand0");
> +	if (!IS_ERR_OR_NULL(mtd)) {
>  		board_get_mtdparts("nand0", ids, parts);
> +		put_mtd_device(mtd);
> +	}
> +
> +	mtd = get_mtd_device_nm("spi-nand0");
> +	if (!IS_ERR_OR_NULL(mtd)) {
> +		board_get_mtdparts("spi-nand0", ids, parts);
> +		put_mtd_device(mtd);
> +	}
>  
>  	if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev))
>  		board_get_mtdparts("nor0", ids, parts);
> @@ -927,6 +944,7 @@ static void board_get_alt_info(const char *dev, char *buff)
>  void set_dfu_alt_info(char *interface, char *devstr)
>  {
>  	struct udevice *dev;
> +	struct mtd_info *mtd;
>  
>  	ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN);
>  
> @@ -935,6 +953,9 @@ void set_dfu_alt_info(char *interface, char *devstr)
>  
>  	memset(buf, 0, sizeof(buf));
>  
> +	/* probe all MTD devices */
> +	mtd_probe_devices();
> +
>  	board_get_alt_info("ram", buf);
>  
>  	if (!uclass_get_device(UCLASS_MMC, 0, &dev))
> @@ -946,9 +967,14 @@ void set_dfu_alt_info(char *interface, char *devstr)
>  	if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev))
>  		board_get_alt_info("nor0", buf);
>  
> -	if (!uclass_get_device(UCLASS_MTD, 0, &dev))
> +	mtd = get_mtd_device_nm("nand0");
> +	if (!IS_ERR_OR_NULL(mtd))
>  		board_get_alt_info("nand0", buf);
>  
> +	mtd = get_mtd_device_nm("spi-nand0");
> +	if (!IS_ERR_OR_NULL(mtd))
> +		board_get_alt_info("spi-nand0", buf);
> +
>  	env_set("dfu_alt_info", buf);
>  	puts("DFU alt info setting: done\n");
>  }
> diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h
> index 4f9024229e..145a644efa 100644
> --- a/include/configs/stm32mp1.h
> +++ b/include/configs/stm32mp1.h
> @@ -124,12 +124,15 @@
>  /* with OPTEE: define specific MTD partitions = teeh, teed, teex */
>  #define STM32MP_MTDPARTS \
>  	"mtdparts_nor0=256k(fsbl1),256k(fsbl2),2m(ssbl),256k(u-boot-env),256k(teeh),256k(teed),256k(teex),-(nor_user)\0" \
> -	"mtdparts_nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),512k(teeh),512k(teed),512k(teex),-(UBI)\0"
> +	"mtdparts_nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),512k(teeh),512k(teed),512k(teex),-(UBI)\0" \
> +	"mtdparts_spi-nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),"\
> +		"512k(teeh),512k(teed),512k(teex),-(UBI)\0"
>  
>  #else /* CONFIG_STM32MP1_OPTEE */
>  #define STM32MP_MTDPARTS \
>  	"mtdparts_nor0=256k(fsbl1),256k(fsbl2),2m(ssbl),256k(u-boot-env),-(nor_user)\0" \
> -	"mtdparts_nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),-(UBI)\0"
> +	"mtdparts_nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),-(UBI)\0" \
> +	"mtdparts_spi-nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),-(UBI)\0"
>  
>  #endif /* CONFIG_STM32MP1_OPTEE */
>  
> @@ -152,6 +155,9 @@
>  	"dfu_alt_info_nand0=mtd nand0="\
>  		"nand_fsbl part 1;nand_ssbl1 part 2;" \
>  		"nand_ssbl2 part 3;nand_UBI partubi 4\0" \
> +	"dfu_alt_info_spi-nand0=mtd spi-nand0="\
> +		"spi-nand_fsbl part 1;spi-nand_ssbl1 part 2;" \
> +		"spi-nand_ssbl2 part 3;spi-nand_UBI partubi 4\0" \
>  	"dfu_alt_info_mmc0=mmc 0=" \
>  		"sdcard_fsbl1 part 0 1;sdcard_fsbl2 part 0 2;" \
>  		"sdcard_ssbl part 0 3;sdcard_bootfs part 0 4;" \

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>

Thanks

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot] [Uboot-stm32] [PATCH v3 15/15] stm32mp1: add support for virtual partition read
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 15/15] stm32mp1: add support for virtual partition read Patrick Delaunay
@ 2019-10-23  9:27   ` Patrice CHOTARD
  2019-11-27 13:41   ` [U-Boot] " Patrick DELAUNAY
  1 sibling, 0 replies; 26+ messages in thread
From: Patrice CHOTARD @ 2019-10-23  9:27 UTC (permalink / raw)
  To: u-boot

Hi Patrick

see below

On 10/14/19 9:28 AM, Patrick Delaunay wrote:
> Add read for OTP and PMIC NVM with alternates
> on virtual DFU device.
>
> Serie-cc: Boris Brezillon <boris.brezillon@bootlin.com>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> Changes in v3:
> - rebase on v2019.10
> - remove previous patch 16/16 pushed by error in v2
>   http://patchwork.ozlabs.org/patch/1162076/
>
> Changes in v2:
> - Update after Lukasz Majewski comments
>
>  board/st/stm32mp1/stm32mp1.c        | 83 +++++++++++++++++++++++++++++
>  configs/stm32mp15_basic_defconfig   |  1 +
>  configs/stm32mp15_optee_defconfig   |  1 +
>  configs/stm32mp15_trusted_defconfig |  1 +
>  4 files changed, 86 insertions(+)
>
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index e4bdf05cd7..6045850c05 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -975,9 +975,92 @@ void set_dfu_alt_info(char *interface, char *devstr)
>  	if (!IS_ERR_OR_NULL(mtd))
>  		board_get_alt_info("spi-nand0", buf);
>  
> +#ifdef CONFIG_DFU_VIRT
> +	strncat(buf, "&virt 0=OTP", DFU_ALT_BUF_LEN);
> +
> +	if (IS_ENABLED(CONFIG_PMIC_STPMIC1))
> +		strncat(buf, "&virt 1=PMIC", DFU_ALT_BUF_LEN);
> +#endif
> +
>  	env_set("dfu_alt_info", buf);
>  	puts("DFU alt info setting: done\n");
>  }
> +
> +#if CONFIG_IS_ENABLED(DFU_VIRT)
> +#include <dfu.h>
> +#include <power/stpmic1.h>
> +
> +int dfu_otp_read(u64 offset, u8 *buffer, long *size)
> +{
> +	struct udevice *dev;
> +	int ret;
> +
> +	ret = uclass_get_device_by_driver(UCLASS_MISC,
> +					  DM_GET_DRIVER(stm32mp_bsec),
> +					  &dev);
> +	if (ret)
> +		return ret;
> +
> +	ret = misc_read(dev, offset + STM32_BSEC_OTP_OFFSET, buffer, *size);
> +	if (ret >= 0) {
> +		*size = ret;
> +		ret = 0;
> +	}
> +
> +	return 0;

"return ret;" instead ?

> +}
> +
> +int dfu_pmic_read(u64 offset, u8 *buffer, long *size)
> +{
> +	int ret;
> +#ifdef CONFIG_PMIC_STPMIC1
> +	struct udevice *dev;
> +
> +	ret = uclass_get_device_by_driver(UCLASS_MISC,
> +					  DM_GET_DRIVER(stpmic1_nvm),
> +					  &dev);
> +	if (ret)
> +		return ret;
> +
> +	ret = misc_read(dev, 0xF8 + offset, buffer, *size);
> +	if (ret >= 0) {
> +		*size = ret;
> +		ret = 0;
> +	}
> +	if (ret == -EACCES) {
> +		*size = 0;
> +		ret = 0;
> +	}
> +#else
> +	pr_err("PMIC update not supported");
> +	ret = -EOPNOTSUPP;
> +#endif
> +
> +	return ret;
> +}
> +
> +int dfu_read_medium_virt(struct dfu_entity *dfu, u64 offset,
> +			 void *buf, long *len)
> +{
> +	switch (dfu->data.virt.dev_num) {
> +	case 0x0:
> +		return dfu_otp_read(offset, buf, len);
> +	case 0x1:
> +		return dfu_pmic_read(offset, buf, len);
> +	}
> +	*len = 0;


insert a blank line

> +	return 0;
> +}
> +
> +int __weak dfu_get_medium_size_virt(struct dfu_entity *dfu, u64 *size)
> +{
> +	*size = SZ_1K;
> +
> +	return 0;
> +}
> +
> +#endif
> +
>  #endif
>  
>  static void board_copro_image_process(ulong fw_image, size_t fw_size)
> diff --git a/configs/stm32mp15_basic_defconfig b/configs/stm32mp15_basic_defconfig
> index 699e687891..29e697ee67 100644
> --- a/configs/stm32mp15_basic_defconfig
> +++ b/configs/stm32mp15_basic_defconfig
> @@ -66,6 +66,7 @@ CONFIG_STM32_ADC=y
>  CONFIG_DFU_MMC=y
>  CONFIG_DFU_RAM=y
>  CONFIG_DFU_MTD=y
> +CONFIG_DFU_VIRT=y
>  CONFIG_USB_FUNCTION_FASTBOOT=y
>  CONFIG_FASTBOOT_BUF_ADDR=0xC0000000
>  CONFIG_FASTBOOT_BUF_SIZE=0x02000000
> diff --git a/configs/stm32mp15_optee_defconfig b/configs/stm32mp15_optee_defconfig
> index 387de0ad35..3b8a90de2d 100644
> --- a/configs/stm32mp15_optee_defconfig
> +++ b/configs/stm32mp15_optee_defconfig
> @@ -53,6 +53,7 @@ CONFIG_STM32_ADC=y
>  CONFIG_DFU_MMC=y
>  CONFIG_DFU_RAM=y
>  CONFIG_DFU_MTD=y
> +CONFIG_DFU_VIRT=y
>  CONFIG_USB_FUNCTION_FASTBOOT=y
>  CONFIG_FASTBOOT_BUF_ADDR=0xC0000000
>  CONFIG_FASTBOOT_BUF_SIZE=0x02000000
> diff --git a/configs/stm32mp15_trusted_defconfig b/configs/stm32mp15_trusted_defconfig
> index 29c23c634d..bcbd8a5c4e 100644
> --- a/configs/stm32mp15_trusted_defconfig
> +++ b/configs/stm32mp15_trusted_defconfig
> @@ -52,6 +52,7 @@ CONFIG_STM32_ADC=y
>  CONFIG_DFU_MMC=y
>  CONFIG_DFU_RAM=y
>  CONFIG_DFU_MTD=y
> +CONFIG_DFU_VIRT=y
>  CONFIG_USB_FUNCTION_FASTBOOT=y
>  CONFIG_FASTBOOT_BUF_ADDR=0xC0000000
>  CONFIG_FASTBOOT_BUF_SIZE=0x02000000

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot] [PATCH v3 11/15] stm32mp1: activate DFU support and command MTD
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 11/15] stm32mp1: activate DFU support and command MTD Patrick Delaunay
  2019-10-23  9:12   ` [U-Boot] [Uboot-stm32] " Patrice CHOTARD
@ 2019-11-27 13:39   ` Patrick DELAUNAY
  1 sibling, 0 replies; 26+ messages in thread
From: Patrick DELAUNAY @ 2019-11-27 13:39 UTC (permalink / raw)
  To: u-boot

Hi,

> From: Patrick DELAUNAY <patrick.delaunay@st.com>
> Sent: lundi 14 octobre 2019 09:28
> 
> Add support of DFU for MMC, MTD, RAM and MTD command.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---

Applied to u-boot-stm32/master, thanks!

-- 
Patrick

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot] [PATCH v3 12/15] stm32mp1: activate SET_DFU_ALT_INFO
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 12/15] stm32mp1: activate SET_DFU_ALT_INFO Patrick Delaunay
  2019-10-23  9:15   ` [U-Boot] [Uboot-stm32] " Patrice CHOTARD
@ 2019-11-27 13:39   ` Patrick DELAUNAY
  1 sibling, 0 replies; 26+ messages in thread
From: Patrick DELAUNAY @ 2019-11-27 13:39 UTC (permalink / raw)
  To: u-boot

Hi,

> From: Patrick DELAUNAY <patrick.delaunay@st.com>
> Sent: lundi 14 octobre 2019 09:28
> 
> Generate automatically dfu_alt_info for the supported device.
> The simple command "dfu 0" allows to start the dfu stack on usb 0 for the
> supported devices:
> - dfu mtd for nand0
> - dfu mtd for nor0
> - dfu mmc for SDCard
> - dfu mmc for eMMC
> - dfu ram for images in DDR
> 
> The DUF alternate use the "part", "partubi" and "mmcpart" options to select the
> correct MTD or GPT partition or the eMMC hw boot partition.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---

Applied to u-boot-stm32/master, thanks!

-- 
Patrick

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot] [PATCH v3 13/15] stm32mp1: configs: activate CONFIG_MTD_SPI_NAND
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 13/15] stm32mp1: configs: activate CONFIG_MTD_SPI_NAND Patrick Delaunay
  2019-10-23  9:16   ` [U-Boot] [Uboot-stm32] " Patrice CHOTARD
@ 2019-11-27 13:39   ` Patrick DELAUNAY
  1 sibling, 0 replies; 26+ messages in thread
From: Patrick DELAUNAY @ 2019-11-27 13:39 UTC (permalink / raw)
  To: u-boot

Hi,

> From: Patrick DELAUNAY <patrick.delaunay@st.com>
> Sent: lundi 14 octobre 2019 09:28
> 
> Activate the support of SPI NAND in stm32mp1 U-Boot.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---

Applied to u-boot-stm32/master, thanks!

-- 
Patrick

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot] [PATCH v3 14/15] stm32mp1: board: add spi nand support
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 14/15] stm32mp1: board: add spi nand support Patrick Delaunay
  2019-10-23  9:20   ` [U-Boot] [Uboot-stm32] " Patrice CHOTARD
@ 2019-11-27 13:40   ` Patrick DELAUNAY
  1 sibling, 0 replies; 26+ messages in thread
From: Patrick DELAUNAY @ 2019-11-27 13:40 UTC (permalink / raw)
  To: u-boot

Hi,

> From: Patrick DELAUNAY <patrick.delaunay@st.com>
> Sent: lundi 14 octobre 2019 09:28
> 
> This patch adds the support of the spi nand device in mtdparts command and in
> dfu_alt_info.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---

Applied to u-boot-stm32/master, thanks!

-- 
Patrick

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot] [PATCH v3 15/15] stm32mp1: add support for virtual partition read
  2019-10-14  7:28 ` [U-Boot] [PATCH v3 15/15] stm32mp1: add support for virtual partition read Patrick Delaunay
  2019-10-23  9:27   ` [U-Boot] [Uboot-stm32] " Patrice CHOTARD
@ 2019-11-27 13:41   ` Patrick DELAUNAY
  1 sibling, 0 replies; 26+ messages in thread
From: Patrick DELAUNAY @ 2019-11-27 13:41 UTC (permalink / raw)
  To: u-boot

Hi,

> From: Patrick DELAUNAY <patrick.delaunay@st.com>
> Sent: lundi 14 octobre 2019 09:28
> 
> Add read for OTP and PMIC NVM with alternates on virtual DFU device.
> 
> Serie-cc: Boris Brezillon <boris.brezillon@bootlin.com>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---

Applied to u-boot-stm32/master, thanks!

-- 
Patrick

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2019-11-27 13:41 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-14  7:27 [U-Boot] [PATCH v3 00/15] dfu: update dfu stack and add MTD backend Patrick Delaunay
2019-10-14  7:27 ` [U-Boot] [PATCH v3 01/15] dfu: cosmetic: cleanup sf to avoid checkpatch error Patrick Delaunay
2019-10-14  7:27 ` [U-Boot] [PATCH v3 02/15] doc: dfu: Add dfu documentation Patrick Delaunay
2019-10-14  7:28 ` [U-Boot] [PATCH v3 03/15] dfu: sf: add partition support for nor backend Patrick Delaunay
2019-10-14  7:28 ` [U-Boot] [PATCH v3 04/15] dfu: prepare the support of multiple interface Patrick Delaunay
2019-10-14  7:28 ` [U-Boot] [PATCH v3 05/15] dfu: allow to manage DFU on several devices Patrick Delaunay
2019-10-14  7:28 ` [U-Boot] [PATCH v3 06/15] dfu: allow read with no data without error for EOF indication Patrick Delaunay
2019-10-14  7:28 ` [U-Boot] [PATCH v3 07/15] dfu: add backend for MTD device Patrick Delaunay
2019-10-14  7:28 ` [U-Boot] [PATCH v3 08/15] dfu: add partition support for MTD backend Patrick Delaunay
2019-10-14  7:28 ` [U-Boot] [PATCH v3 09/15] dfu: add DFU virtual backend Patrick Delaunay
2019-10-14  7:28 ` [U-Boot] [PATCH v3 10/15] dfu: add callback for flush and initiated operation Patrick Delaunay
2019-10-14  7:28 ` [U-Boot] [PATCH v3 11/15] stm32mp1: activate DFU support and command MTD Patrick Delaunay
2019-10-23  9:12   ` [U-Boot] [Uboot-stm32] " Patrice CHOTARD
2019-11-27 13:39   ` [U-Boot] " Patrick DELAUNAY
2019-10-14  7:28 ` [U-Boot] [PATCH v3 12/15] stm32mp1: activate SET_DFU_ALT_INFO Patrick Delaunay
2019-10-23  9:15   ` [U-Boot] [Uboot-stm32] " Patrice CHOTARD
2019-11-27 13:39   ` [U-Boot] " Patrick DELAUNAY
2019-10-14  7:28 ` [U-Boot] [PATCH v3 13/15] stm32mp1: configs: activate CONFIG_MTD_SPI_NAND Patrick Delaunay
2019-10-23  9:16   ` [U-Boot] [Uboot-stm32] " Patrice CHOTARD
2019-11-27 13:39   ` [U-Boot] " Patrick DELAUNAY
2019-10-14  7:28 ` [U-Boot] [PATCH v3 14/15] stm32mp1: board: add spi nand support Patrick Delaunay
2019-10-23  9:20   ` [U-Boot] [Uboot-stm32] " Patrice CHOTARD
2019-11-27 13:40   ` [U-Boot] " Patrick DELAUNAY
2019-10-14  7:28 ` [U-Boot] [PATCH v3 15/15] stm32mp1: add support for virtual partition read Patrick Delaunay
2019-10-23  9:27   ` [U-Boot] [Uboot-stm32] " Patrice CHOTARD
2019-11-27 13:41   ` [U-Boot] " Patrick DELAUNAY

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.