Redundant Environment: protect full sector size
authorWolfgang Denk <wd@denx.de>
Thu, 14 May 2009 22:16:03 +0000 (00:16 +0200)
committerWolfgang Denk <wd@denx.de>
Wed, 3 Jun 2009 22:16:16 +0000 (00:16 +0200)
Several boards used different ways to specify the size of the
protected area when enabling flash write protection for the sectors
holding the environment variables: some used CONFIG_ENV_SIZE and
CONFIG_ENV_SIZE_REDUND, some used CONFIG_ENV_SECT_SIZE, and some even
a mix of both for the "normal" and the "redundant" areas.

Normally, this makes no difference at all. However, things are
different when you have to deal with boards that can come with
different types of flash chips, which may have different sector
sizes.

Here we may have to chose CONFIG_ENV_SECT_SIZE such that it fits the
biggest sector size, which may include several sectors on boards using
the smaller sector flash types. In such a case, using CONFIG_ENV_SIZE
or CONFIG_ENV_SIZE_REDUND to enable the protection may lead to the
case that only the first of these sectors get protected, while the
following ones aren't.

This is no real problem, but it can be confusing for the user -
especially on boards that use CONFIG_ENV_SECT_SIZE to protect the
"normal" areas, while using CONFIG_ENV_SIZE_REDUND for the
"redundant" area.

To avoid such inconsistencies, I changed all sucn boards that I found
to consistently use CONFIG_ENV_SECT_SIZE for protection. This should
not cause any functional changes to the code.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Paul Ruhland
Cc: Pantelis Antoniou <panto@intracom.gr>
Cc: Stefan Roese <sr@denx.de>
Cc: Gary Jennejohn <garyj@denx.de>
Cc: Dave Ellis <DGE@sixnetio.com>
Acked-by: Stefan Roese <sr@denx.de>
15 files changed:
board/lpd7a40x/flash.c
board/mcc200/mcc200.c
board/netphone/flash.c
board/netta/flash.c
board/netta2/flash.c
board/netvia/flash.c
board/pleb2/flash.c
board/prodrive/pdnb3/flash.c
board/rmu/flash.c
board/samsung/smdk2400/flash.c
board/sixnet/flash.c
board/socrates/socrates.c
board/tqc/tqm85xx/tqm85xx.c
board/trab/flash.c
drivers/mtd/cfi_flash.c

index a13b827fb2baf2dd7e7472de8ebf138b444b390b..a3ba75b8938d52d258de46ac54de429e2ad20e25 100644 (file)
@@ -98,12 +98,12 @@ ulong flash_init (void)
 
        flash_protect ( FLAG_PROTECT_SET,
                        CONFIG_ENV_ADDR,
-                       CONFIG_ENV_ADDR + CONFIG_ENV_SIZE - 1, &flash_info[0]);
+                       CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1, &flash_info[0]);
 
 #ifdef CONFIG_ENV_ADDR_REDUND
        flash_protect ( FLAG_PROTECT_SET,
                        CONFIG_ENV_ADDR_REDUND,
-                       CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SIZE_REDUND - 1,
+                       CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
                        &flash_info[0]);
 #endif
 
index 14cf08da3f7abc53b776ccb99d73446b6b48534d..9fa1d3ae75c56eb5a5398371d1c90199173437e3 100644 (file)
@@ -270,7 +270,7 @@ int misc_init_r (void)
                /* Redundant environment protection ON by default */
                flash_protect (FLAG_PROTECT_SET,
                               CONFIG_ENV_ADDR_REDUND,
-                              CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SIZE_REDUND - 1,
+                              CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
                               &flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]);
        }
 
index 8852127e61e38b350ce2a1e18d000e4fe1be2055..349d98e73830839cf0f8e685ba6c21802f608657 100644 (file)
@@ -73,13 +73,13 @@ unsigned long flash_init(void)
 
        flash_protect ( FLAG_PROTECT_SET,
                        CONFIG_ENV_ADDR,
-                       CONFIG_ENV_ADDR + CONFIG_ENV_SIZE - 1,
+                       CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1,
                        &flash_info[0]);
 
 #ifdef CONFIG_ENV_ADDR_REDUND
        flash_protect ( FLAG_PROTECT_SET,
                        CONFIG_ENV_ADDR_REDUND,
-                       CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SIZE_REDUND - 1,
+                       CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
                        &flash_info[0]);
 #endif
 
index 45e6b30102d43a89c2c2bb8705b39b6cf9cdaaec..565fd67c6eab7846d8f18a5c44be75797d6fdd21 100644 (file)
@@ -69,13 +69,13 @@ unsigned long flash_init(void)
 
        flash_protect ( FLAG_PROTECT_SET,
                        CONFIG_ENV_ADDR,
-                       CONFIG_ENV_ADDR + CONFIG_ENV_SIZE - 1,
+                       CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1,
                        &flash_info[0]);
 
 #ifdef CONFIG_ENV_ADDR_REDUND
        flash_protect ( FLAG_PROTECT_SET,
                        CONFIG_ENV_ADDR_REDUND,
-                       CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SIZE_REDUND - 1,
+                       CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
                        &flash_info[0]);
 #endif
 
index b63f459519049a76f19209e4277bb1ad1af1cea1..53a4e1eb20957ab25a117d3c0d0d4ae5e0b4a264 100644 (file)
@@ -70,13 +70,13 @@ unsigned long flash_init(void)
 
        flash_protect ( FLAG_PROTECT_SET,
                        CONFIG_ENV_ADDR,
-                       CONFIG_ENV_ADDR + CONFIG_ENV_SIZE - 1,
+                       CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1,
                        &flash_info[0]);
 
 #ifdef CONFIG_ENV_ADDR_REDUND
        flash_protect ( FLAG_PROTECT_SET,
                        CONFIG_ENV_ADDR_REDUND,
-                       CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SIZE_REDUND - 1,
+                       CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
                        &flash_info[0]);
 #endif
 
index 98479a50b8f87d20ffc77f4568620d615b216298..b9874347b95718d5774fd341abf3353ad68cb05d 100644 (file)
@@ -69,13 +69,13 @@ unsigned long flash_init(void)
 
        flash_protect ( FLAG_PROTECT_SET,
                        CONFIG_ENV_ADDR,
-                       CONFIG_ENV_ADDR + CONFIG_ENV_SIZE - 1,
+                       CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1,
                        &flash_info[0]);
 
 #ifdef CONFIG_ENV_ADDR_REDUND
        flash_protect ( FLAG_PROTECT_SET,
                        CONFIG_ENV_ADDR_REDUND,
-                       CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SIZE_REDUND - 1,
+                       CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
                        &flash_info[0]);
 #endif
 
index abaf0b4d24af018ca4b3f36a43e5f71b4819c91e..a8897dcffe82bc317bb90584e6509adfabcdc290 100644 (file)
@@ -110,13 +110,13 @@ unsigned long flash_init (void)
 #ifdef CONFIG_ENV_ADDR
        flash_protect (FLAG_PROTECT_SET,
                       CONFIG_ENV_ADDR,
-                      CONFIG_ENV_ADDR + CONFIG_ENV_SIZE - 1, &flash_info[0]);
+                      CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1, &flash_info[0]);
 #endif
 
 #ifdef CONFIG_ENV_ADDR_REDUND
        flash_protect (FLAG_PROTECT_SET,
                       CONFIG_ENV_ADDR_REDUND,
-                      CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SIZE_REDUND - 1,
+                      CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
                       &flash_info[0]);
 #endif
 
index 351aed1e113a4b05924d24250feeed6715766169..fe8d100083c6503b7d88083644e71ba917c49ca0 100644 (file)
@@ -78,7 +78,7 @@ unsigned long flash_init(void)
        /* Redundant environment protection ON by default */
        flash_protect(FLAG_PROTECT_SET,
                      CONFIG_ENV_ADDR_REDUND,
-                     CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SIZE_REDUND - 1,
+                     CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
                      &flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]);
 
        flash_info[0].size = size;
index a3ab851d2c79bdd27130ced3f37c5a50590711b8..283b19d045c9cd2e24521c3533070cde74d16428 100644 (file)
@@ -85,18 +85,18 @@ unsigned long flash_init (void)
        /* ENV protection ON by default */
        flash_protect(FLAG_PROTECT_SET,
                      CONFIG_ENV_ADDR,
-                     CONFIG_ENV_ADDR+CONFIG_ENV_SIZE-1,
+                     CONFIG_ENV_ADDR+CONFIG_ENV_SECT_SIZE-1,
                      &flash_info[0]);
 #endif
 
 #if defined(CONFIG_ENV_ADDR_REDUND) || defined(CONFIG_ENV_OFFSET_REDUND)
        debug ("Protect redundand environment: %08lx ... %08lx\n",
                (ulong)CONFIG_ENV_ADDR_REDUND,
-               (ulong)CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SIZE - 1);
+               (ulong)CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1);
 
        flash_protect(FLAG_PROTECT_SET,
                      CONFIG_ENV_ADDR_REDUND,
-                     CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SIZE_REDUND - 1,
+                     CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
                      &flash_info[0]);
 #endif
 
index 46b5786fe6d0ef8a6f612749c1a5656889d1ec32..fb69c21a45056d9cde2b16f23861e639c8f1fb7d 100644 (file)
@@ -98,12 +98,12 @@ ulong flash_init (void)
 
        flash_protect ( FLAG_PROTECT_SET,
                        CONFIG_ENV_ADDR,
-                       CONFIG_ENV_ADDR + CONFIG_ENV_SIZE - 1, &flash_info[0]);
+                       CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1, &flash_info[0]);
 
 #ifdef CONFIG_ENV_ADDR_REDUND
        flash_protect ( FLAG_PROTECT_SET,
                        CONFIG_ENV_ADDR_REDUND,
-                       CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SIZE_REDUND - 1,
+                       CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
                        &flash_info[0]);
 #endif
 
index a8dfca82461752e0f0adb61f1b2cb6f81ba50f3b..20908021cdbfb0a77bdf1963ac988402c3388087 100644 (file)
@@ -111,13 +111,13 @@ unsigned long flash_init (void)
 #ifdef CONFIG_ENV_ADDR
        flash_protect ( FLAG_PROTECT_SET,
                        CONFIG_ENV_ADDR,
-                       CONFIG_ENV_ADDR + CONFIG_ENV_SIZE - 1, &flash_info[0]);
+                       CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1, &flash_info[0]);
 #endif
 
 #ifdef CONFIG_ENV_ADDR_REDUND
        flash_protect ( FLAG_PROTECT_SET,
                        CONFIG_ENV_ADDR_REDUND,
-                       CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SIZE_REDUND - 1,
+                       CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
                        &flash_info[0]);
 #endif
 
index df9696e69a39cc8d6aed6ea6d209e093f00ab0bc..51d66d517e9608b0208a8714aefea710c5a2cba8 100644 (file)
@@ -136,7 +136,7 @@ int misc_init_r (void)
                /* Redundant environment protection ON by default */
                flash_protect (FLAG_PROTECT_SET,
                               CONFIG_ENV_ADDR_REDUND,
-                              CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SIZE_REDUND - 1,
+                              CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
                               &flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]);
        }
 
index a70fd2694cf71bbdcae5c81b9c1696ae3cc27662..ab0e0dd883817af20f45c274fef5c5b503c56055 100644 (file)
@@ -328,7 +328,7 @@ int misc_init_r (void)
        /* Redundant environment protection ON by default */
        flash_protect (FLAG_PROTECT_SET,
                       CONFIG_ENV_ADDR_REDUND,
-                      CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SIZE_REDUND - 1,
+                      CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
                       &flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]);
 #endif
 
index 2bbb70b76dba75bdaa04cff122d3e5702c43e764..4e89c4102728fae360049346aac63acfa1c946ce 100644 (file)
@@ -108,12 +108,12 @@ ulong flash_init (void)
 
        flash_protect ( FLAG_PROTECT_SET,
                        CONFIG_ENV_ADDR,
-                       CONFIG_ENV_ADDR + CONFIG_ENV_SIZE - 1, &flash_info[0]);
+                       CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1, &flash_info[0]);
 
 #ifdef CONFIG_ENV_ADDR_REDUND
        flash_protect ( FLAG_PROTECT_SET,
                        CONFIG_ENV_ADDR_REDUND,
-                       CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SIZE_REDUND - 1,
+                       CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
                        &flash_info[0]);
 #endif
 
index 175d82a792043fe7ea662bc7b81649499541afe8..d0732f53fa002f7c7cb838013b31d9e3dbd1d472 100644 (file)
@@ -2098,7 +2098,7 @@ unsigned long flash_init (void)
 #ifdef CONFIG_ENV_ADDR_REDUND
        flash_protect (FLAG_PROTECT_SET,
                       CONFIG_ENV_ADDR_REDUND,
-                      CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SIZE_REDUND - 1,
+                      CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
                       flash_get_info(CONFIG_ENV_ADDR_REDUND));
 #endif