All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v1 0/7] add support for the etamin draco board variant.
@ 2016-05-25  5:07 Heiko Schocher
  2016-05-25  5:07 ` [U-Boot] [PATCH v1 1/7] siemens,am33x: add ubi fastmap support Heiko Schocher
                   ` (6 more replies)
  0 siblings, 7 replies; 20+ messages in thread
From: Heiko Schocher @ 2016-05-25  5:07 UTC (permalink / raw)
  To: u-boot

In the draco CPU board family, etamin is a new variant
with bigger flash and more RAM. Due to new flash that
uses larger pages (4K) some changes are necessary because
it impacts the MTD partition layout and the ubi mount
parameters.

special here is:
- adding MTD concat support for nand flashs
- add UBI Fastmap support for the siemens boards
- fix a bug in dfu/nand when erasing remaining blocks on
  ubi partitions.
- nand on etamin uses eccstrength bch16, so support
  switch to bch16 also.
- read the ecc type from the config in i2c eeprom, so
  no need to use a define.

$ ./tools/buildman/buildman arm -s
WARNING: no status info for 'kylin-rk3036'
WARNING: no maintainers for 'kylin-rk3036'
WARNING: no status info for 'ls1043aqds_lpuart'
WARNING: no maintainers for 'ls1043aqds_lpuart'
WARNING: no status info for 'ds414'
WARNING: no maintainers for 'ds414'
WARNING: no status info for 'evb-rk3036'
WARNING: no maintainers for 'evb-rk3036'
Summary of current source for 560 boards (8 threads, 1 job per thread)
       arm:  +   Cubietruck omap3_logic omap3_overo gwventana
$

No new errors/warnings



Heiko Schocher (6):
  ubi: add new ubi command "ubi dettach"
  nand: add nand mtd concat support
  mtd: nand: omap: allow to switch to BCH16
  am335x, dxr2: get ECC sType from I2C eeprom
  dfu, nand, ubi: fix erasing after write finish
  siemens,am33x: add draco etamin board

Samuel Egli (1):
  siemens,am33x: add ubi fastmap support

 arch/arm/Kconfig                       |   5 +
 arch/arm/cpu/armv7/omap3/board.c       |   6 +-
 board/siemens/common/board.c           |   4 +
 board/siemens/draco/Kconfig            |  16 ++
 board/siemens/draco/MAINTAINERS        |   1 +
 board/siemens/draco/board.c            |  84 ++++++++++-
 board/siemens/draco/mux.c              |   2 +-
 cmd/ubi.c                              |  38 +++--
 configs/etamin_defconfig               |  17 +++
 drivers/dfu/dfu_nand.c                 |  12 +-
 drivers/mtd/nand/nand.c                |  29 ++++
 drivers/mtd/nand/omap_gpmc.c           |   4 +
 include/configs/draco.h                |   1 +
 include/configs/etamin.h               | 261 +++++++++++++++++++++++++++++++++
 include/configs/pxm2.h                 |   1 +
 include/configs/rastaban.h             |   1 +
 include/configs/rut.h                  |   1 +
 include/configs/siemens-am33x-common.h |   7 +-
 include/configs/thuban.h               |   1 +
 19 files changed, 472 insertions(+), 19 deletions(-)
 create mode 100644 configs/etamin_defconfig
 create mode 100644 include/configs/etamin.h

-- 
2.5.5

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

* [U-Boot] [PATCH v1 1/7] siemens,am33x: add ubi fastmap support
  2016-05-25  5:07 [U-Boot] [PATCH v1 0/7] add support for the etamin draco board variant Heiko Schocher
@ 2016-05-25  5:07 ` Heiko Schocher
  2016-05-25  5:07 ` [U-Boot] [PATCH v1 2/7] ubi: add new ubi command "ubi dettach" Heiko Schocher
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Heiko Schocher @ 2016-05-25  5:07 UTC (permalink / raw)
  To: u-boot

From: Samuel Egli <samuel.egli@siemens.com>

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

 include/configs/siemens-am33x-common.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/configs/siemens-am33x-common.h b/include/configs/siemens-am33x-common.h
index dfc928d..ae26dad 100644
--- a/include/configs/siemens-am33x-common.h
+++ b/include/configs/siemens-am33x-common.h
@@ -288,6 +288,8 @@
 #define CONFIG_LZO
 #define CONFIG_CMD_UBI
 #define CONFIG_CMD_UBIFS
+#define CONFIG_MTD_UBI_FASTMAP
+#define CONFIG_MTD_UBI_FASTMAP_AUTOCONVERT      1
 #endif
 
 /* Commen environment */
-- 
2.5.5

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

* [U-Boot] [PATCH v1 2/7] ubi: add new ubi command "ubi dettach"
  2016-05-25  5:07 [U-Boot] [PATCH v1 0/7] add support for the etamin draco board variant Heiko Schocher
  2016-05-25  5:07 ` [U-Boot] [PATCH v1 1/7] siemens,am33x: add ubi fastmap support Heiko Schocher
@ 2016-05-25  5:07 ` Heiko Schocher
  2016-05-25  5:47   ` Scott Wood
  2016-05-25  5:07 ` [U-Boot] [PATCH v1 3/7] nand: add nand mtd concat support Heiko Schocher
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 20+ messages in thread
From: Heiko Schocher @ 2016-05-25  5:07 UTC (permalink / raw)
  To: u-boot

simple detachs ubi fram the mtd partition.

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

 cmd/ubi.c | 38 +++++++++++++++++++++++++++-----------
 1 file changed, 27 insertions(+), 11 deletions(-)

diff --git a/cmd/ubi.c b/cmd/ubi.c
index 753a4db..bf5da42 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -443,14 +443,8 @@ static int ubi_dev_scan(struct mtd_info *info, char *ubidev,
 	return 0;
 }
 
