[U-Boot-Users] [PATCH 2/7 v5] Simplify reading of the bad-block marker, use chipselect

Scott Wood scottwood at freescale.com
Tue Aug 5 17:21:29 CEST 2008


On Tue, Aug 05, 2008 at 03:36:43PM +0200, Guennadi Liakhovetski wrote:
>  	/*
> -	 * offs has to be aligned to a block address!
> +	 * offs has to be aligned to a page address!
>  	 */
>  	block = offs / CFG_NAND_BLOCK_SIZE;
> +	/* Recalculate offs as an offset inside a block */
> +	offs -= CFG_NAND_BLOCK_SIZE * block;
>  	blockcopy_count = 0;
>  
> -	while (blockcopy_count < (uboot_size / CFG_NAND_BLOCK_SIZE)) {
> -		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;
> +	while (blockcopy_count < ((uboot_size + CFG_NAND_BLOCK_SIZE - 1) /
> +				  CFG_NAND_BLOCK_SIZE)) {

If you're going to allow offs to be block-unaligned, I think this
calculation needs to change.  For example: blocksize 16K, offset 14K, and
length 256K would try to read 16 blocks, when it needs to read 17.

-Scott




More information about the U-Boot mailing list