OTA requires to erase flash
-
- Posts: 132
- Joined: Tue Aug 14, 2018 6:21 am
- Location: India
OTA requires to erase flash
Hi all,
I am updating my firmware using OTA example given in esp idf.
when I am flashing the code to esp32, it needs to erase flash before flashing the code in esp32. so I am using command "make erase_flash flash" and after that my code works with startup.
is there any API to flash entire flash in esp32?
I am updating my firmware using OTA example given in esp idf.
when I am flashing the code to esp32, it needs to erase flash before flashing the code in esp32. so I am using command "make erase_flash flash" and after that my code works with startup.
is there any API to flash entire flash in esp32?
--
Somesh Burkule
Somesh Burkule
Re: OTA requires to erase flash
I'm more interested in why you are asking the question than the answer. If you erase the entire flash with the API your application will likely crash because you erased it. The OTA example erases the appropriate location in the flash before writing the update to it.
John A
John A
-
- Posts: 132
- Joined: Tue Aug 14, 2018 6:21 am
- Location: India
Re: OTA requires to erase flash
actually problem is that when i want to update the firmware using ota example, i need to erase entire flash. if i cant erase it, the firmware will not update. and if i want to erase flash without connecting esp32 to my system then how can i erase the flash?fly135 wrote:I'm more interested in why you are asking the question than the answer. If you erase the entire flash with the API your application will likely crash because you erased it. The OTA example erases the appropriate location in the flash before writing the update to it.
John A
--
Somesh Burkule
Somesh Burkule
Re: OTA requires to erase flash
Seems like the post I made above was adequate to indicate to you that your notion of needing to erase the entire flash was wrong. In addition I indicated that the OTA example will erase the regions of flash needed to perform the update. The OTA example will download a new firmware build and reboot with your new firmware in flash. You don't need to erase the flash yourself.burkulesomesh43 wrote:actually problem is that when i want to update the firmware using ota example, i need to erase entire flash. if i cant erase it, the firmware will not update. and if i want to erase flash without connecting esp32 to my system then how can i erase the flash?
John A
-
- Posts: 132
- Joined: Tue Aug 14, 2018 6:21 am
- Location: India
Re: OTA requires to erase flash
when I am flashing the code of ota for updated firmware without erasing the flash, it will not work. esp32 runs the previous code which is flashed. but as I flash updated firmware code of ota with erasing the flash using make erase_flash flash command, the esp32 runs the ota code and update the firmware..fly135 wrote:Seems like the post I made above was adequate to indicate to you that your notion of needing to erase the entire flash was wrong. In addition I indicated that the OTA example will erase the regions of flash needed to perform the update. The OTA example will download a new firmware build and reboot with your new firmware in flash. You don't need to erase the flash yourself.burkulesomesh43 wrote:actually problem is that when i want to update the firmware using ota example, i need to erase entire flash. if i cant erase it, the firmware will not update. and if i want to erase flash without connecting esp32 to my system then how can i erase the flash?
John A
So what is the issue? I can't understand.
--
Somesh Burkule
Somesh Burkule
Re: OTA requires to erase flash
make erase_ota - Erase ota_data partition. After that will boot first bootable partition (factory or OTAx).
Re: OTA requires to erase flash
After you burn the first OTA the device always boots off an OTA partition. It will never boot from the factory partition after that unless you erase the OTADATA partition, which is instructing the 2nd stage bootloader to boot from OTA. WiFive's post is telling you how to erase the OTADATA partition.burkulesomesh43 wrote:when I am flashing the code of ota for updated firmware without erasing the flash, it will not work. esp32 runs the previous code which is flashed. but as I flash updated firmware code of ota with erasing the flash using make erase_flash flash command, the esp32 runs the ota code and update the firmware..
So what is the issue? I can't understand.
John A
Re: OTA requires to erase flash
From application, it is quite easy to set from which partition, including factory, you want to boot on the next restart using esp_ota_set_boot_partition(part).fly135 wrote:After you burn the first OTA the device always boots off an OTA partition.. It will never boot from the factory partition after that unless you erase the OTADATA partition, which is instructing the 2nd stage bootloader to boot from OTA....
You can find the bootable partition by name and type using:
Code: Select all
const esp_partition_t *boot_part1 = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_FACTORY, part_name);
const esp_partition_t *boot_part2 = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_0, part_name);
const esp_partition_t *boot_part3 = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_1, part_name);
-
- Posts: 132
- Joined: Tue Aug 14, 2018 6:21 am
- Location: India
Re: OTA requires to erase flash
Ok. thank you.loboris wrote:From application, it is quite easy to set from which partition, including factory, you want to boot on the next restart using esp_ota_set_boot_partition(part).fly135 wrote:After you burn the first OTA the device always boots off an OTA partition.. It will never boot from the factory partition after that unless you erase the OTADATA partition, which is instructing the 2nd stage bootloader to boot from OTA....
You can find the bootable partition by name and type using:Code: Select all
const esp_partition_t *boot_part1 = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_FACTORY, part_name); const esp_partition_t *boot_part2 = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_0, part_name); const esp_partition_t *boot_part3 = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_1, part_name);
Now I am trying to understand how ota works. how partitions work to update fiemware with factory app, ota0, ota1...
then I will try your way.
--
Somesh Burkule
Somesh Burkule
-
- Posts: 132
- Joined: Tue Aug 14, 2018 6:21 am
- Location: India
Re: OTA requires to erase flash
see the postfly135 wrote:After you burn the first OTA the device always boots off an OTA partition. It will never boot from the factory partition after that unless you erase the OTADATA partition, which is instructing the 2nd stage bootloader to boot from OTA. WiFive's post is telling you how to erase the OTADATA partition.burkulesomesh43 wrote:when I am flashing the code of ota for updated firmware without erasing the flash, it will not work. esp32 runs the previous code which is flashed. but as I flash updated firmware code of ota with erasing the flash using make erase_flash flash command, the esp32 runs the ota code and update the firmware..
So what is the issue? I can't understand.
John A
viewtopic.php?t=1624#p7544
--
Somesh Burkule
Somesh Burkule
Who is online
Users browsing this forum: No registered users and 109 guests