Skip to contentSkip to conversation

stm32mp1: use U-Boot device tree to configure MTD partitions

PATCH In review Patrick Delaunay 3 participants 28 messages Jun 8, 2023 – Jun 16, 2023

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover stm32mp1: use U-Boot device tree to configure MTD partitions

Add the MTD partitions subnode in U-Boot device tree for all stm32mp13 and stm32mp15 boards and no more rely on mtdids and mtdparts variables or CONFIG_SYS_MTDPARTS_RUNTIME.

When these variables are absent, the required OF fallback is performed in mtd_probe_devices() with commit dc339bf784f0 ("mtd: add support for parsing partitions defined in OF").

To allow dynamically configuration of MTD partitioning for Linux kernel, the MTD partitioning is only defined in U-Boot device tree and copied in Linux kernel device tree.

This serie also disable CMD_MTDPARTS as it is strongly encouraged to no more use this command.

Marek, I modify the dhcom/dhcor boardd in the last patch of the serie but if you prefer I can drop this patch.

For "stm32mp157c-ev1.dts" used by stm32mp15_trusted_defconfig

* nand0
- type: NAND flash
- block size: 0x40000 bytes
- min I/O: 0x1000 bytes
- OOB size: 224 bytes
- OOB available: 118 bytes
- ECC strength: 8 bits
- ECC step size: 512 bytes
- bitflip threshold: 6 bits
- 0x000000000000-0x000040000000 : "nand0"
- 0x000000000000-0x000000200000 : "fsbl"
- 0x000000200000-0x000000600000 : "fip1"
- 0x000000600000-0x000000a00000 : "fip2"
- 0x000000a00000-0x000040000000 : "UBI"
* nor0
- device: flash@0
- parent: spi@58003000
- driver: jedec_spi_nor
- path: /soc/spi@58003000/flash@0
- type: NOR flash
- block size: 0x10000 bytes
- min I/O: 0x1 bytes
- 0x000000000000-0x000004000000 : "nor0"
- 0x000000000000-0x000000040000 : "fsbl1"
- 0x000000040000-0x000000080000 : "fsbl2"
- 0x000000080000-0x000000480000 : "fip"
- 0x000000480000-0x000000500000 : "u-boot-env"
- 0x000000500000-0x000004000000 : "nor-user"

For "stm32mp157c-ev1-scmi.dts" the device tree file used by stm32mp15_defconfig, with TF-A BL2 and OP-TEE including a SCMI server for secure resources (when TZEN=1), the default STMicroelectronics configuration.

I align the NOR and NAND layout on EV1 boards with the STMicroelectronics recommendations used in OpenSTLinux V4.0:
with support of TF-A BL2 firmware update, required 2 "metadata" partition for redundancy and 2 FIPs for A/B update.

* nand0
- type: NAND flash
- block size: 0x40000 bytes
- min I/O: 0x1000 bytes
- OOB size: 224 bytes
- OOB available: 118 bytes
- ECC strength: 8 bits
- ECC step size: 512 bytes
- bitflip threshold: 6 bits
- 0x000000000000-0x000040000000 : "nand0"
- 0x000000000000-0x000000080000 : "fsbl1"
- 0x000000080000-0x000000100000 : "fsbl2"
- 0x000000100000-0x000000180000 : "metadata1"
- 0x000000180000-0x000000200000 : "metadata2"
- 0x000000200000-0x000000600000 : "fip-a1"
- 0x000000600000-0x000000a00000 : "fip-a2"
- 0x000000a00000-0x000000e00000 : "fip-b1"
- 0x000000e00000-0x000001200000 : "fip-b2"
- 0x000001200000-0x000040000000 : "UBI"
* nor0
- device: flash@0
- parent: spi@58003000
- driver: jedec_spi_nor
- path: /soc/spi@58003000/flash@0
- type: NOR flash
- block size: 0x10000 bytes
- min I/O: 0x1 bytes
- 0x000000000000-0x000004000000 : "nor0"
- 0x000000000000-0x000000040000 : "fsbl1"
- 0x000000040000-0x000000080000 : "fsbl2"
- 0x000000080000-0x0000000c0000 : "metadata1"
- 0x0000000c0000-0x000000100000 : "metadata2"
- 0x000000100000-0x000000500000 : "fip-a"
- 0x000000500000-0x000000900000 : "fip-b"
- 0x000000900000-0x000000980000 : "u-boot-env"
- 0x000000980000-0x000004000000 : "nor-user"

Patrice Chotard (5):
stm32mp: stm32prog: Remove usage of "mtdparts" function
arm: dts: stm32: Add partitions in flash0 and nand node for

    stm32mp15xx-ev1
  configs: stm32mp: Disable SYS_MTDPARTS_RUNTIME for stm32mp15 and
    stm32mp13

stm32mp: stm32prog: Remove tee_detected from stm32prog_data struct
configs: stm32mp1: disable CMD_MTDPARTS

Patrick Delaunay (7):
fdt_support: include dm/ofnode.h
fdt_support: add fdt_copy_fixed_partitions function
dfu: mtd: remove direct call of mtdparts_init function
arm: dts: stm32: Align stm32mp15xx-*-scmi-u-boot.dtsi file
board: stm32mp1: use fdt_copy_fixed_partitions
board: st: remove board_mtdparts_default
arm: dts: stm32: Add partitions in flash0 and nand node for

    stm32mp15xx-dhcom/dhcor
 arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi      |   1 +
 arch/arm/dts/stm32mp157c-dk2-scmi-u-boot.dtsi |   7 +
 arch/arm/dts/stm32mp157c-ev1-scmi-u-boot.dtsi | 125 +++++++++++++
 arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi      |  98 +++++++++-
 arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi    |  27 +++
 arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi    |  27 +++
 .../cmd_stm32prog/cmd_stm32prog.c             |   9 -
 .../mach-stm32mp/cmd_stm32prog/stm32prog.c    |  53 ++----
 .../mach-stm32mp/cmd_stm32prog/stm32prog.h    |   3 -
 .../arm/mach-stm32mp/include/mach/stm32prog.h |   4 -
 board/st/common/Kconfig                       |  66 -------
 board/st/common/Makefile                      |   1 -
 board/st/common/stm32mp_mtdparts.c            | 177 ------------------
 board/st/stm32mp1/stm32mp1.c                  |  16 +-
 common/fdt_support.c                          |  75 +++++++-
 configs/stm32mp13_defconfig                   |   3 -
 configs/stm32mp15_basic_defconfig             |   3 -
 configs/stm32mp15_defconfig                   |   7 +-
 configs/stm32mp15_dhcom_basic_defconfig       |   3 -
 configs/stm32mp15_dhcor_basic_defconfig       |   3 -
 configs/stm32mp15_trusted_defconfig           |   3 -
 drivers/dfu/Kconfig                           |   1 -
 drivers/dfu/dfu_mtd.c                         |  34 ++--
 include/fdt_support.h                         |   8 +
 24 files changed, 407 insertions(+), 347 deletions(-)
 delete mode 100644 board/st/common/stm32mp_mtdparts.c
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/12 fdt_support: include dm/ofnode.h

This patch is a preliminary patch to use ofnode function is fdt_support to read the U-Boot device tree with livetree compatible functions.

---

 common/fdt_support.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/fdt_support.c +1 -1
index 2053fe3bad83..ffc59fd8b36a 100644
@@ -13,6 +13,7 @@
 #include <mapmem.h>
 #include <net.h>
 #include <stdio_dev.h>
+#include <dm/ofnode.h>
 #include <linux/ctype.h>
 #include <linux/types.h>
 #include <asm/global_data.h>
@@ -1065,7 +1066,6 @@ void fdt_del_node_and_alias(void *blob, const char *alias)
 
 /* Max address size we deal with */
 #define OF_MAX_ADDR_CELLS	4
-#define OF_BAD_ADDR	FDT_ADDR_T_NONE
 #define OF_CHECK_COUNTS(na, ns)	((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \
 			(ns) > 0)
 
Signature · 1 line
2.25.1
Reviewed-by on v1 1/12
#2 lore raw

Re: [Uboot-stm32] [PATCH 01/12] fdt_support: include dm/ofnode.h

Quoted 23 lines · Patrick Delaunay

This patch is a preliminary patch to use ofnode function is fdt_support to read the U-Boot device tree with livetree compatible functions.

---

 common/fdt_support.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/fdt_support.c +1 -0
index 2053fe3bad83..ffc59fd8b36a 100644
@@ -13,6 +13,7 @@
 #include <mapmem.h>
 #include <net.h>
 #include <stdio_dev.h>
+#include <dm/ofnode.h>
 #include <linux/ctype.h>
 #include <linux/types.h>
 #include <asm/global_data.h>

common/fdt_support.c void fdt_del_node_and_alias(void *blob, const char *alias) · line 1071

Quoted 7 lines
common/fdt_support.c +0 -1
@@ -1065,7 +1066,6 @@ void fdt_del_node_and_alias(void *blob, const char *alias)
 
 /* Max address size we deal with */
 #define OF_MAX_ADDR_CELLS	4
-#define OF_BAD_ADDR	FDT_ADDR_T_NONE
 #define OF_CHECK_COUNTS(na, ns)	((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \
 			(ns) > 0)
 

Thanks
Patrice

Reviewed-by on v1 1/12
#3 lore raw

Re: [PATCH 01/12] fdt_support: include dm/ofnode.h

In reply to Patrick Delaunay

Hi Patrick,

Quoted 4 lines · Patrick Delaunay

This patch is a preliminary patch to use ofnode function is fdt_support to read the U-Boot device tree with livetree compatible functions.

When will the real patch come?

Regards,
Simon

Quoted 30 lines

---

 common/fdt_support.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/fdt_support.c +1 -2
index 2053fe3bad83..ffc59fd8b36a 100644
@@ -13,6 +13,7 @@
 #include <mapmem.h>
 #include <net.h>
 #include <stdio_dev.h>
+#include <dm/ofnode.h>
 #include <linux/ctype.h>
 #include <linux/types.h>
 #include <asm/global_data.h>
@@ -1065,7 +1066,6 @@ void fdt_del_node_and_alias(void *blob, const char *alias)
 
 /* Max address size we deal with */
 #define OF_MAX_ADDR_CELLS      4
-#define OF_BAD_ADDR    FDT_ADDR_T_NONE
 #define OF_CHECK_COUNTS(na, ns)        ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \
                        (ns) > 0)
 
--

2.25.1

#4 lore raw

PATCH 2/12 fdt_support: add fdt_copy_fixed_partitions function

In reply to Patrick Delaunay

Add a new function fdt_copy_fixed_partitions to copy the fixed partition nodes from U-Boot device tree to Linux kernel device tree and to dynamically configure the MTD partitions.

This function fdt_copy_fixed_partitions is only based on device tree with livetree compatible function and replace the function fdt_fixup_mtdparts based on mtdparts variable.

---

 common/fdt_support.c  | 73 +++++++++++++++++++++++++++++++++++++++++++
 include/fdt_support.h |  8 +++++
 2 files changed, 81 insertions(+)
common/fdt_support.c +73 -0
index ffc59fd8b36a..5e49078f8c35 100644
@@ -1051,6 +1051,79 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info,
 }
 #endif
 
