[PATCH v1 05/12] powerpc/mpc85xx: socrates: add MTD partitioning support

Heiko Schocher hs at denx.de
Tue Jan 24 18:06:53 CET 2023


setup MTD partitioning through mtdparts variable
and set it to:

mtdparts=fe0000000.nor:13312k(system1),13312k(system2),5120k(data),128k(env),128k(env-red),768k(u-boot)

and pass this to linux per kernel commandline.

Signed-off-by: Heiko Schocher <hs at denx.de>
---

 configs/socrates_defconfig |  5 +++++
 include/configs/socrates.h | 17 +++++++++++------
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/configs/socrates_defconfig b/configs/socrates_defconfig
index 03e84c3e7e..17c12aed7d 100644
--- a/configs/socrates_defconfig
+++ b/configs/socrates_defconfig
@@ -53,6 +53,9 @@ CONFIG_CMD_PING=y
 CONFIG_CMD_SNTP=y
 # CONFIG_CMD_HASH is not set
 CONFIG_CMD_EXT2=y
+CONFIG_CMD_MTDPARTS=y
+CONFIG_MTDIDS_DEFAULT="nor0=fe000000.nor_flash,nand0=socrates_nand"
+CONFIG_MTDPARTS_DEFAULT="mtdparts=fe000000.nor_flash:13312k(system1),13312k(system2),5120k(data),128k(env),128k(env-red),768k(u-boot);socrates_nand:256M(ubi-data1),-(ubi-data2)"
 # CONFIG_CMD_IRQ is not set
 CONFIG_OF_CONTROL=y
 CONFIG_ENV_IS_IN_FLASH=y
@@ -78,9 +81,11 @@ CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_FSL=y
 # CONFIG_MMC is not set
 CONFIG_MTD=y
+CONFIG_DM_MTD=y
 CONFIG_MTD_NOR_FLASH=y
 CONFIG_FLASH_CFI_DRIVER=y
 CONFIG_FLASH_SHOW_PROGRESS=0
+CONFIG_FLASH_CFI_MTD=y
 CONFIG_SYS_FLASH_CFI=y
 CONFIG_SYS_FLASH_QUIET_TEST=y
 CONFIG_SYS_MAX_FLASH_SECT=256
diff --git a/include/configs/socrates.h b/include/configs/socrates.h
index 2b35be83ec..67ff370e05 100644
--- a/include/configs/socrates.h
+++ b/include/configs/socrates.h
@@ -110,6 +110,10 @@
  */
 #define CFG_SYS_BOOTMAPSZ	(8 << 20)	/* Initial Memory map for Linux	*/
 
+#define SOCRATES_ENV_MTD \
+	"mtdids=" CONFIG_MTDIDS_DEFAULT "\0" \
+	"mtdparts=" CONFIG_MTDPARTS_DEFAULT "\0" \
+	"addmtd=setenv bootargs ${bootargs} ${mtdparts}\0"
 
 #define	CFG_EXTRA_ENV_SETTINGS					\
 	"netdev=eth0\0"							\
@@ -118,7 +122,7 @@
 	"bootfile=/home/tftp/syscon3/uImage\0"				\
 	"fdt_file=/home/tftp/syscon3/socrates.dtb\0"			\
 	"initrd_file=/home/tftp/syscon3/uinitrd.gz\0"			\
-	"uboot_addr=FFF60000\0"						\
+	"uboot_addr=FFF40000\0"						\
 	"kernel_addr=FE000000\0"					\
 	"fdt_addr=FE1E0000\0"						\
 	"ramdisk_addr=FE200000\0"					\
@@ -134,16 +138,16 @@
 	"addip=setenv bootargs $bootargs "				\
 		"ip=$ipaddr:$serverip:$gatewayip:$netmask"		\
 		":$hostname:$netdev:off panic=1\0"			\
-	"boot_nor=run ramargs addcons;"					\
+	"boot_nor=run ramargs addcons addmtd;"				\
 		"bootm ${kernel_addr} ${ramdisk_addr} ${fdt_addr}\0"	\
 	"net_nfs=tftp ${kernel_addr_r} ${bootfile}; "			\
 		"tftp ${fdt_addr_r} ${fdt_file}; "			\
-		"run nfsargs addip addcons;"				\
+		"run nfsargs addip addcons addmtd;"			\
 		"bootm ${kernel_addr_r} - ${fdt_addr_r}\0"		\
 	"update_uboot=tftp 100000 ${uboot_file};"			\
-		"protect off fff60000 ffffffff;"			\
-		"era fff60000 ffffffff;"				\
-		"cp.b 100000 fff60000 ${filesize};"			\
+		"protect off ${uboot_addr} ffffffff;"			\
+		"era ${uboot_addr}  ffffffff;"				\
+		"cp.b 100000 ${uboot_addr}  ${filesize};"		\
 		"setenv filesize;saveenv\0"				\
 	"update_kernel=tftp 100000 ${bootfile};"			\
 		"era fe000000 fe1dffff;"				\
@@ -164,6 +168,7 @@
 	"boot_usb=run load_usb usbargs addcons;"			\
 		"bootm ${kernel_addr_r} - ${fdt_addr};"			\
 		"bootm ${kernel_addr} ${ramdisk_addr} ${fdt_addr}\0"	\
+	SOCRATES_ENV_MTD \
 	""
 
 /* pass open firmware flat tree */
-- 
2.37.3



More information about the U-Boot mailing list