SEARCH
TOOLBOX
LANGUAGES
modified on 6 April 2012 at 19:39 ••• 24,985 views

Using Eclipse/4

From Manuals

Jump to: navigation, search

Contents

Debugging using Eclipse

OpenOCD

OpenOCD is open source application designed to assist in the debugging of embedded target devices and will provide a debugging interface to our device by acting as a GDB Server. It is necessary to have OpenOCD running before beginning a debug session. Eclipse can make this easier by configuring it as an external tool. To do this, select ‘Run,’ ‘External Tools,’ ‘External Tools Configurations…’ and double-click on ‘Program’ to create a new program configuration. Specify the name, location, and working directory of your OpenOCD configuration. Advance to the ‘Build’ tab, unselect ‘Build before launch,’ click ‘Apply’ and then ‘Close.’

Configuring OpenOCD
Figure 7 – Configuring OpenOCD as an external tool

To run OpenOCD, click the ‘Run Last Tool’ icon and select OpenOCD. This only needs to be done once you begin a new Eclipse session as OpenOCD will remain running until Eclipse exits. Any output printed by OpenOCD can be viewed in the console tab. WARNING: Eclipse sometimes does not close OpenOCD when debugging is finished. In order to open a new debugging session OpenOCD's process needs to be shutdown using Windows Task Manger.

Running OpenOCD
Figure 8 - Starting OpenOCD

Debug Configuration

Before beginning a debug session, a debug configuration must be made describing how Eclipse will handle debugging the application. To do this, right click on the project you wish to debug, select ‘Debug As,’ ‘Debug Configurations,’ and double-click ‘Zylin Embedded debug (Native)’ to create a new configuration. Specify the name for this configuration and browse to the application binary for this project.

New Debug Configuration
Figure 9 – Creating a new debug configuration

Advance to the ‘Debugger’ tab and if necessary, change the GDB debugger to match your toolchain. Advance to the ‘Commands’ tab and enter the following for the initialization commands for the Eagle 50:

target remote localhost:3333
monitor jtag arp_init
monitor reset init
b main
load

Enter the following for the initialization commands for the Lincoln 60:

target remote localhost:3333
monitor jtag arp_init
monitor reset init
b main
load
monitor reg pc 0x00000000

Enter the following for the run commands for the Eagle 50:

j ResetISR
GDB Commands
Figure 10 – Specifying GDB commands

Click ‘Apply’ and ‘Close’ to complete the debug configuration. Debugging To begin a new debug session, click the arrow next to the Debug icon and select ‘Debug Configurations…’

Running Debug
Figure 11 – Running a debug configuration

Click ‘Debug’ and click ‘Yes’ when Eclipse prompts you to move to the debug configuration. Your perspective should look similar to the figure below. The Resume, Suspend, Terminate, Step Into, and Step Over buttons are highlighted in red.

Debugging Perspective
Figure 12 – Eclipse’s debug perspective

The program should be stopped at the first instruction in main. This is due to specifying the breakpoint main as one of the debug initialization commands. You can view your source code in the center of the screen and navigate through the project in the Outline tab on the right. Details about your current debug configuration can be seen in the Debug tab in the upper left hand corner. Current variables, breakpoints, and register values can be seen in their corresponding tabs in the upper right hand corner. Console output can be viewed in the Console tab at the bottom. To step to the next instruction, click the ‘Step Over’ icon. To step to the next assembly instruction, click the ‘Instruction Stepping Mode’ icon and click the ‘Step Over’ icon. Assembly code can then be viewed on the right next to the Outline tab. To insert a breakpoint, double-click on the bar to the left of the instruction that you wish to break at. To add a breakpoint condition, right click on the breakpoint and select ‘Breakpoint Properties,’ ‘Common,’ and enter the breakpoint condition. To watch an expression, select the variable, right click, and select ‘Add watch expression…’ The expression can then be viewed in the Expressions tab in the upper right hand corner of the screen. The Resume, Suspend, and Terminate buttons can simply be used to continue, break, or end the debugging session.

Debugging the Eagle 50s Blinky example application

Please follow these steps to debug the Eagle 50s blinky example application using open OCD for the first time:

  • 1. Open the Eclipse IDE.
  • 2. When prompted browse to.
  • 3. Click 'OK'.
  • 4. Press the 'F5' key on the keyboard to refresh the files.
  • 5. Close all of the open projects by right clicking on the project and selecting "Close Project".
  • 6. Open the blinky project by right clicking on the project and selecting "Open Project". If the Sourcery G++ Lite compiler is not installed and devkitARM is installed then click on "Window>Preferences>C/C++>Build>Environment" and add a variable called "COMPILER" with the value set to "devkitARM".
  • 7. Right click on the blinky project and select build. If the project builds correctly then continue.
  • 8. Right click on the blinky project and select "Debug As>Debug Configurations".
  • 9. Double-click "Zylin Embedded debug (Native)" to create a new configuration.
  • 10. Browse for the blinky out file by clicking on the "Browse" button next to the "Search Project" button. The directory should be "blinky.out".
  • 11. Click on the "Debugger" tab. If necessary change the GDB debugger to match your tool chain For Sourcery G++ Lite browse to "%INSTALLDRECTORY%\CodeSourcery\Sourcery G++ Lite\bin\arm-none-eabi-gdb.exe".
  • 12. Click on the "Commands" tab.
  • 13. Type the following in the "Initialze" commands window:
    target remote localhost:3333
    monitor jtag arp_init
    monitor reset init
    b main
    load
  • 14. Type "j ResetISR" in the "'Run' commands" tab.
  • 15. Click "Apply".
  • 16. Close the debug configuration.
  • 17. Open Windows Explorer and browse to "C:\Program Files\Micromint\Tools\openocd" and click on "openocd-eagle" btch file to start open OCD and a screen similar to Figure 13 should open and stay open. If the window does not stay open then the computer could not find the Eagle 50. If Windows Firewall asks if you wish to keep blocking this program click on "Unblock".
Open OCD for Eagle 50
Figure 13 – Eagle 50 Open OCD screen
  • 18. In the Eclipse IDE click on the arrow next to the bug icon and select "1 Blinky Default" to start debugging .
  • 19. Click the green arrow again and the program will start running.
  • 20. Scroll down to "LED_PORT_DATA_R |= LED_PIN;" instruction and click next to it to insert a break point. The program should stop running.
  • 21. If you click the green arrow again the program will start running and will stop at the "LED_PORT_DATA_R |= LED_PIN;" instruction.
  • 22. Press the red square to halt the debugging session.

If at any time power is lost or the reset button is pushed on the Eagle 50 board the OpenOCD-Eagle window needs to be closed and the steps starting at number 17 have to be repeated.

Debugging the Lincoln 60s Blinky example application

Please follow these steps to debug the Lincolns blinky example application using open OCD for the first time:

  • 1. Open the Eclipse IDE.
  • 2. When prompted browse to "%USERPROFILE%\Projects\Micromint\Lincoln" .
  • 3. Click 'OK'.
  • 4. Press the 'F5' key on the keyboard to refresh the files.
  • 5. Close all of the open projects by right clicking on the project and selecting "Close Project".
  • 6. Open the blinky project by right clicking on the project and selecting "Open Project". If the Sourcery G++ Lite compiler is not installed and devkitARM is installed then click on "Window>Preferences>C/C++>Build>Environment" and add a variable called "COMPILER" with the value set to "devkitARM".
  • 7. Right click on the blinky project and select build. If the project build correctly then continue.
  • 8. Right click on the blinky project and select "Debug As>Debug Configurations".
  • 9. Double-click "Zylin Embedded debug (Native)" to create a new configuration.
  • 10. Browse for the blinky elf file by clicking on the "Browse" button next to the "Search Project" button. The directory should be "%USERPROFILE%\Projects\Micromint\Lincoln\CMSIS\projects\blinky\lincoln-all\gcc\blinky.elf".
  • 11. Click on the "Debugger" tab. If necessary change the GDB debugger to match your tool chain For Sourcery G++ Lite browse to "%INSTALLDRECTORY%\CodeSourcery\Sourcery G++ Lite\bin\arm-none-eabi-gdb.exe".
  • 12. Click on the "Commands" tab.
  • 13. Type the following in the "Initialze" commands window:
     target remote localhost:3333
     monitor jtag arp_init
     monitor reset init
     b main
     load
     monitor reg pc 0x00000000
     c
  • 14. Click "Apply".
  • 15. Close the debug configuration.
  • 16. Open Windows Explorer and browse to "C:\Program Files\Micromint\Tools\openocd" and click on "openocd-lincoln" btch file to start open OCD and a screen similar to Figure 13 should open and stay open. If the window does not stay open then the computer could not find the Lincoln 60. If Windows Firewall asks if you wish to keep blocking this program click on "Unblock".
Open OCD for Lincoln 60
Figure 13 – Lincoln 60 Open OCD screen
  • 17. In the Eclipse IDE click on the arrow next to the bug icon and select "1 Blinky Default" to start debugging .
  • 18. Click on the green arrow to start the program.
  • 19. Scroll down to line 71 (the first for loop) and click next to it to insert a break point. The program should stop running.
  • 20. If you click the green arrow again the program will start running and will stop at line 71 again.
  • 21. Press the red square to halt the debugging session.

If at any time power is lost or the reset button is pushed on the Lincoln 60 board the OpenOCD-Lincoln window needs to be closed and the steps starting at number 16 have to be repeated.