Webrepl & ESP32 during running main.py not working

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
astirfreak
Posts: 5
Joined: Mon May 04, 2020 7:14 pm

Webrepl & ESP32 during running main.py not working

Post by astirfreak » Tue May 05, 2020 7:25 pm

Hello,
My last projects I did with an ESP8266 with micropython.

Now I bought a NodeMCU-Board like that one:
Image
I flashed the esp32-idf3-20191220-v1.12.bin on it and it runs now. I enabled webrepl and can connect to the board. Also file transfer is possible.
But in comparison with the ESP8266 it is not possible to connect via webrepl during the main.py is running.
I can connect via webrepl when no script is running. But after starting a python script, it is also not possible to interrupt it with CTRL-C. With putty on the serial port (USB) this works.
Also a file transfer during a running script is not possible.
All issues I have never seen on the ESP8266. Do you have an idea, what the problem is?

Michael

uraich
Posts: 6
Joined: Tue Mar 26, 2019 12:24 pm

Re: Webrepl & ESP32 during running main.py not working

Post by uraich » Sun May 10, 2020 8:49 am

Well, unfortunately I don't know where the problem is. However, I was trying to get the telnet server running on my ESP32. I see that output is working ok but REPL does not seem to ask for input. Then I tried to connect a second serial port to REPL and I have the save effect: output ok but no input. Finally on webrepl it is the same thing. To me it looks like REPL simply does not ask for input on any of the slots except slot 0.
Will try on the ESP8266 as well
Uli
PS: Running newest micropython version from github

astirfreak
Posts: 5
Joined: Mon May 04, 2020 7:14 pm

Re: Webrepl & ESP32 during running main.py not working

Post by astirfreak » Sun May 10, 2020 7:17 pm

Hello,
On the ESP8266, the problem isn't there with the latest Micropython-version 1.12.
If you start Webrepl before starting your script, WebRepl is sending all outputs to the browser and continues after starting the script. That works. But there is no reaction to an input while a script is running.
Also a connect is not possible, while a python script is running.
Today I tried a connect during boot of the ESP32. I received the password prompt but after that, there was no further reaction.

I had some stability issues on the ESP8266 with micropython 1.12, like WDT-resets and resets with undefined reset source (See topic viewtopic.php?f=2&t=8281). Because of that I changed over to the ESP32, but there with different problems.
No idea, if only the current version of micropython is a problem or if there are general problems with my setup.

Michael

astirfreak
Posts: 5
Joined: Mon May 04, 2020 7:14 pm

Re: Webrepl & ESP32 during running main.py not working

Post by astirfreak » Mon May 18, 2020 5:53 pm

I found the problem.
In my main-loop I use

Code: Select all

utime.sleep_ms(10)
If I change this to

Code: Select all

utime.sleep_ms(11)
webrepl works fine.

On an ESP8266, a 10ms sleep makes no problems. Crazy.

Michael

User avatar
tve
Posts: 197
Joined: Wed Jan 01, 2020 10:12 pm
Location: Santa Barbara, CA
Contact:

Re: Webrepl & ESP32 during running main.py not working

Post by tve » Wed May 20, 2020 12:51 am

The obscure reason is that on the esp32 MP uses a clock tick of 100Hz (10ms) and in the sleep code it checks whether less than one tick is left and if so it busy-waits the remaining time. If you call sleep_ms(10) by the time it makes the check a little less than 10ms are left, hence the situation you're observing.

Post Reply