In this section, we will go through the two ways of setting up a development environment for Intel Galileo on our host development system. In the previous section, we created the Intel Galileo SDK, and now we will go through how to use it:
$ cd $BUILD_DIR/meta-clanton/yocto_build/.tmp/deploy/sdk
/opt/clanton-tiny/1.4.2
directory; you can install any directory you want. You will get the following terminal output when you run the SDK installer script:$ sudo ./clanton-tiny-uclibc-x86_64-i586-toolchain-1.4.2.sh Enter target directory for SDK (default: /opt/clanton-tiny/1.4.2): You are about to install the SDK to "/opt/clanton-tiny/1.4.2". Proceed[Y/n]?Y Extracting SDK... Setting it up...done SDK has been successfully set up and is ready to be used.
The Intel Galileo SDK is installed on your host filesystem, and your host system is ready to compile and build C/C++ applications for the Intel Galileo development board.
To start development, you can either use basic text editors and compile the source code on your host machine's console, or you can configure an IDE to use the Intel Galileo SDK to develop applications.
If you don't want to use any IDE for software development, you can just use any text editor and compile your code from the Linux terminal after you set up the SDK environment variables.
After you install the SDK, it copies a Bash script to the SDK directory, and running it is enough to set up environment variables for the GCC compiler and linkers.
You can source the environment variables for the current session on your host machine as follows:
$ source /opt/clanton-tiny/1.4.2/environment-setup-i586-poky-linux-uclibc
You can check whether the setup is completed correctly for C, C++ cross compilers, and linker variables, respectively, as shown in the following code. $CC
is a variable for the C compiler, $CXX
is a variable for the C++ compiler, and $LD
is for the Intel Galileo toolchain linker:
$ echo $CC i586-poky-linux-uclibc-gcc -m32 -march=i586 --sysroot=/opt/clanton-tiny/1.4.2/sysroots/i586-poky-linux-uclibc $ echo $CXX i586-poky-linux-uclibc-g++ -m32 -march=i586 --sysroot=/opt/clanton-tiny/1.4.2/sysroots/i586-poky-linux-uclibc $ echo $LD i586-poky-linux-uclibc-ld --sysroot=/opt/clanton-tiny/1.4.2/sysroots/i586-poky-linux-uclibc
Let's write a simple Hello World C
code with a text editor, compile it on the host console, and run it on Intel Galileo using the following steps:
.c
file with your favorite text editor or any console text editor. Write a printf
function, as follows, and compile it:$ nano hello_world.c #include <stdio.h> int main (void){ printf("Hello World "); return 0; } $ $CC hello_world.c –o helloworld
scp
command. SSH and SCP tools are installed with the full image we built to boot with the SD card.scp
command to the board from your host machine. Secure Copy Protocol (SCP) securely transfers computer files between a local host and a remote host. Therefore you can transfer files from Intel Galileo to your development PC or from your PC to the Intel Galileo board.$ scp helloworld [email protected]:/home/root/apps
Together with the Telnet protocol and the installation of the ssh
daemon (sshd) on Intel Galileo, you can connect to the board's terminal from the ssh
client of your host system:
$ ssh [email protected]
$ cd /home/root/apps $ ./helloworld Hello World
This method can be used to develop any application and deploy it to Intel Galileo. If you don't have a local network connection, it may be difficult for you to transfer files to the Intel Galileo board with a USB stick or with the SD card.
Another and more efficient way of working with embedded devices is to use the Eclipse IDE. Eclipse provides a good C/C++ development environment and remote debugging utilities for developers. Another reason to select the Eclipse IDE is that the Yocto Project has a plugin for Eclipse, and this makes it very easy to set up the SDK's location and cross-compile.
In this section, we will go through the setup process for the Eclipse IDE for development and for remote debugging.
Download the latest Eclipse IDE from its official download site at https://www.eclipse.org/downloads/ or install it from the Ubuntu repository, as follows:
$ sudo apt-get install eclipse
If Java is installed on your host system, you can start the Eclipse IDE from the command line:
$ eclipse
We need to install some necessary plugins for Eclipse before installing the Yocto Project plugin on it:
This will prompt you with a window to start the installation.
This action will load the available plugins to the following list.
Select the required plugins to be installed. Perform the following steps to select plugins from the available software:
Then, click on the Next > button and read and accept the licenses agreement. This will install the plugins and restart the Eclipse IDE. The following screenshot shows you what to select from the list:
When C/C++ development and support tools for the Eclipse IDE have been installed, as described in the previous section, we are good to go with the Yocto Project's plugin installation.
You can perform the following steps to set up the Yocto Project plugin onto Eclipse:
Yocto ADT Plugin
), enter http://downloads.yoctoproject.org/releases/eclipse-plugin/1.6/kepler, and click on Add.The Yocto plugin requires some parameters, such as the location or path of the toolchain on your host machine filesystem, to be pointed by the user.
To configure the Yocto plugin, follow these steps:
One last step in the Eclipse configuration is to configure the remote device. The Eclipse IDE makes it easy for developers to deploy and debug applications on remote devices. If we don't use a helpful tool such as Eclipse to deploy applications, we need to copy the binary to a remote device from the console or copy files to a USB stick in order to transfer the compiled binary to Intel Galileo.
The Eclipse IDE also makes it easy to debug applications on remote devices with the help of a user friendly Graphical User Interface (GUI): the Debug perspective. There are a couple of steps that need to be performed to complete the remote device configuration:
This will show you a window, as shown in following screenshot, where you need to type in the Intel Galileo development board's IP address and a description for the connection:
.ssh
files, processes.shell.linux
, ssh.shells
, and ssh.terminals
.This process defines a remote connection. Now we need to configure Eclipse in order to run applications on a remote device, as follows:
The fully configured remote device is shown in the following screenshot:
We completed all the necessary configurations for Eclipse, so we can easily create an application now without reconfiguring the Eclipse IDE for the Intel Galileo toolchain. Eclipse will create C/C++ projects with toolchain configurations, and you will be able to develop C/C++ applications easily with the Eclipse IDE.
After performing a couple of easy steps, you will be able to create a C project for Intel Galileo with all the toolchain configurations, as shown here:
Hello World
sample by clicking on Build and running with the selection Run As, Remote Application on Intel Galileo.