Back to factory APP (OTA)
Posted: Sat Jan 13, 2018 11:22 pm
Once the OTA's updates are made in the OTA sections, the Factory APP is intact, so what is the procedure to return to the first code, stored in the Factory?
p-rimes wrote:That thread is very interesting indeed.
A couple things were not finalized in that thread:
- Are the patches to the bootloader still needed at this point? Is there any way for a typical "factory reset" other than duplicating the bootloader sources into each app, and making a similar patch (and presumably keeping everything in lockstep with esp-idf forever afterwards)?
- Is there a way to transfer control flow to a different partition (i.e. the just-programmed one, or back to factory), WITHOUT a reboot?
- Does the esp-idf bootloader do a fallback boot to factory, in case of a corrupt image?
Oh, I had not seen this partitions reference, there is a function in that reference that can return the pointer to the factory app and so loads it, thanks!chegewara wrote:Use
http://esp-idf.readthedocs.io/en/latest ... btype_tPKc
with
http://esp-idf.readthedocs.io/en/latest ... artition_t
or read this:
http://esp-idf.readthedocs.io/en/latest ... -partition
Code: Select all
//***********************************************************************************************
// B A C K T O F A C T O R Y *
//***********************************************************************************************
// Return to factory version. *
// This will set the otadata to boot from the factory image, ignoring previous OTA updates. *
//***********************************************************************************************
void backtofactory()
{
esp_partition_iterator_t pi ; // Iterator for find
const esp_partition_t* factory ; // Factory partition
esp_err_t err ;
pi = esp_partition_find ( ESP_PARTITION_TYPE_APP, // Get partition iterator for
ESP_PARTITION_SUBTYPE_APP_FACTORY, // factory partition
"factory" ) ;
if ( pi == NULL ) // Check result
{
ESP_LOGE ( tag, "Failed to find factory partition" ) ;
}
else
{
factory = esp_partition_get ( pi ) ; // Get partition struct
esp_partition_iterator_release ( pi ) ; // Release the iterator
err = esp_ota_set_boot_partition ( factory ) ; // Set partition for boot
if ( err != ESP_OK ) // Check error
{
ESP_LOGE ( tag, "Failed to set boot partition" ) ;
}
else
{
esp_restart() ; // Restart ESP
}
}
}
Are bootloader patch requirements still required? Is there a way to perform a "factory reset" without duplicated bootloader sources for each app?chegewara wrote: ↑Sun Jan 14, 2018 5:16 amUse
http://esp-idf.readthedocs.io/en/latest ... btype_tPKc
with
http://esp-idf.readthedocs.io/en/latest ... artition_t
or read this:
http://esp-idf.readthedocs.io/en/latest ... -partition