OpenJTAG and OpenOCD under Eclipse
I bought from soliddepot.com an item named Spruce -SolidDigi STM32 Arduino Compatible Board With LCD
And then I tried to debug the board under Eclipse!
1. Install OpenOCD
![http://i1102.photobucket.com/albums/g458/soliddigi/spruce/1.jpg](http://i1102.photobucket.com/albums/g458/soliddigi/spruce/1.jpg)
Next
![http://i1102.photobucket.com/albums/g458/soliddigi/spruce/2.jpg](http://i1102.photobucket.com/albums/g458/soliddigi/spruce/2.jpg)
Next, unselect “Add the make utils to the PATH variable” under “Make utils”:
![http://i1102.photobucket.com/albums/g458/soliddigi/spruce/3.jpg](http://i1102.photobucket.com/albums/g458/soliddigi/spruce/3.jpg)
Click “next” to continue until finish the installation.
2. Download in command line mode:Copy openocd.cfg to directory “eclipse_projects”.Connect openjtag to the Spruce, and in command line run:
![http://i1102.photobucket.com/albums/g458/soliddigi/spruce/4.jpg](http://i1102.photobucket.com/albums/g458/soliddigi/spruce/4.jpg)
![http://i1102.photobucket.com/albums/g458/soliddigi/spruce/5.jpg](http://i1102.photobucket.com/albums/g458/soliddigi/spruce/5.jpg)
Next “telnet localhost 4444”Type the following command:
![http://i1102.photobucket.com/albums/g458/soliddigi/spruce/6.jpg](http://i1102.photobucket.com/albums/g458/soliddigi/spruce/6.jpg)
Poll: poll spruce status
Halt:stop the spruce board
Stm32x mass_erase 0: mass erase flash
Flash write_image hex with file full path: write program to flash
Reset: reset the spruce
Note: stop the development board, mass erase, and then write the program to flash.
3. Download and debug under Eclipse:
3.1 Configure the connection of Openocd
In menu, Run->External tools->External tools Configurations
Click the following in sequence, Name、Location、Working Directory and thenArguments, click apply
Name openocd
Location openocd-ftd2xx.ex’s full path
Working Directory workspac’s full path
Arguments -f openocd.cfg’s full path
![http://i1102.photobucket.com/albums/g458/soliddigi/spruce/7.jpg](http://i1102.photobucket.com/albums/g458/soliddigi/spruce/7.jpg)
Open Build options, remove “Build before launch” and click “apply”
![http://i1102.photobucket.com/albums/g458/soliddigi/spruce/8.jpg](http://i1102.photobucket.com/albums/g458/soliddigi/spruce/8.jpg)
3.2 Debug configuration:Click the project name ->Run->debug configuration->double click Zylin Embeddeddebug(Native), the following window will show up
![http://i1102.photobucket.com/albums/g458/soliddigi/spruce/9.jpg](http://i1102.photobucket.com/albums/g458/soliddigi/spruce/9.jpg)
Select “Debugger” and add location of the debug tool: CodeSourcery->SourceryG++ Lite->bin->arm-none-eabi-gdb.exe.(Default: C:\Program Files\CodeSourcery\Sourcery G++Lite\bin\arm-none-eabi-gdb.exe)
![http://i1102.photobucket.com/albums/g458/soliddigi/spruce/10.jpg](http://i1102.photobucket.com/albums/g458/soliddigi/spruce/10.jpg)
Open “Commands” option and add the following commands:
target remote localhost:3333
monitor halt
monitor poll
monitor stm32x mass_erase 0
load
monitor reset init
break Reset_Handler
break main
continue
![http://i1102.photobucket.com/albums/g458/soliddigi/spruce/11.jpg](http://i1102.photobucket.com/albums/g458/soliddigi/spruce/11.jpg)
4. Download and debugClick Debug button in eclipse to enter into debug panel, click to openopenocd,and the following information will show up when connected to openjtag:
![http://i1102.photobucket.com/albums/g458/soliddigi/spruce/12.jpg](http://i1102.photobucket.com/albums/g458/soliddigi/spruce/12.jpg)
Click
and select “DebugConfiguration”
![http://i1102.photobucket.com/albums/g458/soliddigi/spruce/14.jpg](http://i1102.photobucket.com/albums/g458/soliddigi/spruce/14.jpg)
Select the file to be debug, and single click “Debug” to begin debug.
![http://i1102.photobucket.com/albums/g458/soliddigi/spruce/15.jpg](http://i1102.photobucket.com/albums/g458/soliddigi/spruce/15.jpg)
Waiting for the program to be downloaded to spruce:
![http://i1102.photobucket.com/albums/g458/soliddigi/spruce/16.jpg](http://i1102.photobucket.com/albums/g458/soliddigi/spruce/16.jpg)
After downloading, click
to run the program, and single click
or F5to single step debug.
![http://i1102.photobucket.com/albums/g458/soliddigi/spruce/17.jpg](http://i1102.photobucket.com/albums/g458/soliddigi/spruce/17.jpg)
We can double click to set breakpoints and debug.
![http://i1102.photobucket.com/albums/g458/soliddigi/spruce/18.jpg](http://i1102.photobucket.com/albums/g458/soliddigi/spruce/18.jpg)
Isn't it nice!