Skip to contentSkip to conversation

add explicit bbt creation to commandline

PATCH New Harald Welte 5 participants 17 messages Jul 6, 2008 – Feb 17, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add explicit bbt creation to commandline

[PATCH] add explicit bbt creation to commandline ("nand createbbt" command)

This patch adds user-requested BBT creation. It includes the following changes:

- common/cmd_nand.c: move yes/no decision to separate function
- do_nand: ask for confirmation for "nand erase"
- do_nand: add command "nand createbbt" to erase NAND and create a new BBT

---

common/cmd_nand.c +53 -3
index bb46f34..2f41157 100644
@@ -162,6 +162,17 @@ out:
 	return 0;
 }
 
+static int yes(void)
+{
+	char c;
+
+	c = getc();
+	if (c != 'y' && c != 'Y')
+		return 0;
+	c = getc();
+	return c == '\r' || c == '\n';
+}
+
 int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 {
 	int i, dev, ret;
@@ -231,7 +242,8 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 	    strncmp(cmd, "read", 4) != 0 && strncmp(cmd, "write", 5) != 0 &&
 	    strcmp(cmd, "scrub") != 0 && strcmp(cmd, "markbad") != 0 &&
 	    strcmp(cmd, "biterr") != 0 &&
-	    strcmp(cmd, "lock") != 0 && strcmp(cmd, "unlock") != 0 )
+	    strcmp(cmd, "lock") != 0 && strcmp(cmd, "unlock") != 0 &&
+	    strcmp(cmd, "createbbt") != 0 )
 		goto usage;
 
 	/* the following commands operate on the current device */
@@ -286,13 +298,23 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 			     "are sure of what you are doing!\n"
 			     "\nReally scrub this NAND flash? <y/N>\n");
 
-			if (getc() == 'y' && getc() == '\r') {
+			if (yes()) {
 				opts.scrub = 1;
 			} else {
 				puts("scrub aborted\n");
 				return -1;
 			}
 		}
+		else {
+			if (opts.length == nand->size) {
+				puts("Really erase everything ? <y/N>\n");
+				if (!yes()) {
+					puts("erase aborted\n");
+					return -1;
+				}
+			}
+		}
+
 		ret = nand_erase_opts(nand, &opts);
 		printf("%s\n", ret ? "ERROR" : "OK");
 
@@ -461,6 +483,33 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 		return 0;
 	}
 
+	if (strcmp(cmd, "createbbt") == 0) {
+		struct nand_chip *nand_chip = nand->priv;
+		nand_erase_options_t opts;
+
+		puts("Create BBT and erase everything ? <y/N>\n");
+		if (!yes()) {
+			puts("createbbt aborted\n");
+			return -1;
+		}
+		memset(&opts, 0, sizeof(opts));
+		opts.length = nand->size;
+		if (nand_erase_opts(nand, &opts)) {
+			puts("Erase failed\n");
+			return 1;
+		}
+		nand_chip->options &= ~NAND_DONT_CREATE_BBT;
+		puts("Creating BBT. Please wait ...");
+		if (nand_default_bbt(nand)) {
+			puts("\nFailed\n");
+			return 1;
+		}
+		else {
+			puts("\n");
+			return 0;
+		}
+	}
+
 usage:
 	printf("Usage:\n%s\n", cmdtp->usage);
 	return 1;
@@ -481,7 +530,8 @@ U_BOOT_CMD(nand, 5, 1, do_nand,
 	"nand markbad off - mark bad block at offset (UNSAFE)\n"
 	"nand biterr off - make a bit error at offset (UNSAFE)\n"
 	"nand lock [tight] [status] - bring nand to lock state or display locked pages\n"
-	"nand unlock [offset] [size] - unlock section\n");
+	"nand unlock [offset] [size] - unlock section\n"
+	"nand createbbt - create bad block table\n");
 
 static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
 			   ulong offset, ulong addr, char *cmd)
drivers/mtd/nand/nand_bbt.c +2 -1
index 27d5988..3fdc25a 100644
@@ -795,7 +795,8 @@ int nand_scan_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd)
 
 	len = mtd->size >> (this->bbt_erase_shift + 2);
 	/* Allocate memory (2bit per block) */
-	this->bbt = kmalloc (len, GFP_KERNEL);
+	if (!this->bbt)
+		this->bbt = kmalloc (len, GFP_KERNEL);
 	if (!this->bbt) {
 		printk (KERN_ERR "nand_scan_bbt: Out of memory\n");
 		return -ENOMEM;
Signature · 11 lines
- Harald Welte <[email protected]>           http://laforge.gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
                                                  (ETSI EN 300 175-7 Ch. A6)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.denx.de/pipermail/u-boot/attachments/20080706/746c7054/attachment.pgp 
#1 lore raw

PATCH 1/1 add explicit bbt creation to commandline

Quoted 22 lines · Harald Welte

[PATCH] add explicit bbt creation to commandline ("nand createbbt" command)

This patch adds user-requested BBT creation. It includes the following changes:

- common/cmd_nand.c: move yes/no decision to separate function
- do_nand: ask for confirmation for "nand erase"
- do_nand: add command "nand createbbt" to erase NAND and create a new BBT

---

common/cmd_nand.c +1 -0
index bb46f34..2f41157 100644
@@ -162,6 +162,17 @@ out:
 	return 0;
 }
 
+static int yes(void)

common/cmd_nand.c out: · line 175

Quoted 10 lines
common/cmd_nand.c +10 -0
+{
+	char c;
+
+	c = getc();
+	if (c != 'y' && c != 'Y')
+		return 0;
+	c = getc();
+	return c == '\r' || c == '\n';
+}
+

It will be good to have it in a re-usable header as inline.

And why not name it as "ask_confirm()"?

Best Regards,
J.

#2 lore raw

PATCH 1/1 add explicit bbt creation to commandline

Quoted 14 lines · In message <[email protected]> you wrote:

common/cmd_nand.c out: · line 175

Quoted 12 lines
common/cmd_nand.c +11 -0
+static int yes(void)
+{
+	char c;
+
+	c = getc();
+	if (c != 'y' && c != 'Y')
+		return 0;
+	c = getc();
+	return c == '\r' || c == '\n';
+}
+

It will be good to have it in a re-usable header as inline.

Quoted 1 line

And why not name it as "ask_confirm()"?

Or extend it a bit and call it ckyorn() - oh, good old SVR4 times :-)

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Hegel was right when he said that we learn from history that man  can
never learn anything from history.              - George Bernard Shaw
#3 lore raw

PATCH 1/1 add explicit bbt creation to commandline

In reply to Harald Welte
Quoted 1 line · Harald Welte

- do_nand: ask for confirmation for "nand erase"

This will break any usage in scripts. At least, have an explicit command such as "nand erase all" that doesn't ask.

Quoted 1 line

- do_nand: add command "nand createbbt" to erase NAND and create a new BBT

Please do any new NAND development against the u-boot-nand-flash testing tree (and CC me and include "NAND" in the subject on any NAND patches).

-Scott

#4 lore raw

PATCH 1/1 add explicit bbt creation to commandline

In reply to Harald Welte

Hi,
I know this message is about 18 months old. I am using Uboot 2008.10, which seems to not include support for creating the Nand BBT (bad block table). Was this patch released and if so when? Forgive me as I don't know how to find out.

How best to add BBT support to Uboot? I need to have a BBT created such that Linux can use it when it loads.

I hope you can help.

Thanks in advance,
Steve
P.S.: I snipped out portions of this code to save space in this reply.

Quoted 104 lines · Harald Welte

[PATCH] add explicit bbt creation to commandline ("nand createbbt" command)

This patch adds user-requested BBT creation. It includes the following changes:

- common/cmd_nand.c: move yes/no decision to separate function
- do_nand: ask for confirmation for "nand erase"
- do_nand: add command "nand createbbt" to erase NAND and create a new BBT

---

common/cmd_nand.c +13 -1
index bb46f34..2f41157 100644
@@ -162,6 +162,17 @@ out:
 	return 0;
 }
 
+static int yes(void)
+{
+	char c;
+
+	c = getc();
+	if (c != 'y' && c != 'Y')
+		return 0;
+	c = getc();
+	return c == '\r' || c == '\n';
+}
+
 int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 {
 	int i, dev, ret;
@@ -231,7 +242,8 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc,
 char *argv[])
 	    strncmp(cmd, "read", 4) != 0 && strncmp(cmd, "write", 5) != 0 &&
 	    strcmp(cmd, "scrub") != 0 && strcmp(cmd, "markbad") != 0 &&
 	    strcmp(cmd, "biterr") != 0 &&
