All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/11] stm32mp1: migrate MTD and DFU configuration in Kconfig
@ 2020-03-18  8:22 Patrick Delaunay
  2020-03-18  8:22 ` [PATCH 01/11] board: stm32mp1: move board_get_mtdparts in st common directory Patrick Delaunay
                   ` (11 more replies)
  0 siblings, 12 replies; 24+ messages in thread
From: Patrick Delaunay @ 2020-03-18  8:22 UTC (permalink / raw)
  To: u-boot


This serie migrate the dynamically build MTD (CONFIG_SYS_MTDPARTS_RUNTIME)
and the DFU configuration (CONFIG_SET_DFU_ALT_INFO)
previously based on ENV variables to CONFIG_.

These patches reduce the size of the environment and allow to tune
for each target with a specific defconfig file.

This serie also removes the TEE deconfig, replaced by a dynamic
detection based on op-tee driver probe.

This serie depends on previous CONFIG migration proposed in
http://patchwork.ozlabs.org/project/uboot/list/?series=160899
- configs: migrate CONFIG_SET_DFU_ALT_INFO to defconfigs
- configs: migrate CONFIG_SYS_MTDPARTS_RUNTIME to defconfigs



Patrick Delaunay (11):
  board: stm32mp1: move board_get_mtdparts in st common directory
  board: stm32mp1: move set_dfu_alt_info in st common directory
  stm32mp1: dynamically build DFU_ALT_INFO
  stm32mp1: move MTDPART configuration in Kconfig
  board: stm32mp1: reserve memory for OP-TEE in device tree
  stm32mp1: dynamically detect op-tee presence
  board: stm32mp1: use FDT address provided by TF-A at boot time
  configs: stm32mp1: remove optee defconfig
  board: stm32mp1: support boot from spi-nand
  board: stm32mp1: adapt MTD partition for BOOT from NOR or NAND
  doc: stm32mp1: update DFU support example

 arch/arm/dts/stm32mp157a-dk1.dts           |   5 +
 arch/arm/dts/stm32mp157c-ed1.dts           |   5 +
 arch/arm/mach-stm32mp/Kconfig              |  10 -
 arch/arm/mach-stm32mp/Makefile             |   1 +
 arch/arm/mach-stm32mp/boot_params.c        |  45 ++++
 arch/arm/mach-stm32mp/cpu.c                |   4 +
 arch/arm/mach-stm32mp/dram_init.c          |  18 ++
 arch/arm/mach-stm32mp/fdt.c                |  25 ++
 arch/arm/mach-stm32mp/include/mach/stm32.h |   3 +
 arch/arm/mach-stm32mp/spl.c                |   2 +
 board/dhelectronics/dh_stm32mp1/Kconfig    |   1 +
 board/dhelectronics/dh_stm32mp1/Makefile   |   3 +
 board/dhelectronics/dh_stm32mp1/board.c    | 143 +-----------
 board/st/common/Kconfig                    |  64 ++++++
 board/st/common/Makefile                   |   5 +
 board/st/common/stm32mp_dfu.c              | 225 ++++++++++++++++++
 board/st/common/stm32mp_mtdparts.c         | 157 +++++++++++++
 board/st/stm32mp1/MAINTAINERS              |   1 -
 board/st/stm32mp1/stm32mp1.c               | 253 +--------------------
 configs/stm32mp15_optee_defconfig          | 132 -----------
 configs/stm32mp15_trusted_defconfig        |   3 +
 doc/board/st/stm32mp1.rst                  | 147 +++++-------
 include/configs/stm32mp1.h                 |  64 +-----
 23 files changed, 634 insertions(+), 682 deletions(-)
 create mode 100644 arch/arm/mach-stm32mp/boot_params.c
 create mode 100644 board/st/common/stm32mp_dfu.c
 create mode 100644 board/st/common/stm32mp_mtdparts.c
 delete mode 100644 configs/stm32mp15_optee_defconfig

-- 
2.17.1

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

* [PATCH 01/11] board: stm32mp1: move board_get_mtdparts in st common directory
  2020-03-18  8:22 [PATCH 00/11] stm32mp1: migrate MTD and DFU configuration in Kconfig Patrick Delaunay
@ 2020-03-18  8:22 ` Patrick Delaunay
  2020-04-14  9:25   ` [Uboot-stm32] " Patrice CHOTARD
  2020-03-18  8:22 ` [PATCH 02/11] board: stm32mp1: move set_dfu_alt_info " Patrick Delaunay
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 24+ messages in thread
From: Patrick Delaunay @ 2020-03-18  8:22 UTC (permalink / raw)
  To: u-boot

Move the stm32mp1 common code board_get_mtdparts() in common directory,
this patch reduce the maintenance effort on this generic part (not board
dependent).

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

 board/dhelectronics/dh_stm32mp1/Makefile |   1 +
 board/dhelectronics/dh_stm32mp1/board.c  |  89 ------------------
 board/st/common/Makefile                 |   4 +
 board/st/common/stm32mp_mtdparts.c       | 115 +++++++++++++++++++++++
 board/st/stm32mp1/stm32mp1.c             | 102 --------------------
 5 files changed, 120 insertions(+), 191 deletions(-)
 create mode 100644 board/st/common/stm32mp_mtdparts.c

diff --git a/board/dhelectronics/dh_stm32mp1/Makefile b/board/dhelectronics/dh_stm32mp1/Makefile
index b42c4e4c04..c77a1e3a84 100644
--- a/board/dhelectronics/dh_stm32mp1/Makefile
+++ b/board/dhelectronics/dh_stm32mp1/Makefile
@@ -8,3 +8,4 @@ obj-y += ../../st/stm32mp1/spl.o
 endif
 
 obj-y += ../../st/stm32mp1/board.o board.o
+obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += ../../st/common/stm32mp_mtdparts.o
diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c
index b663696983..2baa36278c 100644
--- a/board/dhelectronics/dh_stm32mp1/board.c
+++ b/board/dhelectronics/dh_stm32mp1/board.c
@@ -519,95 +519,6 @@ enum env_location env_get_location(enum env_operation op, int prio)
 #endif
 }
 
-#ifdef CONFIG_SYS_MTDPARTS_RUNTIME
-
-#define MTDPARTS_LEN		256
-#define MTDIDS_LEN		128
-
-/**
- * The mtdparts_nand0 and mtdparts_nor0 variable tends to be long.
- * If we need to access it before the env is relocated, then we need
- * to use our own stack buffer. gd->env_buf will be too small.
- *
- * @param buf temporary buffer pointer MTDPARTS_LEN long
- * @return mtdparts variable string, NULL if not found
- */
-static const char *env_get_mtdparts(const char *str, char *buf)
-{
-	if (gd->flags & GD_FLG_ENV_READY)
-		return env_get(str);
-	if (env_get_f(str, buf, MTDPARTS_LEN) != -1)
-		return buf;
-
-	return NULL;
-}
-
-/**
- * update the variables "mtdids" and "mtdparts" with content of mtdparts_<dev>
- */
-static void board_get_mtdparts(const char *dev,
-			       char *mtdids,
-			       char *mtdparts)
-{
-	char env_name[32] = "mtdparts_";
-	char tmp_mtdparts[MTDPARTS_LEN];
-	const char *tmp;
-
-	/* name of env variable to read = mtdparts_<dev> */
-	strcat(env_name, dev);
-	tmp = env_get_mtdparts(env_name, tmp_mtdparts);
-	if (tmp) {
-		/* 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);
-		strncat(mtdparts, tmp, MTDPARTS_LEN);
-	}
-}
-
-void board_mtdparts_default(const char **mtdids, const char **mtdparts)
-{
-	struct udevice *dev;
-	static char parts[3 * MTDPARTS_LEN + 1];
-	static char ids[MTDIDS_LEN + 1];
-	static bool mtd_initialized;
-
-	if (mtd_initialized) {
-		*mtdids = ids;
-		*mtdparts = parts;
-		return;
-	}
-
-	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)) {
-		pr_debug("mtd device = %s\n", dev->name);
-	}
-
-	if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev))
-		board_get_mtdparts("nor0", ids, parts);
-
-	mtd_initialized = true;
-	*mtdids = ids;
-	*mtdparts = parts;
-	debug("%s:mtdids=%s & mtdparts=%s\n", __func__, ids, parts);
-}
-#endif
-
 #if defined(CONFIG_OF_BOARD_SETUP)
 int ft_board_setup(void *blob, bd_t *bd)
 {
diff --git a/board/st/common/Makefile b/board/st/common/Makefile
index 8553606b90..4bb8b49867 100644
--- a/board/st/common/Makefile
+++ b/board/st/common/Makefile
@@ -4,3 +4,7 @@
 #
 
 obj-$(CONFIG_CMD_STBOARD) += cmd_stboard.o
+
+ifeq ($(CONFIG_ARCH_STM32MP),y)
+obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += stm32mp_mtdparts.o
+endif
diff --git a/board/st/common/stm32mp_mtdparts.c b/board/st/common/stm32mp_mtdparts.c
new file mode 100644
index 0000000000..d77e075864
--- /dev/null
+++ b/board/st/common/stm32mp_mtdparts.c
@@ -0,0 +1,115 @@
+// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
+/*
+ * Copyright (C) 2020, STMicroelectronics - All Rights Reserved
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <env.h>
+#include <env_internal.h>
+#include <mtd.h>
+#include <mtd_node.h>
+
+#define MTDPARTS_LEN		256
+#define MTDIDS_LEN		128
+
+/*
+ * Get a global data pointer
+ */
+DECLARE_GLOBAL_DATA_PTR;
+
+/**
+ * The mtdparts_nand0 and mtdparts_nor0 variable tends to be long.
+ * If we need to access it before the env is relocated, then we need
+ * to use our own stack buffer. gd->env_buf will be too small.
+ *
+ * @param buf temporary buffer pointer MTDPARTS_LEN long
+ * @return mtdparts variable string, NULL if not found
+ */
+static const char *env_get_mtdparts(const char *str, char *buf)
+{
+	if (gd->flags & GD_FLG_ENV_READY)
+		return env_get(str);
+	if (env_get_f(str, buf, MTDPARTS_LEN) != -1)
+		return buf;
+
+	return NULL;
+}
+
+/**
+ * update the variables "mtdids" and "mtdparts" with content of mtdparts_<dev>
+ */
+static void board_get_mtdparts(const char *dev,
+			       char *mtdids,
+			       char *mtdparts)
+{
+	char env_name[32] = "mtdparts_";
+	char tmp_mtdparts[MTDPARTS_LEN];
+	const char *tmp;
+
+	/* name of env variable to read = mtdparts_<dev> */
+	strcat(env_name, dev);
+	tmp = env_get_mtdparts(env_name, tmp_mtdparts);
+	if (tmp) {
+		/* 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);
+		strncat(mtdparts, tmp, 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;
+
+	if (mtd_initialized) {
+		*mtdids = ids;
+		*mtdparts = parts;
+		return;
+	}
+
+	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)) {
+		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);
+
+	mtd_initialized = true;
+	*mtdids = ids;
+	*mtdparts = parts;
+	debug("%s:mtdids=%s & mtdparts=%s\n", __func__, ids, parts);
+}
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index b9d852efa4..bbeeb15d7e 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -828,108 +828,6 @@ const char *env_ext4_get_dev_part(void)
 }
 #endif
 
-#ifdef CONFIG_SYS_MTDPARTS_RUNTIME
-
-#define MTDPARTS_LEN		256
-#define MTDIDS_LEN		128
-
-/**
- * The mtdparts_nand0 and mtdparts_nor0 variable tends to be long.
- * If we need to access it before the env is relocated, then we need
- * to use our own stack buffer. gd->env_buf will be too small.
- *
- * @param buf temporary buffer pointer MTDPARTS_LEN long
- * @return mtdparts variable string, NULL if not found
- */
-static const char *env_get_mtdparts(const char *str, char *buf)
-{
-	if (gd->flags & GD_FLG_ENV_READY)
-		return env_get(str);
-	if (env_get_f(str, buf, MTDPARTS_LEN) != -1)
-		return buf;
-
-	return NULL;
-}
-
-/**
- * update the variables "mtdids" and "mtdparts" with content of mtdparts_<dev>
- */
-static void board_get_mtdparts(const char *dev,
-			       char *mtdids,
-			       char *mtdparts)
-{
-	char env_name[32] = "mtdparts_";
-	char tmp_mtdparts[MTDPARTS_LEN];
-	const char *tmp;
-
-	/* name of env variable to read = mtdparts_<dev> */
-	strcat(env_name, dev);
-	tmp = env_get_mtdparts(env_name, tmp_mtdparts);
-	if (tmp) {
-		/* 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);
-		strncat(mtdparts, tmp, 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;
-
-	if (mtd_initialized) {
-		*mtdids = ids;
-		*mtdparts = parts;
-		return;
-	}
-
-	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)) {
-		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);
-
-	mtd_initialized = true;
-	*mtdids = ids;
-	*mtdparts = parts;
-	debug("%s:mtdids=%s & mtdparts=%s\n", __func__, ids, parts);
-}
-#endif
-
 #if defined(CONFIG_OF_BOARD_SETUP)
 int ft_board_setup(void *blob, bd_t *bd)
 {
-- 
2.17.1

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

* [PATCH 02/11] board: stm32mp1: move set_dfu_alt_info in st common directory
  2020-03-18  8:22 [PATCH 00/11] stm32mp1: migrate MTD and DFU configuration in Kconfig Patrick Delaunay
  2020-03-18  8:22 ` [PATCH 01/11] board: stm32mp1: move board_get_mtdparts in st common directory Patrick Delaunay
@ 2020-03-18  8:22 ` Patrick Delaunay
  2020-04-14  9:25   ` [Uboot-stm32] " Patrice CHOTARD
  2020-03-18  8:22 ` [PATCH 03/11] stm32mp1: dynamically build DFU_ALT_INFO Patrick Delaunay
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 24+ messages in thread
From: Patrick Delaunay @ 2020-03-18  8:22 UTC (permalink / raw)
  To: u-boot

Move the stm32mp1 common code set_dfu_alt_info() in common directory,
this patch reduce the maintenance effort on this generic part (not board
dependent).

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

 board/dhelectronics/dh_stm32mp1/Makefile |   2 +
 board/dhelectronics/dh_stm32mp1/board.c  |  50 --------
 board/st/common/Makefile                 |   1 +
 board/st/common/stm32mp_dfu.c            | 151 +++++++++++++++++++++++
 board/st/stm32mp1/stm32mp1.c             | 145 ----------------------
 5 files changed, 154 insertions(+), 195 deletions(-)
 create mode 100644 board/st/common/stm32mp_dfu.c

diff --git a/board/dhelectronics/dh_stm32mp1/Makefile b/board/dhelectronics/dh_stm32mp1/Makefile
index c77a1e3a84..e8f218da08 100644
--- a/board/dhelectronics/dh_stm32mp1/Makefile
+++ b/board/dhelectronics/dh_stm32mp1/Makefile
@@ -8,4 +8,6 @@ obj-y += ../../st/stm32mp1/spl.o
 endif
 
 obj-y += ../../st/stm32mp1/board.o board.o
+
 obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += ../../st/common/stm32mp_mtdparts.o
+obj-$(CONFIG_SET_DFU_ALT_INFO) += ../../st/common/stm32mp_dfu.o
diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c
index 2baa36278c..bd6540a2aa 100644
--- a/board/dhelectronics/dh_stm32mp1/board.c
+++ b/board/dhelectronics/dh_stm32mp1/board.c
@@ -526,56 +526,6 @@ 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));
-
-	/* probe all MTD devices */
-	mtd_probe_devices();
-
-	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);
-
-	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/board/st/common/Makefile b/board/st/common/Makefile
index 4bb8b49867..aa030bacd8 100644
--- a/board/st/common/Makefile
+++ b/board/st/common/Makefile
@@ -7,4 +7,5 @@ obj-$(CONFIG_CMD_STBOARD) += cmd_stboard.o
 
 ifeq ($(CONFIG_ARCH_STM32MP),y)
 obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += stm32mp_mtdparts.o
+obj-$(CONFIG_SET_DFU_ALT_INFO) += stm32mp_dfu.o
 endif
diff --git a/board/st/common/stm32mp_dfu.c b/board/st/common/stm32mp_dfu.c
new file mode 100644
index 0000000000..99ea21ce15
--- /dev/null
+++ b/board/st/common/stm32mp_dfu.c
@@ -0,0 +1,151 @@
+// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
+/*
+ * Copyright (C) 2020, STMicroelectronics - All Rights Reserved
+ */
+
+#include <common.h>
+#include <dfu.h>
+#include <env.h>
+#include <memalign.h>
+#include <misc.h>
+#include <mtd.h>
+#include <mtd_node.h>
+
+#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;
+	struct mtd_info *mtd;
+
+	ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN);
+
+	if (env_get("dfu_alt_info"))
+		return;
+
+	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))
+		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);
+
+	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);
+
+#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>
+
+static 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;
+}
+
+static 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
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index bbeeb15d7e..2ab3b5cc9a 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -7,7 +7,6 @@
 #include <bootm.h>
 #include <clk.h>
 #include <config.h>
-#include <dfu.h>
 #include <dm.h>
 #include <env.h>
 #include <env_internal.h>
@@ -18,9 +17,7 @@
 #include <init.h>
 #include <led.h>
 #include <malloc.h>
-#include <memalign.h>
 #include <misc.h>
-#include <mtd.h>
 #include <mtd_node.h>
 #include <netdev.h>
 #include <phy.h>
@@ -843,148 +840,6 @@ 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;
-	struct mtd_info *mtd;
-
-	ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN);
-
-	if (env_get("dfu_alt_info"))
-		return;
-
-	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))
-		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);
-
-	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);
-
-#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>
-
-static 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;
-}
-
-static 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)
 {
 	int ret, id = 0; /* Copro id fixed to 0 as only one coproc on mp1 */
-- 
2.17.1

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

* [PATCH 03/11] stm32mp1: dynamically build DFU_ALT_INFO
  2020-03-18  8:22 [PATCH 00/11] stm32mp1: migrate MTD and DFU configuration in Kconfig Patrick Delaunay
  2020-03-18  8:22 ` [PATCH 01/11] board: stm32mp1: move board_get_mtdparts in st common directory Patrick Delaunay
  2020-03-18  8:22 ` [PATCH 02/11] board: stm32mp1: move set_dfu_alt_info " Patrick Delaunay
@ 2020-03-18  8:22 ` Patrick Delaunay
  2020-04-14  9:26   ` [Uboot-stm32] " Patrice CHOTARD
  2020-03-18  8:22 ` [PATCH 04/11] stm32mp1: move MTDPART configuration in Kconfig Patrick Delaunay
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 24+ messages in thread
From: Patrick Delaunay @ 2020-03-18  8:22 UTC (permalink / raw)
  To: u-boot

This patch reduces the stm32mp1 environment size and
builds dynamically the DFU board configuration with gpt
and mtd partitions and information from defconfig
(CONFIG_DFU_ALT_RAM0).

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

 board/dhelectronics/dh_stm32mp1/Kconfig |   1 +
 board/st/common/Kconfig                 |   7 ++
 board/st/common/stm32mp_dfu.c           | 130 +++++++++++++++++++-----
 include/configs/stm32mp1.h              |  33 ------
 4 files changed, 110 insertions(+), 61 deletions(-)

diff --git a/board/dhelectronics/dh_stm32mp1/Kconfig b/board/dhelectronics/dh_stm32mp1/Kconfig
index 8eab986640..69cc48f120 100644
--- a/board/dhelectronics/dh_stm32mp1/Kconfig
+++ b/board/dhelectronics/dh_stm32mp1/Kconfig
@@ -18,4 +18,5 @@ config ENV_OFFSET
 config ENV_OFFSET_REDUND
 	default 0x1F0000 if ENV_IS_IN_SPI_FLASH
 
+source "board/st/common/Kconfig"
 endif
diff --git a/board/st/common/Kconfig b/board/st/common/Kconfig
index af01ca4891..08df845982 100644
--- a/board/st/common/Kconfig
+++ b/board/st/common/Kconfig
@@ -5,3 +5,10 @@ config CMD_STBOARD
 	help
 	  This compile the stboard command to
 	  read and write the board in the OTP.
+
+config DFU_ALT_RAM0
+	string "dfu for ram0"
+	default "uImage ram 0xc2000000 0x2000000;devicetree.dtb ram 0xc4000000 0x100000;uramdisk.image.gz ram 0xc4400000 0x10000000"
+	depends on ARCH_STM32MP && SET_DFU_ALT_INFO
+	help
+	  This defines the partitions of ram used to build dfu dynamically.
diff --git a/board/st/common/stm32mp_dfu.c b/board/st/common/stm32mp_dfu.c
index 99ea21ce15..e129f8c8b5 100644
--- a/board/st/common/stm32mp_dfu.c
+++ b/board/st/common/stm32mp_dfu.c
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <blk.h>
 #include <dfu.h>
 #include <env.h>
 #include <memalign.h>
