Page 1 of 1
esptool and OTA conflict
Posted: Sun Sep 17, 2017 12:00 pm
by ThorstenS
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.
Re: esptool and OTA conflict
Posted: Sun Sep 17, 2017 7:59 pm
by WiFive
Erase otadata partition
Re: esptool and OTA conflict
Posted: Mon Sep 18, 2017 1:43 am
by ESP_Angus
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:
Code: Select all
esptool.py --port PORT erase_region <address of ota_data> 0x2000
OR
(Second option only useful if you don't need any of the other contents of the flash.)
Re: esptool and OTA conflict
Posted: Mon Sep 18, 2017 7:33 pm
by ThorstenS
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
Posted: Wed Aug 29, 2018 8:33 am
by luisonoff
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").
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.
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
Posted: Wed Aug 29, 2018 8:50 pm
by chegewara
You can use full command line to flash bin file from ota partition address:
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
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.
Re: esptool and OTA conflict
Posted: Thu Aug 30, 2018 2:16 am
by ESP_Angus
luisonoff wrote: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").
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.
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.
Hi Luis,
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
Posted: Thu Aug 30, 2018 6:26 am
by luisonoff
Thank you very much for your answers Angus and Chegewara.
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.
This is what I am doing right now, just wanted to confirm there was no easier way (or more correct way) at the moment.
Re: esptool and OTA conflict
Posted: Fri Aug 31, 2018 4:45 pm
by fly135
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