1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-24 07:18:09 +00:00

legacy: unlock flash before erasing (#146)

This commit is contained in:
Hadi 2019-05-11 16:50:58 +04:30 committed by Pavol Rusnak
parent 61d4641810
commit 9ceb479abd

View File

@ -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.