@@ -13,20 +14,86 @@
 
 #define DFU_ALT_BUF_LEN SZ_1K
 
-static void board_get_alt_info(const char *dev, char *buff)
+static void board_get_alt_info_mmc(struct udevice *dev, char *buf)
 {
-	char var_name[32] = "dfu_alt_info_";
-	int ret;
+	disk_partition_t info;
+	int p, len, devnum;
+	bool first = true;
+	const char *name;
+	struct mmc *mmc;
+	struct blk_desc *desc;
+
+	mmc = mmc_get_mmc_dev(dev);
+	if (!mmc)
+		return;
+
+	if (mmc_init(mmc))
+		return;
+
+	desc = mmc_get_blk_desc(mmc);
+	if (!desc)
+		return;
+
+	name = blk_get_if_type_name(desc->if_type);
+	devnum = desc->devnum;
+	len = strlen(buf);
+
+	if (buf[0] != '\0')
+		len += snprintf(buf + len,
+				DFU_ALT_BUF_LEN - len, "&");
+	len += snprintf(buf + len, DFU_ALT_BUF_LEN - len,
+			 "%s %d=", name, devnum);
+
+	if (IS_MMC(mmc) && mmc->capacity_boot) {
+		len += snprintf(buf + len, DFU_ALT_BUF_LEN - len,
+				"%s%d_boot1 raw 0x0 0x%llx mmcpart 1;",
+				name, devnum, mmc->capacity_boot);
+		len += snprintf(buf + len, DFU_ALT_BUF_LEN - len,
+				"%s%d_boot2 raw 0x0 0x%llx mmcpart 2",
+				name, devnum, mmc->capacity_boot);
+		first = false;
+	}
 
-	ALLOC_CACHE_ALIGN_BUFFER(char, tmp_alt, DFU_ALT_BUF_LEN);
+	for (p = 1; p < MAX_SEARCH_PARTITIONS; p++) {
+		if (part_get_info(desc, p, &info))
+			continue;
+		if (!first)
+			len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, ";");
+		first = false;
+		len += snprintf(buf + len, DFU_ALT_BUF_LEN - len,
+				"%s%d_%s part %d %d",
+				name, devnum, info.name, devnum, p);
+	}
+}
 
-	/* 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);
+static void board_get_alt_info_mtd(struct mtd_info *mtd, char *buf)
+{
+	struct mtd_info *part;
+	bool first = true;
+	const char *name;
+	int len, partnum = 0;
+
+	name = mtd->name;
+	len = strlen(buf);
+
+	if (buf[0] != '\0')
+		len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, "&");
+	len += snprintf(buf + len, DFU_ALT_BUF_LEN - len,
+			"mtd %s=", name);
+
+	len += snprintf(buf + len, DFU_ALT_BUF_LEN - len,
+			"%s raw 0x0 0x%llx ",
+			name, mtd->size);
+
+	list_for_each_entry(part, &mtd->partitions, node) {
+		partnum++;
+		if (!first)
+			len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, ";");
+		first = false;
+
+		len += snprintf(buf + len, DFU_ALT_BUF_LEN - len,
+				"%s_%s part %d",
+				name, part->name, partnum);
 	}
 }
 
@@ -42,27 +109,34 @@ 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);
+	snprintf(buf, DFU_ALT_BUF_LEN,
+		 "ram 0=%s", CONFIG_DFU_ALT_RAM0);
 
 	if (!uclass_get_device(UCLASS_MMC, 0, &dev))
-		board_get_alt_info("mmc0", buf);
+		board_get_alt_info_mmc(dev, 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);
-
-	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);
+		board_get_alt_info_mmc(dev, buf);
+
+	if (CONFIG_IS_ENABLED(MTD)) {
+		/* probe all MTD devices */
+		mtd_probe_devices();
+
+		/* probe SPI flash device on a bus */
+		if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev)) {
+			mtd = get_mtd_device_nm("nor0");
+			if (!IS_ERR_OR_NULL(mtd))
+				board_get_alt_info_mtd(mtd, buf);
+		}
+
+		mtd = get_mtd_device_nm("nand0");
+		if (!IS_ERR_OR_NULL(mtd))
+			board_get_alt_info_mtd(mtd, buf);
+
+		mtd = get_mtd_device_nm("spi-nand0");
+		if (!IS_ERR_OR_NULL(mtd))
+			board_get_alt_info_mtd(mtd, buf);
+	}
 
 #ifdef CONFIG_DFU_VIRT
 	strncat(buf, "&virt 0=OTP", DFU_ALT_BUF_LEN);
diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h
index f451edad36..a9631d2a92 100644
--- a/include/configs/stm32mp1.h
+++ b/include/configs/stm32mp1.h
@@ -170,37 +170,6 @@
 #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_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;" \
-		"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
@@ -220,8 +189,6 @@
 		" 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] 24+ messages in thread

* [PATCH 04/11] stm32mp1: move MTDPART configuration in Kconfig
  2020-03-18  8:22 [PATCH 00/11] stm32mp1: migrate MTD and DFU configuration in Kconfig Patrick Delaunay
                   ` (2 preceding siblings ...)
  2020-03-18  8:22 ` [PATCH 03/11] stm32mp1: dynamically build DFU_ALT_INFO Patrick Delaunay
@ 2020-03-18  8:22 ` Patrick Delaunay
  2020-04-14  9:28   ` [Uboot-stm32] " Patrice CHOTARD
  2020-03-18  8:22 ` [PATCH 05/11] board: stm32mp1: reserve memory for OP-TEE in device tree Patrick Delaunay
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 24+ messages in thread
From: Patrick Delaunay @ 2020-03-18  8:22 UTC (permalink / raw)
  To: u-boot

This patch reduces the stm32mp1 environment size and builds
dynamically the MTD partitions with information from defconfig
(CONFIG_MTDPARTS_...).

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

 board/st/common/Kconfig            | 57 ++++++++++++++++++
 board/st/common/stm32mp_mtdparts.c | 93 +++++++++++++++---------------
 include/configs/stm32mp1.h         | 22 -------
 3 files changed, 104 insertions(+), 68 deletions(-)

diff --git a/board/st/common/Kconfig b/board/st/common/Kconfig
index 08df845982..015ba40939 100644
--- a/board/st/common/Kconfig
+++ b/board/st/common/Kconfig
@@ -6,6 +6,63 @@ 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)"
+	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.
+
+config MTDPARTS_NAND0_TEE
+	string "mtd tee partitions for nand0"
+	default "512k(teeh),512k(teed),512k(teex)"
+	depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP
+	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)"
+	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),256k(teed),256k(teex)"
+	depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP
+	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)"
+	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.
+
+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
+	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"
diff --git a/board/st/common/stm32mp_mtdparts.c b/board/st/common/stm32mp_mtdparts.c
index d77e075864..d4c0a7db9f 100644
--- a/board/st/common/stm32mp_mtdparts.c
+++ b/board/st/common/stm32mp_mtdparts.c
@@ -19,54 +19,42 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 /**
- * The mtdparts_nand0 and mtdparts_nor0 variable tends to be long.
- * If we need to access it before the env is relocated, then we need
- * to use our own stack buffer. gd->env_buf will be too small.
- *
- * @param buf temporary buffer pointer MTDPARTS_LEN long
- * @return mtdparts variable string, NULL if not found
- */
-static const char *env_get_mtdparts(const char *str, char *buf)
-{
-	if (gd->flags & GD_FLG_ENV_READY)
-		return env_get(str);
-	if (env_get_f(str, buf, MTDPARTS_LEN) != -1)
-		return buf;
-
-	return NULL;
-}
-
-/**
- * update the variables "mtdids" and "mtdparts" with content of mtdparts_<dev>
+ * update the variables "mtdids" and "mtdparts" with boot, tee and user strings
  */
 static void board_get_mtdparts(const char *dev,
 			       char *mtdids,
-			       char *mtdparts)
+			       char *mtdparts,
+			       const char *boot,
+			       const char *tee,
+			       const char *user)
 {
-	char env_name[32] = "mtdparts_";
-	char tmp_mtdparts[MTDPARTS_LEN];
-	const char *tmp;
-
-	/* name of env variable to read = mtdparts_<dev> */
-	strcat(env_name, dev);
-	tmp = env_get_mtdparts(env_name, tmp_mtdparts);
-	if (tmp) {
-		/* 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);
-		strncat(mtdparts, tmp, MTDPARTS_LEN);
+	/* 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);
+	}
+
+	if (CONFIG_IS_ENABLED(STM32MP1_OPTEE) && tee) {
+		strncat(mtdparts, tee, MTDPARTS_LEN);
+		strncat(mtdparts, ",", MTDPARTS_LEN);
 	}
+
+	strncat(mtdparts, user, MTDPARTS_LEN);
 }
 
 void board_mtdparts_default(const char **mtdids, const char **mtdparts)
@@ -76,6 +64,7 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
 	static char parts[3 * MTDPARTS_LEN + 1];
 	static char ids[MTDIDS_LEN + 1];
 	static bool mtd_initialized;
+	bool tee = false;
 
 	if (mtd_initialized) {
 		*mtdids = ids;
@@ -83,6 +72,9 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
 		return;
 	}
 
+	if (CONFIG_IS_ENABLED(STM32MP1_OPTEE))
+		tee = true;
+
 	memset(parts, 0, sizeof(parts));
 	memset(ids, 0, sizeof(ids));
 
@@ -95,18 +87,27 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
 
 	mtd = get_mtd_device_nm("nand0");
 	if (!IS_ERR_OR_NULL(mtd)) {
-		board_get_mtdparts("nand0", ids, parts);
+		board_get_mtdparts("nand0", ids, parts,
+				   CONFIG_MTDPARTS_NAND0_BOOT,
+				   tee ? CONFIG_MTDPARTS_NAND0_TEE : NULL,
+				   "-(UBI)");
 		put_mtd_device(mtd);
 	}
 
 	mtd = get_mtd_device_nm("spi-nand0");
 	if (!IS_ERR_OR_NULL(mtd)) {
-		board_get_mtdparts("spi-nand0", ids, parts);
+		board_get_mtdparts("spi-nand0", ids, parts,
+				   CONFIG_MTDPARTS_SPINAND0_BOOT,
+				   tee ? CONFIG_MTDPARTS_SPINAND0_TEE : NULL,
+				   "-(UBI)");
 		put_mtd_device(mtd);
 	}
 
 	if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev))
-		board_get_mtdparts("nor0", ids, parts);
+		board_get_mtdparts("nor0", ids, parts,
+				   CONFIG_MTDPARTS_NOR0_BOOT,
+				   tee ? CONFIG_MTDPARTS_NOR0_TEE : NULL,
+				   "-(nor_user)");
 
 	mtd_initialized = true;
 	*mtdids = ids;
diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h
index a9631d2a92..a80741f6a2 100644
--- a/include/configs/stm32mp1.h
+++ b/include/configs/stm32mp1.h
@@ -149,27 +149,6 @@
 
 #include <config_distro_bootcmd.h>
 
-#ifdef CONFIG_STM32MP1_OPTEE
-/* 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_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_spi-nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),-(UBI)\0"
-
-#endif /* CONFIG_STM32MP1_OPTEE */
-
-#ifndef CONFIG_SYS_MTDPARTS_RUNTIME
-#undef STM32MP_MTDPARTS
-#define STM32MP_MTDPARTS
-#endif
-
 /*
  * memory layout for 32M uncompressed/compressed kernel,
  * 1M fdt, 1M script, 1M pxe and 1M for splashimage
@@ -188,7 +167,6 @@
 	"env_check=if test $env_default -eq 1;"\
 		" then env set env_default 0;env save;fi\0" \
 	STM32MP_BOOTCMD \
-	STM32MP_MTDPARTS \
 	BOOTENV \
 	"boot_net_usb_start=true\0"
 
-- 
2.17.1

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

* [PATCH 05/11] board: stm32mp1: reserve memory for OP-TEE in device tree
  2020-03-18  8:22 [PATCH 00/11] stm32mp1: migrate MTD and DFU configuration in Kconfig Patrick Delaunay
                   ` (3 preceding siblings ...)
  2020-03-18  8:22 ` [PATCH 04/11] stm32mp1: move MTDPART configuration in Kconfig Patrick Delaunay
@ 2020-03-18  8:22 ` Patrick Delaunay
  2020-04-14  9:31   ` Patrice CHOTARD
  2020-03-18  8:22 ` [PATCH 06/11] stm32mp1: dynamically detect op-tee presence Patrick Delaunay
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 24+ messages in thread
From: Patrick Delaunay @ 2020-03-18  8:22 UTC (permalink / raw)
  To: u-boot

Add reserve memory for OP-TEE in U-Boot and in kernel device tree:
- no more reduce the DDR size in "memory" node:
  CONFIG_SYS_MEM_TOP_HIDE is no more used
- U-Boot device-tree defines the needed "reserved-memory" for OP-TEE
  and U-Boot should not use this reserved memory: board_get_usable_ram_top
  use lmb lib to found the first free region, the not reserved
  memory, enough to relocate U-Boot: the needed size of U-Boot
  is estimated with gd->mon_len + CONFIG_SYS_MALLOC_LEN.
- the optee node ("optee at ...": firmware with compatible "linaro,optee-tz")
  and the associated "reserved-memory" are deactivated in kernel device
  tree when OP-TEE is not detected by U-Boot to prevent kernel issue
  (memory is reserved but not used, optee driver probe failed).

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---
This patch depends on "ARM: bootm: take into account gd->ram_top"
http://patchwork.ozlabs.org/project/uboot/list/?series=158413

 arch/arm/dts/stm32mp157a-dk1.dts  |  5 +++++
 arch/arm/dts/stm32mp157c-ed1.dts  |  5 +++++
 arch/arm/mach-stm32mp/dram_init.c | 18 ++++++++++++++++++
 arch/arm/mach-stm32mp/fdt.c       | 23 +++++++++++++++++++++++
 include/configs/stm32mp1.h        |  4 ----
 5 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/arch/arm/dts/stm32mp157a-dk1.dts b/arch/arm/dts/stm32mp157a-dk1.dts
index 624bf6954b..70e7aa2fd7 100644
--- a/arch/arm/dts/stm32mp157a-dk1.dts
+++ b/arch/arm/dts/stm32mp157a-dk1.dts
@@ -74,6 +74,11 @@
 			reg = <0xd4000000 0x4000000>;
 			no-map;
 		};
+
+		optee at de000000 {
+			reg = <0xde000000 0x02000000>;
+			no-map;
+		};
 	};
 
 	led {
diff --git a/arch/arm/dts/stm32mp157c-ed1.dts b/arch/arm/dts/stm32mp157c-ed1.dts
index ae4da39ce8..27a0d05d82 100644
--- a/arch/arm/dts/stm32mp157c-ed1.dts
+++ b/arch/arm/dts/stm32mp157c-ed1.dts
@@ -68,6 +68,11 @@
 			reg = <0xe8000000 0x8000000>;
 			no-map;
 		};
+
+		optee at fe000000 {
+			reg = <0xfe000000 0x02000000>;
+			no-map;
+		};
 	};
 
 	aliases {
diff --git a/arch/arm/mach-stm32mp/dram_init.c b/arch/arm/mach-stm32mp/dram_init.c
index 7688b3e315..3233415eff 100644
--- a/arch/arm/mach-stm32mp/dram_init.c
+++ b/arch/arm/mach-stm32mp/dram_init.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <lmb.h>
 #include <ram.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -31,3 +32,20 @@ int dram_init(void)
 
 	return 0;
 }
+
+ulong board_get_usable_ram_top(ulong total_size)
+{
+	phys_addr_t reg;
+	struct lmb lmb;
+
+	/* found enough not-reserved memory to relocated U-Boot */
+	lmb_init(&lmb);
+	lmb_add(&lmb, gd->ram_base, gd->ram_size);
+	boot_fdt_add_mem_rsv_regions(&lmb, (void *)gd->fdt_blob);
+	reg = lmb_alloc(&lmb, CONFIG_SYS_MALLOC_LEN + total_size, SZ_4K);
+
+	if (reg)
+		return ALIGN(reg + CONFIG_SYS_MALLOC_LEN + total_size, SZ_4K);
+
+	return gd->ram_top;
+}
diff --git a/arch/arm/mach-stm32mp/fdt.c b/arch/arm/mach-stm32mp/fdt.c
index 3ee7d6a833..ae82270e42 100644
--- a/arch/arm/mach-stm32mp/fdt.c
+++ b/arch/arm/mach-stm32mp/fdt.c
@@ -218,6 +218,26 @@ static void stm32_fdt_disable(void *fdt, int offset, u32 addr,
 		       string, addr, name);
 }
 
+static void stm32_fdt_disable_optee(void *blob)
+{
+	int off, node;
+
+	off = fdt_node_offset_by_compatible(blob, -1, "linaro,optee-tz");
+	if (off >= 0 && fdtdec_get_is_enabled(blob, off))
+		fdt_status_disabled(blob, off);
+
+	/* Disabled "optee at ..." reserved-memory node */
+	off = fdt_path_offset(blob, "/reserved-memory/");
+	if (off < 0)
+		return;
+	for (node = fdt_first_subnode(blob, off);
+	     node >= 0;
+	     node = fdt_next_subnode(blob, node)) {
+		if (!strncmp(fdt_get_name(blob, node, NULL), "optee@", 6))
+			fdt_status_disabled(blob, node);
+	}
+}
+
 /*
  * This function is called right before the kernel is booted. "blob" is the
  * device tree that will be passed to the kernel.
@@ -302,5 +322,8 @@ int ft_system_setup(void *blob, bd_t *bd)
 				       "st,package", pkg, false);
 	}
 
+	if (!CONFIG_IS_ENABLED(STM32MP1_OPTEE))
+		stm32_fdt_disable_optee(blob);
+
 	return ret;
 }
diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h
index a80741f6a2..c5b09f1a2a 100644
--- a/include/configs/stm32mp1.h
+++ b/include/configs/stm32mp1.h
@@ -23,10 +23,6 @@
 #define CONFIG_SYS_SDRAM_BASE			STM32_DDR_BASE
 #define CONFIG_SYS_INIT_SP_ADDR			CONFIG_SYS_TEXT_BASE
 
-#ifdef CONFIG_STM32MP1_OPTEE
-#define CONFIG_SYS_MEM_TOP_HIDE			SZ_32M
-#endif /* CONFIG_STM32MP1_OPTEE */
-
 /*
  * Console I/O buffer size
  */
-- 
2.17.1

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

* [PATCH 06/11] stm32mp1: dynamically detect op-tee presence
  2020-03-18  8:22 [PATCH 00/11] stm32mp1: migrate MTD and DFU configuration in Kconfig Patrick Delaunay
                   ` (4 preceding siblings ...)
  2020-03-18  8:22 ` [PATCH 05/11] board: stm32mp1: reserve memory for OP-TEE in device tree Patrick Delaunay
