]> git.sur5r.net Git - openocd/commitdiff
src/flash/nor/stm32f2x.c: Really erase second bank if requested.
authorUwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Wed, 2 Mar 2016 12:17:04 +0000 (13:17 +0100)
committerFreddie Chopin <freddie.chopin@gmail.com>
Wed, 4 May 2016 21:56:37 +0000 (22:56 +0100)
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>
src/flash/nor/stm32f2x.c

index 606c0a7960b298057aa18d82c525bfa74fc554c9..5fb2c7ea38b995e587c4b170fd6b78c3db57cd8b 100644 (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;