public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 00/14] Add saveenv support for STM32MP1
@ 2019-05-10 16:11 Patrice Chotard
  2019-05-10 16:11 ` [U-Boot] [PATCH 01/14] Prepare v2019.07-rc1 Patrice Chotard
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: Patrice Chotard @ 2019-05-10 16:11 UTC (permalink / raw)
  To: u-boot


This series adds saveenv support for STM32MP1 on several boot
devices. STM32MP1 is able to boot on eMMC, sdcard and NOR
(NAND support is not fully supported).

On eMMC and sdcard, environment is saved in EXT4 partition
On NOR, environment is saved in a dedicated partition
On NAND, environment is saved in a UBI volume.

This series:
  - enables NAND and NOR support on ev1 board
  - enables ENV_IS_IN_SPI_FLASH, ENV_IS_IN_UBI, ENV_IS_IN_EXT4
    flags
  - fixes get_mtdparts()
  - allows to override interface, device and partition for ext4
    environment
  - updates rule to set ENV_IS_NOWHERE value
  - introduce ENV_IS_IN_DEVICE


Patrice Chotard (10):
  stm32mp1: support dynamic MTDPARTS
  env: ext4: Allow overriding interface, device and partition
  board: stm32mp1: Add env_ext4_get_dev_part() and env_ext4_get_intf()
  env: allow ENV_IS_NOWHERE with other storage target
  stm32mp1: Add env_get_location()
  mtd: Fix get_mtdparts()
  stm32mp1: Move ENV_SIZE to Kconfig
  configs: stm32mp15: Enable ENV_IS_IN_UBI
  configs: stm32mp15: Enable ENV_IS_SPI_FLASH
  stm32mp1: Update env_get_location for NOR support

Patrick Delaunay (3):
  stm32mp1: activate NAND and NOR support on EV1
  env: enable saveenv command when one CONFIG_ENV_IS_IN is activated
  configs: stm32mp15: Enable ENV_IS_IN_EXT4 and all relative flags

Tom Rini (1):
  Prepare v2019.07-rc1

 Makefile                             |   4 +-
 arch/arm/dts/stm32mp157-pinctrl.dtsi |  44 ++++++++++++
 arch/arm/dts/stm32mp157c-ev1.dts     |  16 +++++
 arch/arm/dts/stm32mp157c.dtsi        |  15 ++++
 arch/arm/mach-stm32mp/Kconfig        |   3 +
 board/st/stm32mp1/stm32mp1.c         | 136 +++++++++++++++++++++++++++++++++++
 cmd/nvedit.c                         |  36 ++++++----
 configs/stm32mp15_basic_defconfig    |  27 +++++++
 configs/stm32mp15_trusted_defconfig  |  27 +++++++
 drivers/mtd/mtd_uboot.c              |   5 +-
 env/Kconfig                          |  20 ++----
 env/ext4.c                           |  34 +++++----
 include/configs/stm32mp1.h           |  24 +++++--
 13 files changed, 340 insertions(+), 51 deletions(-)

-- 
1.9.1

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

* [U-Boot] [PATCH 01/14] Prepare v2019.07-rc1
  2019-05-10 16:11 [U-Boot] [PATCH 00/14] Add saveenv support for STM32MP1 Patrice Chotard
@ 2019-05-10 16:11 ` Patrice Chotard
  2019-05-10 16:11 ` [U-Boot] [PATCH 02/14] stm32mp1: activate NAND and NOR support on EV1 Patrice Chotard
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Patrice Chotard @ 2019-05-10 16:11 UTC (permalink / raw)
  To: u-boot

From: Tom Rini <trini@konsulko.com>

Signed-off-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---

 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index f2c7bb6..d6a6ef1 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,9 @@
 # SPDX-License-Identifier: GPL-2.0+
 
 VERSION = 2019
-PATCHLEVEL = 04
+PATCHLEVEL = 07
 SUBLEVEL =
-EXTRAVERSION =
+EXTRAVERSION = -rc1
 NAME =
 
 # *DOCUMENTATION*
-- 
1.9.1

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

* [U-Boot] [PATCH 02/14] stm32mp1: activate NAND and NOR support on EV1
  2019-05-10 16:11 [U-Boot] [PATCH 00/14] Add saveenv support for STM32MP1 Patrice Chotard
  2019-05-10 16:11 ` [U-Boot] [PATCH 01/14] Prepare v2019.07-rc1 Patrice Chotard
@ 2019-05-10 16:11 ` Patrice Chotard
  2019-05-10 16:11 ` [U-Boot] [PATCH 03/14] stm32mp1: support dynamic MTDPARTS Patrice Chotard
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Patrice Chotard @ 2019-05-10 16:11 UTC (permalink / raw)
  To: u-boot

From: Patrick Delaunay <patrick.delaunay@st.com>

Add the necessary configuration to have NAND and NOR support on ev1 board
for BASIC boot (with SPL) or for TRUSTED boot (with TF-A).

STM32MP> nand info

Device 0: nand0, sector size 256 KiB
  Page size       4096 b
  OOB size         224 b
  Erase size    262144 b
  subpagesize     4096 b
  options     0x00184200
  bbt options 0x00060000

STM32MP> sf probe
SF: Detected mx66l51235l with page size 256 Bytes, erase size 64 KiB, total 64 MiB

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---

 arch/arm/dts/stm32mp157-pinctrl.dtsi | 44 ++++++++++++++++++++++++++++++++++++
 arch/arm/dts/stm32mp157c-ev1.dts     | 16 +++++++++++++
 arch/arm/dts/stm32mp157c.dtsi        | 15 ++++++++++++
 configs/stm32mp15_basic_defconfig    | 17 ++++++++++++++
 configs/stm32mp15_trusted_defconfig  | 17 ++++++++++++++
 include/configs/stm32mp1.h           |  3 +++
 6 files changed, 112 insertions(+)

diff --git a/arch/arm/dts/stm32mp157-pinctrl.dtsi b/arch/arm/dts/stm32mp157-pinctrl.dtsi
index 0aae69b..9d1d386 100644
--- a/arch/arm/dts/stm32mp157-pinctrl.dtsi
+++ b/arch/arm/dts/stm32mp157-pinctrl.dtsi
@@ -210,6 +210,50 @@
 				};
 			};
 
+			fmc_pins_a: fmc-0 {
+				pins1 {
+					pinmux = <STM32_PINMUX('D', 4, AF12)>, /* FMC_NOE */
+						 <STM32_PINMUX('D', 5, AF12)>, /* FMC_NWE */
+						 <STM32_PINMUX('D', 11, AF12)>, /* FMC_A16_FMC_CLE */
+						 <STM32_PINMUX('D', 12, AF12)>, /* FMC_A17_FMC_ALE */
+						 <STM32_PINMUX('D', 14, AF12)>, /* FMC_D0 */
+						 <STM32_PINMUX('D', 15, AF12)>, /* FMC_D1 */
+						 <STM32_PINMUX('D', 0, AF12)>, /* FMC_D2 */
+						 <STM32_PINMUX('D', 1, AF12)>, /* FMC_D3 */
+						 <STM32_PINMUX('E', 7, AF12)>, /* FMC_D4 */
+						 <STM32_PINMUX('E', 8, AF12)>, /* FMC_D5 */
+						 <STM32_PINMUX('E', 9, AF12)>, /* FMC_D6 */
+						 <STM32_PINMUX('E', 10, AF12)>, /* FMC_D7 */
+						 <STM32_PINMUX('G', 9, AF12)>; /* FMC_NE2_FMC_NCE */
+					bias-disable;
+					drive-push-pull;
+					slew-rate = <1>;
+				};
+				pins2 {
+					pinmux = <STM32_PINMUX('D', 6, AF12)>; /* FMC_NWAIT */
+					bias-pull-up;
+				};
+			};
+
+			fmc_sleep_pins_a: fmc-sleep-0 {
+				pins {
+					pinmux = <STM32_PINMUX('D', 4, ANALOG)>, /* FMC_NOE */
+						 <STM32_PINMUX('D', 5, ANALOG)>, /* FMC_NWE */
+						 <STM32_PINMUX('D', 11, ANALOG)>, /* FMC_A16_FMC_CLE */
+						 <STM32_PINMUX('D', 12, ANALOG)>, /* FMC_A17_FMC_ALE */
+						 <STM32_PINMUX('D', 14, ANALOG)>, /* FMC_D0 */
+						 <STM32_PINMUX('D', 15, ANALOG)>, /* FMC_D1 */
+						 <STM32_PINMUX('D', 0, ANALOG)>, /* FMC_D2 */
+						 <STM32_PINMUX('D', 1, ANALOG)>, /* FMC_D3 */
+						 <STM32_PINMUX('E', 7, ANALOG)>, /* FMC_D4 */
+						 <STM32_PINMUX('E', 8, ANALOG)>, /* FMC_D5 */
+						 <STM32_PINMUX('E', 9, ANALOG)>, /* FMC_D6 */
+						 <STM32_PINMUX('E', 10, ANALOG)>, /* FMC_D7 */
+						 <STM32_PINMUX('D', 6, ANALOG)>, /* FMC_NWAIT */
+						 <STM32_PINMUX('G', 9, ANALOG)>; /* FMC_NE2_FMC_NCE */
+				};
+			};
+
 			i2c1_pins_a: i2c1-0 {
 				pins {
 					pinmux = <STM32_PINMUX('D', 12, AF5)>, /* I2C1_SCL */
diff --git a/arch/arm/dts/stm32mp157c-ev1.dts b/arch/arm/dts/stm32mp157c-ev1.dts
index a6ee379..69980ca 100644
--- a/arch/arm/dts/stm32mp157c-ev1.dts
+++ b/arch/arm/dts/stm32mp157c-ev1.dts
@@ -92,6 +92,22 @@
 	};
 };
 
+&fmc {
+	pinctrl-names = "default", "sleep";
+	pinctrl-0 = <&fmc_pins_a>;
+	pinctrl-1 = <&fmc_sleep_pins_a>;
+	status = "okay";
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	nand: nand at 0 {
+		reg = <0>;
+		nand-on-flash-bbt;
+		#address-cells = <1>;
+		#size-cells = <1>;
+	};
+};
+
 &i2c2 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&i2c2_pins_a>;
diff --git a/arch/arm/dts/stm32mp157c.dtsi b/arch/arm/dts/stm32mp157c.dtsi
index 9463433..dd0f4e8 100644
--- a/arch/arm/dts/stm32mp157c.dtsi
+++ b/arch/arm/dts/stm32mp157c.dtsi
@@ -1033,6 +1033,21 @@
 			dma-requests = <48>;
 		};
 
+		fmc: nand-controller at 58002000 {
+			compatible = "st,stm32mp15-fmc2";
+			reg = <0x58002000 0x1000>,
+			      <0x80000000 0x1000>,
+			      <0x88010000 0x1000>,
+			      <0x88020000 0x1000>,
+			      <0x81000000 0x1000>,
+			      <0x89010000 0x1000>,
+			      <0x89020000 0x1000>;
+			interrupts = <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&rcc FMC_K>;
+			resets = <&rcc FMC_R>;
+			stafmctus = "disabled";
+		};
+
 		qspi: spi at 58003000 {
 			compatible = "st,stm32f469-qspi";
 			reg = <0x58003000 0x1000>, <0x70000000 0x10000000>;
diff --git a/configs/stm32mp15_basic_defconfig b/configs/stm32mp15_basic_defconfig
index bd75df8..f5e13dd 100644
--- a/configs/stm32mp15_basic_defconfig
+++ b/configs/stm32mp15_basic_defconfig
@@ -29,6 +29,7 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_SF=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_CACHE=y
@@ -37,6 +38,7 @@ CONFIG_CMD_TIMER=y
 CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
+CONFIG_CMD_MTDPARTS=y
 # CONFIG_SPL_DOS_PARTITION is not set
 CONFIG_DEFAULT_DEVICE_TREE="stm32mp157c-ev1"
 CONFIG_STM32_ADC=y
@@ -54,6 +56,18 @@ CONFIG_LED=y
 CONFIG_LED_GPIO=y
 CONFIG_DM_MMC=y
 CONFIG_STM32_SDMMC2=y
+CONFIG_MTD=y
+CONFIG_NAND=y
+CONFIG_NAND_STM32_FMC2=y
+CONFIG_DM_SPI_FLASH=y
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_BAR=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_PHY=y
 CONFIG_PHY_STM32_USBPHYC=y
 CONFIG_PINCONF=y
@@ -68,6 +82,9 @@ CONFIG_DM_REGULATOR_STM32_VREFBUF=y
 CONFIG_DM_REGULATOR_STPMIC1=y
 CONFIG_SERIAL_RX_BUFFER=y
 CONFIG_STM32_SERIAL=y
+CONFIG_SPI=y
+CONFIG_DM_SPI=y
+CONFIG_STM32_QSPI=y
 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 f82b770..cae3324 100644
--- a/configs/stm32mp15_trusted_defconfig
+++ b/configs/stm32mp15_trusted_defconfig
@@ -22,6 +22,7 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_SF=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_CACHE=y
@@ -30,6 +31,7 @@ CONFIG_CMD_TIMER=y
 CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
+CONFIG_CMD_MTDPARTS=y
 CONFIG_DEFAULT_DEVICE_TREE="stm32mp157c-ev1"
 CONFIG_STM32_ADC=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
@@ -46,6 +48,18 @@ CONFIG_LED=y
 CONFIG_LED_GPIO=y
 CONFIG_DM_MMC=y
 CONFIG_STM32_SDMMC2=y
+CONFIG_MTD=y
+CONFIG_NAND=y
+CONFIG_NAND_STM32_FMC2=y
+CONFIG_DM_SPI_FLASH=y
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_BAR=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_PHY=y
 CONFIG_PHY_STM32_USBPHYC=y
 CONFIG_PINCONF=y
@@ -58,6 +72,9 @@ CONFIG_DM_REGULATOR_STM32_VREFBUF=y
 CONFIG_DM_REGULATOR_STPMIC1=y
 CONFIG_SERIAL_RX_BUFFER=y
 CONFIG_STM32_SERIAL=y
+CONFIG_SPI=y
+CONFIG_DM_SPI=y
+CONFIG_STM32_QSPI=y
 CONFIG_USB=y
 CONFIG_DM_USB=y
 CONFIG_DM_USB_GADGET=y
diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h
index 3069373..a28b8b3 100644
--- a/include/configs/stm32mp1.h
+++ b/include/configs/stm32mp1.h
@@ -85,6 +85,9 @@
 
 #if !defined(CONFIG_SPL_BUILD)
 
+/* NAND support */
+#define CONFIG_SYS_NAND_ONFI_DETECTION
+#define CONFIG_SYS_MAX_NAND_DEVICE	1
 #define BOOT_TARGET_DEVICES(func) \
 	func(MMC, mmc, 1) \
 	func(MMC, mmc, 0) \
-- 
1.9.1

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

* [U-Boot] [PATCH 03/14] stm32mp1: support dynamic MTDPARTS
  2019-05-10 16:11 [U-Boot] [PATCH 00/14] Add saveenv support for STM32MP1 Patrice Chotard
  2019-05-10 16:11 ` [U-Boot] [PATCH 01/14] Prepare v2019.07-rc1 Patrice Chotard
  2019-05-10 16:11 ` [U-Boot] [PATCH 02/14] stm32mp1: activate NAND and NOR support on EV1 Patrice Chotard
@ 2019-05-10 16:11 ` Patrice Chotard
  2019-05-10 16:11 ` [U-Boot] [PATCH 04/14] env: ext4: Allow overriding interface, device and partition Patrice Chotard
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Patrice Chotard @ 2019-05-10 16:11 UTC (permalink / raw)
  To: u-boot

This patch configure the default value for mtdids and mtparts
dynamically according the presence of nor and nand in
the board device tree

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Signed-off-by: Christophe Kerello <christophe.kerello@st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---

 board/st/stm32mp1/stm32mp1.c | 85 ++++++++++++++++++++++++++++++++++++++++++++
 include/configs/stm32mp1.h   |  9 +++++
 2 files changed, 94 insertions(+)

diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 76917b0..360b0df 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -504,3 +504,88 @@ void board_quiesce_devices(void)
 {
 	setup_led(LEDST_OFF);
 }
+
+#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[2 * 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));
+
+	if (!uclass_get_device(UCLASS_MTD, 0, &dev))
+		board_get_mtdparts("nand0", ids, parts);
+
+	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
diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h
index a28b8b3..254aad1 100644
--- a/include/configs/stm32mp1.h
+++ b/include/configs/stm32mp1.h
@@ -115,6 +115,14 @@
 
 #include <config_distro_bootcmd.h>
 
+#if defined(CONFIG_STM32_QSPI) || defined(CONFIG_NAND_STM32_FMC)
+#define CONFIG_SYS_MTDPARTS_RUNTIME
+#endif
+
+#define STM32MP_MTDPARTS \
+	"mtdparts_nor0=256k(fsbl1),256k(fsbl2),2m(ssbl),-(nor_user)\0" \
+	"mtdparts_nand0=2m(fsbl),2m(ssbl),-(UBI)\0"
+
 /*
  * memory layout for 32M uncompressed/compressed kernel,
  * 1M fdt, 1M script, 1M pxe and 1M for splashimage
@@ -130,6 +138,7 @@
 	"fdt_high=0xffffffff\0" \
 	"initrd_high=0xffffffff\0" \
 	STM32MP_BOOTCMD \
+	STM32MP_MTDPARTS \
 	BOOTENV
 
 #endif /* ifndef CONFIG_SPL_BUILD */
-- 
1.9.1

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

* [U-Boot] [PATCH 04/14] env: ext4: Allow overriding interface, device and partition
  2019-05-10 16:11 [U-Boot] [PATCH 00/14] Add saveenv support for STM32MP1 Patrice Chotard
                   ` (2 preceding siblings ...)
  2019-05-10 16:11 ` [U-Boot] [PATCH 03/14] stm32mp1: support dynamic MTDPARTS Patrice Chotard
@ 2019-05-10 16:11 ` Patrice Chotard
  2019-05-10 16:11 ` [U-Boot] [PATCH 05/14] board: stm32mp1: Add env_ext4_get_dev_part() and env_ext4_get_intf() Patrice Chotard
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Patrice Chotard @ 2019-05-10 16:11 UTC (permalink / raw)
  To: u-boot

For platform which can boot on different device, this allows
to override interface, device and partition from board code.

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

 env/ext4.c | 34 +++++++++++++++++++++-------------
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/env/ext4.c b/env/ext4.c
index 388474a..9947381 100644
--- a/env/ext4.c
+++ b/env/ext4.c
@@ -30,6 +30,16 @@
 #include <ext4fs.h>
 #include <mmc.h>
 
+__weak const char *env_ext4_get_intf(void)
+{
+	return (const char *)CONFIG_ENV_EXT4_INTERFACE;
+}
+
+__weak const char *env_ext4_get_dev_part(void)
+{
+	return (const char *)CONFIG_ENV_EXT4_DEVICE_AND_PART;
+}
+
 #ifdef CONFIG_CMD_SAVEENV
 static int env_ext4_save(void)
 {
@@ -38,13 +48,14 @@ static int env_ext4_save(void)
 	disk_partition_t info;
 	int dev, part;
 	int err;
+	const char *ifname = env_ext4_get_intf();
+	const char *dev_and_part = env_ext4_get_dev_part();
 
 	err = env_export(&env_new);
 	if (err)
 		return err;
 
-	part = blk_get_device_part_str(CONFIG_ENV_EXT4_INTERFACE,
-				       CONFIG_ENV_EXT4_DEVICE_AND_PART,
+	part = blk_get_device_part_str(ifname, dev_and_part,
 				       &dev_desc, &info, 1);
 	if (part < 0)
 		return 1;
@@ -54,8 +65,7 @@ static int env_ext4_save(void)
 
 	if (!ext4fs_mount(info.size)) {
 		printf("\n** Unable to use %s %s for saveenv **\n",
-		       CONFIG_ENV_EXT4_INTERFACE,
-		       CONFIG_ENV_EXT4_DEVICE_AND_PART);
+		       ifname, dev_and_part);
 		return 1;
 	}
 
@@ -65,8 +75,7 @@ static int env_ext4_save(void)
 
 	if (err == -1) {
 		printf("\n** Unable to write \"%s\" from %s%d:%d **\n",
-			CONFIG_ENV_EXT4_FILE, CONFIG_ENV_EXT4_INTERFACE, dev,
-			part);
+			CONFIG_ENV_EXT4_FILE, ifname, dev, part);
 		return 1;
 	}
 
@@ -83,14 +92,15 @@ static int env_ext4_load(void)
 	int dev, part;
 	int err;
 	loff_t off;
+	const char *ifname = env_ext4_get_intf();
+	const char *dev_and_part = env_ext4_get_dev_part();
 
 #ifdef CONFIG_MMC
-	if (!strcmp(CONFIG_ENV_EXT4_INTERFACE, "mmc"))
+	if (!strcmp(ifname, "mmc"))
 		mmc_initialize(NULL);
 #endif
 
-	part = blk_get_device_part_str(CONFIG_ENV_EXT4_INTERFACE,
-				       CONFIG_ENV_EXT4_DEVICE_AND_PART,
+	part = blk_get_device_part_str(ifname, dev_and_part,
 				       &dev_desc, &info, 1);
 	if (part < 0)
 		goto err_env_relocate;
@@ -100,8 +110,7 @@ static int env_ext4_load(void)
 
 	if (!ext4fs_mount(info.size)) {
 		printf("\n** Unable to use %s %s for loading the env **\n",
-		       CONFIG_ENV_EXT4_INTERFACE,
-		       CONFIG_ENV_EXT4_DEVICE_AND_PART);
+		       ifname, dev_and_part);
 		goto err_env_relocate;
 	}
 
@@ -111,8 +120,7 @@ static int env_ext4_load(void)
 
 	if (err == -1) {
 		printf("\n** Unable to read \"%s\" from %s%d:%d **\n",
-			CONFIG_ENV_EXT4_FILE, CONFIG_ENV_EXT4_INTERFACE, dev,
-			part);
+			CONFIG_ENV_EXT4_FILE, ifname, dev, part);
 		goto err_env_relocate;
 	}
 
