-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Using the Eclipse IDE for C and CPP Developers, Howto
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.
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-repository have been cloned, (head over to the getting started guide if you're uncertain how to obtain the RIOT source)
- and the Eclipse IDE for C/C++ Developers is installed/available.
- we use the
hello-worldexample - we use the Linaro Toolchain Binaries GCC in version 4.8 for ARM cross compillation
- Start the eclipse IDE and switch to the workbench
- Now we create a new Makefile project with existing code by clicking on: File→New→Makefile Project with Existing Code
- A new window shows up asking for the directory containing the source and the Makefile.
- for
nativewe select the main directory of RIOT and choose the Linux GCC in the Toolchain and indexer Settings and click Finish - for
msba2we select the main directory of RIOT and choose the <none> in the Toolchain and indexer Settings and click Finish
Installing GNU Arm eclipse Plug-ins
- We click on Help→Install New Software, which opens an Install window
- In the Work with: field we type
http://gnuarmeclipse.sourceforge.net/updatesand click Add... - We select
GNU ARM C/C++ Cross Development Toolsand clickNext >presentig us the Install details - After checking the details we click
Next >again presenting us the Review Licenses view - To install the plug-ins we accept the
Eclipse Foundation Software User Agreementand click Finish
- We select the RIOT project in the Project explorer and click the Project→Properties menu.
- In the new Properties for RIOT window we select Tool Chain Editor
- In the new view we uncheck the Display compatible toolchains only
- and select the Cross ARM GCC from the Current toolchain: dropdown menu
- We click on Settings and set the Global path to the
binfolder of the toolchain (e.g./home/user/Development/toolchains/gcc-arm-none-eabi-4_8-2014q1/bin) - Then we Apply the changes and click OK
- We select the RIOT project in the Project explorer and click the Project→Properties menu.
- There we select Build Variables and click on Add... opening the Define a New Variable window
- Using a speaking Variable Name:, i.e.
RIOT_PROJECTwe set the Value: toexamples/hello-world - We create another variable
RIOT_BOARDwithmsba2ORnativeas value (i.e. the actual used board for development) - We Apply the changes and click OK
- We select the RIOT project in the Project explorer and click the Project→Properties menu.
- In the presented Properties for RIOT window select C/C++ Build
- we uncheck Use default build command,
- and add the previously specified
RIOT_BOARDvariable to our build (i.e.${cross_make} BOARD=${RIOT_BOARD}) - Then we add the project path to the Build Location using the
RIOT_PROJECTvariable (i.e.${workspace_loc:/RIOT}/${RIOT_PROJECT}) - Optionally for debugging in
nativewe appendall-debugas build command additionally - Then we Apply the changes and click OK
After setting the project properties we build the set project by clicking Project→Build All.
- We click on Run→Run Configurations... which opens the Run Configurations window
- There we add a new launch configuration (if not already present)
- Now we adjust the C/C++ application: path to the just now built executable relative from the RIOT main folder, i.e.
examples/default/bin/native/default.elf - We hit the Apply button and if everything went right,
- hitting the Run button executes our built project
Repeat the setup for Debug Configurations if not applied automatically by Eclipse, to enable debugging.
Flashing and connecting msba2 requires to build the ./RIOT/boards/msba2-common/tools.
So we fire up a terminal, switch to the ./tools folder and execute make generating two executables in ./tools/bin
-
lpc2k_pgmused to flash the built codeimagemsba2board -
pseudotermused to communicate with themsba2board
We change to ./RIOT/boards/msba2-common/tools/bin and create two shell scripts:
- we type
touch flash.sh && chmod a+x flash.sh - and
touch terminal.sh && chmod a+x terminal.sh
Using a text editor we open the flash.sh file and add:
#!/bin/bash
TOOLPARAMETER="lpc2k_pgm $1 $2"
TOOLDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
xterm -e "sudo $TOOLDIR/$TOOLPARAMETER"Then we open the terminal.sh file and add:
#!/bin/bash
TOOLPARAMETER="pseudoterm $1"
TOOLDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
xterm -e "$TOOLDIR/$TOOLPARAMETER"Back to eclipse, we click on Run→External Tools→External Tools Configurations...
- In the new window we create a new configuration for flashing using a speaking name (e.g.
flash_msba2) - We select the
flash.shscript in the Location: filed - Then we add the device path, e.g.
/dev/ttyUSB0and - the path to the codeimage, e.g.
${workspace_loc:/RIOT}/examples/hello-world/bin/msba2/hello-world.hex, to the Arguments:. - We Apply the changes and Close the window
- In the new window we create a new configuration for flashing using a speaking name (e.g.
terminal_msba2) - We select the
terminal.shscript in the Location: filed - Then we add the device path, e.g.
/dev/ttyUSB0to the Arguments:. - We Apply the changes and Close the window
Now we go to *Run→External Tools→Organize Favorites...**. In the new window we select or just created configurations and hit OK.
Finally we can:
- selecting a project to build using the
RIOT_PROJECTvariable - selecting a board to build using the
RIOT_BOARDvariable - compile the desired project hitting Project→Build All
- flash the device using Run→External Tools→flash_msba2 (adjusting the codeimage path in its External Tools Configuration)
- communicate using Run→External Tools→terminal_msba2