@ 2020-03-18  8:22 ` Patrick Delaunay
  2020-04-14  9:31   ` Patrice CHOTARD
  2020-03-18  8:22 ` [PATCH 07/11] board: stm32mp1: use FDT address provided by TF-A at boot time Patrick Delaunay
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 24+ messages in thread
From: Patrick Delaunay @ 2020-03-18  8:22 UTC (permalink / raw)
  To: u-boot

Activate OP-TEE driver for trusted and optee defconfig.

This driver allows detection of TEE presence for boot from flash;
CONFIG_STM32MP1_OPTEE is also removed.

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

 arch/arm/mach-stm32mp/Kconfig           | 10 ----------
 arch/arm/mach-stm32mp/fdt.c             |  4 +++-
 board/dhelectronics/dh_stm32mp1/board.c |  4 +---
 board/st/common/stm32mp_mtdparts.c      |  6 ++++--
 board/st/stm32mp1/stm32mp1.c            |  4 +---
 configs/stm32mp15_optee_defconfig       |  4 +++-
 configs/stm32mp15_trusted_defconfig     |  3 +++
 7 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/arch/arm/mach-stm32mp/Kconfig b/arch/arm/mach-stm32mp/Kconfig
index 96153693a7..1a5545b98d 100644
--- a/arch/arm/mach-stm32mp/Kconfig
+++ b/arch/arm/mach-stm32mp/Kconfig
@@ -93,16 +93,6 @@ config STM32MP1_TRUSTED
 		BootRom => TF-A.stm32 (clock & DDR) => U-Boot.stm32
 		TF-A monitor provides proprietary SMC to manage secure devices
 
-config STM32MP1_OPTEE
-	bool "Support trusted boot with TF-A and OP-TEE"
-	depends on STM32MP1_TRUSTED
-	default n
-	help
-		Say Y here to enable boot with TF-A and OP-TEE
-		Trusted boot chain is :
-		BootRom => TF-A.stm32 (clock & DDR) => OP-TEE => U-Boot.stm32
-		OP-TEE monitor provides ST SMC to access to secure resources
-
 config SYS_TEXT_BASE
 	default 0xC0100000
 
diff --git a/arch/arm/mach-stm32mp/fdt.c b/arch/arm/mach-stm32mp/fdt.c
index ae82270e42..21b5f09728 100644
--- a/arch/arm/mach-stm32mp/fdt.c
+++ b/arch/arm/mach-stm32mp/fdt.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <fdt_support.h>
+#include <tee.h>
 #include <asm/arch/sys_proto.h>
 #include <dt-bindings/pinctrl/stm32-pinfunc.h>
 #include <linux/io.h>
@@ -322,7 +323,8 @@ int ft_system_setup(void *blob, bd_t *bd)
 				       "st,package", pkg, false);
 	}
 
-	if (!CONFIG_IS_ENABLED(STM32MP1_OPTEE))
+	if (!CONFIG_IS_ENABLED(OPTEE) ||
+	    !tee_find_device(NULL, NULL, NULL, NULL))
 		stm32_fdt_disable_optee(blob);
 
 	return ret;
diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c
index bd6540a2aa..ea51b92282 100644
--- a/board/dhelectronics/dh_stm32mp1/board.c
+++ b/board/dhelectronics/dh_stm32mp1/board.c
@@ -117,9 +117,7 @@ int checkboard(void)
 	const char *fdt_compat;
 	int fdt_compat_len;
 
-	if (IS_ENABLED(CONFIG_STM32MP1_OPTEE))
-		mode = "trusted with OP-TEE";
-	else if (IS_ENABLED(CONFIG_STM32MP1_TRUSTED))
+	if (IS_ENABLED(CONFIG_STM32MP1_TRUSTED))
 		mode = "trusted";
 	else
 		mode = "basic";
diff --git a/board/st/common/stm32mp_mtdparts.c b/board/st/common/stm32mp_mtdparts.c
index d4c0a7db9f..2b6413be16 100644
--- a/board/st/common/stm32mp_mtdparts.c
+++ b/board/st/common/stm32mp_mtdparts.c
@@ -9,6 +9,7 @@
 #include <env_internal.h>
 #include <mtd.h>
 #include <mtd_node.h>
+#include <tee.h>
 
 #define MTDPARTS_LEN		256
 #define MTDIDS_LEN		128
@@ -49,7 +50,7 @@ static void board_get_mtdparts(const char *dev,
 		strncat(mtdparts, ",", MTDPARTS_LEN);
 	}
 
-	if (CONFIG_IS_ENABLED(STM32MP1_OPTEE) && tee) {
+	if (tee) {
 		strncat(mtdparts, tee, MTDPARTS_LEN);
 		strncat(mtdparts, ",", MTDPARTS_LEN);
 	}
@@ -72,7 +73,8 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
 		return;
 	}
 
-	if (CONFIG_IS_ENABLED(STM32MP1_OPTEE))
+	if (CONFIG_IS_ENABLED(OPTEE) &&
+	    tee_find_device(NULL, NULL, NULL, NULL))
 		tee = true;
 
 	memset(parts, 0, sizeof(parts));
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 2ab3b5cc9a..14c56a0f24 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -87,9 +87,7 @@ int checkboard(void)
 	const char *fdt_compat;
 	int fdt_compat_len;
 
-	if (IS_ENABLED(CONFIG_STM32MP1_OPTEE))
-		mode = "trusted with OP-TEE";
-	else if (IS_ENABLED(CONFIG_STM32MP1_TRUSTED))
+	if (CONFIG_IS_ENABLED(STM32MP1_TRUSTED))
 		mode = "trusted";
 	else
 		mode = "basic";
diff --git a/configs/stm32mp15_optee_defconfig b/configs/stm32mp15_optee_defconfig
index 317cd55862..f0d524d344 100644
--- a/configs/stm32mp15_optee_defconfig
+++ b/configs/stm32mp15_optee_defconfig
@@ -4,7 +4,6 @@ CONFIG_SYS_MALLOC_F_LEN=0x3000
 CONFIG_ENV_SECT_SIZE=0x40000
 CONFIG_ENV_OFFSET=0x280000
 CONFIG_TARGET_ST_STM32MP15x=y
-CONFIG_STM32MP1_OPTEE=y
 CONFIG_ENV_OFFSET_REDUND=0x2C0000
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT=y
@@ -111,6 +110,9 @@ CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_STM32_QSPI=y
 CONFIG_STM32_SPI=y
+CONFIG_TEE=y
+CONFIG_OPTEE=y
+# CONFIG_OPTEE_TA_AVB is not set
 CONFIG_USB=y
 CONFIG_DM_USB=y
 CONFIG_DM_USB_GADGET=y
diff --git a/configs/stm32mp15_trusted_defconfig b/configs/stm32mp15_trusted_defconfig
index 73cbe6c7d6..f0d524d344 100644
--- a/configs/stm32mp15_trusted_defconfig
+++ b/configs/stm32mp15_trusted_defconfig
@@ -110,6 +110,9 @@ CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_STM32_QSPI=y
 CONFIG_STM32_SPI=y
+CONFIG_TEE=y
+CONFIG_OPTEE=y
+# CONFIG_OPTEE_TA_AVB is not set
 CONFIG_USB=y
 CONFIG_DM_USB=y
 CONFIG_DM_USB_GADGET=y
-- 
2.17.1

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

* [PATCH 07/11] board: stm32mp1: use FDT address provided by TF-A at boot time
  2020-03-18  8:22 [PATCH 00/11] stm32mp1: migrate MTD and DFU configuration in Kconfig Patrick Delaunay
                   ` (5 preceding siblings ...)
  2020-03-18  8:22 ` [PATCH 06/11] stm32mp1: dynamically detect op-tee presence Patrick Delaunay
@ 2020-03-18  8:22 ` Patrick Delaunay
  2020-04-14  9:32   ` Patrice CHOTARD
  2020-03-18  8:22 ` [PATCH 08/11] configs: stm32mp1: remove optee defconfig Patrick Delaunay
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 24+ messages in thread
From: Patrick Delaunay @ 2020-03-18  8:22 UTC (permalink / raw)
  To: u-boot

Save and use the FDT address provided by TF-A in r2 at boot time
(it is NT_FW_CONFIG = Non Trusted Firmware configuration file)

Address is saved in save_boot_params(), called by start.S
and the used DTB is gd->fdt_blob = board_fdt_blob_setup().

If dtb is not provided or invalid, U-Boot use as fallback
the builtin DTB.

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

 arch/arm/mach-stm32mp/Makefile      |  1 +
 arch/arm/mach-stm32mp/boot_params.c | 45 +++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)
 create mode 100644 arch/arm/mach-stm32mp/boot_params.c

diff --git a/arch/arm/mach-stm32mp/Makefile b/arch/arm/mach-stm32mp/Makefile
index eee39c27c3..19ca3b08a5 100644
--- a/arch/arm/mach-stm32mp/Makefile
+++ b/arch/arm/mach-stm32mp/Makefile
@@ -13,6 +13,7 @@ else
 obj-y += bsec.o
 obj-$(CONFIG_CMD_STM32KEY) += cmd_stm32key.o
 obj-$(CONFIG_ARMV7_PSCI) += psci.o
+obj-$(CONFIG_STM32MP1_TRUSTED) += boot_params.o
 endif
 
 obj-$(CONFIG_$(SPL_)DM_REGULATOR) += pwr_regulator.o
diff --git a/arch/arm/mach-stm32mp/boot_params.c b/arch/arm/mach-stm32mp/boot_params.c
new file mode 100644
index 0000000000..e4351de939
--- /dev/null
+++ b/arch/arm/mach-stm32mp/boot_params.c
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
+/*
+ * Copyright (C) 2019, STMicroelectronics - All Rights Reserved
+ */
+
+#include <common.h>
+#include <asm/sections.h>
+#include <asm/system.h>
+
+/*
+ * Force data-section, as .bss will not be valid
+ * when save_boot_params is invoked.
+ */
+static unsigned long nt_fw_dtb __section(".data");
+
+/*
+ * Save the FDT address provided by TF-A in r2 at boot time
+ * This function is called from start.S
+ */
+void save_boot_params(unsigned long r0, unsigned long r1, unsigned long r2,
+		      unsigned long r3)
+{
+	nt_fw_dtb = r2;
+
+	save_boot_params_ret();
+}
+
+/*
+ * Use the saved FDT address provided by TF-A at boot time (NT_FW_CONFIG =
+ * Non Trusted Firmware configuration file) when the pointer is valid
+ */
+void *board_fdt_blob_setup(void)
+{
+	debug("%s: nt_fw_dtb=%lx\n", __func__, nt_fw_dtb);
+
+	/* use external device tree only if address is valid */
+	if (nt_fw_dtb >= STM32_DDR_BASE) {
+		if (fdt_magic(nt_fw_dtb) == FDT_MAGIC)
+			return (void *)nt_fw_dtb;
+		debug("%s: DTB not found.\n", __func__);
+	}
+	debug("%s: fall back to builtin DTB, %p\n", __func__, &_end);
+
+	return (void *)&_end;
+}
-- 
2.17.1

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

* [PATCH 08/11] configs: stm32mp1: remove optee defconfig
  2020-03-18  8:22 [PATCH 00/11] stm32mp1: migrate MTD and DFU configuration in Kconfig Patrick Delaunay
                   ` (6 preceding siblings ...)
  2020-03-18  8:22 ` [PATCH 07/11] board: stm32mp1: use FDT address provided by TF-A at boot time Patrick Delaunay
@ 2020-03-18  8:22 ` Patrick Delaunay
  2020-04-14  9:32   ` Patrice CHOTARD
  2020-03-18  8:22 ` [PATCH 09/11] board: stm32mp1: support boot from spi-nand Patrick Delaunay
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 24+ messages in thread
From: Patrick Delaunay @ 2020-03-18  8:22 UTC (permalink / raw)
  To: u-boot

As the op-tee presence is detected by U-boot, the stm32mp15_optee_defconfig
is identical to stm32mp15_trusted_defconfig and can be removed.

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

 board/st/stm32mp1/MAINTAINERS     |   1 -
 configs/stm32mp15_optee_defconfig | 134 ------------------------------
 doc/board/st/stm32mp1.rst         |  32 ++-----
 3 files changed, 7 insertions(+), 160 deletions(-)
 delete mode 100644 configs/stm32mp15_optee_defconfig

diff --git a/board/st/stm32mp1/MAINTAINERS b/board/st/stm32mp1/MAINTAINERS
index 2930947716..96c4559033 100644
--- a/board/st/stm32mp1/MAINTAINERS
+++ b/board/st/stm32mp1/MAINTAINERS
@@ -6,6 +6,5 @@ S:	Maintained
 F:	arch/arm/dts/stm32mp15*
 F:	board/st/stm32mp1/
 F:	configs/stm32mp15_basic_defconfig
-F:	configs/stm32mp15_optee_defconfig
 F:	configs/stm32mp15_trusted_defconfig
 F:	include/configs/stm32mp1.h
diff --git a/configs/stm32mp15_optee_defconfig b/configs/stm32mp15_optee_defconfig
deleted file mode 100644
index f0d524d344..0000000000
--- a/configs/stm32mp15_optee_defconfig
+++ /dev/null
@@ -1,134 +0,0 @@
-CONFIG_ARM=y
-CONFIG_ARCH_STM32MP=y
-CONFIG_SYS_MALLOC_F_LEN=0x3000
-CONFIG_ENV_SECT_SIZE=0x40000
-CONFIG_ENV_OFFSET=0x280000
-CONFIG_TARGET_ST_STM32MP15x=y
-CONFIG_ENV_OFFSET_REDUND=0x2C0000
-CONFIG_DISTRO_DEFAULTS=y
-CONFIG_FIT=y
-CONFIG_BOOTCOMMAND="run bootcmd_stm32mp"
-CONFIG_SYS_PROMPT="STM32MP> "
-# CONFIG_CMD_BOOTD is not set
-# CONFIG_CMD_ELF is not set
-# CONFIG_CMD_IMI is not set
-# CONFIG_CMD_XIMG is not set
-# CONFIG_CMD_EXPORTENV is not set
-# CONFIG_CMD_IMPORTENV is not set
-CONFIG_CMD_MEMINFO=y
-CONFIG_CMD_MEMTEST=y
-CONFIG_CMD_ADC=y
-CONFIG_CMD_CLK=y
-CONFIG_CMD_DFU=y
-CONFIG_CMD_FUSE=y
-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_SPI=y
-CONFIG_CMD_USB=y
-CONFIG_CMD_USB_MASS_STORAGE=y
-CONFIG_CMD_BMP=y
-CONFIG_CMD_CACHE=y
-CONFIG_CMD_TIME=y
-CONFIG_CMD_TIMER=y
-CONFIG_CMD_PMIC=y
-CONFIG_CMD_REGULATOR=y
-CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_MTDPARTS=y
-CONFIG_CMD_UBI=y
-CONFIG_DEFAULT_DEVICE_TREE="stm32mp157c-ev1"
-CONFIG_ENV_IS_NOWHERE=y
-CONFIG_ENV_IS_IN_EXT4=y
-CONFIG_ENV_IS_IN_SPI_FLASH=y
-CONFIG_ENV_IS_IN_UBI=y
-CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
-CONFIG_ENV_EXT4_INTERFACE="mmc"
-CONFIG_ENV_EXT4_DEVICE_AND_PART="0:auto"
-CONFIG_ENV_EXT4_FILE="/uboot.env"
-CONFIG_ENV_UBI_PART="UBI"
-CONFIG_ENV_UBI_VOLUME="uboot_config"
-CONFIG_ENV_UBI_VOLUME_REDUND="uboot_config_r"
-CONFIG_SYS_RELOC_GD_ENV_ADDR=y
-CONFIG_STM32_ADC=y
-CONFIG_DFU_MMC=y
-CONFIG_DFU_RAM=y
-CONFIG_DFU_MTD=y
-CONFIG_DFU_VIRT=y
-CONFIG_SET_DFU_ALT_INFO=y
-CONFIG_USB_FUNCTION_FASTBOOT=y
-CONFIG_FASTBOOT_BUF_ADDR=0xC0000000
-CONFIG_FASTBOOT_BUF_SIZE=0x02000000
-CONFIG_FASTBOOT_USB_DEV=1
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=1
-CONFIG_DM_HWSPINLOCK=y
-CONFIG_HWSPINLOCK_STM32=y
-CONFIG_DM_I2C=y
-CONFIG_SYS_I2C_STM32F7=y
-CONFIG_LED=y
-CONFIG_LED_GPIO=y
-CONFIG_DM_MAILBOX=y
-CONFIG_STM32_IPCC=y
-CONFIG_DM_MMC=y
-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_MTD_SPI_NAND=y
-CONFIG_DM_SPI_FLASH=y
-CONFIG_SPI_FLASH_MACRONIX=y
-CONFIG_SPI_FLASH_SPANSION=y
-CONFIG_SPI_FLASH_STMICRO=y
-CONFIG_SPI_FLASH_WINBOND=y
-# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set
-CONFIG_SPI_FLASH_MTD=y
-CONFIG_DM_ETH=y
-CONFIG_DWC_ETH_QOS=y
-CONFIG_PHY=y
-CONFIG_PHY_STM32_USBPHYC=y
-CONFIG_PINCONF=y
-CONFIG_PINCTRL_STMFX=y
-CONFIG_DM_PMIC=y
-CONFIG_PMIC_STPMIC1=y
-CONFIG_DM_REGULATOR_FIXED=y
-CONFIG_DM_REGULATOR_GPIO=y
-CONFIG_DM_REGULATOR_STM32_VREFBUF=y
-CONFIG_DM_REGULATOR_STPMIC1=y
-CONFIG_REMOTEPROC_STM32_COPRO=y
-CONFIG_DM_RNG=y
-CONFIG_RNG_STM32MP1=y
-CONFIG_DM_RTC=y
-CONFIG_RTC_STM32=y
-CONFIG_SERIAL_RX_BUFFER=y
-CONFIG_SPI=y
-CONFIG_DM_SPI=y
-CONFIG_STM32_QSPI=y
-CONFIG_STM32_SPI=y
-CONFIG_TEE=y
-CONFIG_OPTEE=y
-# CONFIG_OPTEE_TA_AVB is not set
-CONFIG_USB=y
-CONFIG_DM_USB=y
-CONFIG_DM_USB_GADGET=y
-CONFIG_USB_EHCI_HCD=y
-CONFIG_USB_EHCI_GENERIC=y
-CONFIG_USB_GADGET=y
-CONFIG_USB_GADGET_MANUFACTURER="STMicroelectronics"
-CONFIG_USB_GADGET_VENDOR_NUM=0x0483
-CONFIG_USB_GADGET_PRODUCT_NUM=0x5720
-CONFIG_USB_GADGET_DWC2_OTG=y
-CONFIG_DM_VIDEO=y
-CONFIG_BACKLIGHT_GPIO=y
-CONFIG_VIDEO_LCD_ORISETECH_OTM8009A=y
-CONFIG_VIDEO_LCD_RAYDIUM_RM68200=y
-CONFIG_VIDEO_STM32=y
-CONFIG_VIDEO_STM32_DSI=y
-CONFIG_VIDEO_STM32_MAX_XRES=1280
-CONFIG_VIDEO_STM32_MAX_YRES=800
-CONFIG_FDT_FIXUP_PARTITIONS=y
diff --git a/doc/board/st/stm32mp1.rst b/doc/board/st/stm32mp1.rst
index b7a0fbfd03..7fccdfbb94 100644
--- a/doc/board/st/stm32mp1.rst
+++ b/doc/board/st/stm32mp1.rst
@@ -80,32 +80,16 @@ defconfig_file : stm32mp15_trusted_defconfig
     +             +-------------------------+------------+-------+
     |             |Trusted Firmware-A (TF-A)| U-Boot     | Linux |
     +-------------+-------------------------+------------+-------+
-    | TrustZone   |TF-A secure monitor                           |
+    | TrustZone   |secure monitor                                |
     +-------------+-------------------------+------------+-------+
 
 TF-A performs a full initialization of Secure peripherals and installs a
-secure monitor (BL32=SPMin).
+secure monitor, BL32:
 
-U-Boot is running in normal world and uses TF-A monitor to access
-to secure resources.
-
-The **Trusted** boot chain with **OP-TEE**
-``````````````````````````````````````````
-
-defconfig_file : stm32mp15_optee_defconfig
-
-    +-------------+-------------------------+------------+-------+
-    |  ROM code   | FSBL                    | SSBL       | OS    |
-    +             +-------------------------+------------+-------+
-    |             |Trusted Firmware-A (TF-A)| U-Boot     | Linux |
-    +-------------+-------------------------+------------+-------+
-    | TrustZone   |OP-TEE                                        |
-    +-------------+-------------------------+------------+-------+
-
-TF-A performs a full initialization of Secure peripherals and installs OP-TEE
-from specific partitions (teeh, teed, teex).
+  * SPMin provided by TF-A or
+  * OP-TEE from specific partitions (teeh, teed, teex).
 
-U-Boot is running in normal world and uses OP-TEE monitor to access
+U-Boot is running in normal world and uses the secure monitor to access
 to secure resources.
 
 The **Basic** boot chain
@@ -180,7 +164,6 @@ Build Procedure
    for example: use one output directory for each configuration::
 
    # export KBUILD_OUTPUT=stm32mp15_trusted
-   # export KBUILD_OUTPUT=stm32mp15_optee
    # export KBUILD_OUTPUT=stm32mp15_basic
 
    you can build outside of code directory::
@@ -194,7 +177,6 @@ Build Procedure
    with <defconfig_file>:
 
    - For **trusted** boot mode : **stm32mp15_trusted_defconfig**
-   - For **trusted** with OP-TEE boot mode : **stm32mp15_optee_defconfig**
    - For basic boot mode: stm32mp15_basic_defconfig
 
 5. Configure the device-tree and build the U-Boot image::
@@ -211,8 +193,8 @@ Build Procedure
 
   b) trusted with OP-TEE boot on dk2::
 
-      # export KBUILD_OUTPUT=stm32mp15_optee
-      # make stm32mp15_optee_defconfig
+      # export KBUILD_OUTPUT=stm32mp15_trusted
+      # make stm32mp15_trusted_defconfig
       # make DEVICE_TREE=stm32mp157c-dk2 all
 
   c) basic boot on ev1::
-- 
2.17.1

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

* [PATCH 09/11] board: stm32mp1: support boot from spi-nand
  2020-03-18  8:22 [PATCH 00/11] stm32mp1: migrate MTD and DFU configuration in Kconfig Patrick Delaunay
                   ` (7 preceding siblings ...)
  2020-03-18  8:22 ` [PATCH 08/11] configs: stm32mp1: remove optee defconfig Patrick Delaunay
@ 2020-03-18  8:22 ` Patrick Delaunay
  2020-04-14  9:33   ` Patrice CHOTARD
  2020-03-18  8:22 ` [PATCH 10/11] board: stm32mp1: adapt MTD partition for BOOT from NOR or NAND Patrick Delaunay
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 24+ messages in thread
From: Patrick Delaunay @ 2020-03-18  8:22 UTC (permalink / raw)
  To: u-boot

Manage BOOT_FLASH_SPINAND, with boot_device="spi-nand"
and treat this value in bootcmd_stm32mp.

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

 arch/arm/mach-stm32mp/cpu.c                | 4 ++++
 arch/arm/mach-stm32mp/include/mach/stm32.h | 3 +++
 arch/arm/mach-stm32mp/spl.c                | 2 ++
 board/st/stm32mp1/stm32mp1.c               | 2 ++
 include/configs/stm32mp1.h                 | 5 +++--
 5 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-stm32mp/cpu.c b/arch/arm/mach-stm32mp/cpu.c
index 9aa5794334..e14e3e47f2 100644
--- a/arch/arm/mach-stm32mp/cpu.c
+++ b/arch/arm/mach-stm32mp/cpu.c
@@ -435,6 +435,10 @@ static void setup_boot_mode(void)
 		env_set("boot_device", "nand");
 		env_set("boot_instance", "0");
 		break;
+	case BOOT_FLASH_SPINAND:
+		env_set("boot_device", "spi-nand");
+		env_set("boot_instance", "0");
+		break;
 	case BOOT_FLASH_NOR:
 		env_set("boot_device", "nor");
 		env_set("boot_instance", "0");
diff --git a/arch/arm/mach-stm32mp/include/mach/stm32.h b/arch/arm/mach-stm32mp/include/mach/stm32.h
index 6daf9f7121..a9bd5bdc1b 100644
--- a/arch/arm/mach-stm32mp/include/mach/stm32.h
+++ b/arch/arm/mach-stm32mp/include/mach/stm32.h
@@ -79,6 +79,9 @@ enum boot_device {
 
 	BOOT_SERIAL_USB = 0x60,
 	BOOT_SERIAL_USB_OTG = 0x62,
+
+	BOOT_FLASH_SPINAND = 0x70,
+	BOOT_FLASH_SPINAND_1 = 0x71,
 };
 
 /* TAMP registers */
diff --git a/arch/arm/mach-stm32mp/spl.c b/arch/arm/mach-stm32mp/spl.c
index ca4231cd0d..9cd7b418a4 100644
--- a/arch/arm/mach-stm32mp/spl.c
+++ b/arch/arm/mach-stm32mp/spl.c
@@ -39,6 +39,8 @@ u32 spl_boot_device(void)
 		return BOOT_DEVICE_NAND;
 	case BOOT_FLASH_NOR_QSPI:
 		return BOOT_DEVICE_SPI;
+	case BOOT_FLASH_SPINAND_1:
+		return BOOT_DEVICE_NONE; /* SPINAND not supported in SPL */
 	}
 
 	return BOOT_DEVICE_MMC1;
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 14c56a0f24..423be23555 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -789,6 +789,7 @@ enum env_location env_get_location(enum env_operation op, int prio)
 #endif
 #ifdef CONFIG_ENV_IS_IN_UBI
 	case BOOT_FLASH_NAND:
+	case BOOT_FLASH_SPINAND:
 		return ENVL_UBI;
 #endif
 #ifdef CONFIG_ENV_IS_IN_SPI_FLASH
@@ -829,6 +830,7 @@ int ft_board_setup(void *blob, bd_t *bd)
 #ifdef CONFIG_FDT_FIXUP_PARTITIONS
 	struct node_info nodes[] = {
 		{ "st,stm32f469-qspi",		MTD_DEV_TYPE_NOR,  },
+		{ "st,stm32f469-qspi",		MTD_DEV_TYPE_SPINAND},
 		{ "st,stm32mp15-fmc2",		MTD_DEV_TYPE_NAND, },
 	};
 	fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h
index c5b09f1a2a..c34a720e0c 100644
--- a/include/configs/stm32mp1.h
+++ b/include/configs/stm32mp1.h
@@ -127,7 +127,7 @@
  * bootcmd for stm32mp1:
  * for serial/usb: execute the stm32prog command
  * for mmc boot (eMMC, SD card), boot only on the same device
- * for nand boot, boot with on ubifs partition on nand
+ * for nand or spi-nand boot, boot with on ubifs partition on UBI partition
  * for nor boot, use the default order
  */
 #define STM32MP_BOOTCMD "bootcmd_stm32mp=" \
@@ -138,7 +138,8 @@
 		"run env_check;" \
 		"if test ${boot_device} = mmc;" \
 		"then env set boot_targets \"mmc${boot_instance}\"; fi;" \
-		"if test ${boot_device} = nand;" \
+		"if test ${boot_device} = nand ||" \
+		  " test ${boot_device} = spi-nand ;" \
 		"then env set boot_targets ubifs0; fi;" \
 		"run distro_bootcmd;" \
 	"fi;\0"
-- 
2.17.1

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

* [PATCH 10/11] board: stm32mp1: adapt MTD partition for BOOT from NOR or NAND
  2020-03-18  8:22 [PATCH 00/11] stm32mp1: migrate MTD and DFU configuration in Kconfig Patrick Delaunay
                   ` (8 preceding siblings ...)
  2020-03-18  8:22 ` [PATCH 09/11] board: stm32mp1: support boot from spi-nand Patrick Delaunay
@ 2020-03-18  8:22 ` Patrick Delaunay
  2020-04-14  9:28   ` [Uboot-stm32] " Patrice CHOTARD
  2020-03-18  8:22 ` [PATCH 11/11] doc: stm32mp1: update DFU support example Patrick Delaunay
  2020-05-14  9:26 ` [PATCH 00/11] stm32mp1: migrate MTD and DFU configuration in Kconfig Patrick DELAUNAY
  11 siblings, 1 reply; 24+ messages in thread
From: Patrick Delaunay @ 2020-03-18  8:22 UTC (permalink / raw)
  To: u-boot

Dynamically adapt the MTD partitions in NAND and SPI-NAND when boot from
NOR or NAND/SPI-NAND is detected.

This patch avoids to define the save MTD partition name for NOR and NAND
devices and issue with latest kernel: only the needed MTD partitions
are defined.

For boot from NOR
1/ bootloader (TF-A, U-Boot and OP-TE) in NOR
2/ one large UBI partition in NAND

For boot from NAND
1/ bootloader (TF-A, U-Boot and OP-TE) in MTD raw partition
2/ one large UBI partition

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

# Conflicts:
#	board/st/common/stm32mp_mtdparts.c
---

 board/st/common/stm32mp_mtdparts.c | 81 ++++++++++++++++++++++--------
 1 file changed, 60 insertions(+), 21 deletions(-)

diff --git a/board/st/common/stm32mp_mtdparts.c b/board/st/common/stm32mp_mtdparts.c
index 2b6413be16..5028511077 100644
--- a/board/st/common/stm32mp_mtdparts.c
+++ b/board/st/common/stm32mp_mtdparts.c
@@ -10,6 +10,7 @@
 #include <mtd.h>
 #include <mtd_node.h>
 #include <tee.h>
+#include <asm/arch/sys_proto.h>
 
 #define MTDPARTS_LEN		256
 #define MTDIDS_LEN		128
@@ -22,7 +23,7 @@ DECLARE_GLOBAL_DATA_PTR;
 /**
  * update the variables "mtdids" and "mtdparts" with boot, tee and user strings
  */
-static void board_get_mtdparts(const char *dev,
+static void board_set_mtdparts(const char *dev,
 			       char *mtdids,
 			       char *mtdparts,
 			       const char *boot,
@@ -65,7 +66,7 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
 	static char parts[3 * MTDPARTS_LEN + 1];
 	static char ids[MTDIDS_LEN + 1];
 	static bool mtd_initialized;
-	bool tee = false;
+	bool tee, nor, nand, spinand;
 
 	if (mtd_initialized) {
 		*mtdids = ids;
@@ -73,6 +74,28 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
 		return;
 	}
 
+	tee = false;
+	nor = false;
+	nand = false;
+	spinand = false;
+
+	switch (get_bootmode() & TAMP_BOOT_DEVICE_MASK) {
+	case BOOT_SERIAL_UART:
+	case BOOT_SERIAL_USB:
+		break;
+	case BOOT_FLASH_NAND:
+		nand = true;
+		break;
+	case BOOT_FLASH_SPINAND:
+		spinand = true;
+		break;
+	case BOOT_FLASH_NOR:
+		nor = true;
+		break;
+	default:
+		break;
+	}
+
 	if (CONFIG_IS_ENABLED(OPTEE) &&
 	    tee_find_device(NULL, NULL, NULL, NULL))
 		tee = true;
@@ -87,29 +110,45 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
 		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,
-				   CONFIG_MTDPARTS_NAND0_BOOT,
-				   tee ? CONFIG_MTDPARTS_NAND0_TEE : NULL,
-				   "-(UBI)");
-		put_mtd_device(mtd);
+	if (nor || nand) {
+		mtd = get_mtd_device_nm("nand0");
+		if (!IS_ERR_OR_NULL(mtd)) {
+			const char *mtd_boot = CONFIG_MTDPARTS_NAND0_BOOT;
+			const char *mtd_tee = CONFIG_MTDPARTS_NAND0_TEE;
+
+			board_set_mtdparts("nand0", ids, parts,
+					   !nor ? mtd_boot : NULL,
+					   !nor && tee ? mtd_tee : NULL,
+					   "-(UBI)");
+			put_mtd_device(mtd);
+		}
 	}
 
-	mtd = get_mtd_device_nm("spi-nand0");
-	if (!IS_ERR_OR_NULL(mtd)) {
-		board_get_mtdparts("spi-nand0", ids, parts,
-				   CONFIG_MTDPARTS_SPINAND0_BOOT,
-				   tee ? CONFIG_MTDPARTS_SPINAND0_TEE : NULL,
-				   "-(UBI)");
-		put_mtd_device(mtd);
+	if (nor || spinand) {
+		mtd = get_mtd_device_nm("spi-nand0");
+		if (!IS_ERR_OR_NULL(mtd)) {
+			const char *mtd_boot = CONFIG_MTDPARTS_SPINAND0_BOOT;
+			const char *mtd_tee = CONFIG_MTDPARTS_SPINAND0_TEE;
+
+			board_set_mtdparts("spi-nand0", ids, parts,
+					   !nor ? mtd_boot : NULL,
+					   !nor && tee ? mtd_tee : NULL,
+					   "-(UBI)");
+			put_mtd_device(mtd);
+		}
 	}
 
-	if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev))
-		board_get_mtdparts("nor0", ids, parts,
-				   CONFIG_MTDPARTS_NOR0_BOOT,
-				   tee ? CONFIG_MTDPARTS_NOR0_TEE : NULL,
-				   "-(nor_user)");
+	if (nor) {
+		if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev)) {
+			const char *mtd_boot = CONFIG_MTDPARTS_NOR0_BOOT;
+			const char *mtd_tee = CONFIG_MTDPARTS_NOR0_TEE;
+
+			board_set_mtdparts("nor0", ids, parts,
+					   mtd_boot,
+					   tee ? mtd_tee : NULL,
+					   "-(nor_user)");
+		}
+	}
 
 	mtd_initialized = true;
 	*mtdids = ids;
-- 
2.17.1

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

* [PATCH 11/11] doc: stm32mp1: update DFU support example
  2020-03-18  8:22 [PATCH 00/11] stm32mp1: migrate MTD and DFU configuration in Kconfig Patrick Delaunay
                   ` (9 preceding siblings ...)
  2020-03-18  8:22 ` [PATCH 10/11] board: stm32mp1: adapt MTD partition for BOOT from NOR or NAND Patrick Delaunay
@ 2020-03-18  8:22 ` Patrick Delaunay
  2020-04-14  9:34   ` Patrice CHOTARD
  2020-05-14  9:26 ` [PATCH 00/11] stm32mp1: migrate MTD and DFU configuration in Kconfig Patrick DELAUNAY
  11 siblings, 1 reply; 24+ messages in thread
From: Patrick Delaunay @ 2020-03-18  8:22 UTC (permalink / raw)
  To: u-boot

Update stm32mp1 board documentation with new management of MMC and
MTD partitions and new PID df11.

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

 doc/board/st/stm32mp1.rst | 115 ++++++++++++++++++--------------------
 1 file changed, 54 insertions(+), 61 deletions(-)

diff --git a/doc/board/st/stm32mp1.rst b/doc/board/st/stm32mp1.rst
index 7fccdfbb94..41d0206d34 100644
--- a/doc/board/st/stm32mp1.rst
+++ b/doc/board/st/stm32mp1.rst
@@ -518,61 +518,49 @@ On EV1 board, booting from SD card, without OP-TEE::
   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
+  dev: eMMC alt: 3 name: mmc0_fsbl1 layout: RAW_ADDR
+  dev: eMMC alt: 4 name: mmc0_fsbl2 layout: RAW_ADDR
+  dev: eMMC alt: 5 name: mmc0_ssbl layout: RAW_ADDR
+  dev: eMMC alt: 6 name: mmc0_bootfs layout: RAW_ADDR
+  dev: eMMC alt: 7 name: mmc0_vendorfs layout: RAW_ADDR
+  dev: eMMC alt: 8 name: mmc0_rootfs layout: RAW_ADDR
+  dev: eMMC alt: 9 name: mmc0_userfs layout: RAW_ADDR
+  dev: eMMC alt: 10 name: mmc1_boot1 layout: RAW_ADDR
+  dev: eMMC alt: 11 name: mmc1_boot2 layout: RAW_ADDR
+  dev: eMMC alt: 12 name: mmc1_ssbl layout: RAW_ADDR
+  dev: eMMC alt: 13 name: mmc1_bootfs layout: RAW_ADDR
+  dev: eMMC alt: 14 name: mmc1_vendorfs layout: RAW_ADDR
+  dev: eMMC alt: 15 name: mmc1_rootfs layout: RAW_ADDR
+  dev: eMMC alt: 16 name: mmc1_userfs layout: RAW_ADDR
+  dev: MTD alt: 17 name: nor0 layout: RAW_ADDR
+  dev: MTD alt: 18 name: nand0 layout: RAW_ADDR
+  dev: VIRT alt: 19 name: OTP layout: RAW_ADDR
+  dev: VIRT alt: 20 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"
+  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=20, name="PMIC", serial="002700333338511934383330"
+  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=19, name="OTP", serial="002700333338511934383330"
+  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=18, name="nand0", serial="002700333338511934383330"
+  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=17, name="nor0", serial="002700333338511934383330"
+  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=16, name="mmc1_userfs", serial="002700333338511934383330"
+  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=15, name="mmc1_rootfs", serial="002700333338511934383330"
+  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=14, name="mmc1_vendorfs", serial="002700333338511934383330"
+  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=13, name="mmc1_bootfs", serial="002700333338511934383330"
+  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=12, name="mmc1_ssbl", serial="002700333338511934383330"
+  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=11, name="mmc1_boot2", serial="002700333338511934383330"
+  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=10, name="mmc1_boot1", serial="002700333338511934383330"
+  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=9, name="mmc0_userfs", serial="002700333338511934383330"
+  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=8, name="mmc0_rootfs", serial="002700333338511934383330"
+  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=7, name="mmc0_vendorfs", serial="002700333338511934383330"
+  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=6, name="mmc0_bootfs", serial="002700333338511934383330"
+  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=5, name="mmc0_ssbl", serial="002700333338511934383330"
+  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=4, name="mmc0_fsbl2", serial="002700333338511934383330"
+  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=3, name="mmc0_fsbl1", serial="002700333338511934383330"
+  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=2, name="uramdisk.image.gz", serial="002700333338511934383330"
+  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=1, name="devicetree.dtb", serial="002700333338511934383330"
+  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=0, name="uImage", serial="002700333338511934383330"
 
 You can update the boot device:
 
@@ -596,20 +584,25 @@ You can update the boot device:
   $> 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::
+- you can also dump the OTP and the PMIC NVM with::
+
+  $> dfu-util -d 0483:5720 -a 19 -U otp.bin
+  $> dfu-util -d 0483:5720 -a 20 -U pmic.bin
+
 
-  $> 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
+When the board is booting for nor0 or nand0,
+only the MTD partition on the boot devices are available, for example:
 
-- NAND (UBI partition used for NAND only boot or NOR + NAND boot)::
+- NOR (nor0 = alt 20) & NAND (nand0 = alt 26) ::
 
   $> 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 22 -D tf-a-stm32mp157c-ev1-trusted.stm32
   $> 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
+  $> dfu-util -d 0483:5720 -a 27 -D st-image-weston-openstlinux-weston-stm32mp1_nand_4_256_multivolume.ubi
 
-- you can also dump the OTP and the PMIC NVM with::
+- NAND (nand0 = alt 21)::
 
-  $> dfu-util -d 0483:5720 -a 25 -U otp.bin
-  $> dfu-util -d 0483:5720 -a 26 -U pmic.bin
+  $> dfu-util -d 0483:5720 -a 22 -D tf-a-stm32mp157c-ev1-trusted.stm32
+  $> dfu-util -d 0483:5720 -a 23 -D u-boot-stm32mp157c-ev1-trusted.img
+  $> dfu-util -d 0483:5720 -a 24 -D u-boot-stm32mp157c-ev1-trusted.img
+  $> dfu-util -d 0483:5720 -a 25 -D st-image-weston-openstlinux-weston-stm32mp1_nand_4_256_multivolume.ubi
-- 
2.17.1

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

* [Uboot-stm32] [PATCH 01/11] board: stm32mp1: move board_get_mtdparts in st common directory
  2020-03-18  8:22 ` [PATCH 01/11] board: stm32mp1: move board_get_mtdparts in st common directory Patrick Delaunay
