1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 14:28:07 +00:00

flash: unify lock/unlock sequences

This commit is contained in:
Pavol Rusnak 2019-02-10 13:21:31 +01:00
parent c609d10c3f
commit 26f9b5ba81
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 4 additions and 0 deletions

View File

@ -78,6 +78,8 @@ void check_bootloader(void)
for (int tries = 0; tries < 10; tries++) {
// replace bootloader
flash_wait_for_last_operation();
flash_clear_status_flags();
flash_unlock();
for (int i = FLASH_BOOT_SECTOR_FIRST; i <= FLASH_BOOT_SECTOR_LAST; i++) {
flash_erase_sector(i, FLASH_CR_PROGRAM_X32);
@ -86,6 +88,7 @@ void check_bootloader(void)
const uint32_t *w = (const uint32_t *)(bl_data + i * 4);
flash_program_word(FLASH_BOOT_START + i * 4, *w);
}
flash_wait_for_last_operation();
flash_lock();
// check whether the write was OK
r = memory_bootloader_hash(hash);

View File

@ -25,6 +25,7 @@
#if !EMULATOR
static void svhandler_flash_unlock(void) {
flash_wait_for_last_operation();
flash_clear_status_flags();
flash_unlock();
}