Skip to content

Commit

Permalink
wip: set correct BKER bit when erasing bank 2 on G4
Browse files Browse the repository at this point in the history
  • Loading branch information
Gnarflord authored Mar 3, 2025
1 parent 44ae84a commit 3d9378f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/stlink-lib/common_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1130,9 +1130,9 @@ int32_t stlink_erase_flash_page(stlink_t *sl, stm32_addr_t flashaddr) {
// In this case we need to specify which bank to erase (sec 3.7.5 - BKER)
if(sl->flash_size > (128 * 1024) &&
((flashaddr - STM32_FLASH_BASE) >= sl->flash_size / 2)) {
val |= (1 << STM32_FLASH_Gx_CR_BKER); // erase bank 2
val |= (1 << STM32_FLASH_G4_CR_BKER); // erase bank 2
} else {
val &= ~(1 << STM32_FLASH_Gx_CR_BKER); // erase bank 1
val &= ~(1 << STM32_FLASH_G4_CR_BKER); // erase bank 1
}
val |= ((flash_page & 0x7FF) << 3) | (1 << FLASH_CR_PER);
stlink_write_debug32(sl, STM32_FLASH_Gx_CR, val);
Expand Down

0 comments on commit 3d9378f

Please sign in to comment.