Skip to content

Commit

Permalink
fixup! fix(legacy): don't erase firmware and storage in intermediate …
Browse files Browse the repository at this point in the history
…firmware
  • Loading branch information
prusnak committed May 12, 2021
1 parent 8f9acc8 commit b4c7d22
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions legacy/intermediate_fw/trezor.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,11 @@ erase_sector(uint8_t sector, uint32_t psize) {
}

static void __attribute__((noinline, section(".data")))
erase_firmware_and_storage(void) {
erase_firmware(void) {
// Flash unlock
FLASH_KEYR = FLASH_KEYR_KEY1;
FLASH_KEYR = FLASH_KEYR_KEY2;

// Erase storage sectors
for (int i = FLASH_STORAGE_SECTOR_FIRST; i <= FLASH_STORAGE_SECTOR_LAST;
i++) {
erase_sector(i, FLASH_CR_PROGRAM_X32);
}

// Erase the first firmware sector
// (we don't need full erasure, this speeds up the process)
erase_sector(FLASH_CODE_SECTOR_FIRST, FLASH_CR_PROGRAM_X32);
Expand All @@ -100,8 +94,8 @@ void __attribute__((noinline, noreturn, section(".data"))) reboot_device(void) {

/** Entry point of RAM shim that deletes old FW, storage and reboot */
void __attribute__((noinline, noreturn, section(".data")))
erase_and_reboot(void) {
erase_firmware_and_storage();
erase_firmware_and_reboot(void) {
erase_firmware();
reboot_device();

for (;;)
Expand Down Expand Up @@ -146,7 +140,7 @@ int main(void) {
// don't erase
reboot_device();
} else {
erase_and_reboot();
erase_firmware_and_reboot();
}

return 0;
Expand Down

0 comments on commit b4c7d22

Please sign in to comment.