@ 2020-04-14  9:25   ` Patrice CHOTARD
  0 siblings, 0 replies; 24+ messages in thread
From: Patrice CHOTARD @ 2020-04-14  9:25 UTC (permalink / raw)
  To: u-boot

Hi Patrick

On 3/18/20 9:22 AM, Patrick Delaunay wrote:
> Move the stm32mp1 common code board_get_mtdparts() in common directory,
> this patch reduce the maintenance effort on this generic part (not board
> dependent).
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---

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

Patrice


>
>  board/dhelectronics/dh_stm32mp1/Makefile |   1 +
>  board/dhelectronics/dh_stm32mp1/board.c  |  89 ------------------
>  board/st/common/Makefile                 |   4 +
>  board/st/common/stm32mp_mtdparts.c       | 115 +++++++++++++++++++++++
>  board/st/stm32mp1/stm32mp1.c             | 102 --------------------
>  5 files changed, 120 insertions(+), 191 deletions(-)
>  create mode 100644 board/st/common/stm32mp_mtdparts.c
>
> diff --git a/board/dhelectronics/dh_stm32mp1/Makefile b/board/dhelectronics/dh_stm32mp1/Makefile
> index b42c4e4c04..c77a1e3a84 100644
> --- a/board/dhelectronics/dh_stm32mp1/Makefile
> +++ b/board/dhelectronics/dh_stm32mp1/Makefile
> @@ -8,3 +8,4 @@ obj-y += ../../st/stm32mp1/spl.o
>  endif
>  
>  obj-y += ../../st/stm32mp1/board.o board.o
> +obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += ../../st/common/stm32mp_mtdparts.o
> diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c
> index b663696983..2baa36278c 100644
> --- a/board/dhelectronics/dh_stm32mp1/board.c
> +++ b/board/dhelectronics/dh_stm32mp1/board.c
> @@ -519,95 +519,6 @@ enum env_location env_get_location(enum env_operation op, int prio)
>  #endif
>  }
>  
> -#ifdef CONFIG_SYS_MTDPARTS_RUNTIME
> -
> -#define MTDPARTS_LEN		256
> -#define MTDIDS_LEN		128
> -
> -/**
> - * The mtdparts_nand0 and mtdparts_nor0 variable tends to be long.
> - * If we need to access it before the env is relocated, then we need
> - * to use our own stack buffer. gd->env_buf will be too small.
> - *
> - * @param buf temporary buffer pointer MTDPARTS_LEN long
> - * @return mtdparts variable string, NULL if not found
> - */
> -static const char *env_get_mtdparts(const char *str, char *buf)
> -{
> -	if (gd->flags & GD_FLG_ENV_READY)
> -		return env_get(str);
> -	if (env_get_f(str, buf, MTDPARTS_LEN) != -1)
> -		return buf;
> -
> -	return NULL;
> -}
> -
> -/**
> - * update the variables "mtdids" and "mtdparts" with content of mtdparts_<dev>
> - */
> -static void board_get_mtdparts(const char *dev,
> -			       char *mtdids,
> -			       char *mtdparts)
> -{
> -	char env_name[32] = "mtdparts_";
> -	char tmp_mtdparts[MTDPARTS_LEN];
> -	const char *tmp;
> -
> -	/* name of env variable to read = mtdparts_<dev> */
> -	strcat(env_name, dev);
> -	tmp = env_get_mtdparts(env_name, tmp_mtdparts);
> -	if (tmp) {
> -		/* 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);
> -		strncat(mtdparts, tmp, MTDPARTS_LEN);
> -	}
> -}
> -
> -void board_mtdparts_default(const char **mtdids, const char **mtdparts)
> -{
> -	struct udevice *dev;
> -	static char parts[3 * MTDPARTS_LEN + 1];
> -	static char ids[MTDIDS_LEN + 1];
> -	static bool mtd_initialized;
> -
> -	if (mtd_initialized) {
> -		*mtdids = ids;
> -		*mtdparts = parts;
> -		return;
> -	}
> -
> -	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)) {
> -		pr_debug("mtd device = %s\n", dev->name);
> -	}
> -
> -	if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev))
> -		board_get_mtdparts("nor0", ids, parts);
> -
> -	mtd_initialized = true;
> -	*mtdids = ids;
> -	*mtdparts = parts;
> -	debug("%s:mtdids=%s & mtdparts=%s\n", __func__, ids, parts);
> -}
> -#endif
> -
>  #if defined(CONFIG_OF_BOARD_SETUP)
>  int ft_board_setup(void *blob, bd_t *bd)
>  {
> diff --git a/board/st/common/Makefile b/board/st/common/Makefile
> index 8553606b90..4bb8b49867 100644
> --- a/board/st/common/Makefile
> +++ b/board/st/common/Makefile
> @@ -4,3 +4,7 @@
>  #
>  
>  obj-$(CONFIG_CMD_STBOARD) += cmd_stboard.o
> +
> +ifeq ($(CONFIG_ARCH_STM32MP),y)
> +obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += stm32mp_mtdparts.o
> +endif
> diff --git a/board/st/common/stm32mp_mtdparts.c b/board/st/common/stm32mp_mtdparts.c
> new file mode 100644
> index 0000000000..d77e075864
> --- /dev/null
> +++ b/board/st/common/stm32mp_mtdparts.c
> @@ -0,0 +1,115 @@
> +// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
> +/*
> + * Copyright (C) 2020, STMicroelectronics - All Rights Reserved
> + */
> +
> +#include <common.h>
> +#include <dm.h>
> +#include <env.h>
> +#include <env_internal.h>
> +#include <mtd.h>
> +#include <mtd_node.h>
> +
> +#define MTDPARTS_LEN		256
> +#define MTDIDS_LEN		128
> +
> +/*
> + * Get a global data pointer
> + */
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +/**
> + * The mtdparts_nand0 and mtdparts_nor0 variable tends to be long.
> + * If we need to access it before the env is relocated, then we need
> + * to use our own stack buffer. gd->env_buf will be too small.
> + *
> + * @param buf temporary buffer pointer MTDPARTS_LEN long
> + * @return mtdparts variable string, NULL if not found
> + */
> +static const char *env_get_mtdparts(const char *str, char *buf)
> +{
> +	if (gd->flags & GD_FLG_ENV_READY)
> +		return env_get(str);
> +	if (env_get_f(str, buf, MTDPARTS_LEN) != -1)
> +		return buf;
> +
> +	return NULL;
> +}
> +
> +/**
> + * update the variables "mtdids" and "mtdparts" with content of mtdparts_<dev>
> + */
> +static void board_get_mtdparts(const char *dev,
> +			       char *mtdids,
> +			       char *mtdparts)
> +{
> +	char env_name[32] = "mtdparts_";
> +	char tmp_mtdparts[MTDPARTS_LEN];
> +	const char *tmp;
> +
> +	/* name of env variable to read = mtdparts_<dev> */
> +	strcat(env_name, dev);
> +	tmp = env_get_mtdparts(env_name, tmp_mtdparts);
> +	if (tmp) {
> +		/* 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);
> +		strncat(mtdparts, tmp, 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;
> +
> +	if (mtd_initialized) {
> +		*mtdids = ids;
> +		*mtdparts = parts;
> +		return;
> +	}
> +
> +	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)) {
> +		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);
> +
> +	mtd_initialized = true;
> +	*mtdids = ids;
> +	*mtdparts = parts;
> +	debug("%s:mtdids=%s & mtdparts=%s\n", __func__, ids, parts);
> +}
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index b9d852efa4..bbeeb15d7e 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -828,108 +828,6 @@ const char *env_ext4_get_dev_part(void)
>  }
>  #endif
>  
> -#ifdef CONFIG_SYS_MTDPARTS_RUNTIME
> -
> -#define MTDPARTS_LEN		256
> -#define MTDIDS_LEN		128
> -
> -/**
> - * The mtdparts_nand0 and mtdparts_nor0 variable tends to be long.
> - * If we need to access it before the env is relocated, then we need
> - * to use our own stack buffer. gd->env_buf will be too small.
> - *
> - * @param buf temporary buffer pointer MTDPARTS_LEN long
> - * @return mtdparts variable string, NULL if not found
> - */
> -static const char *env_get_mtdparts(const char *str, char *buf)
> -{
> -	if (gd->flags & GD_FLG_ENV_READY)
> -		return env_get(str);
> -	if (env_get_f(str, buf, MTDPARTS_LEN) != -1)
> -		return buf;
> -
> -	return NULL;
> -}
> -
> -/**
> - * update the variables "mtdids" and "mtdparts" with content of mtdparts_<dev>
> - */
> -static void board_get_mtdparts(const char *dev,
> -			       char *mtdids,
> -			       char *mtdparts)
> -{
> -	char env_name[32] = "mtdparts_";
> -	char tmp_mtdparts[MTDPARTS_LEN];
> -	const char *tmp;
> -
> -	/* name of env variable to read = mtdparts_<dev> */
> -	strcat(env_name, dev);
> -	tmp = env_get_mtdparts(env_name, tmp_mtdparts);
> -	if (tmp) {
> -		/* 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);
> -		strncat(mtdparts, tmp, 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;
> -
> -	if (mtd_initialized) {
> -		*mtdids = ids;
> -		*mtdparts = parts;
> -		return;
> -	}
> -
> -	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)) {
> -		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);
> -
> -	mtd_initialized = true;
> -	*mtdids = ids;
> -	*mtdparts = parts;
> -	debug("%s:mtdids=%s & mtdparts=%s\n", __func__, ids, parts);
> -}
> -#endif
> -
>  #if defined(CONFIG_OF_BOARD_SETUP)
>  int ft_board_setup(void *blob, bd_t *bd)
>  {

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

* [Uboot-stm32] [PATCH 02/11] board: stm32mp1: move set_dfu_alt_info in st common directory
  2020-03-18  8:22 ` [PATCH 02/11] board: stm32mp1: move set_dfu_alt_info " Patrick Delaunay
@ 2020-04-14  9:25   ` Patrice CHOTARD
  0 siblings, 0 replies; 24+ messages in thread
From: Patrice CHOTARD @ 2020-04-14  9:25 UTC (permalink / raw)
  To: u-boot

Hi

On 3/18/20 9:22 AM, Patrick Delaunay wrote:
> Move the stm32mp1 common code set_dfu_alt_info() in common directory,
> this patch reduce the maintenance effort on this generic part (not board
> dependent).
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---


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

Patrice

>
>  board/dhelectronics/dh_stm32mp1/Makefile |   2 +
>  board/dhelectronics/dh_stm32mp1/board.c  |  50 --------
>  board/st/common/Makefile                 |   1 +
>  board/st/common/stm32mp_dfu.c            | 151 +++++++++++++++++++++++
>  board/st/stm32mp1/stm32mp1.c             | 145 ----------------------
>  5 files changed, 154 insertions(+), 195 deletions(-)
>  create mode 100644 board/st/common/stm32mp_dfu.c
>
> diff --git a/board/dhelectronics/dh_stm32mp1/Makefile b/board/dhelectronics/dh_stm32mp1/Makefile
> index c77a1e3a84..e8f218da08 100644
> --- a/board/dhelectronics/dh_stm32mp1/Makefile
> +++ b/board/dhelectronics/dh_stm32mp1/Makefile
> @@ -8,4 +8,6 @@ obj-y += ../../st/stm32mp1/spl.o
>  endif
>  
>  obj-y += ../../st/stm32mp1/board.o board.o
> +
>  obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += ../../st/common/stm32mp_mtdparts.o
> +obj-$(CONFIG_SET_DFU_ALT_INFO) += ../../st/common/stm32mp_dfu.o
> diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c
> index 2baa36278c..bd6540a2aa 100644
> --- a/board/dhelectronics/dh_stm32mp1/board.c
> +++ b/board/dhelectronics/dh_stm32mp1/board.c
> @@ -526,56 +526,6 @@ 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));
> -
> -	/* probe all MTD devices */
> -	mtd_probe_devices();
> -
> -	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);
> -
> -	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/board/st/common/Makefile b/board/st/common/Makefile
> index 4bb8b49867..aa030bacd8 100644
> --- a/board/st/common/Makefile
> +++ b/board/st/common/Makefile
> @@ -7,4 +7,5 @@ obj-$(CONFIG_CMD_STBOARD) += cmd_stboard.o
>  
>  ifeq ($(CONFIG_ARCH_STM32MP),y)
>  obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += stm32mp_mtdparts.o
> +obj-$(CONFIG_SET_DFU_ALT_INFO) += stm32mp_dfu.o
>  endif
> diff --git a/board/st/common/stm32mp_dfu.c b/board/st/common/stm32mp_dfu.c
> new file mode 100644
> index 0000000000..99ea21ce15
> --- /dev/null
> +++ b/board/st/common/stm32mp_dfu.c
> @@ -0,0 +1,151 @@
> +// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
> +/*
> + * Copyright (C) 2020, STMicroelectronics - All Rights Reserved
> + */
> +
> +#include <common.h>
> +#include <dfu.h>
> +#include <env.h>
> +#include <memalign.h>
> +#include <misc.h>
> +#include <mtd.h>
> +#include <mtd_node.h>
> +
> +#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;
> +	struct mtd_info *mtd;
> +
> +	ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN);
> +
> +	if (env_get("dfu_alt_info"))
> +		return;
> +
> +	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))
> +		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);
> +
> +	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);
> +
> +#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>
> +
> +static 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;
> +}
> +
> +static 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
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index bbeeb15d7e..2ab3b5cc9a 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -7,7 +7,6 @@
>  #include <bootm.h>
>  #include <clk.h>
>  #include <config.h>
> -#include <dfu.h>
>  #include <dm.h>
>  #include <env.h>
>  #include <env_internal.h>
> @@ -18,9 +17,7 @@
>  #include <init.h>
>  #include <led.h>
>  #include <malloc.h>
> -#include <memalign.h>
>  #include <misc.h>
> -#include <mtd.h>
>  #include <mtd_node.h>
>  #include <netdev.h>
>  #include <phy.h>
> @@ -843,148 +840,6 @@ 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;
> -	struct mtd_info *mtd;
> -
> -	ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN);
> -
> -	if (env_get("dfu_alt_info"))
> -		return;
> -
> -	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))
> -		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);
> -
> -	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);
> -
> -#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>
> -
> -static 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;
> -}
> -
> -static 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)
>  {
>  	int ret, id = 0; /* Copro id fixed to 0 as only one coproc on mp1 */

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

* [Uboot-stm32] [PATCH 03/11] stm32mp1: dynamically build DFU_ALT_INFO
  2020-03-18  8:22 ` [PATCH 03/11] stm32mp1: dynamically build DFU_ALT_INFO Patrick Delaunay
@ 2020-04-14  9:26   ` Patrice CHOTARD
  0 siblings, 0 replies; 24+ messages in thread
From: Patrice CHOTARD @ 2020-04-14  9:26 UTC (permalink / raw)
  To: u-boot

Hi

On 3/18/20 9:22 AM, Patrick Delaunay wrote:
> This patch reduces the stm32mp1 environment size and
> builds dynamically the DFU board configuration with gpt
> and mtd partitions and information from defconfig
> (CONFIG_DFU_ALT_RAM0).
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---


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

Patrice

>
>  board/dhelectronics/dh_stm32mp1/Kconfig |   1 +
>  board/st/common/Kconfig                 |   7 ++
>  board/st/common/stm32mp_dfu.c           | 130 +++++++++++++++++++-----
>  include/configs/stm32mp1.h              |  33 ------
>  4 files changed, 110 insertions(+), 61 deletions(-)
>
> diff --git a/board/dhelectronics/dh_stm32mp1/Kconfig b/board/dhelectronics/dh_stm32mp1/Kconfig
> index 8eab986640..69cc48f120 100644
> --- a/board/dhelectronics/dh_stm32mp1/Kconfig
> +++ b/board/dhelectronics/dh_stm32mp1/Kconfig
> @@ -18,4 +18,5 @@ config ENV_OFFSET
>  config ENV_OFFSET_REDUND
>  	default 0x1F0000 if ENV_IS_IN_SPI_FLASH
>  
> +source "board/st/common/Kconfig"
>  endif
> diff --git a/board/st/common/Kconfig b/board/st/common/Kconfig
> index af01ca4891..08df845982 100644
> --- a/board/st/common/Kconfig
> +++ b/board/st/common/Kconfig
> @@ -5,3 +5,10 @@ config CMD_STBOARD
>  	help
>  	  This compile the stboard command to
>  	  read and write the board in the OTP.
> +
> +config DFU_ALT_RAM0
> +	string "dfu for ram0"
> +	default "uImage ram 0xc2000000 0x2000000;devicetree.dtb ram 0xc4000000 0x100000;uramdisk.image.gz ram 0xc4400000 0x10000000"
> +	depends on ARCH_STM32MP && SET_DFU_ALT_INFO
> +	help
> +	  This defines the partitions of ram used to build dfu dynamically.
> diff --git a/board/st/common/stm32mp_dfu.c b/board/st/common/stm32mp_dfu.c
> index 99ea21ce15..e129f8c8b5 100644
> --- a/board/st/common/stm32mp_dfu.c
> +++ b/board/st/common/stm32mp_dfu.c
> @@ -4,6 +4,7 @@
>   */
>  
>  #include <common.h>
> +#include <blk.h>
>  #include <dfu.h>
>  #include <env.h>
>  #include <memalign.h>
> @@ -13,20 +14,86 @@
>  
>  #define DFU_ALT_BUF_LEN SZ_1K
>  
> -static void board_get_alt_info(const char *dev, char *buff)
> +static void board_get_alt_info_mmc(struct udevice *dev, char *buf)
>  {
> -	char var_name[32] = "dfu_alt_info_";
> -	int ret;
> +	disk_partition_t info;
> +	int p, len, devnum;
> +	bool first = true;
> +	const char *name;
> +	struct mmc *mmc;
> +	struct blk_desc *desc;
> +
> +	mmc = mmc_get_mmc_dev(dev);
> +	if (!mmc)
> +		return;
> +
> +	if (mmc_init(mmc))
> +		return;
> +
> +	desc = mmc_get_blk_desc(mmc);
> +	if (!desc)
> +		return;
> +
> +	name = blk_get_if_type_name(desc->if_type);
> +	devnum = desc->devnum;
> +	len = strlen(buf);
> +
> +	if (buf[0] != '\0')
> +		len += snprintf(buf + len,
> +				DFU_ALT_BUF_LEN - len, "&");
> +	len += snprintf(buf + len, DFU_ALT_BUF_LEN - len,
> +			 "%s %d=", name, devnum);
> +
> +	if (IS_MMC(mmc) && mmc->capacity_boot) {
> +		len += snprintf(buf + len, DFU_ALT_BUF_LEN - len,
> +				"%s%d_boot1 raw 0x0 0x%llx mmcpart 1;",
> +				name, devnum, mmc->capacity_boot);
> +		len += snprintf(buf + len, DFU_ALT_BUF_LEN - len,
> +				"%s%d_boot2 raw 0x0 0x%llx mmcpart 2",
> +				name, devnum, mmc->capacity_boot);
> +		first = false;
> +	}
>  
> -	ALLOC_CACHE_ALIGN_BUFFER(char, tmp_alt, DFU_ALT_BUF_LEN);
> +	for (p = 1; p < MAX_SEARCH_PARTITIONS; p++) {
> +		if (part_get_info(desc, p, &info))
> +			continue;
> +		if (!first)
> +			len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, ";");
> +		first = false;
> +		len += snprintf(buf + len, DFU_ALT_BUF_LEN - len,
> +				"%s%d_%s part %d %d",
> +				name, devnum, info.name, devnum, p);
> +	}
> +}
>  
> -	/* 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);
> +static void board_get_alt_info_mtd(struct mtd_info *mtd, char *buf)
> +{
> +	struct mtd_info *part;
> +	bool first = true;
> +	const char *name;
> +	int len, partnum = 0;
> +
> +	name = mtd->name;
> +	len = strlen(buf);
> +
> +	if (buf[0] != '\0')
> +		len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, "&");
> +	len += snprintf(buf + len, DFU_ALT_BUF_LEN - len,
> +			"mtd %s=", name);
> +
> +	len += snprintf(buf + len, DFU_ALT_BUF_LEN - len,
> +			"%s raw 0x0 0x%llx ",
> +			name, mtd->size);
> +
> +	list_for_each_entry(part, &mtd->partitions, node) {
> +		partnum++;
> +		if (!first)
> +			len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, ";");
> +		first = false;
> +
> +		len += snprintf(buf + len, DFU_ALT_BUF_LEN - len,
> +				"%s_%s part %d",
> +				name, part->name, partnum);
>  	}
>  }
>  
> @@ -42,27 +109,34 @@ 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);
> +	snprintf(buf, DFU_ALT_BUF_LEN,
> +		 "ram 0=%s", CONFIG_DFU_ALT_RAM0);
>  
>  	if (!uclass_get_device(UCLASS_MMC, 0, &dev))
> -		board_get_alt_info("mmc0", buf);
> +		board_get_alt_info_mmc(dev, 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);
> -
> -	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);
> +		board_get_alt_info_mmc(dev, buf);
> +
> +	if (CONFIG_IS_ENABLED(MTD)) {
> +		/* probe all MTD devices */
> +		mtd_probe_devices();
> +
> +		/* probe SPI flash device on a bus */
> +		if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev)) {
> +			mtd = get_mtd_device_nm("nor0");
> +			if (!IS_ERR_OR_NULL(mtd))
> +				board_get_alt_info_mtd(mtd, buf);
> +		}
> +
> +		mtd = get_mtd_device_nm("nand0");
> +		if (!IS_ERR_OR_NULL(mtd))
> +			board_get_alt_info_mtd(mtd, buf);
> +
> +		mtd = get_mtd_device_nm("spi-nand0");
> +		if (!IS_ERR_OR_NULL(mtd))
> +			board_get_alt_info_mtd(mtd, buf);
> +	}
>  
>  #ifdef CONFIG_DFU_VIRT
>  	strncat(buf, "&virt 0=OTP", DFU_ALT_BUF_LEN);
> diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h
> index f451edad36..a9631d2a92 100644
> --- a/include/configs/stm32mp1.h
> +++ b/include/configs/stm32mp1.h
> @@ -170,37 +170,6 @@
>  #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_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;" \
> -		"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
> @@ -220,8 +189,6 @@
>  		" 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"
>  

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

* [Uboot-stm32] [PATCH 04/11] stm32mp1: move MTDPART configuration in Kconfig
  2020-03-18  8:22 ` [PATCH 04/11] stm32mp1: move MTDPART configuration in Kconfig Patrick Delaunay
