Debugger for Micropython

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
nikhiledutech
Posts: 118
Joined: Wed Dec 27, 2017 8:52 am

Debugger for Micropython

Post by nikhiledutech » Fri Jan 19, 2018 12:15 pm

Hello,

I am currently using STM32F407disc. I wanted to know, can we debug micropython code using eclipse or any other software. If yes, is their any documentation available for debugging code. Or if you have done micropython debugging, kindly help me.

Thank you

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Debugger for Micropython

Post by dhylands » Fri Jan 19, 2018 4:19 pm

There is currently not any support for debugging at the python level. You could run a debugger to debug at the C code level which is no different fort micropython than any other C program.

nikhiledutech
Posts: 118
Joined: Wed Dec 27, 2017 8:52 am

Re: Debugger for Micropython

Post by nikhiledutech » Sat Jan 20, 2018 9:57 am

Hello,

So is their any steps available to debug the code at C code level for micropython ?

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: Debugger for Micropython

Post by deshipu » Sat Jan 20, 2018 7:57 pm

Well, since MicroPython is a regular C application, you can use the same tools and procedures you would use for debugging any other C code on the particular platform, such as jtag or swd for the ARM chips, for example.

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

Re: Debugger for Micropython

Post by pythoncoder » Sun Jan 21, 2018 7:24 am

@nikhiledutech I don't know your level of experience so apologies in advance if my comment below is stating the obvious.

Running MicroPython under a C debugger will enable you to examine the operation of the Python VM, but that's a long stretch from debugging problems in your MicroPython source code. The compiler converts your code to bytecode and the VM interprets the bytecode. Tracing the operation of the VM is conceptually a long way from diagnosing (say) a problem with a socket receiving unexpected data.

My personal view is that the interactive nature of Python reduces the need for a debugger, but evidently many disagree.
Peter Hinch
Index to my micropython libraries.

User avatar
ta1db
Posts: 53
Joined: Mon Sep 02, 2019 12:05 pm
Contact:

Re: Debugger for Micropython

Post by ta1db » Tue Sep 17, 2019 6:11 am

nikhiledutech wrote:
Fri Jan 19, 2018 12:15 pm
Hello,

I am currently using STM32F407disc. I wanted to know, can we debug micropython code using eclipse or any other software. If yes, is their any documentation available for debugging code. Or if you have done micropython debugging, kindly help me.

Thank you
I use STMStudio for debugging my micropython stm32 projects in python level. STMStudio can connect even simultaneously while I am connected to the board and coding with rshell or uPyCraft on the same usb connector. For this, you have to know and insert memory address of registers which you want to watch. You can either use processors' user manuals or simply code import stm, help(stm) to see the addresses.

This way you can debug by tracing all memory locations however I am still looking for a better way to make debug as to see core registers as well and with start, stop, single step etc. possibilities.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Debugger for Micropython

Post by jimmo » Tue Sep 17, 2019 6:43 am

I use gdb on STM32 boards quite frequently and find it extremely useful.

If you compile with debug symbols (either `make DEBUG=1` or add `-g` to CFLAGS), then you can do interactive line-by-line debugging. It works really well.

My setup is to either use stlink (either a dongle or one of the st dev boards with the built-in stlink), connected via openocd to arm-none-eabi-gdb.

e.g.

Code: Select all

make BOARD=XYZ DEBUG=1 deploy-stlink
openocd -f interface/stlink-v2.cfg  -f target/stm32f7x.cfg  (in another terminal)
arm-none-eabi-gdb build-XYZ/firmware.elf
target remote localhost:3333
I also sometimes use my Black Magic Probe instead of the stlink. Can very highly recommend it.

stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

Re: Debugger for Micropython

Post by stijn » Tue Sep 17, 2019 7:19 am

With the recent addition of sys.settrace we're one step closer to a Python-level debugger..

User avatar
mattyt
Posts: 410
Joined: Mon Jan 23, 2017 6:39 am

Re: Debugger for Micropython

Post by mattyt » Tue Sep 17, 2019 2:17 pm

For reference, @stijn is referring to PR 5026.

stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

Re: Debugger for Micropython

Post by stijn » Tue Sep 17, 2019 3:48 pm

Yes that's it.
I briefly tinkered with it and it's fairly easy to implement 'break when line in file y is hit' and print a stacktrace, but inspecting variables seems harder because not all features for that are implemented yet.

Post Reply