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)) { (FLASH_OPTCR == 0x0FFCCCED)) {
return; // already set up correctly - bail out return; // already set up correctly - bail out
} }
flash_unlock();
for (int i = FLASH_STORAGE_SECTOR_FIRST; i <= FLASH_STORAGE_SECTOR_LAST; for (int i = FLASH_STORAGE_SECTOR_FIRST; i <= FLASH_STORAGE_SECTOR_LAST;
i++) { i++) {
flash_erase_sector(i, FLASH_CR_PROGRAM_X32); flash_erase_sector(i, FLASH_CR_PROGRAM_X32);
} }
flash_lock();
flash_unlock_option_bytes(); flash_unlock_option_bytes();
// Section 2.8.6 Flash option control register (FLASH_OPTCR) // Section 2.8.6 Flash option control register (FLASH_OPTCR)
// Bits 31:28 Reserved, must be kept cleared. // Bits 31:28 Reserved, must be kept cleared.

Loading…
Cancel
Save