[U-Boot-Users] Re: Make drivers/cfi_flash.c protect environment and redundant enviro nment

Woodruff, Richard r-woodruff2 at ti.com
Sat Feb 26 14:36:44 CET 2005


A half related note is, I recently switched the OMAP/H4 driver to use
CFI.  Intel parts after power on reset have all their lock bits
set...So, the explicit protect of env sectors is kind of moot when they
are all set...software reset doesn't clear them.  The Intel doc's say
its that way to protect the flash through power cycles.

I also needed to fix up the hardware protect routine for the parts in
question as be base command set only works per partition, not per part.

Regards,
Richard W.



> -----Original Message-----
> From: u-boot-users-admin at lists.sourceforge.net [mailto:u-boot-users-
> admin at lists.sourceforge.net] On Behalf Of Ladislav Michl
> Sent: Saturday, February 26, 2005 4:52 AM
> To: Michael Bendzick
> Cc: U-Boot-Users (E-mail)
> Subject: [U-Boot-Users] Re: Make drivers/cfi_flash.c protect
environment
> and redundant enviro nment
> 
> On Mon, Aug 30, 2004 at 01:56:34PM -0500, Michael Bendzick wrote:
> > Included is a patch to the drivers/cfi_flash.c driver that will
> > automatically enable environment and redundant environment
protection
> > protection upon booting.  Previously, only the monitor (U-Boot) was
> > protected by the driver.
> [snip]
> > diff -purN a/drivers/cfi_flash.c b/drivers/cfi_flash.c
> > --- a/drivers/cfi_flash.c	2004-07-12 17:34:52.000000000 -0500
> > +++ b/drivers/cfi_flash.c	2004-08-30 13:34:23.783099389 -0500
> > @@ -338,6 +338,21 @@ unsigned long flash_init (void)
> >  		       &flash_info[0]);
> >  #endif
> >
> > +	/* Environment protection ON by default */
> > +#ifdef CFG_ENV_IS_IN_FLASH
> > +	flash_protect (FLAG_PROTECT_SET,
> > +		       CFG_ENV_ADDR,
> > +		       CFG_ENV_ADDR + CFG_ENV_SECT_SIZE - 1,
> > +		       &flash_info[0]);
> > +#endif
> > +
> > +	/* Redundant environment protection ON by default */
> > +#ifdef CFG_ENV_ADDR_REDUND
> > +	flash_protect (FLAG_PROTECT_SET,
> > +		       CFG_ENV_ADDR_REDUND,
> > +		       CFG_ENV_ADDR_REDUND + CFG_ENV_SIZE_REDUND - 1,
> > +		       &flash_info[0]);
> > +#endif
> >  	return (size);
> >  }
> 
> Well, if you are using CFG_ENV_SIZE_REDUND it would make sense to use
> CFG_ENV_SIZE instead of CFG_ENV_SECT_SIZE to make code a bit more
> consistent. flash_protect will extend end address to sector boundary
> anyway.
> 
> Index: drivers/cfi_flash.c
> ===================================================================
> RCS file: /cvsroot/u-boot/u-boot/drivers/cfi_flash.c,v
> retrieving revision 1.16
> diff -u -r1.16 cfi_flash.c
> --- drivers/cfi_flash.c	9 Jan 2005 17:12:33 -0000	1.16
> +++ drivers/cfi_flash.c	26 Feb 2005 10:42:12 -0000
> @@ -348,10 +347,8 @@
>  #ifdef CFG_ENV_IS_IN_FLASH
>  	flash_protect (FLAG_PROTECT_SET,
>  		       CFG_ENV_ADDR,
> -		       CFG_ENV_ADDR + CFG_ENV_SECT_SIZE - 1,
> +		       CFG_ENV_ADDR + CFG_ENV_SIZE - 1,
>  		       &flash_info[0]);
> -#endif
> -
>  	/* Redundant environment protection ON by default */
>  #ifdef CFG_ENV_ADDR_REDUND
>  	flash_protect (FLAG_PROTECT_SET,
> @@ -359,6 +356,7 @@
>  		       CFG_ENV_ADDR_REDUND + CFG_ENV_SIZE_REDUND - 1,
>  		       &flash_info[0]);
>  #endif
> +#endif
>  	return (size);
>  }
> 
> 
> 
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real
users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> _______________________________________________
> U-Boot-Users mailing list
> U-Boot-Users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/u-boot-users




More information about the U-Boot mailing list