[U-Boot] [PATCH 1/3] Bad block support for environment variables partition in OneNAND

Scott Wood scottwood at freescale.com
Thu Jan 15 22:12:07 CET 2009


On Thu, Dec 11, 2008 at 07:58:26PM +0530, Rohit Hagargundgi wrote:
> +	env_addr = FLEXONENAND(this) ? CONFIG_ENV_ADDR_FLEX :
> +					CONFIG_ENV_ADDR;
> +
> +	env_len = FLEXONENAND(this) ? CONFIG_ENV_SIZE_FLEX :
> +					CONFIG_ENV_SIZE;

Is there any reason why this has to be done at runtime, rather than just
using one set of CONFIG_ parameters regardless of whether it's flex?

>  
>  	/* Check OneNAND exist */
> -	if (onenand_mtd.writesize)
> -		/* Ignore read fail */
> -		onenand_read(&onenand_mtd, env_addr, onenand_mtd.writesize,
> -			     &retlen, (u_char *) env_ptr);
> -	else
> +	if (onenand_mtd.writesize) {
> +		while (env_addr < env_addr + env_len) {

This is a tautology, unless you're checking for wraparound of unsigned
long.

> +	onenand_get_block(this, ofs, &slc);
> +	if (slc)
> +		instr.len += 1 << (this->erase_shift -1);

this->erase_shift - 1

> +	if (mtd->erase(mtd, &instr)) {
> +		printf("writeenv: erase failed at 0x%08lx\n", ofs);
> +		if(mtd->block_markbad(mtd, ofs))
> +			printf("writeenv: Mark bad failed at 0x%08lx\n", ofs);

Space after "if".

-Scott


More information about the U-Boot mailing list