dfu: add backend for MTD device
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>
diff --git a/include/dfu.h b/include/dfu.h
index 7d60ffc..924952f 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -22,6 +22,7 @@
DFU_DEV_NAND,
DFU_DEV_RAM,
DFU_DEV_SF,
+ DFU_DEV_MTD,
};
enum dfu_layout {
@@ -55,6 +56,14 @@
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 @@
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 @@
}
#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
*