mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 07:28:10 +00:00
legacy: unlock flash before erasing (#146)
This commit is contained in:
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…
Reference in New Issue
Block a user