Debugging from GDB

28 views
Skip to first unread message

Michael Pratt

unread,
Oct 17, 2012, 7:06:15 PM10/17/12
to ncsu-lug-os...@googlegroups.com
With stlink installed, you can use the st-util utility to start a GDB server with which to debug the STM32F4 Discovery.

You will probably want to add the stlink folder to your PATH, so that you can invoke it from anywhere.

With your STM32 connected, run st-util to start a GDB server.

st-util

This will establish a connection with the board and communicate between the board and GDB.  Fire up GDB, and connect to the server you start started.

arm-none-eabi-gdb
target remote localhost:4242

That last command can be shortened to 'tar rem :4242'.  Finally, if you have compiled your binary with debugging symbols ('-g' or '-g3' in GCC), you can load the symbols into GDB so that you can view the source and symbols as you execute.

file os.elf

Now you should be good to go to watch your program execute.  Some neat commands you may wish to use are 'info regs' to view the registers, and 'layout asm', 'layout source', and 'layout split' to view the source and assembly that is executing.

If you want to avoid all of that setup each time you open GDB, you can add my little alias to your bashrc, which takes your symbol file as an argument and starts up st-util and GDB to be fully ready to run.

alias stm32-gdb='st-util &> /dev/null & arm-none-eabi-gdb -q -ex "tar rem :4242" --symbol \!^'
Reply all
Reply to author
Forward
0 new messages