From: Wolfgang Denk Date: Thu, 14 May 2009 22:16:03 +0000 (+0200) Subject: Redundant Environment: protect full sector size X-Git-Tag: v2009.06-rc3~17 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=dfcd7f21607fd847236b04bb1a8d59a7c10ab99c;p=oweals%2Fu-boot.git Redundant Environment: protect full sector size 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 Cc: Paul Ruhland Cc: Pantelis Antoniou Cc: Stefan Roese Cc: Gary Jennejohn Cc: Dave Ellis Acked-by: Stefan Roese --- diff --git a/board/lpd7a40x/flash.c b/board/lpd7a40x/flash.c index a13b827fb2..a3ba75b893 100644 --- a/board/lpd7a40x/flash.c +++ b/board/lpd7a40x/flash.c @@ -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 diff --git a/board/mcc200/mcc200.c b/board/mcc200/mcc200.c index 14cf08da3f..9fa1d3ae75 100644 --- a/board/mcc200/mcc200.c +++ b/board/mcc200/mcc200.c @@ -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]); } diff --git a/board/netphone/flash.c b/board/netphone/flash.c index 8852127e61..349d98e738 100644 --- a/board/netphone/flash.c +++ b/board/netphone/flash.c @@ -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 diff --git a/board/netta/flash.c b/board/netta/flash.c index 45e6b30102..565fd67c6e 100644 --- a/board/netta/flash.c +++ b/board/netta/flash.c @@ -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 diff --git a/board/netta2/flash.c b/board/netta2/flash.c index b63f459519..53a4e1eb20 100644 --- a/board/netta2/flash.c +++ b/board/netta2/flash.c @@ -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 diff --git a/board/netvia/flash.c b/board/netvia/flash.c index 98479a50b8..b9874347b9 100644 --- a/board/netvia/flash.c +++ b/board/netvia/flash.c @@ -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 diff --git a/board/pleb2/flash.c b/board/pleb2/flash.c index abaf0b4d24..a8897dcffe 100644 --- a/board/pleb2/flash.c +++ b/board/pleb2/flash.c @@ -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 diff --git a/board/prodrive/pdnb3/flash.c b/board/prodrive/pdnb3/flash.c index 351aed1e11..fe8d100083 100644 --- a/board/prodrive/pdnb3/flash.c +++ b/board/prodrive/pdnb3/flash.c @@ -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; diff --git a/board/rmu/flash.c b/board/rmu/flash.c index a3ab851d2c..283b19d045 100644 --- a/board/rmu/flash.c +++ b/board/rmu/flash.c @@ -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 diff --git a/board/samsung/smdk2400/flash.c b/board/samsung/smdk2400/flash.c index 46b5786fe6..fb69c21a45 100644 --- a/board/samsung/smdk2400/flash.c +++ b/board/samsung/smdk2400/flash.c @@ -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 diff --git a/board/sixnet/flash.c b/board/sixnet/flash.c index a8dfca8246..20908021cd 100644 --- a/board/sixnet/flash.c +++ b/board/sixnet/flash.c @@ -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 diff --git a/board/socrates/socrates.c b/board/socrates/socrates.c index df9696e69a..51d66d517e 100644 --- a/board/socrates/socrates.c +++ b/board/socrates/socrates.c @@ -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]); } diff --git a/board/tqc/tqm85xx/tqm85xx.c b/board/tqc/tqm85xx/tqm85xx.c index a70fd2694c..ab0e0dd883 100644 --- a/board/tqc/tqm85xx/tqm85xx.c +++ b/board/tqc/tqm85xx/tqm85xx.c @@ -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 diff --git a/board/trab/flash.c b/board/trab/flash.c index 2bbb70b76d..4e89c41027 100644 --- a/board/trab/flash.c +++ b/board/trab/flash.c @@ -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 diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c index 175d82a792..d0732f53fa 100644 --- a/drivers/mtd/cfi_flash.c +++ b/drivers/mtd/cfi_flash.c @@ -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