-
Notifications
You must be signed in to change notification settings - Fork 0
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
, the msba2
board and the stm32f4discovery
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
orstm32f4discovery
) - the RIOT GIT-repository have been cloned, (head over to the quick 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-world
example - we use the Linaro Toolchain Binaries GCC in version 4.8 for ARM cross compillation
- We start the eclipse IDE and switch to the workbench
- There we create a new Makefile project with existing code by clicking on: File→New→Makefile Project with Existing Code
- The Toolchain and indexer Settings window shows up asking for the directory containing the source and the Makefile
- we select the main directory of RIOT and choose:
- for
native
the Linux GCC - for
msba2
orstm32f4discovery
<none>
- finally we click on Finish
- 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:, e.g.
RIOT_PROJECT
, we set the Value: toexamples/hello-world
- We create another variable,
RIOT_BOARD
, withmsba2
ORstm32f4discovery
ORnative
as value (i.e. the actual used board for development) - We Apply the changes and click OK
-
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/updates
and press enter -
We select
GNU ARM C/C++ Cross Development Tools
and click Next > presenting us the Install details -
After checking them we click Next >, presenting us the Review Licenses view
-
To install the plug-ins we accept the
Eclipse Foundation Software User Agreement
(s) and click Finish -
Setting up the the ARM cross toolchain
-
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
-
There we uncheck the Display compatible toolchains only
-
and select the Cross ARM GCC from the Current toolchain: dropdown menu * Please restart eclipse, if Cross ARM GCC is not available
-
We click on Settings and set the Global path to the
bin
folder 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
- In the presented Properties for RIOT window select C/C++ Build
- we uncheck Use default build command,
- and add the previously specified
RIOT_BOARD
variable to our build
- e.g.
${cross_make} BOARD=${RIOT_BOARD}
(formsba2
orstm32f4discovery
and further ARM boards) - e.g.
make BOARD=${RIOT_BOARD}
(fornative
)
- Then we add the project path to the Build Location using the
RIOT_PROJECT
variable
- e.g.
${workspace_loc:/RIOT}/${RIOT_PROJECT}
- For debugging on
native
we appendall-debug
as build command additionally
- i.e.
make BOARD=${RIOT_BOARD} all-debug
- Then we Apply the changes and click OK
- We open a terminal and switch to to the location of the RIOT project
- e.g.
cd /home/user/Development/RIOT/examples/hello-world
- Now we create a configuration
.xml
file for eclipse by typing:
-
make BOARD=stm32f4discovery eclipsesym
- Note: the set
BOARD
should be the same as set for the${RIOT_BOARD}
variable in eclipse before.
- Note: the set
- Now we import the generated configuration file in our eclipse project
- We open the project properties, menu Project→Properties
- Then select C/C++ General→Paths and Symbols
- (optionally) we click Restore Defaults to delete any existing macros and include paths
- We Click on Import Settings... and
- Select the generated
eclipsesym.xml
located in our application directory and press Finish - We rebuild the C/C++ index to teach eclipse the new paths and symbols using Project→C/C++ Index→Rebuild
Note: the settings in eclipsesym.xml
are specific for the selected project and BOARD.
If you start to develop another project or want to use additional compile time options these 3 steps must be repeated.
After setting the project properties we hit Project→Build All to build the project
- 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 built executable, relative from the RIOT main folder:
- i.e.
examples/hello-world/bin/native/hello-world.elf
- We click 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 with the msba2
requires to build the ./RIOT/boards/msba2-common/tools
.
So we fire up a terminal, switch to the ./tools
folder and execute make
compiling two executables in ./tools/bin
-
lpc2k_pgm
used to flash the built codeimage -
pseudoterm
used to communicate with the board
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 "sudo $TOOLDIR/$TOOLPARAMETER"
Now 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 click on Browse File System... for the Location: and select the
flash.sh
script - Then we add the device path to the Arguments:, e.g.
/dev/ttyUSB0
- it is assumed here that the
msba2
board is connected and recognized as/dev/ttyUSB0
- and also the path to the codeimage
- e.g.
${workspace_loc:/RIOT}/examples/hello-world/bin/msba2/hello-world.hex
- We Apply the changes and Close the window
- we create a further configuration for communication using a speaking Name: (e.g.
terminal_msba2
) - We click on Browse File System... for the Location: and select the
terminal.sh
script - Then we add the device path to the Arguments:
- e.g.
/dev/ttyUSB0
- We Apply the changes and Close the window
Now we go to Run→External Tools→Organize Favorites..., select our created configurations and hit OK
Run→External Tools→flash_msba2 will open an xterm starting the flash process using its Arguments:
- as device path, e.g.
/dev/ttyUSB0
- as the codeimage to flash, e.g.
${workspace_loc:/RIOT}/examples/hello-world/bin/msba2/hello-world.hex
Run→External Tools→terminal_msba2 will open an xterm connecting the msba2
using its Arguments:
- as device path, e.g.
/dev/ttyUSB0
We create two external tools in order to flash and to initialize the debugger on the board. If they are launched too many times it can sometimes generate conflicts, so we create two tools to clean them.
#####Notes:
Some tools need you to be sudo user so Eclipse asks you for your password. To handle this, we need to create/update this file: /etc/sudo.conf
# Path to askpass helper program
Path askpass /usr/bin/ssh-askpass
( For all next commands details, please read firstly this page Getting started with STM32F[0|3|4]discovery boards )
- Now 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.
STM32-Flash
) - We fill Location: with
/usr/bin/sudo
- Then we can execute the next command as sudo user and so we fill Arguments with
-A st-flash write ${workspace_loc:/RIOT}/examples/hello-world/bin/stm32f4discovery/hello-world.hex 0x8000000
- We can also disable the checkbox
Build before launch
in the Build tab - We Apply the changes and Close the window
- We click on
Run Configurations
in the Run tab - In the new window we create a new configuration, Name: (e.g.
STM32
) - We can enable the checkbox
Disable auto build
to avoid compiling each time we run - We fill C/C++ Application: with
/usr/bin/sudo
- Then we can execute the next command as sudo user and so in the Arguments tab, we fill
Program arguments
with-A ${workspace_loc:/RIOT}/dist/tools/pyterm/pyterm.py /dev/ttyUSB1
- Please note that the serial number of
ttyUSB*
depends on your configuration
- We Apply the changes and Close the window
- We create another tool in
External Tools Configurations
- In the new window we create a new configuration using a speaking Name: (e.g.
Stop STM32
) - We fill Location: with
/usr/bin/sudo
- Then we can execute the next command as sudo user and so we fill Arguments with
-
-A pkill python
(Please note that this will also kill all process that use python)
-
- We can also disable the checkbox
Build before launch
in the Build tab - We Apply the changes and Close the window
- We create another tool in
External Tools Configurations
- In the new window we create a new configuration using a speaking Name: (e.g.
Init STM32-Debug
) - We fill Location: with
/usr/bin/sudo
- Then we can execute the next command as sudo user and so we fill Arguments with
-A st-util
- We can also disable the checkbox
Build before launch
in the Build tab - We Apply the changes and Close the window
- We click on
Debug Configurations
in the Run tab - In the new window we create a new
GDB Hardware Debugging
configuration, Name: (e.g.STM32-Debug
) - We can enable the checkbox
Disable auto build
to avoid compiling each time we run - We fill C/C++ Application: with
${workspace_loc:/RIOT}/examples/hello-wolrd/bin/stm32f4discovery/hello-world.elf
- We provide to Eclipse our debugger in the Debugger tab:
- We fill
GDB Command
with the path of the ARM GDB e.g./home/user/Development/toolchains/gcc-arm-none-eabi-4_8-2014q1/bin/arm-none-eabi-gdb
- We specify in
Port number
4242
because the "Init STM32-Debug" tool we created just before uses the port 4242
- We Apply the changes and Close the window
- We create another tool in
External Tools Configurations
- In the new window we create a new configuration using a speaking Name: (e.g.
Clean STM32-Debug
) - We fill Location: with
/usr/bin/sudo
- Then we can execute the next command as sudo user and so we fill Arguments with
-A pkill st-util
- We can also disable the checkbox
Build before launch
in the Build tab - We Apply the changes and Close the window
Now we can:
- select a project to be build using the
RIOT_PROJECT
variable
- e.g.
examples/hello-world
- select a target board using the
RIOT_BOARD
variable
- e.g.
native
- compile the desired project hitting Project→Build All
- specific to
native
:
- setup the C/C++ application: path (cf. 6)
- Run the compiled code
- Debug the compiled code
- specific to
msba2
:
- setup the Arguments: for flashing and communication
- e.g.
/dev/ttyUSB0
for the connected device (cf. Flashing: 6.1 and Communicating: 6.1) - e.g.
${workspace_loc:/RIOT}/examples/hello-world/bin/msba2/hello-world.hex
- e.g.
- flash the codeimage on the
msba2
using Run→External Tools→flash_msba2 - communicate with the
msba2
using Run→External Tools→terminal_msba2
- specific to
stm32f4discovery
:
-
Run
- flash the codeimage on the
stm32f4discovery
using Run→External Tools→STM32-Flash - Run the compiled code
- stop running using Run→External Tools→Stop STM32 (You can also click on the red square but note that it can generate conflicts)
- flash the codeimage on the
-
Debug
- flash the codeimage on the
stm32f4discovery
using Run→External Tools→STM32-Flash - to avoid some conflicts, we advise to stop the past initialization of some debuggers using Run→External Tools→Clean STM32-Debug
- initialize the debugger using Run→External Tools→Init STM32-Debug
- Debug the compiled code using Run→Debug History→STM32-Debug (sometimes we need to launch it a few times to make it run)
- flash the codeimage on the
RIOT - The friendly Operating System for the Internet of Things
Homepage | [GitHub] (https://github.com/RIOT-OS/) | Developers Mailing List | Users Mailing List | Twitter @RIOT_OS
- Family: ARM
- Board: Airfy Beacon
- Board: Arduino Due
- Board: CC2538DK
- Board: HikoB Fox
- Board: IoT LAB M3
- Board: LimiFrog-v1
- Board: mbed_lpc1768
- Board: MSB-IoT
- Board: MSBA2
- Board: Nucleo-L1
- Board: Nucleo-F334
- Board: Nucleo-F303
- Board: Nucleo-F091
- Board: Mulle
- Board: OpenMote
- Board: PCA1000x (nRF51822 Development Kit)
- Board: Phytec phyWAVE-KW22
- Board: RFduino
- Board: Samr21 xpro
- Board: Spark Core
- Board: STM32F0discovery
- Board: STM32F3discovery
- Board: STM32F4discovery
- Board: UDOO
- Board: yunjia-nrf51822
- Family: ATmega
- Board: Arduino Mega2560
- Family: MSP430
- Board: MSB-430H
- Board: TelosB
- Board: WSN430
- Board: Zolertia Z1
- Board: eZ430-Chronos
- Family: native
- Board: native
- Family: x86
- Board: Intel Galileo