mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-18 05:28:40 +00:00
50 lines
1.7 KiB
C
50 lines
1.7 KiB
C
static void erase_storage_code_progress(void) {
|
|
flash_wait_for_last_operation();
|
|
flash_clear_status_flags();
|
|
flash_unlock();
|
|
// erase storage area
|
|
for (int i = FLASH_STORAGE_SECTOR_FIRST; i <= FLASH_STORAGE_SECTOR_LAST;
|
|
i++) {
|
|
layoutProgress("WIPING ... Please wait",
|
|
1000 * (i - FLASH_STORAGE_SECTOR_FIRST) /
|
|
(FLASH_CODE_SECTOR_LAST - FLASH_STORAGE_SECTOR_FIRST));
|
|
flash_erase_sector(i, FLASH_CR_PROGRAM_X32);
|
|
}
|
|
// erase code area
|
|
for (int i = FLASH_CODE_SECTOR_FIRST; i <= FLASH_CODE_SECTOR_LAST; i++) {
|
|
layoutProgress("WIPING ... Please wait",
|
|
1000 * (i - FLASH_STORAGE_SECTOR_FIRST) /
|
|
(FLASH_CODE_SECTOR_LAST - FLASH_STORAGE_SECTOR_FIRST));
|
|
flash_erase_sector(i, FLASH_CR_PROGRAM_X32);
|
|
}
|
|
flash_wait_for_last_operation();
|
|
flash_lock();
|
|
}
|
|
|
|
static void erase_code_progress(void) {
|
|
flash_wait_for_last_operation();
|
|
flash_clear_status_flags();
|
|
flash_unlock();
|
|
for (int i = FLASH_CODE_SECTOR_FIRST; i <= FLASH_CODE_SECTOR_LAST; i++) {
|
|
layoutProgress("PREPARING ... Please wait",
|
|
1000 * (i - FLASH_CODE_SECTOR_FIRST) /
|
|
(FLASH_CODE_SECTOR_LAST - FLASH_CODE_SECTOR_FIRST));
|
|
flash_erase_sector(i, FLASH_CR_PROGRAM_X32);
|
|
}
|
|
layoutProgress("INSTALLING ... Please wait", 0);
|
|
flash_wait_for_last_operation();
|
|
flash_lock();
|
|
}
|
|
|
|
static void erase_storage(void) {
|
|
flash_wait_for_last_operation();
|
|
flash_clear_status_flags();
|
|
flash_unlock();
|
|
for (int i = FLASH_STORAGE_SECTOR_FIRST; i <= FLASH_STORAGE_SECTOR_LAST;
|
|
i++) {
|
|
flash_erase_sector(i, FLASH_CR_PROGRAM_X32);
|
|
}
|
|
flash_wait_for_last_operation();
|
|
flash_lock();
|
|
}
|