From 3e030a84f87a60fb9cb232db796e8f4500ded9e8 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 17 Sep 2009 10:22:28 +0800 Subject: [PATCH] fix usbboot skips empty pages during write --- usbboot/xburst_stage2/nandflash_4740.c | 27 ++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/usbboot/xburst_stage2/nandflash_4740.c b/usbboot/xburst_stage2/nandflash_4740.c index e7e0b24..a2c8d77 100644 --- a/usbboot/xburst_stage2/nandflash_4740.c +++ b/usbboot/xburst_stage2/nandflash_4740.c @@ -541,11 +541,17 @@ u32 nand_read_4740(void *buf, u32 startpage, u32 pagecount, int option) u32 nand_program_4740(void *context, int spage, int pages, int option) { + size_t datasize; u32 i, j, cur, rowaddr; u8 *tmpbuf; u32 ecccnt,oobsize_sav,ecccnt_sav,eccpos_sav; u8 ecc_buf[256]; + datasize = pagesize; + if (option != NO_OOB) + datasize += oobsize; + + if (wp_pin) __gpio_set_pin(wp_pin); restart: @@ -581,19 +587,16 @@ restart: } } - //if NO_OOB do not perform vaild check! - if ( option != NO_OOB ) { - for ( j = 0 ; j < pagesize + oobsize; j ++) { - if (tmpbuf[j] != 0xff) - break; - } + for (j = 0; j < datasize; ++j) { + if (tmpbuf[j] != 0xff) + break; + } - if ( j == oobsize + pagesize ) { - tmpbuf += ( pagesize + oobsize ) ; - i ++; - cur ++; - continue; - } + if (j == datasize) { + tmpbuf += datasize; + ++i; + ++cur; + continue; } if (pagesize == 512)