diff options
author | Vic Yang <victoryang@chromium.org> | 2014-08-13 10:00:28 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-08-14 22:44:44 +0000 |
commit | 9262797ee6816e81b7523bcabfac5e30cf0c6226 (patch) | |
tree | 2f6095d3cce8fcc6a407a7faf7622631b292fc14 /chip/stm32/flash-stm32f.c | |
parent | c8fa85d0b4ccafc4243f62f073f21c883d574042 (diff) | |
download | chrome-ec-9262797ee6816e81b7523bcabfac5e30cf0c6226.tar.gz |
pd: Print warning before flash erase if on PD power
During flash erase operation, read is stalled and thus interrupt might
be serviced later. This can cause PD communication to fail and thus the
board reboots if there is no battery. Print a warning message in this
case.
BUG=chrome-os-partner:31127,chrome-os-partner:31207,chrome-os-partner:31362
TEST=Boot Ryu, on software sync, see warning message before board
reboots.
BRANCH=None
Change-Id: If327a4f533fd2dfa83f92531148bd52ace927e03
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212264
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'chip/stm32/flash-stm32f.c')
-rw-r--r-- | chip/stm32/flash-stm32f.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/chip/stm32/flash-stm32f.c b/chip/stm32/flash-stm32f.c index a49701740c..52220e4d23 100644 --- a/chip/stm32/flash-stm32f.c +++ b/chip/stm32/flash-stm32f.c @@ -5,6 +5,7 @@ /* Flash memory module for Chrome EC */ +#include "battery.h" #include "console.h" #include "flash.h" #include "hooks.h" @@ -281,6 +282,23 @@ int flash_physical_erase(int offset, int size) { int res = EC_SUCCESS; +#ifdef CONFIG_USB_PD_FLASH_ERASE_CHECK + /* + * During flash erase operation, read is stalled and thus interrupt + * might be serviced later. This can cause PD communication to fail. + * This is unlikely going to affect normal users as they have + * batteries. However, print a warning in the console for developers + * without a battery. + * + * TODO(crosbug.com/p/31362): Remove this when PD ping is disabled. + */ + if (battery_is_present() != BP_YES) { + ccprintf("WARNING: Performing flash erase while running on " + "USB PD power only!\n"); + cflush(); + } +#endif + if (unlock(PRG_LOCK) != EC_SUCCESS) return EC_ERROR_UNKNOWN; |