OTA upload on ESP32

@ggggh @Aleksander_Lyse let’s start a new topic regarding OTA:

@ggggh the default password for OTA is OTAPASSWORD, you have to enter it into the Arduino IDE pop up.

Yes, was using that, but kept failing. I think the IDE just keeps asking for the password whatever the connection problem is, usually the return port not being accessible, but may be anything…

It’s possible that the BLE scan conflict with OTA, maybe try with a faster speed like below when using platformio:

upload_protocol = espota
upload_port = 192.168.1.99
upload_flags =
  --auth=OTAPASSWORD
  --port=8266
upload_speed = 921600

One alternative could be to set the interval of BLE scans to a longer period:
https://docs.openmqttgateway.com/use/ble.html#setting-the-time-between-scans-and-force-a-scan

If it is due to BLE scan I will implement a lock when OTA is processing.

Could it be something that writes to the spffs? I checked the log during a lot of ota now, and sometimes I get not enough space on any percentage, but mostly it seems to start failing when mqtt start doing something, maybe bt too. But the W: MQTT connection… debug line comes up in a lot of cases where it fails

[E][ArduinoOTA.cpp:200] _onRx(): 200 was expected. got 0 instead

T: Progress: 66%
T: Progress: 66%
T: Progress: 66%
[E][ArduinoOTA.cpp:285] _runUpdate(): Receive Failed
Error[3]: E: Receive Failed
W: MQTT connection…

And tried again. It makes no sense its out of space after 26%, when the last was 60

T: Progress: 26%

T: Progress: 26%

T: Progress: 26%

T: Progress: 26%

[E][ArduinoOTA.cpp:321] _runUpdate(): Write ERROR: Not Enough Space

Error[4]: E: End Failed

[E][ArduinoOTA.cpp:344] _runUpdate(): Update ERROR: Not Enough Space

W: MQTT connection…

Interesting, I will go in deep from this

I have added a lock flag when OTA is ongoing, you can test it there:

This mechanism prevent the MQTT and BLEScan function from processing when OTA is in progress.

Cherry on the cake now M5Stack and M5StickC display when OTA is in progress.

Hmm, still getting some errors but seems less frequent:

T: Progress: 72%
Error[4]: E: End Failed

@Aleksander_Lyse could you test on your side please to see how it behaves?

In my side even if I deactivate the BT gateway it fails sometimes.

I have tested with Arduino IDE and this branch:

and I got 5/5 success

Just by comparing the commands of PIO:
c:\users\flori\.platformio\penv\scripts\python.exe" "C:\Users\flori\.platformio\packages\framework-arduinoespressif32\tools\espota.py" --auth=OTAPASSWORD --port=8266 --debug --progress -i 192.168.1.17 -f .pio\build\esp32-m5stack-ble\firmware.bin

and Arduino IDE

C:\Users\xi\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/espota.exe -i 192.168.1.17 -p 8266 --auth=OTAPASSWORD -f C:\Users\flori\AppData\Local\Temp\arduino_build_243071/main.ino.bin

The only differences I see are the -debug and -progress options, let’s try to remove them from PIO.

I have done some tests with BasicOTA example and I’m also getting :

15:53:56 [ERROR]: Error Uploading
*** [upload] Error 1 

Seems that this error is not due to OMG

@Aleksander_Lyse could you give me your feedback on this branch please?