summaryrefslogtreecommitdiff
path: root/chip/stm32/flash-f.c
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2015-01-06 16:04:43 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-01-08 00:38:17 +0000
commitcca794d2fec61133f09b6e1cc6816392f11e15cb (patch)
tree06cff81c910ae796f2859b9d78f3b656ae1d846a /chip/stm32/flash-f.c
parentdc1362ca82e72ac488bb25d308c97aaf733274fc (diff)
downloadchrome-ec-cca794d2fec61133f09b6e1cc6816392f11e15cb.tar.gz
pd: dingdong/hoho: Enable flash write-protection
These USB type-C accessories don't have a write-protect GPIO. Add a configure flag (CONFIG_WP_ALWAYS) to force the flash write-protection on the dongles. Also set the read protection (by elevating RDP to level 1), so trying to unprotect the flash will trigger a full erase. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=chrome-os-partner:35088 TEST=boot Hoho, check the flash OBR and WRPR registers: "rw 0x4002201c" / "rw 0x40022020" and the option bytes write-protect bits: "rw 0x1FFFF808" dump the logical state with "flashinfo" command. > rw 0x4002201c read 0x40022020 = 0xffff0002 > rw 0x40022020 read 0x40022020 = 0xffff0000 > rw 0x1FFFF808 read 0x1ffff808 = 0xff00ff00 > flashinfo Physical: 128 KB Usable: 128 KB Write: 2 B (ideal 2 B) Erase: 2048 B (to 1-bits) Protect: 4096 B Flags: wp_gpio_asserted ro_at_boot ro_now Protected now: YYYYYYYY YYYYYYYY ........ ........ Change-Id: I45bbc0bce40ecc174b6b8a1ebacf4f53d2fd372d Reviewed-on: https://chromium-review.googlesource.com/238893 Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org>
Diffstat (limited to 'chip/stm32/flash-f.c')
-rw-r--r--chip/stm32/flash-f.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/chip/stm32/flash-f.c b/chip/stm32/flash-f.c
index e457aea8ce..6f334b94a2 100644
--- a/chip/stm32/flash-f.c
+++ b/chip/stm32/flash-f.c
@@ -362,6 +362,14 @@ int flash_physical_protect_at_boot(enum flash_wp_range range)
if (original_val[i] != val[i])
write_optb(i * 2 + 8, val[i]);
+#ifdef CONFIG_WP_ALWAYS
+ /*
+ * Set a permanent protection by increasing RDP to level 1,
+ * trying to unprotected the flash will trigger a full erase.
+ */
+ write_optb(0, 0x11);
+#endif
+
return EC_SUCCESS;
}