summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShamile Khan <shamile.khan@intel.com>2016-03-23 16:02:59 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-03-25 18:51:44 -0700
commitef561a293f1641750bba635a9af4f380a9dfd32e (patch)
tree01ff621285b4b7252e0753913e874bfb046bd728
parenta76eb92cc2e92fdb5c91570b264241e51a72ab42 (diff)
downloadchrome-ec-ef561a293f1641750bba635a9af4f380a9dfd32e.tar.gz
spi_flash: Reload watchdog before writing a flash page
When EC receives many flash write requests from host and PDCMD, CHARGE and USB_CHG_P0 tasks are all ready to run, the HOOK task may not get scheduled in time to pet the watchdog resulting in an EC reset. BUG=chrome-os-partner:51438 BRANCH=None TEST=Manual on lars, determine two EC versions that have enough differences so that replacing one image with the other will require all or most of the flash pages to be updated. Alternate between flashing the two images with flashrom using a script. Atleast 1000 iterations should pass. Change-Id: I8b5c8b680a2935b945f3740e371dee2d218ec4c5 Signed-off-by: Shamile Khan <shamile.khan@intel.com> Reviewed-on: https://chromium-review.googlesource.com/334457 Reviewed-by: Stefan Reinauer <reinauer@google.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> (cherry picked from commit a537d1ac44c40e7f6e1131e8cc852b030ccdba52) Reviewed-on: https://chromium-review.googlesource.com/334903 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--common/spi_flash.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/common/spi_flash.c b/common/spi_flash.c
index 41138c5362..c19253f518 100644
--- a/common/spi_flash.c
+++ b/common/spi_flash.c
@@ -272,6 +272,7 @@ int spi_flash_write(unsigned int offset, unsigned int bytes,
return EC_ERROR_INVAL;
while (bytes > 0) {
+ watchdog_reload();
/* Write length can not go beyond the end of the flash page */
write_size = MIN(bytes, SPI_FLASH_MAX_WRITE_SIZE -
(offset & (SPI_FLASH_MAX_WRITE_SIZE - 1)));
@@ -540,8 +541,6 @@ static int command_spi_flashwrite(int argc, char **argv)
ccprintf("Writing %d bytes to 0x%x...\n", bytes, offset);
while (bytes > 0) {
- watchdog_reload();
-
/* First write multiples of 256, then (bytes % 256) last */
write_len = ((bytes % SPI_FLASH_MAX_WRITE_SIZE) == bytes) ?
bytes : SPI_FLASH_MAX_WRITE_SIZE;