How to set up an Eclipse and GNU gcc based toolchain to build and debug your Renesas RX based project on Linux (part 3)

This is part 3 of how to set up your GNU gcc based toolchain for your Renesas RX project. In this article I will explain how to install the CDT plugin into Eclipse and how to set up the debugging that Eclipse will work with your J-Link GDB-server and your Renesas RX target.

The other parts are:

After part 2, you have a working gcc to compile a project and we can start our J-Link gdb server which connects to the target.

The next step is to download Eclipse. In this how-to I will use Eclipse Kepler. After extracting and starting Eclipse, you have to install the CDT plugin:

  • Under the help menu choose the point “Install new software”.
  • Add the repository http://download.eclipse.org/tools/cdt/releases/kepler
  • Choose the features (C/C++ Development Tools, C/C++ GCC Cross Compiler Support, C/C++ GDB Hardware Debugging, C/C++ Enhanced Memory View)
Eclipse install new software dialog

Eclipse install new software dialog

After installing the CDT plugin, you have to create a new project: Under File->New->Project, create a new C project. Choose the project type as Executable->Empty Project and for the toolchain choose “Cross GCC”.

In the next dialog you have to enter your cross compiler prefix. If you used the same prefix as I used in part 1, the prefix is “rx-elf-” and the cross compiler path is “/opt/rx-elf/bin”. After pressing the button to finish the dialog, you should end up with an empty project.

To make your first steps, you can again use Andrew Karpow’s GR-Sakura template, which I mentioned earlier in part 1. Just copy the “src”-folder and the file gr-sakura.ld into your project tree and try to build the project. In the console window, you should see the compiler output and that the build was finished. A new folder “Debug” should be in your project tree. After that, you should move the file “gr-sakura.ld” into this new “Debug” folder and tell the linker to use it. You can do this in Project->Properties in the Properties Dialog under C/C++ Build->Settings. Here in the tool settings for Cross GCC Linker, you should modify the command to “gcc -T gr-sakura.ld”. The flag “-T gr-sakura.ld” tells the linker to use this linker script. Since the linker command is executed inside the “Debug” directory inside your project tree, the linker script has to be located there.

Aditionally, in the tool settings for Cross GCC Linker under expert settings, you should modify the command line pattern from

${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}

to

${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT}.elf ${INPUTS}

which will produce a file with the .elf suffix as an output.

Eclipse Porject Settings Dialog

Eclipse Porject Settings Dialog

After applying the changes and closing the dialog you can verify your changes by rebuilding the project. After the rebuild, in the console output, you should see the executed linker command as follows:

rx-elf-gcc -T gr-sakura.ld  -o "test123".elf  ./src/blink.o

Additionally, after the build, a file with the .elf suffix should reside inside the Debug directory.

Now, we want to program the RX target and start our debugging. To do so, you have to create a new debug configuration, which you can do under the Menu Run->Debug Configurations. Here right click GDB Hardware Debugging and create a new configuration. In the main tab verify that the C/C++ Application field contains the .elf file, which is the result of the build process. In the tab debugger, you have to enter the name of the gdb, which is “rx-elf-gdb” if you used the prefix from part 1 when building the toolchain. The default port, the J-Link gdb server listens on, is port 2331. Do not forget to apply the changes before changing to the next tab.

In the startup tab for your debug configuration, uncheck the points “Reset and Delay” and “Halt” and enter the following commands into the text field for the initialization commands:

monitor flash breakpoints = 1
monitor flash device = R5F563NB
monitor flash download = 1
monitor reset
monitor halt

If you do not use the GR-Sakura board, you have to substitute the chip you are using in the second command. In the Load Image and Symbols field, the points “Load image” and “Load symbols” should be checked.

Apply the changes and close the dialog. Now you can start the J-Link GDB-server in a separate console window and start your debugging session. Go to Run->Debug Configurations, choose the new configuration you created in the last step under GDB Hardware Debugging and hit “Debug”. After this, Eclipse should look like this:

The Eclipse debugging perspective

The Eclipse debugging perspective

Congratulations! Now you can do hardware debugging on your target and find out, why the GR-Sakura template might not work as expected. But this is another story.