Filter results by

Eclipse Desktop IDE for Windows

This article offers guidelines on how you would cross-compile from Eclipse and link to the sysroot of the board, to link to external dependencies (mainly shared libraries). It includes installation instructions for the ARTIK SDK, which can be treated like any other dependency that you, as a developer, would need to develop your own application.

This guide has been tested on Windows 7 and Windows 10.

This article supersedes the previous Eclipse for Windows installation instructions, as it adds capability for installing the ARTIK SDK and using ARTIK API calls. The old article can be found here for reference.

Prerequisites

The following steps need to be performed on the development machine to install the required dependencies.

msys2

Install the msys2 64 bit tools suite from https://msys2.github.io/. It will install by default under C:\msys64. Be sure to follow the directions and run the update multiple times, closing the msys bash window (not typing "exit") each time, until no more updates are found.

At the end of the installation, again open a bash window (C:\msys64\msys2_shell.cmd) and type the following command.

pacman -S make tar rsync openssh git mingw-w64-x86_64-make

Confirm to proceed to the installation of the packages.

GCC cross-compile toolchain

Download the toolchain from this link:

https://launchpad.net/linaro-toolchain-binaries/trunk/2013.10/+download/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10-20131018_win32.exe.

Open the installer and follow the installation steps until the last screen; make sure you check Add path to environment variable.

The toolchain should be installed under
C:\Program Files (x86)\Linaro\gcc-linaro-arm-linux-gnueabihf-4.8-2013.10.

SDK Installation - ARTIK Target

The SDK needs to be installed on the ARTIK target board, along with its development packages containing the headers. The development machine then needs a way to stay in sync with the target board sysroot.

Install SDK on the ARTIK target

First, set up access to the repository as described here.

Now type the following command on the ARTIK board to install the right packages.

dnf install libartik-sdk-*-devel gdb-gdbserver rsync

Enable synchronization of sysroot from the target

To access the SDK libraries and headers, you first need to extract the rootfs of the target and expose it on the development machine. There are many ways to do so, one of the simplest one being to use the rsync tool to automatically synchronize the remote directory from the target to the development machine. rsync is available on most operating systems, even though its installation and usage may vary.

1. Use your Windows text editor to create a script with the following content under C:\sysroots

sync-sysroot.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#! /bin/sh
IP=$1
OUTDIR=$2

if [ -z "$1" ] || [ -z "$2" ]; then
   echo 'Wrong parameters'
   echo 'Usage: sync-sysroot.sh <target IP address> <output directory>'
   exit 1
fi

if [ ! -d "$OUTDIR/usr/include" ]; then
    mkdir -p $OUTDIR/usr/include
fi

if [ ! -d "$OUTDIR/usr/lib" ]; then
    mkdir -p $OUTDIR/usr/lib
fi

if [ ! -L "$OUTDIR/lib" ]; then
   WINOUTDIR=`cygpath -w $OUTDIR`
   cmd //c "mklink /J $WINOUTDIR\lib $WINOUTDIR\usr\lib"
fi

rsync -avu --delete-after --exclude 'lib/firmware' --exclude 'lib/modules' --exclude 'lib/jvm-exports' --exclude 'lib/jvm' --exclude 'lib/node_modules' root@$IP:/usr/lib $OUTDIR/usr/
rsync -avu --delete-after root@$IP:/usr/include $OUTDIR/usr/

2. Open an msys bash window and make the script executable.

cd /c/sysroots
chmod +x sync-sysroot.sh

3. Add the development machine as an authorized SSH client to avoid asking password during SSH sessions. First check if you have an RSA key generated.

ls ~/.ssh

id_rsa id_rsa.pub known_hosts

4. If there are no id_rsa and id_rsa.pub files under this directory, generate one as follows (don't enter any passphrase when asked):

ssh-keygen

Generating public/private rsa key pair.                               
Enter file in which to save the key (/home/user/.ssh/id_rsa):        
Enter passphrase (empty for no passphrase):                           
Enter same passphrase again:                                          
Your identification has been saved in /home/user/.ssh/id_rsa.        
Your public key has been saved in /home/user/.ssh/id_rsa.pub.        
The key fingerprint is:                                               
SHA256:Lm6q0CFw5Ds6MenB2zKvzNN7tHTdB3aeObBU/zymD2E user@966bb16e176e  
The key's randomart image is:                                         
+---[RSA 2048]----+
|  .              |
| o           .   |
|. o         . .  |
|oo .       = . . |
|=o+     S + *Eo..|
|.*+o o o . o.*.oo|
|+=o.o + .   ..+ .|
|o++. +..     ..  |
| ++++o.       .. |
+----[SHA256]-----+

5. Add the development machine public key to the authorized keys of the target:

ssh-copy-id -i ~/.ssh/id_rsa.pub root@<IP address of the board>

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/user/.ssh/id_rsa.pub"                           
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed    
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys  
root@<IP address>'s password:                                                                                   

Number of key(s) added: 1                                                                                             

Now try logging into the machine, with: "ssh 'root@xxx.xxx.xxx.xxx'"  
and check to make sure that only the key(s) you wanted were added.

6. Create a sysroot output directory on the development machine. Omit sudo if not needed.

sudo mkdir -p /c/sysroots/artik-sysroot
sudo chmod 0777 /c/sysroots/artik-sysroot

Synchronize sysroot from the target

With everything in place, you can now run the synchronization of the sysroot.

./sync-sysroot.sh <target IP address> /c/sysroots/artik-sysroot

Notes on sysroot synchronization. The sysroot should be synchronized regularly to make sure the sysroot on the development machine matches exactly the content of the root filesystem on the target. In particular, the synchronization script should be run after:

  • Running a dnf update command

  • Installing a new package

  • Modifying/deleting/adding any file under /usr/lib or /usr/include

If you need to target another board, it is recommended to create another sysroot directory and do a synchronization from the start. It is generally good practice to keep separate sysroots for each board, and change the build parameters to target the one you want to build against.

If you get Eclipse build failures due to missing files, try to resync. If all else fails, remove the sysroot and start fresh.

rm -rf /c/sysroots/artik-sysroot/*

Eclipse Installation

Download the latest eclipse version from the Eclipse download site; the installer should be named eclipse-inst-win64.exe.

  1. Launch the installer and select the installation of Eclipse IDE for C/C++ Developers.

    You will be prompted to install Java if it is not already installed.

  2. Follow the installation steps until it is complete, then launch Eclipse. Select the directory of the workspace that will contain your projects, and write down this path for later.

  3. Click Help then Install New Software.

  4. Select CDT - http://download.eclipse.org/tools/cdt/releases/9.x in the dropdown list, then select the following for installation.

    • Under CDT Main Features

      – C/C++ Development Tools

    • Under CDT Optional or Uncategorized Features

      – C/C++ GCC Cross Compiler Support

      – C/C++ Remote Launch

      – CDT Standalone Debugger support

  5. Click Next several times and accept the license agreement to start installing the packages.

Eclipse may ask to restart after installing the packages.

Create New Project

We'll start a project using code we already have available. Open a bash window, then type the following commands. Use the workspace directory you chose earlier.

cd /c/Users/user/workspace git clone https://github.com/SamsungARTIK/artik-sdk-examples.git

  1. Create a new Makefile Project with Existing Code.

  2. Select the GPIO example program from the ARTIK SDK samples. Choose a name and Cross GCC as the toolchain.

  3. Right-click on the project to get the contextual menu then click Properties.

  4. Check the Generate Makefiles automatically under the C/C++ Build tab and change the default build command to mingw32-make.exe

  5. In the C/C++ Build => Build Variables menu, select Add to add a SYSROOT variable pointing to C:\sysroots\artik-sysroot and make sure you check Apply to all configurations.

  6. Under C/C++ Build => Environment, edit the PATH to prepend C:\msys64\mingw64\bin; C:\Program Files (x86)\Linaro\gcc-linaro-arm-linux-gnueabihf-4.8-2013.10\bin; to the existing path.

  7. Configure the toolchain as below under the C/C++ build => Settings => Cross Settings menu to add the arm-linux-gnueabihf- prefix.

  8. Add the include paths pointing to the SDK location in the sysroot by clicking on the circled "add" icon:
    ${SYSROOT}\usr\include\artik\systemio
    ${SYSROOT}\usr\include\artik\base

    The GPIO example only requires the base and systemio SDK libraries. For your own projects, add an entry for each SDK library the program needs to be linked against.

  9. Link the artik-sdk-base library to your project by adding the following entries under C/C++ Build => Settings => Cross G++ linker => Librairies.
    artik-sdk-base
    ${SYSROOT}\usr\lib

  10. Add --sysroot=${SYSROOT} to the Linker flags parameter under C/C++ Build => Settings => Cross G++ Linker => Miscellaneous.

  11. Click OK to close the Properties window.

  12. Launch the build by right-clicking on the project then clicking Build project.

The result of the build appears in the console window.

Troubleshooting Tip. If you get build messages saying "cannot find" file xxx, it may be due to rsync issues. Run another sync; it may take several tries to get all file updates. If needed, remove sysroot and start fresh.

Deploy to Target

Here we'll deploy the program to the target and execute it.

  1. Click Run, then Run Configurations.

  2. Add a C/C++ Remote Application and configure it as follows.
    1. Click New button (upper left corner) to create a new remote connection; enter information like that shown.

    2. Select SSH as the connection type. Configure the connection as follows, by changing the IP address to match the IP of the target. If you have not changed the password on the target, the login/password should be root/root.

    3. Apply the new settings. Make sure the newly created connection (e.g. ARTIK 710) is selected under the Connection dropdown list.

  3. Finally click Run. If prompted, accept RSA key exchange and enter the credentials to allow the connection.

If everything goes well, you should see the output of the program running remotely in the Console window.

Debug

You can debug the program as follows.

  1. Create a new build configuration.

  2. Click New.

  3. Enter Debug as the name of the configuration, copy settings from the Default configuration, then click OK.

  4. Set the Debug configuration as active, then click OK.

  5. Edit the project configuration.

  6. Make sure the Debug configuration is selected, then change the optimization level to None (-O0) under C/C++ Build => Settings => Tool Settings => Optimization. Click OK.

  7. Build the project.

  8. Launch the Debug Configurations menu.

  9. Add a new C/C++ Remote Application and configure the parameters as shown below. Make sure you select the Debug output and build.

  10. Under the Debugger tab, add the arm-linux-gnueabihf- prefix to the GDB debugger field. Click Apply then Close to validate the configuration.

  11. Edit the artik_gpio_test.c file and add a breakpoint in the main function by double clicking in the left column in front of the line you want to break at. You should see a blue bubble if the breakpoint was set.

  12. Click the debug icon then gpio-test to launch the debug session.

The debug session should launch and stop in the main function. You can now use the debug commands to run, go step by step, watch variables, etc.

Happy debugging!

Last updated on: