Skip to contentSkip to conversation

arm: mvebu: Espressobin: Enable 'mtd' command and define SPI NOR partitions

PATCH In review Pali Rohár 3 participants 3 messages Jul 16, 2021 – Jul 19, 2021 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: mvebu: Espressobin: Enable 'mtd' command and define SPI NOR partitions

U-Boot now supports parsing SPI NOR partitions from Device Tree. So enable 'mtd' command support for Espressobin board and define partition layout in U-Boot Espressobin DTS file. Access to SPI NOR via 'sf' command is old method and 'mtd' command is now preferred variant.

From include file remove '#define CONFIG_MTD_PARTITIONS' as this option is now defined and enabled in defconfig file. This change is required to fix compile error:

CC arch/arm/lib/asm-offsets.s
In file included from include/config.h:4,
from include/common.h:16,
from lib/asm-offsets.c:14:
include/configs/mvebu_armada-37xx.h:63: warning: "CONFIG_MTD_PARTITIONS" redefined
#define CONFIG_MTD_PARTITIONS /* required for UBI partition support */

In file included from ././include/linux/kconfig.h:4,
from <command-line>:
include/generated/autoconf.h:44: note: this is the location of the previous definition
#define CONFIG_MTD_PARTITIONS 1

After enabling support for mtd command, output from 'mtd list' on Espressobin board is:

=> mtd list
List of MTD devices:
* w25q32dw
- device: spi-flash@0
- parent: spi@10600
- driver: jedec_spi_nor
- path: /soc/internal-regs/spi@10600/spi-flash@0
- type: NOR flash
- block size: 0x1000 bytes
- min I/O: 0x1 bytes
- 0x000000000000-0x000000400000 : "w25q32dw"
- 0x000000000000-0x0000003f0000 : "firmware"
- 0x0000003f0000-0x000000400000 : "u-boot-env"
=>

---
 arch/arm/dts/armada-3720-espressobin.dts    | 18 ++++++++++++++++++
 configs/mvebu_espressobin-88f3720_defconfig |  3 +++
 include/configs/mvebu_armada-37xx.h         |  5 -----
 3 files changed, 21 insertions(+), 5 deletions(-)
arch/arm/dts/armada-3720-espressobin.dts +18 -0
index d86d8f0b63cf..cba6139be690 100644
@@ -164,6 +164,24 @@
 		reg = <0>; /* Chip select 0 */
 		spi-max-frequency = <50000000>;
 		m25p,fast-read;
+
+#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition@firmware {
+				reg = <0 CONFIG_ENV_OFFSET>;
+				label = "firmware";
+			};
+
+			partition@u-boot-env {
+				reg = <CONFIG_ENV_OFFSET CONFIG_ENV_SIZE>;
+				label = "u-boot-env";
+			};
+		};
+#endif
 	};
 };
 
configs/mvebu_espressobin-88f3720_defconfig +3 -0
index dc199cfe503b..78796115cd38 100644
@@ -28,6 +28,7 @@ CONFIG_BOARD_LATE_INIT=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_MTD=y
 CONFIG_CMD_PCI=y
 CONFIG_CMD_SPI=y
 CONFIG_CMD_USB=y
@@ -54,6 +55,7 @@ CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_SDMA=y
 CONFIG_MMC_SDHCI_XENON=y
 CONFIG_MTD=y
+CONFIG_DM_MTD=y
 CONFIG_SF_DEFAULT_MODE=0
 CONFIG_SF_DEFAULT_SPEED=40000000
 CONFIG_SPI_FLASH_GIGADEVICE=y
@@ -62,6 +64,7 @@ CONFIG_SPI_FLASH_MACRONIX=y
 CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_SPI_FLASH_WINBOND=y
+CONFIG_SPI_FLASH_MTD=y
 CONFIG_PHY_MARVELL=y
 CONFIG_PHY_GIGE=y
 CONFIG_E1000=y
include/configs/mvebu_armada-37xx.h +0 -5
index a2bea2947dd1..c8c34d7d92dd 100644
@@ -57,11 +57,6 @@
 #define CONFIG_I2C_MV
 #define CONFIG_SYS_I2C_SLAVE		0x0
 
-/*
- * SPI Flash configuration
- */
-#define CONFIG_MTD_PARTITIONS		/* required for UBI partition support */
-
 /*
  * Environment
  */
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw

Hi, Pali,

Quoted 53 lines

-----Original Message-----
From: Pali Rohár <[email protected]>
Sent: Friday, July 16, 2021 13:35
To: Stefan Roese <[email protected]>; Andre Heider <[email protected]>; Gérald Kerma <[email protected]>; Kostya Porotchkin <[email protected]>
Cc: [email protected]
Subject: [EXT] [PATCH] arm: mvebu: Espressobin: Enable 'mtd' command and define SPI NOR partitions

External Email

----------------------------------------------------------------------
U-Boot now supports parsing SPI NOR partitions from Device Tree. So enable 'mtd' command support for Espressobin board and define partition layout in U- Boot Espressobin DTS file. Access to SPI NOR via 'sf' command is old method and 'mtd' command is now preferred variant.

From include file remove '#define CONFIG_MTD_PARTITIONS' as this option is now defined and enabled in defconfig file. This change is required to fix compile error:

CC arch/arm/lib/asm-offsets.s
In file included from include/config.h:4,
from include/common.h:16,
from lib/asm-offsets.c:14:
include/configs/mvebu_armada-37xx.h:63: warning:
"CONFIG_MTD_PARTITIONS" redefined
#define CONFIG_MTD_PARTITIONS /* required for UBI partition support */

In file included from ././include/linux/kconfig.h:4,
from <command-line>:
include/generated/autoconf.h:44: note: this is the location of the previous
definition

     #define CONFIG_MTD_PARTITIONS 1

After enabling support for mtd command, output from 'mtd list' on Espressobin board is:

=> mtd list
List of MTD devices:
* w25q32dw
- device: spi-flash@0
- parent: spi@10600
- driver: jedec_spi_nor
- path: /soc/internal-regs/spi@10600/spi-flash@0
- type: NOR flash
- block size: 0x1000 bytes
- min I/O: 0x1 bytes
- 0x000000000000-0x000000400000 : "w25q32dw"
- 0x000000000000-0x0000003f0000 : "firmware"
- 0x0000003f0000-0x000000400000 : "u-boot-env"
=>

Quoted 1 line

Regards
Kosta

Quoted 83 lines
---
 arch/arm/dts/armada-3720-espressobin.dts    | 18 ++++++++++++++++++
 configs/mvebu_espressobin-88f3720_defconfig |  3 +++
 include/configs/mvebu_armada-37xx.h         |  5 -----
 3 files changed, 21 insertions(+), 5 deletions(-)
arch/arm/dts/armada-3720-espressobin.dts +18 -0
index d86d8f0b63cf..cba6139be690 100644
@@ -164,6 +164,24 @@
 		reg = <0>; /* Chip select 0 */
 		spi-max-frequency = <50000000>;
 		m25p,fast-read;
+
+#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition@firmware {
+				reg = <0 CONFIG_ENV_OFFSET>;
+				label = "firmware";
+			};
+
+			partition@u-boot-env {
+				reg = <CONFIG_ENV_OFFSET
 CONFIG_ENV_SIZE>;
+				label = "u-boot-env";
+			};
+		};
+#endif
 	};
 };
configs/mvebu_espressobin-88f3720_defconfig +0 -0
index dc199cfe503b..78796115cd38 100644
@@ -28,6 +28,7 @@ CONFIG_BOARD_LATE_INIT=y  CONFIG_CMD_GPIO=y

CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y

configs/mvebu_espressobin-88f3720_defconfig +2 -0
+CONFIG_CMD_MTD=y
 CONFIG_CMD_PCI=y
 CONFIG_CMD_SPI=y
 CONFIG_CMD_USB=y
@@ -54,6 +55,7 @@ CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_SDMA=y
 CONFIG_MMC_SDHCI_XENON=y
 CONFIG_MTD=y
+CONFIG_DM_MTD=y
 CONFIG_SF_DEFAULT_MODE=0
 CONFIG_SF_DEFAULT_SPEED=40000000
 CONFIG_SPI_FLASH_GIGADEVICE=y
@@ -62,6 +64,7 @@ CONFIG_SPI_FLASH_MACRONIX=y

CONFIG_SPI_FLASH_SPANSION=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_WINBOND=y

configs/mvebu_espressobin-88f3720_defconfig +1 -0
+CONFIG_SPI_FLASH_MTD=y
 CONFIG_PHY_MARVELL=y
 CONFIG_PHY_GIGE=y
 CONFIG_E1000=y
include/configs/mvebu_armada-37xx.h +0 -4
index a2bea2947dd1..c8c34d7d92dd 100644
@@ -57,11 +57,6 @@
 #define CONFIG_I2C_MV
 #define CONFIG_SYS_I2C_SLAVE		0x0
 
-/*
- * SPI Flash configuration
- */
-#define CONFIG_MTD_PARTITIONS		/* required for UBI partition

support */
-
/*
* Environment
*/
--
2.20.1

Reviewed-by on v1 1/1
#2 lore raw
In reply to Pali Rohár
Quoted 39 lines · Pali Rohár

