VAR-SOM-MX6 1GB NAND

From Variscite Wiki
Revision as of 13:10, 20 March 2017 by Eran (talk | contribs)
VAR-SOM-MX6 1GB NAND flash support

To use a 1GB NAND flash with erase block size of 512KiB, apply the following U-Boot, Linux and meta-variscite-imx patches:

U-Boot:

From 7b038e142caf81406a5230b4de06af89b1f27b2c Mon Sep 17 00:00:00 2001
From: Eran Matityahu <eran.m@variscite.com>
Date: Thu, 2 Mar 2017 12:11:07 +0200
Subject: [PATCH 1/2] mx6var_som: nand: Increase mtd0 partition size to 4M

---
 include/configs/mx6var_som.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/configs/mx6var_som.h b/include/configs/mx6var_som.h
index 94d1e9c033..02834db673 100644
--- a/include/configs/mx6var_som.h
+++ b/include/configs/mx6var_som.h
@@ -208,8 +208,8 @@
 		"else " \
 			"run bootargs_emmc; " \
 		"fi; " \
-		"nand read ${loadaddr} 0x400000 0x800000; " \
-		"nand read ${fdt_addr} 0x3e0000 0x20000; " \
+		"nand read ${loadaddr} 0x600000 0x800000; " \
+		"nand read ${fdt_addr} 0x5e0000 0x20000; " \
 		"bootm ${loadaddr} - ${fdt_addr}\0" \
 	"mtdids=" MTDIDS_DEFAULT "\0" \
 	"mtdparts=" MTDPARTS_DEFAULT "\0"
@@ -379,7 +379,7 @@
 #define CONFIG_ENV_IS_IN_NAND
 /* NAND boot config */
 #define CONFIG_SYS_NAND_U_BOOT_START	CONFIG_SYS_TEXT_BASE
-#define CONFIG_SYS_NAND_U_BOOT_OFFS	0x200000
+#define CONFIG_SYS_NAND_U_BOOT_OFFS	0x400000
 #else
 #define CONFIG_ENV_IS_IN_MMC
 #endif
@@ -403,14 +403,14 @@
 
 /*
  * Partitions layout for NAND is:
- *     mtd0: 2M       (spl) First boot loader
+ *     mtd0: 4M       (spl) First boot loader
  *     mtd1: 2M       (u-boot, dtb)
  *     mtd2: 8M       (kernel)
  *     mtd3: left     (rootfs)
  */
 /* Default mtd partition table */
 #define MTDPARTS_DEFAULT	"mtdparts=nandflash-0:"\
-					"2m(spl),"\
+					"4m(spl),"\
 					"2m(u-boot),"\
 					"8m(kernel),"\
 					"-(rootfs)"	/* ubifs */
@@ -432,7 +432,7 @@
 #define CONFIG_ENV_OFFSET		(0x3E0000)
 #elif defined(CONFIG_ENV_IS_IN_NAND)
 #undef CONFIG_ENV_SIZE
-#define CONFIG_ENV_OFFSET		(0x180000)
+#define CONFIG_ENV_OFFSET		(0x380000)
 #define CONFIG_ENV_SECT_SIZE		(128 << 10)
 #define CONFIG_ENV_SIZE			CONFIG_ENV_SECT_SIZE
 #endif
-- 
2.11.0
From 28a98dfeda1d9567b52afcd943443bf3a59fc5dc Mon Sep 17 00:00:00 2001
From: Eran Matityahu <eran.m@variscite.com>
Date: Mon, 20 Mar 2017 09:34:49 +0200
Subject: [PATCH 2/2] mx6var_som: nand: Set CONFIG_ENV_SECT_SIZE to 512KiB

---
 include/configs/mx6var_som.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/configs/mx6var_som.h b/include/configs/mx6var_som.h
index 02834db673..d38a90bda6 100644
--- a/include/configs/mx6var_som.h
+++ b/include/configs/mx6var_som.h
@@ -433,7 +433,7 @@
 #elif defined(CONFIG_ENV_IS_IN_NAND)
 #undef CONFIG_ENV_SIZE
 #define CONFIG_ENV_OFFSET		(0x380000)
-#define CONFIG_ENV_SECT_SIZE		(128 << 10)
+#define CONFIG_ENV_SECT_SIZE		(512 << 10)
 #define CONFIG_ENV_SIZE			CONFIG_ENV_SECT_SIZE
 #endif
 
-- 
2.11.0


Linux:

From 756829210fad2a0c45b088d028ebb3b98032023b Mon Sep 17 00:00:00 2001
From: Eran Matityahu <eran.m@variscite.com>
Date: Thu, 2 Mar 2017 12:17:23 +0200
Subject: [PATCH] imx6-var-som: nand: Increase mtd0 partition size to 4M

---
 arch/arm/boot/dts/imx6qdl-var-som.dtsi | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm/boot/dts/imx6qdl-var-som.dtsi b/arch/arm/boot/dts/imx6qdl-var-som.dtsi
