diff options
author | Louis Yung-Chieh Lo <yjlou@chromium.org> | 2012-07-13 12:50:27 +0800 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-07-18 00:56:45 -0700 |
commit | 9c289eda9f4fc9d14ea334cf57bc94f789c890e9 (patch) | |
tree | 40c7453e755cf2c7637d17a326c09e9f26145a2e /common/flash_common.c | |
parent | 73b042f3dce25f471003a459b72ba727b0d90181 (diff) | |
download | chrome-ec-9c289eda9f4fc9d14ea334cf57bc94f789c890e9.tar.gz |
Enable Lucas EC WP again.
Uncomment back the old code and fix the bug of WRP bit definition and
also write_opt().
Note that to make this functional, wp_pin_asserted() always returns true.
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Change-Id: Ic09d3346ca68a2700697ff863f0fa08525129b11
BUG=chrome-os-partner:9849
TEST=run on lucas.
> flashwp set 0 0x1f000
> flashwp lock
> flashinfo # ensure the setting is right.
stm32mon -r to read the firmware.
stm32mon -w to write a different image.
stm32mon -r to read again and compare the firmware is non-changed.
> flashwp unlock
Command returned error 1
stm32mon -u to unlock write protection.
Reviewed-on: https://gerrit.chromium.org/gerrit/27503
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Tested-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Diffstat (limited to 'common/flash_common.c')
-rw-r--r-- | common/flash_common.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/common/flash_common.c b/common/flash_common.c index 184f5a79bb..e7467954f4 100644 --- a/common/flash_common.c +++ b/common/flash_common.c @@ -31,7 +31,11 @@ static int wp_pin_asserted(void) { #ifdef CHIP_stm32 /* TODO (vpalatin) : write protect scheme for stm32 */ - return 0; /* always disable write protect */ + return 1; /* Always enable write protect until we have WP pin. + * For developer to unlock WP, please use stm32mon -u and + * immediately re-program the pstate sector (so that + * apply_pstate() has no chance to run). + */ #else return gpio_get_level(GPIO_WRITE_PROTECT); #endif @@ -41,7 +45,6 @@ static int wp_pin_asserted(void) /* Read persistent state into pstate. */ static int read_pstate(void) { -#ifndef CHIP_stm32 int i; int rv = flash_physical_read(usable_flash_size, sizeof(pstate), (char *)&pstate); @@ -58,7 +61,6 @@ static int read_pstate(void) pstate.lock &= FLASH_PROTECT_LOCK_SET; for (i = 0; i < MAX_BANKS; i++) pstate.blocks[i] &= FLASH_PROTECT_PERSISTENT; -#endif /* CHIP_stm32 */ return EC_SUCCESS; } @@ -66,7 +68,6 @@ static int read_pstate(void) /* Write persistent state from pstate, erasing if necessary. */ static int write_pstate(void) { -#ifndef CHIP_stm32 int rv; /* Erase top protection block. Assumes pstate size is less than @@ -86,9 +87,6 @@ static int write_pstate(void) /* Rewrite the data */ return flash_physical_write(usable_flash_size, sizeof(pstate), (const char *)&pstate); -#else - return EC_SUCCESS; -#endif /* CHIP_stm32 */ } @@ -354,17 +352,12 @@ int flash_pre_init(void) */ flash_physical_pre_init(); -#ifdef CHIP_stm32 - usable_flash_size = flash_physical_size(); -#else /* * Calculate usable flash size. Reserve one protection block * at the top to hold the "pretend SPI" write protect data. */ usable_flash_size = flash_physical_size() - flash_get_protect_block_size(); -#endif - /* Apply write protect to blocks if needed */ return apply_pstate(); |