summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-05-16 13:58:57 -0700
committerKatie Roberts-Hoffman <katierh@chromium.org>2013-05-22 16:21:49 -0700
commit645f8119b920d76dfa1923477de827cdfb36cfbd (patch)
tree8eca4c20d7132a55901f7103191aaa6dfc1894d7
parent1a6a26811c7de5e70c53f5d4fe9bcf610594fc90 (diff)
downloadchrome-ec-645f8119b920d76dfa1923477de827cdfb36cfbd.tar.gz
Fix detecting inconsistent flash state
If the last bank of flash in a region was protected and the rest of the region was unprotected, flash_get_protect() shoud return the INCONSISTENT flag, but this wasn't being properly detected. Port the existing fix from STM32F. BUG=chrome-os-partner:19529 BRANCH=none (not likely worth porting to link) TEST=protect just the last bank of RW firmware, then flashinfo > flashinfo Physical: 128 KB Usable: 128 KB Write: 64 B Erase: 256 B Protect: 4096 B Flags: all_now INCONSISTENT Protected now: ........ ........ ........ .......Y Should have the inconsistent flag set. Change-Id: I407737cef42748da6b3ec40d84968c76ee07972c Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/51498 Reviewed-by: Bill Richardson <wfrichar@chromium.org> (cherry picked from commit 6ff01d910a17900c58179809d49f30f921e72d8c) Reviewed-on: https://gerrit.chromium.org/gerrit/56320 Commit-Queue: Katie Roberts-Hoffman <katierh@chromium.org> Reviewed-by: Katie Roberts-Hoffman <katierh@chromium.org> Tested-by: Katie Roberts-Hoffman <katierh@chromium.org>
-rw-r--r--chip/lm4/flash.c9
-rw-r--r--chip/stm32/flash-stm32l15x.c9
2 files changed, 14 insertions, 4 deletions
diff --git a/chip/lm4/flash.c b/chip/lm4/flash.c
index 7fc59e1ecb..3351fd851e 100644
--- a/chip/lm4/flash.c
+++ b/chip/lm4/flash.c
@@ -295,6 +295,7 @@ uint32_t flash_get_protect(void)
{
struct persist_state pstate;
uint32_t flags = 0;
+ int not_protected[2] = {0};
int i;
/* Read all-protected state from our shadow copy */
@@ -324,9 +325,13 @@ uint32_t flash_get_protect(void)
if (flash_physical_get_protect(i)) {
/* At least one bank in the region is protected */
flags |= bank_flag;
- } else if (flags & bank_flag) {
+ if (not_protected[is_ro])
+ flags |= EC_FLASH_PROTECT_ERROR_INCONSISTENT;
+ } else {
/* But not all banks in the region! */
- flags |= EC_FLASH_PROTECT_ERROR_INCONSISTENT;
+ not_protected[is_ro] = 1;
+ if (flags & bank_flag)
+ flags |= EC_FLASH_PROTECT_ERROR_INCONSISTENT;
}
}
diff --git a/chip/stm32/flash-stm32l15x.c b/chip/stm32/flash-stm32l15x.c
index 046c106820..811ee3a125 100644
--- a/chip/stm32/flash-stm32l15x.c
+++ b/chip/stm32/flash-stm32l15x.c
@@ -306,6 +306,7 @@ void flash_physical_set_protect(int start_bank, int bank_count)
uint32_t flash_get_protect(void)
{
uint32_t flags = 0;
+ int not_protected[2] = {0};
int i;
/*
@@ -328,9 +329,13 @@ uint32_t flash_get_protect(void)
if (flash_physical_get_protect(i)) {
/* At least one bank in the region is protected */
flags |= bank_flag;
- } else if (flags & bank_flag) {
+ if (not_protected[is_ro])
+ flags |= EC_FLASH_PROTECT_ERROR_INCONSISTENT;
+ } else {
/* But not all banks in the region! */
- flags |= EC_FLASH_PROTECT_ERROR_INCONSISTENT;
+ not_protected[is_ro] = 1;
+ if (flags & bank_flag)
+ flags |= EC_FLASH_PROTECT_ERROR_INCONSISTENT;
}
}