Page 1 of 1

Debug main.py at runtime

Posted: Fri Nov 23, 2018 2:16 pm
by rp346@njit.edu
Hi,

How do I debug main.py file at runtime. I am in a situation where I have boot.py and main.py on ESP32 running micropython.

When the board starts up boot.py works perfectly because ESP32 connects to WIFI. But main.py which has application code doesn't run (my assumption). If I run main.py manually with following command it works, but not by the system itself.

Code: Select all

ampy -p /dev/tty.SLAB_USBtoUART run main.py
Anyone know how can I debug main.py ?

Thanks

Re: Debug main.py at runtime

Posted: Fri Nov 23, 2018 5:22 pm
by HermannSW
> Anyone know how can I debug main.py ?
>
Write a file as 1st step in main.py (f=open("main.dbg","w") ...), then power cycle module and see (uos.listdir()) whether file was written or not.

Re: Debug main.py at runtime

Posted: Sat Nov 24, 2018 6:04 am
by pythoncoder
The best approach is to put your code into a module and debug that at the REPL. When it's working, adapt main.py simply to import and run your module. That way main.py is extremely simple.