IotWebConf icon indicating copy to clipboard operation
IotWebConf copied to clipboard

factory reset?

Open societyofrobots opened this issue 4 years ago • 0 comments

Lets say I install firmware 1.0 by flashing to the ESP32.

Then, I upgrade to 1.1 using OTA with IotWebConf.

How could I command the ESP32 to use the original 1.0 firmware?

Is this code below (source) valid?

#include "esp_partition.h"

//find partitions
esp_partition_iterator_t pi = esp_partition_find(
  ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_FACTORY, NULL);//null for factory firmware

//get pointer to partition
const esp_partition_t* esp_partition_get(esp_partition_iterator_t iterator);

//release iterator
void esp_partition_iterator_release(esp_partition_iterator_t iterator);

//flag partition and reboot
if(pi != NULL) {
  const esp_partition_t* factory = esp_partition_get(pi);
  esp_partition_iterator_release(pi);
  if(esp_ota_set_boot_partition(factory) == ESP_OK) esp_restart();	
}

societyofrobots avatar Jul 26 '21 00:07 societyofrobots