Debugger for Micropython

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
User avatar
ta1db
Posts: 53
Joined: Mon Sep 02, 2019 12:05 pm
Contact:

Re: Debugger for Micropython

Post by ta1db » Wed Sep 18, 2019 10:21 am

jimmo wrote:
Tue Sep 17, 2019 6:43 am
I use gdb on STM32 boards quite frequently and find it extremely useful.
@jimmo openocd is a nice tool and worked well with st_nucleo_f4.cfg as well running micropython . However my configuration and run is slightly different than the code you've shared.

Thanks again.

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

Re: Debugger for Micropython

Post by jimmo » Wed Sep 18, 2019 11:08 am

ta1db wrote:
Wed Sep 18, 2019 10:21 am
However my configuration and run is slightly different than the code you've shared.
I wrote that off the top of my head on my phone so it's possible that it's wrong? Can you post a corrected version, if that might be useful to other people reading this thread.

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

Re: Debugger for Micropython

Post by ta1db » Sat Sep 21, 2019 8:51 am

jimmo wrote:
Wed Sep 18, 2019 11:08 am
Can you post a corrected version, if that might be useful to other people reading this thread.
Okay,

Official website for OpenOCD (Open On Chip Debugger) is: http://openocd.org/
Version 0.10.0 is available here: https://sourceforge.net/projects/openoc ... cd/0.10.0/
Windows users may prefer windows binaries available here : http://www.freddiechopin.info/en/downlo ... /4-openocd

I downloaded windows binaries. It doesn't need any installation. Simply extract the zip file wherever you want, then go to PATH_TO_INSTALL_DIR\openocd\scripts\board and search the config file for your particular board. Mine was stm32f7discovery and st_nucleo_f4.cfg As far as I see there are too many config options for several boards, chips, fpga, interface ... A User's guide also exits. Notice that 2 sets of binaries exist for 32 bit and 64 bit in \bin and \bin-x64 directories. On my 64 bit machine both sets worked well.

On Linux and OsX, installation, configuration and running should be different, you may get inspiration from this video: https://youtu.be/R5wub5ywzTU

Let's go ahead ;

Connect your board and test it is connected and communicating normally.

Code: Select all

>cd PATH_TO_INSTALL_DIR\openocd
>bin\openocd -f board/YOUR_BOARD.cfg #for 64 bit you may try bin-x64

if all right, you will see some messages on the command screen telling that the openocd is connected to your board and waiting for a telnet connection.

Then open another command screen and

Code: Select all

>telnet localhost 4444 #you have to have telnet installed


alternatively you may use PuTTY and establish a telnet connection to hocalhost over 4444 port.

if still all right, on the second command screen you will see

Code: Select all

Open On-Chip Debugger
>
OpenOCD is waiting commands from you. Don't enter "help", it prints an encyclopedia on the screen :lol: directing output to a file with "help > openocd_help.txt" looks like working but I couldn't find the output file.

OpenOCD is a very capable tool so I recommend you to look at its manual and other documents to see what is possible. I will give you some examples:

Code: Select all

> targets 
this prints info on connected targets
> flash banks
> reg
> reg r0
these print corresponding info on registers respectively 

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

Re: Debugger for Micropython

Post by jimmo » Sun Sep 22, 2019 2:37 am

Thanks for that!

The main difference is that instead of using openocd directly (which is definitely useful for things like flashing and device configuration), I'm using gdb to drive it instead. Quite often you'll end up using both.

Post Reply