[U-Boot-Users] [PATCH 2/7 v6] nand_spl: Support page-aligned read in nand_load, use chipselect
    Guennadi Liakhovetski 
    lg at denx.de
       
    Thu Aug  7 08:36:59 CEST 2008
    
    
  
On Wed, 6 Aug 2008, Scott Wood wrote:
> On Wed, Aug 06, 2008 at 09:42:07PM +0200, Guennadi Liakhovetski wrote:
> >  	block = offs / CFG_NAND_BLOCK_SIZE;
> > +	blocks = (uboot_size + offs - ((block - 1) * CFG_NAND_BLOCK_SIZE) - 1) /
> > +		CFG_NAND_BLOCK_SIZE;
> >  	blockcopy_count = 0;
> >  
> > -	while (blockcopy_count < (uboot_size / CFG_NAND_BLOCK_SIZE)) {
> > +	while (blockcopy_count < blocks) {
> >  		if (!nand_is_bad_block(mtd, block)) {
> >  			/*
> >  			 * Skip bad blocks
> >  			 */
> >  			for (page = 0; page < CFG_NAND_PAGE_COUNT; page++) {
> >  				nand_read_page(mtd, block, page, dst);
> > -				dst += CFG_NAND_PAGE_SIZE;
> > +				/* Overwrite skipped pages */
> > +				if (read >= offs)
> > +					dst += CFG_NAND_PAGE_SIZE;
> > +				read += CFG_NAND_PAGE_SIZE;
> 
> This looks wrong if offs isn't within the first block.
Arrrgh, during the merge the following two lines went missing from the 
patch:
+       /* Recalculate offs as an offset inside a block */
+       offs -= CFG_NAND_BLOCK_SIZE * block;
which were there, for example, in v5.
> I've pushed a fixed and simplified version to nand-flash/testing -- can
> you test it?
Yes, it works. Your version is also better, since it skips unneeded pages 
instead of reading them in and overwriting, as mine did.
Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
    
    
More information about the U-Boot
mailing list