EPS32 OTA: wrong path to espota.py // can't open file 'tools\espota.py' - corrected title

Hi,

I am trying to use OTA on a Heltec32 ESP32 board.

I set up platformio.ini, hit → and get

Apparently python does not find the espota.py, nore do I when I search for it (Win10);

I had a native ESP-IDF installed before, including path setting in the environment variables. These I not deleted, without success.

Dies anyone have an idea how I can install ESPOTA manually or make platformio install it?

Last time I asked here in the community I got good help, so I hope to solve my problem quickly.
Thank you all for helping!

Greetings
Georg

Upload is set to espota, and it is looking for espota.py, so lets get that out of the way first. Should it be using espota, or esptool? If it should be using esptool, perhaps you need to set upload_protocol = esptool ?

Now, if it’s supposed to be using esptoa, we need to find out why it’s looking in tools\espota.py, and not in the .platformio\packages\tool-espota folder. You could always manually download it from https://dl.bintray.com/platformio/dl-packages/ and extract it to that folder, which should contain just two files … esptool.py and package.json. But, since the upload code specifically makes mention of the arduino framework, and google is not giving anything useful, I think you’re after esptool, not espota. Or am I missing something?

Hi Pfeerick,

you are absolutely right, I messed up the title. ESPOTA.py is the tool that python does not find.
Sorry on this.

I will try to install it manually tonight (GMT-1).
But then I might still have the issue with the wrong path.
Can you/anyone point me to the path-settings?

I can compile the code fine and upload it via COM, now my aim is to upload OTA.

Greetings
Georg

I’ve not done ESPIDF OTA stuff, so can’t really help you there. Reading a bit more about OTA w/ the ESPIDF, I still think you’re trying to use the wrong tool… it looks like it should be otatool.py, which PlatformIO doesn’t know anything about. If that is the case, you’ll probably need to do some custom upload tool scripting.

https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/system/ota.html#ota-tool-otatool-py

Hi,

sadly setting upload_protocol=otatool did not work, platformio switched back to espota, as I had it set before:

Reading the PlatformIO reference to ESP32 OTA

https://docs.platformio.org/en/latest/platforms/espressif32.html#over-the-air-ota-update

Accordingly I set the platformio.ini:

[env:heltec_wifi_kit_32]
platform = espressif32
board = heltec_wifi_kit_32
framework = espidf

upload_protocol = espota
upload_port = 192.168.1.1
upload_flags = -p 8032

;upload_port = COM2
;upload_speed = 115200

monitor_port = COM2
monitor_speed = 115200

So I guess OTA has been integrated for ESP32 on PlatformIO, but somehow I do not happen to have espota.py downloaded. I will see if I find a manual way to do so.

Still: any help welcome.

Greetings
Georg

Hello,

I downloaded the ESPOTA from https://dl.bintray.com/platformio/dl-packages/ and saved it to
C:\Users\GvT.platformio\packages\tool-espota

Still Python does not find the location. So I tried commandline I found in the forum with the following result:

There seems to be no waiting period, immediate error.

Greetings
Georg

Hi,

I also tried @pfeerick’s hint to esptool, similar result, PlatformIO switches to ESPOTA.PY:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Any ideas how I can convince PlatformIO to deliver OTA updates?
(My code worked before with ESP-IDF Installation on VSC)
How can I delete and have the OTA part reinstalled or refreshed?

++++++++++++++++++++++++++++++++++++++++++++++++++++++

Greetings
Georg

P.S. sorry for so many posts, as a new user I had to split them up => one Image per post only…

I’ve bumped your permissions, so you shouldn’t have to split posts.

How did you upload to the ESP32 using the ESP-IDF before?

Do you have any documentation or links showing that espota is valid for the ESP-IDF. The PlatformIO documentaiton you linked to is mostly for the Arduino. If you look at the ESP-IDF specific example code that were linked there, it only talks about OTA being download from a server, not on-demand OTA.

Hello,

ok, summing up briefly, please correct me if I am wrong:
a.) Platformio had no preset OTA integration for ESP32 using IDF
b.) When specifying an IP address as upload_port, espota.py gets called as protocol, overriding other settings. This not being integrated leads to no OTA upload, see (a)

I suggest this behavior could be a future point to fix :slight_smile:

Anyhow, I went back to my old method, that works in Windows 10:

