diff --git a/firmware/fsm.c b/firmware/fsm.c index cf1d6c54ab..29463de7b2 100644 --- a/firmware/fsm.c +++ b/firmware/fsm.c @@ -241,6 +241,7 @@ void fsm_msgWipeDevice(WipeDevice *msg) storage_reset(); storage_reset_uuid(); storage_commit(); + storage_clearPinArea(); // the following does not work on Mac anyway :-/ Linux/Windows are fine, so it is not needed // usbReconnect(); // force re-enumeration because of the serial number change fsm_sendSuccess("Device wiped"); diff --git a/firmware/storage.c b/firmware/storage.c index 8d7f15a568..0b9b7b2588 100644 --- a/firmware/storage.c +++ b/firmware/storage.c @@ -419,6 +419,15 @@ bool session_isPinCached(void) return sessionPinCached; } +void storage_clearPinArea() +{ + flash_clear_status_flags(); + flash_unlock(); + flash_erase_sector(FLASH_META_SECTOR_LAST, FLASH_CR_PROGRAM_X32); + flash_lock(); + storage_check_flash_errors(); +} + void storage_resetPinFails(uint32_t *pinfailsptr) { flash_clear_status_flags(); diff --git a/firmware/storage.h b/firmware/storage.h index 321f276aae..ef6978f12c 100644 --- a/firmware/storage.h +++ b/firmware/storage.h @@ -56,6 +56,7 @@ bool storage_hasPin(void); void storage_setPin(const char *pin); void session_cachePin(void); bool session_isPinCached(void); +void storage_clearPinArea(void); void storage_resetPinFails(uint32_t *pinfailptr); bool storage_increasePinFails(uint32_t *pinfailptr); uint32_t *storage_getPinFailsPtr(void); diff --git a/firmware/trezor.c b/firmware/trezor.c index bc9c1ba1b3..aa154d6e61 100644 --- a/firmware/trezor.c +++ b/firmware/trezor.c @@ -50,6 +50,7 @@ int main(void) storage_reset(); // wipe storage if debug link storage_reset_uuid(); storage_commit(); + storage_clearPinArea(); // reset PIN failures if debug link #endif oledDrawBitmap(40, 0, &bmp_logo64);