-int ubi_part(char *part_name, const char *vid_header_offset)
+int ubi_dettach(void)
 {
-	int err = 0;
-	char mtd_dev[16];
-	struct mtd_device *dev;
-	struct part_info *part;
-	u8 pnum;
-
 	if (mtdparts_init() != 0) {
 		printf("Error initializing mtdparts!\n");
 		return 1;
@@ -466,17 +460,28 @@ int ubi_part(char *part_name, const char *vid_header_offset)
 		cmd_ubifs_umount();
 #endif
 
-	/* todo: get dev number for NAND... */
-	ubi_dev.nr = 0;
-
 	/*
 	 * Call ubi_exit() before re-initializing the UBI subsystem
 	 */
 	if (ubi_initialized) {
 		ubi_exit();
 		del_mtd_partitions(ubi_dev.mtd_info);
+		ubi_initialized = 0;
 	}
 
+	ubi_dev.selected = 0;
+	return 0;
+}
+
+int ubi_part(char *part_name, const char *vid_header_offset)
+{
+	int err = 0;
+	char mtd_dev[16];
+	struct mtd_device *dev;
+	struct part_info *part;
+	u8 pnum;
+
+	ubi_dettach();
 	/*
 	 * Search the mtd device number where this partition
 	 * is located
@@ -517,6 +522,15 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	if (argc < 2)
 		return CMD_RET_USAGE;
 
+
+	if (strcmp(argv[1], "dettach") == 0) {
+		if (argc < 2)
+			return CMD_RET_USAGE;
+
+		return ubi_dettach();
+	}
+
+
 	if (strcmp(argv[1], "part") == 0) {
 		const char *vid_header_offset = NULL;
 
@@ -661,7 +675,9 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 U_BOOT_CMD(
 	ubi, 6, 1, do_ubi,
 	"ubi commands",
-	"part [part] [offset]\n"
+	"dettach"
+		" - detach ubi from a mtd partition\n"
+	"ubi part [part] [offset]\n"
 		" - Show or set current partition (with optional VID"
 		" header offset)\n"
 	"ubi info [l[ayout]]"
-- 
2.5.5

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

* [U-Boot] [PATCH v1 3/7] nand: add nand mtd concat support
  2016-05-25  5:07 [U-Boot] [PATCH v1 0/7] add support for the etamin draco board variant Heiko Schocher
  2016-05-25  5:07 ` [U-Boot] [PATCH v1 1/7] siemens,am33x: add ubi fastmap support Heiko Schocher
  2016-05-25  5:07 ` [U-Boot] [PATCH v1 2/7] ubi: add new ubi command "ubi dettach" Heiko Schocher
@ 2016-05-25  5:07 ` Heiko Schocher
  2016-05-25  5:30   ` Scott Wood
  2016-05-25  5:07 ` [U-Boot] [PATCH v1 4/7] mtd: nand: omap: allow to switch to BCH16 Heiko Schocher
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 20+ messages in thread
From: Heiko Schocher @ 2016-05-25  5:07 UTC (permalink / raw)
  To: u-boot

add for nand devices mtd concat support. Generic MTD concat
support is already ported to mainline, and used in the cfi_mtd
driver. This patch adds it similiar for nand devices.

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

 drivers/mtd/nand/nand.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c
index 8f0a921..5413123 100644
--- a/drivers/mtd/nand/nand.c
+++ b/drivers/mtd/nand/nand.c
@@ -9,6 +9,7 @@
 #include <common.h>
 #include <nand.h>
 #include <errno.h>
+#include <linux/mtd/concat.h>
 
 #ifndef CONFIG_SYS_NAND_BASE_LIST
 #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE }
@@ -30,6 +31,12 @@ static char dev_name[CONFIG_SYS_MAX_NAND_DEVICE][8];
 
 static unsigned long total_nand_size; /* in kiB */
 
+#ifdef CONFIG_MTD_CONCAT
+static int nand_devices_found;
+static struct mtd_info *mtd_nand_list[CONFIG_SYS_MAX_NAND_DEVICE];
+static char c_mtd_name[16];
+#endif
+
 /* Register an initialized NAND mtd device with the U-Boot NAND command. */
 int nand_register(int devnum)
 {
@@ -49,6 +56,9 @@ int nand_register(int devnum)
 	 * via the mtdcore infrastructure (e.g. ubi).
 	 */
 	add_mtd_device(mtd);
+#ifdef CONFIG_MTD_CONCAT
+	mtd_nand_list[nand_devices_found++] = mtd;
+#endif
 #endif
 
 	total_nand_size += mtd->size / 1024;
@@ -102,4 +112,23 @@ void nand_init(void)
 	 */
 	board_nand_select_device(nand_info[nand_curr_device].priv, nand_curr_device);
 #endif
+
+#ifdef CONFIG_MTD_CONCAT
+	if (nand_devices_found > 1) {
+		struct mtd_info *mtd;
+
+		/*
+		 * We detected multiple devices. Concatenate them together.
+		 */
+		sprintf(c_mtd_name, "nand%d", nand_devices_found);
+		mtd = mtd_concat_create(mtd_nand_list, nand_devices_found,
+					c_mtd_name);
+
+		if (mtd == NULL)
+			return;
+
+		if (add_mtd_device(mtd))
+			return;
+	}
+#endif /* CONFIG_MTD_CONCAT */
 }
-- 
2.5.5

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

* [U-Boot] [PATCH v1 4/7] mtd: nand: omap: allow to switch to BCH16
  2016-05-25  5:07 [U-Boot] [PATCH v1 0/7] add support for the etamin draco board variant Heiko Schocher
                   ` (2 preceding siblings ...)
  2016-05-25  5:07 ` [U-Boot] [PATCH v1 3/7] nand: add nand mtd concat support Heiko Schocher
@ 2016-05-25  5:07 ` Heiko Schocher
  2016-05-25  5:07 ` [U-Boot] [PATCH v1 5/7] am335x, dxr2: get ECC sType from I2C eeprom Heiko Schocher
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Heiko Schocher @ 2016-05-25  5:07 UTC (permalink / raw)
  To: u-boot

support in omap_nand_switch_ecc() also an eccstrength
from 16.

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

 arch/arm/cpu/armv7/omap3/board.c | 6 ++++--
 drivers/mtd/nand/omap_gpmc.c     | 4 ++++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/arm/cpu/armv7/omap3/board.c b/arch/arm/cpu/armv7/omap3/board.c
index 0c44ea5..5f55977 100644
--- a/arch/arm/cpu/armv7/omap3/board.c
+++ b/arch/arm/cpu/armv7/omap3/board.c
@@ -280,6 +280,8 @@ static int do_switch_ecc(cmd_tbl_t * cmdtp, int flag, int argc, char * const arg
 				omap_nand_switch_ecc(1, 1);
 			else if (strncmp(argv[2], "bch8", 4) == 0)
 				omap_nand_switch_ecc(1, 8);
+			else if (strncmp(argv[2], "bch16", 5) == 0)
+				omap_nand_switch_ecc(1, 16);
 			else
 				goto usage;
 		}
@@ -308,8 +310,8 @@ usage:
 U_BOOT_CMD(
 	nandecc, 3, 1,	do_switch_ecc,
 	"switch OMAP3 NAND ECC calculation algorithm",
-	"hw [hamming|bch8] - Switch between NAND hardware 1-bit hamming and"
-	" 8-bit BCH\n"
+	"hw [hamming|bch8|bch16] - Switch between NAND hardware 1-bit hamming"
+	" and 8-bit/16-bit BCH\n"
 	"                           ecc calculation (second parameter may"
 	" be omitted).\n"
 	"nandecc sw               - Switch to NAND software ecc algorithm."
diff --git a/drivers/mtd/nand/omap_gpmc.c b/drivers/mtd/nand/omap_gpmc.c
index 6a45d28..b58694c 100644
--- a/drivers/mtd/nand/omap_gpmc.c
+++ b/drivers/mtd/nand/omap_gpmc.c
@@ -917,6 +917,10 @@ int __maybe_unused omap_nand_switch_ecc(uint32_t hardware, uint32_t eccstrength)
 			err = omap_select_ecc_scheme(nand,
 					OMAP_ECC_BCH8_CODE_HW,
 					mtd->writesize, mtd->oobsize);
+		} else if (eccstrength == 16) {
+			err = omap_select_ecc_scheme(nand,
+					OMAP_ECC_BCH16_CODE_HW,
+					mtd->writesize, mtd->oobsize);
 		} else {
 			printf("nand: error: unsupported ECC scheme\n");
 			return -EINVAL;
-- 
2.5.5

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

* [U-Boot] [PATCH v1 5/7] am335x, dxr2: get ECC sType from I2C eeprom
  2016-05-25  5:07 [U-Boot] [PATCH v1 0/7] add support for the etamin draco board variant Heiko Schocher
                   ` (3 preceding siblings ...)
  2016-05-25  5:07 ` [U-Boot] [PATCH v1 4/7] mtd: nand: omap: allow to switch to BCH16 Heiko Schocher
@ 2016-05-25  5:07 ` Heiko Schocher
  2016-05-25  5:07 ` [U-Boot] [PATCH v1 6/7] dfu, nand, ubi: fix erasing after write finish Heiko Schocher
  2016-05-25  5:07 ` [U-Boot] [PATCH v1 7/7] siemens,am33x: add draco etamin board Heiko Schocher
  6 siblings, 0 replies; 20+ messages in thread
From: Heiko Schocher @ 2016-05-25  5:07 UTC (permalink / raw)
  To: u-boot

read the ECC Type field from the i2c eeprom, instead
configuring it static in the U-Boot binary.

see RM:
Table 26-17. NAND Geometry Information on I2C EEPROM

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

 board/siemens/draco/board.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/board/siemens/draco/board.c b/board/siemens/draco/board.c
index 988c12a..41bdef0 100644
--- a/board/siemens/draco/board.c
+++ b/board/siemens/draco/board.c
@@ -105,6 +105,40 @@ static void print_chip_data(void)
 }
 #endif /* CONFIG_SPL_BUILD */
 
+#define AM335X_NAND_ECC_MASK 0x0f
+#define AM335X_NAND_ECC_TYPE_16 0x02
+
+static int ecc_type;
+
+struct am335x_nand_geometry {
+	u32 magic;
+	u8 nand_geo_addr;
+	u8 nand_geo_page;
+	u8 nand_bus;
+};
+
+static int draco_read_nand_geometry(void)
+{
+	struct am335x_nand_geometry geo;
+
+	/* Read NAND geometry */
+	if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0x80, 2,
+		     (uchar *)&geo, sizeof(struct am335x_nand_geometry))) {
+		printf("Could not read the NAND geomtery; something fundamentally wrong on the I2C bus.\n");
+		return -EIO;
+	}
+	if (geo.magic != 0xa657b310) {
+		printf("%s: bad magic: %x\n", __func__, geo.magic);
+		return -EFAULT;
+	}
+	if ((geo.nand_bus & AM335X_NAND_ECC_MASK) == AM335X_NAND_ECC_TYPE_16)
+		ecc_type = 16;
+	else
+		ecc_type = 8;
+
+	return 0;
+}
+
 /*
  * Read header information from EEPROM into global structure.
  */
@@ -147,6 +181,8 @@ static int read_eeprom(void)
 		printf("Warning: No chip data in eeprom\n");
 
 	print_ddr3_timings();
+
+	return draco_read_nand_geometry();
 #endif
 	return 0;
 }
@@ -207,7 +243,14 @@ static void spl_siemens_board_init(void)
 #ifdef CONFIG_BOARD_LATE_INIT
 int board_late_init(void)
 {
-	omap_nand_switch_ecc(1, 8);
+	int ret;
+
+	ret = draco_read_nand_geometry();
+	if (ret != 0)
+		return ret;
+
+	nand_curr_device = 0;
+	omap_nand_switch_ecc(1, ecc_type);
 #ifdef CONFIG_FACTORYSET
 	/* Set ASN in environment*/
 	if (factory_dat.asn[0] != 0) {
-- 
2.5.5

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

* [U-Boot] [PATCH v1 6/7] dfu, nand, ubi: fix erasing after write finish
  2016-05-25  5:07 [U-Boot] [PATCH v1 0/7] add support for the etamin draco board variant Heiko Schocher
                   ` (4 preceding siblings ...)
  2016-05-25  5:07 ` [U-Boot] [PATCH v1 5/7] am335x, dxr2: get ECC sType from I2C eeprom Heiko Schocher
@ 2016-05-25  5:07 ` Heiko Schocher
  2016-05-25  5:33   ` Scott Wood
  2016-05-25  5:07 ` [U-Boot] [PATCH v1 7/7] siemens,am33x: add draco etamin board Heiko Schocher
  6 siblings, 1 reply; 20+ messages in thread
From: Heiko Schocher @ 2016-05-25  5:07 UTC (permalink / raw)
  To: u-boot

writting to ubi nand partitions need after write ends an erase
of the remaining sectors. This fail, if dfu write size was not
a multiple of erasesize, example log:

Failure erase: -1

Fix this error.

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

 drivers/dfu/dfu_nand.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/dfu/dfu_nand.c b/drivers/dfu/dfu_nand.c
index da2278e..f60d032 100644
--- a/drivers/dfu/dfu_nand.c
+++ b/drivers/dfu/dfu_nand.c
@@ -143,6 +143,7 @@ static int dfu_read_medium_nand(struct dfu_entity *dfu, u64 offset, void *buf,
 static int dfu_flush_medium_nand(struct dfu_entity *dfu)
 {
 	int ret = 0;
+	u64 off;
 
 	/* in case of ubi partition, erase rest of the partition */
 	if (dfu->data.nand.ubi) {
@@ -159,7 +160,16 @@ static int dfu_flush_medium_nand(struct dfu_entity *dfu)
 		nand = &nand_info[nand_curr_device];
 
 		memset(&opts, 0, sizeof(opts));
-		opts.offset = dfu->data.nand.start + dfu->offset +
+		off = dfu->offset;
+		if ((off & (nand->erasesize - 1)) != 0) {
+			/*
+			 * last write ended with unaligned length
+			 * sector is erased, jump to next
+			 */
+			off = off & ~((nand->erasesize - 1));
+			off += nand->erasesize;
+		}
+		opts.offset = dfu->data.nand.start + off +
 				dfu->bad_skip;
 		opts.length = dfu->data.nand.start +
 				dfu->data.nand.size - opts.offset;
-- 
2.5.5

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

* [U-Boot] [PATCH v1 7/7] siemens,am33x: add draco etamin board
  2016-05-25  5:07 [U-Boot] [PATCH v1 0/7] add support for the etamin draco board variant Heiko Schocher
                   ` (5 preceding siblings ...)
  2016-05-25  5:07 ` [U-Boot] [PATCH v1 6/7] dfu, nand, ubi: fix erasing after write finish Heiko Schocher
@ 2016-05-25  5:07 ` Heiko Schocher
  6 siblings, 0 replies; 20+ messages in thread
From: Heiko Schocher @ 2016-05-25  5:07 UTC (permalink / raw)
  To: u-boot

In the draco CPU board family, etamin is a new variant
with bigger flash and more RAM. Due to new flash that
uses larger pages (4K) some changes are necessary because
it impacts the MTD partition layout and the ubi mount
parameters.

Signed-off-by: Samuel Egli <samuel.egli@siemens.com>
Signed-off-by: Heiko Schocher <hs@denx.de>
---

 arch/arm/Kconfig                       |   5 +
 board/siemens/common/board.c           |   4 +
 board/siemens/draco/Kconfig            |  16 ++
 board/siemens/draco/MAINTAINERS        |   1 +
 board/siemens/draco/board.c            |  39 ++++-
 board/siemens/draco/mux.c              |   2 +-
 configs/etamin_defconfig               |  17 +++
 include/configs/draco.h                |   1 +
 include/configs/etamin.h               | 261 +++++++++++++++++++++++++++++++++
 include/configs/pxm2.h                 |   1 +
 include/configs/rastaban.h             |   1 +
 include/configs/rut.h                  |   1 +
 include/configs/siemens-am33x-common.h |   5 +-
 include/configs/thuban.h               |   1 +
 14 files changed, 351 insertions(+), 4 deletions(-)
 create mode 100644 configs/etamin_defconfig
 create mode 100644 include/configs/etamin.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 6b65d8e..f72ce5c 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -339,6 +339,11 @@ config TARGET_RASTABAN
 	select CPU_V7
 	select SUPPORT_SPL
 
+config TARGET_ETAMIN
+        bool "Support etamin"
+        select CPU_V7
+        select SUPPORT_SPL
+
 config TARGET_PXM2
 	bool "Support pxm2"
 	select CPU_V7
diff --git a/board/siemens/common/board.c b/board/siemens/common/board.c
index c127f6c..9cafcea 100644
--- a/board/siemens/common/board.c
+++ b/board/siemens/common/board.c
@@ -83,8 +83,12 @@ int board_init(void)
 #ifdef CONFIG_FACTORYSET
 	factoryset_read_eeprom(CONFIG_SYS_I2C_EEPROM_ADDR);
 #endif
+
 	gpmc_init();
 
+#ifdef CONFIG_NAND_CS_INIT
+	board_nand_cs_init();
+#endif
 #ifdef CONFIG_VIDEO
 	board_video_init();
 #endif
diff --git a/board/siemens/draco/Kconfig b/board/siemens/draco/Kconfig
index 819d187..a699c7d 100644
--- a/board/siemens/draco/Kconfig
+++ b/board/siemens/draco/Kconfig
@@ -45,3 +45,19 @@ config SYS_CONFIG_NAME
 	default "rastaban"
 
 endif
+
+if TARGET_ETAMIN
+
+config SYS_BOARD
+        default "draco"
+
+config SYS_VENDOR
+        default "siemens"
+
+config SYS_SOC
+        default "am33xx"
+
+config SYS_CONFIG_NAME
+        default "etamin"
+
+endif
diff --git a/board/siemens/draco/MAINTAINERS b/board/siemens/draco/MAINTAINERS
index 484dd73..e9107f0 100644
--- a/board/siemens/draco/MAINTAINERS
+++ b/board/siemens/draco/MAINTAINERS
@@ -4,6 +4,7 @@ S:	Maintained
 F:	board/siemens/draco/
 F:	include/configs/draco.h
 F:	configs/draco_defconfig
+F:	configs/etamin_defconfig
 F:	include/configs/thuban.h
 F:	configs/thuban_defconfig
 F:	include/configs/rastaban.h
diff --git a/board/siemens/draco/board.c b/board/siemens/draco/board.c
index 41bdef0..d8869a0 100644
--- a/board/siemens/draco/board.c
+++ b/board/siemens/draco/board.c
@@ -24,6 +24,7 @@
 #include <asm/arch/gpio.h>
 #include <asm/arch/mmc_host_def.h>
 #include <asm/arch/sys_proto.h>
+#include <asm/arch/mem.h>
 #include <asm/io.h>
 #include <asm/emif.h>
 #include <asm/gpio.h>
@@ -33,6 +34,7 @@
 #include <watchdog.h>
 #include "board.h"
 #include "../common/factoryset.h"
+#include <nand.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -40,6 +42,7 @@ DECLARE_GLOBAL_DATA_PTR;
 static struct draco_baseboard_id __attribute__((section(".data"))) settings;
 
 #if DDR_PLL_FREQ == 303
+#if !defined(CONFIG_TARGET_ETAMIN)
 /* Default at 303MHz-i0 */
 const struct ddr3_data ddr3_default = {
 	0x33524444, 0x56312e35, 0x0080, 0x0000, 0x003A, 0x003F, 0x009F,
@@ -48,6 +51,16 @@ const struct ddr3_data ddr3_default = {
 	"default name @303MHz           \0",
 	"default marking                \0",
 };
+#else
+/* etamin board */
+const struct ddr3_data ddr3_default = {
+	0x33524444, 0x56312e36, 0x0080, 0x0000, 0x003A, 0x0010, 0x009F,
+	0x0050, 0x0888A39B, 0x266D7FDA, 0x501F86AF, 0x00100206, 0x61A44BB2,
+	0x0000093B, 0x0000018A,
+	"test-etamin                    \0",
+	"generic-8Gbit                  \0",
+};
+#endif
 #elif DDR_PLL_FREQ == 400
 /* Default at 400MHz-i0 */
 const struct ddr3_data ddr3_default = {
@@ -210,6 +223,7 @@ struct ctrl_ioregs draco_ddr3_ioregs = {
 	draco_ddr3_emif_reg_data.emif_ddr_phy_ctlr_1 =
 		settings.ddr3.emif_ddr_phy_ctlr_1;
 	draco_ddr3_emif_reg_data.sdram_config = settings.ddr3.sdram_config;
+	draco_ddr3_emif_reg_data.sdram_config2 = 0x08000000;
 	draco_ddr3_emif_reg_data.ref_ctrl = settings.ddr3.ref_ctrl;
 
 	draco_ddr3_data.datardsratio0 = settings.ddr3.dt0rdsratio0;
@@ -251,6 +265,10 @@ int board_late_init(void)
 
 	nand_curr_device = 0;
 	omap_nand_switch_ecc(1, ecc_type);
+#ifdef CONFIG_TARGET_ETAMIN
+	nand_curr_device = 1;
+	omap_nand_switch_ecc(1, ecc_type);
+#endif
 #ifdef CONFIG_FACTORYSET
 	/* Set ASN in environment*/
 	if (factory_dat.asn[0] != 0) {
@@ -326,7 +344,7 @@ int board_eth_init(bd_t *bis)
 }
 
 static int do_switch_reset(cmd_tbl_t *cmdtp, int flag, int argc,
-			   char *const argv[])
+			  char *const argv[])
 {
 	/* Reset SMSC LAN9303 switch for default configuration */
 	gpio_request(GPIO_LAN9303_NRST, "nRST");
@@ -346,4 +364,23 @@ U_BOOT_CMD(
 #endif /* #if defined(CONFIG_DRIVER_TI_CPSW) */
 #endif /* #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) */
 
+#ifdef CONFIG_NAND_CS_INIT
+/* GPMC definitions for second nand cs1 */
+static const u32 gpmc_nand_config[] = {
+	ETAMIN_NAND_GPMC_CONFIG1,
+	ETAMIN_NAND_GPMC_CONFIG2,
+	ETAMIN_NAND_GPMC_CONFIG3,
+	ETAMIN_NAND_GPMC_CONFIG4,
+	ETAMIN_NAND_GPMC_CONFIG5,
+	ETAMIN_NAND_GPMC_CONFIG6,
+	/*CONFIG7- computed as params */
+};
+
+static void board_nand_cs_init(void)
+{
+	enable_gpmc_cs_config(gpmc_nand_config, &gpmc_cfg->cs[1],
+			      0x18000000, GPMC_SIZE_16M);
+}
+#endif
+
 #include "../common/board.c"
diff --git a/board/siemens/draco/mux.c b/board/siemens/draco/mux.c
index dbcc80b..38a484e 100644
--- a/board/siemens/draco/mux.c
+++ b/board/siemens/draco/mux.c
@@ -51,6 +51,7 @@ static struct module_pin_mux nand_pin_mux[] = {
 	{OFFSET(gpmc_wait0), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* NAND WAIT */
 	{OFFSET(gpmc_wpn), (MODE(7) | PULLUP_EN | RXACTIVE)},	/* NAND_WPN */
 	{OFFSET(gpmc_csn0), (MODE(0) | PULLUDEN)},	/* NAND_CS0 */
+	{OFFSET(gpmc_csn1), MODE(0) | PULLUDEN | PULLUP_EN},    /* NAND_CS1 */
 	{OFFSET(gpmc_advn_ale), (MODE(0) | PULLUDEN)}, /* NAND_ADV_ALE */
 	{OFFSET(gpmc_oen_ren), (MODE(0) | PULLUDEN)},	/* NAND_OE */
 	{OFFSET(gpmc_wen), (MODE(0) | PULLUDEN)},	/* NAND_WEN */
@@ -68,7 +69,6 @@ static struct module_pin_mux gpios_pin_mux[] = {
 	{OFFSET(mmc0_dat1), MODE(7) | PULLUDDIS | RXACTIVE},	/* Y3 GPIO2_28*/
 	{OFFSET(mmc0_dat2), MODE(7) | PULLUDDIS | RXACTIVE},	/* Y7 GPIO2_27*/
 	/* Triacs initial HW Rev */
-	{OFFSET(gpmc_csn1), MODE(7) | RXACTIVE | PULLUDDIS},	/* 1_30 Y0 */
 	{OFFSET(gpmc_be1n), MODE(7) | RXACTIVE | PULLUDDIS},	/* 1_28 Y1 */
 	{OFFSET(gpmc_csn2), MODE(7) | RXACTIVE | PULLUDDIS},	/* 1_31 Y2 */
 	{OFFSET(lcd_data15), MODE(7) | RXACTIVE | PULLUDDIS},	/* 0_11 Y3 */
diff --git a/configs/etamin_defconfig b/configs/etamin_defconfig
new file mode 100644
index 0000000..3f21bc4
--- /dev/null
+++ b/configs/etamin_defconfig
@@ -0,0 +1,17 @@
+CONFIG_ARM=y
+CONFIG_TARGET_ETAMIN=y
+CONFIG_SPL=y
+CONFIG_SYS_PROMPT="U-Boot# "
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_PROMPT="Autobooting in %d seconds, press \"<Esc><Esc>\" to stop\n"
+CONFIG_AUTOBOOT_STOP_STR="\x1b\x1b"
+# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_GPIO=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_WINBOND=y
+CONFIG_SYS_NS16550=y
+CONFIG_USB=y
+CONFIG_USB_GADGET=y
+CONFIG_OF_LIBFDT=y
diff --git a/include/configs/draco.h b/include/configs/draco.h
index 8aee25b..35642a5 100644
--- a/include/configs/draco.h
+++ b/include/configs/draco.h
@@ -73,6 +73,7 @@
 /* Default env settings */
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	"hostname=draco\0" \
+	"ubi_off=2048\0"\
 	"nand_img_size=0x400000\0" \
 	"optargs=\0" \
 	"preboot=draco_led 0\0" \
diff --git a/include/configs/etamin.h b/include/configs/etamin.h
new file mode 100644
index 0000000..5eb5b45
--- /dev/null
+++ b/include/configs/etamin.h
@@ -0,0 +1,261 @@
+/*
+ * (C) Copyright 2013 Siemens Schweiz AG
+ * (C) Heiko Schocher, DENX Software Engineering, hs at denx.de.
+ *
+ * Based on:
+ * U-Boot file:/include/configs/am335x_evm.h
+ *
+ * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __CONFIG_ETAMIN_H
+#define __CONFIG_ETAMIN_H
+
+#include "siemens-am33x-common.h"
+/* NAND specific changes for etamin due to different page size */
+#undef CONFIG_SYS_NAND_PAGE_SIZE
+#undef CONFIG_SYS_NAND_OOBSIZE
+#undef CONFIG_SYS_NAND_BLOCK_SIZE
+#undef CONFIG_SYS_NAND_ECCPOS
+#undef CONFIG_SYS_NAND_U_BOOT_OFFS
+#undef CONFIG_SYS_ENV_SECT_SIZE
+#undef CONFIG_ENV_OFFSET
+#undef CONFIG_NAND_OMAP_ECCSCHEME
+#define CONFIG_NAND_OMAP_ECCSCHEME	OMAP_ECC_BCH16_CODE_HW
+
+#define CONFIG_ENV_OFFSET       0x980000
+#define CONFIG_SYS_ENV_SECT_SIZE       (512 << 10)     /* 512 KiB */
+#define CONFIG_SYS_NAND_PAGE_SIZE       4096
+#define CONFIG_SYS_NAND_OOBSIZE         224
+#define CONFIG_SYS_NAND_BLOCK_SIZE      (128 * CONFIG_SYS_NAND_PAGE_SIZE)
+#define CONFIG_SYS_NAND_ECCPOS	{ 2, 3, 4, 5, 6, 7, 8, 9, \
+				10, 11, 12, 13, 14, 15, 16, 17, 18, 19, \
+				20, 21, 22, 23, 24, 25, 26, 27, 28, 29, \
+				30, 31, 32, 33, 34, 35, 36, 37, 38, 39, \
+				40, 41, 42, 43, 44, 45, 46, 47, 48, 49, \
+				50, 51, 52, 53, 54, 55, 56, 57, 58, 59, \
+				60, 61, 62, 63, 64, 65, 66, 67, 68, 69, \
+				70, 71, 72, 73, 74, 75, 76, 77, 78, 79, \
+				80, 81, 82, 83, 84, 85, 86, 87, 88, 89, \
+				90, 91, 92, 93, 94, 95, 96, 97, 98, 99, \
+			100, 101, 102, 103, 104, 105, 106, 107, 108, 109, \
+			110, 111, 112, 113, 114, 115, 116, 117, 118, 119, \
+			120, 121, 122, 123, 124, 125, 126, 127, 128, 129, \
+			130, 131, 132, 133, 134, 135, 136, 137, 138, 139, \
+			140, 141, 142, 143, 144, 145, 146, 147, 148, 149, \
+			150, 151, 152, 153, 154, 155, 156, 157, 158, 159, \
+			160, 161, 162, 163, 164, 165, 166, 167, 168, 169, \
+			170, 171, 172, 173, 174, 175, 176, 177, 178, 179, \
+			180, 181, 182, 183, 184, 185, 186, 187, 188, 189, \
+			190, 191, 192, 193, 194, 195, 196, 197, 198, 199, \
+			200, 201, 202, 203, 204, 205, 206, 207, 208, 209, \
+			}
+
+#undef CONFIG_SYS_NAND_ECCSIZE
+#undef CONFIG_SYS_NAND_ECCBYTES
+#define CONFIG_SYS_NAND_ECCSIZE 512
+#define CONFIG_SYS_NAND_ECCBYTES 26
+
+#define CONFIG_SYS_NAND_U_BOOT_OFFS     0x200000
+
+#define CONFIG_SYS_NAND_MAX_CHIPS       1
+
+#undef CONFIG_SYS_MAX_NAND_DEVICE
+#define CONFIG_SYS_MAX_NAND_DEVICE      2
+#define CONFIG_SYS_NAND_BASE2           (0x18000000)    /* physical address */
+#define CONFIG_SYS_NAND_BASE_LIST       {CONFIG_SYS_NAND_BASE, \
+					CONFIG_SYS_NAND_BASE2}
+
+#define CONFIG_SYS_NAND_ONFI_DETECTION
+#define CONFIG_DISPLAY_CPUINFO
+#define CONFIG_SYS_MPUCLK	300
+#define DDR_PLL_FREQ	303
+#undef CONFIG_SPL_AM33XX_ENABLE_RTC32K_OSC
+
+/* FWD Button = 27
+ * SRV Button = 87 */
+#define BOARD_DFU_BUTTON_GPIO	27
+#define GPIO_LAN9303_NRST	88	/* GPIO2_24 = gpio88 */
+/* In dfu mode keep led1 on */
+#define CONFIG_ENV_SETTINGS_BUTTONS_AND_LEDS \
+	"button_dfu0=27\0" \
+	"button_dfu1=87\0" \
+	"led0=3,0,1\0" \
+	"led1=4,0,0\0" \
+	"led2=5,0,1\0" \
+	"led3=87,0,1\0" \
+	"led4=60,0,1\0" \
+	"led5=63,0,1\0"
+
+#undef CONFIG_DOS_PARTITION
+#undef CONFIG_CMD_FAT
+
+#define CONFIG_BOARD_LATE_INIT
+
+/* Physical Memory Map */
+#define CONFIG_MAX_RAM_BANK_SIZE       (1024 << 20)    /* 1GB */
+
+/* I2C Configuration */
+#define CONFIG_SYS_I2C_SPEED		100000
+
+#define CONFIG_SYS_I2C_EEPROM_ADDR              0x50
+#define EEPROM_ADDR_DDR3 0x90
+#define EEPROM_ADDR_CHIP 0x120
+
+#define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS	0x300
+
+#undef CONFIG_SPL_NET_SUPPORT
+#undef CONFIG_SPL_NET_VCI_STRING
+#undef CONFIG_SPL_ETH_SUPPORT
+
+#undef CONFIG_MII
+#undef CONFIG_PHY_GIGE
+#define CONFIG_PHY_SMSC
+
+#define CONFIG_FACTORYSET
+
+/* use both define to compile a SPL compliance test  */
+/*
+#define CONFIG_SPL_CMT
+#define CONFIG_SPL_CMT_DEBUG
+*/
+
+/* nedded by compliance test in read mode */
+#if defined(CONFIG_SPL_CMT)
+#define CONFIG_SYS_DCACHE_OFF
+#endif
+
+/* Watchdog */
+#define CONFIG_OMAP_WATCHDOG
+
+/* Define own nand partitions */
+#define CONFIG_ENV_OFFSET_REDUND	0xB80000
+#define CONFIG_ENV_SIZE_REDUND		CONFIG_ENV_SIZE
+#define CONFIG_ENV_RANGE		(4 * CONFIG_SYS_ENV_SECT_SIZE)
+
+
+
+#define CONFIG_DFU_MTD
+#undef COMMON_ENV_DFU_ARGS
+#define COMMON_ENV_DFU_ARGS	"dfu_args=run bootargs_defaults;" \
+				"setenv bootargs ${bootargs};" \
+				"mtdparts default;" \
+				"draco_led 1;" \
+				"dfu 0 mtd 0;" \
+				"draco_led 0;\0" \
+
+#undef DFU_ALT_INFO_NAND_V2
+#define DFU_ALT_INFO_NAND_V2 \
+	"spl mtddev;" \
+	"spl.backup1 mtddev;" \
+	"spl.backup2 mtddev;" \
+	"spl.backup3 mtddev;" \
+	"u-boot mtddev;" \
+	"u-boot.env0 mtddev;" \
+	"u-boot.env1 mtddev;" \
+	"rootfs mtddevubi" \
+
+#undef MTDIDS_NAME_STR
+#define MTDIDS_NAME_STR		"omap2-nand_concat"
+#undef MTDIDS_DEFAULT
+#define MTDIDS_DEFAULT		"nand2=" MTDIDS_NAME_STR
+
+#undef MTDPARTS_DEFAULT_V2
+#define MTDPARTS_DEFAULT_V2     "mtdparts=" MTDIDS_NAME_STR ":" \
+				"512k(spl)," \
+				"512k(spl.backup1)," \
+				"512k(spl.backup2)," \
+				"512k(spl.backup3)," \
+				"7680k(u-boot)," \
+				"2048k(u-boot.env0)," \
+				"2048k(u-boot.env1)," \
+				"2048k(mtdoops)," \
+				"-(rootfs)"
+
+#undef MTDPARTS_DEFAULT
+#define MTDPARTS_DEFAULT	MTDPARTS_DEFAULT_V2
+
+#undef CONFIG_ENV_SETTINGS_NAND_V2
+#define CONFIG_ENV_SETTINGS_NAND_V2 \
+	"nand_active_ubi_vol=rootfs_a\0" \
+	"rootfs_name=rootfs\0" \
+	"kernel_name=uImage\0"\
+	"nand_root_fs_type=ubifs rootwait=1\0" \
+	"nand_args=run bootargs_defaults;" \
+		"mtdparts default;" \
+		"setenv ${partitionset_active} true;" \
+		"if test -n ${A}; then " \
+			"setenv nand_active_ubi_vol ${rootfs_name}_a;" \
+		"fi;" \
+		"if test -n ${B}; then " \
+			"setenv nand_active_ubi_vol ${rootfs_name}_b;" \
+		"fi;" \
+		"setenv nand_root ubi0:${nand_active_ubi_vol} rw " \
+		"ubi.mtd=rootfs,${ubi_off};" \
+		"setenv bootargs ${bootargs} " \
+		"root=${nand_root} noinitrd ${mtdparts} " \
+		"rootfstype=${nand_root_fs_type} ip=${ip_method} " \
+		"console=ttyMTD,mtdoops console=ttyO0,115200n8 mtdoops.mtddev" \
+		"=mtdoops\0" \
+	COMMON_ENV_DFU_ARGS \
+		"dfu_alt_info=" DFU_ALT_INFO_NAND_V2 "\0" \
+	COMMON_ENV_NAND_BOOT \
+		"ubi part rootfs ${ubi_off};" \
+		"ubifsmount ubi0:${nand_active_ubi_vol};" \
+		"ubifsload ${kloadaddr} boot/${kernel_name};" \
+		"ubifsload ${loadaddr} boot/${dtb_name}.dtb;" \
+		"bootm ${kloadaddr} - ${loadaddr}\0" \
+	"nand_boot_backup=ubifsload ${loadaddr} boot/am335x-draco.dtb;" \
+		"bootm ${kloadaddr} - ${loadaddr}\0" \
+	COMMON_ENV_NAND_CMDS
+
+#ifndef CONFIG_SPL_BUILD
+
+#define CONFIG_NAND_CS_INIT
+#define ETAMIN_NAND_GPMC_CONFIG1	0x00000800
+#define ETAMIN_NAND_GPMC_CONFIG2	0x001e1e00
+#define ETAMIN_NAND_GPMC_CONFIG3	0x001e1e00
+#define ETAMIN_NAND_GPMC_CONFIG4	0x16051807
+#define ETAMIN_NAND_GPMC_CONFIG5	0x00151e1e
+#define ETAMIN_NAND_GPMC_CONFIG6	0x16000f80
+#define CONFIG_MTD_CONCAT
+
+/* Default env settings */
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	"hostname=etamin\0" \
+	"ubi_off=4096\0"\
+	"nand_img_size=0x400000\0" \
+	"optargs=\0" \
+	"preboot=draco_led 0\0" \
+	CONFIG_ENV_SETTINGS_BUTTONS_AND_LEDS \
+	CONFIG_ENV_SETTINGS_V2 \
+	CONFIG_ENV_SETTINGS_NAND_V2
+
+#ifndef CONFIG_RESTORE_FLASH
+/* set to negative value for no autoboot */
+#define CONFIG_BOOTDELAY		3
+
+#define CONFIG_BOOTCOMMAND \
+"if dfubutton; then " \
+	"run dfu_start; " \
+	"reset; " \
+"fi;" \
+"run nand_boot;" \
+"run nand_boot_backup;" \
+"reset;"
+
+
+#else
+#define CONFIG_BOOTDELAY		0
+
+#define CONFIG_BOOTCOMMAND			\
+	"setenv autoload no; "			\
+	"dhcp; "				\
+	"if tftp 80000000 debrick.scr; then "	\
+		"source 80000000; "		\
+	"fi"
+#endif
+#endif	/* CONFIG_SPL_BUILD */
+#endif	/* ! __CONFIG_ETAMIN_H */
diff --git a/include/configs/pxm2.h b/include/configs/pxm2.h
index 7450a1a..3f5e0ea 100644
--- a/include/configs/pxm2.h
+++ b/include/configs/pxm2.h
@@ -61,6 +61,7 @@
 /* Default env settings */
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	"hostname=pxm2\0" \
+	"ubi_off=2048\0"\
 	"nand_img_size=0x500000\0" \
 	"optargs=\0" \
 	"preboot=draco_led 0\0" \
diff --git a/include/configs/rastaban.h b/include/configs/rastaban.h
index 47d2379..3fd431c 100644
--- a/include/configs/rastaban.h
+++ b/include/configs/rastaban.h
@@ -76,6 +76,7 @@
 /* Default env settings */
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	"hostname=rastaban\0" \
+	"ubi_off=2048\0"\
 	"nand_img_size=0x400000\0" \
 	"optargs=\0" \
 	"preboot=draco_led 0\0" \
diff --git a/include/configs/rut.h b/include/configs/rut.h
index bf2cc2f..fcca849 100644
--- a/include/configs/rut.h
+++ b/include/configs/rut.h
@@ -56,6 +56,7 @@
 /* Default env settings */
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	"hostname=rut\0" \
+	"ubi_off=2048\0"\
 	"nand_img_size=0x500000\0" \
 	"splashpos=m,m\0" \
 	"optargs=fixrtc --no-log consoleblank=0 \0" \
diff --git a/include/configs/siemens-am33x-common.h b/include/configs/siemens-am33x-common.h
index ae26dad..5969541 100644
--- a/include/configs/siemens-am33x-common.h
+++ b/include/configs/siemens-am33x-common.h
@@ -159,6 +159,7 @@
 #define CONFIG_SPL_NAND_BASE
 #define CONFIG_SPL_NAND_DRIVERS
 #define CONFIG_SPL_NAND_ECC
+#define CONFIG_SYS_NAND_ONFI_DETECTION
 #define CONFIG_SYS_NAND_5_ADDR_CYCLE
 #define CONFIG_SYS_NAND_PAGE_COUNT	(CONFIG_SYS_NAND_BLOCK_SIZE / \
 					 CONFIG_SYS_NAND_PAGE_SIZE)
@@ -421,7 +422,7 @@
 			"setenv nand_src_addr ${nand_src_addr_B};" \
 		"fi;" \
 		"setenv nand_root ubi0:${nand_active_ubi_vol} rw " \
-		"ubi.mtd=9,2048;" \
+		"ubi.mtd=9,${ubi_off};" \
 		"setenv bootargs ${bootargs} " \
 		"root=${nand_root} noinitrd ${mtdparts} " \
 		"rootfstype=${nand_root_fs_type} ip=${ip_method} " \
@@ -513,7 +514,7 @@
 	COMMON_ENV_DFU_ARGS \
 		"dfu_alt_info=" DFU_ALT_INFO_NAND_V2 "\0" \
 	COMMON_ENV_NAND_BOOT \
-		"ubi part rootfs 2048;" \
+		"ubi part rootfs ${ubi_off};" \
 		"ubifsmount ubi0:${nand_active_ubi_vol};" \
 		"ubifsload ${kloadaddr} boot/${kernel_name};" \
 		"ubifsload ${loadaddr} boot/${dtb_name}.dtb;" \
diff --git a/include/configs/thuban.h b/include/configs/thuban.h
index 5fed55d..5daf071 100644
--- a/include/configs/thuban.h
+++ b/include/configs/thuban.h
@@ -69,6 +69,7 @@
 /* Default env settings */
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	"hostname=thuban\0" \
+	"ubi_off=2048\0"\
 	"nand_img_size=0x400000\0" \
 	"optargs=\0" \
 	"preboot=draco_led 0\0" \
-- 
2.5.5

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

* [U-Boot] [PATCH v1 3/7] nand: add nand mtd concat support
  2016-05-25  5:07 ` [U-Boot] [PATCH v1 3/7] nand: add nand mtd concat support Heiko Schocher
@ 2016-05-25  5:30   ` Scott Wood
  2016-05-25  6:10     ` Heiko Schocher
  0 siblings, 1 reply; 20+ messages in thread
From: Scott Wood @ 2016-05-25  5:30 UTC (permalink / raw)
  To: u-boot

On 05/25/2016 12:07 AM, Heiko Schocher wrote:
> add for nand devices mtd concat support. Generic MTD concat
> support is already ported to mainline, and used in the cfi_mtd
> driver. This patch adds it similiar for nand devices.
> 
> Signed-off-by: Heiko Schocher <hs@denx.de>
> ---
> 
>  drivers/mtd/nand/nand.c | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c
> index 8f0a921..5413123 100644
> --- a/drivers/mtd/nand/nand.c
> +++ b/drivers/mtd/nand/nand.c
> @@ -9,6 +9,7 @@
>  #include <common.h>
>  #include <nand.h>
>  #include <errno.h>
> +#include <linux/mtd/concat.h>
>  
>  #ifndef CONFIG_SYS_NAND_BASE_LIST
>  #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE }
> @@ -30,6 +31,12 @@ static char dev_name[CONFIG_SYS_MAX_NAND_DEVICE][8];
>  
>  static unsigned long total_nand_size; /* in kiB */
>  
> +#ifdef CONFIG_MTD_CONCAT
> +static int nand_devices_found;
> +static struct mtd_info *mtd_nand_list[CONFIG_SYS_MAX_NAND_DEVICE];
> +static char c_mtd_name[16];
> +#endif

Why is c_mtd_name file-scope rather than local?

> +
>  /* Register an initialized NAND mtd device with the U-Boot NAND command. */
>  int nand_register(int devnum)
>  {
> @@ -49,6 +56,9 @@ int nand_register(int devnum)
>  	 * via the mtdcore infrastructure (e.g. ubi).
>  	 */
>  	add_mtd_device(mtd);
> +#ifdef CONFIG_MTD_CONCAT
> +	mtd_nand_list[nand_devices_found++] = mtd;
> +#endif

Why do we need another list of NAND devices?  Use nand_info[].

>  #endif
>  
>  	total_nand_size += mtd->size / 1024;
> @@ -102,4 +112,23 @@ void nand_init(void)
>  	 */
>  	board_nand_select_device(nand_info[nand_curr_device].priv, nand_curr_device);
>  #endif
> +
> +#ifdef CONFIG_MTD_CONCAT
> +	if (nand_devices_found > 1) {
> +		struct mtd_info *mtd;
> +
> +		/*
> +		 * We detected multiple devices. Concatenate them together.
> +		 */
> +		sprintf(c_mtd_name, "nand%d", nand_devices_found);
> +		mtd = mtd_concat_create(mtd_nand_list, nand_devices_found,
> +					c_mtd_name);
> +
> +		if (mtd == NULL)
> +			return;
> +
> +		if (add_mtd_device(mtd))
> +			return;
> +	}
> +#endif /* CONFIG_MTD_CONCAT */
>  }

Please don't add new features that depend on the old-style NAND init.

-Scott

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

* [U-Boot] [PATCH v1 6/7] dfu, nand, ubi: fix erasing after write finish
  2016-05-25  5:07 ` [U-Boot] [PATCH v1 6/7] dfu, nand, ubi: fix erasing after write finish Heiko Schocher
@ 2016-05-25  5:33   ` Scott Wood
  2016-05-25  6:21     ` Heiko Schocher
  0 siblings, 1 reply; 20+ messages in thread
From: Scott Wood @ 2016-05-25  5:33 UTC (permalink / raw)
  To: u-boot

On 05/25/2016 12:07 AM, Heiko Schocher wrote:
> writting to ubi nand partitions need after write ends an erase
> of the remaining sectors. This fail, if dfu write size was not
> a multiple of erasesize, example log:
> 
> Failure erase: -1
> 
> Fix this error.
> 
> Signed-off-by: Heiko Schocher <hs@denx.de>

Why don't you just erase the whole partition up front?

-Scott

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

* [U-Boot] [PATCH v1 2/7] ubi: add new ubi command "ubi dettach"
  2016-05-25  5:07 ` [U-Boot] [PATCH v1 2/7] ubi: add new ubi command "ubi dettach" Heiko Schocher
@ 2016-05-25  5:47   ` Scott Wood
  2016-05-25  6:28     ` Heiko Schocher
  0 siblings, 1 reply; 20+ messages in thread
From: Scott Wood @ 2016-05-25  5:47 UTC (permalink / raw)
  To: u-boot

On 05/25/2016 12:07 AM, Heiko Schocher wrote:
> @@ -661,7 +675,9 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>  U_BOOT_CMD(
>  	ubi, 6, 1, do_ubi,
>  	"ubi commands",
> -	"part [part] [offset]\n"
> +	"dettach"

"detach", here and elsewhere.

> +		" - detach ubi from a mtd partition\n"

Like that. :-)

-Scott

P.S. When CCing me, please use oss at buserror.net so that my responses
don't have to go through moderation.

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

* [U-Boot] [PATCH v1 3/7] nand: add nand mtd concat support
  2016-05-25  5:30   ` Scott Wood
@ 2016-05-25  6:10     ` Heiko Schocher
  2016-05-25 14:51       ` Scott Wood
  0 siblings, 1 reply; 20+ messages in thread
From: Heiko Schocher @ 2016-05-25  6:10 UTC (permalink / raw)
  To: u-boot

Hello Scott,

Am 25.05.2016 um 07:30 schrieb Scott Wood:
> On 05/25/2016 12:07 AM, Heiko Schocher wrote:
>> add for nand devices mtd concat support. Generic MTD concat
>> support is already ported to mainline, and used in the cfi_mtd
>> driver. This patch adds it similiar for nand devices.
>>
>> Signed-off-by: Heiko Schocher <hs@denx.de>
>> ---
>>
>>   drivers/mtd/nand/nand.c | 29 +++++++++++++++++++++++++++++
>>   1 file changed, 29 insertions(+)
>>
>> diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c
>> index 8f0a921..5413123 100644
>> --- a/drivers/mtd/nand/nand.c
>> +++ b/drivers/mtd/nand/nand.c
>> @@ -9,6 +9,7 @@
>>   #include <common.h>
>>   #include <nand.h>
>>   #include <errno.h>
>> +#include <linux/mtd/concat.h>
>>
>>   #ifndef CONFIG_SYS_NAND_BASE_LIST
>>   #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE }
>> @@ -30,6 +31,12 @@ static char dev_name[CONFIG_SYS_MAX_NAND_DEVICE][8];
>>
>>   static unsigned long total_nand_size; /* in kiB */
>>
>> +#ifdef CONFIG_MTD_CONCAT
>> +static int nand_devices_found;
>> +static struct mtd_info *mtd_nand_list[CONFIG_SYS_MAX_NAND_DEVICE];
>> +static char c_mtd_name[16];
>> +#endif
>
> Why is c_mtd_name file-scope rather than local?

fixed.

>> +
>>   /* Register an initialized NAND mtd device with the U-Boot NAND command. */
>>   int nand_register(int devnum)
>>   {
>> @@ -49,6 +56,9 @@ int nand_register(int devnum)
>>   	 * via the mtdcore infrastructure (e.g. ubi).
>>   	 */
>>   	add_mtd_device(mtd);
>> +#ifdef CONFIG_MTD_CONCAT
>> +	mtd_nand_list[nand_devices_found++] = mtd;
>> +#endif
>
> Why do we need another list of NAND devices?  Use nand_info[].

Ah, correct ... struct nand_info_t == struct mtd_info ... Hmm...
why we need a "struct nand_info_t" ?

>>   #endif
>>
>>   	total_nand_size += mtd->size / 1024;
>> @@ -102,4 +112,23 @@ void nand_init(void)
>>   	 */
>>   	board_nand_select_device(nand_info[nand_curr_device].priv, nand_curr_device);
>>   #endif
>> +
>> +#ifdef CONFIG_MTD_CONCAT
>> +	if (nand_devices_found > 1) {
>> +		struct mtd_info *mtd;
>> +
>> +		/*
>> +		 * We detected multiple devices. Concatenate them together.
>> +		 */
>> +		sprintf(c_mtd_name, "nand%d", nand_devices_found);
>> +		mtd = mtd_concat_create(mtd_nand_list, nand_devices_found,
>> +					c_mtd_name);
>> +
>> +		if (mtd == NULL)
>> +			return;
>> +
>> +		if (add_mtd_device(mtd))
>> +			return;
>> +	}
>> +#endif /* CONFIG_MTD_CONCAT */
>>   }
>
> Please don't add new features that depend on the old-style NAND init.

Hmm... my add works for the "#ifdef CONFIG_SYS_NAND_SELF_INIT" case
and the "else" case ... where would be the appropriate place?

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

* [U-Boot] [PATCH v1 6/7] dfu, nand, ubi: fix erasing after write finish
  2016-05-25  5:33   ` Scott Wood
@ 2016-05-25  6:21     ` Heiko Schocher
  2016-05-30  9:51       ` Lukasz Majewski
  0 siblings, 1 reply; 20+ messages in thread
From: Heiko Schocher @ 2016-05-25  6:21 UTC (permalink / raw)
  To: u-boot

Hello Scott,

Am 25.05.2016 um 07:33 schrieb Scott Wood:
> On 05/25/2016 12:07 AM, Heiko Schocher wrote:
>> writting to ubi nand partitions need after write ends an erase
>> of the remaining sectors. This fail, if dfu write size was not
>> a multiple of erasesize, example log:
>>
>> Failure erase: -1
>>
>> Fix this error.
>>
>> Signed-off-by: Heiko Schocher <hs@denx.de>
>
> Why don't you just erase the whole partition up front?

Good question ... I think the reason is that if we erase a big partition
at once on dfu start, dfu-util rans into timeout ... but may I am wrong ...

IIRC at the end of a DFU transfer DFU protocol sends a "flush" to the
device ... where we currently erase the remaining sectors ... we need
this on an ubi partition, else there may remain old used UBI sectors ...
(BTW: we need an "ubi format" command ...)

@Lukasz? Am I correct? Or could we simple erase before writting?

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

* [U-Boot] [PATCH v1 2/7] ubi: add new ubi command "ubi dettach"
  2016-05-25  5:47   ` Scott Wood
@ 2016-05-25  6:28     ` Heiko Schocher
  2016-05-25 14:46       ` Scott Wood
  0 siblings, 1 reply; 20+ messages in thread
From: Heiko Schocher @ 2016-05-25  6:28 UTC (permalink / raw)
  To: u-boot

Hello Scott,

Am 25.05.2016 um 07:47 schrieb Scott Wood:
> On 05/25/2016 12:07 AM, Heiko Schocher wrote:
>> @@ -661,7 +675,9 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>>   U_BOOT_CMD(
>>   	ubi, 6, 1, do_ubi,
>>   	"ubi commands",
>> -	"part [part] [offset]\n"
>> +	"dettach"
>
> "detach", here and elsewhere.
>
>> +		" - detach ubi from a mtd partition\n"
>
> Like that. :-)

Thanks! Fixed.

> P.S. When CCing me, please use oss at buserror.net so that my responses
> don't have to go through moderation.

Huh... I used the address in u-boot:/doc/git-mailrc ...
changed.

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

* [U-Boot] [PATCH v1 2/7] ubi: add new ubi command "ubi dettach"
  2016-05-25  6:28     ` Heiko Schocher
@ 2016-05-25 14:46       ` Scott Wood
  0 siblings, 0 replies; 20+ messages in thread
From: Scott Wood @ 2016-05-25 14:46 UTC (permalink / raw)
  To: u-boot

On 05/25/2016 01:28 AM, Heiko Schocher wrote:
> Hello Scott,
> 
> Am 25.05.2016 um 07:47 schrieb Scott Wood:
>> On 05/25/2016 12:07 AM, Heiko Schocher wrote:
>>> @@ -661,7 +675,9 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>>>   U_BOOT_CMD(
>>>   	ubi, 6, 1, do_ubi,
>>>   	"ubi commands",
>>> -	"part [part] [offset]\n"
>>> +	"dettach"
>>
>> "detach", here and elsewhere.
>>
>>> +		" - detach ubi from a mtd partition\n"
>>
>> Like that. :-)
> 
> Thanks! Fixed.
> 
>> P.S. When CCing me, please use oss at buserror.net so that my responses
>> don't have to go through moderation.
> 
> Huh... I used the address in u-boot:/doc/git-mailrc ...
> changed.

I changed it in MAINTAINERS... didn't realize there was another place I
needed to change it.  I'll send a patch to update that.

-Scott

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

* [U-Boot] [PATCH v1 3/7] nand: add nand mtd concat support
  2016-05-25  6:10     ` Heiko Schocher
@ 2016-05-25 14:51       ` Scott Wood
  2016-05-26  4:45         ` Heiko Schocher
  0 siblings, 1 reply; 20+ messages in thread
From: Scott Wood @ 2016-05-25 14:51 UTC (permalink / raw)
  To: u-boot

On 05/25/2016 01:10 AM, Heiko Schocher wrote:
> Hello Scott,
> 
> Am 25.05.2016 um 07:30 schrieb Scott Wood:
>> On 05/25/2016 12:07 AM, Heiko Schocher wrote:
>>> add for nand devices mtd concat support. Generic MTD concat
>>> support is already ported to mainline, and used in the cfi_mtd
>>> driver. This patch adds it similiar for nand devices.
>>>
>>> Signed-off-by: Heiko Schocher <hs@denx.de>
>>> ---
>>>
>>>   drivers/mtd/nand/nand.c | 29 +++++++++++++++++++++++++++++
>>>   1 file changed, 29 insertions(+)
>>>
>>> diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c
>>> index 8f0a921..5413123 100644
>>> --- a/drivers/mtd/nand/nand.c
>>> +++ b/drivers/mtd/nand/nand.c
>>> @@ -9,6 +9,7 @@
>>>   #include <common.h>
>>>   #include <nand.h>
>>>   #include <errno.h>
>>> +#include <linux/mtd/concat.h>
>>>
>>>   #ifndef CONFIG_SYS_NAND_BASE_LIST
>>>   #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE }
>>> @@ -30,6 +31,12 @@ static char dev_name[CONFIG_SYS_MAX_NAND_DEVICE][8];
>>>
>>>   static unsigned long total_nand_size; /* in kiB */
>>>
>>> +#ifdef CONFIG_MTD_CONCAT
>>> +static int nand_devices_found;
>>> +static struct mtd_info *mtd_nand_list[CONFIG_SYS_MAX_NAND_DEVICE];
>>> +static char c_mtd_name[16];
>>> +#endif
>>
>> Why is c_mtd_name file-scope rather than local?
> 
> fixed.
> 
>>> +
>>>   /* Register an initialized NAND mtd device with the U-Boot NAND command. */
>>>   int nand_register(int devnum)
>>>   {
>>> @@ -49,6 +56,9 @@ int nand_register(int devnum)
>>>   	 * via the mtdcore infrastructure (e.g. ubi).
>>>   	 */
>>>   	add_mtd_device(mtd);
>>> +#ifdef CONFIG_MTD_CONCAT
>>> +	mtd_nand_list[nand_devices_found++] = mtd;
>>> +#endif
>>
>> Why do we need another list of NAND devices?  Use nand_info[].
> 
> Ah, correct ... struct nand_info_t == struct mtd_info ... Hmm...
> why we need a "struct nand_info_t" ?

It's a typedef, not a struct...  and we don't need it.  I already have a
patch in the set I'm working on for the Linux NAND sync that removes the
typedef, and another that converts nand_info[] into an array of pointers
(which should make calling mtd_concat_create easier).

> 
>>>   #endif
>>>
>>>   	total_nand_size += mtd->size / 1024;
>>> @@ -102,4 +112,23 @@ void nand_init(void)
>>>   	 */
>>>   	board_nand_select_device(nand_info[nand_curr_device].priv, nand_curr_device);
>>>   #endif
>>> +
>>> +#ifdef CONFIG_MTD_CONCAT
>>> +	if (nand_devices_found > 1) {
>>> +		struct mtd_info *mtd;
>>> +
>>> +		/*
>>> +		 * We detected multiple devices. Concatenate them together.
>>> +		 */
>>> +		sprintf(c_mtd_name, "nand%d", nand_devices_found);
>>> +		mtd = mtd_concat_create(mtd_nand_list, nand_devices_found,
>>> +					c_mtd_name);
>>> +
>>> +		if (mtd == NULL)
>>> +			return;
>>> +
>>> +		if (add_mtd_device(mtd))
>>> +			return;
>>> +	}
>>> +#endif /* CONFIG_MTD_CONCAT */
>>>   }
>>
>> Please don't add new features that depend on the old-style NAND init.
> 
> Hmm... my add works for the "#ifdef CONFIG_SYS_NAND_SELF_INIT" case
> and the "else" case ... where would be the appropriate place?

You're right...  For some reason I was thinking that none of this was
called with self-init.

-Scott

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

* [U-Boot] [PATCH v1 3/7] nand: add nand mtd concat support
  2016-05-25 14:51       ` Scott Wood
@ 2016-05-26  4:45         ` Heiko Schocher
  0 siblings, 0 replies; 20+ messages in thread
From: Heiko Schocher @ 2016-05-26  4:45 UTC (permalink / raw)
  To: u-boot

Hello Scott,

Am 25.05.2016 um 16:51 schrieb Scott Wood:
> On 05/25/2016 01:10 AM, Heiko Schocher wrote:
>> Hello Scott,
>>
>> Am 25.05.2016 um 07:30 schrieb Scott Wood:
>>> On 05/25/2016 12:07 AM, Heiko Schocher wrote:
>>>> add for nand devices mtd concat support. Generic MTD concat
>>>> support is already ported to mainline, and used in the cfi_mtd
>>>> driver. This patch adds it similiar for nand devices.
>>>>
>>>> Signed-off-by: Heiko Schocher <hs@denx.de>
>>>> ---
>>>>
>>>>    drivers/mtd/nand/nand.c | 29 +++++++++++++++++++++++++++++
>>>>    1 file changed, 29 insertions(+)
>>>>
>>>> diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c
>>>> index 8f0a921..5413123 100644
>>>> --- a/drivers/mtd/nand/nand.c
>>>> +++ b/drivers/mtd/nand/nand.c
[...]
>>>> +
>>>>    /* Register an initialized NAND mtd device with the U-Boot NAND command. */
>>>>    int nand_register(int devnum)
>>>>    {
>>>> @@ -49,6 +56,9 @@ int nand_register(int devnum)
>>>>    	 * via the mtdcore infrastructure (e.g. ubi).
>>>>    	 */
>>>>    	add_mtd_device(mtd);
>>>> +#ifdef CONFIG_MTD_CONCAT
>>>> +	mtd_nand_list[nand_devices_found++] = mtd;
>>>> +#endif
>>>
>>> Why do we need another list of NAND devices?  Use nand_info[].
>>
>> Ah, correct ... struct nand_info_t == struct mtd_info ... Hmm...
>> why we need a "struct nand_info_t" ?
>
> It's a typedef, not a struct...  and we don't need it.  I already have a

Oh, yes, sorry.

> patch in the set I'm working on for the Linux NAND sync that removes the
> typedef, and another that converts nand_info[] into an array of pointers
> (which should make calling mtd_concat_create easier).

Thanks!

>>>> @@ -102,4 +112,23 @@ void nand_init(void)
>>>>    	 */
>>>>    	board_nand_select_device(nand_info[nand_curr_device].priv, nand_curr_device);
>>>>    #endif
>>>> +
>>>> +#ifdef CONFIG_MTD_CONCAT
>>>> +	if (nand_devices_found > 1) {
>>>> +		struct mtd_info *mtd;
>>>> +
>>>> +		/*
>>>> +		 * We detected multiple devices. Concatenate them together.
>>>> +		 */
>>>> +		sprintf(c_mtd_name, "nand%d", nand_devices_found);
>>>> +		mtd = mtd_concat_create(mtd_nand_list, nand_devices_found,
>>>> +					c_mtd_name);
>>>> +
>>>> +		if (mtd == NULL)
>>>> +			return;
>>>> +
>>>> +		if (add_mtd_device(mtd))
>>>> +			return;
>>>> +	}
>>>> +#endif /* CONFIG_MTD_CONCAT */
>>>>    }
>>>
>>> Please don't add new features that depend on the old-style NAND init.
>>
>> Hmm... my add works for the "#ifdef CONFIG_SYS_NAND_SELF_INIT" case
>> and the "else" case ... where would be the appropriate place?
>
> You're right...  For some reason I was thinking that none of this was
> called with self-init.

Ok, so I let it here.

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

* [U-Boot] [PATCH v1 6/7] dfu, nand, ubi: fix erasing after write finish
  2016-05-25  6:21     ` Heiko Schocher
@ 2016-05-30  9:51       ` Lukasz Majewski
  2016-05-30 10:15         ` Heiko Schocher
  0 siblings, 1 reply; 20+ messages in thread
From: Lukasz Majewski @ 2016-05-30  9:51 UTC (permalink / raw)
  To: u-boot

Hi Heiko,

> Hello Scott,
> 
> Am 25.05.2016 um 07:33 schrieb Scott Wood:
> > On 05/25/2016 12:07 AM, Heiko Schocher wrote:
> >> writting to ubi nand partitions need after write ends an erase
> >> of the remaining sectors. This fail, if dfu write size was not
> >> a multiple of erasesize, example log:
> >>
> >> Failure erase: -1

Is this a new bug? Or is this a regression?

> >>
> >> Fix this error.
> >>
> >> Signed-off-by: Heiko Schocher <hs@denx.de>
> >
> > Why don't you just erase the whole partition up front?
> 
> Good question ... I think the reason is that if we erase a big
> partition at once on dfu start, dfu-util rans into timeout ... but
> may I am wrong ...

This is interesting, since we had similar problem with eMMC, but on the
end of writing large files to FS.

To fix this issue, the deferred write has been introduced [1]:
SHA1: fc18f8d170ecc7e15269ad5312ec643addb42491

> 
> IIRC at the end of a DFU transfer DFU protocol sends a "flush" to the
> device ... 

Yes, correct, we do that.

> where we currently erase the remaining sectors 

I'm not the "regular" user of NAND part of DFU framework. However,
AFAIK each sector is erased just before writing (dfu_nand.c @ line 62).

The same scheme should be performed just before writing last chunk of
data to NAND.

> ... we need
> this on an ubi partition, else there may remain old used UBI
> sectors ... (BTW: we need an "ubi format" command ...)
> 
> @Lukasz? Am I correct? Or could we simple erase before writting?

I'm just wondering if have you tried erasing the whole NAND area before
starting DFU operation?
How long does it take to erase large NAND area for e.g. rootfs?

If I remember correctly, the timeout in dfu-util is 5 seconds sharp. 


Generally, I'm fine with erasing NAND sectors just before writing (as
we do it up till now in the NAND part of DFU).

> 
> bye,
> Heiko


-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

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

* [U-Boot] [PATCH v1 6/7] dfu, nand, ubi: fix erasing after write finish
  2016-05-30  9:51       ` Lukasz Majewski
@ 2016-05-30 10:15         ` Heiko Schocher
  2016-05-30 13:13           ` Lukasz Majewski
  0 siblings, 1 reply; 20+ messages in thread
From: Heiko Schocher @ 2016-05-30 10:15 UTC (permalink / raw)
  To: u-boot

Hello Lukasz,

Am 30.05.2016 um 11:51 schrieb Lukasz Majewski:
> Hi Heiko,
>
>> Hello Scott,
>>
>> Am 25.05.2016 um 07:33 schrieb Scott Wood:
>>> On 05/25/2016 12:07 AM, Heiko Schocher wrote:
>>>> writting to ubi nand partitions need after write ends an erase
>>>> of the remaining sectors. This fail, if dfu write size was not
>>>> a multiple of erasesize, example log:
>>>>
>>>> Failure erase: -1
>
> Is this a new bug? Or is this a regression?

This is a fix of a current Bug.

>>>> Fix this error.
>>>>
>>>> Signed-off-by: Heiko Schocher <hs@denx.de>
>>>
>>> Why don't you just erase the whole partition up front?
>>
>> Good question ... I think the reason is that if we erase a big
>> partition at once on dfu start, dfu-util rans into timeout ... but
>> may I am wrong ...
>
> This is interesting, since we had similar problem with eMMC, but on the
> end of writing large files to FS.
>
> To fix this issue, the deferred write has been introduced [1]:
> SHA1: fc18f8d170ecc7e15269ad5312ec643addb42491

I had downloaded files > 300MiB IIRC without problems on NAND.

>> IIRC at the end of a DFU transfer DFU protocol sends a "flush" to the
>> device ...
>
> Yes, correct, we do that.
>
>> where we currently erase the remaining sectors
>
> I'm not the "regular" user of NAND part of DFU framework. However,
> AFAIK each sector is erased just before writing (dfu_nand.c @ line 62).

Yep, and this is currrent state and works fine (on the siemens boards)
And so we need at the end in the flush state of the dfu protcol
to erase the sectors on the end of the partition, if it is an ubi partition.

> The same scheme should be performed just before writing last chunk of
> data to NAND.
>
>> ... we need
>> this on an ubi partition, else there may remain old used UBI
>> sectors ... (BTW: we need an "ubi format" command ...)
>>
>> @Lukasz? Am I correct? Or could we simple erase before writting?
>
> I'm just wondering if have you tried erasing the whole NAND area before
> starting DFU operation?
> How long does it take to erase large NAND area for e.g. rootfs?

I must measure this value ... but just posted the etamin module support,
and there is a DDP Nand with 4GiB ... and there is a big fat (UBI) partition
at the end:

device nand2 <omap2-nand_concat>, # parts = 9
  #: name                size            offset          mask_flags
[...]
  8: rootfs              0xff080000      0x00f80000      0

> If I remember correctly, the timeout in dfu-util is 5 seconds sharp.

Yes, this is may too small, right, just erased the DDP nand on the
etamin module:

U-Boot# nand device 0
Device 0: nand0... is now current device
U-Boot# time nand erase f80000 7f080000

NAND erase: device 0 offset 0xf80000, size 0x7f080000
[...]
Erasing at 0x7ff80000 -- 100% complete.
OK

time: 3.999 seconds
U-Boot# nand device 1
Device 1: nand1... is now current device
U-Boot# time nand erase.chip

NAND erase.chip: device 1 whole chip
[...]
Erasing at 0x7ff80000 -- 100% complete.
OK

time: 4.019 seconds
U-Boot#

~8seconds for erasing the hole partition ...

> Generally, I'm fine with erasing NAND sectors just before writing (as
> we do it up till now in the NAND part of DFU).

Thanks for clarification!

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

* [U-Boot] [PATCH v1 6/7] dfu, nand, ubi: fix erasing after write finish
  2016-05-30 10:15         ` Heiko Schocher
@ 2016-05-30 13:13           ` Lukasz Majewski
  0 siblings, 0 replies; 20+ messages in thread
From: Lukasz Majewski @ 2016-05-30 13:13 UTC (permalink / raw)
  To: u-boot

Hi Heiko,

> Hello Lukasz,
> 
> Am 30.05.2016 um 11:51 schrieb Lukasz Majewski:
> > Hi Heiko,
> >
> >> Hello Scott,
> >>
> >> Am 25.05.2016 um 07:33 schrieb Scott Wood:
> >>> On 05/25/2016 12:07 AM, Heiko Schocher wrote:
> >>>> writting to ubi nand partitions need after write ends an erase
> >>>> of the remaining sectors. This fail, if dfu write size was not
> >>>> a multiple of erasesize, example log:
> >>>>
> >>>> Failure erase: -1
> >
> > Is this a new bug? Or is this a regression?
> 
> This is a fix of a current Bug.

Ok.

> 
> >>>> Fix this error.
> >>>>
> >>>> Signed-off-by: Heiko Schocher <hs@denx.de>
> >>>
> >>> Why don't you just erase the whole partition up front?
> >>
> >> Good question ... I think the reason is that if we erase a big
> >> partition at once on dfu start, dfu-util rans into timeout ... but
> >> may I am wrong ...
> >
> > This is interesting, since we had similar problem with eMMC, but on
> > the end of writing large files to FS.
> >
> > To fix this issue, the deferred write has been introduced [1]:
> > SHA1: fc18f8d170ecc7e15269ad5312ec643addb42491
> 
> I had downloaded files > 300MiB IIRC without problems on NAND.
> 
> >> IIRC at the end of a DFU transfer DFU protocol sends a "flush" to
> >> the device ...
> >
> > Yes, correct, we do that.
> >
> >> where we currently erase the remaining sectors
> >
> > I'm not the "regular" user of NAND part of DFU framework. However,
> > AFAIK each sector is erased just before writing (dfu_nand.c @ line
> > 62).
> 
> Yep, and this is currrent state and works fine (on the siemens boards)
> And so we need at the end in the flush state of the dfu protcol
> to erase the sectors on the end of the partition, if it is an ubi
> partition.

Then we should stick with this scheme.

> 
> > The same scheme should be performed just before writing last chunk
> > of data to NAND.
> >
> >> ... we need
> >> this on an ubi partition, else there may remain old used UBI
> >> sectors ... (BTW: we need an "ubi format" command ...)
> >>
> >> @Lukasz? Am I correct? Or could we simple erase before writting?
> >
> > I'm just wondering if have you tried erasing the whole NAND area
> > before starting DFU operation?
> > How long does it take to erase large NAND area for e.g. rootfs?
> 
> I must measure this value ... but just posted the etamin module
> support, and there is a DDP Nand with 4GiB ... and there is a big fat
> (UBI) partition at the end:
> 
> device nand2 <omap2-nand_concat>, # parts = 9
>   #: name                size            offset          mask_flags
> [...]
>   8: rootfs              0xff080000      0x00f80000      0
> 
> > If I remember correctly, the timeout in dfu-util is 5 seconds sharp.
> 
> Yes, this is may too small, right, just erased the DDP nand on the
> etamin module:
> 
> U-Boot# nand device 0
> Device 0: nand0... is now current device
> U-Boot# time nand erase f80000 7f080000
> 
> NAND erase: device 0 offset 0xf80000, size 0x7f080000
> [...]
> Erasing at 0x7ff80000 -- 100% complete.
> OK
> 
> time: 3.999 seconds
> U-Boot# nand device 1
> Device 1: nand1... is now current device
> U-Boot# time nand erase.chip
> 
> NAND erase.chip: device 1 whole chip
> [...]
> Erasing at 0x7ff80000 -- 100% complete.
> OK
> 
> time: 4.019 seconds
> U-Boot#
> 
> ~8seconds for erasing the hole partition ...

So, then we would need to add some extra code to support erasing the
whole partition before flashing. 

However, I think that we should use the current scheme and erase the
last sector just before writing.

> 
> > Generally, I'm fine with erasing NAND sectors just before writing
> > (as we do it up till now in the NAND part of DFU).
> 
> Thanks for clarification!

No problem.

> 
> bye,
> Heiko



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

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

end of thread, other threads:[~2016-05-30 13:13 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-25  5:07 [U-Boot] [PATCH v1 0/7] add support for the etamin draco board variant Heiko Schocher
2016-05-25  5:07 ` [U-Boot] [PATCH v1 1/7] siemens,am33x: add ubi fastmap support Heiko Schocher
2016-05-25  5:07 ` [U-Boot] [PATCH v1 2/7] ubi: add new ubi command "ubi dettach" Heiko Schocher
2016-05-25  5:47   ` Scott Wood
2016-05-25  6:28     ` Heiko Schocher
2016-05-25 14:46       ` Scott Wood
2016-05-25  5:07 ` [U-Boot] [PATCH v1 3/7] nand: add nand mtd concat support Heiko Schocher
2016-05-25  5:30   ` Scott Wood
2016-05-25  6:10     ` Heiko Schocher
2016-05-25 14:51       ` Scott Wood
2016-05-26  4:45         ` Heiko Schocher
2016-05-25  5:07 ` [U-Boot] [PATCH v1 4/7] mtd: nand: omap: allow to switch to BCH16 Heiko Schocher
2016-05-25  5:07 ` [U-Boot] [PATCH v1 5/7] am335x, dxr2: get ECC sType from I2C eeprom Heiko Schocher
2016-05-25  5:07 ` [U-Boot] [PATCH v1 6/7] dfu, nand, ubi: fix erasing after write finish Heiko Schocher
2016-05-25  5:33   ` Scott Wood
2016-05-25  6:21     ` Heiko Schocher
2016-05-30  9:51       ` Lukasz Majewski
2016-05-30 10:15         ` Heiko Schocher
2016-05-30 13:13           ` Lukasz Majewski
2016-05-25  5:07 ` [U-Boot] [PATCH v1 7/7] siemens,am33x: add draco etamin board Heiko Schocher

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.