esptool and OTA conflict
esptool and OTA conflict
I am developing code, so the ESP32 checks a remote webserver for updated firmware. If a newer version is available, it downloads and flashes it via OTA.
After the first update to partition OTA 1, when I use "make flash" the esptool writes to partition OTA 0. But OTA 1 is still the active boot partition, so the device always reboots into OTA 1.
Is there a tool - or a command line option for esptool - to set OTA 0 as boot partition?
In my opinion, this is a bug. When esptool flashes to a partition, it should make it automatically the boot partition.
After the first update to partition OTA 1, when I use "make flash" the esptool writes to partition OTA 0. But OTA 1 is still the active boot partition, so the device always reboots into OTA 1.
Is there a tool - or a command line option for esptool - to set OTA 0 as boot partition?
In my opinion, this is a bug. When esptool flashes to a partition, it should make it automatically the boot partition.
Re: esptool and OTA conflict
Erase otadata partition
Re: esptool and OTA conflict
Thanks for pointing this out. We're aware of this limitation and we're planning a fix, but we don't have an ETA yet.
The underlying issue is, at the moment the IDF build system doesn't know about OTA. Specifically, it doesn't know if there's an OTA data partition or where it is. It needs to parse the partition table in order to know this information. Then we can add options to automatically clear ota_data on serial flash (and/or to serial flash into an OTA slot instead of into "factory").
In the meantime, you can use manual esptool.py commands to clear ota_data. Either of the following will work:
OR
(Second option only useful if you don't need any of the other contents of the flash.)
The underlying issue is, at the moment the IDF build system doesn't know about OTA. Specifically, it doesn't know if there's an OTA data partition or where it is. It needs to parse the partition table in order to know this information. Then we can add options to automatically clear ota_data on serial flash (and/or to serial flash into an OTA slot instead of into "factory").
In the meantime, you can use manual esptool.py commands to clear ota_data. Either of the following will work:
Code: Select all
esptool.py --port PORT erase_region <address of ota_data> 0x2000
Code: Select all
esptool.py erase_flash
Re: esptool and OTA conflict
Thanks for the info. erase_region will help. I used erase_flash once before, but deleting everything is not what I want.
Re: esptool and OTA conflict
Hello @ESP_Angus, any news about this feature of serial flashing into an OTA slot and booting from there instead of factory? I see that the clear ota_data option has already been implemented, but cannot find anything about the other option.ESP_Angus wrote:Then we can add options to automatically clear ota_data on serial flash (and/or to serial flash into an OTA slot instead of into "factory").
I am working on a project with FACTORY+OTA partitions and I would like to speed up development just serial flashing to OTA partition directly, debugging from there, etc, without having to boot from FACTORY each time.
Thank you!
Re: esptool and OTA conflict
You can use full command line to flash bin file from ota partition address:
I deleted from command line part to flash partition table and bootloader, only part id ota bin file. Of course you have to change file name and 0x100000 to your value and port com9.
Code: Select all
python /d/msys32/home/imper/esp/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port com9 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size 0x100000 /home/ble_test/build/ota.bin
Re: esptool and OTA conflict
Hi Luis,luisonoff wrote:Hello @ESP_Angus, any news about this feature of serial flashing into an OTA slot and booting from there instead of factory? I see that the clear ota_data option has already been implemented, but cannot find anything about the other option.ESP_Angus wrote:Then we can add options to automatically clear ota_data on serial flash (and/or to serial flash into an OTA slot instead of into "factory").
I am working on a project with FACTORY+OTA partitions and I would like to speed up development just serial flashing to OTA partition directly, debugging from there, etc, without having to boot from FACTORY each time.
As you've noticed, the default flasher commands in master branch now erase the ota_data partition and flash the default partition (factory or OTA slot 0 if no factory partition is present) each time. This will be in the V3.2 release.
Regarding flashing a specific ota_data (to point to a certain slot) and flashing a different app slot via serial, we don't have an ETA for this feature. Probably the most straightforward thing you can do now is to use the esptool.py read_flash command to pull an ota_data partition which points to the correct app slot already, and then flash it and your app manually similar to what chegewara is showing.
Or you could temporarily modify the CSV file for the partition table to change the type of the "factory" partition to something else (which means the system will fallback to flashing and booting from OTA slot 0 by default). Then change it back when you go to production.
Angus
Re: esptool and OTA conflict
Thank you very much for your answers Angus and Chegewara.
This is what I am doing right now, just wanted to confirm there was no easier way (or more correct way) at the moment.ESP_Angus wrote:Or you could temporarily modify the CSV file for the partition table to change the type of the "factory" partition to something else (which means the system will fallback to flashing and booting from OTA slot 0 by default). Then change it back when you go to production.
Re: esptool and OTA conflict
I erase my OTADATA partition with the following....
$IDF_PATH/components/esptool_py/esptool/esptool.py --port com3 erase_region 0xd000 0x2000
After execution the device boots off the factory partition.
John A
$IDF_PATH/components/esptool_py/esptool/esptool.py --port com3 erase_region 0xd000 0x2000
After execution the device boots off the factory partition.
John A
Who is online
Users browsing this forum: No registered users and 9 guests