@ 2020-04-14  9:28   ` Patrice CHOTARD
  0 siblings, 0 replies; 24+ messages in thread
From: Patrice CHOTARD @ 2020-04-14  9:28 UTC (permalink / raw)
  To: u-boot

Hi

On 3/18/20 9:22 AM, Patrick Delaunay wrote:
> This patch reduces the stm32mp1 environment size and builds
> dynamically the MTD partitions with information from defconfig
> (CONFIG_MTDPARTS_...).
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---

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

Patrice


>  board/st/common/Kconfig            | 57 ++++++++++++++++++
>  board/st/common/stm32mp_mtdparts.c | 93 +++++++++++++++---------------
>  include/configs/stm32mp1.h         | 22 -------
>  3 files changed, 104 insertions(+), 68 deletions(-)
>
> diff --git a/board/st/common/Kconfig b/board/st/common/Kconfig
> index 08df845982..015ba40939 100644
> --- a/board/st/common/Kconfig
> +++ b/board/st/common/Kconfig
> @@ -6,6 +6,63 @@ 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)"
> +	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.
> +
> +config MTDPARTS_NAND0_TEE
> +	string "mtd tee partitions for nand0"
> +	default "512k(teeh),512k(teed),512k(teex)"
> +	depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP
> +	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)"
> +	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),256k(teed),256k(teex)"
> +	depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP
> +	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)"
> +	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.
> +
> +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
> +	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"
> diff --git a/board/st/common/stm32mp_mtdparts.c b/board/st/common/stm32mp_mtdparts.c
> index d77e075864..d4c0a7db9f 100644
> --- a/board/st/common/stm32mp_mtdparts.c
> +++ b/board/st/common/stm32mp_mtdparts.c
> @@ -19,54 +19,42 @@
>  DECLARE_GLOBAL_DATA_PTR;
>  
>  /**
> - * The mtdparts_nand0 and mtdparts_nor0 variable tends to be long.
> - * If we need to access it before the env is relocated, then we need
> - * to use our own stack buffer. gd->env_buf will be too small.
> - *
> - * @param buf temporary buffer pointer MTDPARTS_LEN long
> - * @return mtdparts variable string, NULL if not found
> - */
> -static const char *env_get_mtdparts(const char *str, char *buf)
> -{
> -	if (gd->flags & GD_FLG_ENV_READY)
> -		return env_get(str);
> -	if (env_get_f(str, buf, MTDPARTS_LEN) != -1)
> -		return buf;
> -
> -	return NULL;
> -}
> -
> -/**
> - * update the variables "mtdids" and "mtdparts" with content of mtdparts_<dev>
> + * update the variables "mtdids" and "mtdparts" with boot, tee and user strings
>   */
>  static void board_get_mtdparts(const char *dev,
>  			       char *mtdids,
> -			       char *mtdparts)
> +			       char *mtdparts,
> +			       const char *boot,
> +			       const char *tee,
> +			       const char *user)
>  {
> -	char env_name[32] = "mtdparts_";
> -	char tmp_mtdparts[MTDPARTS_LEN];
> -	const char *tmp;
> -
> -	/* name of env variable to read = mtdparts_<dev> */
> -	strcat(env_name, dev);
> -	tmp = env_get_mtdparts(env_name, tmp_mtdparts);
> -	if (tmp) {
> -		/* 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);
> -		strncat(mtdparts, tmp, MTDPARTS_LEN);
> +	/* 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);
> +	}
> +
> +	if (CONFIG_IS_ENABLED(STM32MP1_OPTEE) && tee) {
> +		strncat(mtdparts, tee, MTDPARTS_LEN);
> +		strncat(mtdparts, ",", MTDPARTS_LEN);
>  	}
> +
> +	strncat(mtdparts, user, MTDPARTS_LEN);
>  }
>  
>  void board_mtdparts_default(const char **mtdids, const char **mtdparts)
> @@ -76,6 +64,7 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
>  	static char parts[3 * MTDPARTS_LEN + 1];
>  	static char ids[MTDIDS_LEN + 1];
>  	static bool mtd_initialized;
> +	bool tee = false;
>  
>  	if (mtd_initialized) {
>  		*mtdids = ids;
> @@ -83,6 +72,9 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
>  		return;
>  	}
>  
> +	if (CONFIG_IS_ENABLED(STM32MP1_OPTEE))
> +		tee = true;
> +
>  	memset(parts, 0, sizeof(parts));
>  	memset(ids, 0, sizeof(ids));
>  
> @@ -95,18 +87,27 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
>  
>  	mtd = get_mtd_device_nm("nand0");
>  	if (!IS_ERR_OR_NULL(mtd)) {
> -		board_get_mtdparts("nand0", ids, parts);
> +		board_get_mtdparts("nand0", ids, parts,
> +				   CONFIG_MTDPARTS_NAND0_BOOT,
> +				   tee ? CONFIG_MTDPARTS_NAND0_TEE : NULL,
> +				   "-(UBI)");
>  		put_mtd_device(mtd);
>  	}
>  
>  	mtd = get_mtd_device_nm("spi-nand0");
>  	if (!IS_ERR_OR_NULL(mtd)) {
> -		board_get_mtdparts("spi-nand0", ids, parts);
> +		board_get_mtdparts("spi-nand0", ids, parts,
> +				   CONFIG_MTDPARTS_SPINAND0_BOOT,
> +				   tee ? CONFIG_MTDPARTS_SPINAND0_TEE : NULL,
> +				   "-(UBI)");
>  		put_mtd_device(mtd);
>  	}
>  
>  	if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev))
> -		board_get_mtdparts("nor0", ids, parts);
> +		board_get_mtdparts("nor0", ids, parts,
> +				   CONFIG_MTDPARTS_NOR0_BOOT,
> +				   tee ? CONFIG_MTDPARTS_NOR0_TEE : NULL,
> +				   "-(nor_user)");
>  
>  	mtd_initialized = true;
>  	*mtdids = ids;
> diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h
> index a9631d2a92..a80741f6a2 100644
> --- a/include/configs/stm32mp1.h
> +++ b/include/configs/stm32mp1.h
> @@ -149,27 +149,6 @@
>  
>  #include <config_distro_bootcmd.h>
>  
> -#ifdef CONFIG_STM32MP1_OPTEE
> -/* 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_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_spi-nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),-(UBI)\0"
> -
> -#endif /* CONFIG_STM32MP1_OPTEE */
> -
> -#ifndef CONFIG_SYS_MTDPARTS_RUNTIME
> -#undef STM32MP_MTDPARTS
> -#define STM32MP_MTDPARTS
> -#endif
> -
>  /*
>   * memory layout for 32M uncompressed/compressed kernel,
>   * 1M fdt, 1M script, 1M pxe and 1M for splashimage
> @@ -188,7 +167,6 @@
>  	"env_check=if test $env_default -eq 1;"\
>  		" then env set env_default 0;env save;fi\0" \
>  	STM32MP_BOOTCMD \
> -	STM32MP_MTDPARTS \
>  	BOOTENV \
>  	"boot_net_usb_start=true\0"
>  

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

* [Uboot-stm32] [PATCH 10/11] board: stm32mp1: adapt MTD partition for BOOT from NOR or NAND
  2020-03-18  8:22 ` [PATCH 10/11] board: stm32mp1: adapt MTD partition for BOOT from NOR or NAND Patrick Delaunay
@ 2020-04-14  9:28   ` Patrice CHOTARD
  0 siblings, 0 replies; 24+ messages in thread
From: Patrice CHOTARD @ 2020-04-14  9:28 UTC (permalink / raw)
  To: u-boot

Hi

On 3/18/20 9:22 AM, Patrick Delaunay wrote:
> Dynamically adapt the MTD partitions in NAND and SPI-NAND when boot from
> NOR or NAND/SPI-NAND is detected.
>
> This patch avoids to define the save MTD partition name for NOR and NAND
> devices and issue with latest kernel: only the needed MTD partitions
> are defined.
>
> For boot from NOR
> 1/ bootloader (TF-A, U-Boot and OP-TE) in NOR
> 2/ one large UBI partition in NAND
>
> For boot from NAND
> 1/ bootloader (TF-A, U-Boot and OP-TE) in MTD raw partition
> 2/ one large UBI partition
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
>
> # Conflicts:
> #	board/st/common/stm32mp_mtdparts.c
> ---
>
>  board/st/common/stm32mp_mtdparts.c | 81 ++++++++++++++++++++++--------
>  1 file changed, 60 insertions(+), 21 deletions(-)
>
> diff --git a/board/st/common/stm32mp_mtdparts.c b/board/st/common/stm32mp_mtdparts.c
> index 2b6413be16..5028511077 100644
> --- a/board/st/common/stm32mp_mtdparts.c
> +++ b/board/st/common/stm32mp_mtdparts.c
> @@ -10,6 +10,7 @@
>  #include <mtd.h>
>  #include <mtd_node.h>
>  #include <tee.h>
> +#include <asm/arch/sys_proto.h>
>  
>  #define MTDPARTS_LEN		256
>  #define MTDIDS_LEN		128
> @@ -22,7 +23,7 @@ DECLARE_GLOBAL_DATA_PTR;
>  /**
>   * update the variables "mtdids" and "mtdparts" with boot, tee and user strings
>   */
> -static void board_get_mtdparts(const char *dev,
> +static void board_set_mtdparts(const char *dev,
>  			       char *mtdids,
>  			       char *mtdparts,
>  			       const char *boot,
> @@ -65,7 +66,7 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
>  	static char parts[3 * MTDPARTS_LEN + 1];
>  	static char ids[MTDIDS_LEN + 1];
>  	static bool mtd_initialized;
> -	bool tee = false;
> +	bool tee, nor, nand, spinand;
>  
>  	if (mtd_initialized) {
>  		*mtdids = ids;
> @@ -73,6 +74,28 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
>  		return;
>  	}
>  
> +	tee = false;
> +	nor = false;
> +	nand = false;
> +	spinand = false;
> +
> +	switch (get_bootmode() & TAMP_BOOT_DEVICE_MASK) {
> +	case BOOT_SERIAL_UART:
> +	case BOOT_SERIAL_USB:
> +		break;
> +	case BOOT_FLASH_NAND:
> +		nand = true;
> +		break;
> +	case BOOT_FLASH_SPINAND:
> +		spinand = true;
> +		break;
> +	case BOOT_FLASH_NOR:
> +		nor = true;
> +		break;
> +	default:
> +		break;
> +	}
> +
>  	if (CONFIG_IS_ENABLED(OPTEE) &&
>  	    tee_find_device(NULL, NULL, NULL, NULL))
>  		tee = true;
> @@ -87,29 +110,45 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
>  		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,
> -				   CONFIG_MTDPARTS_NAND0_BOOT,
> -				   tee ? CONFIG_MTDPARTS_NAND0_TEE : NULL,
> -				   "-(UBI)");
> -		put_mtd_device(mtd);
> +	if (nor || nand) {
> +		mtd = get_mtd_device_nm("nand0");
> +		if (!IS_ERR_OR_NULL(mtd)) {
> +			const char *mtd_boot = CONFIG_MTDPARTS_NAND0_BOOT;
> +			const char *mtd_tee = CONFIG_MTDPARTS_NAND0_TEE;
> +
> +			board_set_mtdparts("nand0", ids, parts,
> +					   !nor ? mtd_boot : NULL,
> +					   !nor && tee ? mtd_tee : NULL,
> +					   "-(UBI)");
> +			put_mtd_device(mtd);
> +		}
>  	}
>  
> -	mtd = get_mtd_device_nm("spi-nand0");
> -	if (!IS_ERR_OR_NULL(mtd)) {
> -		board_get_mtdparts("spi-nand0", ids, parts,
> -				   CONFIG_MTDPARTS_SPINAND0_BOOT,
> -				   tee ? CONFIG_MTDPARTS_SPINAND0_TEE : NULL,
> -				   "-(UBI)");
> -		put_mtd_device(mtd);
> +	if (nor || spinand) {
> +		mtd = get_mtd_device_nm("spi-nand0");
> +		if (!IS_ERR_OR_NULL(mtd)) {
> +			const char *mtd_boot = CONFIG_MTDPARTS_SPINAND0_BOOT;
> +			const char *mtd_tee = CONFIG_MTDPARTS_SPINAND0_TEE;
> +
> +			board_set_mtdparts("spi-nand0", ids, parts,
> +					   !nor ? mtd_boot : NULL,
> +					   !nor && tee ? mtd_tee : NULL,
> +					   "-(UBI)");
> +			put_mtd_device(mtd);
> +		}
>  	}
>  
> -	if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev))
> -		board_get_mtdparts("nor0", ids, parts,
> -				   CONFIG_MTDPARTS_NOR0_BOOT,
> -				   tee ? CONFIG_MTDPARTS_NOR0_TEE : NULL,
> -				   "-(nor_user)");
> +	if (nor) {
> +		if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev)) {
> +			const char *mtd_boot = CONFIG_MTDPARTS_NOR0_BOOT;
> +			const char *mtd_tee = CONFIG_MTDPARTS_NOR0_TEE;
> +
> +			board_set_mtdparts("nor0", ids, parts,
> +					   mtd_boot,
> +					   tee ? mtd_tee : NULL,
> +					   "-(nor_user)");
> +		}
> +	}
>  
>  	mtd_initialized = true;
>  	*mtdids = ids;


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

Patrice

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

* [PATCH 05/11] board: stm32mp1: reserve memory for OP-TEE in device tree
  2020-03-18  8:22 ` [PATCH 05/11] board: stm32mp1: reserve memory for OP-TEE in device tree Patrick Delaunay
@ 2020-04-14  9:31   ` Patrice CHOTARD
  0 siblings, 0 replies; 24+ messages in thread
From: Patrice CHOTARD @ 2020-04-14  9:31 UTC (permalink / raw)
  To: u-boot

Hi

On 3/18/20 9:22 AM, Patrick Delaunay wrote:
> Add reserve memory for OP-TEE in U-Boot and in kernel device tree:
> - no more reduce the DDR size in "memory" node:
>   CONFIG_SYS_MEM_TOP_HIDE is no more used
> - U-Boot device-tree defines the needed "reserved-memory" for OP-TEE
>   and U-Boot should not use this reserved memory: board_get_usable_ram_top
>   use lmb lib to found the first free region, the not reserved
>   memory, enough to relocate U-Boot: the needed size of U-Boot
>   is estimated with gd->mon_len + CONFIG_SYS_MALLOC_LEN.
> - the optee node ("optee at ...": firmware with compatible "linaro,optee-tz")
>   and the associated "reserved-memory" are deactivated in kernel device
>   tree when OP-TEE is not detected by U-Boot to prevent kernel issue
>   (memory is reserved but not used, optee driver probe failed).
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
> This patch depends on "ARM: bootm: take into account gd->ram_top"
> http://patchwork.ozlabs.org/project/uboot/list/?series=158413
>
>  arch/arm/dts/stm32mp157a-dk1.dts  |  5 +++++
>  arch/arm/dts/stm32mp157c-ed1.dts  |  5 +++++
>  arch/arm/mach-stm32mp/dram_init.c | 18 ++++++++++++++++++
>  arch/arm/mach-stm32mp/fdt.c       | 23 +++++++++++++++++++++++
>  include/configs/stm32mp1.h        |  4 ----
>  5 files changed, 51 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/dts/stm32mp157a-dk1.dts b/arch/arm/dts/stm32mp157a-dk1.dts
> index 624bf6954b..70e7aa2fd7 100644
> --- a/arch/arm/dts/stm32mp157a-dk1.dts
> +++ b/arch/arm/dts/stm32mp157a-dk1.dts
> @@ -74,6 +74,11 @@
>  			reg = <0xd4000000 0x4000000>;
>  			no-map;
>  		};
> +
> +		optee at de000000 {
> +			reg = <0xde000000 0x02000000>;
> +			no-map;
> +		};
>  	};
>  
>  	led {
> diff --git a/arch/arm/dts/stm32mp157c-ed1.dts b/arch/arm/dts/stm32mp157c-ed1.dts
> index ae4da39ce8..27a0d05d82 100644
> --- a/arch/arm/dts/stm32mp157c-ed1.dts
> +++ b/arch/arm/dts/stm32mp157c-ed1.dts
> @@ -68,6 +68,11 @@
>  			reg = <0xe8000000 0x8000000>;
>  			no-map;
>  		};
> +
> +		optee at fe000000 {
> +			reg = <0xfe000000 0x02000000>;
> +			no-map;
> +		};
>  	};
>  
>  	aliases {
> diff --git a/arch/arm/mach-stm32mp/dram_init.c b/arch/arm/mach-stm32mp/dram_init.c
> index 7688b3e315..3233415eff 100644
> --- a/arch/arm/mach-stm32mp/dram_init.c
> +++ b/arch/arm/mach-stm32mp/dram_init.c
> @@ -5,6 +5,7 @@
>  
>  #include <common.h>
>  #include <dm.h>
> +#include <lmb.h>
>  #include <ram.h>
>  
>  DECLARE_GLOBAL_DATA_PTR;
> @@ -31,3 +32,20 @@ int dram_init(void)
>  
>  	return 0;
>  }
> +
> +ulong board_get_usable_ram_top(ulong total_size)
> +{
> +	phys_addr_t reg;
> +	struct lmb lmb;
> +
> +	/* found enough not-reserved memory to relocated U-Boot */
> +	lmb_init(&lmb);
> +	lmb_add(&lmb, gd->ram_base, gd->ram_size);
> +	boot_fdt_add_mem_rsv_regions(&lmb, (void *)gd->fdt_blob);
> +	reg = lmb_alloc(&lmb, CONFIG_SYS_MALLOC_LEN + total_size, SZ_4K);
> +
> +	if (reg)
> +		return ALIGN(reg + CONFIG_SYS_MALLOC_LEN + total_size, SZ_4K);
> +
> +	return gd->ram_top;
> +}
> diff --git a/arch/arm/mach-stm32mp/fdt.c b/arch/arm/mach-stm32mp/fdt.c
> index 3ee7d6a833..ae82270e42 100644
> --- a/arch/arm/mach-stm32mp/fdt.c
> +++ b/arch/arm/mach-stm32mp/fdt.c
> @@ -218,6 +218,26 @@ static void stm32_fdt_disable(void *fdt, int offset, u32 addr,
>  		       string, addr, name);
>  }
>  
> +static void stm32_fdt_disable_optee(void *blob)
> +{
> +	int off, node;
> +
> +	off = fdt_node_offset_by_compatible(blob, -1, "linaro,optee-tz");
> +	if (off >= 0 && fdtdec_get_is_enabled(blob, off))
> +		fdt_status_disabled(blob, off);
> +
> +	/* Disabled "optee at ..." reserved-memory node */
> +	off = fdt_path_offset(blob, "/reserved-memory/");
> +	if (off < 0)
> +		return;
> +	for (node = fdt_first_subnode(blob, off);
> +	     node >= 0;
> +	     node = fdt_next_subnode(blob, node)) {
> +		if (!strncmp(fdt_get_name(blob, node, NULL), "optee@", 6))
> +			fdt_status_disabled(blob, node);
> +	}
> +}
> +
>  /*
>   * This function is called right before the kernel is booted. "blob" is the
>   * device tree that will be passed to the kernel.
> @@ -302,5 +322,8 @@ int ft_system_setup(void *blob, bd_t *bd)
>  				       "st,package", pkg, false);
>  	}
>  
> +	if (!CONFIG_IS_ENABLED(STM32MP1_OPTEE))
> +		stm32_fdt_disable_optee(blob);
> +
>  	return ret;
>  }
> diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h
> index a80741f6a2..c5b09f1a2a 100644
> --- a/include/configs/stm32mp1.h
> +++ b/include/configs/stm32mp1.h
> @@ -23,10 +23,6 @@
>  #define CONFIG_SYS_SDRAM_BASE			STM32_DDR_BASE
>  #define CONFIG_SYS_INIT_SP_ADDR			CONFIG_SYS_TEXT_BASE
>  
> -#ifdef CONFIG_STM32MP1_OPTEE
> -#define CONFIG_SYS_MEM_TOP_HIDE			SZ_32M
> -#endif /* CONFIG_STM32MP1_OPTEE */
> -
>  /*
>   * Console I/O buffer size
>   */

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

Patrice

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

* [PATCH 06/11] stm32mp1: dynamically detect op-tee presence
  2020-03-18  8:22 ` [PATCH 06/11] stm32mp1: dynamically detect op-tee presence Patrick Delaunay
