Skip to content

[Arduino OTA] Python consuming 25% of an I5 processor - Showing error in IDE after upload #4966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rtek1000 opened this issue Jul 27, 2018 · 15 comments
Assignees
Labels
component: OTA waiting for feedback Waiting on additional info. If it's not received, the issue may be closed.

Comments

@rtek1000
Copy link

rtek1000 commented Jul 27, 2018

Hello,

I'm trying the Arduino OTA (built-in - Arduino IDE 1.8.5), and at some point I can note that after the upload is done, python gets stuck. The esp8266 program works normally, but the IDE returns error after a while.

When the Arduino IDE informs that the upload was done correctly, in the task manager (Win7 x64) I can see that python was consuming little processing, about 1% (of the Intel I5 processor). And after the IDE shows the upload completion message, python exits.

But when the IDE does not show the completion message as soon as the upload is done, then by looking at the task manager, I can see python consuming about 25% processing.

And after a long time the IDE shows an error, then the processor is released and I can notice that until the ventilation returns to the normal state.

When python is consuming 25% of processing, if I terminate the python process in the task manager, everything returns to normal, but the IDE shows error.

Is this problem caused in python or in IDE?

How does this interaction between IDE and Python work?

Thank you.

@rtek1000
Copy link
Author

Note, the python version I installed was the 2.7.10 (x64) I saw now that has version 2.7.15, I'll try: https://www.python.org/downloads/

@SWR-DMaster
Copy link

SWR-DMaster commented Aug 10, 2018

Hi rteck,

I, too, am having this issue; though at 15% cpu per instance.
I found this post with a user having 100%, same issue. 4746

Using an EPS-201 off e-bay here but hangs most of the time after an OTA.
I am loading to the ESP via OTA while the ESP is an AP.
Have had concerns the ESP rebooting and losing the AP was causing the issue but now know better.

Hopefully there will be a solution soon.

Thanks,
SWR_DMaster

@rtek1000
Copy link
Author

Hi,

Now I'm using Linux instead of Windows, it's faster for builds and I did not have that problem with phyton until now.

Using Lubuntu 18.04 running in a VirtualBox.

I'm also using the Arduino Pro Mini instead of ESP8266, I'm using ESP8266 with "esp-link" just to reprogram the Arduino flash memory.

https://github.com/jeelabs/esp-link

Operating in similar way to Arduino UNO Wifi:

https://github.com/jeelabs/esp-link/issues/394

Sometimes the IDE, the PING command, and the browser do not quickly find the ESP8266. But I can see in the settings of my router the IP address of the ESP8266. Maybe mDNS or another service is not working very well yet (This happens in Windows and Linux, however it seems that in Linux it solves a little faster).

Thanks.

@d-a-v
Copy link
Collaborator

d-a-v commented Sep 13, 2018

Can you try with #5135 ?

@d-a-v d-a-v self-assigned this Sep 13, 2018
@d-a-v d-a-v added component: OTA waiting for feedback Waiting on additional info. If it's not received, the issue may be closed. labels Sep 13, 2018
@gordoste
Copy link

I am experiencing a very similar issue. I am running Windows 7 with PlatformIO and NodeMCU ESP8266 (ESP-12E).
#4746 seems similar but a little different as that user's espota.py NEVER came back, and it was intermittent. My issue occurs ALL the time.

The OTA update is completes successfully, but espota.py simply times out while waiting for the result. I ran WireShark on my PC and can see that no TCP packet with "OK" message from the OTA client gets to my PC. I can see all of the earlier ones saying how many bytes were received.

I tried adding #5135 in WifiClient.cpp but it didn't help. (In fact, I already tried doing flush() between client.print("OK") and client.stop() in ArduinoOTA.cpp before looking here for help!)

@gordoste
Copy link

I have just found that putting delay(1000) between client.print("OK") and client.stop() in ArduinoOTA.cpp makes it work. I guess the Wifi module was not getting a chance to get the data out.
Obviously, this is a very dirty kludge, but hopefully it helps you understand what is going on.

@d-a-v
Copy link
Collaborator

d-a-v commented Sep 22, 2018

Could you make another tcpdump so we can check on the real delay ?
Current version of flush() only wait for 10ms at most. It is probably too short and should be increased and configurable.

@d-a-v
Copy link
Collaborator

d-a-v commented Sep 23, 2018

@gordoste any chance you can try #5089 ?
There is now a fair timeout for TCP flushing before stop among other changes (of course without your delay).

@gordoste
Copy link

This fixes the issue, however the OTA update is much slower. Perhaps the timeout is being triggered before stop()?

@d-a-v
Copy link
Collaborator

d-a-v commented Sep 23, 2018

I could reproduce and this is fixed by client.setNoDelay(true) in OTA code (because now Nagle is working, and in the OTA protocol the ESP sends lots of sparse small packets).
You may please retry it, again without your delay.
I hope you can dedicate your i5 busy core back to something more productive.

@gordoste
Copy link

Perfect! That does fix everything. Will the client.setNoDelay(true) be included in the master version?

@d-a-v
Copy link
Collaborator

d-a-v commented Sep 24, 2018

Should we understand that you tried again #5089 and got success ?
In that case, thanks for the feedback !
The OTA fix will probably be integrated since we have your confirmation

@gordoste
Copy link

gordoste commented Sep 25, 2018

Yes, I tried #5089 and added client.setNoDelay(true) AFTER client.connect() in ArduinoOTA::runUpdate()

This makes the update work at normal speed AND the “OK” message is successfully sent to PC.

@washcroft
Copy link

@d-a-v see #4283 (comment)

@earlephilhower
Copy link
Collaborator

This was fixed with the referenced PR #5089 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: OTA waiting for feedback Waiting on additional info. If it's not received, the issue may be closed.
Projects
None yet
Development

No branches or pull requests

6 participants