Nicolas Boichat 241e7e3a01 chip/stm32/flash-f: Clear option byte write enable/erase operation when done
Before
72afc55bd9 "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>
2017-07-07 02:40:03 -07:00
2017-06-28 21:50:51 -07:00
2017-06-28 21:50:50 -07:00
2012-05-11 09:11:52 -07:00
2014-04-02 19:58:53 +00:00
2015-12-08 20:05:05 -08:00

For an overview of the Embedded Controller firmware, refer to

http://www.chromium.org/chromium-os/2014-firmware-summit

For instructions on building from source, refer to

http://www.chromium.org/chromium-os/ec-development/getting-started-building-ec-images-quickly
Description
No description provided
Readme 1.4 GiB
Languages
C 64.7%
Lasso 20.7%
ASL 3.6%
JavaScript 3.2%
C# 2.9%
Other 4.6%