kopia lustrzana https://github.com/stlink-org/stlink
Merge pull request #1457 from Gnarflord/testing
[feature] STM32G4: Erase pages on flash bank 2pull/1466/head
commit
b149e2448e
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue