Debugger for Micropython
-
- Posts: 118
- Joined: Wed Dec 27, 2017 8:52 am
Debugger for Micropython
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 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
Re: Debugger for Micropython
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.
-
- Posts: 118
- Joined: Wed Dec 27, 2017 8:52 am
Re: Debugger for Micropython
Hello,
So is their any steps available to debug the code at C code level for micropython ?
So is their any steps available to debug the code at C code level for micropython ?
Re: Debugger for Micropython
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.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Debugger for Micropython
@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.
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.
Index to my micropython libraries.
Re: Debugger for Micropython
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.nikhiledutech wrote: ↑Fri Jan 19, 2018 12:15 pmHello,
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
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.
Re: Debugger for Micropython
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.
I also sometimes use my Black Magic Probe instead of the stlink. Can very highly recommend it.
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
Re: Debugger for Micropython
With the recent addition of sys.settrace we're one step closer to a Python-level debugger..
Re: Debugger for Micropython
For reference, @stijn is referring to PR 5026.
Re: Debugger for Micropython
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.
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.