U-Boot now supports parsing SPI NOR partitions from Device Tree. So enable 'mtd' command support for Espressobin board and define partition layout in U-Boot Espressobin DTS file. Access to SPI NOR via 'sf' command is old method and 'mtd' command is now preferred variant.

From include file remove '#define CONFIG_MTD_PARTITIONS' as this option is
now defined and enabled in defconfig file. This change is required to fix compile error:

CC arch/arm/lib/asm-offsets.s
In file included from include/config.h:4,
from include/common.h:16,
from lib/asm-offsets.c:14:
include/configs/mvebu_armada-37xx.h:63: warning: "CONFIG_MTD_PARTITIONS" redefined
#define CONFIG_MTD_PARTITIONS /* required for UBI partition support */

In file included from ././include/linux/kconfig.h:4,
from <command-line>:
include/generated/autoconf.h:44: note: this is the location of the previous definition
#define CONFIG_MTD_PARTITIONS 1

After enabling support for mtd command, output from 'mtd list' on Espressobin board is:

=> mtd list
List of MTD devices:
* w25q32dw
- device: spi-flash@0
- parent: spi@10600
- driver: jedec_spi_nor
- path: /soc/internal-regs/spi@10600/spi-flash@0
- type: NOR flash
- block size: 0x1000 bytes
- min I/O: 0x1 bytes
- 0x000000000000-0x000000400000 : "w25q32dw"
- 0x000000000000-0x0000003f0000 : "firmware"
- 0x0000003f0000-0x000000400000 : "u-boot-env"
=>

Quoted 1 line

Thanks,
Stefan

Quoted 70 lines
---
  arch/arm/dts/armada-3720-espressobin.dts    | 18 ++++++++++++++++++
  configs/mvebu_espressobin-88f3720_defconfig |  3 +++
  include/configs/mvebu_armada-37xx.h         |  5 -----
  3 files changed, 21 insertions(+), 5 deletions(-)
arch/arm/dts/armada-3720-espressobin.dts +18 -0
index d86d8f0b63cf..cba6139be690 100644
@@ -164,6 +164,24 @@
  		reg = <0>; /* Chip select 0 */
  		spi-max-frequency = <50000000>;
  		m25p,fast-read;
+
+#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition@firmware {
+				reg = <0 CONFIG_ENV_OFFSET>;
+				label = "firmware";
+			};
+
+			partition@u-boot-env {
+				reg = <CONFIG_ENV_OFFSET CONFIG_ENV_SIZE>;
+				label = "u-boot-env";
+			};
+		};
+#endif
  	};
  };
 
configs/mvebu_espressobin-88f3720_defconfig +3 -0
index dc199cfe503b..78796115cd38 100644
@@ -28,6 +28,7 @@ CONFIG_BOARD_LATE_INIT=y
  CONFIG_CMD_GPIO=y
  CONFIG_CMD_I2C=y
  CONFIG_CMD_MMC=y
+CONFIG_CMD_MTD=y
  CONFIG_CMD_PCI=y
  CONFIG_CMD_SPI=y
  CONFIG_CMD_USB=y
@@ -54,6 +55,7 @@ CONFIG_MMC_SDHCI=y
  CONFIG_MMC_SDHCI_SDMA=y
  CONFIG_MMC_SDHCI_XENON=y
  CONFIG_MTD=y
+CONFIG_DM_MTD=y
  CONFIG_SF_DEFAULT_MODE=0
  CONFIG_SF_DEFAULT_SPEED=40000000
  CONFIG_SPI_FLASH_GIGADEVICE=y
@@ -62,6 +64,7 @@ CONFIG_SPI_FLASH_MACRONIX=y
  CONFIG_SPI_FLASH_SPANSION=y
  CONFIG_SPI_FLASH_STMICRO=y
  CONFIG_SPI_FLASH_WINBOND=y
+CONFIG_SPI_FLASH_MTD=y
  CONFIG_PHY_MARVELL=y
  CONFIG_PHY_GIGE=y
  CONFIG_E1000=y
include/configs/mvebu_armada-37xx.h +0 -0
index a2bea2947dd1..c8c34d7d92dd 100644
@@ -57,11 +57,6 @@
  #define CONFIG_I2C_MV

include/configs/mvebu_armada-37xx.h line 62

Quoted 10 lines
include/configs/mvebu_armada-37xx.h +0 -5
  #define CONFIG_SYS_I2C_SLAVE		0x0
 
-/*
- * SPI Flash configuration
- */
-#define CONFIG_MTD_PARTITIONS		/* required for UBI partition support */
-
  /*
   * Environment
   */

Viele Grüße,
Stefan

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]