+int fdt_copy_fixed_partitions(void *blob)
+{
+	ofnode node, subnode;
+	int off, suboff, res;
+	char path[256];
+	int address_cells, size_cells;
+	u8 i, j, child_count;
+
+	node = ofnode_by_compatible(ofnode_null(), "fixed-partitions");
+	while (ofnode_valid(node)) {
+		/* copy the U-Boot fixed partition */
+		address_cells = ofnode_read_simple_addr_cells(node);
+		size_cells = ofnode_read_simple_size_cells(node);
+
+		res = ofnode_get_path(ofnode_get_parent(node), path, sizeof(path));
+		if (res)
+			return res;
+
+		off = fdt_path_offset(blob, path);
+		if (off < 0)
+			return -ENODEV;
+
+		off = fdt_find_or_add_subnode(blob, off, "partitions");
+		res = fdt_setprop_string(blob, off, "compatible", "fixed-partitions");
+		if (res)
+			return res;
+
+		res = fdt_setprop_u32(blob, off, "#address-cells", address_cells);
+		if (res)
+			return res;
+
+		res = fdt_setprop_u32(blob, off, "#size-cells", size_cells);
+		if (res)
+			return res;
+
+		/*
+		 * parse partition in reverse order as fdt_find_or_add_subnode() only
+		 * insert the new node after the parent's properties
+		 */
+		child_count = ofnode_get_child_count(node);
+		for (i = child_count; i > 0 ; i--) {
+			subnode = ofnode_first_subnode(node);
+			if (!ofnode_valid(subnode))
+				break;
+
+			for (j = 0; (j < i - 1); j++)
+				subnode = ofnode_next_subnode(subnode);
+
+			if (!ofnode_valid(subnode))
+				break;
+
+			const u32 *reg;
+			int len;
+
+			suboff = fdt_find_or_add_subnode(blob, off, ofnode_get_name(subnode));
+			res = fdt_setprop_string(blob, suboff, "label",
+						 ofnode_read_string(subnode, "label"));
+			if (res)
+				return res;
+
+			reg = ofnode_get_property(subnode, "reg", &len);
+			res = fdt_setprop(blob, suboff, "reg", reg, len);
+			if (res)
+				return res;
+		}
+
+		/* go to next fixed-partitions node */
+		node = ofnode_by_compatible(node, "fixed-partitions");
+	}
+
+	return 0;
+}
+
 void fdt_del_node_and_alias(void *blob, const char *alias)
 {
 	int off = fdt_path_offset(blob, alias);
include/fdt_support.h +8 -0
index eeb83e6251d3..2cd836689821 100644
@@ -256,6 +256,14 @@ static inline void fdt_fixup_mtdparts(void *fdt,
 }
 #endif
 
+/**
+ * copy the fixed-partition nodes from U-Boot device tree to external blob
+ *
+ * @param blob		FDT blob to update
+ * Return: 0 if ok, or non-zero on error
+ */
+int fdt_copy_fixed_partitions(void *blob);
+
 void fdt_del_node_and_alias(void *blob, const char *alias);
 
 /**
Signature · 1 line
2.25.1
Reviewed-by on v1 2/12
#5 lore raw

Re: [Uboot-stm32] [PATCH 02/12] fdt_support: add fdt_copy_fixed_partitions function

Quoted 108 lines · Patrick Delaunay

Add a new function fdt_copy_fixed_partitions to copy the fixed partition nodes from U-Boot device tree to Linux kernel device tree and to dynamically configure the MTD partitions.

This function fdt_copy_fixed_partitions is only based on device tree with livetree compatible function and replace the function fdt_fixup_mtdparts based on mtdparts variable.

---

 common/fdt_support.c  | 73 +++++++++++++++++++++++++++++++++++++++++++
 include/fdt_support.h |  8 +++++
 2 files changed, 81 insertions(+)
common/fdt_support.c +73 -0
index ffc59fd8b36a..5e49078f8c35 100644
@@ -1051,6 +1051,79 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info,
 }
 #endif
 
+int fdt_copy_fixed_partitions(void *blob)
+{
+	ofnode node, subnode;
+	int off, suboff, res;
+	char path[256];
+	int address_cells, size_cells;
+	u8 i, j, child_count;
+
+	node = ofnode_by_compatible(ofnode_null(), "fixed-partitions");
+	while (ofnode_valid(node)) {
+		/* copy the U-Boot fixed partition */
+		address_cells = ofnode_read_simple_addr_cells(node);
+		size_cells = ofnode_read_simple_size_cells(node);
+
+		res = ofnode_get_path(ofnode_get_parent(node), path, sizeof(path));
+		if (res)
+			return res;
+
+		off = fdt_path_offset(blob, path);
+		if (off < 0)
+			return -ENODEV;
+
+		off = fdt_find_or_add_subnode(blob, off, "partitions");
+		res = fdt_setprop_string(blob, off, "compatible", "fixed-partitions");
+		if (res)
+			return res;
+
+		res = fdt_setprop_u32(blob, off, "#address-cells", address_cells);
+		if (res)
+			return res;
+
+		res = fdt_setprop_u32(blob, off, "#size-cells", size_cells);
+		if (res)
+			return res;
+
+		/*
+		 * parse partition in reverse order as fdt_find_or_add_subnode() only
+		 * insert the new node after the parent's properties
+		 */
+		child_count = ofnode_get_child_count(node);
+		for (i = child_count; i > 0 ; i--) {
+			subnode = ofnode_first_subnode(node);
+			if (!ofnode_valid(subnode))
+				break;
+
+			for (j = 0; (j < i - 1); j++)
+				subnode = ofnode_next_subnode(subnode);
+
+			if (!ofnode_valid(subnode))
+				break;
+
+			const u32 *reg;
+			int len;
+
+			suboff = fdt_find_or_add_subnode(blob, off, ofnode_get_name(subnode));
+			res = fdt_setprop_string(blob, suboff, "label",
+						 ofnode_read_string(subnode, "label"));
+			if (res)
+				return res;
+
+			reg = ofnode_get_property(subnode, "reg", &len);
+			res = fdt_setprop(blob, suboff, "reg", reg, len);
+			if (res)
+				return res;
+		}
+
+		/* go to next fixed-partitions node */
+		node = ofnode_by_compatible(node, "fixed-partitions");
+	}
+
+	return 0;
+}
+
 void fdt_del_node_and_alias(void *blob, const char *alias)
 {
 	int off = fdt_path_offset(blob, alias);
include/fdt_support.h +1 -0
index eeb83e6251d3..2cd836689821 100644
@@ -256,6 +256,14 @@ static inline void fdt_fixup_mtdparts(void *fdt,
 }
 #endif
 
+/**

include/fdt_support.h static inline void fdt_fixup_mtdparts(void *fdt, · line 269

Quoted 10 lines
include/fdt_support.h +7 -0
+ * copy the fixed-partition nodes from U-Boot device tree to external blob
+ *
+ * @param blob		FDT blob to update
+ * Return: 0 if ok, or non-zero on error
+ */
+int fdt_copy_fixed_partitions(void *blob);
+
 void fdt_del_node_and_alias(void *blob, const char *alias);
 
 /**

Thanks
Patrice

#6 lore raw

Re: [PATCH 02/12] fdt_support: add fdt_copy_fixed_partitions function

In reply to Patrick Delaunay

Hi Patrick,

Quoted 35 lines · Patrick Delaunay

Add a new function fdt_copy_fixed_partitions to copy the fixed partition nodes from U-Boot device tree to Linux kernel device tree and to dynamically configure the MTD partitions.

This function fdt_copy_fixed_partitions is only based on device tree with livetree compatible function and replace the function fdt_fixup_mtdparts based on mtdparts variable.

---

 common/fdt_support.c  | 73 +++++++++++++++++++++++++++++++++++++++++++
 include/fdt_support.h |  8 +++++
 2 files changed, 81 insertions(+)
common/fdt_support.c +11 -0
index ffc59fd8b36a..5e49078f8c35 100644
@@ -1051,6 +1051,79 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info,
 }
 #endif
 
+int fdt_copy_fixed_partitions(void *blob)
+{
+       ofnode node, subnode;
+       int off, suboff, res;
+       char path[256];
+       int address_cells, size_cells;
+       u8 i, j, child_count;
+
+       node = ofnode_by_compatible(ofnode_null(), "fixed-partitions");
+       while (ofnode_valid(node)) {
+               /* copy the U-Boot fixed partition */

common/fdt_support.c void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info, · line 1074

Quoted 10 lines
common/fdt_support.c +10 -0
+               address_cells = ofnode_read_simple_addr_cells(node);
+               size_cells = ofnode_read_simple_size_cells(node);
+
+               res = ofnode_get_path(ofnode_get_parent(node), path, sizeof(path));
+               if (res)
+                       return res;
+
+               off = fdt_path_offset(blob, path);
+               if (off < 0)
+                       return -ENODEV;

It should be possible to use livetree to write to the blob. E.g.:

oftree tree = oftree_from_fdt(blob);
ofnode node = oftree_path(tree, "/...");

That would be more future-proof than using this API. I'd like to move DT fixup to the ofnode API eventually.

Quoted 75 lines
common/fdt_support.c +52 -0
+
+               off = fdt_find_or_add_subnode(blob, off, "partitions");
+               res = fdt_setprop_string(blob, off, "compatible", "fixed-partitions");
+               if (res)
+                       return res;
+
+               res = fdt_setprop_u32(blob, off, "#address-cells", address_cells);
+               if (res)
+                       return res;
+
+               res = fdt_setprop_u32(blob, off, "#size-cells", size_cells);
+               if (res)
+                       return res;
+
+               /*
+                * parse partition in reverse order as fdt_find_or_add_subnode() only
+                * insert the new node after the parent's properties
+                */
+               child_count = ofnode_get_child_count(node);
+               for (i = child_count; i > 0 ; i--) {
+                       subnode = ofnode_first_subnode(node);
+                       if (!ofnode_valid(subnode))
+                               break;
+
+                       for (j = 0; (j < i - 1); j++)
+                               subnode = ofnode_next_subnode(subnode);
+
+                       if (!ofnode_valid(subnode))
+                               break;
+
+                       const u32 *reg;
+                       int len;
+
+                       suboff = fdt_find_or_add_subnode(blob, off, ofnode_get_name(subnode));
+                       res = fdt_setprop_string(blob, suboff, "label",
+                                                ofnode_read_string(subnode, "label"));
+                       if (res)
+                               return res;
+
+                       reg = ofnode_get_property(subnode, "reg", &len);
+                       res = fdt_setprop(blob, suboff, "reg", reg, len);
+                       if (res)
+                               return res;
+               }
+
+               /* go to next fixed-partitions node */
+               node = ofnode_by_compatible(node, "fixed-partitions");
+       }
+
+       return 0;
+}
+
 void fdt_del_node_and_alias(void *blob, const char *alias)
 {
        int off = fdt_path_offset(blob, alias);
include/fdt_support.h +8 -1
index eeb83e6251d3..2cd836689821 100644
@@ -256,6 +256,14 @@ static inline void fdt_fixup_mtdparts(void *fdt,
 }
 #endif
 
+/**
+ * copy the fixed-partition nodes from U-Boot device tree to external blob
+ *
+ * @param blob         FDT blob to update
+ * Return: 0 if ok, or non-zero on error
+ */
+int fdt_copy_fixed_partitions(void *blob);
+
 void fdt_del_node_and_alias(void *blob, const char *alias);
 
 /**
--
Quoted 2 lines

2.25.1

Regards,
Simon

#7 lore raw

PATCH 3/12 dfu: mtd: remove direct call of mtdparts_init function

In reply to Patrick Delaunay

With MTD support in driver model, the direct call of mtdparts_init should be avoided and replaced by mtd_probe_devices.

With the modificaton when MTDIDS/MTDPARTS are empty the OF fallback with partition describe in device tree is correctly performed, introduced by commit dc339bf784f0 ("mtd: add support for parsing partitions defined in OF").
With this patch the dependency with CONFIG_CMD_MTDPARTS is removed.

---

 drivers/dfu/Kconfig   |  1 -
 drivers/dfu/dfu_mtd.c | 34 +++++++++++++++++++---------------
 2 files changed, 19 insertions(+), 16 deletions(-)
drivers/dfu/Kconfig +0 -1
index 8d7f13dcb0b5..c3a0b93b25e0 100644
@@ -41,7 +41,6 @@ config DFU_MMC
 config DFU_MTD
 	bool "MTD back end for DFU"
 	depends on DM_MTD
-	depends on CMD_MTDPARTS
 	help
 	  This option enables using DFU to read and write to on any MTD device.
 
drivers/dfu/dfu_mtd.c +19 -15
index c7075f12eca9..75e2f6a42151 100644
@@ -10,7 +10,6 @@
 #include <common.h>
 #include <dfu.h>
 #include <mtd.h>
-#include <jffs2/load_kernel.h>
 #include <linux/err.h>
 #include <linux/ctype.h>
 
@@ -275,7 +274,7 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char **argv, int a
 {
 	char *s;
 	struct mtd_info *mtd;
-	int ret, part;
+	int part;
 
 	mtd = get_mtd_device_nm(devstr);
 	if (IS_ERR_OR_NULL(mtd))
@@ -299,10 +298,9 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char **argv, int a
 		if (*s)
 			return -EINVAL;
 	} else if ((!strcmp(argv[0], "part")) || (!strcmp(argv[0], "partubi"))) {
-		char mtd_id[32];
-		struct mtd_device *mtd_dev;
-		u8 part_num;
-		struct part_info *pi;
+		struct mtd_info *partition;
+		int partnum = 0;
+		bool part_found = false;
 
 		if (argc != 2)
 			return -EINVAL;
@@ -313,19 +311,25 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char **argv, int a
 		if (*s)
 			return -EINVAL;
 
-		sprintf(mtd_id, "%s,%d", devstr, part - 1);
-		printf("using id '%s'\n", mtd_id);
+		/* register partitions with MTDIDS/MTDPARTS or OF fallback */
+		mtd_probe_devices();
 
-		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);
+		partnum = 0;
+		list_for_each_entry(partition, &mtd->partitions, node) {
+			partnum++;
+			if (partnum == part) {
+				part_found = true;
+				break;
+			}
+		}
+		if (!part_found) {
+			printf("No partition %d in %s\n", part, mtd->name);
 			return -1;
 		}
+		log_debug("partition %d:%s in %s\n", partnum, partition->name, mtd->name);
 
