src/flash/nor/stm32f2x.c: Really erase second bank if requested.

Taken from git://git.ac6.fr/openocd commit e8ed67c42227b7072

Change-Id: Ic7f529aecd1603b8c083c3c9ce96a0f13dd604e0
Signed-off-by: Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Reviewed-on: http://openocd.zylin.com/3374
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
This commit is contained in:
Uwe Bonnes 2016-03-02 13:17:04 +01:00 committed by Freddie Chopin
parent 934ed07b0d
commit 0a432e42aa
1 changed files with 5 additions and 3 deletions

View File

@ -1114,6 +1114,7 @@ COMMAND_HANDLER(stm32x_handle_unlock_command)
static int stm32x_mass_erase(struct flash_bank *bank)
{
int retval;
uint32_t flash_mer;
struct target *target = bank->target;
struct stm32x_flash_bank *stm32x_info = NULL;
@ -1130,13 +1131,14 @@ static int stm32x_mass_erase(struct flash_bank *bank)
/* mass erase flash memory */
if (stm32x_info->has_large_mem)
retval = target_write_u32(target, stm32x_get_flash_reg(bank, STM32_FLASH_CR), FLASH_MER | FLASH_MER1);
flash_mer = FLASH_MER | FLASH_MER1;
else
retval = target_write_u32(target, stm32x_get_flash_reg(bank, STM32_FLASH_CR), FLASH_MER);
flash_mer = FLASH_MER;
retval = target_write_u32(target, stm32x_get_flash_reg(bank, STM32_FLASH_CR), flash_mer);
if (retval != ERROR_OK)
return retval;
retval = target_write_u32(target, stm32x_get_flash_reg(bank, STM32_FLASH_CR),
FLASH_MER | FLASH_STRT);
flash_mer | FLASH_STRT);
if (retval != ERROR_OK)
return retval;