Fixed nRF52 soft-brick on device EEPROM wipe

This commit is contained in:
Mark Qvist 2025-01-15 12:42:24 +01:00
parent 32fc5afee2
commit 7e30648968

View File

@ -1289,13 +1289,10 @@ void promisc_disable() {
InternalFS.begin();
file.open(EEPROM_FILE, FILE_O_READ);
// if file doesn't exist
if (!file) {
if (file.open(EEPROM_FILE, FILE_O_WRITE)) {
// initialise the file with empty content
uint8_t empty_content[EEPROM_SIZE] = {0};
file.write(empty_content, EEPROM_SIZE);
for (uint32_t mapped_addr = 0; mapped_addr < EEPROM_SIZE; mapped_addr++) { file.seek(mapped_addr); file.write(0xFF); }
eeprom_flush();
return true;
} else {
return false;
@ -1423,9 +1420,13 @@ void eeprom_write(uint8_t addr, uint8_t byte) {
}
void eeprom_erase() {
#if !HAS_EEPROM && MCU_VARIANT == MCU_NRF52
InternalFS.format();
#else
for (int addr = 0; addr < EEPROM_RESERVED; addr++) {
eeprom_update(eeprom_addr(addr), 0xFF);
}
#endif
hard_reset();
}