Hi Team,
I am using OTA update in my project but I want to enable an option to move back to factory image. I found out below option but not sure of the same. Below is the link:
https://docs.espressif.com/projects/esp ... tory-reset
It is mentioned here that "To trigger a factory reset, this GPIO must be pulled low on reset." Here, reset means hard reboot??
OTA will work even after moving to factory image?
If not this method, let me know if there is any other way to do the same.
Thanks
Ritu.
GPIO Based Factory Reset
Re: GPIO Based Factory Reset
Waiting for response
Re: GPIO Based Factory Reset
Hi,
First of all, Did you check how OTA is working into ESP32 with different partitions like Factory App, OTA_0 and OTA_1?
Also just want to make sure requirement like you want to switch to Factory Default Partition using some external input if you are running your current image into OTA_0 or OTA_1 partition as per your partition table mechanism?
Or you want something else?
First of all, Did you check how OTA is working into ESP32 with different partitions like Factory App, OTA_0 and OTA_1?
Also just want to make sure requirement like you want to switch to Factory Default Partition using some external input if you are running your current image into OTA_0 or OTA_1 partition as per your partition table mechanism?
Or you want something else?
Regards,
Ritesh Prajapati
Ritesh Prajapati
Re: GPIO Based Factory Reset
Hi Ritesh,
I want to move back to factory app if required.
Thanks
Ritu
I want to move back to factory app if required.
Thanks
Ritu
Re: GPIO Based Factory Reset
So that Requirement is based on any event or button or something like that?
Regards,
Ritesh Prajapati
Ritesh Prajapati
Re: GPIO Based Factory Reset
Yes, something like when we give input from GPIO, device should restart from factory app.
Re: GPIO Based Factory Reset
Ok. Then it is quite easy job to move your firmware into factory app which you are using.
So, Basically, which partition mechanism you are using? if you are using Default, OTA_0 and OTA_1 then you can do easily which you want in case to move your device to factory firmware.
Regards,
Ritesh Prajapati
Ritesh Prajapati
Re: GPIO Based Factory Reset
Yes, I am using Factory, OTA_0, OTA_1 partitions for image update. How do we do that??
Re: GPIO Based Factory Reset
Please find below code sequence which we are using. but we are using for Default Partition and OTA_0. So, Same way you can use it for all 3 partitions in which you can set Default Partition as Factory Reset Partition while other OTA_0 and OTA_1 partitions can be used for Firmware Update support and switching for that.
esp_partition_t partition;
memset(&partition, 0, sizeof(esp_partition_t));
const esp_partition_t *partition1 = esp_ota_get_boot_partition();
if (partition1 == NULL) {
return FIRMWARE_UPDATE_FAIL;
}
if (partition1->subtype == ESP_PARTITION_SUBTYPE_APP_OTA_0) {
partition.type = ESP_PARTITION_TYPE_APP;
partition.subtype = ESP_PARTITION_SUBTYPE_APP_FACTORY;
partition.address = OTA_PARTITION_0_ADDR;
partition.size = OTA_PARTITION_SIZE;
strcpy(partition.label, "FACTORY_APP");
partition.encrypted = FAIL;
dest = OTA_PARTITION_0_ADDR;
} else if (partition1->subtype == ESP_PARTITION_SUBTYPE_APP_FACTORY) {
partition.type = ESP_PARTITION_TYPE_APP;
partition.subtype = ESP_PARTITION_SUBTYPE_APP_OTA_0;
partition.address = OTA_PARTITION_1_ADDR;
partition.size = OTA_PARTITION_SIZE;
strcpy(partition.label, "OTA_0_APP");
partition.encrypted = FAIL;
dest = OTA_PARTITION_1_ADDR;
}
spi_flash_erase_range
spi_flash_write
esp_ota_set_boot_partition
Restart ESP32 with some timer mechanism of 5 seconds or 10 seconds
Let me know if need any further help regarding same.
Regards,
Ritesh Prajapati
Ritesh Prajapati
Re: GPIO Based Factory Reset
In your code, you are first checking the present partition and accordingly changing the other partition, But I want to change to factory app, be it any partition. So, my code would be something like below:
esp_partition_t partition;
memset(&partition, 0, sizeof(esp_partition_t));
const esp_partition_t *partition1 = esp_ota_get_boot_partition();
if (partition1 == NULL) {
return FIRMWARE_UPDATE_FAIL;
}
if ((partition1->subtype == ESP_PARTITION_SUBTYPE_APP_OTA_0) || (partition1->subtype == ESP_PARTITION_SUBTYPE_APP_OTA_1)){
partition.type = ESP_PARTITION_TYPE_APP;
partition.subtype = ESP_PARTITION_SUBTYPE_APP_FACTORY;
partition.address = OTA_PARTITION_0_ADDR; /*why are you using ota_0 partition address*/
partition.size = OTA_PARTITION_SIZE; /*wht are you using ota partition size*/
strcpy(partition.label, "FACTORY_APP");
partition.encrypted = FAIL;
dest = OTA_PARTITION_0_ADDR;
}
else printf("Already running factory app\n");
Please check the above code and confirm.
Also, please let me know the GPIO configuration for this.I will be using pin 33/GPIO21.
Thanks
Ritu
esp_partition_t partition;
memset(&partition, 0, sizeof(esp_partition_t));
const esp_partition_t *partition1 = esp_ota_get_boot_partition();
if (partition1 == NULL) {
return FIRMWARE_UPDATE_FAIL;
}
if ((partition1->subtype == ESP_PARTITION_SUBTYPE_APP_OTA_0) || (partition1->subtype == ESP_PARTITION_SUBTYPE_APP_OTA_1)){
partition.type = ESP_PARTITION_TYPE_APP;
partition.subtype = ESP_PARTITION_SUBTYPE_APP_FACTORY;
partition.address = OTA_PARTITION_0_ADDR; /*why are you using ota_0 partition address*/
partition.size = OTA_PARTITION_SIZE; /*wht are you using ota partition size*/
strcpy(partition.label, "FACTORY_APP");
partition.encrypted = FAIL;
dest = OTA_PARTITION_0_ADDR;
}
else printf("Already running factory app\n");
Please check the above code and confirm.
Also, please let me know the GPIO configuration for this.I will be using pin 33/GPIO21.
Thanks
Ritu
Who is online
Users browsing this forum: No registered users and 160 guests