summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Schodet2015-12-21 11:11:01 +0100
committerNicolas Schodet2019-10-07 00:44:57 +0200
commit5b4e922da076f4d0b91a65dc62ac1fe547f92a1d (patch)
tree08519cac5619728024327b4b8e49f575cc3244b5
parentab62929a0a7e3dfd5f095c8182425829a8d1b2a6 (diff)
ucoo/hal/self_programming: fix second bank erase on STM32F4
-rw-r--r--ucoo/hal/self_programming/self_programming.stm32f4.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/ucoo/hal/self_programming/self_programming.stm32f4.cc b/ucoo/hal/self_programming/self_programming.stm32f4.cc
index 9d352ac..912eb15 100644
--- a/ucoo/hal/self_programming/self_programming.stm32f4.cc
+++ b/ucoo/hal/self_programming/self_programming.stm32f4.cc
@@ -35,7 +35,7 @@ static const uint32_t sector_addr[] = {
0x8010000,
// 128 KB.
0x8020000, 0x8040000, 0x8060000, 0x8080000, 0x80a0000, 0x80c0000,
- 0x80e0000, 0x8100000,
+ 0x80e0000,
// For two banks devices only:
// 16 KB
0x8100000, 0x8104000, 0x8108000, 0x810c000,
@@ -62,8 +62,9 @@ self_programming_erase (uint32_t addr, int count)
{
if (addr == sector_addr[sector])
{
+ int snb = sector >= 12 ? sector + 16 - 12 : sector;
flash_unlock ();
- flash_erase_sector (sector, FLASH_CR_PROGRAM_X32);
+ flash_erase_sector (snb, FLASH_CR_PROGRAM_X32);
flash_lock ();
int sector_size = sector_addr[sector + 1] - addr;
addr += sector_size;