From 0a432e42aa1f106a04935b239a6be43dabc9e389 Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Wed, 2 Mar 2016 13:17:04 +0100 Subject: [PATCH] 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 Reviewed-on: http://openocd.zylin.com/3374 Tested-by: jenkins Reviewed-by: Andreas Fritiofson --- src/flash/nor/stm32f2x.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/flash/nor/stm32f2x.c b/src/flash/nor/stm32f2x.c index 606c0a79..5fb2c7ea 100644 --- a/src/flash/nor/stm32f2x.c +++ b/src/flash/nor/stm32f2x.c @@ -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; -- 2.39.5