2025-01-23 08:39 AM
Maybe someone has encountered such a problem: the first 4 pages of FLASH memory are not erased
Why are the first 4 pages not erased when the read protection bit is set?
If the protection bit is disabled, then the same pages are erased without problems.
Code snippet:
...
void FLASH_Page_erase(uint16_t Adress) {
if (READ_BIT(FLASH->CR, FLASH_CR_LOCK)) {
FLASH_Unlock();
}
SET_BIT(FLASH->CR, FLASH_CR_PER);
FLASH->AR = Adress;
SET_BIT(FLASH->CR, FLASH_CR_STRT);
while (READ_BIT(FLASH->SR, FLASH_SR_BSY));
while (READ_BIT(FLASH->SR, FLASH_SR_EOP) == 0);
CLEAR_BIT(FLASH->CR, FLASH_CR_PER);
FLASH_Lock();
}
for(uint8_t i = 0; i < 20; i++) {
FLASH_Page_erase(i);
}
...
2025-01-23 09:34 AM
Maybe your showed code is here ? Or flash write page protection bits is set .
2025-01-23 09:46 AM
>>Why are the first 4 pages not erased when the read protection bit is set?
To prevent your "secure" boot loader from being erased