index da34c19815ce..c6c203700534 100644
--- a/arch/arm/boot/dts/imx6qdl-var-som.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-var-som.dtsi
@@ -699,28 +699,28 @@
 	pinctrl-0 = <&pinctrl_gpmi_nand_v1>;
 	status = "okay";
 
-	/* a 2 MiB partition */
+	/* a 4 MiB partition */
 	partition@0 {
 		label = "spl";
-		reg = <0x00000000 0x00200000>;
+		reg = <0x00000000 0x00400000>;
 	};
 
 	/* a 2 MiB partition */
 	partition@1 {
 		label = "bootloader";
-		reg = <0x00200000 0x00200000>;
+		reg = <0x00400000 0x00200000>;
 	};
 
 	/* an 8 MiB partition */
 	partition@2 {
 		label = "kernel";
-		reg = <0x00400000 0x00800000>;
+		reg = <0x00600000 0x00800000>;
 	};
 
-	/* a 1012 MiB partition */
+	/* a 1010 MiB partition */
 	partition@3 {
 		label = "rootfs";
-		reg = <0x00c00000 0x3f400000>;
+		reg = <0x00e00000 0x3f200000>;
 	};
 };
 
-- 
2.11.0


meta-variscite-imx:

From f93a8e8ec8c08fa24e0f9844ea21d3bfe05a0ff4 Mon Sep 17 00:00:00 2001
From: Eran Matityahu <eran.m@variscite.com>
Date: Thu, 2 Mar 2017 17:24:02 +0200
Subject: [PATCH 1/2] var-som-mx6: Create UBI image for 1GB NAND flash with
 512KiB erase blocks

---
 conf/machine/var-som-mx6.conf | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/conf/machine/var-som-mx6.conf b/conf/machine/var-som-mx6.conf
index d43ebe7..624137e 100644
--- a/conf/machine/var-som-mx6.conf
+++ b/conf/machine/var-som-mx6.conf
@@ -16,16 +16,16 @@ SERIAL_CONSOLE = "115200 ttymxc0"
 MACHINE_FEATURES += " pci bluetooth touchscreen wifi"
 
 # UBIFS for Variscite NAND 0.5 GB
-MKUBIFS_ARGS = " -m 2048 -e 124KiB -c 3965 "
-UBINIZE_ARGS = " -m 2048 -p 128KiB -s 2048 -O 2048 "
+#MKUBIFS_ARGS = " -m 2048 -e 124KiB -c 3965 "
+#UBINIZE_ARGS = " -m 2048 -p 128KiB -s 2048 -O 2048 "
 
 # UBIFS for Variscite NAND 1.0 GB (models with erase block size of 128KiB)
 #MKUBIFS_ARGS = " -m 2048 -e 124KiB -c 7855 "
 #UBINIZE_ARGS = " -m 2048 -p 128KiB -s 2048 -O 2048 "
 
 # UBIFS for Variscite NAND 1.0 GB (models with erase block size of 512KiB)
-#MKUBIFS_ARGS = " -m 4096 -e 504KiB -c 2000 "
-#UBINIZE_ARGS = " -m 4096 -p 512KiB -s 4096 -O 4096 "
+MKUBIFS_ARGS = " -m 4096 -e 504KiB -c 2000 "
+UBINIZE_ARGS = " -m 4096 -p 512KiB -s 4096 -O 4096 "
 
 UBI_VOLNAME  = "rootfs"
 
-- 
2.11.0
From 01280aafeb71e64c9783b179611c39f768ccab72 Mon Sep 17 00:00:00 2001
From: Eran Matityahu <eran.m@variscite.com>
Date: Mon, 20 Mar 2017 10:40:39 +0200
Subject: [PATCH 2/2] var-som-mx6: u-boot-fw-utils: Adjust cfg file to 1GB
 512KB PEB NAND configuration

---
 recipes-bsp/u-boot/u-boot-fw-utils/var-som-mx6/fw_env.config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/recipes-bsp/u-boot/u-boot-fw-utils/var-som-mx6/fw_env.config b/recipes-bsp/u-boot/u-boot-fw-utils/var-som-mx6/fw_env.config
index 56ae708..9919819 100644
--- a/recipes-bsp/u-boot/u-boot-fw-utils/var-som-mx6/fw_env.config
+++ b/recipes-bsp/u-boot/u-boot-fw-utils/var-som-mx6/fw_env.config
@@ -6,7 +6,7 @@
 
 # NAND example
 # MTD device name	Device offset	Env. size	Flash sector size	Number of sectors
-/dev/mtd0		0x180000	0x20000		0x20000			1
+/dev/mtd0		0x380000	0x80000		0x80000			1
 
 # Block device example
 #/dev/mmcblk0		0x3e0000	0x2000
-- 
2.11.0