@ 2020-04-14  9:31   ` Patrice CHOTARD
  0 siblings, 0 replies; 24+ messages in thread
From: Patrice CHOTARD @ 2020-04-14  9:31 UTC (permalink / raw)
  To: u-boot

Hi

On 3/18/20 9:22 AM, Patrick Delaunay wrote:
> Activate OP-TEE driver for trusted and optee defconfig.
>
> This driver allows detection of TEE presence for boot from flash;
> CONFIG_STM32MP1_OPTEE is also removed.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
>  arch/arm/mach-stm32mp/Kconfig           | 10 ----------
>  arch/arm/mach-stm32mp/fdt.c             |  4 +++-
>  board/dhelectronics/dh_stm32mp1/board.c |  4 +---
>  board/st/common/stm32mp_mtdparts.c      |  6 ++++--
>  board/st/stm32mp1/stm32mp1.c            |  4 +---
>  configs/stm32mp15_optee_defconfig       |  4 +++-
>  configs/stm32mp15_trusted_defconfig     |  3 +++
>  7 files changed, 15 insertions(+), 20 deletions(-)
>
> diff --git a/arch/arm/mach-stm32mp/Kconfig b/arch/arm/mach-stm32mp/Kconfig
> index 96153693a7..1a5545b98d 100644
> --- a/arch/arm/mach-stm32mp/Kconfig
> +++ b/arch/arm/mach-stm32mp/Kconfig
> @@ -93,16 +93,6 @@ config STM32MP1_TRUSTED
>  		BootRom => TF-A.stm32 (clock & DDR) => U-Boot.stm32
>  		TF-A monitor provides proprietary SMC to manage secure devices
>  
> -config STM32MP1_OPTEE
> -	bool "Support trusted boot with TF-A and OP-TEE"
> -	depends on STM32MP1_TRUSTED
> -	default n
> -	help
> -		Say Y here to enable boot with TF-A and OP-TEE
> -		Trusted boot chain is :
> -		BootRom => TF-A.stm32 (clock & DDR) => OP-TEE => U-Boot.stm32
> -		OP-TEE monitor provides ST SMC to access to secure resources
> -
>  config SYS_TEXT_BASE
>  	default 0xC0100000
>  
> diff --git a/arch/arm/mach-stm32mp/fdt.c b/arch/arm/mach-stm32mp/fdt.c
> index ae82270e42..21b5f09728 100644
> --- a/arch/arm/mach-stm32mp/fdt.c
> +++ b/arch/arm/mach-stm32mp/fdt.c
> @@ -5,6 +5,7 @@
>  
>  #include <common.h>
>  #include <fdt_support.h>
> +#include <tee.h>
>  #include <asm/arch/sys_proto.h>
>  #include <dt-bindings/pinctrl/stm32-pinfunc.h>
>  #include <linux/io.h>
> @@ -322,7 +323,8 @@ int ft_system_setup(void *blob, bd_t *bd)
>  				       "st,package", pkg, false);
>  	}
>  
> -	if (!CONFIG_IS_ENABLED(STM32MP1_OPTEE))
> +	if (!CONFIG_IS_ENABLED(OPTEE) ||
> +	    !tee_find_device(NULL, NULL, NULL, NULL))
>  		stm32_fdt_disable_optee(blob);
>  
>  	return ret;
> diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c
> index bd6540a2aa..ea51b92282 100644
> --- a/board/dhelectronics/dh_stm32mp1/board.c
> +++ b/board/dhelectronics/dh_stm32mp1/board.c
> @@ -117,9 +117,7 @@ int checkboard(void)
>  	const char *fdt_compat;
>  	int fdt_compat_len;
>  
> -	if (IS_ENABLED(CONFIG_STM32MP1_OPTEE))
> -		mode = "trusted with OP-TEE";
> -	else if (IS_ENABLED(CONFIG_STM32MP1_TRUSTED))
> +	if (IS_ENABLED(CONFIG_STM32MP1_TRUSTED))
>  		mode = "trusted";
>  	else
>  		mode = "basic";
> diff --git a/board/st/common/stm32mp_mtdparts.c b/board/st/common/stm32mp_mtdparts.c
> index d4c0a7db9f..2b6413be16 100644
> --- a/board/st/common/stm32mp_mtdparts.c
> +++ b/board/st/common/stm32mp_mtdparts.c
> @@ -9,6 +9,7 @@
>  #include <env_internal.h>
>  #include <mtd.h>
>  #include <mtd_node.h>
> +#include <tee.h>
>  
>  #define MTDPARTS_LEN		256
>  #define MTDIDS_LEN		128
> @@ -49,7 +50,7 @@ static void board_get_mtdparts(const char *dev,
>  		strncat(mtdparts, ",", MTDPARTS_LEN);
>  	}
>  
> -	if (CONFIG_IS_ENABLED(STM32MP1_OPTEE) && tee) {
> +	if (tee) {
>  		strncat(mtdparts, tee, MTDPARTS_LEN);
>  		strncat(mtdparts, ",", MTDPARTS_LEN);
>  	}
> @@ -72,7 +73,8 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
>  		return;
>  	}
>  
> -	if (CONFIG_IS_ENABLED(STM32MP1_OPTEE))
> +	if (CONFIG_IS_ENABLED(OPTEE) &&
> +	    tee_find_device(NULL, NULL, NULL, NULL))
>  		tee = true;
>  
>  	memset(parts, 0, sizeof(parts));
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index 2ab3b5cc9a..14c56a0f24 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -87,9 +87,7 @@ int checkboard(void)
>  	const char *fdt_compat;
>  	int fdt_compat_len;
>  
> -	if (IS_ENABLED(CONFIG_STM32MP1_OPTEE))
> -		mode = "trusted with OP-TEE";
> -	else if (IS_ENABLED(CONFIG_STM32MP1_TRUSTED))
> +	if (CONFIG_IS_ENABLED(STM32MP1_TRUSTED))
>  		mode = "trusted";
>  	else
>  		mode = "basic";
> diff --git a/configs/stm32mp15_optee_defconfig b/configs/stm32mp15_optee_defconfig
> index 317cd55862..f0d524d344 100644
> --- a/configs/stm32mp15_optee_defconfig
> +++ b/configs/stm32mp15_optee_defconfig
> @@ -4,7 +4,6 @@ CONFIG_SYS_MALLOC_F_LEN=0x3000
>  CONFIG_ENV_SECT_SIZE=0x40000
>  CONFIG_ENV_OFFSET=0x280000
>  CONFIG_TARGET_ST_STM32MP15x=y
> -CONFIG_STM32MP1_OPTEE=y
>  CONFIG_ENV_OFFSET_REDUND=0x2C0000
>  CONFIG_DISTRO_DEFAULTS=y
>  CONFIG_FIT=y
> @@ -111,6 +110,9 @@ CONFIG_SPI=y
>  CONFIG_DM_SPI=y
>  CONFIG_STM32_QSPI=y
>  CONFIG_STM32_SPI=y
> +CONFIG_TEE=y
> +CONFIG_OPTEE=y
> +# CONFIG_OPTEE_TA_AVB is not set
>  CONFIG_USB=y
>  CONFIG_DM_USB=y
>  CONFIG_DM_USB_GADGET=y
> diff --git a/configs/stm32mp15_trusted_defconfig b/configs/stm32mp15_trusted_defconfig
> index 73cbe6c7d6..f0d524d344 100644
> --- a/configs/stm32mp15_trusted_defconfig
> +++ b/configs/stm32mp15_trusted_defconfig
> @@ -110,6 +110,9 @@ CONFIG_SPI=y
>  CONFIG_DM_SPI=y
>  CONFIG_STM32_QSPI=y
>  CONFIG_STM32_SPI=y
> +CONFIG_TEE=y
> +CONFIG_OPTEE=y
> +# CONFIG_OPTEE_TA_AVB is not set
>  CONFIG_USB=y
>  CONFIG_DM_USB=y
>  CONFIG_DM_USB_GADGET=y


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

Patrice

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

* [PATCH 07/11] board: stm32mp1: use FDT address provided by TF-A at boot time
  2020-03-18  8:22 ` [PATCH 07/11] board: stm32mp1: use FDT address provided by TF-A at boot time Patrick Delaunay
@ 2020-04-14  9:32   ` Patrice CHOTARD
  0 siblings, 0 replies; 24+ messages in thread
From: Patrice CHOTARD @ 2020-04-14  9:32 UTC (permalink / raw)
  To: u-boot

Hi

On 3/18/20 9:22 AM, Patrick Delaunay wrote:
> Save and use the FDT address provided by TF-A in r2 at boot time
> (it is NT_FW_CONFIG = Non Trusted Firmware configuration file)
>
> Address is saved in save_boot_params(), called by start.S
> and the used DTB is gd->fdt_blob = board_fdt_blob_setup().
>
> If dtb is not provided or invalid, U-Boot use as fallback
> the builtin DTB.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
>  arch/arm/mach-stm32mp/Makefile      |  1 +
>  arch/arm/mach-stm32mp/boot_params.c | 45 +++++++++++++++++++++++++++++
>  2 files changed, 46 insertions(+)
>  create mode 100644 arch/arm/mach-stm32mp/boot_params.c
>
> diff --git a/arch/arm/mach-stm32mp/Makefile b/arch/arm/mach-stm32mp/Makefile
> index eee39c27c3..19ca3b08a5 100644
> --- a/arch/arm/mach-stm32mp/Makefile
> +++ b/arch/arm/mach-stm32mp/Makefile
> @@ -13,6 +13,7 @@ else
>  obj-y += bsec.o
>  obj-$(CONFIG_CMD_STM32KEY) += cmd_stm32key.o
>  obj-$(CONFIG_ARMV7_PSCI) += psci.o
> +obj-$(CONFIG_STM32MP1_TRUSTED) += boot_params.o
>  endif
>  
>  obj-$(CONFIG_$(SPL_)DM_REGULATOR) += pwr_regulator.o
> diff --git a/arch/arm/mach-stm32mp/boot_params.c b/arch/arm/mach-stm32mp/boot_params.c
> new file mode 100644
> index 0000000000..e4351de939
> --- /dev/null
> +++ b/arch/arm/mach-stm32mp/boot_params.c
> @@ -0,0 +1,45 @@
> +// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
> +/*
> + * Copyright (C) 2019, STMicroelectronics - All Rights Reserved
> + */
> +
> +#include <common.h>
> +#include <asm/sections.h>
> +#include <asm/system.h>
> +
> +/*
> + * Force data-section, as .bss will not be valid
> + * when save_boot_params is invoked.
> + */
> +static unsigned long nt_fw_dtb __section(".data");
> +
> +/*
> + * Save the FDT address provided by TF-A in r2 at boot time
> + * This function is called from start.S
> + */
> +void save_boot_params(unsigned long r0, unsigned long r1, unsigned long r2,
> +		      unsigned long r3)
> +{
> +	nt_fw_dtb = r2;
> +
> +	save_boot_params_ret();
> +}
> +
> +/*
> + * Use the saved FDT address provided by TF-A at boot time (NT_FW_CONFIG =
> + * Non Trusted Firmware configuration file) when the pointer is valid
> + */
> +void *board_fdt_blob_setup(void)
> +{
> +	debug("%s: nt_fw_dtb=%lx\n", __func__, nt_fw_dtb);
> +
> +	/* use external device tree only if address is valid */
> +	if (nt_fw_dtb >= STM32_DDR_BASE) {
> +		if (fdt_magic(nt_fw_dtb) == FDT_MAGIC)
> +			return (void *)nt_fw_dtb;
> +		debug("%s: DTB not found.\n", __func__);
> +	}
> +	debug("%s: fall back to builtin DTB, %p\n", __func__, &_end);
> +
> +	return (void *)&_end;
> +}

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

Patrice

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

* [PATCH 08/11] configs: stm32mp1: remove optee defconfig
  2020-03-18  8:22 ` [PATCH 08/11] configs: stm32mp1: remove optee defconfig Patrick Delaunay
@ 2020-04-14  9:32   ` Patrice CHOTARD
  0 siblings, 0 replies; 24+ messages in thread
From: Patrice CHOTARD @ 2020-04-14  9:32 UTC (permalink / raw)
  To: u-boot

Hi

On 3/18/20 9:22 AM, Patrick Delaunay wrote:
> As the op-tee presence is detected by U-boot, the stm32mp15_optee_defconfig
> is identical to stm32mp15_trusted_defconfig and can be removed.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---

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

Patrice


>  board/st/stm32mp1/MAINTAINERS     |   1 -
>  configs/stm32mp15_optee_defconfig | 134 ------------------------------
>  doc/board/st/stm32mp1.rst         |  32 ++-----
>  3 files changed, 7 insertions(+), 160 deletions(-)
>  delete mode 100644 configs/stm32mp15_optee_defconfig
>
> diff --git a/board/st/stm32mp1/MAINTAINERS b/board/st/stm32mp1/MAINTAINERS
> index 2930947716..96c4559033 100644
> --- a/board/st/stm32mp1/MAINTAINERS
> +++ b/board/st/stm32mp1/MAINTAINERS
> @@ -6,6 +6,5 @@ S:	Maintained
>  F:	arch/arm/dts/stm32mp15*
>  F:	board/st/stm32mp1/
>  F:	configs/stm32mp15_basic_defconfig
> -F:	configs/stm32mp15_optee_defconfig
>  F:	configs/stm32mp15_trusted_defconfig
>  F:	include/configs/stm32mp1.h
> diff --git a/configs/stm32mp15_optee_defconfig b/configs/stm32mp15_optee_defconfig
> deleted file mode 100644
> index f0d524d344..0000000000
> --- a/configs/stm32mp15_optee_defconfig
> +++ /dev/null
> @@ -1,134 +0,0 @@
> -CONFIG_ARM=y
> -CONFIG_ARCH_STM32MP=y
> -CONFIG_SYS_MALLOC_F_LEN=0x3000
> -CONFIG_ENV_SECT_SIZE=0x40000
> -CONFIG_ENV_OFFSET=0x280000
> -CONFIG_TARGET_ST_STM32MP15x=y
> -CONFIG_ENV_OFFSET_REDUND=0x2C0000
> -CONFIG_DISTRO_DEFAULTS=y
> -CONFIG_FIT=y
> -CONFIG_BOOTCOMMAND="run bootcmd_stm32mp"
> -CONFIG_SYS_PROMPT="STM32MP> "
> -# CONFIG_CMD_BOOTD is not set
> -# CONFIG_CMD_ELF is not set
> -# CONFIG_CMD_IMI is not set
> -# CONFIG_CMD_XIMG is not set
> -# CONFIG_CMD_EXPORTENV is not set
> -# CONFIG_CMD_IMPORTENV is not set
> -CONFIG_CMD_MEMINFO=y
> -CONFIG_CMD_MEMTEST=y
> -CONFIG_CMD_ADC=y
> -CONFIG_CMD_CLK=y
> -CONFIG_CMD_DFU=y
> -CONFIG_CMD_FUSE=y
> -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_SPI=y
> -CONFIG_CMD_USB=y
> -CONFIG_CMD_USB_MASS_STORAGE=y
> -CONFIG_CMD_BMP=y
> -CONFIG_CMD_CACHE=y
> -CONFIG_CMD_TIME=y
> -CONFIG_CMD_TIMER=y
> -CONFIG_CMD_PMIC=y
> -CONFIG_CMD_REGULATOR=y
> -CONFIG_CMD_EXT4_WRITE=y
> -CONFIG_CMD_MTDPARTS=y
> -CONFIG_CMD_UBI=y
> -CONFIG_DEFAULT_DEVICE_TREE="stm32mp157c-ev1"
> -CONFIG_ENV_IS_NOWHERE=y
> -CONFIG_ENV_IS_IN_EXT4=y
> -CONFIG_ENV_IS_IN_SPI_FLASH=y
> -CONFIG_ENV_IS_IN_UBI=y
> -CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
> -CONFIG_ENV_EXT4_INTERFACE="mmc"
> -CONFIG_ENV_EXT4_DEVICE_AND_PART="0:auto"
> -CONFIG_ENV_EXT4_FILE="/uboot.env"
> -CONFIG_ENV_UBI_PART="UBI"
> -CONFIG_ENV_UBI_VOLUME="uboot_config"
> -CONFIG_ENV_UBI_VOLUME_REDUND="uboot_config_r"
> -CONFIG_SYS_RELOC_GD_ENV_ADDR=y
> -CONFIG_STM32_ADC=y
> -CONFIG_DFU_MMC=y
> -CONFIG_DFU_RAM=y
> -CONFIG_DFU_MTD=y
> -CONFIG_DFU_VIRT=y
> -CONFIG_SET_DFU_ALT_INFO=y
> -CONFIG_USB_FUNCTION_FASTBOOT=y
> -CONFIG_FASTBOOT_BUF_ADDR=0xC0000000
> -CONFIG_FASTBOOT_BUF_SIZE=0x02000000
> -CONFIG_FASTBOOT_USB_DEV=1
> -CONFIG_FASTBOOT_FLASH=y
> -CONFIG_FASTBOOT_FLASH_MMC_DEV=1
> -CONFIG_DM_HWSPINLOCK=y
> -CONFIG_HWSPINLOCK_STM32=y
> -CONFIG_DM_I2C=y
> -CONFIG_SYS_I2C_STM32F7=y
> -CONFIG_LED=y
> -CONFIG_LED_GPIO=y
> -CONFIG_DM_MAILBOX=y
> -CONFIG_STM32_IPCC=y
> -CONFIG_DM_MMC=y
> -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_MTD_SPI_NAND=y
> -CONFIG_DM_SPI_FLASH=y
> -CONFIG_SPI_FLASH_MACRONIX=y
> -CONFIG_SPI_FLASH_SPANSION=y
> -CONFIG_SPI_FLASH_STMICRO=y
> -CONFIG_SPI_FLASH_WINBOND=y
> -# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set
> -CONFIG_SPI_FLASH_MTD=y
> -CONFIG_DM_ETH=y
> -CONFIG_DWC_ETH_QOS=y
> -CONFIG_PHY=y
> -CONFIG_PHY_STM32_USBPHYC=y
> -CONFIG_PINCONF=y
> -CONFIG_PINCTRL_STMFX=y
> -CONFIG_DM_PMIC=y
> -CONFIG_PMIC_STPMIC1=y
> -CONFIG_DM_REGULATOR_FIXED=y
> -CONFIG_DM_REGULATOR_GPIO=y
> -CONFIG_DM_REGULATOR_STM32_VREFBUF=y
> -CONFIG_DM_REGULATOR_STPMIC1=y
> -CONFIG_REMOTEPROC_STM32_COPRO=y
> -CONFIG_DM_RNG=y
> -CONFIG_RNG_STM32MP1=y
> -CONFIG_DM_RTC=y
> -CONFIG_RTC_STM32=y
> -CONFIG_SERIAL_RX_BUFFER=y
> -CONFIG_SPI=y
> -CONFIG_DM_SPI=y
> -CONFIG_STM32_QSPI=y
> -CONFIG_STM32_SPI=y
> -CONFIG_TEE=y
> -CONFIG_OPTEE=y
> -# CONFIG_OPTEE_TA_AVB is not set
> -CONFIG_USB=y
> -CONFIG_DM_USB=y
> -CONFIG_DM_USB_GADGET=y
> -CONFIG_USB_EHCI_HCD=y
> -CONFIG_USB_EHCI_GENERIC=y
> -CONFIG_USB_GADGET=y
> -CONFIG_USB_GADGET_MANUFACTURER="STMicroelectronics"
> -CONFIG_USB_GADGET_VENDOR_NUM=0x0483
> -CONFIG_USB_GADGET_PRODUCT_NUM=0x5720
> -CONFIG_USB_GADGET_DWC2_OTG=y
> -CONFIG_DM_VIDEO=y
> -CONFIG_BACKLIGHT_GPIO=y
> -CONFIG_VIDEO_LCD_ORISETECH_OTM8009A=y
> -CONFIG_VIDEO_LCD_RAYDIUM_RM68200=y
> -CONFIG_VIDEO_STM32=y
> -CONFIG_VIDEO_STM32_DSI=y
> -CONFIG_VIDEO_STM32_MAX_XRES=1280
> -CONFIG_VIDEO_STM32_MAX_YRES=800
> -CONFIG_FDT_FIXUP_PARTITIONS=y
> diff --git a/doc/board/st/stm32mp1.rst b/doc/board/st/stm32mp1.rst
> index b7a0fbfd03..7fccdfbb94 100644
> --- a/doc/board/st/stm32mp1.rst
> +++ b/doc/board/st/stm32mp1.rst
> @@ -80,32 +80,16 @@ defconfig_file : stm32mp15_trusted_defconfig
>      +             +-------------------------+------------+-------+
>      |             |Trusted Firmware-A (TF-A)| U-Boot     | Linux |
>      +-------------+-------------------------+------------+-------+
> -    | TrustZone   |TF-A secure monitor                           |
> +    | TrustZone   |secure monitor                                |
>      +-------------+-------------------------+------------+-------+
>  
>  TF-A performs a full initialization of Secure peripherals and installs a
> -secure monitor (BL32=SPMin).
> +secure monitor, BL32:
>  
> -U-Boot is running in normal world and uses TF-A monitor to access
> -to secure resources.
> -
> -The **Trusted** boot chain with **OP-TEE**
> -``````````````````````````````````````````
> -
> -defconfig_file : stm32mp15_optee_defconfig
> -
> -    +-------------+-------------------------+------------+-------+
> -    |  ROM code   | FSBL                    | SSBL       | OS    |
> -    +             +-------------------------+------------+-------+
> -    |             |Trusted Firmware-A (TF-A)| U-Boot     | Linux |
> -    +-------------+-------------------------+------------+-------+
> -    | TrustZone   |OP-TEE                                        |
> -    +-------------+-------------------------+------------+-------+
> -
> -TF-A performs a full initialization of Secure peripherals and installs OP-TEE
> -from specific partitions (teeh, teed, teex).
> +  * SPMin provided by TF-A or
> +  * OP-TEE from specific partitions (teeh, teed, teex).
>  
> -U-Boot is running in normal world and uses OP-TEE monitor to access
> +U-Boot is running in normal world and uses the secure monitor to access
>  to secure resources.
>  
>  The **Basic** boot chain
> @@ -180,7 +164,6 @@ Build Procedure
>     for example: use one output directory for each configuration::
>  
>     # export KBUILD_OUTPUT=stm32mp15_trusted
> -   # export KBUILD_OUTPUT=stm32mp15_optee
>     # export KBUILD_OUTPUT=stm32mp15_basic
>  
>     you can build outside of code directory::
> @@ -194,7 +177,6 @@ Build Procedure
>     with <defconfig_file>:
>  
>     - For **trusted** boot mode : **stm32mp15_trusted_defconfig**
> -   - For **trusted** with OP-TEE boot mode : **stm32mp15_optee_defconfig**
>     - For basic boot mode: stm32mp15_basic_defconfig
>  
>  5. Configure the device-tree and build the U-Boot image::
> @@ -211,8 +193,8 @@ Build Procedure
>  
>    b) trusted with OP-TEE boot on dk2::
>  
> -      # export KBUILD_OUTPUT=stm32mp15_optee
> -      # make stm32mp15_optee_defconfig
> +      # export KBUILD_OUTPUT=stm32mp15_trusted
> +      # make stm32mp15_trusted_defconfig
>        # make DEVICE_TREE=stm32mp157c-dk2 all
>  
>    c) basic boot on ev1::

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

* [PATCH 09/11] board: stm32mp1: support boot from spi-nand
  2020-03-18  8:22 ` [PATCH 09/11] board: stm32mp1: support boot from spi-nand Patrick Delaunay
