basic factory reset routine
This commit is contained in:
parent
e88760c299
commit
b16b6902d7
2 changed files with 18 additions and 1 deletions
17
src/main.cpp
17
src/main.cpp
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue