OTA (again) with ESP32 Clone

Hi everybody and thanks in advance. I am having problems accessing and updating my ESP-WROOM-32 device with OTA. After having read tons of posts, I could not solve it. And it seems the same that more people have solved, but I have tried a lot of things and the issue continues. Problem is very easy. I launch from platformio OTA-env the “Upload and Monitor” and in seems to begin, and then… Crash!

The error message:

Creating esp32 image...
Merged 27 ELF sections
Successfully created esp32 image.
Configuring upload protocol...
AVAILABLE: cmsis-dap, esp-bridge, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = espota
Uploading .pio\build\OTA_env\firmware.bin
13:50:50 [DEBUG]: Options: {'esp_ip': '192.168.1.242', 'host_ip': '0.0.0.0', 'esp_port': 3232, 'host_port': 13509, 'auth': '2357 --port=8266', 'image': '.pio\\build\\OTA_env\\firmware.bin', 'spiffs': False, 'debug': True, 'progress': True, 'timeout': 10}  
13:50:50 [INFO]: Starting on 0.0.0.0:13509
13:50:50 [INFO]: Upload size: 833104
Sending invitation to 192.168.1.242 ..........
13:52:30 [ERROR]: No response from the ESP
*** [upload] Error 1
================================================= [FAILED] Took 107.80 seconds =================================================

Environment    Status    Duration
-------------  --------  ------------
OTA_env        FAILED    00:01:47.798
============================================ 1 failed, 0 succeeded in 00:01:47.798 ============================================ 

And my platformio.ini file

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps = adafruit/Adafruit BME280 Library@^2.2.4

[env:OTA_env]
platform = platformio/espressif32
board = esp32dev
framework = arduino
upload_protocol = espota
upload_port = 192.168.1.242
upload_flags = --auth=password --port=8266
lib_deps = adafruit/Adafruit BME280 Library@^2.2.4

I have turn off my firewall, and I have tried from different PC’s but it did not work. The code of the project is quite easy, and the ArduinoOTA.handle() is in the “loop()”. Any of you could give some clue to solve it? Thank you again.

Remove this line or at least remove “--port=8266” because the ESP32 is using port 3232.

Tip: Try getting this work without password. If this works, you can add a password later.

This is how ArduinoOTA works:

  • The PC opens a TCP port x and listens for incomming connections
  • The PC sends an invitation via UDP to the ESP on port 3232 and communicates the litstening TCP port
  • The ESP32 connects to the PC on the given TCP port and starts “downloading” the new firmware

Thank you sivar2311. At the beginning it did no work, deleting the line you told me, but, what I did is to write it all again but without that line and… it worked. But, now the process does not go beyond 14% 7 meters away from router, getting “Error uploading *** [upload] Error 1”. And nothing else. Just this shot message.
I have got up to 34% 2 meters away from router. I do not know if it was the wifi card of the ESP32.

Try erasing the flash (via USB connection)
Then upload the initial OTA sketch via USB and then try uploading via OTA again.

Erase Flash: click PIO-Icon → PROJECT TASKS → esp32dev → Platform → Erase Flash

Which exact board do you have and what is the size of the flash?

Hi. When you say that I try after erasing the flash, I guess that is with the device connected to the USB, because it cannot access de network.
I did it this way and, I do not know why, the “No response from the ESP” came back. I will try again later.

My board is exactly this

Yes, because you need to upload an OTA enabled sketch first.

Make sure your ESP is connected to your wifi network.

image

Does this board really just have 1 MB of flash?

Hi and thanks for your quick answer. Yes, the board is connected to the Wifi because I am sending a message through serial telling it and, I can ping it. Even a I hava a little Web Server working. I can access its web.

I have tried again with the same result. I will try after lunch again.

Regarding the flash memory, the result of the commands getflashchipsize, chipspeed and chipmode is this:

Tamaño total de la memoria flash: 4194304 bytes ← flash memroy size
Velocidad de la memoria flash: 40000000 Hz ← flash memory speed
Modo de la memoria flash: 2 ← flash memory mode

Edit: One question? Can a delay(30000) thay I have at the end of the loop be interfering in the ota process?

And two: Why the commando I told you gave me 4MB of Falsh and during the OTA process PlO is telling Advanced Memory Usage is available via "PlatformIO Home > Project Inspect" RAM: [== ] 15.3% (used 50100 bytes from 327680 bytes) Flash: [======= ] 66.4% (used 869965 bytes from 1310720 bytes)

Checking PIO messages when uploading code I have read that the flash is 4MB but, why “1310720 bytes”???

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (6.9.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)

Oh yes. Remove this!
This will block the whole sketch.
If you need to wait that amount of time consider to use the wait without delay idiom.

Great!!! It worked!! Thank you for you advice. I am a one week newbie in this world or micros and I thought that the OTA method worked using an interruption or something similar.

What do you thing about what I told you about the flash memory? Is it possible that I have been cheated with this board?

No, everything is fine! I thought this board comes with just 1 MB of flash.

The flash is partitioned and the default app-partition size is 1310720.
See Espressif 32 — PlatformIO latest documentation
and default.csv

So everything is fine :slight_smile:

Ok. Thank you.
I have been reading a bit the links and the question is if it’s possible to use the 4MB RAM. I will have to read more about this.

You already use the full 4MB - Take a look at the partition.csv linked above.

partition size
reserved (not listed in table) 64 kB
NVS 20 kb
OTA data* 8 kB
app0* 1280 kB
app1* 1280 kB
spiffs 1408 kB
coredump 64 kB
total 4096 kB

*For OTA you need 1 OTA Data + 2 APP partitions