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

Ladislav Michl ladis at linux-mips.org
Sat Feb 26 11:52:06 CET 2005


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);
 }
 




More information about the U-Boot mailing list