summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2015-10-16 15:38:43 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-10-17 08:18:46 -0700
commit92e350197aae867bebd3c017ca678d11c9a64162 (patch)
tree4eb9ee7cbb43faa8e18a94c6eddbdbd8570acf88
parent784e0b1b472772080aaa975e0b7b415d78ab8ef1 (diff)
downloadchrome-ec-92e350197aae867bebd3c017ca678d11c9a64162.tar.gz
Cr50: enable modificaton of flash bank 1
Security settings prevent flash updates by default. This allows erase and writes to flash bank 1 (0x80000 - 0xbffff). Note that this doesn't allow for execution of any code you might put there. That requires additional steps which are not part of this CL. BUG=chrome-os-partner:44745 BRANCH=none TEST=manual Pick an unused section of flash and use the flasherase and flashwrite commands to test it. The flashwrite command fills a buffer with bytes, counting up (0x00, 0x01, 0x02, 0x03, ...), then writes that buffer to the address given. Note that the "md" command uses the absolute address, while the flash commands use the offset address within the flash memory. For example: > md 0xbb000 16 000BB000: ffffffff ffffffff ffffffff ffffffff 000BB010: ffffffff ffffffff ffffffff ffffffff 000BB020: ffffffff ffffffff ffffffff ffffffff 000BB030: ffffffff ffffffff ffffffff ffffffff > flasherase 0x7b000 0x800 Erasing 2048 bytes at 0x7b000... > md 0xbb000 16 000BB000: ffffffff ffffffff ffffffff ffffffff 000BB010: ffffffff ffffffff ffffffff ffffffff 000BB020: ffffffff ffffffff ffffffff ffffffff 000BB030: ffffffff ffffffff ffffffff ffffffff > flashwrite 0x7b000 0x800 Writing 2048 bytes to 0x7b000... > md 0xbb000 16 000BB000: 03020100 07060504 0b0a0908 0f0e0d0c 000BB010: 13121110 17161514 1b1a1918 1f1e1d1c 000BB020: 23222120 27262524 2b2a2928 2f2e2d2c 000BB030: 33323130 37363534 3b3a3938 3f3e3d3c > md .b 0xbb000 16 000BB000: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f > Change-Id: Ia9fb6415bcc65ab92cab8132d8cf615215804a6d Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/306687 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
-rw-r--r--chip/g/flash.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/chip/g/flash.c b/chip/g/flash.c
index 22376d5fbe..04074cc3b5 100644
--- a/chip/g/flash.c
+++ b/chip/g/flash.c
@@ -45,6 +45,16 @@
int flash_pre_init(void)
{
+ /* Enable access to the upper half of the flash */
+ uint32_t half = CONFIG_FLASH_SIZE / 2;
+
+ GWRITE(GLOBALSEC, FLASH_REGION2_BASE_ADDR,
+ CONFIG_MAPPED_STORAGE_BASE + half);
+ GWRITE(GLOBALSEC, FLASH_REGION2_SIZE, half - 1);
+ GWRITE_FIELD(GLOBALSEC, FLASH_REGION2_CTRL, WR_EN, 1);
+ GWRITE_FIELD(GLOBALSEC, FLASH_REGION2_CTRL, RD_EN, 1);
+ GWRITE_FIELD(GLOBALSEC, FLASH_REGION2_CTRL, EN, 1);
+
return EC_SUCCESS;
}