diff options
author | Vadzim Dambrouski <pftbest@gmail.com> | 2015-10-23 21:14:07 +0300 |
---|---|---|
committer | Albert ARIBAUD <albert.u.boot@aribaud.net> | 2015-11-10 16:48:50 +0100 |
commit | 43fb0e3926dc52d4618d172a388cb6750311193d (patch) | |
tree | f1874da7ef425b0b703e79c748b0d76cf9799aab /arch/arm/cpu | |
parent | 4cd3246f2a3a3a5032edcaed3cf807dd916f0aea (diff) | |
download | u-boot-imx-43fb0e3926dc52d4618d172a388cb6750311193d.zip u-boot-imx-43fb0e3926dc52d4618d172a388cb6750311193d.tar.gz u-boot-imx-43fb0e3926dc52d4618d172a388cb6750311193d.tar.bz2 |
arm: stm32f4: fix a bug when a random sector gets erased
Old sector number is not being cleared from FLASH_CR register. For example
when first erased sector was 001 and then you want to erase sector 010,
sector 011 gets erased instead.
This patch clears old sector number from FLASH_CR register before a new
one is written.
Signed-off-by: Vadzim Dambrouski <pftbest@gmail.com>
Diffstat (limited to 'arch/arm/cpu')
-rw-r--r-- | arch/arm/cpu/armv7m/stm32f4/flash.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/arm/cpu/armv7m/stm32f4/flash.c b/arch/arm/cpu/armv7m/stm32f4/flash.c index ae63790..dd058bd 100644 --- a/arch/arm/cpu/armv7m/stm32f4/flash.c +++ b/arch/arm/cpu/armv7m/stm32f4/flash.c @@ -97,6 +97,9 @@ int flash_erase(flash_info_t *info, int first, int last) while (readl(&STM32_FLASH->sr) & STM32_FLASH_SR_BSY) ; + /* clear old sector number before writing a new one */ + clrbits_le32(&STM32_FLASH->cr, STM32_FLASH_CR_SNB_MASK); + if (bank == 0) { setbits_le32(&STM32_FLASH->cr, (i << STM32_FLASH_CR_SNB_OFFSET)); |