-- 
1.9.1

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

* [U-Boot] [PATCH 05/14] board: stm32mp1: Add env_ext4_get_dev_part() and env_ext4_get_intf()
  2019-05-10 16:11 [U-Boot] [PATCH 00/14] Add saveenv support for STM32MP1 Patrice Chotard
                   ` (3 preceding siblings ...)
  2019-05-10 16:11 ` [U-Boot] [PATCH 04/14] env: ext4: Allow overriding interface, device and partition Patrice Chotard
@ 2019-05-10 16:11 ` Patrice Chotard
  2019-05-10 16:11 ` [U-Boot] [PATCH 06/14] env: allow ENV_IS_NOWHERE with other storage target Patrice Chotard
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Patrice Chotard @ 2019-05-10 16:11 UTC (permalink / raw)
  To: u-boot

This allows to :
- select the current device to save the environment file
- select the correct EXT4 boot device instance
  and partition to save the environment file.

For EXT4, device is mmc, device instance is 0 for sdcard or 1 for eMMC.
The partition is set to "auto" to select the first partition with
bootable flag.

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

 board/st/stm32mp1/stm32mp1.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 360b0df..316cd48 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -19,6 +19,7 @@
 #include <asm/io.h>
 #include <asm/gpio.h>
 #include <asm/arch/stm32.h>
+#include <asm/arch/sys_proto.h>
 #include <power/regulator.h>
 #include <usb/dwc2_udc.h>
 
@@ -505,6 +506,29 @@ void board_quiesce_devices(void)
 	setup_led(LEDST_OFF);
 }
 
+#if defined(CONFIG_ENV_IS_IN_EXT4)
+const char *env_ext4_get_intf(void)
+{
+	u32 bootmode = get_bootmode();
+
+	switch (bootmode & TAMP_BOOT_DEVICE_MASK) {
+	case BOOT_FLASH_SD:
+	case BOOT_FLASH_EMMC:
+		return "mmc";
+	default:
+		return "";
+	}
+}
+
+const char *env_ext4_get_dev_part(void)
+{
+	static char *const dev_part[] = {"0:auto", "1:auto", "2:auto"};
+	u32 bootmode = get_bootmode();
+
+	return dev_part[(bootmode & TAMP_BOOT_INSTANCE_MASK) - 1];
+}
+#endif
+
 #ifdef CONFIG_SYS_MTDPARTS_RUNTIME
 
 #define MTDPARTS_LEN		256
-- 
1.9.1

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

* [U-Boot] [PATCH 06/14] env: allow ENV_IS_NOWHERE with other storage target
  2019-05-10 16:11 [U-Boot] [PATCH 00/14] Add saveenv support for STM32MP1 Patrice Chotard
                   ` (4 preceding siblings ...)
  2019-05-10 16:11 ` [U-Boot] [PATCH 05/14] board: stm32mp1: Add env_ext4_get_dev_part() and env_ext4_get_intf() Patrice Chotard
@ 2019-05-10 16:11 ` Patrice Chotard
  2019-05-10 16:11 ` [U-Boot] [PATCH 07/14] env: enable saveenv command when one CONFIG_ENV_IS_IN is activated Patrice Chotard
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Patrice Chotard @ 2019-05-10 16:11 UTC (permalink / raw)
  To: u-boot

Allow U-Boot to get default environment for some boot mode
(USB for example), and to select storage location when it is
booting from flash device;
ENVL_NOWHERE is present in env_locations with other one.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---

 env/Kconfig | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/env/Kconfig b/env/Kconfig
index 7830066..ca889cc 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -2,18 +2,12 @@ menu "Environment"
 
 config ENV_IS_NOWHERE
 	bool "Environment is not stored"
-	depends on !ENV_IS_IN_EEPROM
-	depends on !ENV_IS_IN_EXT4
-	depends on !ENV_IS_IN_FAT
-	depends on !ENV_IS_IN_FLASH
-	depends on !ENV_IS_IN_MMC
-	depends on !ENV_IS_IN_NAND
-	depends on !ENV_IS_IN_NVRAM
-	depends on !ENV_IS_IN_ONENAND
-	depends on !ENV_IS_IN_REMOTE
-	depends on !ENV_IS_IN_SPI_FLASH
-	depends on !ENV_IS_IN_UBI
-	default y
+	default y if !ENV_IS_IN_EEPROM && !ENV_IS_IN_EXT4 && \
+		     !ENV_IS_IN_FAT && !ENV_IS_IN_FLASH && \
+		     !ENV_IS_IN_MMC && !ENV_IS_IN_NAND && \
+		     !ENV_IS_IN_NVRAM && !ENV_IS_IN_ONENAND && \
+		     !ENV_IS_IN_REMOTE && !ENV_IS_IN_SPI_FLASH && \
+		     !ENV_IS_IN_UBI
 	help
 	  Define this if you don't want to or can't have an environment stored
 	  on a storage medium. In this case the environment will still exist
-- 
1.9.1

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

