esptool and OTA conflict

ThorstenS
Posts: 3
Joined: Sun Sep 17, 2017 11:52 am

esptool and OTA conflict

Postby ThorstenS » Sun Sep 17, 2017 12:00 pm

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.

WiFive
Posts: 1911
Joined: Tue Dec 01, 2015 7:35 am

Re: esptool and OTA conflict

Postby WiFive » Sun Sep 17, 2017 7:59 pm

Erase otadata partition

ESP_Angus
Posts: 1143
Joined: Sun May 08, 2016 4:11 am

Re: esptool and OTA conflict

Postby ESP_Angus » Mon Sep 18, 2017 1:43 am

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

Code: Select all

esptool.py erase_flash


(Second option only useful if you don't need any of the other contents of the flash.)

ThorstenS
Posts: 3
Joined: Sun Sep 17, 2017 11:52 am

Re: esptool and OTA conflict

Postby ThorstenS » Mon Sep 18, 2017 7:33 pm

Thanks for the info. erase_region will help. I used erase_flash once before, but deleting everything is not what I want.

User avatar
luisonoff
Posts: 22
Joined: Fri Feb 09, 2018 12:20 pm

Re: esptool and OTA conflict

Postby luisonoff » Wed Aug 29, 2018 8:33 am

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!

chegewara
Posts: 425
Joined: Wed Jun 14, 2017 9:00 pm

Re: esptool and OTA conflict

Postby chegewara » Wed Aug 29, 2018 8:50 pm

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.

ESP_Angus
Posts: 1143
Joined: Sun May 08, 2016 4:11 am

Re: esptool and OTA conflict

Postby ESP_Angus » Thu Aug 30, 2018 2:16 am

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

User avatar
luisonoff
Posts: 22
Joined: Fri Feb 09, 2018 12:20 pm

Re: esptool and OTA conflict

Postby luisonoff » Thu Aug 30, 2018 6:26 am

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.

User avatar
fly135
Posts: 348
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: esptool and OTA conflict

Postby fly135 » Fri Aug 31, 2018 4:45 pm

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

Who is online

Users browsing this forum: No registered users and 2 guests