summaryrefslogtreecommitdiff
path: root/chip/stm32/registers.h
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@google.com>2017-07-07 09:03:28 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-07-07 02:40:03 -0700
commit241e7e3a01f36b41b9a4e5ba60ad77173f96890c (patch)
treea5305268b14a74fc46a7e871dc434c73d6d0f0ca /chip/stm32/registers.h
parentbdd39d51a30a43516f1712b01c66cad26b37826f (diff)
downloadchrome-ec-241e7e3a01f36b41b9a4e5ba60ad77173f96890c.tar.gz
chip/stm32/flash-f: Clear option byte write enable/erase operation when done
Before 72afc55bd9d3 "stm32: cleanup flash-f by using constant from register.h" lock() function would simply do: STM32_FLASH_CR = FLASH_CR_LOCK; which would clear all other bits in STM32_FLASH_CR, including FLASH_CR_OPTER and FLASH_CR_OPTWRE. This allow preserve_optb to work, as it does: 1. erase_optb a. unlock() b. Set FLASH_CR_OPTER c. lock() (clears FLASH_CR_OPTER!) 2. write_optb a. unlock() b. Set FLASH_CR_OPTPG c. Write option byte d. Clear FLASH_CR_OPTPG e. lock() After the patch, we now have: STM32_FLASH_CR |= FLASH_CR_LOCK; which seems more correct. However, 1.c. does not clear FLASH_CR_OPTER, and 2.b. ends up with both FLASH_CR_OPTPG and FLASH_CR_OPTER set, and the programming operation does not do anything. This patches does 3 things: - Rename FLASH_CR_OPTSTRT to FLASH_CR_OPTER, as that's the correct register name for STM32F0 and STM32F3. - Fix the above by clearing FLASH_CR_OPTER in erase_optb - Also clear FLASH_CR_OPTWRE in lock(). Not strictly necessary, but this seems to be the right thing to do. BRANCH=none BUG=chromium:739608 TEST=On hammer, type flashwp true; reboot; flashwp all; reboot flashinfo => All flash is protected Change-Id: Ic276545ae3c0bdb685c7b117a7f896ec341731bb Reviewed-on: https://chromium-review.googlesource.com/562839 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'chip/stm32/registers.h')
-rw-r--r--chip/stm32/registers.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/chip/stm32/registers.h b/chip/stm32/registers.h
index b8035620f0..03a2c3be00 100644
--- a/chip/stm32/registers.h
+++ b/chip/stm32/registers.h
@@ -1342,7 +1342,7 @@ typedef volatile struct stm32_spi_regs stm32_spi_regs_t;
#define FLASH_CR_PG (1 << 0)
#define FLASH_CR_PER (1 << 1)
#define FLASH_CR_OPTPG (1 << 4)
-#define FLASH_CR_OPTSTRT (1 << 5)
+#define FLASH_CR_OPTER (1 << 5)
#define FLASH_CR_STRT (1 << 6)
#define FLASH_CR_LOCK (1 << 7)
#define FLASH_CR_OPTWRE (1 << 9)