summaryrefslogtreecommitdiff
path: root/chip/lm4/flash.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-05-16 13:58:57 -0700
committerChromeBot <chrome-bot@google.com>2013-05-17 09:52:28 -0700
commit6ff01d910a17900c58179809d49f30f921e72d8c (patch)
treecd4d788700beabae487d6bdcb2837dd9320cb1b4 /chip/lm4/flash.c
parent4b89cc6bafba2ea5b40b681bf9a9d56a86795078 (diff)
downloadchrome-ec-6ff01d910a17900c58179809d49f30f921e72d8c.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>
Diffstat (limited to 'chip/lm4/flash.c')
-rw-r--r--chip/lm4/flash.c9
1 files changed, 7 insertions, 2 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;
}
}