summaryrefslogtreecommitdiff
path: root/include/flash.h
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-05-17 13:12:01 -0700
committerChromeBot <chrome-bot@google.com>2013-05-22 19:15:56 -0700
commite8ecda5e8d0384ddc8fe6b3bd9e991ee6d84faae (patch)
tree402184e035d6e792ccfa41fbdf4caf9b9c8abece /include/flash.h
parent6592036c6c6b24744ac3bb1450ee41f0c7630b10 (diff)
downloadchrome-ec-e8ecda5e8d0384ddc8fe6b3bd9e991ee6d84faae.tar.gz
Support flash write protect on STM32L
This adds support for write protecting the RO code at boot, and the entire flash on demand. Implementation if WP# is not asserted is currently a little different than STM32F and LM4; RO is still protected at boot if ro_at_boot, but can be unprotected and the change will commit on the next reboot. This saves the bank of flash which we use for pstate on LM4 and STM32F. I think I can use one of the unused option bits (WRP2 bit 0) to hold the RO-at-boot flag, in which case I can more closely match the behavior of the other chips, but I'd like to do that (or give up and implement pstate) in a separate CL so it's clearer what I'm doing. BUG=chrome-os-partner:15613 BRANCH=none TEST=manual - flashinfo -> (no flags) - enable WP (via screw or dut-control) - flashinfo -> wp_gpio_asserted - flashwp enable - flashinfo -> wp_gpio_asserted ro_at_boot - flashwp now - flashinfo -> wp_gpio_asserted ro_at_boot all_now - flashwp disable -> fails - flashinfo -> wp_gpio_asserted ro_at_boot all_now - flasherase 0x1fc00 0x400 -> fails - reboot - flashinfo -> wp_gpio_asserted ro_at_boot ro_now - flasherase 0xfc00 0x400 -> fails - flasherase 0x1fc00 0x400 -> succeeds - disable WP (via screw or dut-control) - reboot - flashinfo -> ro_at_boot ro_now - flashwp disable - flashinfo -> ro_now - reboot - flashinfo -> (no flags) - flasherase 0xfc00 0x400 -> succeeds - flasherase 0x1fc00 0x400 -> succeeds Change-Id: Id1b6b099a44a1985a5ab9387feb882a8f26e3aa1 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/55594
Diffstat (limited to 'include/flash.h')
-rw-r--r--include/flash.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/flash.h b/include/flash.h
index 9a9454bf52..fe592e3478 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -70,6 +70,17 @@ int flash_physical_erase(int offset, int size);
*/
int flash_physical_get_protect(int bank);
+/**
+ * Force reload of flash protection bits.
+ *
+ * Some EC architectures (STM32L) only load the bits from option bytes at
+ * power-on reset or via a special command. This issues that command if
+ * possible, which triggers a power-on reboot.
+ *
+ * Only returns (with EC_ERROR_ACCESS_DENIED) if the command is locked.
+ */
+int flash_physical_force_reload(void);
+
/*****************************************************************************/
/* High-level interface for use by other modules. */