From 0e92eb8bd72ed858d92b3f43c899269b0dce6b99 Mon Sep 17 00:00:00 2001 From: Xiangfu Liu Date: Thu, 23 Dec 2010 19:10:51 +0800 Subject: [PATCH] xburst_stage2: don't skip bad block when nand erase --- usbboot/xburst_stage2/nandflash_4740.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/usbboot/xburst_stage2/nandflash_4740.c b/usbboot/xburst_stage2/nandflash_4740.c index 7586199..5f66b3a 100644 --- a/usbboot/xburst_stage2/nandflash_4740.c +++ b/usbboot/xburst_stage2/nandflash_4740.c @@ -309,19 +309,17 @@ u32 nand_read_raw_4740(void *buf, u32 startpage, u32 pagecount, int option) u32 nand_erase_4740(int blk_num, int sblk, int force) { - int i, j; + int j; u32 cur, rowaddr; if (wp_pin) __gpio_set_pin(wp_pin); - cur = sblk * ppb; - for (i = 0; i < blk_num; ) { + for (cur = sblk * ppb; cur < (sblk + blk_num) * ppb; cur += ppb) { rowaddr = cur; select_chip(cur / ppb); if (!force) { - if (nand_check_block(cur/ppb)) { - cur += ppb; + if (nand_check_block(cur / ppb)) { blk_num += Hand.nand_plane; continue; } @@ -341,15 +339,13 @@ u32 nand_erase_4740(int blk_num, int sblk, int force) serial_puts("\nErase fail at: \t"); serial_put_hex(cur / ppb); nand_mark_bad_4740(cur/ppb); - cur += ppb; continue; } - cur += ppb; - i++; } if (wp_pin) __gpio_clear_pin(wp_pin); + return cur; } @@ -744,7 +740,6 @@ u32 nand_mark_bad_4740(int block) { u32 rowaddr; - /* nand_erase_4740( 1, block, 1); force erase before */ if (bad_block_page >= ppb) { /* mark four page! */ rowaddr = block * ppb + 0; nand_mark_bad_page(rowaddr);