-		dfu->data.mtd.start = pi->offset;
-		dfu->data.mtd.size = pi->size;
+		dfu->data.mtd.start = partition->offset;
+		dfu->data.mtd.size = partition->size;
 		if (!strcmp(argv[0], "partubi"))
 			dfu->data.mtd.ubi = 1;
 	} else {
Signature · 1 line
2.25.1
Reviewed-by on v1 3/12
#8 lore raw

Re: [Uboot-stm32] [PATCH 03/12] dfu: mtd: remove direct call of mtdparts_init function

Quoted 88 lines · Patrick Delaunay

With MTD support in driver model, the direct call of mtdparts_init should be avoided and replaced by mtd_probe_devices.

With the modificaton when MTDIDS/MTDPARTS are empty the OF fallback with partition describe in device tree is correctly performed, introduced by commit dc339bf784f0 ("mtd: add support for parsing partitions defined in OF").
With this patch the dependency with CONFIG_CMD_MTDPARTS is removed.

---

 drivers/dfu/Kconfig   |  1 -
 drivers/dfu/dfu_mtd.c | 34 +++++++++++++++++++---------------
 2 files changed, 19 insertions(+), 16 deletions(-)
drivers/dfu/Kconfig +0 -1
index 8d7f13dcb0b5..c3a0b93b25e0 100644
@@ -41,7 +41,6 @@ config DFU_MMC
 config DFU_MTD
 	bool "MTD back end for DFU"
 	depends on DM_MTD
-	depends on CMD_MTDPARTS
 	help
 	  This option enables using DFU to read and write to on any MTD device.
 
drivers/dfu/dfu_mtd.c +16 -13
index c7075f12eca9..75e2f6a42151 100644
@@ -10,7 +10,6 @@
 #include <common.h>
 #include <dfu.h>
 #include <mtd.h>
-#include <jffs2/load_kernel.h>
 #include <linux/err.h>
 #include <linux/ctype.h>
 
@@ -275,7 +274,7 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char **argv, int a
 {
 	char *s;
 	struct mtd_info *mtd;
-	int ret, part;
+	int part;
 
 	mtd = get_mtd_device_nm(devstr);
 	if (IS_ERR_OR_NULL(mtd))
@@ -299,10 +298,9 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char **argv, int a
 		if (*s)
 			return -EINVAL;
 	} else if ((!strcmp(argv[0], "part")) || (!strcmp(argv[0], "partubi"))) {
-		char mtd_id[32];
-		struct mtd_device *mtd_dev;
-		u8 part_num;
-		struct part_info *pi;
+		struct mtd_info *partition;
+		int partnum = 0;
+		bool part_found = false;
 
 		if (argc != 2)
 			return -EINVAL;
@@ -313,19 +311,25 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char **argv, int a
 		if (*s)
 			return -EINVAL;
 
-		sprintf(mtd_id, "%s,%d", devstr, part - 1);
-		printf("using id '%s'\n", mtd_id);
+		/* register partitions with MTDIDS/MTDPARTS or OF fallback */
+		mtd_probe_devices();
 
-		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);
+		partnum = 0;
+		list_for_each_entry(partition, &mtd->partitions, node) {
+			partnum++;
+			if (partnum == part) {
+				part_found = true;
+				break;
+			}
+		}
+		if (!part_found) {
+			printf("No partition %d in %s\n", part, mtd->name);
 			return -1;

drivers/dfu/dfu_mtd.c int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char **argv, int a · line 335

Quoted 10 lines
drivers/dfu/dfu_mtd.c +3 -2
 		}
+		log_debug("partition %d:%s in %s\n", partnum, partition->name, mtd->name);
 
-		dfu->data.mtd.start = pi->offset;
-		dfu->data.mtd.size = pi->size;
+		dfu->data.mtd.start = partition->offset;
+		dfu->data.mtd.size = partition->size;
 		if (!strcmp(argv[0], "partubi"))
 			dfu->data.mtd.ubi = 1;
 	} else {

Thanks
Patrice

#9 lore raw

PATCH 4/12 stm32mp: stm32prog: Remove usage of "mtdparts" function

In reply to Patrick Delaunay

From: Patrice Chotard <[email protected]>

Motivation for this patch is to remove usage of function define in cmd/mtdparts.c interface, based on env variables mtdids and mtdparts:
mtdparts_init() and find_dev_and_part().
See commit 938db6fe5da3 ("cmd: mtdparts: describe as legacy")

Now, all MTD devices are populated with their partition's information found in DT, accessible in MTD devices. Use these information to find the wanted partitions, no more need of find_dev_and_part() usage.

---

 .../mach-stm32mp/cmd_stm32prog/stm32prog.c    | 42 +++++++++----------
 1 file changed, 19 insertions(+), 23 deletions(-)
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c +19 -23
index 6f3641ccf57b..241ad40abb7c 100644
@@ -208,11 +208,6 @@ static int optee_ta_invoke(struct stm32prog_data *data, int cmd, int type,
 	return rc;
 }
 
-/* partition handling routines : CONFIG_CMD_MTDPARTS */
-int mtdparts_init(void);
-int find_dev_and_part(const char *id, struct mtd_device **dev,
-		      u8 *part_num, struct part_info **part);
-
 char *stm32prog_get_error(struct stm32prog_data *data)
 {
 	static const char error_msg[] = "Unspecified";
@@ -741,6 +736,7 @@ static int init_device(struct stm32prog_data *data,
 	struct mmc *mmc = NULL;
 	struct blk_desc *block_dev = NULL;
 	struct mtd_info *mtd = NULL;
+	struct mtd_info *partition;
 	char mtd_id[16];
 	int part_id;
 	int ret;
@@ -749,6 +745,7 @@ static int init_device(struct stm32prog_data *data,
 	u64 part_addr, part_size;
 	bool part_found;
 	const char *part_name;
+	u8 i;
 
 	switch (dev->target) {
 	case STM32PROG_MMC:
@@ -793,10 +790,11 @@ static int init_device(struct stm32prog_data *data,
 			stm32prog_err("unknown device type = %d", dev->target);
 			return -ENODEV;
 		}
+		/* register partitions with MTDIDS/MTDPARTS or OF fallback */
+		mtd_probe_devices();
 		get_mtd_by_target(mtd_id, dev->target, dev->dev_id);
 		log_debug("%s\n", mtd_id);
 
-		mtdparts_init();
 		mtd = get_mtd_device_nm(mtd_id);
 		if (IS_ERR(mtd)) {
 			stm32prog_err("MTD device %s not found", mtd_id);
@@ -943,25 +941,23 @@ static int init_device(struct stm32prog_data *data,
 		}
 
 		if (IS_ENABLED(CONFIG_MTD) && mtd) {
-			char mtd_part_id[32];
-			struct part_info *mtd_part;
-			struct mtd_device *mtd_dev;
-			u8 part_num;
-
-			sprintf(mtd_part_id, "%s,%d", mtd_id,
-				part->part_id - 1);
-			ret = find_dev_and_part(mtd_part_id, &mtd_dev,
-						&part_num, &mtd_part);
-			if (ret != 0) {
-				stm32prog_err("%s (0x%x): Invalid MTD partition %s",
-					      part->name, part->id,
-					      mtd_part_id);
+			i = 0;
+			list_for_each_entry(partition, &mtd->partitions, node) {
+				if ((part->part_id - 1) == i) {
+					part_found = true;
+					break;
+				}
+				i++;
+			}
+			if (part_found) {
+				part_addr = partition->offset;
+				part_size = partition->size;
+				part_name = partition->name;
+			} else {
+				stm32prog_err("%s (0x%x):Couldn't find part %d on device mtd %s",
+					      part->name, part->id, part->part_id, mtd_id);
 				return -ENODEV;
 			}
-			part_addr = mtd_part->offset;
-			part_size = mtd_part->size;
-			part_name = mtd_part->name;
-			part_found = true;
 		}
 
 		/* no partition for this device */
Signature · 1 line
2.25.1
Reviewed-by on v1 4/12
#10 lore raw

Re: [PATCH 04/12] stm32mp: stm32prog: Remove usage of "mtdparts" function

Quoted 94 lines · Patrick Delaunay

From: Patrice Chotard <[email protected]>

Motivation for this patch is to remove usage of function define in cmd/mtdparts.c interface, based on env variables mtdids and mtdparts:
mtdparts_init() and find_dev_and_part().
See commit 938db6fe5da3 ("cmd: mtdparts: describe as legacy")

Now, all MTD devices are populated with their partition's information found in DT, accessible in MTD devices. Use these information to find the wanted partitions, no more need of find_dev_and_part() usage.

---

 .../mach-stm32mp/cmd_stm32prog/stm32prog.c    | 42 +++++++++----------
 1 file changed, 19 insertions(+), 23 deletions(-)
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c +18 -19
index 6f3641ccf57b..241ad40abb7c 100644
@@ -208,11 +208,6 @@ static int optee_ta_invoke(struct stm32prog_data *data, int cmd, int type,
 	return rc;
 }
 
-/* partition handling routines : CONFIG_CMD_MTDPARTS */
-int mtdparts_init(void);
-int find_dev_and_part(const char *id, struct mtd_device **dev,
-		      u8 *part_num, struct part_info **part);
-
 char *stm32prog_get_error(struct stm32prog_data *data)
 {
 	static const char error_msg[] = "Unspecified";
@@ -741,6 +736,7 @@ static int init_device(struct stm32prog_data *data,
 	struct mmc *mmc = NULL;
 	struct blk_desc *block_dev = NULL;
 	struct mtd_info *mtd = NULL;
+	struct mtd_info *partition;
 	char mtd_id[16];
 	int part_id;
 	int ret;
@@ -749,6 +745,7 @@ static int init_device(struct stm32prog_data *data,
 	u64 part_addr, part_size;
 	bool part_found;
 	const char *part_name;
+	u8 i;
 
 	switch (dev->target) {
 	case STM32PROG_MMC:
@@ -793,10 +790,11 @@ static int init_device(struct stm32prog_data *data,
 			stm32prog_err("unknown device type = %d", dev->target);
 			return -ENODEV;
 		}
+		/* register partitions with MTDIDS/MTDPARTS or OF fallback */
+		mtd_probe_devices();
 		get_mtd_by_target(mtd_id, dev->target, dev->dev_id);
 		log_debug("%s\n", mtd_id);
 
-		mtdparts_init();
 		mtd = get_mtd_device_nm(mtd_id);
 		if (IS_ERR(mtd)) {
 			stm32prog_err("MTD device %s not found", mtd_id);
@@ -943,25 +941,23 @@ static int init_device(struct stm32prog_data *data,
 		}
 
 		if (IS_ENABLED(CONFIG_MTD) && mtd) {
-			char mtd_part_id[32];
-			struct part_info *mtd_part;
-			struct mtd_device *mtd_dev;
-			u8 part_num;
-
-			sprintf(mtd_part_id, "%s,%d", mtd_id,
-				part->part_id - 1);
-			ret = find_dev_and_part(mtd_part_id, &mtd_dev,
-						&part_num, &mtd_part);
-			if (ret != 0) {
-				stm32prog_err("%s (0x%x): Invalid MTD partition %s",
-					      part->name, part->id,
-					      mtd_part_id);
+			i = 0;
+			list_for_each_entry(partition, &mtd->partitions, node) {
+				if ((part->part_id - 1) == i) {
+					part_found = true;
+					break;
+				}
+				i++;
+			}
+			if (part_found) {
+				part_addr = partition->offset;
+				part_size = partition->size;
+				part_name = partition->name;
+			} else {
+				stm32prog_err("%s (0x%x):Couldn't find part %d on device mtd %s",

arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c static int init_device(struct stm32prog_data *data, · line 963

Quoted 10 lines
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c +1 -4
+					      part->name, part->id, part->part_id, mtd_id);
 				return -ENODEV;
 			}
-			part_addr = mtd_part->offset;
-			part_size = mtd_part->size;
-			part_name = mtd_part->name;
-			part_found = true;
 		}
 
 		/* no partition for this device */

Thanks
Patrice

#11 lore raw

PATCH 5/12 arm: dts: stm32: Align stm32mp15xx-*-scmi-u-boot.dtsi file

In reply to Patrick Delaunay

Update "secure" version of STM32 boards based on SCMI when RCC_TZCR.TZEN=1 stm32mp15xx-*-scmi-u-boot.dtsi with latest patches on files stm32mp15xx-*-u-boot.dtsi.

---

 arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi      |  1 +
 arch/arm/dts/stm32mp157c-dk2-scmi-u-boot.dtsi |  7 ++++
 arch/arm/dts/stm32mp157c-ev1-scmi-u-boot.dtsi | 40 +++++++++++++++++++
 3 files changed, 48 insertions(+)
arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi +1 -0
index cff3f49948e4..2623cebf21a4 100644
@@ -12,6 +12,7 @@
 		i2c3 = &i2c4;
 		usb0 = &usbotg_hs;
 	};
+
 	config {
 		u-boot,boot-led = "heartbeat";
 		u-boot,error-led = "error";
arch/arm/dts/stm32mp157c-dk2-scmi-u-boot.dtsi +7 -0
index 5a8fc15ab2b7..ae93497cd5a8 100644
@@ -4,3 +4,10 @@
  */
 
 #include "stm32mp157a-dk1-scmi-u-boot.dtsi"
+
+/ {
+	fwu-mdata {
+		compatible = "u-boot,fwu-mdata-gpt";
+		fwu-mdata-store = <&sdmmc1>;
+	};
+};
arch/arm/dts/stm32mp157c-ev1-scmi-u-boot.dtsi +40 -0
index 71a94f9130a6..eef717946b5f 100644
@@ -14,4 +14,44 @@
 		spi0 = &qspi;
 		usb0 = &usbotg_hs;
 	};
+
+	fwu-mdata {
+		compatible = "u-boot,fwu-mdata-gpt";
+		fwu-mdata-store = <&sdmmc1>;
+	};
+};
+
+&flash0 {
+	bootph-pre-ram;
+};
+
+&qspi {
+	bootph-pre-ram;
+};
+
+&qspi_clk_pins_a {
+	bootph-pre-ram;
+	pins {
+		bootph-pre-ram;
+	};
+};
+
+&qspi_bk1_pins_a {
+	bootph-pre-ram;
+	pins1 {
+		bootph-pre-ram;
+	};
+	pins2 {
+		bootph-pre-ram;
+	};
+};
+
+&qspi_bk2_pins_a {
+	bootph-pre-ram;
+	pins1 {
+		bootph-pre-ram;
+	};
+	pins2 {
+		bootph-pre-ram;
+	};
 };
Signature · 1 line
2.25.1
Reviewed-by on v1 5/12
#12 lore raw

Re: [PATCH 05/12] arm: dts: stm32: Align stm32mp15xx-*-scmi-u-boot.dtsi file

Quoted 78 lines · Patrick Delaunay

Update "secure" version of STM32 boards based on SCMI when RCC_TZCR.TZEN=1 stm32mp15xx-*-scmi-u-boot.dtsi with latest patches on files stm32mp15xx-*-u-boot.dtsi.

---

 arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi      |  1 +
 arch/arm/dts/stm32mp157c-dk2-scmi-u-boot.dtsi |  7 ++++
 arch/arm/dts/stm32mp157c-ev1-scmi-u-boot.dtsi | 40 +++++++++++++++++++
 3 files changed, 48 insertions(+)
arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi +1 -0
index cff3f49948e4..2623cebf21a4 100644
@@ -12,6 +12,7 @@
 		i2c3 = &i2c4;
 		usb0 = &usbotg_hs;
 	};
+
 	config {
 		u-boot,boot-led = "heartbeat";
 		u-boot,error-led = "error";
arch/arm/dts/stm32mp157c-dk2-scmi-u-boot.dtsi +7 -0
index 5a8fc15ab2b7..ae93497cd5a8 100644
@@ -4,3 +4,10 @@
  */
 
 #include "stm32mp157a-dk1-scmi-u-boot.dtsi"
+
+/ {
+	fwu-mdata {
+		compatible = "u-boot,fwu-mdata-gpt";
+		fwu-mdata-store = <&sdmmc1>;
+	};
+};
arch/arm/dts/stm32mp157c-ev1-scmi-u-boot.dtsi +31 -0
index 71a94f9130a6..eef717946b5f 100644
@@ -14,4 +14,44 @@
 		spi0 = &qspi;
 		usb0 = &usbotg_hs;
 	};
+
+	fwu-mdata {
+		compatible = "u-boot,fwu-mdata-gpt";
+		fwu-mdata-store = <&sdmmc1>;
+	};
+};
+
+&flash0 {
+	bootph-pre-ram;
+};
+
+&qspi {
+	bootph-pre-ram;
+};
+
+&qspi_clk_pins_a {
+	bootph-pre-ram;
+	pins {
+		bootph-pre-ram;
+	};
+};
+
+&qspi_bk1_pins_a {
+	bootph-pre-ram;
+	pins1 {
+		bootph-pre-ram;
+	};
+	pins2 {
+		bootph-pre-ram;
+	};
+};

arch/arm/dts/stm32mp157c-ev1-scmi-u-boot.dtsi line 57

Quoted 10 lines
arch/arm/dts/stm32mp157c-ev1-scmi-u-boot.dtsi +9 -0
+
+&qspi_bk2_pins_a {
+	bootph-pre-ram;
+	pins1 {
+		bootph-pre-ram;
+	};
+	pins2 {
+		bootph-pre-ram;
+	};
 };

Thanks
Patrice

#13 lore raw

PATCH 6/12 arm: dts: stm32: Add partitions in flash0 and nand node for stm32mp15xx-ev1

In reply to Patrick Delaunay

From: Patrice Chotard <[email protected]>

Add partitions subnode in flash0 and nand nodes for all stm32mp157xx-ev1 boards. Update only the file stm32mp157c-ev1-*u-boot.dtsi, included by other files stm32mp15*-ev1-*-u-boot.dtsi.

For SCMI variant of device tree used with stm32mp15_defconfig add partitions needed by TF-A firmware update:
- metadata to save the TF-A information: 2 copy
- fip-a / fip-b: two FIP slots, used for system A/B (seamless) update
- the previous "fsbl" partition with 2 copy of TFA is replaced by 2 partitions (only one copy in each MTD partition) to simplify the update: no need to managed this copy on update, need to update the two partition (skip bad block for NAND)
The offset for ENV partition are also updated in stm32mp15_defconfig

---

 arch/arm/dts/stm32mp157c-ev1-scmi-u-boot.dtsi | 85 ++++++++++++++++
 arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi      | 98 ++++++++++++++++++-
 configs/stm32mp15_defconfig                   |  4 +-
 3 files changed, 184 insertions(+), 3 deletions(-)
arch/arm/dts/stm32mp157c-ev1-scmi-u-boot.dtsi +85 -0
index eef717946b5f..9768db8de9c9 100644
@@ -23,6 +23,91 @@
 
 &flash0 {
 	bootph-pre-ram;
+	partitions {
+		compatible = "fixed-partitions";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		partition@0 {
+			label = "fsbl1";
+			reg = <0x00000000 0x00040000>;
+		};
+		partition@40000 {
+			label = "fsbl2";
+			reg = <0x00040000 0x00040000>;
+		};
+		partition@80000 {
+			label = "metadata1";
+			reg = <0x00080000 0x00040000>;
+		};
+		partition@c0000 {
+			label = "metadata2";
+			reg = <0x000c0000 0x00040000>;
+		};
+		partition@100000 {
+			label = "fip-a";
+			reg = <0x00100000 0x00400000>;
+		};
+		partition@500000 {
+			label = "fip-b";
+			reg = <0x00500000 0x00400000>;
+		};
+		partition@900000 {
+			label = "u-boot-env";
+			reg = <0x00900000 0x00080000>;
+		};
+		partition@980000 {
+			label = "nor-user";
+			reg = <0x00980000 0x03680000>;
+		};
+	};
+};
+
+&fmc {
+	nand-controller@4,0 {
+		nand@0 {
+			partitions {
+				compatible = "fixed-partitions";
+				#address-cells = <1>;
+				#size-cells = <1>;
+				partition@0 {
+					label = "fsbl1";
+					reg = <0x00000000 0x00080000>;
+				};
+				partition@80000 {
+					label = "fsbl2";
+					reg = <0x00080000 0x00080000>;
+				};
+				partition@100000 {
+					label = "metadata1";
+					reg = <0x00100000 0x00080000>;
+				};
+				partition@180000 {
+					label = "metadata2";
+					reg = <0x00180000 0x00080000>;
+				};
+				partition@200000 {
+					label = "fip-a1";
+					reg = <0x00200000 0x00400000>;
+				};
+				partition@600000 {
+					label = "fip-a2";
+					reg = <0x00600000 0x00400000>;
+				};
+				partition@a00000 {
+					label = "fip-b1";
+					reg = <0x00a00000 0x00400000>;
+				};
+				partition@e00000 {
+					label = "fip-b2";
+					reg = <0x00e00000 0x00400000>;
+				};
+				partition@1200000 {
+					label = "UBI";
+					reg = <0x01200000 0x3ee00000>;
+				};
+			};
+		};
+	};
 };
 
 &qspi {
arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi +97 -1

107 lines not on this page · raw message

configs/stm32mp15_defconfig +2 -2
index 2669aae0f2f4..bad5c32ef808 100644
@@ -3,7 +3,7 @@ CONFIG_ARCH_STM32MP=y
 CONFIG_TFABOOT=y
 CONFIG_SYS_MALLOC_F_LEN=0x80000
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xc0100000
-CONFIG_ENV_OFFSET=0x480000
+CONFIG_ENV_OFFSET=0x900000
 CONFIG_ENV_SECT_SIZE=0x40000
 CONFIG_DEFAULT_DEVICE_TREE="stm32mp157c-ev1"
 CONFIG_SYS_PROMPT="STM32MP> "
@@ -11,7 +11,7 @@ CONFIG_DDR_CACHEABLE_SIZE=0x10000000
 CONFIG_CMD_STM32KEY=y
 CONFIG_TYPEC_STUSB160X=y
 CONFIG_TARGET_ST_STM32MP15x=y
-CONFIG_ENV_OFFSET_REDUND=0x4C0000
+CONFIG_ENV_OFFSET_REDUND=0x940000
 CONFIG_CMD_STM32PROG=y
 # CONFIG_ARMV7_NONSEC is not set
 CONFIG_SYS_LOAD_ADDR=0xc2000000
Signature · 1 line
2.25.1
Reviewed-by on v1 6/12
#14 lore raw

Re: [PATCH 06/12] arm: dts: stm32: Add partitions in flash0 and nand node for stm32mp15xx-ev1

Quoted 248 lines · Patrick Delaunay

From: Patrice Chotard <[email protected]>

Add partitions subnode in flash0 and nand nodes for all stm32mp157xx-ev1 boards. Update only the file stm32mp157c-ev1-*u-boot.dtsi, included by other files stm32mp15*-ev1-*-u-boot.dtsi.

For SCMI variant of device tree used with stm32mp15_defconfig add partitions needed by TF-A firmware update:
- metadata to save the TF-A information: 2 copy
- fip-a / fip-b: two FIP slots, used for system A/B (seamless) update
- the previous "fsbl" partition with 2 copy of TFA is replaced by 2 partitions (only one copy in each MTD partition) to simplify the update: no need to managed this copy on update, need to update the two partition (skip bad block for NAND)
The offset for ENV partition are also updated in stm32mp15_defconfig

---

 arch/arm/dts/stm32mp157c-ev1-scmi-u-boot.dtsi | 85 ++++++++++++++++
 arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi      | 98 ++++++++++++++++++-
 configs/stm32mp15_defconfig                   |  4 +-
 3 files changed, 184 insertions(+), 3 deletions(-)
arch/arm/dts/stm32mp157c-ev1-scmi-u-boot.dtsi +85 -0
index eef717946b5f..9768db8de9c9 100644
@@ -23,6 +23,91 @@
 
 &flash0 {
 	bootph-pre-ram;
+	partitions {
+		compatible = "fixed-partitions";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		partition@0 {
+			label = "fsbl1";
+			reg = <0x00000000 0x00040000>;
+		};
+		partition@40000 {
+			label = "fsbl2";
+			reg = <0x00040000 0x00040000>;
+		};
+		partition@80000 {
+			label = "metadata1";
+			reg = <0x00080000 0x00040000>;
+		};
+		partition@c0000 {
+			label = "metadata2";
+			reg = <0x000c0000 0x00040000>;
+		};
+		partition@100000 {
+			label = "fip-a";
+			reg = <0x00100000 0x00400000>;
+		};
+		partition@500000 {
+			label = "fip-b";
+			reg = <0x00500000 0x00400000>;
+		};
+		partition@900000 {
+			label = "u-boot-env";
+			reg = <0x00900000 0x00080000>;
+		};
+		partition@980000 {
+			label = "nor-user";
+			reg = <0x00980000 0x03680000>;
+		};
+	};
+};
+
+&fmc {
+	nand-controller@4,0 {
+		nand@0 {
+			partitions {
+				compatible = "fixed-partitions";
+				#address-cells = <1>;
+				#size-cells = <1>;
+				partition@0 {
+					label = "fsbl1";
+					reg = <0x00000000 0x00080000>;
+				};
+				partition@80000 {
+					label = "fsbl2";
+					reg = <0x00080000 0x00080000>;
+				};
+				partition@100000 {
+					label = "metadata1";
+					reg = <0x00100000 0x00080000>;
+				};
+				partition@180000 {
+					label = "metadata2";
+					reg = <0x00180000 0x00080000>;
+				};
+				partition@200000 {
+					label = "fip-a1";
+					reg = <0x00200000 0x00400000>;
+				};
+				partition@600000 {
+					label = "fip-a2";
+					reg = <0x00600000 0x00400000>;
+				};
+				partition@a00000 {
+					label = "fip-b1";
+					reg = <0x00a00000 0x00400000>;
+				};
+				partition@e00000 {
+					label = "fip-b2";
+					reg = <0x00e00000 0x00400000>;
+				};
+				partition@1200000 {
+					label = "UBI";
+					reg = <0x01200000 0x3ee00000>;
+				};
+			};
+		};
+	};
 };
 
 &qspi {
arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi +97 -1
index cb32c30431c2..1f7fdbce5304 100644
@@ -23,6 +23,103 @@
 
 &flash0 {
 	bootph-pre-ram;
+	partitions {
+		compatible = "fixed-partitions";
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+#if defined(CONFIG_STM32MP15x_STM32IMAGE) || defined(CONFIG_SPL)
+		partition@0 {
+			label = "fsbl1";
+			reg = <0x00000000 0x00040000>;
+		};
+		partition@80000 {
+			label = "fsbl2";
+			reg = <0x00040000 0x00040000>;
+		};
+		partition@100000 {
+			label = "ssbl";
+			reg = <0x00080000 0x00200000>;
+		};
+		partition@280000  {
+			label = "u-boot-env";
+			reg = <0x00280000 0x00080000>;
+		};
+		partition@300000 {
+			label = "nor-user";
+			reg = <0x00300000 0x03d00000>;
+		};
+#else
+		partition@0 {
+			label = "fsbl1";
+			reg = <0x00000000 0x00040000>;
+		};
+		partition@40000 {
+			label = "fsbl2";
+			reg = <0x00040000 0x00040000>;
+		};
+		partition@100000 {
+			label = "fip";
+			reg = <0x00080000 0x00400000>;
+		};
+		partition@480000 {
+			label = "u-boot-env";
+			reg = <0x00480000 0x00080000>;
+		};
+		partition@500000 {
+			label = "nor-user";
+			reg = <0x00500000 0x03b00000>;
+		};
+#endif
+	};
+};
+
+&fmc {
+	nand-controller@4,0 {
+		nand@0 {
+			partitions {
+				compatible = "fixed-partitions";
+				#address-cells = <1>;
+				#size-cells = <1>;
+
+#if defined(CONFIG_STM32MP15x_STM32IMAGE) || defined(CONFIG_SPL)
+				partition@0 {
+					label = "fsbl";
+					reg = <0x00000000 0x00200000>;
+				};
+				partition@200000 {
+					label = "ssbl1";
+					reg = <0x00200000 0x00200000>;
+				};
+				partition@400000 {
+					label = "ssbl2";
+					reg = <0x00400000 0x00200000>;
+				};
+				partition@600000 {
+					label = "UBI";
+					reg = <0x00600000 0x3fa00000>;
+				};
+#else
+				partition@0 {
+					label = "fsbl";
+					reg = <0x00000000 0x00200000>;
+				};
+				partition@200000 {
+					label = "fip1";
+					reg = <0x00200000 0x00400000>;
+				};
+				partition@600000 {
+					label = "fip2";
+					reg = <0x00600000 0x00400000>;
+				};
+				partition@1200000 {
+					label = "UBI";
+					reg = <0x00a00000 0x3f600000>;
+				};
+#endif
+			};
+		};
+	};
 };
 
 &qspi {
@@ -55,4 +152,3 @@
 		bootph-pre-ram;
 	};
 };
-
configs/stm32mp15_defconfig +1 -1
index 2669aae0f2f4..bad5c32ef808 100644
@@ -3,7 +3,7 @@ CONFIG_ARCH_STM32MP=y
 CONFIG_TFABOOT=y
 CONFIG_SYS_MALLOC_F_LEN=0x80000
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xc0100000
-CONFIG_ENV_OFFSET=0x480000
+CONFIG_ENV_OFFSET=0x900000
 CONFIG_ENV_SECT_SIZE=0x40000
 CONFIG_DEFAULT_DEVICE_TREE="stm32mp157c-ev1"
 CONFIG_SYS_PROMPT="STM32MP> "

configs/stm32mp15_defconfig CONFIG_DDR_CACHEABLE_SIZE=0x10000000 · line 17

Quoted 8 lines
configs/stm32mp15_defconfig +1 -1
@@ -11,7 +11,7 @@ CONFIG_DDR_CACHEABLE_SIZE=0x10000000
 CONFIG_CMD_STM32KEY=y
 CONFIG_TYPEC_STUSB160X=y
 CONFIG_TARGET_ST_STM32MP15x=y
-CONFIG_ENV_OFFSET_REDUND=0x4C0000
+CONFIG_ENV_OFFSET_REDUND=0x940000
 CONFIG_CMD_STM32PROG=y
 # CONFIG_ARMV7_NONSEC is not set
 CONFIG_SYS_LOAD_ADDR=0xc2000000

Thanks
Patrice

#15 lore raw

PATCH 7/12 configs: stm32mp: Disable SYS_MTDPARTS_RUNTIME for stm32mp15 and stm32mp13

In reply to Patrick Delaunay

From: Patrice Chotard <[email protected]>

As we don't use anymore MTDPARTS_xx Kconfig variables (MTDPARTS_NAND0_BOOT, MTDPARTS_NOR0_BOOT...), disable SYS_MTDPARTS_RUNTIME.

---

 configs/stm32mp13_defconfig         | 1 -
 configs/stm32mp15_basic_defconfig   | 1 -
 configs/stm32mp15_defconfig         | 1 -
 configs/stm32mp15_trusted_defconfig | 1 -
 4 files changed, 4 deletions(-)
configs/stm32mp13_defconfig +0 -1
index b076573c450f..02a29cd9f03a 100644
@@ -59,7 +59,6 @@ CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_STM32_SDMMC2=y
 CONFIG_MTD=y
 CONFIG_DM_MTD=y
-CONFIG_SYS_MTDPARTS_RUNTIME=y
 CONFIG_PINCONF=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
configs/stm32mp15_basic_defconfig +0 -1
index 13355ebb4692..273b72fdaf0a 100644
@@ -125,7 +125,6 @@ CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_STM32_SDMMC2=y
 CONFIG_MTD=y
 CONFIG_DM_MTD=y
-CONFIG_SYS_MTDPARTS_RUNTIME=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_NAND_STM32_FMC2=y
 CONFIG_SYS_NAND_ONFI_DETECTION=y
configs/stm32mp15_defconfig +0 -1
index bad5c32ef808..b1f0f2f7c784 100644
@@ -98,7 +98,6 @@ CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_STM32_SDMMC2=y
 CONFIG_MTD=y
 CONFIG_DM_MTD=y
-CONFIG_SYS_MTDPARTS_RUNTIME=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_NAND_STM32_FMC2=y
 CONFIG_SYS_NAND_ONFI_DETECTION=y
configs/stm32mp15_trusted_defconfig +0 -1
index 5f0fb4565105..bcfd60e5a85a 100644
@@ -99,7 +99,6 @@ CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_STM32_SDMMC2=y
 CONFIG_MTD=y
 CONFIG_DM_MTD=y
-CONFIG_SYS_MTDPARTS_RUNTIME=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_NAND_STM32_FMC2=y
 CONFIG_SYS_NAND_ONFI_DETECTION=y
Signature · 1 line
2.25.1
Reviewed-by on v1 7/12
#16 lore raw

Re: [PATCH 07/12] configs: stm32mp: Disable SYS_MTDPARTS_RUNTIME for stm32mp15 and stm32mp13

Quoted 57 lines · Patrick Delaunay

From: Patrice Chotard <[email protected]>

As we don't use anymore MTDPARTS_xx Kconfig variables (MTDPARTS_NAND0_BOOT, MTDPARTS_NOR0_BOOT...), disable SYS_MTDPARTS_RUNTIME.

---

 configs/stm32mp13_defconfig         | 1 -
 configs/stm32mp15_basic_defconfig   | 1 -
 configs/stm32mp15_defconfig         | 1 -
 configs/stm32mp15_trusted_defconfig | 1 -
 4 files changed, 4 deletions(-)
configs/stm32mp13_defconfig +0 -1
index b076573c450f..02a29cd9f03a 100644
@@ -59,7 +59,6 @@ CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_STM32_SDMMC2=y
 CONFIG_MTD=y
 CONFIG_DM_MTD=y
-CONFIG_SYS_MTDPARTS_RUNTIME=y
 CONFIG_PINCONF=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
configs/stm32mp15_basic_defconfig +0 -1
index 13355ebb4692..273b72fdaf0a 100644
@@ -125,7 +125,6 @@ CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_STM32_SDMMC2=y
 CONFIG_MTD=y
 CONFIG_DM_MTD=y
-CONFIG_SYS_MTDPARTS_RUNTIME=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_NAND_STM32_FMC2=y
 CONFIG_SYS_NAND_ONFI_DETECTION=y
configs/stm32mp15_defconfig +0 -1
index bad5c32ef808..b1f0f2f7c784 100644
@@ -98,7 +98,6 @@ CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_STM32_SDMMC2=y
 CONFIG_MTD=y
 CONFIG_DM_MTD=y
-CONFIG_SYS_MTDPARTS_RUNTIME=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_NAND_STM32_FMC2=y
 CONFIG_SYS_NAND_ONFI_DETECTION=y
configs/stm32mp15_trusted_defconfig +0 -0
index 5f0fb4565105..bcfd60e5a85a 100644

configs/stm32mp15_trusted_defconfig CONFIG_SUPPORT_EMMC_BOOT=y · line 104

Quoted 7 lines
configs/stm32mp15_trusted_defconfig +0 -1
@@ -99,7 +99,6 @@ CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_STM32_SDMMC2=y
 CONFIG_MTD=y
 CONFIG_DM_MTD=y
-CONFIG_SYS_MTDPARTS_RUNTIME=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_NAND_STM32_FMC2=y
 CONFIG_SYS_NAND_ONFI_DETECTION=y

Thanks
Patrice

#17 lore raw

PATCH 8/12 board: stm32mp1: use fdt_copy_fixed_partitions

In reply to Patrick Delaunay

Copy the fixed partition nodes from U-Boot device tree to Linux kernel device tree to dynamically configure the MTD partitions.

fdt_copy_fixed_partitions is only based on device tree
and replace the function fdt_fixup_mtdparts based on mtdparts variable; the variable mtdid and mtdparts are not more required.

---

 board/st/stm32mp1/stm32mp1.c        | 16 +---------------
 configs/stm32mp13_defconfig         |  1 -
 configs/stm32mp15_basic_defconfig   |  1 -
 configs/stm32mp15_defconfig         |  1 -
 configs/stm32mp15_trusted_defconfig |  1 -
 5 files changed, 1 insertion(+), 19 deletions(-)
board/st/stm32mp1/stm32mp1.c +1 -15
index 1a1b1844c8c0..be850151e5fc 100644
@@ -25,7 +25,6 @@
 #include <log.h>
 #include <malloc.h>
 #include <misc.h>
-#include <mtd_node.h>
 #include <net.h>
 #include <netdev.h>
 #include <phy.h>
@@ -915,20 +914,7 @@ int mmc_get_env_dev(void)
 #if defined(CONFIG_OF_BOARD_SETUP)
 int ft_board_setup(void *blob, struct bd_info *bd)
 {
-	static const struct node_info nodes[] = {
-		{ "jedec,spi-nor",		MTD_DEV_TYPE_NOR,  },
-		{ "spi-nand",			MTD_DEV_TYPE_SPINAND},
-		{ "st,stm32mp15-fmc2",		MTD_DEV_TYPE_NAND, },
-		{ "st,stm32mp1-fmc2-nfc",	MTD_DEV_TYPE_NAND, },
-	};
-	char *boot_device;
-
-	/* Check the boot-source and don't update MTD for serial or usb boot */
-	boot_device = env_get("boot_device");
-	if (!boot_device ||
-	    (strcmp(boot_device, "serial") && strcmp(boot_device, "usb")))
-		if (IS_ENABLED(CONFIG_FDT_FIXUP_PARTITIONS))
-			fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
+	fdt_copy_fixed_partitions(blob);
 
 	if (IS_ENABLED(CONFIG_FDT_SIMPLEFB))
 		fdt_simplefb_enable_and_mem_rsv(blob);
configs/stm32mp13_defconfig +0 -1
index 02a29cd9f03a..a9cc7e4d0353 100644
@@ -74,7 +74,6 @@ CONFIG_TEE=y
 CONFIG_OPTEE=y
 # CONFIG_OPTEE_TA_AVB is not set
 CONFIG_ERRNO_STR=y
-CONFIG_FDT_FIXUP_PARTITIONS=y
 # CONFIG_LMB_USE_MAX_REGIONS is not set
 CONFIG_LMB_MEMORY_REGIONS=2
 CONFIG_LMB_RESERVED_REGIONS=16
configs/stm32mp15_basic_defconfig +0 -1
index 273b72fdaf0a..7661159110e5 100644
@@ -188,7 +188,6 @@ CONFIG_WDT=y
 CONFIG_WDT_STM32MP=y
 # CONFIG_BINMAN_FDT is not set
 CONFIG_ERRNO_STR=y
-CONFIG_FDT_FIXUP_PARTITIONS=y
 # CONFIG_LMB_USE_MAX_REGIONS is not set
 CONFIG_LMB_MEMORY_REGIONS=2
 CONFIG_LMB_RESERVED_REGIONS=16
configs/stm32mp15_defconfig +0 -1
index b1f0f2f7c784..1ff9f73730d3 100644
@@ -164,7 +164,6 @@ CONFIG_WDT=y
 CONFIG_WDT_STM32MP=y
 # CONFIG_BINMAN_FDT is not set
 CONFIG_ERRNO_STR=y
-CONFIG_FDT_FIXUP_PARTITIONS=y
 # CONFIG_LMB_USE_MAX_REGIONS is not set
 CONFIG_LMB_MEMORY_REGIONS=2
 CONFIG_LMB_RESERVED_REGIONS=16
configs/stm32mp15_trusted_defconfig +0 -1
index bcfd60e5a85a..e7bf2e171ace 100644
@@ -164,7 +164,6 @@ CONFIG_WDT=y
 CONFIG_WDT_STM32MP=y
 # CONFIG_BINMAN_FDT is not set
 CONFIG_ERRNO_STR=y
-CONFIG_FDT_FIXUP_PARTITIONS=y
 # CONFIG_LMB_USE_MAX_REGIONS is not set
 CONFIG_LMB_MEMORY_REGIONS=2
 CONFIG_LMB_RESERVED_REGIONS=16
Signature · 1 line
2.25.1
Reviewed-by on v1 8/12
#18 lore raw

Re: [PATCH 08/12] board: stm32mp1: use fdt_copy_fixed_partitions

Quoted 92 lines · Patrick Delaunay

Copy the fixed partition nodes from U-Boot device tree to Linux kernel device tree to dynamically configure the MTD partitions.

fdt_copy_fixed_partitions is only based on device tree
and replace the function fdt_fixup_mtdparts based on mtdparts variable; the variable mtdid and mtdparts are not more required.

---

 board/st/stm32mp1/stm32mp1.c        | 16 +---------------
 configs/stm32mp13_defconfig         |  1 -
 configs/stm32mp15_basic_defconfig   |  1 -
 configs/stm32mp15_defconfig         |  1 -
 configs/stm32mp15_trusted_defconfig |  1 -
 5 files changed, 1 insertion(+), 19 deletions(-)
board/st/stm32mp1/stm32mp1.c +1 -15
index 1a1b1844c8c0..be850151e5fc 100644
@@ -25,7 +25,6 @@
 #include <log.h>
 #include <malloc.h>
 #include <misc.h>
-#include <mtd_node.h>
 #include <net.h>
 #include <netdev.h>
 #include <phy.h>
@@ -915,20 +914,7 @@ int mmc_get_env_dev(void)
 #if defined(CONFIG_OF_BOARD_SETUP)
 int ft_board_setup(void *blob, struct bd_info *bd)
 {
-	static const struct node_info nodes[] = {
-		{ "jedec,spi-nor",		MTD_DEV_TYPE_NOR,  },
-		{ "spi-nand",			MTD_DEV_TYPE_SPINAND},
-		{ "st,stm32mp15-fmc2",		MTD_DEV_TYPE_NAND, },
-		{ "st,stm32mp1-fmc2-nfc",	MTD_DEV_TYPE_NAND, },
-	};
-	char *boot_device;
-
-	/* Check the boot-source and don't update MTD for serial or usb boot */
-	boot_device = env_get("boot_device");
-	if (!boot_device ||
-	    (strcmp(boot_device, "serial") && strcmp(boot_device, "usb")))
-		if (IS_ENABLED(CONFIG_FDT_FIXUP_PARTITIONS))
-			fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
+	fdt_copy_fixed_partitions(blob);
 
 	if (IS_ENABLED(CONFIG_FDT_SIMPLEFB))
 		fdt_simplefb_enable_and_mem_rsv(blob);
configs/stm32mp13_defconfig +0 -1
index 02a29cd9f03a..a9cc7e4d0353 100644
@@ -74,7 +74,6 @@ CONFIG_TEE=y
 CONFIG_OPTEE=y
 # CONFIG_OPTEE_TA_AVB is not set
 CONFIG_ERRNO_STR=y
-CONFIG_FDT_FIXUP_PARTITIONS=y
 # CONFIG_LMB_USE_MAX_REGIONS is not set
 CONFIG_LMB_MEMORY_REGIONS=2
 CONFIG_LMB_RESERVED_REGIONS=16
configs/stm32mp15_basic_defconfig +0 -1
index 273b72fdaf0a..7661159110e5 100644
@@ -188,7 +188,6 @@ CONFIG_WDT=y
 CONFIG_WDT_STM32MP=y
 # CONFIG_BINMAN_FDT is not set
 CONFIG_ERRNO_STR=y
-CONFIG_FDT_FIXUP_PARTITIONS=y
 # CONFIG_LMB_USE_MAX_REGIONS is not set
 CONFIG_LMB_MEMORY_REGIONS=2
 CONFIG_LMB_RESERVED_REGIONS=16
configs/stm32mp15_defconfig +0 -1
index b1f0f2f7c784..1ff9f73730d3 100644
@@ -164,7 +164,6 @@ CONFIG_WDT=y
 CONFIG_WDT_STM32MP=y
 # CONFIG_BINMAN_FDT is not set
 CONFIG_ERRNO_STR=y
-CONFIG_FDT_FIXUP_PARTITIONS=y
 # CONFIG_LMB_USE_MAX_REGIONS is not set
 CONFIG_LMB_MEMORY_REGIONS=2
 CONFIG_LMB_RESERVED_REGIONS=16
configs/stm32mp15_trusted_defconfig +0 -0
index bcfd60e5a85a..e7bf2e171ace 100644

configs/stm32mp15_trusted_defconfig CONFIG_WDT=y · line 169

Quoted 7 lines
configs/stm32mp15_trusted_defconfig +0 -1
@@ -164,7 +164,6 @@ CONFIG_WDT=y
 CONFIG_WDT_STM32MP=y
 # CONFIG_BINMAN_FDT is not set
 CONFIG_ERRNO_STR=y
-CONFIG_FDT_FIXUP_PARTITIONS=y
 # CONFIG_LMB_USE_MAX_REGIONS is not set
 CONFIG_LMB_MEMORY_REGIONS=2
 CONFIG_LMB_RESERVED_REGIONS=16

Thanks
Patrice

#19 lore raw

PATCH 9/12 board: st: remove board_mtdparts_default

In reply to Patrick Delaunay

Remove the function board_mtdparts_default and the associated file or configs, only used by the CONFIG_SYS_MTDPARTS_RUNTIME now removed.

---

 board/st/common/Kconfig            |  66 -----------
 board/st/common/Makefile           |   1 -
 board/st/common/stm32mp_mtdparts.c | 177 -----------------------------
 3 files changed, 244 deletions(-)
 delete mode 100644 board/st/common/stm32mp_mtdparts.c
board/st/common/Kconfig +0 -66
index aba3590866e0..c1c254d07354 100644
@@ -6,72 +6,6 @@ config CMD_STBOARD
 	  This compile the stboard command to
 	  read and write the board in the OTP.
 
-config MTDPARTS_NAND0_BOOT
-	string "mtd boot partitions for nand0"
-	default "2m(fsbl),2m(ssbl1),2m(ssbl2)" if STM32MP15x_STM32IMAGE || \
-						  !TFABOOT
-	default "2m(fsbl),4m(fip1),4m(fip2)"
-	depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP
-	help
-	  This define the partitions of nand0 used to build mtparts dynamically
-	  for boot from nand0.
-	  Each partition need to be aligned with the device erase block size,
-	  512KB is the max size for the NAND supported by stm32mp1 platform.
-	  The fsbl partition support multiple copy of the same binary, one by
-	  erase block.
-
-config MTDPARTS_NAND0_TEE
-	string "mtd tee partitions for nand0"
-	default "512k(teeh),512k(teed),512k(teex)"
-	depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP && STM32MP15x_STM32IMAGE
-	help
-	  This define the tee partitions added in mtparts dynamically
-	  when tee is supported with boot from nand0.
-	  Each partition need to be aligned with the device erase block size,
-	  512KB is the max size for the NAND supported by stm32mp1 platform.
-
-config MTDPARTS_NOR0_BOOT
-	string "mtd boot partitions for nor0"
-	default "256k(fsbl1),256k(fsbl2),2m(ssbl),512k(u-boot-env)" if STM32MP15x_STM32IMAGE || \
-								       !TFABOOT
-	default "256k(fsbl1),256k(fsbl2),4m(fip),512k(u-boot-env)"
-	depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP
-	help
-	  This define the partitions of nand0 used to build mtparts dynamically
-	  for boot from nor0.
-	  Each partition need to be aligned with the device erase block size,
-	  with 256KB we support all the NOR.
-	  U-Boot env partition (512kB) use 2 erase block for redundancy.
-
-config MTDPARTS_NOR0_TEE
-	string "mtd tee partitions for nor0"
-	default "256k(teeh),512k(teed),256k(teex)"
-	depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP && STM32MP15x_STM32IMAGE
-	help
-	  This define the tee partitions added in mtparts dynamically
-	  when tee is supported with boot from nor0.
-
-config MTDPARTS_SPINAND0_BOOT
-	string "mtd boot partitions for spi-nand0"
-	default "2m(fsbl),2m(ssbl1),2m(ssbl2)" if STM32MP15x_STM32IMAGE || !TFABOOT
-	default "2m(fsbl),4m(fip1),4m(fip2)"
-	depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP
-	help
-	  This define the partitions of nand0 used to build mtparts dynamically
-	  for boot from spi-nand0,
-	  512KB is the max size for the NAND supported by stm32mp1 platform.
-	  The fsbl partition support multiple copy of the same binary, one by
-	  erase block.
-
-config MTDPARTS_SPINAND0_TEE
-	string "mtd tee partitions for spi-nand0"
-	default "512k(teeh),512k(teed),512k(teex)"
-	depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP && STM32MP15x_STM32IMAGE
-	help
-	  This define the tee partitions added in mtparts dynamically
-	  when tee is supported with boot from spi-nand0,
-	  512KB is the max size for the NAND supported by stm32mp1 platform.
-
 config DFU_ALT_RAM0
 	string "dfu for ram0"
 	default "uImage ram 0xc2000000 0x2000000;devicetree.dtb ram 0xc4000000 0x100000;uramdisk.image.gz ram 0xc4400000 0x10000000"
board/st/common/Makefile +0 -1
index 65bbebd6abc3..c9608297261a 100644
@@ -7,7 +7,6 @@ obj-$(CONFIG_CMD_STBOARD) += cmd_stboard.o
 obj-$(CONFIG_PMIC_STPMIC1) += stpmic1.o
 
 ifeq ($(CONFIG_ARCH_STM32MP),y)
-obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += stm32mp_mtdparts.o
 obj-$(CONFIG_SET_DFU_ALT_INFO) += stm32mp_dfu.o
 endif
 
board/st/common/stm32mp_mtdparts.c deleted +0 -177

177 lines not on this page · raw message

Signature · 1 line
2.25.1
Reviewed-by on v1 9/12
#20 lore raw

Re: [PATCH 09/12] board: st: remove board_mtdparts_default

Quoted 274 lines · Patrick Delaunay

Remove the function board_mtdparts_default and the associated file or configs, only used by the CONFIG_SYS_MTDPARTS_RUNTIME now removed.

---

 board/st/common/Kconfig            |  66 -----------
 board/st/common/Makefile           |   1 -
 board/st/common/stm32mp_mtdparts.c | 177 -----------------------------
 3 files changed, 244 deletions(-)
 delete mode 100644 board/st/common/stm32mp_mtdparts.c
board/st/common/Kconfig +0 -66
index aba3590866e0..c1c254d07354 100644
@@ -6,72 +6,6 @@ config CMD_STBOARD
 	  This compile the stboard command to
 	  read and write the board in the OTP.
 
-config MTDPARTS_NAND0_BOOT
-	string "mtd boot partitions for nand0"
-	default "2m(fsbl),2m(ssbl1),2m(ssbl2)" if STM32MP15x_STM32IMAGE || \
-						  !TFABOOT
-	default "2m(fsbl),4m(fip1),4m(fip2)"
-	depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP
-	help
-	  This define the partitions of nand0 used to build mtparts dynamically
-	  for boot from nand0.
-	  Each partition need to be aligned with the device erase block size,
-	  512KB is the max size for the NAND supported by stm32mp1 platform.
-	  The fsbl partition support multiple copy of the same binary, one by
-	  erase block.
-
-config MTDPARTS_NAND0_TEE
-	string "mtd tee partitions for nand0"
-	default "512k(teeh),512k(teed),512k(teex)"
-	depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP && STM32MP15x_STM32IMAGE
-	help
-	  This define the tee partitions added in mtparts dynamically
-	  when tee is supported with boot from nand0.
-	  Each partition need to be aligned with the device erase block size,
-	  512KB is the max size for the NAND supported by stm32mp1 platform.
-
-config MTDPARTS_NOR0_BOOT
-	string "mtd boot partitions for nor0"
-	default "256k(fsbl1),256k(fsbl2),2m(ssbl),512k(u-boot-env)" if STM32MP15x_STM32IMAGE || \
-								       !TFABOOT
-	default "256k(fsbl1),256k(fsbl2),4m(fip),512k(u-boot-env)"
-	depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP
-	help
-	  This define the partitions of nand0 used to build mtparts dynamically
-	  for boot from nor0.
-	  Each partition need to be aligned with the device erase block size,
-	  with 256KB we support all the NOR.
-	  U-Boot env partition (512kB) use 2 erase block for redundancy.
-
-config MTDPARTS_NOR0_TEE
-	string "mtd tee partitions for nor0"
-	default "256k(teeh),512k(teed),256k(teex)"
-	depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP && STM32MP15x_STM32IMAGE
-	help
-	  This define the tee partitions added in mtparts dynamically
-	  when tee is supported with boot from nor0.
-
-config MTDPARTS_SPINAND0_BOOT
-	string "mtd boot partitions for spi-nand0"
-	default "2m(fsbl),2m(ssbl1),2m(ssbl2)" if STM32MP15x_STM32IMAGE || !TFABOOT
-	default "2m(fsbl),4m(fip1),4m(fip2)"
-	depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP
-	help
-	  This define the partitions of nand0 used to build mtparts dynamically
-	  for boot from spi-nand0,
-	  512KB is the max size for the NAND supported by stm32mp1 platform.
-	  The fsbl partition support multiple copy of the same binary, one by
-	  erase block.
-
-config MTDPARTS_SPINAND0_TEE
-	string "mtd tee partitions for spi-nand0"
-	default "512k(teeh),512k(teed),512k(teex)"
-	depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP && STM32MP15x_STM32IMAGE
-	help
-	  This define the tee partitions added in mtparts dynamically
-	  when tee is supported with boot from spi-nand0,
-	  512KB is the max size for the NAND supported by stm32mp1 platform.
-
 config DFU_ALT_RAM0
 	string "dfu for ram0"
 	default "uImage ram 0xc2000000 0x2000000;devicetree.dtb ram 0xc4000000 0x100000;uramdisk.image.gz ram 0xc4400000 0x10000000"
board/st/common/Makefile +0 -1
index 65bbebd6abc3..c9608297261a 100644
@@ -7,7 +7,6 @@ obj-$(CONFIG_CMD_STBOARD) += cmd_stboard.o
 obj-$(CONFIG_PMIC_STPMIC1) += stpmic1.o
 
 ifeq ($(CONFIG_ARCH_STM32MP),y)
-obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += stm32mp_mtdparts.o
 obj-$(CONFIG_SET_DFU_ALT_INFO) += stm32mp_dfu.o
 endif
 
board/st/common/stm32mp_mtdparts.c deleted +0 -167
deleted file mode 100644
index 67a56a2623a1..000000000000
@@ -1,177 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
-/*
- * Copyright (C) 2020, STMicroelectronics - All Rights Reserved
- */
-
-#include <common.h>
-#include <dfu.h>
-#include <dm.h>
-#include <env.h>
-#include <env_internal.h>
-#include <log.h>
-#include <mtd.h>
-#include <mtd_node.h>
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-#include <tee.h>
-#endif
-#include <asm/arch/stm32prog.h>
-#include <asm/arch/sys_proto.h>
-#include <asm/global_data.h>
-
-#define MTDPARTS_LEN		256
-#define MTDIDS_LEN		128
-
-/*
- * Get a global data pointer
- */
-DECLARE_GLOBAL_DATA_PTR;
-
-/**
- * update the variables "mtdids" and "mtdparts" with boot, tee and user strings
- */
-static void board_set_mtdparts(const char *dev,
-			       char *mtdids,
-			       char *mtdparts,
-			       const char *boot,
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-			       const char *tee,
-#endif
-			       const char *user)
-{
-	/* mtdids: "<dev>=<dev>, ...." */
-	if (mtdids[0] != '\0')
-		strcat(mtdids, ",");
-	strcat(mtdids, dev);
-	strcat(mtdids, "=");
-	strcat(mtdids, dev);
-
-	/* mtdparts: "mtdparts=<dev>:<mtdparts_<dev>>;..." */
-	if (mtdparts[0] != '\0')
-		strncat(mtdparts, ";", MTDPARTS_LEN);
-	else
-		strcat(mtdparts, "mtdparts=");
-
-	strncat(mtdparts, dev, MTDPARTS_LEN);
-	strncat(mtdparts, ":", MTDPARTS_LEN);
-
-	if (boot) {
-		strncat(mtdparts, boot, MTDPARTS_LEN);
-		strncat(mtdparts, ",", MTDPARTS_LEN);
-	}
-
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-	if (tee) {
-		strncat(mtdparts, tee, MTDPARTS_LEN);
-		strncat(mtdparts, ",", MTDPARTS_LEN);
-	}
-#endif
-
-	strncat(mtdparts, user, MTDPARTS_LEN);
-}
-
-void board_mtdparts_default(const char **mtdids, const char **mtdparts)
-{
-	struct mtd_info *mtd;
-	struct udevice *dev;
-	static char parts[3 * MTDPARTS_LEN + 1];
-	static char ids[MTDIDS_LEN + 1];
-	static bool mtd_initialized;
-	bool nor, nand, spinand, serial;
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-	bool tee = false;
-#endif
-
-	if (mtd_initialized) {
-		*mtdids = ids;
-		*mtdparts = parts;
-		return;
-	}
-
-	nor = false;
-	nand = false;
-	spinand = false;
-	serial = false;
-
-	switch (get_bootmode() & TAMP_BOOT_DEVICE_MASK) {
-	case BOOT_SERIAL_UART:
-	case BOOT_SERIAL_USB:
-		serial = true;
-		if (IS_ENABLED(CONFIG_CMD_STM32PROG)) {
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-			tee = stm32prog_get_tee_partitions();
-#endif
-			nor = stm32prog_get_fsbl_nor();
-		}
-		nand = true;
-		spinand = true;
-		break;
-	case BOOT_FLASH_NAND:
-		nand = true;
-		break;
-	case BOOT_FLASH_SPINAND:
-		spinand = true;
-		break;
-	case BOOT_FLASH_NOR:
-		nor = true;
-		break;
-	default:
-		break;
-	}
-
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-	if (!serial && tee_find_device(NULL, NULL, NULL, NULL))
-		tee = true;
-#endif
-
-	memset(parts, 0, sizeof(parts));
-	memset(ids, 0, sizeof(ids));
-
-	/* probe all MTD devices */
-	for (uclass_first_device(UCLASS_MTD, &dev);
-	     dev;
-	     uclass_next_device(&dev)) {
-		log_debug("mtd device = %s\n", dev->name);
-	}
-
-	if (nand) {
-		mtd = get_mtd_device_nm("nand0");
-		if (!IS_ERR_OR_NULL(mtd)) {
-			board_set_mtdparts("nand0", ids, parts,
-					   CONFIG_MTDPARTS_NAND0_BOOT,
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-					   !nor && tee ? CONFIG_MTDPARTS_NAND0_TEE : NULL,
-#endif
-					   "-(UBI)");
-			put_mtd_device(mtd);
-		}
-	}
-
-	if (spinand) {
-		mtd = get_mtd_device_nm("spi-nand0");
-		if (!IS_ERR_OR_NULL(mtd)) {
-			board_set_mtdparts("spi-nand0", ids, parts,
-					   CONFIG_MTDPARTS_SPINAND0_BOOT,
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-					   !nor && tee ? CONFIG_MTDPARTS_SPINAND0_TEE : NULL,
-#endif
-					   "-(UBI)");
-			put_mtd_device(mtd);
-		}
-	}
-
-	if (nor) {
-		if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev)) {
-			board_set_mtdparts("nor0", ids, parts,
-					   CONFIG_MTDPARTS_NOR0_BOOT,
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-					   tee ? CONFIG_MTDPARTS_NOR0_TEE : NULL,

board/st/common/stm32mp_mtdparts.c line 177

Quoted 10 lines
board/st/common/stm32mp_mtdparts.c deleted +0 -10
-#endif
-					   "-(nor_user)");
-		}
-	}
-
-	mtd_initialized = true;
-	*mtdids = ids;
-	*mtdparts = parts;
-	log_debug("mtdids=%s & mtdparts=%s\n", ids, parts);
-}

Thanks
Patrice

#21 lore raw

PATCH 10/12 stm32mp: stm32prog: Remove tee_detected from stm32prog_data struct

In reply to Patrick Delaunay

From: Patrice Chotard <[email protected]>

As stm32prog_get_tee_partitions() is no more used, remove tee_detected boolean from stm32prog_data struct and all code using it.

---

 arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c |  9 ---------
 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c     | 11 -----------
 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h     |  3 ---
 arch/arm/mach-stm32mp/include/mach/stm32prog.h      |  4 ----
 4 files changed, 27 deletions(-)
arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c +0 -9
index cfafa539aeb9..c695cc11232b 100644
@@ -180,15 +180,6 @@ U_BOOT_CMD(stm32prog, 5, 0, do_stm32prog,
 	   "  <size> = size of flashlayout (optional for image with STM32 header)\n"
 );
 
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-bool stm32prog_get_tee_partitions(void)
-{
-	if (stm32prog_data)
-		return stm32prog_data->tee_detected;
-
-	return false;
-}
-#endif
 
 bool stm32prog_get_fsbl_nor(void)
 {
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c +0 -11
index 241ad40abb7c..0cdc14dd5bc8 100644
@@ -995,9 +995,6 @@ static int treat_partition_list(struct stm32prog_data *data)
 		INIT_LIST_HEAD(&data->dev[j].part_list);
 	}
 
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-	data->tee_detected = false;
-#endif
 	data->fsbl_nor_detected = false;
 	for (i = 0; i < data->part_nb; i++) {
 		part = &data->part_array[i];
@@ -1049,14 +1046,6 @@ static int treat_partition_list(struct stm32prog_data *data)
 			    !strncmp(part->name, "fsbl", 4))
 				data->fsbl_nor_detected = true;
 			/* fallthrough */
-		case STM32PROG_NAND:
-		case STM32PROG_SPI_NAND:
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-			if (!data->tee_detected &&
-			    !strncmp(part->name, "tee", 3))
-				data->tee_detected = true;
-			break;
-#endif
 		default:
 			break;
 		}
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h +0 -3
index 58f4b96fa752..04a899ee1184 100644
@@ -149,9 +149,6 @@ struct stm32prog_data {
 	struct stm32prog_dev_t	dev[STM32PROG_MAX_DEV];	/* array of device */
 	int			part_nb;	/* nb of partition */
 	struct stm32prog_part_t	*part_array;	/* array of partition */
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-	bool			tee_detected;
-#endif
 	bool			fsbl_nor_detected;
 
 	/* command internal information */
arch/arm/mach-stm32mp/include/mach/stm32prog.h +0 -4
index 99be4e1d656b..23d1adfbad92 100644
@@ -11,8 +11,4 @@ int stm32prog_read_medium_virt(struct dfu_entity *dfu, u64 offset,
 			       void *buf, long *len);
 int stm32prog_get_medium_size_virt(struct dfu_entity *dfu, u64 *size);
 
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-bool stm32prog_get_tee_partitions(void);
-#endif
-
 bool stm32prog_get_fsbl_nor(void);
Signature · 1 line
2.25.1
Reviewed-by on v1 10/12
#22 lore raw

Re: [PATCH 10/12] stm32mp: stm32prog: Remove tee_detected from stm32prog_data struct

Quoted 83 lines · Patrick Delaunay

From: Patrice Chotard <[email protected]>

As stm32prog_get_tee_partitions() is no more used, remove tee_detected boolean from stm32prog_data struct and all code using it.

---

 arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c |  9 ---------
 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c     | 11 -----------
 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h     |  3 ---
 arch/arm/mach-stm32mp/include/mach/stm32prog.h      |  4 ----
 4 files changed, 27 deletions(-)
arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c +0 -9
index cfafa539aeb9..c695cc11232b 100644
@@ -180,15 +180,6 @@ U_BOOT_CMD(stm32prog, 5, 0, do_stm32prog,
 	   "  <size> = size of flashlayout (optional for image with STM32 header)\n"
 );
 
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-bool stm32prog_get_tee_partitions(void)
-{
-	if (stm32prog_data)
-		return stm32prog_data->tee_detected;
-
-	return false;
-}
-#endif
 
 bool stm32prog_get_fsbl_nor(void)
 {
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c +0 -11
index 241ad40abb7c..0cdc14dd5bc8 100644
@@ -995,9 +995,6 @@ static int treat_partition_list(struct stm32prog_data *data)
 		INIT_LIST_HEAD(&data->dev[j].part_list);
 	}
 
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-	data->tee_detected = false;
-#endif
 	data->fsbl_nor_detected = false;
 	for (i = 0; i < data->part_nb; i++) {
 		part = &data->part_array[i];
@@ -1049,14 +1046,6 @@ static int treat_partition_list(struct stm32prog_data *data)
 			    !strncmp(part->name, "fsbl", 4))
 				data->fsbl_nor_detected = true;
 			/* fallthrough */
-		case STM32PROG_NAND:
-		case STM32PROG_SPI_NAND:
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-			if (!data->tee_detected &&
-			    !strncmp(part->name, "tee", 3))
-				data->tee_detected = true;
-			break;
-#endif
 		default:
 			break;
 		}
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h +0 -3
index 58f4b96fa752..04a899ee1184 100644
@@ -149,9 +149,6 @@ struct stm32prog_data {
 	struct stm32prog_dev_t	dev[STM32PROG_MAX_DEV];	/* array of device */
 	int			part_nb;	/* nb of partition */
 	struct stm32prog_part_t	*part_array;	/* array of partition */
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-	bool			tee_detected;
-#endif
 	bool			fsbl_nor_detected;
 
 	/* command internal information */
arch/arm/mach-stm32mp/include/mach/stm32prog.h +0 -0
index 99be4e1d656b..23d1adfbad92 100644

arch/arm/mach-stm32mp/include/mach/stm32prog.h int stm32prog_read_medium_virt(struct dfu_entity *dfu, u64 offset, · line 14

Quoted 8 lines
arch/arm/mach-stm32mp/include/mach/stm32prog.h +0 -4
@@ -11,8 +11,4 @@ int stm32prog_read_medium_virt(struct dfu_entity *dfu, u64 offset,
 			       void *buf, long *len);
 int stm32prog_get_medium_size_virt(struct dfu_entity *dfu, u64 *size);
 
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-bool stm32prog_get_tee_partitions(void);
-#endif
-
 bool stm32prog_get_fsbl_nor(void);

Thanks
Patrice

#23 lore raw

PATCH 11/12 configs: stm32mp1: disable CMD_MTDPARTS

In reply to Patrick Delaunay

From: Patrice Chotard <[email protected]>

Disable CMD_MTDPARTS as it's no more needed and it is strongly encouraged to avoid using this command anymore.
(see comments in ./cmd/Kconfig:2422).

---

 configs/stm32mp13_defconfig         | 1 -
 configs/stm32mp15_basic_defconfig   | 1 -
 configs/stm32mp15_defconfig         | 1 -
 configs/stm32mp15_trusted_defconfig | 1 -
 4 files changed, 4 deletions(-)
configs/stm32mp13_defconfig +0 -1
index a9cc7e4d0353..5e9abc5e2625 100644
@@ -39,7 +39,6 @@ CONFIG_CMD_RNG=y
 CONFIG_CMD_TIMER=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_MTDPARTS=y
 CONFIG_CMD_LOG=y
 CONFIG_CMD_UBI=y
 CONFIG_OF_LIVE=y
configs/stm32mp15_basic_defconfig +0 -1
index 7661159110e5..94f4dbd4c32b 100644
@@ -75,7 +75,6 @@ CONFIG_CMD_TIMER=y
 CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_MTDPARTS=y
 CONFIG_CMD_LOG=y
 CONFIG_CMD_UBI=y
 # CONFIG_SPL_DOS_PARTITION is not set
configs/stm32mp15_defconfig +0 -1
index 1ff9f73730d3..37b6d4a7b4ac 100644
@@ -51,7 +51,6 @@ CONFIG_CMD_TIMER=y
 CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_MTDPARTS=y
 CONFIG_CMD_LOG=y
 CONFIG_CMD_UBI=y
 CONFIG_OF_LIVE=y
configs/stm32mp15_trusted_defconfig +0 -1
index e7bf2e171ace..9c5446d6d4a2 100644
@@ -52,7 +52,6 @@ CONFIG_CMD_TIMER=y
 CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_MTDPARTS=y
 CONFIG_CMD_LOG=y
 CONFIG_CMD_UBI=y
 CONFIG_OF_LIVE=y
Signature · 1 line
2.25.1
Reviewed-by on v1 11/12
#24 lore raw

Re: [PATCH 11/12] configs: stm32mp1: disable CMD_MTDPARTS

Quoted 57 lines · Patrick Delaunay

From: Patrice Chotard <[email protected]>

Disable CMD_MTDPARTS as it's no more needed and it is strongly encouraged to avoid using this command anymore.
(see comments in ./cmd/Kconfig:2422).

---

 configs/stm32mp13_defconfig         | 1 -
 configs/stm32mp15_basic_defconfig   | 1 -
 configs/stm32mp15_defconfig         | 1 -
 configs/stm32mp15_trusted_defconfig | 1 -
 4 files changed, 4 deletions(-)
configs/stm32mp13_defconfig +0 -1
index a9cc7e4d0353..5e9abc5e2625 100644
@@ -39,7 +39,6 @@ CONFIG_CMD_RNG=y
 CONFIG_CMD_TIMER=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_MTDPARTS=y
 CONFIG_CMD_LOG=y
 CONFIG_CMD_UBI=y
 CONFIG_OF_LIVE=y
configs/stm32mp15_basic_defconfig +0 -1
index 7661159110e5..94f4dbd4c32b 100644
@@ -75,7 +75,6 @@ CONFIG_CMD_TIMER=y
 CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_MTDPARTS=y
 CONFIG_CMD_LOG=y
 CONFIG_CMD_UBI=y
 # CONFIG_SPL_DOS_PARTITION is not set
configs/stm32mp15_defconfig +0 -1
index 1ff9f73730d3..37b6d4a7b4ac 100644
@@ -51,7 +51,6 @@ CONFIG_CMD_TIMER=y
 CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_MTDPARTS=y
 CONFIG_CMD_LOG=y
 CONFIG_CMD_UBI=y
 CONFIG_OF_LIVE=y
configs/stm32mp15_trusted_defconfig +0 -0
index e7bf2e171ace..9c5446d6d4a2 100644

configs/stm32mp15_trusted_defconfig CONFIG_CMD_TIMER=y · line 57

Quoted 7 lines
configs/stm32mp15_trusted_defconfig +0 -1
@@ -52,7 +52,6 @@ CONFIG_CMD_TIMER=y
 CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_MTDPARTS=y
 CONFIG_CMD_LOG=y
 CONFIG_CMD_UBI=y
 CONFIG_OF_LIVE=y

Thanks
Patrice

#25 lore raw

PATCH 12/12 arm: dts: stm32: Add partitions in flash0 and nand node for stm32mp15xx-dhcom/dhcor

In reply to Patrick Delaunay

Add partitions subnode in flash0 for stm32mp157xx-dhcom/dhcor boards.

---

 arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi | 27 ++++++++++++++++++++++
 arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi | 27 ++++++++++++++++++++++
 configs/stm32mp15_dhcom_basic_defconfig    |  3 ---
 configs/stm32mp15_dhcor_basic_defconfig    |  3 ---
 4 files changed, 54 insertions(+), 6 deletions(-)
arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi +27 -0
index bc0730cf2bd0..a808620e1219 100644
@@ -92,6 +92,33 @@
 
 &flash0 {
 	bootph-pre-ram;
+
+	partitions {
+		compatible = "fixed-partitions";
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		partition@0 {
+			label = "fsbl1";
+			reg = <0x00000000 0x00040000>;
+		};
+		partition@40000 {
+			label = "fsbl2";
+			reg = <0x00040000 0x00040000>;
+		};
+		partition@500000 {
+			label = "uboot";
+			reg = <0x00080000 0x00160000>;
+		};
+		partition@900000 {
+			label = "env1";
+			reg = <0x001E0000 0x00010000>;
+		};
+		partition@980000 {
+			label = "env2";
+			reg = <0x001F0000 0x00010000>;
+		};
+	};
 };
 
 &qspi {
arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi +27 -0
index 804c66283e08..eb905ad28201 100644
@@ -28,6 +28,33 @@
 
 &flash0 {
 	bootph-pre-ram;
+
+	partitions {
+		compatible = "fixed-partitions";
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		partition@0 {
+			label = "fsbl1";
+			reg = <0x00000000 0x00040000>;
+		};
+		partition@40000 {
+			label = "fsbl2";
+			reg = <0x00040000 0x00040000>;
+		};
+		partition@500000 {
+			label = "uboot";
+			reg = <0x00080000 0x00160000>;
+		};
+		partition@900000 {
+			label = "env1";
+			reg = <0x001E0000 0x00010000>;
+		};
+		partition@980000 {
+			label = "env2";
+			reg = <0x001F0000 0x00010000>;
+		};
+	};
 };
 
 &i2c4 {
configs/stm32mp15_dhcom_basic_defconfig +0 -3
index 430d0bccc9a7..77f0fafc5c71 100644
@@ -85,9 +85,6 @@ CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_BTRFS=y
 CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_MTDPARTS=y
-CONFIG_MTDIDS_DEFAULT="nor0=nor0"
-CONFIG_MTDPARTS_DEFAULT="mtdparts=nor0:256k(fsbl1),256k(fsbl2),1408k(uboot),64k(env1),64k(env2)"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_ISO_PARTITION is not set
 # CONFIG_SPL_PARTITION_UUIDS is not set
configs/stm32mp15_dhcor_basic_defconfig +0 -3
index f23875fb84fe..4151ad64a4be 100644
@@ -83,9 +83,6 @@ CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_BTRFS=y
 CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_MTDPARTS=y
-CONFIG_MTDIDS_DEFAULT="nor0=nor0"
-CONFIG_MTDPARTS_DEFAULT="mtdparts=nor0:256k(fsbl1),256k(fsbl2),1408k(uboot),64k(env1),64k(env2)"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_ISO_PARTITION is not set
 # CONFIG_SPL_PARTITION_UUIDS is not set
Signature · 1 line
2.25.1
Reviewed-by on v1 12/12
#26 lore raw

Re: [PATCH 12/12] arm: dts: stm32: Add partitions in flash0 and nand node for stm32mp15xx-dhcom/dhcor

Quoted 106 lines · Patrick Delaunay

Add partitions subnode in flash0 for stm32mp157xx-dhcom/dhcor boards.

---

 arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi | 27 ++++++++++++++++++++++
 arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi | 27 ++++++++++++++++++++++
 configs/stm32mp15_dhcom_basic_defconfig    |  3 ---
 configs/stm32mp15_dhcor_basic_defconfig    |  3 ---
 4 files changed, 54 insertions(+), 6 deletions(-)
arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi +27 -0
index bc0730cf2bd0..a808620e1219 100644
@@ -92,6 +92,33 @@
 
 &flash0 {
 	bootph-pre-ram;
+
+	partitions {
+		compatible = "fixed-partitions";
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		partition@0 {
+			label = "fsbl1";
+			reg = <0x00000000 0x00040000>;
+		};
+		partition@40000 {
+			label = "fsbl2";
+			reg = <0x00040000 0x00040000>;
+		};
+		partition@500000 {
+			label = "uboot";
+			reg = <0x00080000 0x00160000>;
+		};
+		partition@900000 {
+			label = "env1";
+			reg = <0x001E0000 0x00010000>;
+		};
+		partition@980000 {
+			label = "env2";
+			reg = <0x001F0000 0x00010000>;
+		};
+	};
 };
 
 &qspi {
arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi +27 -0
index 804c66283e08..eb905ad28201 100644
@@ -28,6 +28,33 @@
 
 &flash0 {
 	bootph-pre-ram;
+
+	partitions {
+		compatible = "fixed-partitions";
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		partition@0 {
+			label = "fsbl1";
+			reg = <0x00000000 0x00040000>;
+		};
+		partition@40000 {
+			label = "fsbl2";
+			reg = <0x00040000 0x00040000>;
+		};
+		partition@500000 {
+			label = "uboot";
+			reg = <0x00080000 0x00160000>;
+		};
+		partition@900000 {
+			label = "env1";
+			reg = <0x001E0000 0x00010000>;
+		};
+		partition@980000 {
+			label = "env2";
+			reg = <0x001F0000 0x00010000>;
+		};
+	};
 };
 
 &i2c4 {
configs/stm32mp15_dhcom_basic_defconfig +0 -3
index 430d0bccc9a7..77f0fafc5c71 100644
@@ -85,9 +85,6 @@ CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_BTRFS=y
 CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_MTDPARTS=y
-CONFIG_MTDIDS_DEFAULT="nor0=nor0"
-CONFIG_MTDPARTS_DEFAULT="mtdparts=nor0:256k(fsbl1),256k(fsbl2),1408k(uboot),64k(env1),64k(env2)"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_ISO_PARTITION is not set
 # CONFIG_SPL_PARTITION_UUIDS is not set
configs/stm32mp15_dhcor_basic_defconfig +0 -0
index f23875fb84fe..4151ad64a4be 100644

configs/stm32mp15_dhcor_basic_defconfig CONFIG_CMD_PMIC=y · line 88

Quoted 9 lines
configs/stm32mp15_dhcor_basic_defconfig +0 -3
@@ -83,9 +83,6 @@ CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_BTRFS=y
 CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_MTDPARTS=y
-CONFIG_MTDIDS_DEFAULT="nor0=nor0"
-CONFIG_MTDPARTS_DEFAULT="mtdparts=nor0:256k(fsbl1),256k(fsbl2),1408k(uboot),64k(env1),64k(env2)"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_ISO_PARTITION is not set
 # CONFIG_SPL_PARTITION_UUIDS is not set

Thanks
Patrice

#27 lore raw
In reply to Patrick Delaunay
Quoted 137 lines · Patrick Delaunay

Add the MTD partitions subnode in U-Boot device tree for all stm32mp13 and stm32mp15 boards and no more rely on mtdids and mtdparts variables or CONFIG_SYS_MTDPARTS_RUNTIME.

When these variables are absent, the required OF fallback is performed in mtd_probe_devices() with commit dc339bf784f0 ("mtd: add support for parsing partitions defined in OF").

To allow dynamically configuration of MTD partitioning for Linux kernel, the MTD partitioning is only defined in U-Boot device tree and copied in Linux kernel device tree.

This serie also disable CMD_MTDPARTS as it is strongly encouraged to no more use this command.

Marek, I modify the dhcom/dhcor boardd in the last patch of the serie but if you prefer I can drop this patch.

For "stm32mp157c-ev1.dts" used by stm32mp15_trusted_defconfig

* nand0
- type: NAND flash
- block size: 0x40000 bytes
- min I/O: 0x1000 bytes
- OOB size: 224 bytes
- OOB available: 118 bytes
- ECC strength: 8 bits
- ECC step size: 512 bytes
- bitflip threshold: 6 bits
- 0x000000000000-0x000040000000 : "nand0"
- 0x000000000000-0x000000200000 : "fsbl"
- 0x000000200000-0x000000600000 : "fip1"
- 0x000000600000-0x000000a00000 : "fip2"
- 0x000000a00000-0x000040000000 : "UBI"
* nor0
- device: flash@0
- parent: spi@58003000
- driver: jedec_spi_nor
- path: /soc/spi@58003000/flash@0
- type: NOR flash
- block size: 0x10000 bytes
- min I/O: 0x1 bytes
- 0x000000000000-0x000004000000 : "nor0"
- 0x000000000000-0x000000040000 : "fsbl1"
- 0x000000040000-0x000000080000 : "fsbl2"
- 0x000000080000-0x000000480000 : "fip"
- 0x000000480000-0x000000500000 : "u-boot-env"
- 0x000000500000-0x000004000000 : "nor-user"

For "stm32mp157c-ev1-scmi.dts" the device tree file used by stm32mp15_defconfig, with TF-A BL2 and OP-TEE including a SCMI server for secure resources (when TZEN=1), the default STMicroelectronics configuration.

I align the NOR and NAND layout on EV1 boards with the STMicroelectronics recommendations used in OpenSTLinux V4.0:
with support of TF-A BL2 firmware update, required 2 "metadata" partition for redundancy and 2 FIPs for A/B update.

* nand0
- type: NAND flash
- block size: 0x40000 bytes
- min I/O: 0x1000 bytes
- OOB size: 224 bytes
- OOB available: 118 bytes
- ECC strength: 8 bits
- ECC step size: 512 bytes
- bitflip threshold: 6 bits
- 0x000000000000-0x000040000000 : "nand0"
- 0x000000000000-0x000000080000 : "fsbl1"
- 0x000000080000-0x000000100000 : "fsbl2"
- 0x000000100000-0x000000180000 : "metadata1"
- 0x000000180000-0x000000200000 : "metadata2"
- 0x000000200000-0x000000600000 : "fip-a1"
- 0x000000600000-0x000000a00000 : "fip-a2"
- 0x000000a00000-0x000000e00000 : "fip-b1"
- 0x000000e00000-0x000001200000 : "fip-b2"
- 0x000001200000-0x000040000000 : "UBI"
* nor0
- device: flash@0
- parent: spi@58003000
- driver: jedec_spi_nor
- path: /soc/spi@58003000/flash@0
- type: NOR flash
- block size: 0x10000 bytes
- min I/O: 0x1 bytes
- 0x000000000000-0x000004000000 : "nor0"
- 0x000000000000-0x000000040000 : "fsbl1"
- 0x000000040000-0x000000080000 : "fsbl2"
- 0x000000080000-0x0000000c0000 : "metadata1"
- 0x0000000c0000-0x000000100000 : "metadata2"
- 0x000000100000-0x000000500000 : "fip-a"
- 0x000000500000-0x000000900000 : "fip-b"
- 0x000000900000-0x000000980000 : "u-boot-env"
- 0x000000980000-0x000004000000 : "nor-user"

Patrice Chotard (5):
stm32mp: stm32prog: Remove usage of "mtdparts" function
arm: dts: stm32: Add partitions in flash0 and nand node for

    stm32mp15xx-ev1
  configs: stm32mp: Disable SYS_MTDPARTS_RUNTIME for stm32mp15 and
    stm32mp13

stm32mp: stm32prog: Remove tee_detected from stm32prog_data struct
configs: stm32mp1: disable CMD_MTDPARTS

Patrick Delaunay (7):
fdt_support: include dm/ofnode.h
fdt_support: add fdt_copy_fixed_partitions function
dfu: mtd: remove direct call of mtdparts_init function
arm: dts: stm32: Align stm32mp15xx-*-scmi-u-boot.dtsi file
board: stm32mp1: use fdt_copy_fixed_partitions
board: st: remove board_mtdparts_default
arm: dts: stm32: Add partitions in flash0 and nand node for

    stm32mp15xx-dhcom/dhcor
 arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi      |   1 +
 arch/arm/dts/stm32mp157c-dk2-scmi-u-boot.dtsi |   7 +
 arch/arm/dts/stm32mp157c-ev1-scmi-u-boot.dtsi | 125 +++++++++++++
 arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi      |  98 +++++++++-
 arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi    |  27 +++
 arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi    |  27 +++
 .../cmd_stm32prog/cmd_stm32prog.c             |   9 -
 .../mach-stm32mp/cmd_stm32prog/stm32prog.c    |  53 ++----
 .../mach-stm32mp/cmd_stm32prog/stm32prog.h    |   3 -
 .../arm/mach-stm32mp/include/mach/stm32prog.h |   4 -
 board/st/common/Kconfig                       |  66 -------
 board/st/common/Makefile                      |   1 -
 board/st/common/stm32mp_mtdparts.c            | 177 ------------------
 board/st/stm32mp1/stm32mp1.c                  |  16 +-
 common/fdt_support.c                          |  75 +++++++-
 configs/stm32mp13_defconfig                   |   3 -
 configs/stm32mp15_basic_defconfig             |   3 -
 configs/stm32mp15_defconfig                   |   7 +-
Quoted 9 lines
 configs/stm32mp15_dhcom_basic_defconfig       |   3 -
 configs/stm32mp15_dhcor_basic_defconfig       |   3 -
 configs/stm32mp15_trusted_defconfig           |   3 -
 drivers/dfu/Kconfig                           |   1 -
 drivers/dfu/dfu_mtd.c                         |  34 ++--
 include/fdt_support.h                         |   8 +
 24 files changed, 407 insertions(+), 347 deletions(-)
 delete mode 100644 board/st/common/stm32mp_mtdparts.c

For the whole series:

Applied to u-boot-stm/next

Thanks

Patrice