summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2018-04-04 17:39:36 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-04-05 15:20:43 -0700
commit75e0015cc16d287724ef353c5d7f50c1287db2cb (patch)
tree9bc1968d237d80499f6e7f4f9a403abc3b4c0b8c
parent96931840bcf4171a9c44e48d4645b3c7c227014b (diff)
downloadchrome-ec-75e0015cc16d287724ef353c5d7f50c1287db2cb.tar.gz
flash: Allow currently active regions to be modified
This patch allows chips which run code in RAM to erase or write regions even if they're active. BUG=b:77306460 BRANCH=none TEST=flashrom -p ec -w /tmp/ec.bin on Fizz Change-Id: Ib536b250dde78283513acb942507c67da0a6f622 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/997022 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--common/flash.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/common/flash.c b/common/flash.c
index d463aee244..6746f178ef 100644
--- a/common/flash.c
+++ b/common/flash.c
@@ -1165,8 +1165,10 @@ static int flash_command_write(struct host_cmd_handler_args *args)
if (p->size + sizeof(*p) > args->params_size)
return EC_RES_INVALID_PARAM;
+#ifdef CONFIG_INTERNAL_STORAGE
if (system_unsafe_to_overwrite(offset, p->size))
return EC_RES_ACCESS_DENIED;
+#endif
if (flash_write(offset, p->size, (const uint8_t *)(p + 1)))
return EC_RES_ERROR;
@@ -1204,8 +1206,10 @@ static int flash_command_erase(struct host_cmd_handler_args *args)
if (flash_get_protect() & EC_FLASH_PROTECT_ALL_NOW)
return EC_RES_ACCESS_DENIED;
+#ifdef CONFIG_INTERNAL_STORAGE
if (system_unsafe_to_overwrite(offset, p->size))
return EC_RES_ACCESS_DENIED;
+#endif
switch (cmd) {
case FLASH_ERASE_SECTOR: