You are here
Home > embedded >

Debugging in Eclipse Using OpenOCD on Ubuntu

This is second part of ongoing tutorial on setting up GCC + Eclipse + OpenOCD environment for use with the SAME54 Xplained pro board on latest Ubuntu system. In order to be able to follow this blog entry you must already have the gcc-arm toolchain and openOCD configured

When we talk about debugging it is important to know that the actual “debugger” or emulation hardware is “on chip” and is called the “on chip debug” (OCD) hardware. While there are other methods to debug your embedded code using DDD, Kgdb, & Gdb on Ubuntu in this post will see debugging using Eclipse.

Prerequisite – Download and install the latest version of Eclipse (open-source integrated development environment). Compile and install openOCD (Free and Open On-Chip Debugging, In-System Programming and Boundary-Scan Testing). Eclipse along with OpenOCD is an ultimate opensource alternative to the MPLAB IDE and Atmel Studio IDEs.

Make Eclipse Settings Right

Then Install the GNU MCU plugin from the Eclipse Marketplace. Go to Help>Marketplace then search for “GNU”.

Configure the Eclipse global path location.

Go to Window>Preferences or type ‘OpenOCD’ in the search box and select Global, Leave Executable as is if it says ‘openocd’, otherwise add ‘openocd’. For the path, browse to the location where you installed it.

Select the project that you have download in previous step and create Makefile project with the existing code.

Enter a name for the project then browse to the location where you extracted downloaded AtmelStart project. Choose ARM Cross GCC for the toolchain.

Edit the project properties (go to Project>Properties) and select ‘C/C++ Build’ and change the Build Directory location to “gcc” as shown bleow

This should update the ‘Build directory’ path to ${workspace_loc:/RTC_Event/gcc}

Now you can build the project. Since this is first time using eclipse and we have selected to create makefile project, At this stage, there is chance that you can see following two errors.

arm-gcc not found – this could be because you have not set PATH variable, and the arm-gcc bin path is not set in Eclipse. Set this under global preference in eclipse, in my case gnu toolchain is kept in /usr/lib/. Make sure you give path till /bin. go to (Window →) Preferences → MCU → Global ARM toolchains Path (or Workspace ARM toolchains Path) it should look as follows –

Now try to build the project. This time project build is success from command line using ubuntu terminal but it is failing in eclipse with following error :

 "all" terminated with exit code 127
clean terminated with exit code 127

This could be because we have to select GNU parser under settings->binary parser and set to ‘GNU elf parser’ from default ‘elf parser’

With these settings your makefile project must compile successfully.

OpenOCD Settings in Eclipse

Let us setup OpenOCD by configuring the debug settings in Run>Debug Configurations.

1 Double-click on ‘GDB OpenOCD Debugging’. This will create a target with the same name as your project. OpenOCD setting will be here.

2. In the Config options field, we need to add a line to point to the target board script. Here we will give absolute path for OpenOCD location.
For example:
-f ${openocd_path}/tcl/board/atmel_same54_xplained_pro.cfg

All other options can be left alone.

Now hit debug button in eclipse. If you encounter “Error: unable to open CMSIS-DAP device” then it is very likely that you need to run eclipse as “sudo”. To solve this error as explained in previous blog entry, close eclipse and start it using $ sudo eclipse

Happy debugging using eclipse and openOCD.

Few steps are referred from microchip developer site. More detailed descriptions at Eclipse.

2 thoughts on “Debugging in Eclipse Using OpenOCD on Ubuntu

  1. I have noticed you don't monetize neudeep.com, don't waste
    your traffic, you can earn extra cash every month with new monetization method.
    This is the best adsense alternative for any type of website (they approve all sites), for more details
    simply search in gooogle: murgrabia's tools

Leave a Reply

Top
%d bloggers like this: