basic factory reset routine

This commit is contained in:
Siwat Sirichai 2024-01-12 02:05:51 +07:00
parent e88760c299
commit b16b6902d7
2 changed files with 18 additions and 1 deletions

View file

@ -12,6 +12,6 @@
platform = espressif32
board = wt32-eth01
framework = arduino
lib_deps = siwats/ESPMegaProR3@^2.0.7
lib_deps = siwats/ESPMegaPROR3@^2.0.7
monitor_speed = 115200
;build_flags = -DCORE_DEBUG_LEVEL=5

View file

@ -89,6 +89,13 @@ void sendExtStopBytes()
void setup()
{
gpio_config_t gpio_2_conf;
gpio_2_conf.intr_type = GPIO_INTR_DISABLE;
gpio_2_conf.mode = GPIO_MODE_INPUT;
gpio_2_conf.pull_up_en = GPIO_PULLUP_ENABLE;
gpio_config(&gpio_2_conf);
// If GPIO 2 is pulled low, clear the FRAM then reboot (Reset the device to factory defaults)
bool clear_fram = !gpio_get_level(GPIO_NUM_2);
Serial.begin(115200);
cudDisplayAdapter.begin(CUD_DISPLAY_BAUD_RATE, SERIAL_8N1, CUD_DISPLAY_RX_PIN, CUD_DISPLAY_TX_PIN);
sendExtStopBytes();
@ -100,6 +107,16 @@ void setup()
Serial.print("boot_state.txt=\"Core Initializing . . .\"");
sendStopBytes();
espmega.begin();
if (clear_fram)
{
Serial.print("boot_state.txt=\"Factory Resetting . . .\"");
sendStopBytes();
for (uint16_t i = 0; i < 32768; i++)
{
espmega.fram.write8(i, 0);
}
esp_restart();
}
Serial.print("boot_state.txt=\"IoT Initializing . . .\"");
sendStopBytes();
espmega.enableIotModule();