Skip to content

Using the Eclipse IDE for C and CPP Developers, Howto

BytesGalore edited this page Feb 5, 2014 · 2 revisions

This brief howto is meant as a quick guidance to start developing using RIOT-OS and eclipse. It should give at least a hint how to start developing with eclipse. Right now this howto is focused on the native and the msba2 board.

Prerequisites

Before we start it is assumed that:

  • the OS used for development is equipped with a working and somehow current GCC toolchain (native)
  • the OS used for development is equipped with the recommended or somehow current gcc-arm-none-eabi cross toolchain (msba2)
  • the RIOT GIT-repositories including RIOT and projects have been cloned,
  • and the Eclipse IDE for C/C++ Developers is installed/available.

The host system of the howto

  • The machine used in this howto is a x86 running Ubuntu 10.04 on it.
  • The used toolchain is a gcc-4.6 obtained by using the Ubuntu apt-get command: sudo apt-get install build-essential for the native port and
  • a gcc-arm-none-eabi cross toolchain for the msba2 port. (a GCC 4.7 arm toolchain)
  • The RIOT repos have been cloned to /home/riotdev/Desktop/devRIOT/. Head over to the getting started guide for a quick guide how to get the required RIOT sources used in this tutorial.
  • And the Eclipse IDE for C/C++ Developers is used, which can be downloaded from here: eclipse download.

Setup the eclipse IDE for RIOT development

Please note: we use the default-native project cloned to the ./devRIOT/projects directory to start development with native, and the default project for msba2.

  1. Start the eclipse IDE and switch to the workbench
  2. Now we create a new Makefile project with existing code by clicking on: File→New→Makefile Project with Existing Code
  3. A new window shows up asking for the directory containing the source and the Makefile.
  • for native we select the location of the default-native project and choose the Linux GCC in the Toolchain and indexer Settings
  • for msba2 we select the location of the default project and choose <none>

After a click on the Finish button the project appears in the eclipse Project Explorer tab. Opening the main.c welcomes us with a bunch of unresolved inclusions warnings and some errors about unresolved types.

Resolving the Warnings and Errors

We have to set the location of the currently unresolvable types and includes appeared after adding the new Makefile project with existing code

  1. Using a terminal, we switch to the RIOT main directory /home/riotdev/Desktop/devRIOT/RIOT/ and type: find `pwd` -type d \( -path */boards -o -path */cpu \) -prune -o -type f -name '*.h' |sed 's#\(.*\)/.*#\1#' |sort -u, to list all locations of common used .h files
  2. Back to eclipse, we go to the Project→Properties
  3. There we navigate to C/C++ General→Paths and Symbols
  4. and we Add... all the listed directories in the presented view

Now we Add... the specific header directories used by the default-native project or the msba2 project respectively to enable the eclipse IDE to also find them.

Note: use only the specific includes for native OR msba2 (this applies for every board)

The following specific include paths for native in this howto would be:

  • /home/riotdev/Desktop/devRIOT/RIOT/boards/native/include
  • /home/riotdev/Desktop/devRIOT/RIOT/cpu/native/include

and the specific include paths for msba2 would be:

  • /home/riotdev/Desktop/devRIOT/RIOT/boards/msba2/include
  • /home/riotdev/Desktop/devRIOT/RIOT/boards/msba2-common/include
  • /home/riotdev/Desktop/devRIOT/RIOT/cpu/lpc2387/include (Note: lpc2387 is the msba2 cpu)
  • /home/riotdev/Desktop/devRIOT/boards/arm_common/include

As we chosen <none> in the Toolchain and indexer Settings for default (msba2) we have to add paths for the cross toolchain includes: Note: the tutorial configuration cross compiler toolchain is not installed into the default location, but in: /home/riotdev/Desktop/devRIOT/gcc-arm-none-eabi-4_7/.

  • /home/riotdev/Desktop/devRIOT/gcc-arm-none-eabi-4_7/include
  • /home/riotdev/Desktop/devRIOT/gcc-arm-none-eabi-4_7/gcc-arm-none-eabi/include
  • /home/riotdev/Desktop/devRIOT/gcc-arm-none-eabi-4_7/gcc-arm-none-eabi/c++/4.7
  • /home/riotdev/Desktop/devRIOT/gcc-arm-none-eabi-4_7/gcc-arm-none-eabi/c++/4.7/backward
  • /home/riotdev/Desktop/devRIOT/gcc-arm-none-eabi-4_7/gcc-arm-none-eabi/include/machine
  • /home/riotdev/Desktop/devRIOT/gcc-arm-none-eabi-4_7/lib/gcc-arm-none-eabi/4.7/include
  • /home/riotdev/Desktop/devRIOT/gcc-arm-none-eabi-4_7/gcc-arm-none-eabi/4.7/include-fixed

While chosen Linux GCC in the Toolchain and indexer Settings for default-native (native) these paths were set automaticly.

To enable eclipse compiling with the cross toolchain (arm-none-eabi-*) we

  • navigate to C/C++ Build→Environment
  • click at Add..., name a new variable PATH and click OK
  • we click Edit... and add /home/riotdev/Desktop/devRIOT/gcc-arm-none-eabi-4_7/bin: at the beginning of the Value filed and click OK.
  • Then we click again at Add..., name a new variable LD_LIBRARY_PATH and click OK
  • we click Edit... and add /home/riotdev/Desktop/devRIOT/gcc-arm-none-eabi-4_7/lib: at the beginning of the Value filed and click OK.

After setting the right include directories and the path Environment variables in for msba2, a click on OK or the Apply button updates with the new settings and the warnings and errors are resolved.

The RIOT Source

Now that we introduced the include paths of RIOT to eclipse we have to setup the paths for the RIOT source code:

  1. We go to the Project→Properties
  2. There we navigate to C/C++ General→Paths and Symbols
  3. We select the Source Location Tab, and
  4. click on the Link Folder... button

Now we are presented with a new window. There we select the Link to folder in the filesystem and browse to the root of RIOT to select it. After confirming the changed Properties, the RIOT root folder is linked into the project and can be browsed, accessed and found by eclipse.

With this setup you should be able to start developing and joining the RIOT.

This litte howto ends here for now. I hope it was somehow helpful. So, Happy RIOT-ing!

Clone this wiki locally