diff options
author | Vic Yang <victoryang@chromium.org> | 2014-10-09 15:19:22 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-10-15 23:55:55 +0000 |
commit | 82915c25029c0bc2c018cfc080d913255ed82aac (patch) | |
tree | 1da32cff8e9e01142b63960fd454ff2b1832278a /chip/stm32/flash-stm32l.c | |
parent | 5ff320f66e990a5efe8270f6125ed7c55699d50c (diff) | |
download | chrome-ec-82915c25029c0bc2c018cfc080d913255ed82aac.tar.gz |
Write protect support for STM32F0
On STM32F0, we cannot work around the hard fault triggered when trying
to protect the whole flash. Therefore, we need to go with the
ALL_AT_BOOT approach. When write protect is enabled, instead of setting
ALL_NOW flag to immediately lock down the entire flash, we need to set
ALL_AT_BOOT and then reboot to have the protection take effect.
BUG=chrome-os-partner:32745
TEST=Along with the next CL. On Ryu:
1. Enable HW WP. Check the output of 'ectool flashprotect' and see
correct flags.
2. 'flashrom -p ec --wp-range 0 0x10000'. Check RO_AT_BOOT is set.
3. Reboot EC and check RO_NOW is enabled.
4. Boot the system and check ALL_NOW is set.
5. Update BIOS and reboot. Check software sync updates EC-RW.
6. 'flashrom -p ec --wp-disable' and check it fails.
7. Disable HW WP and reboot EC. Check RO_NOW and ALL_NOW are cleared.
8. 'flashrom -p ec --wp-disable' and check RO_AT_BOOT is cleared.
TEST=Enable/disable WP on Spring. Check RO_AT_BOOT/ALL_NOW can be set
properly.
BRANCH=samus
Change-Id: I1c7c4f98f2535f1c8a1c7daaa88d47412d015977
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222622
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'chip/stm32/flash-stm32l.c')
-rw-r--r-- | chip/stm32/flash-stm32l.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/chip/stm32/flash-stm32l.c b/chip/stm32/flash-stm32l.c index 90ed1a9d55..98f46565a3 100644 --- a/chip/stm32/flash-stm32l.c +++ b/chip/stm32/flash-stm32l.c @@ -422,7 +422,7 @@ int flash_pre_init(void) * update to the write protect register and reboot so * it takes effect. */ - flash_protect_ro_at_boot(1); + flash_protect_at_boot(FLASH_WP_RO); need_reset = 1; } @@ -431,8 +431,9 @@ int flash_pre_init(void) * Write protect register was in an inconsistent state. * Set it back to a good state and reboot. */ - flash_protect_ro_at_boot( - prot_flags & EC_FLASH_PROTECT_RO_AT_BOOT); + flash_protect_at_boot( + (prot_flags & EC_FLASH_PROTECT_RO_AT_BOOT) ? + FLASH_WP_RO : FLASH_WP_NONE); need_reset = 1; } } else if (prot_flags & (EC_FLASH_PROTECT_RO_NOW | |