Software factory reset

markevens
Posts: 38
Joined: Sat Aug 01, 2020 6:31 am

Software factory reset

Postby markevens » Wed Dec 14, 2022 11:26 am

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.

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: Software factory reset

Postby ESP_igrr » Wed Dec 14, 2022 8:28 pm

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.

Who is online

Users browsing this forum: YaCy [Bot] and 125 guests