Debug main.py at runtime

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
rp346@njit.edu
Posts: 18
Joined: Sun Sep 16, 2018 6:33 pm

Debug main.py at runtime

Post by rp346@njit.edu » Fri Nov 23, 2018 2:16 pm

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
- roy

HermannSW
Posts: 197
Joined: Wed Nov 01, 2017 7:46 am
Contact:

Re: Debug main.py at runtime

Post by HermannSW » Fri Nov 23, 2018 5:22 pm

> 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.
Pico-W Access Point static file webserver:
https://github.com/Hermann-SW/pico-w

Tiny MicroPython robots (the PCB IS the robot platform)
viewtopic.php?f=5&t=11454

webrepl_client.py
https://github.com/Hermann-SW/webrepl#webrepl-shell

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Debug main.py at runtime

Post by pythoncoder » Sat Nov 24, 2018 6:04 am

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.
Peter Hinch
Index to my micropython libraries.

Post Reply