@ 2020-04-14  9:33   ` Patrice CHOTARD
  0 siblings, 0 replies; 24+ messages in thread
From: Patrice CHOTARD @ 2020-04-14  9:33 UTC (permalink / raw)
  To: u-boot

Hi

On 3/18/20 9:22 AM, Patrick Delaunay wrote:
> Manage BOOT_FLASH_SPINAND, with boot_device="spi-nand"
> and treat this value in bootcmd_stm32mp.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
>  arch/arm/mach-stm32mp/cpu.c                | 4 ++++
>  arch/arm/mach-stm32mp/include/mach/stm32.h | 3 +++
>  arch/arm/mach-stm32mp/spl.c                | 2 ++
>  board/st/stm32mp1/stm32mp1.c               | 2 ++
>  include/configs/stm32mp1.h                 | 5 +++--
>  5 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/mach-stm32mp/cpu.c b/arch/arm/mach-stm32mp/cpu.c
> index 9aa5794334..e14e3e47f2 100644
> --- a/arch/arm/mach-stm32mp/cpu.c
> +++ b/arch/arm/mach-stm32mp/cpu.c
> @@ -435,6 +435,10 @@ static void setup_boot_mode(void)
>  		env_set("boot_device", "nand");
>  		env_set("boot_instance", "0");
>  		break;
> +	case BOOT_FLASH_SPINAND:
> +		env_set("boot_device", "spi-nand");
> +		env_set("boot_instance", "0");
> +		break;
>  	case BOOT_FLASH_NOR:
>  		env_set("boot_device", "nor");
>  		env_set("boot_instance", "0");
> diff --git a/arch/arm/mach-stm32mp/include/mach/stm32.h b/arch/arm/mach-stm32mp/include/mach/stm32.h
> index 6daf9f7121..a9bd5bdc1b 100644
> --- a/arch/arm/mach-stm32mp/include/mach/stm32.h
> +++ b/arch/arm/mach-stm32mp/include/mach/stm32.h
> @@ -79,6 +79,9 @@ enum boot_device {
>  
>  	BOOT_SERIAL_USB = 0x60,
>  	BOOT_SERIAL_USB_OTG = 0x62,
> +
> +	BOOT_FLASH_SPINAND = 0x70,
> +	BOOT_FLASH_SPINAND_1 = 0x71,
>  };
>  
>  /* TAMP registers */
> diff --git a/arch/arm/mach-stm32mp/spl.c b/arch/arm/mach-stm32mp/spl.c
> index ca4231cd0d..9cd7b418a4 100644
> --- a/arch/arm/mach-stm32mp/spl.c
> +++ b/arch/arm/mach-stm32mp/spl.c
> @@ -39,6 +39,8 @@ u32 spl_boot_device(void)
>  		return BOOT_DEVICE_NAND;
>  	case BOOT_FLASH_NOR_QSPI:
>  		return BOOT_DEVICE_SPI;
> +	case BOOT_FLASH_SPINAND_1:
> +		return BOOT_DEVICE_NONE; /* SPINAND not supported in SPL */
>  	}
>  
>  	return BOOT_DEVICE_MMC1;
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index 14c56a0f24..423be23555 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -789,6 +789,7 @@ enum env_location env_get_location(enum env_operation op, int prio)
>  #endif
>  #ifdef CONFIG_ENV_IS_IN_UBI
>  	case BOOT_FLASH_NAND:
> +	case BOOT_FLASH_SPINAND:
>  		return ENVL_UBI;
>  #endif
>  #ifdef CONFIG_ENV_IS_IN_SPI_FLASH
> @@ -829,6 +830,7 @@ int ft_board_setup(void *blob, bd_t *bd)
>  #ifdef CONFIG_FDT_FIXUP_PARTITIONS
>  	struct node_info nodes[] = {
>  		{ "st,stm32f469-qspi",		MTD_DEV_TYPE_NOR,  },
> +		{ "st,stm32f469-qspi",		MTD_DEV_TYPE_SPINAND},
>  		{ "st,stm32mp15-fmc2",		MTD_DEV_TYPE_NAND, },
>  	};
>  	fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
> diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h
> index c5b09f1a2a..c34a720e0c 100644
> --- a/include/configs/stm32mp1.h
> +++ b/include/configs/stm32mp1.h
> @@ -127,7 +127,7 @@
>   * bootcmd for stm32mp1:
>   * for serial/usb: execute the stm32prog command
>   * for mmc boot (eMMC, SD card), boot only on the same device
> - * for nand boot, boot with on ubifs partition on nand
> + * for nand or spi-nand boot, boot with on ubifs partition on UBI partition
>   * for nor boot, use the default order
>   */
>  #define STM32MP_BOOTCMD "bootcmd_stm32mp=" \
> @@ -138,7 +138,8 @@
>  		"run env_check;" \
>  		"if test ${boot_device} = mmc;" \
>  		"then env set boot_targets \"mmc${boot_instance}\"; fi;" \
> -		"if test ${boot_device} = nand;" \
> +		"if test ${boot_device} = nand ||" \
> +		  " test ${boot_device} = spi-nand ;" \
>  		"then env set boot_targets ubifs0; fi;" \
>  		"run distro_bootcmd;" \
>  	"fi;\0"

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

Patrice

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

* [PATCH 11/11] doc: stm32mp1: update DFU support example
  2020-03-18  8:22 ` [PATCH 11/11] doc: stm32mp1: update DFU support example Patrick Delaunay
@ 2020-04-14  9:34   ` Patrice CHOTARD
  0 siblings, 0 replies; 24+ messages in thread
From: Patrice CHOTARD @ 2020-04-14  9:34 UTC (permalink / raw)
  To: u-boot

Hi

On 3/18/20 9:22 AM, Patrick Delaunay wrote:
> Update stm32mp1 board documentation with new management of MMC and
> MTD partitions and new PID df11.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
>  doc/board/st/stm32mp1.rst | 115 ++++++++++++++++++--------------------
>  1 file changed, 54 insertions(+), 61 deletions(-)
>
> diff --git a/doc/board/st/stm32mp1.rst b/doc/board/st/stm32mp1.rst
> index 7fccdfbb94..41d0206d34 100644
> --- a/doc/board/st/stm32mp1.rst
> +++ b/doc/board/st/stm32mp1.rst
> @@ -518,61 +518,49 @@ On EV1 board, booting from SD card, without OP-TEE::
>    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
> +  dev: eMMC alt: 3 name: mmc0_fsbl1 layout: RAW_ADDR
> +  dev: eMMC alt: 4 name: mmc0_fsbl2 layout: RAW_ADDR
> +  dev: eMMC alt: 5 name: mmc0_ssbl layout: RAW_ADDR
> +  dev: eMMC alt: 6 name: mmc0_bootfs layout: RAW_ADDR
> +  dev: eMMC alt: 7 name: mmc0_vendorfs layout: RAW_ADDR
> +  dev: eMMC alt: 8 name: mmc0_rootfs layout: RAW_ADDR
> +  dev: eMMC alt: 9 name: mmc0_userfs layout: RAW_ADDR
> +  dev: eMMC alt: 10 name: mmc1_boot1 layout: RAW_ADDR
> +  dev: eMMC alt: 11 name: mmc1_boot2 layout: RAW_ADDR
> +  dev: eMMC alt: 12 name: mmc1_ssbl layout: RAW_ADDR
> +  dev: eMMC alt: 13 name: mmc1_bootfs layout: RAW_ADDR
> +  dev: eMMC alt: 14 name: mmc1_vendorfs layout: RAW_ADDR
> +  dev: eMMC alt: 15 name: mmc1_rootfs layout: RAW_ADDR
> +  dev: eMMC alt: 16 name: mmc1_userfs layout: RAW_ADDR
> +  dev: MTD alt: 17 name: nor0 layout: RAW_ADDR
> +  dev: MTD alt: 18 name: nand0 layout: RAW_ADDR
> +  dev: VIRT alt: 19 name: OTP layout: RAW_ADDR
> +  dev: VIRT alt: 20 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"
> +  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=20, name="PMIC", serial="002700333338511934383330"
> +  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=19, name="OTP", serial="002700333338511934383330"
> +  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=18, name="nand0", serial="002700333338511934383330"
> +  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=17, name="nor0", serial="002700333338511934383330"
> +  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=16, name="mmc1_userfs", serial="002700333338511934383330"
> +  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=15, name="mmc1_rootfs", serial="002700333338511934383330"
> +  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=14, name="mmc1_vendorfs", serial="002700333338511934383330"
> +  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=13, name="mmc1_bootfs", serial="002700333338511934383330"
> +  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=12, name="mmc1_ssbl", serial="002700333338511934383330"
> +  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=11, name="mmc1_boot2", serial="002700333338511934383330"
> +  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=10, name="mmc1_boot1", serial="002700333338511934383330"
> +  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=9, name="mmc0_userfs", serial="002700333338511934383330"
> +  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=8, name="mmc0_rootfs", serial="002700333338511934383330"
> +  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=7, name="mmc0_vendorfs", serial="002700333338511934383330"
> +  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=6, name="mmc0_bootfs", serial="002700333338511934383330"
> +  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=5, name="mmc0_ssbl", serial="002700333338511934383330"
> +  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=4, name="mmc0_fsbl2", serial="002700333338511934383330"
> +  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=3, name="mmc0_fsbl1", serial="002700333338511934383330"
> +  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=2, name="uramdisk.image.gz", serial="002700333338511934383330"
> +  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=1, name="devicetree.dtb", serial="002700333338511934383330"
> +  Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=0, name="uImage", serial="002700333338511934383330"
>  
>  You can update the boot device:
>  
> @@ -596,20 +584,25 @@ You can update the boot device:
>    $> 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::
> +- you can also dump the OTP and the PMIC NVM with::
> +
> +  $> dfu-util -d 0483:5720 -a 19 -U otp.bin
> +  $> dfu-util -d 0483:5720 -a 20 -U pmic.bin
> +
>  
> -  $> 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
> +When the board is booting for nor0 or nand0,
> +only the MTD partition on the boot devices are available, for example:
>  
> -- NAND (UBI partition used for NAND only boot or NOR + NAND boot)::
> +- NOR (nor0 = alt 20) & NAND (nand0 = alt 26) ::
>  
>    $> 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 22 -D tf-a-stm32mp157c-ev1-trusted.stm32
>    $> 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
> +  $> dfu-util -d 0483:5720 -a 27 -D st-image-weston-openstlinux-weston-stm32mp1_nand_4_256_multivolume.ubi
>  
> -- you can also dump the OTP and the PMIC NVM with::
> +- NAND (nand0 = alt 21)::
>  
> -  $> dfu-util -d 0483:5720 -a 25 -U otp.bin
> -  $> dfu-util -d 0483:5720 -a 26 -U pmic.bin
> +  $> dfu-util -d 0483:5720 -a 22 -D tf-a-stm32mp157c-ev1-trusted.stm32
> +  $> dfu-util -d 0483:5720 -a 23 -D u-boot-stm32mp157c-ev1-trusted.img
> +  $> dfu-util -d 0483:5720 -a 24 -D u-boot-stm32mp157c-ev1-trusted.img
> +  $> dfu-util -d 0483:5720 -a 25 -D st-image-weston-openstlinux-weston-stm32mp1_nand_4_256_multivolume.ubi


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

Patrice

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

* [PATCH 00/11] stm32mp1: migrate MTD and DFU configuration in Kconfig
  2020-03-18  8:22 [PATCH 00/11] stm32mp1: migrate MTD and DFU configuration in Kconfig Patrick Delaunay
                   ` (10 preceding siblings ...)
  2020-03-18  8:22 ` [PATCH 11/11] doc: stm32mp1: update DFU support example Patrick Delaunay
@ 2020-05-14  9:26 ` Patrick DELAUNAY
  11 siblings, 0 replies; 24+ messages in thread
From: Patrick DELAUNAY @ 2020-05-14  9:26 UTC (permalink / raw)
  To: u-boot

Hi,

> From: Patrick DELAUNAY <patrick.delaunay@st.com>
> Sent: mercredi 18 mars 2020 09:23
> 
> 
> This serie migrate the dynamically build MTD
> (CONFIG_SYS_MTDPARTS_RUNTIME) and the DFU configuration
> (CONFIG_SET_DFU_ALT_INFO) previously based on ENV variables to
> CONFIG_.
> 
> These patches reduce the size of the environment and allow to tune for each
> target with a specific defconfig file.
> 
> This serie also removes the TEE deconfig, replaced by a dynamic detection
> based on op-tee driver probe.
> 
> This serie depends on previous CONFIG migration proposed in
> http://patchwork.ozlabs.org/project/uboot/list/?series=160899
> - configs: migrate CONFIG_SET_DFU_ALT_INFO to defconfigs
> - configs: migrate CONFIG_SYS_MTDPARTS_RUNTIME to defconfigs
> 
> 
> 
> Patrick Delaunay (11):
>   board: stm32mp1: move board_get_mtdparts in st common directory
>   board: stm32mp1: move set_dfu_alt_info in st common directory
>   stm32mp1: dynamically build DFU_ALT_INFO
>   stm32mp1: move MTDPART configuration in Kconfig
>   board: stm32mp1: reserve memory for OP-TEE in device tree
>   stm32mp1: dynamically detect op-tee presence
>   board: stm32mp1: use FDT address provided by TF-A at boot time
>   configs: stm32mp1: remove optee defconfig
>   board: stm32mp1: support boot from spi-nand
>   board: stm32mp1: adapt MTD partition for BOOT from NOR or NAND
>   doc: stm32mp1: update DFU support example
> 
>  arch/arm/dts/stm32mp157a-dk1.dts           |   5 +
>  arch/arm/dts/stm32mp157c-ed1.dts           |   5 +
>  arch/arm/mach-stm32mp/Kconfig              |  10 -
>  arch/arm/mach-stm32mp/Makefile             |   1 +
>  arch/arm/mach-stm32mp/boot_params.c        |  45 ++++
>  arch/arm/mach-stm32mp/cpu.c                |   4 +
>  arch/arm/mach-stm32mp/dram_init.c          |  18 ++
>  arch/arm/mach-stm32mp/fdt.c                |  25 ++
>  arch/arm/mach-stm32mp/include/mach/stm32.h |   3 +
>  arch/arm/mach-stm32mp/spl.c                |   2 +
>  board/dhelectronics/dh_stm32mp1/Kconfig    |   1 +
>  board/dhelectronics/dh_stm32mp1/Makefile   |   3 +
>  board/dhelectronics/dh_stm32mp1/board.c    | 143 +-----------
>  board/st/common/Kconfig                    |  64 ++++++
>  board/st/common/Makefile                   |   5 +
>  board/st/common/stm32mp_dfu.c              | 225 ++++++++++++++++++
>  board/st/common/stm32mp_mtdparts.c         | 157 +++++++++++++
>  board/st/stm32mp1/MAINTAINERS              |   1 -
>  board/st/stm32mp1/stm32mp1.c               | 253 +--------------------
>  configs/stm32mp15_optee_defconfig          | 132 -----------
>  configs/stm32mp15_trusted_defconfig        |   3 +
>  doc/board/st/stm32mp1.rst                  | 147 +++++-------
>  include/configs/stm32mp1.h                 |  64 +-----
>  23 files changed, 634 insertions(+), 682 deletions(-)  create mode 100644
> arch/arm/mach-stm32mp/boot_params.c
>  create mode 100644 board/st/common/stm32mp_dfu.c  create mode 100644
> board/st/common/stm32mp_mtdparts.c
>  delete mode 100644 configs/stm32mp15_optee_defconfig
> 
> --
> 2.17.1

For the serie applied to u-boot-stm/master, thanks!

Regards

Patrick

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

end of thread, other threads:[~2020-05-14  9:26 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-18  8:22 [PATCH 00/11] stm32mp1: migrate MTD and DFU configuration in Kconfig Patrick Delaunay
2020-03-18  8:22 ` [PATCH 01/11] board: stm32mp1: move board_get_mtdparts in st common directory Patrick Delaunay
2020-04-14  9:25   ` [Uboot-stm32] " Patrice CHOTARD
2020-03-18  8:22 ` [PATCH 02/11] board: stm32mp1: move set_dfu_alt_info " Patrick Delaunay
2020-04-14  9:25   ` [Uboot-stm32] " Patrice CHOTARD
2020-03-18  8:22 ` [PATCH 03/11] stm32mp1: dynamically build DFU_ALT_INFO Patrick Delaunay
2020-04-14  9:26   ` [Uboot-stm32] " Patrice CHOTARD
2020-03-18  8:22 ` [PATCH 04/11] stm32mp1: move MTDPART configuration in Kconfig Patrick Delaunay
2020-04-14  9:28   ` [Uboot-stm32] " Patrice CHOTARD
2020-03-18  8:22 ` [PATCH 05/11] board: stm32mp1: reserve memory for OP-TEE in device tree Patrick Delaunay
2020-04-14  9:31   ` Patrice CHOTARD
2020-03-18  8:22 ` [PATCH 06/11] stm32mp1: dynamically detect op-tee presence Patrick Delaunay
2020-04-14  9:31   ` Patrice CHOTARD
2020-03-18  8:22 ` [PATCH 07/11] board: stm32mp1: use FDT address provided by TF-A at boot time Patrick Delaunay
2020-04-14  9:32   ` Patrice CHOTARD
2020-03-18  8:22 ` [PATCH 08/11] configs: stm32mp1: remove optee defconfig Patrick Delaunay
2020-04-14  9:32   ` Patrice CHOTARD
2020-03-18  8:22 ` [PATCH 09/11] board: stm32mp1: support boot from spi-nand Patrick Delaunay
2020-04-14  9:33   ` Patrice CHOTARD
2020-03-18  8:22 ` [PATCH 10/11] board: stm32mp1: adapt MTD partition for BOOT from NOR or NAND Patrick Delaunay
2020-04-14  9:28   ` [Uboot-stm32] " Patrice CHOTARD
2020-03-18  8:22 ` [PATCH 11/11] doc: stm32mp1: update DFU support example Patrick Delaunay
2020-04-14  9:34   ` Patrice CHOTARD
2020-05-14  9:26 ` [PATCH 00/11] stm32mp1: migrate MTD and DFU configuration in Kconfig 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.