Marvee Amasi
DIIDevHeads IoT Integration Server
•Created by Daniel kalu on 9/27/2024 in #firmware-and-baremetal
Implementing Failsafe Mechanism for Firmware Updates on ESP32
See this #include "esp_system.h"
#include "esp_attr.h"
void restart_to_flash_mode() {
// Check if GPIO0 is grounded (button pressed)
if (gpio_get_level(GPIO_NUM_0) == 0) {
// Perform hardware reset instead of software reset
REG_WRITE(RTC_CNTL_OPTIONS0_REG, RTC_CNTL_SW_SYS_RST);
} else {
ESP.restart(); // Perform normal software reset if GPIO0 is not grounded
}
}
6 replies