Page 1 of 1

Software factory reset

Posted: Wed Dec 14, 2022 11:26 am
by markevens
Hello, I am writing factory reset functionality using the software.
and below is my code.

Code: Select all

 esp_partition_iterator_t pi = esp_partition_find(
            ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_FACTORY, NULL);

        if (pi != NULL)
        {
            const esp_partition_t *factory = esp_partition_get(pi);
            esp_partition_iterator_release(pi);
            esp_err_t  err = esp_ota_set_boot_partition(factory);
            if (err == ESP_OK)
                esp_restart();
            else
                printf("Boot partition not set successful\n");
        }
        else
            printf("Factory partition not found:\n");
questions:
1-> Am I doing right?
2-> I am using OTA API for setting boot partition it is right?
3-> Do I need to write 0xFF to OTA data partition?
or any suggestions or comments from any member.

Re: Software factory reset

Posted: Wed Dec 14, 2022 8:28 pm
by ESP_igrr
This looks correct. You don't need to erase ota_data if you switch to the factory partition like this.
You may also consider erasing the NVS partition to clear any settings such as Wi-Fi credentials.