[U-Boot] [PATCH] NAND CMD: Add bad block skipping for nboot

David.Kondrad at onqlegrand.com David.Kondrad at onqlegrand.com
Thu Dec 11 19:32:40 CET 2008


This patch adds bad block skipping for nboot command by using
nand_read_skip_bad function.

The initial read size had to be increased because there seems to be an
issue with
nand_read_skip_bad and read sizes less than erasesize when the first block
needs to be skipped.

Since our kernel images are likely to be much larger than page size, we
sacrifice a little
performance for correct behavior.

Tested with following procedure:

(kernel partition is nand0,2 beginning at offset c8000)
(platform is davinci dvevm, small page nand, broken ecc enabled)

1. nand erase nand0,2
2. nand markbad c8000
3. nand markbad cc000
4. nand markbad e4000
5. tftp 80700000 uImage
6. nand write 80700000 nand0,2 1c000
7. mw 80700000 0 1c000
8. nboot 80700000 nand0,2
9. iminfo 80700000

Diff based off of latest git as of 8:30 AM EST.

Signed-off-by: David Kondrad <david.kondrad at onqlegrand.com>
---
 common/cmd_nand.c |   22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index 0a366d3..aadfe96 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -507,9 +507,21 @@ static int nand_load_image(cmd_tbl_t *cmdtp,
nand_info_t *nand,
      }

      printf("\nLoading from %s, offset 0x%lx\n", nand->name, offset);
-
-     cnt = nand->writesize;
-     r = nand_read(nand, offset, &cnt, (u_char *) addr);
+
+     /* When using nand_read_skip_bad the process fails
+           with the original size of writesize when a bad block
+        needs to be skipped.
+
+        This points to a bug in nand_read_skip_bad, but since
+        this is supposed to be a simple fix let's just bump up
+        the size so that the read doesn't fail with bad blocks.
+     */
+     cnt = nand->erasesize;
+
+     /* Should be skipping bad blocks just as a nand read does
+           so we'll do the same thing here
+     */
+     r = nand_read_skip_bad(nand, offset, &cnt, (u_char *) addr);
      if (r) {
            puts("** Read error\n");
            show_boot_progress (-56);
@@ -541,8 +553,8 @@ static int nand_load_image(cmd_tbl_t *cmdtp,
nand_info_t *nand,
      }
      show_boot_progress (57);

-     /* FIXME: skip bad blocks */
-     r = nand_read(nand, offset, &cnt, (u_char *) addr);
+     /* FIXED: Use same read function as nand read command */
+     r = nand_read_skip_bad(nand, offset, &cnt, (u_char *) addr);
      if (r) {
            puts("** Read error\n");
            show_boot_progress (-58);
---

DAVID A. KONDRAD
Software Design Engineer
On-Q/Legrand
Telephone (800) 321-2343 x311
www.onqlegrand.com



More information about the U-Boot mailing list