Skip to contentSkip to conversation

IMPORTANT NOTE to all maintainers with NAND flash

U-Boot-Users Wolfgang Denk 4 participants 7 messages Feb 28, 2006 – Mar 24, 2006

lore
Share & tools
lore
#0 lore raw

Hello,

this is a "heads up" note to all maintainers of boards with NAND flash:

I am going to drop support for the old NAND flash code and replace it by Ladislav Michl's rewrite, which is available in the "testing-NAND" branch of our git repository.

This new code has been available for testing for 6 months, and I have not received any negative feedback (I did not receive any positive feedback, either - but if you did not care until now you should not complain later).

Dropping the support for the old code means that the build for all boards that use NAND currently will *break*. I am aware that this is not a nice thing to do, but I see no other way to get the attention of the board maintainers and force them to update their code to the new way for their boards. This should be not be very hard, though. Since the new implementation is borrowed from Linux, it is quite likely that the said boards could use the new NAND support already present for them in the Linux source.

We will now merge the "testing-NAND" branch back into the main tree; once this is done, I will allow for a transition period of 4 weeks. After this, the old code will be removed, even if it breaks support for some boards.

Best regards,

Wolfgang Denk

Signature · 3 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
 The software required `Windows 95 or better', so I installed Linux.
#1 lore raw
Quoted 26 lines · Wolfgang Denk

Hello,

this is a "heads up" note to all maintainers of boards with NAND flash:

I am going to drop support for the old NAND flash code and replace it by Ladislav Michl's rewrite, which is available in the "testing-NAND" branch of our git repository.

This new code has been available for testing for 6 months, and I have not received any negative feedback (I did not receive any positive feedback, either - but if you did not care until now you should not complain later).

Dropping the support for the old code means that the build for all boards that use NAND currently will *break*. I am aware that this is not a nice thing to do, but I see no other way to get the attention of the board maintainers and force them to update their code to the new way for their boards. This should be not be very hard, though. Since the new implementation is borrowed from Linux, it is quite likely that the said boards could use the new NAND support already present for them in the Linux source.

Quoted 6 lines

We will now merge the "testing-NAND" branch back into the main tree; once this is done, I will allow for a transition period of 4 weeks. After this, the old code will be removed, even if it breaks support for some boards.

I did test it, it works.

A few things are missing but most are doable.

Quoted 4 lines

Best regards,

Wolfgang Denk

Regards

Pantelis

#2 lore raw

On Tue, Feb 28, 2006 at 12:05:32PM +0200, Pantelis Antoniou wrote:

Hi Wolfgang & Pantelis,

Quoted 1 line

A few things are missing but most are doable.

Here is one of those 'few' things - erasing OOB area...

Signed-off-by Ladislav Michl <[email protected]>

CHANGELOG
* Implement NAND OOB erase command
Patch by Ladislav Michl, 17 Mar 2006

common/cmd_nand.c +5 -4
index 21adb1b..bf4173f 100644
@@ -198,13 +198,15 @@ int do_nand(cmd_tbl_t * cmdtp, int flag,
 	}
 
 	if (strcmp(cmd, "erase") == 0) {
-		arg_off_size(argc - 2, argv + 2, &off, &size, nand->size);
+		int clean = (argc > 2 && strcmp(argv[2], "clean") == 0) ? 1 : 0;
+		int o = clean ? 3 : 2;
+		arg_off_size(argc - o, argv + o, &off, &size, nand->size);
 		if (off == 0 && size == 0)
-			return 1;
+			size = nand->size;
 
 		printf("\nNAND erase: device %d offset 0x%x, size 0x%x ",
 		       nand_curr_device, off, size);
-		ret = nand_erase(nand, off, size);
+		ret = nand_erase(nand, off, size, clean);
 		printf("%s\n", ret ? "ERROR" : "OK");
 
 		return ret == 0 ? 0 : 1;
@@ -275,7 +277,6 @@ U_BOOT_CMD(nand, 5, 1, do_nand,
 	"    offset `off' (entire device if not specified)\n"
 	"nand bad - show bad blocks\n"
 	"nand dump[.oob] off - dump page\n"
-	"nand scrub - really clean NAND erasing bad blocks (UNSAFE)\n"
 	"nand markbad off - mark bad block at offset (UNSAFE)\n"
 	"nand biterr off - make a bit error at offset (UNSAFE)\n");
 
common/env_nand.c +1 -1
index dd27f7b..97371e9 100644
@@ -116,7 +116,7 @@ int saveenv(void)
 	int ret = 0;
 
 	puts ("Erasing Nand...");
-	if (nand_erase(&nand_info[0], CFG_ENV_OFFSET, CFG_ENV_SIZE))
+	if (nand_erase(&nand_info[0], CFG_ENV_OFFSET, CFG_ENV_SIZE, 0))
 		return 1;
 
 	puts ("Writing to Nand... ");
include/nand.h +2 -2
index 905115b..ccac9c1 100644
@@ -48,7 +48,7 @@ static inline int nand_block_isbad(nand_
 	return info->block_isbad(info, ofs);
 }
 
-static inline int nand_erase(nand_info_t *info, ulong off, ulong size)
+static inline int nand_erase(nand_info_t *info, ulong off, ulong size, int clean)
 {
 	struct erase_info instr;
 
@@ -57,7 +57,7 @@ static inline int nand_erase(nand_info_t
 	instr.len = size;
 	instr.callback = 0;
 
-	return info->erase(info, &instr);
+	return nand_erase_nand(info, &instr, clean);
 }
 
 #endif
#3 lore raw

Dear Ladislav,

Quoted 2 lines · in message <20060317185016.GA10588@orphique> you wrote:

Here is one of those 'few' things - erasing OOB area...

Thanks a lot, but...

common/cmd_nand.c int do_nand(cmd_tbl_t * cmdtp, int flag, · line 203

Quoted 3 lines
common/cmd_nand.c +3 -0
+		int clean = (argc > 2 && strcmp(argv[2], "clean") == 0) ? 1 : 0;
+		int o = clean ? 3 : 2;
+		arg_off_size(argc - o, argv + o, &off, &size, nand->size);

Can you please re-implement this in a bit a less cryptic way? I will not complain if it takes 6 lines instead of 3. LoC are cheap these days ;-)

Best regards,

Wolfgang Denk

Signature · 7 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
That's their goal, remember, a goal that's really contrary to that of
the programmer or administrator. We just want to get our  jobs  done.
$Bill  just  wants  to  become  $$Bill. These aren't even marginallly
congruent.
         -- Tom Christiansen in <[email protected]>
#4 lore raw
Quoted 7 lines · Wolfgang Denk

common/cmd_nand.c int do_nand(cmd_tbl_t * cmdtp, int flag, · line 203

Quoted 3 lines
common/cmd_nand.c +3 -0
+		int clean = (argc > 2 && strcmp(argv[2], "clean") == 0) ? 1 : 0;
+		int o = clean ? 3 : 2;
+		arg_off_size(argc - o, argv + o, &off, &size, nand->size);

Can you please re-implement this in a bit a less cryptic way? I will not complain if it takes 6 lines instead of 3. LoC are cheap these days ;-)

Syntax is:

	0	1	2	3	4
	nand	erase 	[clean] [off 	size]

So we just look if there are more that two arguments and argument at index 2 is "clean". In that case we want also erase OOB. Then we just skip first 2 or 3 argumets while looking for offset and size. Shall I try harder to reimplement it or is additional comment okay? ;-)

Best regards,
ladis

#5 lore raw
Quoted 9 lines · In message <20060324004338.GA14228@orphique> you wrote:

Syntax is:

	0	1	2	3	4
	nand	erase 	[clean] [off 	size]

So we just look if there are more that two arguments and argument at index 2 is "clean". In that case we want also erase OOB. Then we just skip first 2 or 3 argumets while looking for offset and size. Shall I try harder to reimplement it or is additional comment okay? ;-)

Yes :-)

Meaning - the comment is IMHO necessary. Thanks.

Best regards,

Wolfgang Denk

Signature · 4 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The last thing one knows in constructing a work is what to put first.
- Blaise Pascal
#6 lore raw
Quoted 1 line · Wolfgang Denk

Meaning - the comment is IMHO necessary. Thanks.

I hope it makes enough sense...

Best regards,
ladis

Signed-off-by Ladislav Michl <[email protected]>

CHANGELOG
* Implement NAND OOB erase command
Patch by Ladislav Michl, 24 Mar 2006

common/cmd_nand.c +12 -4
index 21adb1b..d443086 100644
@@ -197,14 +197,23 @@ int do_nand(cmd_tbl_t * cmdtp, int flag,
 		return 0;
 	}
 
+	/*
+	 * Syntax is:
+	 *    0    1     2       3    4
+	 *   nand erase [clean] [off size]
+	 */
 	if (strcmp(cmd, "erase") == 0) {
-		arg_off_size(argc - 2, argv + 2, &off, &size, nand->size);
+		/* "clean" at index 2 means request to erase OOB */
+		int clean = (argc > 2 && strcmp(argv[2], "clean") == 0) ? 1 : 0;
+		int o = clean ? 3 : 2;
+		/* skip first two or three arguments, look for offset and size */
+		arg_off_size(argc - o, argv + o, &off, &size, nand->size);
 		if (off == 0 && size == 0)
-			return 1;
+			size = nand->size;
 
 		printf("\nNAND erase: device %d offset 0x%x, size 0x%x ",
 		       nand_curr_device, off, size);
-		ret = nand_erase(nand, off, size);
+		ret = nand_erase(nand, off, size, clean);
 		printf("%s\n", ret ? "ERROR" : "OK");
 
 		return ret == 0 ? 0 : 1;
@@ -275,7 +284,6 @@ U_BOOT_CMD(nand, 5, 1, do_nand,
 	"    offset `off' (entire device if not specified)\n"
 	"nand bad - show bad blocks\n"
 	"nand dump[.oob] off - dump page\n"
-	"nand scrub - really clean NAND erasing bad blocks (UNSAFE)\n"
 	"nand markbad off - mark bad block at offset (UNSAFE)\n"
 	"nand biterr off - make a bit error at offset (UNSAFE)\n");
 
common/env_nand.c +1 -1
index dd27f7b..97371e9 100644
@@ -116,7 +116,7 @@ int saveenv(void)
 	int ret = 0;
 
 	puts ("Erasing Nand...");
-	if (nand_erase(&nand_info[0], CFG_ENV_OFFSET, CFG_ENV_SIZE))
+	if (nand_erase(&nand_info[0], CFG_ENV_OFFSET, CFG_ENV_SIZE, 0))
 		return 1;
 
 	puts ("Writing to Nand... ");
include/nand.h +2 -2
index 905115b..ccac9c1 100644
@@ -48,7 +48,7 @@ static inline int nand_block_isbad(nand_
 	return info->block_isbad(info, ofs);
 }
 
-static inline int nand_erase(nand_info_t *info, ulong off, ulong size)
+static inline int nand_erase(nand_info_t *info, ulong off, ulong size, int clean)
 {
 	struct erase_info instr;
 
@@ -57,7 +57,7 @@ static inline int nand_erase(nand_info_t
 	instr.len = size;
 	instr.callback = 0;
 
-	return info->erase(info, &instr);
+	return nand_erase_nand(info, &instr, clean);
 }
 
 #endif