PowerShell:
“curl 192.168.1.1:8032 --data-binary @- < C:\Users\GvT\Documents\ESP32\Basics.pio\build\heltec_wifi_kit_32\firmware.bin” | cmd

or from commandline:
curl 192.168.1.1:8032 --data-binary @- < C:\Users\GvT\Documents\ESP32\Basics.pio\build\heltec_wifi_kit_32\firmware.bin

Right now there must be some sdkconfig settings that I am not getting right as my core 0 panics when I start the upload (code was working before, using esp-idf and vsc with idf.py).

I have not bothered to find a variable pointing to the BIN file, but as this should not change, it does not seem like a problem. Would be nice to add a button to do this call though.

I will post once I get it working.
Greetings
Georg

That is my understanding, and no-one has jumped in to say otherwise yet…

Since you have …

curl 192.168.1.1:8032 --data-binary @- < C:\Users\GvT\Documents\ESP32\Basics.pio\build\heltec_wifi_kit_32\firmware.bin

… there doesn’t seem to be any reason you can’t use the advanced scripting to setup that custom upload method.

A script like this might work (don’t forget to add the extra_scripts line on your platformio.ini referencing it)

Import("env")

env.Replace(
    UPLOADCMD="curl 192.168.1.1:8032 --data-binary @$SOURCE"
)

Hi,

unfortunately my code crashes when trying to identify the next boot partition.

Checking and comparing the sdkconfig and sdkconfig.h between my old ESP-IDF code and Platformio, I find many differences. When I overwrite the sdkconfig filed from Platformio, I get compile errors.

I have no clue what I need to change in SDKconfig to compile OTA code.

Did anyone use OTA and ESPidf with Platformio?

Greetings
Georg

What version of the ESP-IDF were you using before? PlatformIO only uses the stable/release versions, and is currently on 3.3 LTS (as of version 1.10.0 of the espressif32 platform).. If you were using an older version of the ESP-IDF, you can specify an older version of the platform to use that instead.

Hello pfeerick,

I updates my native ESP_IDF in September. Since I deleted it before I installed PlatromIO, I cannot tell you the Version number.

I solved my issue today and will post a summary, so that anyone else who has trouble with OTA and IDF might find some help here.

Thank you very much for your questions and advice, as well as the hints.

Greetings
Georg

Hello everybody,

I got PlatformIO (VSC & Windows 10) with espidf framework to update via OTA.

As for the C code I used the simple_OTA as example, mixed with the AP example, so I have to log in to the ESP32 AccessPoint from my PC. The code worked with a native installation of ESP-IDF and VSC, but panic’d when running it from PlatformIO. This is what I missed, even if it is so obvious:

1.) Provide “fact_two_ota_part.csv” in the root directory (where platformio.ini is)

# Espressif ESP32 Partition table
#
# Factory Boot partition
# OTA Partition 1 & 2
#
# Name, Type, Subtyp, Ofs, Size, Flags
nvs, data, nvs, , 0x4000,
otadata, data, ota, , 0x2000,
phy_init, data, phy, , 0x1000,
factory, app, factory,, 1M,
ota_0, app, ota_0, , 1M,
ota_1, app, ota_1, , 1M,

2.) modify platformio.ini to use this partition.csv file

[env:heltec_wifi_kit_32]
platform = espressif32
board = heltec_wifi_kit_32
framework = espidf
board_build.partitions = fact_two_ota_part.csv

3.) now upload your compiled code one last time via COM onto the board

4.) using powershell [> ] you can now upload via OTA

“curl 192.168.1.1:8032 --data-binary @- < C:\Users\GvT\Documents\ESP32\Basics.pio\build\heltec_wifi_kit_32\firmware.bin” | cmd

this command pipes the curl command to cmd.exe. You need to specify the IP address of your board, the listening port of the OTA server, the type of data as well as the link to the your image (compiled and linked code).

I have not setup a script as pfeerick suggested


Why do I want to use OTA?

  • faster than Upload via COM (for me about factor 2)
  • no need to connect your board via USB (my Heltec32 is waterproof encased)

Many greetings
and thanks a lot to pfeerick for the hints
Georg

1 Like

Glad you were able to get it working, and thanks for documenting how you did… I’m sure it will help others in the future! :slight_smile:

I 100% agree with both reasons to do OTA… it’s so much faster than the reliable 460k serial baud rate, and so much easier when you have devices in enclosures, or scattered around the place. :wink: