On 13:03 Thu 26 Feb , Rohit Hagargundgi wrote: > Currently OneNAND initial program loader (ipl) reads only block 0. > However, u-boot image for apollon board is 195KB making the board > unbootable with OneNAND. > Fix ipl to read 256KB. > > Signed-off-by: Rohit Hagargundgi <h.ro...@samsung.com> > --- > onenand_ipl/onenand_ipl.h | 1 + > onenand_ipl/onenand_read.c | 29 +++++++++++++++++++++-------- > 2 files changed, 22 insertions(+), 8 deletions(-) > > diff --git a/onenand_ipl/onenand_ipl.h b/onenand_ipl/onenand_ipl.h > index 3387998..f96e88a 100644 > --- a/onenand_ipl/onenand_ipl.h > +++ b/onenand_ipl/onenand_ipl.h > @@ -24,6 +24,7 @@ > #include <linux/mtd/onenand_regs.h> > > #define ONENAND_BLOCK_SIZE 2048 > +#define ONENAND_BOOTLOADER_SIZE 0x40000 why hardcoded value? > > #ifndef CONFIG_SYS_PRINTF > #define printf(format, args...) > diff --git a/onenand_ipl/onenand_read.c b/onenand_ipl/onenand_read.c > index 6d04943..33c66ff 100644 > --- a/onenand_ipl/onenand_read.c > +++ b/onenand_ipl/onenand_read.c > @@ -72,6 +72,13 @@ static inline int onenand_read_page(ulong block, ulong > page, > while (!(READ_INTERRUPT() & ONENAND_INT_READ)) > continue; > > + /* Check for invalid block mark*/ > + if (page < 2) { > + unsigned int mark = > onenand_readw(THIS_ONENAND(ONENAND_SPARERAM)); please add a empty line
and why not do this if (page < 2 && (onenand_readw(THIS_ONENAND(ONENAND_SPARERAM)) != 0xffff)) return 1; > + if (mark != 0xffff) > + return 1; > + } > + > #ifdef __HAVE_ARCH_MEMCPY32 > /* 32 bytes boundary memory copy */ > memcpy32(buf, base, pagesize); > @@ -94,21 +101,27 @@ static inline int onenand_read_page(ulong block, ulong > page, > */ > int onenand_read_block0(unsigned char *buf) > { > - int page, offset = 0; > + int block = 0, page, offset = 0; > int pagesize = ONENAND_PAGE_SIZE; > + int nblocks = ONENAND_BOOTLOADER_SIZE / (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 >>= 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; > - } > + for (page = ONENAND_START_PAGE; block < nblocks; page = 0, block++) please add the {} and move the page = 0 to the second 'for' it will be easier to read and understand > + 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; > + } Best Regards, J. _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot