GDB and Jlink on Eclipse in Linux

This tutorial will show how to configure eclipse as a gdb client connecting to the Segger JTAG gdb server on Linux.

We assume that:

  • OpenWSN projects are already configured in your PC
  • You are able to compile OpenWSN firmware with Scons
  • You are familiar with eclipse and it is installed in your PC
  • You have the arm gnu toolchain installed and configured accordingly to be able to compile OpenWSN.
  • In the example we will be using OpenMote CC2538 but this might work with slight variations with other boards.

As we will be using a Segger Jlink (the presented procedure might work with other Debuggers with similar configuration steps) we need to install the gdb server and tools provided by them.

Download and install the latest jlink toolset from Segger website.

 

sudo dpkg --install jlink_4.84.6_x86_64.deb

Then, execute the Jlink GDB Server by executing:

/opt/SEGGER/JLink/JLinkGDBServer -device CC2538SF53

This command executes the JLinkGDBserver to debug a CC2538SF53 device, which is the one we use for the OpenMote-CC2538 board. It is mandatory to include the “-device CC2538SF53” parameter since the Segger JLink needs to configure the CC2538 chip for standard JTAG operation (4 wire) instead of the new cJTAG (2 wire). You should see a dialog similar to the one depicted next where the JLinkGDBServer waits for a connection from the GDB client.

 

Now in eclipse we need to configure the GDB client to connect to this server. First we need to enable HW debugging capabilities (if not already enabled). To do so we will install a plugin.

Go to Helo -> Install new Software and look for GDB Hardware Debugging

Install the plugin and restart eclipse. Next we will go to Run->Debug Configurations and we will add a new Hardware Debugging configuration.(Note that we are using the Legacy GDB mode which can be changed by clicking the select other label at the bottom. )

The C/C++ Application should point to the .elf file generated by the compiler, e.g the output of the Scons command that produces the _prog file. 

The debugger tab should be as presented in the above image. And the startup window should be as follows:

Important to remark that the Use file section should point to the .elf file that has to be uploaded. E.g:  $OPENWSN_HOME/firmware/openos/projects/common/cc2538/03oos_openwsn_prog

monitor interface jtag
monitor speed 5000
monitor endian little
monitor flash download = 1
monitor flash breakpoints = 1

The text area should contain the above information.

Click Apply and then Debug. Make sure the mote is connected to the JTAG and that the JTAG is connected to the PC and JLinkGDBServer is running. Place a breakpoint somewhere in your code and Press run on the debugger button.

And that's it! As easy as in Windows!