This is a follow on from the Setting up Eclipse and Code Sourcery for STM32 Discovery Development. and so assumes you already have Eclipse working with the Code Sourcery Lite tool chain.
What you will need
Atollic True Studio Lite , which can be downloaded for free from the Atollic website here:
Download and Install the Atollic True Studio Lite , this contains within the package a gdbserver which we will use to talk to the STLink on the STM32-Discovery board.
From the Eclipse main menu bar , select Help->Install new software and select the CDT – http://download.eclipse.org/tools/cdt/releases/helios that you set up earlier for the Work with drop down
You need to select C/C++ GDB Hardware debugging as shown below
Now continue on and install the software and restart Eclipse when you are asked.
From the main menu choose Run->Debug configurations…
Now select GDB Hardware debugging and click on the New icon (circled in red below)
Select the Project first and then the C/C++ application with the Search Project.. button and finally give the debugging session a Name.
Which should look something like this after the Apply buttons is pressed :
Next move on to the Debugger Tab and browse to the <code sourcery>\Sorcery G++ Lite\bin folder to select the arm-none-eabi-gdb.exe program, then set the port number to 61234. Then finally click on Apply.
Close the Debug configuration Dialog and go to Run->External tools->External tools configuration…
Browse to the ST-LINK_gdbserver program ( <Atollic>\TrueSTUDIO STM32 Lite 1.4.0\Servers\ST-LINK_gdbserver) in the location field and add the arguments -e -d which tells ST-LINK_gdbserver to run in persistent mode and to use SWD rather than JTAG for debugging.
Now select the Build tab
Uncheck the Build before Launch check box and finally click on Apply.
Now the gdbserver can be started at any time from the Launch external tools tool bar icon shown below:
Starting a debug session
In order to start a debug session for you program you must first make sure the gdbserver is running so the first thing to do is to use the Launch External Tools tool-bar button which we set up previously to start up the gdbserver.
As the gdbserver starts it will output start up information to the console so you can see if it started up all right.
Now start a debug session for you program , From the main menu select Run->Debug Configurations… as before and select the profile you set up previously under GDB Hardware Debugging and click Debug.
The perspective should now switch to the debug perspective , if not you can manually switch to the debug perspective by pressing the debug button on the right hand side of the tool bar.
You are now ready to run and debug your STM32 Discovery program.
As you can see from the above screen shot the gdbserver is listed in the debug process window along with you program. Sometimes the gdbserver may crash or lock up, If that happens you can restart it by right clicking on it and selecting Terminate and Relaunch. If the gdbserver is not listed then you will need to restart it from the external tools tool-bar icon. Usually the gdbserver will only need to be started once after Eclipse has been started.
You will need to create a separate debug profile for each of the projects that you wish to debug.