Hello!
I have just started using MicroPython on a custom PCB with ESP32-WROOM-32, and everything seems fine except... I don't know how to update the python files once I have a working main.py. As is the case in most embedded applications, my main.py has an infinite loop, and so I never get the REPL.
How do I update main.py (or access the filesystem in general) if I no longer have access to the REPL? Do I need to do a firmware flash every time I want to update the file? How are people working around this?
Thanks
Matthew
Updating main.py with infinite loop
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: Updating main.py with infinite loop
You could use rshell which stops the working loop and then uploads the file, then you disconnect and reset the device.
Or you use the webrepl to upload your main.py.
Or are you asking for a completely automated update of the main.py file?
Or you use the webrepl to upload your main.py.
Or are you asking for a completely automated update of the main.py file?
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
-
- Posts: 169
- Joined: Fri Aug 19, 2016 11:55 am
Re: Updating main.py with infinite loop
By “no longer have access to the REPL”, do you mean that you explicitly detached the UART from stdin/out (using dupterm)? Because if not, you can just send a control-C through the UART and that will break out of your infinite loop and drop you in the REPL – same as in CPython on the desktop.
And yes, if you have it enabled, WebREPL also works for both uploading files and sending ctrl-C even while your infinite loop is running.
And yes, if you have it enabled, WebREPL also works for both uploading files and sending ctrl-C even while your infinite loop is running.
Re: Updating main.py with infinite loop
To elaborate on what Kevin said, sending a Ctrl-C (whether interactive or just by literally sending 0x03 to the serial console) should terminate any code that is running.
Re: Updating main.py with infinite loop
Unless the code disabled interrupt by Ctrl-CTo elaborate on what Kevin said, sending a Ctrl-C (whether interactive or just by literally sending 0x03 to the serial console) should terminate any code that is running.
-
- Posts: 3
- Joined: Thu Oct 24, 2019 12:34 am
Re: Updating main.py with infinite loop
Thanks guys! I didn't realise uploading through WebRepl still worked even when the prompt doesn't. I thought it was just a convenience mechanism that uses the repl prompt to receive and save the file.
I also didn't realise Ctrl-C still works!
Thanks!
I also didn't realise Ctrl-C still works!
Thanks!