-	    strcmp(cmd, "lock") != 0 && strcmp(cmd, "unlock") != 0 )
+	    strcmp(cmd, "lock") != 0 && strcmp(cmd, "unlock") != 0 &&
+	    strcmp(cmd, "createbbt") != 0 )
 		goto usage;
 
common/cmd_nand.c +26 -1
 	/* the following commands operate on the current device */
@@ -286,13 +298,23 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc,
 char *argv[])
 			     "are sure of what you are doing!\n"
 			     "\nReally scrub this NAND flash? <y/N>\n");
 
-			if (getc() == 'y' && getc() == '\r') {
+			if (yes()) {
 				opts.scrub = 1;
 			} else {
 				puts("scrub aborted\n");
 				return -1;
 			}
 		}
+		else {
+			if (opts.length == nand->size) {
+				puts("Really erase everything ? <y/N>\n");
+				if (!yes()) {
+					puts("erase aborted\n");
+					return -1;
+				}
+			}
+		}
+
 		ret = nand_erase_opts(nand, &opts);
 		printf("%s\n", ret ? "ERROR" : "OK");
@@ -461,6 +483,33 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc,
 char *argv[])
 		return 0;
 	}
 
+	if (strcmp(cmd, "createbbt") == 0) {
+		struct nand_chip *nand_chip = nand->priv;
+		nand_erase_options_t opts;
+
+		puts("Create BBT and erase everything ? <y/N>\n");
+		if (!yes()) {
+			puts("createbbt aborted\n");
+			return -1;
+		}
+		memset(&opts, 0, sizeof(opts));
+		opts.length = nand->size;
+		if (nand_erase_opts(nand, &opts)) {
+			puts("Erase failed\n");
+			return 1;
+.

.
.
snip....
.
.
.

Signature · 2 lines
View this message in context: http://old.nabble.com/-PATCH--add-explicit-bbt-creation-to-commandline-tp18299804p27558231.html
Sent from the Uboot - Users mailing list archive at Nabble.com.
#5 lore raw

PATCH 1/1 add explicit bbt creation to commandline

Quoted 9 lines · Steven Zedeck

Hi,
I know this message is about 18 months old. I am using Uboot 2008.10, which seems to not include support for creating the Nand BBT (bad block table). Was this patch released and if so when? Forgive me as I don't know how to find out.

How best to add BBT support to Uboot? I need to have a BBT created such that Linux can use it when it loads.

U-Boot supports creating a bad block table in flash, and has done so since before 2008.10 (assuming you're not using legacy NAND). Whether it does this depends on whether the NAND driver requests it with NAND_BBT_CREATE in nand_bbt_descr.options and NAND_USE_FLASH_BBT in nand_chip.options.

Linux can also create this table. Either way, it only needs to be done once, not on every boot.

What the patch you quote does, as far as I can tell without what's been snipped, is allow a new bad block table to be created when erasing the entire chip. Normally the bad block table would be excluded from a full-chip erase.

-Scott

#6 lore raw

PATCH 1/1 add explicit bbt creation to commandline

Quoted 14 lines

Hi,
I know this message is about 18 months old. I am using Uboot 2008.10, which
seems to not include support for creating the Nand BBT (bad block table). Was this patch released and if so when? Forgive me as I don't know how to find out.

How best to add BBT support to Uboot? I need to have a BBT created such that
Linux can use it when it loads.

Quoted 5 lines

U-Boot supports creating a bad block table in flash, and has done so since before 2008.10 (assuming you're not using legacy NAND). Whether it does this depends on whether the NAND driver requests it with NAND_BBT_CREATE in
nand_bbt_descr.options and NAND_USE_FLASH_BBT in nand_chip.options.

I REALLY appreciate your help. I see in drivers/mtd/nand/nand_bbt.c where it checks for NAND_BBT_CREATE. What I don't see is where/how this gets set. Is there a config file that sets this?

thanks,
Steve

Quoted 7 lines

Linux can also create this table. Either way, it only needs to be done once, not on every boot.

What the patch you quote does, as far as I can tell without what's been snipped, is allow a new bad block table to be created when erasing the entire chip. Normally the bad block table would be excluded from a full-chip erase.

Signature · 2 lines
View this message in context: http://old.nabble.com/-PATCH--add-explicit-bbt-creation-to-commandline-tp18299804p27566937.html
Sent from the Uboot - Users mailing list archive at Nabble.com.
#7 lore raw

PATCH 1/1 add explicit bbt creation to commandline

Quoted 9 lines · Steven Zedeck
Quoted 5 lines

U-Boot supports creating a bad block table in flash, and has done so since before 2008.10 (assuming you're not using legacy NAND). Whether it does this depends on whether the NAND driver requests it with NAND_BBT_CREATE in
nand_bbt_descr.options and NAND_USE_FLASH_BBT in nand_chip.options.

I REALLY appreciate your help. I see in drivers/mtd/nand/nand_bbt.c where it checks for NAND_BBT_CREATE. What I don't see is where/how this gets set. Is there a config file that sets this?

It is set in the BBT descriptor struct. Which NAND driver are you using? In order for it not to be set, the driver would have to use a non-default BBT descriptor (for bbt_td/bbt_md, not badblock_pattern) and leave out that flag. I don't see any upstream drivers (at least not under drivers/mtd/nand) that do that, so it should just be a matter of whether the driver specifies NAND_USE_FLASH_BBT in chip->options.

-Scott

#8 lore raw

PATCH 1/1 add explicit bbt creation to commandline

Quoted 13 lines
Quoted 7 lines

U-Boot supports creating a bad block table in flash, and has done so since before 2008.10 (assuming you're not using legacy NAND). Whether it does this depends on whether the NAND driver requests it with NAND_BBT_CREATE in
nand_bbt_descr.options and NAND_USE_FLASH_BBT in nand_chip.options.

Quoted 5 lines

I REALLY appreciate your help. I see in drivers/mtd/nand/nand_bbt.c where it
checks for NAND_BBT_CREATE. What I don't see is where/how this gets set.
Is
there a config file that sets this?

Quoted 6 lines

It is set in the BBT descriptor struct. Which NAND driver are you using? In order for it not to be set, the driver would have to use a non-default BBT descriptor (for bbt_td/bbt_md, not badblock_pattern) and leave out that flag. I don't see any upstream drivers (at least not under drivers/mtd/nand) that do that, so it should just be a matter of whether the driver specifies NAND_USE_FLASH_BBT in chip->options.

First of all, I inherited much of this code, especially the NAND-related stuff. I've never needed to go into this portion of the code.

It seems we are using the mtd driver as all our files dealing with nand are in drivers/mtd/nand. The only place I see NAND_USE_FLASH_BBT being used is in nand_bbt.c in nand_default_bbt. I see this:

this->options |= NAND_USE_FLASH_BBT;
return nand_scan_bbt (mtd, &agand_flashbased);

Is this what you are referring to?

Also, once we get the BBT created, does the code that loads Linux use that info ?

Thanks a million.
Steve

Signature · 2 lines
View this message in context: http://old.nabble.com/-PATCH--add-explicit-bbt-creation-to-commandline-tp18299804p27567768.html
Sent from the Uboot - Users mailing list archive at Nabble.com.
#9 lore raw

PATCH 1/1 add explicit bbt creation to commandline

Quoted 11 lines · Steven Zedeck

First of all, I inherited much of this code, especially the NAND-related stuff. I've never needed to go into this portion of the code.

It seems we are using the mtd driver as all our files dealing with nand are in drivers/mtd/nand. The only place I see NAND_USE_FLASH_BBT being used is in nand_bbt.c in nand_default_bbt. I see this:

this->options |= NAND_USE_FLASH_BBT;
return nand_scan_bbt (mtd, &agand_flashbased);

Is this what you are referring to?

No, I mean in the NAND driver for your specific hardware (fsl_elbc_nand.c, mxc_nand.c, ndfc_nand.c, etc).

Quoted 2 lines

Also, once we get the BBT created, does the code that loads Linux use that info ?

The BBT is created on the flash. Linux runs pretty much the same code as u-boot and will use the on-flash BBT if its NAND driver specifies NAND_USE_FLASH_BBT. This isn't about in-memory BBTs.

-Scott

#10 lore raw

PATCH 1/1 add explicit bbt creation to commandline

Quoted 4 lines

No, I mean in the NAND driver for your specific hardware (fsl_elbc_nand.c, mxc_nand.c, ndfc_nand.c, etc).

You have been so helpful. I looked at the mtd/nand/Makefile and the only file that's included besides the nand* files is:

COBJS-y += fsl_upm.o

However, in that code:
#if defined(CONFIG_CMD_NAND) && defined(CONFIG_NAND_FSL_UPM)

But I don't see CONFIG_NAND_FSL_UPM defined anywhere. It seems that this file really isn't being used.

How do I determine what hadrware driver its using? I'm sure this sounds like a dumb question. Do all the drivers live in drivers/mtd/nand/.... ?

thanks,
Steve

Signature · 2 lines
View this message in context: http://old.nabble.com/-PATCH--add-explicit-bbt-creation-to-commandline-tp18299804p27568153.html
Sent from the Uboot - Users mailing list archive at Nabble.com.
#11 lore raw

PATCH 1/1 add explicit bbt creation to commandline

Quoted 13 lines · Steven Zedeck
Quoted 4 lines

No, I mean in the NAND driver for your specific hardware (fsl_elbc_nand.c, mxc_nand.c, ndfc_nand.c, etc).

You have been so helpful. I looked at the mtd/nand/Makefile and the only file that's included besides the nand* files is:

COBJS-y += fsl_upm.o

However, in that code:
#if defined(CONFIG_CMD_NAND) && defined(CONFIG_NAND_FSL_UPM)

Quoted 10 lines

But I don't see CONFIG_NAND_FSL_UPM defined anywhere. It seems that this file really isn't being used.

How do I determine what hadrware driver its using? I'm sure this sounds like a dumb question. Do all the drivers live in drivers/mtd/nand/.... ?

thanks,
Steve

I think we are just using the base/generic mtd nand driver. Is that possible?

thanks,
Steve

Signature · 2 lines
View this message in context: http://old.nabble.com/-PATCH--add-explicit-bbt-creation-to-commandline-tp18299804p27568365.html
Sent from the Uboot - Users mailing list archive at Nabble.com.
#12 lore raw

PATCH 1/1 add explicit bbt creation to commandline

Quoted 10 lines · Steven Zedeck
Quoted 7 lines · Steven Zedeck
Quoted 3 lines

No, I mean in the NAND driver for your specific hardware (fsl_elbc_nand.c, mxc_nand.c, ndfc_nand.c, etc).

You have been so helpful. I looked at the mtd/nand/Makefile and the only file that's included besides the nand* files is:

COBJS-y += fsl_upm.o

You've got an old/out-of-tree u-boot.

Quoted 2 lines

I think we are just using the base/generic mtd nand driver. Is that possible?

No, there must be a controller driver. It may be in a board or cpu directory, though. Search for board_nand_init().

-Scott

#13 lore raw

PATCH 1/1 add explicit bbt creation to commandline

Quoted 13 lines · Scott Wood-2 wrote:
Quoted 10 lines · Steven Zedeck
Quoted 7 lines · Steven Zedeck
Quoted 3 lines

No, I mean in the NAND driver for your specific hardware (fsl_elbc_nand.c, mxc_nand.c, ndfc_nand.c, etc).

You have been so helpful. I looked at the mtd/nand/Makefile and the only file that's included besides the nand* files is:

COBJS-y += fsl_upm.o

Quoted 9 lines

You've got an old/out-of-tree u-boot.

Quoted 2 lines

I think we are just using the base/generic mtd nand driver. Is that possible?

No, there must be a controller driver. It may be in a board or cpu directory, though. Search for board_nand_init().

Its in board/atmel/at91sam9rlek/nand.c

It doesn't do much but set up the various GPIO connections. Here's the function:

int board_nand_init(struct nand_chip *nand)

{
	nand->ecc.mode = NAND_ECC_SOFT;
#ifdef CFG_NAND_DBW_16
	nand->options = NAND_BUSWIDTH_16;
#endif
	nand->cmd_ctrl = at91sam9rlek_nand_hwcontrol;
	nand->dev_ready = at91sam9rlek_nand_ready;
	nand->chip_delay = 20;

	return 0;
}

thanks,
Steve

Signature · 2 lines
View this message in context: http://old.nabble.com/-PATCH--add-explicit-bbt-creation-to-commandline-tp18299804p27571823.html
Sent from the Uboot - Users mailing list archive at Nabble.com.
#14 lore raw

PATCH 1/1 add explicit bbt creation to commandline

Quoted 6 lines · Steven Zedeck

Its in board/atmel/at91sam9rlek/nand.c

It doesn't do much but set up the various GPIO connections. Here's the function:

int board_nand_init(struct nand_chip *nand)

Quoted 11 lines
{
	nand->ecc.mode = NAND_ECC_SOFT;
#ifdef CFG_NAND_DBW_16
	nand->options = NAND_BUSWIDTH_16;
#endif
	nand->cmd_ctrl = at91sam9rlek_nand_hwcontrol;
	nand->dev_ready = at91sam9rlek_nand_ready;
	nand->chip_delay = 20;

	return 0;
}

Add "nand->options |= NAND_USE_FLASH_BBT;".

-Scott

#15 lore raw

PATCH 1/1 add explicit bbt creation to commandline

Quoted 17 lines · Scott Wood-2 wrote:
Quoted 15 lines · Steven Zedeck

Its in board/atmel/at91sam9rlek/nand.c

It doesn't do much but set up the various GPIO connections. Here's the function:

int board_nand_init(struct nand_chip *nand)

{
	nand->ecc.mode = NAND_ECC_SOFT;
#ifdef CFG_NAND_DBW_16
	nand->options = NAND_BUSWIDTH_16;
#endif
	nand->cmd_ctrl = at91sam9rlek_nand_hwcontrol;
	nand->dev_ready = at91sam9rlek_nand_ready;
	nand->chip_delay = 20;
Quoted 8 lines
Quoted 2 lines
	return 0;
}

Add "nand->options |= NAND_USE_FLASH_BBT;".

-Scott

Scott,
I really appreciate your help. I added what you suggested, except since we are using an 8 bit wide bus and not 16 I had to do the following:

#ifdef CFG_NAND_DBW_8
    nand->options |= NAND_USE_FLASH_BBT;

#endif

CFG_NAND_DBW_8 is set in my configs.h file.

Now when my board boots I get this and then it just stops:
NAND: Entering nand_init
Nand Base 0x40000000
Bad block table not found for chip 0
Bad block table not found for chip 0

That comes from nand_bbt.c
Clearly there is something I'm missing regarding how the BBT is created and utilized in Uboot.

thanks,
Steve

Signature · 2 lines
View this message in context: http://old.nabble.com/-PATCH--add-explicit-bbt-creation-to-commandline-tp18299804p27625639.html
Sent from the Uboot - Users mailing list archive at Nabble.com.
#16 lore raw

PATCH 1/1 add explicit bbt creation to commandline

Quoted 15 lines · Steven Zedeck
Quoted 14 lines · Scott Wood-2 wrote:
Quoted 12 lines · Steven Zedeck

int board_nand_init(struct nand_chip *nand)

{
	nand->ecc.mode = NAND_ECC_SOFT;
#ifdef CFG_NAND_DBW_16
	nand->options = NAND_BUSWIDTH_16;
#endif
	nand->cmd_ctrl = at91sam9rlek_nand_hwcontrol;
	nand->dev_ready = at91sam9rlek_nand_ready;
	nand->chip_delay = 20;

	return 0;
}

Add "nand->options |= NAND_USE_FLASH_BBT;".

[snip]

Quoted 6 lines

I really appreciate your help. I added what you suggested, except since we are using an 8 bit wide bus and not 16 I had to do the following:

#ifdef CFG_NAND_DBW_8
    nand->options |= NAND_USE_FLASH_BBT;

#endif

I don't see why the ifdef is needed -- just don't put it inside (or before) the other ifdef.

Quoted 5 lines

Now when my board boots I get this and then it just stops:
NAND: Entering nand_init
Nand Base 0x40000000
Bad block table not found for chip 0
Bad block table not found for chip 0

The messages are expected on the first boot -- but it should then create the bad block table.

You'll have to debug to find out why it's hanging. If you don't set NAND_USE_FLASH_BBT, does ordinary nand read/write from the u-boot prompt work?

-Scott