Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion inc/stm32_flash.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@
#define STM32_FLASH_Gx_CR_PNB (3) /* Page number */
#define STM32_FLASH_G0_CR_PNG_LEN (5) /* STM32G0: 5 page number bits */
#define STM32_FLASH_G4_CR_PNG_LEN (7) /* STM32G4: 7 page number bits */
#define STM32_FLASH_Gx_CR_BKER (13) /* Bank selection for erase operation */
#define STM32_FLASH_G0_CR_BKER (13) /* Bank selection for erase operation on G0*/
#define STM32_FLASH_G4_CR_BKER (11) /* Bank selection for erase operation on G4*/
#define STM32_FLASH_Gx_CR_MER2 (15) /* Mass erase (2nd bank)*/
#define STM32_FLASH_Gx_CR_STRT (16) /* Start */
#define STM32_FLASH_Gx_CR_OPTSTRT (17) /* Start of modification of option bytes */
Expand Down
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
Loading