* [U-Boot] [PATCH 07/14] env: enable saveenv command when one CONFIG_ENV_IS_IN is activated
  2019-05-10 16:11 [U-Boot] [PATCH 00/14] Add saveenv support for STM32MP1 Patrice Chotard
                   ` (5 preceding siblings ...)
  2019-05-10 16:11 ` [U-Boot] [PATCH 06/14] env: allow ENV_IS_NOWHERE with other storage target Patrice Chotard
@ 2019-05-10 16:11 ` Patrice Chotard
  2019-05-10 16:11 ` [U-Boot] [PATCH 08/14] configs: stm32mp15: Enable ENV_IS_IN_EXT4 and all relative flags Patrice Chotard
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Patrice Chotard @ 2019-05-10 16:11 UTC (permalink / raw)
  To: u-boot

From: Patrick Delaunay <patrick.delaunay@st.com>

Introduce ENV_IS_IN_DEVICE to test if one the
CONFIG_ENV_IS_IN_ is defined and support the command
saveenv even if CONFIG_ENV_IS_NOWHERE is activated

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---

 cmd/nvedit.c | 36 +++++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 24a6cf7..5d723ac 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -39,18 +39,24 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if	!defined(CONFIG_ENV_IS_IN_EEPROM)	&& \
-	!defined(CONFIG_ENV_IS_IN_FLASH)	&& \
-	!defined(CONFIG_ENV_IS_IN_MMC)		&& \
-	!defined(CONFIG_ENV_IS_IN_FAT)		&& \
-	!defined(CONFIG_ENV_IS_IN_EXT4)		&& \
-	!defined(CONFIG_ENV_IS_IN_NAND)		&& \
-	!defined(CONFIG_ENV_IS_IN_NVRAM)	&& \
-	!defined(CONFIG_ENV_IS_IN_ONENAND)	&& \
-	!defined(CONFIG_ENV_IS_IN_SATA)		&& \
-	!defined(CONFIG_ENV_IS_IN_SPI_FLASH)	&& \
-	!defined(CONFIG_ENV_IS_IN_REMOTE)	&& \
-	!defined(CONFIG_ENV_IS_IN_UBI)		&& \
+#if	defined(CONFIG_ENV_IS_IN_EEPROM)	|| \
+	defined(CONFIG_ENV_IS_IN_FLASH)		|| \
+	defined(CONFIG_ENV_IS_IN_MMC)		|| \
+	defined(CONFIG_ENV_IS_IN_FAT)		|| \
+	defined(CONFIG_ENV_IS_IN_EXT4)		|| \
+	defined(CONFIG_ENV_IS_IN_NAND)		|| \
+	defined(CONFIG_ENV_IS_IN_NVRAM)		|| \
+	defined(CONFIG_ENV_IS_IN_ONENAND)	|| \
+	defined(CONFIG_ENV_IS_IN_SATA)		|| \
+	defined(CONFIG_ENV_IS_IN_SPI_FLASH)	|| \
+	defined(CONFIG_ENV_IS_IN_REMOTE)	|| \
+	defined(CONFIG_ENV_IS_IN_UBI)
+
+#define ENV_IS_IN_DEVICE
+
+#endif
+
+#if	!defined(ENV_IS_IN_DEVICE)		&& \
 	!defined(CONFIG_ENV_IS_NOWHERE)
 # error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|MMC|FAT|EXT4|\
 NAND|NVRAM|ONENAND|SATA|SPI_FLASH|REMOTE|UBI} or CONFIG_ENV_IS_NOWHERE
@@ -749,7 +755,7 @@ ulong env_get_ulong(const char *name, int base, ulong default_val)
 }
 
 #ifndef CONFIG_SPL_BUILD
