From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rohit Hagargundgi Date: Sun, 08 Mar 2009 12:20:02 +0530 Subject: [U-Boot] [PATCH] Fix OneNAND ipl to read 256KB In-Reply-To: <9c9fda240903041555i36b8048ck4e3349a81b51e0a3@mail.gmail.com> References: <49A645E0.9060608@samsung.com> <20090226082314.3A3BA832E43F@gemini.denx.de> <9c9fda240902260234w4eaf509cq5b05c59e699096f4@mail.gmail.com> <49A6F513.9070205@samsung.com> <49AE99C0.9040400@samsung.com> <9c9fda240903041555i36b8048ck4e3349a81b51e0a3@mail.gmail.com> Message-ID: <49B36A9A.2050502@samsung.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi, Kyungmin Park wrote: >> >> + /* Check for invalid block mark*/ >> + if (page < 2 && (onenand_readw(THIS_ONENAND(ONENAND_SPARERAM)) != 0xffff)) >> + return 1; >> + > > No need to check invalid block. Note that block 0 is always good > block. no exception. Correct. block 0 is guaranteed to be good. > Now you assume block 1 can be invalid block. If true just skip it. > when update bootloader at u-boot or kernel. > there's bad block at block 1. it will skip write. it means bootloader > are located at block 0 and block 2. yes, block 1 is invalid so block 0 and block 2 store bootloader. so in ipl, we need to check invalid mark. block 1 is detected bad. block 1 is skipped and block 2 is read for bootloader. >> + int nblocks = CONFIG_SYS_MONITOR_LEN / (ONENAND_PAGES_PER_BLOCK * ONENAND_PAGE_SIZE); >> >> /* 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; >> + } assuming page size of 2KB, nblocks is initialised to 2. for 4KB paged devices (like Flex-OneNAND), nblocks gets halved ie 1. >> >> /* 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; >> + page = ONENAND_START_PAGE; >> + 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; >> + } >> + page = 0; >> } >> >> return 0; > > NAK, please use previous one as I sent. > In Flex-OneNAND block 0 has 256KiB. need to handle at here how many > blocks are needed. this is taken care above. > I also want to use CONFIG_ONENAND_END_BLOCK since we don't know which > OneNAND or Flex-OneNAND are attached to apollon board. okay. but why not use a variable instead. Thanks, Rohit