legacy: unlock flash before erasing (#146)

pull/150/head
Hadi 5 years ago committed by Pavol Rusnak
parent 61d4641810
commit 9ceb479abd

@ -37,10 +37,14 @@ void memory_protect(void) {
(FLASH_OPTCR == 0x0FFCCCED)) {
return; // already set up correctly - bail out
}
flash_unlock();
for (int i = FLASH_STORAGE_SECTOR_FIRST; i <= FLASH_STORAGE_SECTOR_LAST;
i++) {
flash_erase_sector(i, FLASH_CR_PROGRAM_X32);
}
flash_lock();
flash_unlock_option_bytes();
// Section 2.8.6 Flash option control register (FLASH_OPTCR)
// Bits 31:28 Reserved, must be kept cleared.

Loading…
Cancel
Save