Filter results by

Eclipse Desktop IDE for Linux

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.

The procedure has been tested on ubuntu 14.04 64-bit and Mac OS 10.12.2.

This procedure is updated to use the rsync method of synchronizing sysroot from the target ARTIK board.

Prerequisites

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

General packages

Install the basic package set as follows.

sudo apt-get install git rsync build-essential

Java

A Java JDK 8 is required for latest version of Eclipse.From Ubuntu 14.10 onwards it can be installed as follows:

sudo apt-get install openjdk-8-jdk

For older versions, do:

sudo add-apt-repository ppa:webupd8team/java -y
sudo apt-get update
sudo apt-get install oracle-java8-installer

GCC cross-compile toolchain

Many cross-compilation toolchains may be used to compile for the ARTIK platforms. This guide will use a specific one that has been tested to work well.

Ubuntu. Download and install the toolchain as follows..

wget https://releases.linaro.org/components/toolchain/binaries/latest-5/arm-linux-gnueabihf/gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabihf.tar.xz
sudo mkdir -p /opt/toolchains
sudo tar xvf gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabihf.tar.xz -C /opt/toolchains

Mac OS. There are not a lot of cross toolchains around for ARM running on Mac OS X. However, this one has been tested to work for ARTIK boards.

http://www.welzels.de/blog/download/gcc-linaro-arm-linux-gnueabihf-raspbian-2014.05_mac.zip

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. Create the directory /opt/sysroots and cd into it.

2. Use a text editor to create a script with the following content in the directory that you just made.

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
#! /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
    ln -sf usr/lib $OUTDIR/lib
fi
 
rsync -avzu --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 -avzu --delete-after root@$IP:/usr/include $OUTDIR/usr/

3. Make the script executable.

chmod +x sync-sysroot.sh

4. 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

5. 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]-----+

6. 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.

7. Create a sysroot output directory on the development machine.

sudo mkdir -p /opt/sysroots/artik-sysroot
sudo chmod 0777 /opt/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> /opt/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 /opt/sysroots/artik-sysroot/*

Eclipse Installation

Go to http://www.eclipse.org/downloads/ and select the Eclipse Neon download for Linux (eclipse-inst-linux64.tar.gz).

cd /tmp
tar xvf ~/Downloads/eclipse-inst-linux64.tar.gz
eclipse-installer/eclipse-inst

Follow the installation steps as described below.

  1. Select the indicated installation package.

  2. Select the Installation folder where you want to put Eclipse. Here we'll choose /home/user/eclipse and will later refer to it as such.

  3. Follow the installation steps from the installer until the installation succeeds. When it is done, it should automatically launch eclipse and ask for a workspace directory:

  4. Select your workspace location then click OK. Open the Install New Software menu.

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

    • CDT Main Features
      – C/C++ Development Tools
    • CDT Optional Features
      – C/C++ GCC Cross Compiler Support
  6. 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. Type the following commands. Use the workspace directory you chose earlier.

cd /home/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.

  5. Add a SYSROOT variable pointing to /opt/sysroots/artik-sysroot in the C/C++ Build => Build Variables menu. Make sure you check Apply to all configurations.

  6. Configure the toolchain as below under the C/C++ build => Settings => Cross Settings menu. The Path entry should point to the toolchain directory at /opt/toolchains/gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabihf/bin/.

  7. Add the include paths pointing to the SDK location in the sysroot as follows:

  8. Add an entry for each SDK library the program needs to be linked against. The GPIO example only requires the base and systemio SDK libraries. Link the artik-sdk-base library to your project by adding the entries as shown under C/C++ Build => Settings => Cross G++ linker => Libraries.

  9. Finally add –sysroot=${SYSROOT} to the Linker flags parameter under C/C++ Build => Settings => Cross G++ Linker => Miscellaneous.

  10. When the configuration is done, click OK. Then launch the build by clicking Project => Build All.

The program should build successfully as shown in the console window.

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 to create a new remote connection

    2. Select SSH as the connection type. Configure the connection by changing the IP address to match the IP of the target as shown. Unless you changed the board login, User and Password should both be root.

    3. Click Finish.

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

  4. 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 by selecting Properties.

  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.

  10. Configure the parameters as shown below.

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

  12. 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.

  13. Click the debug icon then gpio-test Debug 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: