diff options
author | Randall Spangler <rspangler@chromium.org> | 2012-04-12 09:41:35 -0700 |
---|---|---|
committer | Randall Spangler <rspangler@chromium.org> | 2012-04-12 09:41:35 -0700 |
commit | 20fdc57a351998f4a43731249f57bb262d610f72 (patch) | |
tree | 7f7838776505a874ece04172900460b81e290d00 /chip/lm4/flash.c | |
parent | e581c9e4caa2d6a5190a4542e8f8541f2eeb9d9a (diff) | |
download | chrome-ec-20fdc57a351998f4a43731249f57bb262d610f72.tar.gz |
Reload watchdog timer during flash operations.
Signed-off-by: Randall Spangler <rspangler@chromium.org>
BUG=chrome-os-partner:8967
TEST=manual
While ssh'd into the device:
1) Create a test image:
Extracting to: /tmp/ecup
132+1 records in
132+1 records out
136132 bytes (136 kB) copied, 0.000550122 s, 247 MB/s
2) Force the EC into its RO image:
done.
3) Erase the A and B images, then reprogram them:
Erasing 163840 bytes at offset 81920...
done.
Reading 136132 bytes from /home/chronos/user/ecb.bin...
Writing to offset 81920...
done.
4) Repeat step 3 about 10 times while monitoring the EC debug console.
Commands should complete successfully all the time. (Note that during
the flashwrite, there's a ton of debug output; what you should NOT see
is something like this:
WATCHDOG PC=00002104 / LR=0000597f / pSP=200013a0
Change-Id: I2f1f05eb19abcd6e19c6364f6d4ac785cca6a4c6
Diffstat (limited to 'chip/lm4/flash.c')
-rw-r--r-- | chip/lm4/flash.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/chip/lm4/flash.c b/chip/lm4/flash.c index e05b62089b..da8039bb7d 100644 --- a/chip/lm4/flash.c +++ b/chip/lm4/flash.c @@ -6,9 +6,10 @@ /* Flash memory module for Chrome EC */ #include "flash.h" -#include "uart.h" #include "registers.h" +#include "uart.h" #include "util.h" +#include "watchdog.h" #define FLASH_WRITE_BYTES 4 #define FLASH_FWB_WORDS 32 @@ -71,6 +72,12 @@ static int write_buffer(void) /* Start write operation at page boundary */ LM4_FLASH_FMC2 = 0xa4420001; +#ifdef CONFIG_TASK_WATCHDOG + /* Reload the watchdog timer, so that writing a large amount of flash + * doesn't cause a watchdog reset. */ + watchdog_reload(); +#endif + /* Wait for write to complete */ /* TODO: timeout */ while (LM4_FLASH_FMC2 & 0x01) {} @@ -124,6 +131,13 @@ int flash_physical_erase(int offset, int size) LM4_FLASH_FMA = offset; for ( ; size > 0; size -= FLASH_ERASE_BYTES) { + +#ifdef CONFIG_TASK_WATCHDOG + /* Reload the watchdog timer, so that erasing many flash pages + * doesn't cause a watchdog reset. */ + watchdog_reload(); +#endif + /* Start erase */ LM4_FLASH_FMC = 0xa4420002; |