[U-Boot] [PATCH 1/2] Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN
Scott Wood
scottwood at freescale.com
Mon Mar 9 20:42:37 CET 2009
On Mon, Mar 09, 2009 at 07:45:40PM +0530, Rohit Hagargundgi wrote:
> + /* Check for invalid block mark*/
> + if (page < 2 && (onenand_readw(THIS_ONENAND(ONENAND_SPARERAM)) != 0xffff))
> + return 1;
Line length.
> - int page, offset = 0;
> + int block = 0, page = ONENAND_START_PAGE, offset = 0;
> int pagesize = ONENAND_PAGE_SIZE;
> + int nblocks = CONFIG_SYS_MONITOR_LEN / ONENAND_BLOCK_SIZE;
Shouldn't nblocks be rounded up?
> /* MLC OneNAND has 4KiB page size */
> - if (onenand_readw(THIS_ONENAND(ONENAND_REG_TECHNOLOGY)))
> + if (onenand_readw(THIS_ONENAND(ONENAND_REG_TECHNOLOGY))) {
> pagesize <<= 1;
> + nblocks = (nblocks + 1) >> 1;
> + }
Hmm, might be clearer to just do this:
if (onenand_readw(THIS_ONENAND(ONENAND_REG_TECHNOLOGY))) {
pagesize = 4096;
pageshift = 12;
} else {
pagesize = 2048;
pageshift = 11;
}
nblocks = (CONFIG_SYS_MONITOR_LEN + pagesize - 1) >> pageshift;
ONENAND_PAGE_SIZE as a constant should go away since it's not always
true.
> /* NOTE: you must read page from page 1 of block 0 */
> /* read the block page by page*/
> - for (page = ONENAND_START_PAGE;
> - page < ONENAND_PAGES_PER_BLOCK; page++) {
> -
> - onenand_read_page(0, page, buf + offset, pagesize);
> - offset += pagesize;
> + for (; block < nblocks; block++) {
> + for (; page < ONENAND_PAGES_PER_BLOCK; page++) {
> + if (onenand_read_page(block, page, buf + offset, pagesize)) {
> + /* This block is bad. Skip it and read next block */
> + nblocks++;
> + break;
> + }
> + offset += pagesize;
If you find a bad block marker in the second page of a block, shouldn't
you rewind offset to the beginning of the block?
BTW, if we're going to have "onenand_readw" and "onenand_writew"
wrappers, can we make them useful by combining them with THIS_ONENAND?
-Scott
More information about the U-Boot
mailing list