-#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
+#if defined(CONFIG_CMD_SAVEENV) && defined(ENV_IS_IN_DEVICE)
 static int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc,
 		       char * const argv[])
 {
@@ -1205,7 +1211,7 @@ static cmd_tbl_t cmd_env_sub[] = {
 #if defined(CONFIG_CMD_RUN)
 	U_BOOT_CMD_MKENT(run, CONFIG_SYS_MAXARGS, 1, do_run, "", ""),
 #endif
-#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
+#if defined(CONFIG_CMD_SAVEENV) && defined(ENV_IS_IN_DEVICE)
 	U_BOOT_CMD_MKENT(save, 1, 0, do_env_save, "", ""),
 #endif
 	U_BOOT_CMD_MKENT(set, CONFIG_SYS_MAXARGS, 0, do_env_set, "", ""),
@@ -1280,7 +1286,7 @@ static char env_help_text[] =
 #if defined(CONFIG_CMD_RUN)
 	"env run var [...] - run commands in an environment variable\n"
 #endif
-#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
+#if defined(CONFIG_CMD_SAVEENV) && defined(ENV_IS_IN_DEVICE)
 	"env save - save environment\n"
 #endif
 #if defined(CONFIG_CMD_NVEDIT_EFI)
-- 
1.9.1

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

* [U-Boot] [PATCH 08/14] configs: stm32mp15: Enable ENV_IS_IN_EXT4 and all relative flags
  2019-05-10 16:11 [U-Boot] [PATCH 00/14] Add saveenv support for STM32MP1 Patrice Chotard
                   ` (6 preceding siblings ...)
  2019-05-10 16:11 ` [U-Boot] [PATCH 07/14] env: enable saveenv command when one CONFIG_ENV_IS_IN is activated Patrice Chotard
@ 2019-05-10 16:11 ` Patrice Chotard
  2019-05-10 16:11 ` [U-Boot] [PATCH 09/14] stm32mp1: Add env_get_location() Patrice Chotard
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Patrice Chotard @ 2019-05-10 16:11 UTC (permalink / raw)
  To: u-boot

From: Patrick Delaunay <patrick.delaunay@st.com>

Enable ENV_IS_IN_EXT4 and all relative flags to be able to
load/save environment in EXT4 partition.

This will allows to load/save environment on both sdcard and eMMC.
As for stm32mp15, bootfs has not the same partition number on sdcard
and on eMMC, we use "auto" key which allows to find the first
partition in device with bootable flag which is partition 4 on sdcard
and partition 2 on eMMC.

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

 configs/stm32mp15_basic_defconfig   | 5 +++++
 configs/stm32mp15_trusted_defconfig | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/configs/stm32mp15_basic_defconfig b/configs/stm32mp15_basic_defconfig
index f5e13dd..051c1de 100644
--- a/configs/stm32mp15_basic_defconfig
+++ b/configs/stm32mp15_basic_defconfig
@@ -41,6 +41,11 @@ CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_MTDPARTS=y
 # CONFIG_SPL_DOS_PARTITION is not set
 CONFIG_DEFAULT_DEVICE_TREE="stm32mp157c-ev1"
+CONFIG_ENV_IS_NOWHERE=y
+CONFIG_ENV_IS_IN_EXT4=y
+CONFIG_ENV_EXT4_INTERFACE="mmc"
+CONFIG_ENV_EXT4_DEVICE_AND_PART="0:auto"
+CONFIG_ENV_EXT4_FILE="/uboot.env"
 CONFIG_STM32_ADC=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0xC0000000
diff --git a/configs/stm32mp15_trusted_defconfig b/configs/stm32mp15_trusted_defconfig
index cae3324..f09f0e4 100644
--- a/configs/stm32mp15_trusted_defconfig
+++ b/configs/stm32mp15_trusted_defconfig
@@ -33,6 +33,11 @@ CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_MTDPARTS=y
 CONFIG_DEFAULT_DEVICE_TREE="stm32mp157c-ev1"
+CONFIG_ENV_IS_NOWHERE=y
+CONFIG_ENV_IS_IN_EXT4=y
+CONFIG_ENV_EXT4_INTERFACE="mmc"
+CONFIG_ENV_EXT4_DEVICE_AND_PART="0:auto"
+CONFIG_ENV_EXT4_FILE="/uboot.env"
 CONFIG_STM32_ADC=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0xC0000000
-- 
1.9.1

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

* [U-Boot] [PATCH 09/14] stm32mp1: Add env_get_location()
  2019-05-10 16:11 [U-Boot] [PATCH 00/14] Add saveenv support for STM32MP1 Patrice Chotard
                   ` (7 preceding siblings ...)
  2019-05-10 16:11 ` [U-Boot] [PATCH 08/14] configs: stm32mp15: Enable ENV_IS_IN_EXT4 and all relative flags Patrice Chotard
@ 2019-05-10 16:11 ` Patrice Chotard
  2019-05-10 16:11 ` [U-Boot] [PATCH 10/14] mtd: Fix get_mtdparts() Patrice Chotard
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Patrice Chotard @ 2019-05-10 16:11 UTC (permalink / raw)
  To: u-boot

In case of several environment location support, env_get_location
is needed to select the correct location depending of the boot
device .

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

 board/st/stm32mp1/stm32mp1.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 316cd48..4f7d24a 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -7,6 +7,7 @@
 #include <config.h>
 #include <clk.h>
 #include <dm.h>
+#include <environment.h>
 #include <g_dnl.h>
 #include <generic-phy.h>
 #include <i2c.h>
@@ -506,6 +507,28 @@ void board_quiesce_devices(void)
 	setup_led(LEDST_OFF);
 }
 
+enum env_location env_get_location(enum env_operation op, int prio)
+{
+	u32 bootmode = get_bootmode();
+
+	if (prio)
+		return ENVL_UNKNOWN;
+
+	switch (bootmode & TAMP_BOOT_DEVICE_MASK) {
+#ifdef CONFIG_ENV_IS_IN_EXT4
+	case BOOT_FLASH_SD:
+	case BOOT_FLASH_EMMC:
+		return ENVL_EXT4;
+#endif
+#ifdef CONFIG_ENV_IS_IN_UBI
+	case BOOT_FLASH_NAND:
+		return ENVL_UBI;
+#endif
+	default:
+		return ENVL_NOWHERE;
+	}
+}
+
 #if defined(CONFIG_ENV_IS_IN_EXT4)
 const char *env_ext4_get_intf(void)
 {
-- 
1.9.1

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

* [U-Boot] [PATCH 10/14] mtd: Fix get_mtdparts()
  2019-05-10 16:11 [U-Boot] [PATCH 00/14] Add saveenv support for STM32MP1 Patrice Chotard
                   ` (8 preceding siblings ...)
  2019-05-10 16:11 ` [U-Boot] [PATCH 09/14] stm32mp1: Add env_get_location() Patrice Chotard
@ 2019-05-10 16:11 ` Patrice Chotard
  2019-05-10 16:11 ` [U-Boot] [PATCH 11/14] stm32mp1: Move ENV_SIZE to Kconfig Patrice Chotard
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Patrice Chotard @ 2019-05-10 16:11 UTC (permalink / raw)
  To: u-boot

When ENV_IS_IN_UBI is enable, get_mtdparts is called before relocation.

During first get_mtdparts() call, mtdparts is not available in environment,
it can be retrieved by calling board_mtdparts_default(), but following
env_set() do nothing as we are before relocation. Finally mtdparts is
still not available in environment.

At second get_mtdparts() call, use_defaults is false, but mtdparts is still
not in environment and is NULL.

Remove use_defaults bool, only mtdparts criteria is useful.

Fixes: commit 5ffcd50612f6 ("mtd: Use default mtdparts/mtids when not defined
in the environment")

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

 drivers/mtd/mtd_uboot.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/mtd/mtd_uboot.c b/drivers/mtd/mtd_uboot.c
index d638f70..0a41ed4 100644
--- a/drivers/mtd/mtd_uboot.c
+++ b/drivers/mtd/mtd_uboot.c
@@ -122,7 +122,6 @@ static const char *get_mtdparts(void)
 {
 	__maybe_unused const char *mtdids = NULL;
 	static char tmp_parts[MTDPARTS_MAXLEN];
-	static bool use_defaults = true;
 	const char *mtdparts = NULL;
 
 	if (gd->flags & GD_FLG_ENV_READY)
@@ -130,7 +129,7 @@ static const char *get_mtdparts(void)
 	else if (env_get_f("mtdparts", tmp_parts, sizeof(tmp_parts)) != -1)
 		mtdparts = tmp_parts;
 
-	if (mtdparts || !use_defaults)
+	if (mtdparts)
 		return mtdparts;
 
 #if defined(CONFIG_SYS_MTDPARTS_RUNTIME)
@@ -144,8 +143,6 @@ static const char *get_mtdparts(void)
 	if (mtdparts)
 		env_set("mtdparts", mtdparts);
 
-	use_defaults = false;
-
 	return mtdparts;
 }
 
-- 
1.9.1

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

* [U-Boot] [PATCH 11/14] stm32mp1: Move ENV_SIZE to Kconfig
  2019-05-10 16:11 [U-Boot] [PATCH 00/14] Add saveenv support for STM32MP1 Patrice Chotard
                   ` (9 preceding siblings ...)
  2019-05-10 16:11 ` [U-Boot] [PATCH 10/14] mtd: Fix get_mtdparts() Patrice Chotard
@ 2019-05-10 16:11 ` Patrice Chotard
  2019-05-10 16:11 ` [U-Boot] [PATCH 12/14] configs: stm32mp15: Enable ENV_IS_IN_UBI Patrice Chotard
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Patrice Chotard @ 2019-05-10 16:11 UTC (permalink / raw)
  To: u-boot

Move ENV_SIZE from include/configs/stm32mp1.h to
arch/arm/mach-stm32mp/Kconfig

Increase ENV_SIZE from 4 to 8 Ko

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---

 arch/arm/mach-stm32mp/Kconfig | 3 +++
 env/Kconfig                   | 2 +-
 include/configs/stm32mp1.h    | 5 -----
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-stm32mp/Kconfig b/arch/arm/mach-stm32mp/Kconfig
index 73aa382..5a7f40d 100644
--- a/arch/arm/mach-stm32mp/Kconfig
+++ b/arch/arm/mach-stm32mp/Kconfig
@@ -23,6 +23,9 @@ config SPL
 config SYS_SOC
 	default "stm32mp"
 
+config ENV_SIZE
+	default 0x2000
+
 config TARGET_STM32MP1
 	bool "Support stm32mp1xx"
 	select ARCH_SUPPORT_PSCI if !STM32MP1_TRUSTED
diff --git a/env/Kconfig b/env/Kconfig
index ca889cc..1091c89 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -464,7 +464,7 @@ config ENV_EXT4_FILE
 	  It's a string of the EXT4 file name. This file use to store the
 	  environment (explicit path to the file)
 
-if ARCH_ROCKCHIP || ARCH_SUNXI || ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_VERSAL || ARC
+if ARCH_ROCKCHIP || ARCH_SUNXI || ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_VERSAL || ARC || ARCH_STM32MP
 
 config ENV_OFFSET
 	hex "Environment Offset"
diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h
index 254aad1..51f1736 100644
--- a/include/configs/stm32mp1.h
+++ b/include/configs/stm32mp1.h
@@ -43,11 +43,6 @@
  */
 #define CONFIG_SYS_LOAD_ADDR			STM32_DDR_BASE
 
-/*
- * Env parameters
- */
-#define CONFIG_ENV_SIZE				SZ_4K
-
 /* ATAGs */
 #define CONFIG_CMDLINE_TAG
 #define CONFIG_SETUP_MEMORY_TAGS
-- 
1.9.1

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

* [U-Boot] [PATCH 12/14] configs: stm32mp15: Enable ENV_IS_IN_UBI
  2019-05-10 16:11 [U-Boot] [PATCH 00/14] Add saveenv support for STM32MP1 Patrice Chotard
                   ` (10 preceding siblings ...)
  2019-05-10 16:11 ` [U-Boot] [PATCH 11/14] stm32mp1: Move ENV_SIZE to Kconfig Patrice Chotard
@ 2019-05-10 16:11 ` Patrice Chotard
  2019-05-10 16:11 ` [U-Boot] [PATCH 13/14] configs: stm32mp15: Enable ENV_IS_SPI_FLASH Patrice Chotard
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Patrice Chotard @ 2019-05-10 16:11 UTC (permalink / raw)
  To: u-boot

Add all relative flags needed by ENV_IS_IN_UBI

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

 configs/stm32mp15_basic_defconfig   | 4 ++++
 configs/stm32mp15_trusted_defconfig | 4 ++++
 include/configs/stm32mp1.h          | 4 ++++
 3 files changed, 12 insertions(+)

diff --git a/configs/stm32mp15_basic_defconfig b/configs/stm32mp15_basic_defconfig
index 051c1de..e8f170d 100644
--- a/configs/stm32mp15_basic_defconfig
+++ b/configs/stm32mp15_basic_defconfig
@@ -39,13 +39,17 @@ CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_MTDPARTS=y
+CONFIG_CMD_UBI=y
 # CONFIG_SPL_DOS_PARTITION is not set
 CONFIG_DEFAULT_DEVICE_TREE="stm32mp157c-ev1"
 CONFIG_ENV_IS_NOWHERE=y
 CONFIG_ENV_IS_IN_EXT4=y
+CONFIG_ENV_IS_IN_UBI=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_STM32_ADC=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0xC0000000
diff --git a/configs/stm32mp15_trusted_defconfig b/configs/stm32mp15_trusted_defconfig
index f09f0e4..61d4467 100644
--- a/configs/stm32mp15_trusted_defconfig
+++ b/configs/stm32mp15_trusted_defconfig
@@ -32,12 +32,16 @@ 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_UBI=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_STM32_ADC=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0xC0000000
diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h
index 51f1736..e9bd551 100644
--- a/include/configs/stm32mp1.h
+++ b/include/configs/stm32mp1.h
@@ -43,6 +43,10 @@
  */
 #define CONFIG_SYS_LOAD_ADDR			STM32_DDR_BASE
 
+#if defined(CONFIG_ENV_IS_IN_UBI)
+#define CONFIG_ENV_UBI_VOLUME_REDUND		"uboot_config_r"
+#endif
+
 /* ATAGs */
 #define CONFIG_CMDLINE_TAG
 #define CONFIG_SETUP_MEMORY_TAGS
-- 
1.9.1

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

* [U-Boot] [PATCH 13/14] configs: stm32mp15: Enable ENV_IS_SPI_FLASH
  2019-05-10 16:11 [U-Boot] [PATCH 00/14] Add saveenv support for STM32MP1 Patrice Chotard
                   ` (11 preceding siblings ...)
  2019-05-10 16:11 ` [U-Boot] [PATCH 12/14] configs: stm32mp15: Enable ENV_IS_IN_UBI Patrice Chotard
@ 2019-05-10 16:11 ` Patrice Chotard
  2019-05-10 16:11 ` [U-Boot] [PATCH 14/14] stm32mp1: Update env_get_location for NOR support Patrice Chotard
  2019-05-10 16:18 ` [U-Boot] [PATCH 00/14] Add saveenv support for STM32MP1 Patrice CHOTARD
  14 siblings, 0 replies; 16+ messages in thread
From: Patrice Chotard @ 2019-05-10 16:11 UTC (permalink / raw)
  To: u-boot

Add all relative flags needed by ENV_IS_IN_SPI_FLASH

Reserved a 256KB partition in NOR to save the U-Boot
environment.

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

 configs/stm32mp15_basic_defconfig   | 1 +
 configs/stm32mp15_trusted_defconfig | 1 +
 include/configs/stm32mp1.h          | 7 ++++++-
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/configs/stm32mp15_basic_defconfig b/configs/stm32mp15_basic_defconfig
index e8f170d..93066aa 100644
--- a/configs/stm32mp15_basic_defconfig
+++ b/configs/stm32mp15_basic_defconfig
@@ -44,6 +44,7 @@ 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_ENV_EXT4_INTERFACE="mmc"
 CONFIG_ENV_EXT4_DEVICE_AND_PART="0:auto"
diff --git a/configs/stm32mp15_trusted_defconfig b/configs/stm32mp15_trusted_defconfig
index 61d4467..949b56a 100644
--- a/configs/stm32mp15_trusted_defconfig
+++ b/configs/stm32mp15_trusted_defconfig
@@ -36,6 +36,7 @@ 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_ENV_EXT4_INTERFACE="mmc"
 CONFIG_ENV_EXT4_DEVICE_AND_PART="0:auto"
diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h
index e9bd551..f541132 100644
--- a/include/configs/stm32mp1.h
+++ b/include/configs/stm32mp1.h
@@ -47,6 +47,11 @@
 #define CONFIG_ENV_UBI_VOLUME_REDUND		"uboot_config_r"
 #endif
 
+#if defined(CONFIG_ENV_IS_IN_SPI_FLASH)
+#define	CONFIG_ENV_SECT_SIZE			SZ_256K
+#define	CONFIG_ENV_OFFSET			0x00280000
+#endif
+
 /* ATAGs */
 #define CONFIG_CMDLINE_TAG
 #define CONFIG_SETUP_MEMORY_TAGS
@@ -119,7 +124,7 @@
 #endif
 
 #define STM32MP_MTDPARTS \
-	"mtdparts_nor0=256k(fsbl1),256k(fsbl2),2m(ssbl),-(nor_user)\0" \
+	"mtdparts_nor0=256k(fsbl1),256k(fsbl2),2m(ssbl),256k(u-boot-env),-(nor_user)\0" \
 	"mtdparts_nand0=2m(fsbl),2m(ssbl),-(UBI)\0"
 
 /*
-- 
1.9.1

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

* [U-Boot] [PATCH 14/14] stm32mp1: Update env_get_location for NOR support
  2019-05-10 16:11 [U-Boot] [PATCH 00/14] Add saveenv support for STM32MP1 Patrice Chotard
                   ` (12 preceding siblings ...)
  2019-05-10 16:11 ` [U-Boot] [PATCH 13/14] configs: stm32mp15: Enable ENV_IS_SPI_FLASH Patrice Chotard
@ 2019-05-10 16:11 ` Patrice Chotard
  2019-05-10 16:18 ` [U-Boot] [PATCH 00/14] Add saveenv support for STM32MP1 Patrice CHOTARD
  14 siblings, 0 replies; 16+ messages in thread
From: Patrice Chotard @ 2019-05-10 16:11 UTC (permalink / raw)
  To: u-boot

Update env_get_location() to be able to save environment into
NOR (SPI_FLASH).

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

 board/st/stm32mp1/stm32mp1.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 4f7d24a..af607c5 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -524,6 +524,10 @@ enum env_location env_get_location(enum env_operation op, int prio)
 	case BOOT_FLASH_NAND:
 		return ENVL_UBI;
 #endif
+#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
+	case BOOT_FLASH_NOR:
+		return ENVL_SPI_FLASH;
+#endif
 	default:
 		return ENVL_NOWHERE;
 	}
-- 
1.9.1

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

* [U-Boot] [PATCH 00/14] Add saveenv support for STM32MP1
  2019-05-10 16:11 [U-Boot] [PATCH 00/14] Add saveenv support for STM32MP1 Patrice Chotard
                   ` (13 preceding siblings ...)
  2019-05-10 16:11 ` [U-Boot] [PATCH 14/14] stm32mp1: Update env_get_location for NOR support Patrice Chotard
@ 2019-05-10 16:18 ` Patrice CHOTARD
  14 siblings, 0 replies; 16+ messages in thread
From: Patrice CHOTARD @ 2019-05-10 16:18 UTC (permalink / raw)
  To: u-boot

Sorry, i sent one useless patch, i will resend this series

Patrice

On 5/10/19 6:11 PM, Patrice Chotard wrote:
> 
> This series adds saveenv support for STM32MP1 on several boot
> devices. STM32MP1 is able to boot on eMMC, sdcard and NOR
> (NAND support is not fully supported).
> 
> On eMMC and sdcard, environment is saved in EXT4 partition
> On NOR, environment is saved in a dedicated partition
> On NAND, environment is saved in a UBI volume.
> 
> This series:
>   - enables NAND and NOR support on ev1 board
>   - enables ENV_IS_IN_SPI_FLASH, ENV_IS_IN_UBI, ENV_IS_IN_EXT4
>     flags
>   - fixes get_mtdparts()
>   - allows to override interface, device and partition for ext4
>     environment
>   - updates rule to set ENV_IS_NOWHERE value
>   - introduce ENV_IS_IN_DEVICE
> 
> 
> Patrice Chotard (10):
>   stm32mp1: support dynamic MTDPARTS
>   env: ext4: Allow overriding interface, device and partition
>   board: stm32mp1: Add env_ext4_get_dev_part() and env_ext4_get_intf()
>   env: allow ENV_IS_NOWHERE with other storage target
>   stm32mp1: Add env_get_location()
>   mtd: Fix get_mtdparts()
>   stm32mp1: Move ENV_SIZE to Kconfig
>   configs: stm32mp15: Enable ENV_IS_IN_UBI
>   configs: stm32mp15: Enable ENV_IS_SPI_FLASH
>   stm32mp1: Update env_get_location for NOR support
> 
> Patrick Delaunay (3):
>   stm32mp1: activate NAND and NOR support on EV1
>   env: enable saveenv command when one CONFIG_ENV_IS_IN is activated
>   configs: stm32mp15: Enable ENV_IS_IN_EXT4 and all relative flags
> 
> Tom Rini (1):
>   Prepare v2019.07-rc1
> 
>  Makefile                             |   4 +-
>  arch/arm/dts/stm32mp157-pinctrl.dtsi |  44 ++++++++++++
>  arch/arm/dts/stm32mp157c-ev1.dts     |  16 +++++
>  arch/arm/dts/stm32mp157c.dtsi        |  15 ++++
>  arch/arm/mach-stm32mp/Kconfig        |   3 +
>  board/st/stm32mp1/stm32mp1.c         | 136 +++++++++++++++++++++++++++++++++++
>  cmd/nvedit.c                         |  36 ++++++----
>  configs/stm32mp15_basic_defconfig    |  27 +++++++
>  configs/stm32mp15_trusted_defconfig  |  27 +++++++
>  drivers/mtd/mtd_uboot.c              |   5 +-
>  env/Kconfig                          |  20 ++----
>  env/ext4.c                           |  34 +++++----
>  include/configs/stm32mp1.h           |  24 +++++--
>  13 files changed, 340 insertions(+), 51 deletions(-)
> 

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

end of thread, other threads:[~2019-05-10 16:18 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-10 16:11 [U-Boot] [PATCH 00/14] Add saveenv support for STM32MP1 Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 01/14] Prepare v2019.07-rc1 Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 02/14] stm32mp1: activate NAND and NOR support on EV1 Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 03/14] stm32mp1: support dynamic MTDPARTS Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 04/14] env: ext4: Allow overriding interface, device and partition Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 05/14] board: stm32mp1: Add env_ext4_get_dev_part() and env_ext4_get_intf() Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 06/14] env: allow ENV_IS_NOWHERE with other storage target Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 07/14] env: enable saveenv command when one CONFIG_ENV_IS_IN is activated Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 08/14] configs: stm32mp15: Enable ENV_IS_IN_EXT4 and all relative flags Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 09/14] stm32mp1: Add env_get_location() Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 10/14] mtd: Fix get_mtdparts() Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 11/14] stm32mp1: Move ENV_SIZE to Kconfig Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 12/14] configs: stm32mp15: Enable ENV_IS_IN_UBI Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 13/14] configs: stm32mp15: Enable ENV_IS_SPI_FLASH Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 14/14] stm32mp1: Update env_get_location for NOR support Patrice Chotard
2019-05-10 16:18 ` [U-Boot] [PATCH 00/14] Add saveenv support for STM32MP1 Patrice CHOTARD

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox