===== Setup Eclipse IDE for @stk_name@ =====
Cross compilation for @stk_name@ is only supported on a Linux based developement host!
===Prerequisites===
* BSP built according to [[@lang@:@mod_arch@:@mod_name@:linux:yocto:quickstart_yocto| quickstart guide]]
* Built Yocto SDK based on the current RootFS configuration, installed on the development host. See [[@lang@:@mod_arch@:@mod_name@:linux:yocto:how_to:development_host#build_yocto_sdk|Build Yocto SDK]] how to build it.
* Configured SSH login on target. See [[@lang@:@mod_arch@:@mod_name@:linux:yocto:how_to:target#ssh-connection|setup ssh connection]]
* Configured Network connection to the development host
==== Additional Yocto Packages ====
Additional packages have to be installed in the Yocto image. The following lines can be added to the local.conf file in the build directory or to a custom image recipe:
EXTRA_IMAGE_FEATURES = " eclipse-debug"
IMAGE_INSTALL_append = " openssh-sftp-server"
==== Additional Packages on Development Host ====
The Eclipse IDE requires the packages listed below installed on the development host:
* build-essential
* gdb
* gdb-multiarch
* git
* default-jre
On a Ubuntu based development host, they can be installed by the following commands:
sudo apt install build-essential gdb gdb-multiarch git default-jre
\\
==== Download and Install Eclipse ====
You may download the latest //Eclipse for Embedded C/C%%++%% Developers// from the [[https://www.eclipse.org/downloads/packages/|offial download page]] (Linux). This tutorial was tested with Eclipse version [[https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/2022-12/R/eclipse-embedcpp-2022-12-R-linux-gtk-x86_64.tar.gz|2022-R12]].\\
\\
After downloading extract the Eclipse tarball e.g. to your home directory, by default the folder is named eclipse.
cd ~
tar -xf ~/Downloads/eclipse-embedcpp-2022-12-R-linux-gtk-x86_64.tar.gz
==== Eclipse Startup ====
Now Eclipse can be started from a terminal. However for the Cross Compiler to work properly, you will need to source the [[@lang@:@mod_arch@:@mod_name@:linux:yocto:how_to:development_host:yocto_sdk|Yocto SDK]] environment script beforehand., if the SDK has been install in the default path the script is located in ''/opt/@tq_distro@/@yocto_rel_ver_major@.@yocto_rel_ver_minor@/@sdk_env_script@''
\\
\\
Since you would need to do that every time before starting the IDE, you might want to create a short launch script to source the environment variables and open Eclipse with only one command instead:
echo -e "source /opt/@tq_distro@/@yocto_rel_ver_major@.@yocto_rel_ver_minor@/source /opt/@tq_distro@/@yocto_rel_ver_major@.@yocto_rel_ver_minor@/@sdk_env_script@\n~/eclipse/eclipse" > eclipse_@mod_name@.sh
chmod +x eclipse_@mod_name@.sh
Now you can simply execute the ''./eclipse_@mod_name@.sh'' script to setup the environment properly start the Eclipse IDE for @mod_name@-development.
==== Create a new C or C++ Project ====
Select **File → New → C/C%%++%% Project**\\
then select eighter //C// or //C%%++%% Managed Build// and click Next.\\
===Important Notes:===
* Make sure to select //Cross GCC// in the toolchain field
* //Cross compiler prefix// and //Cross compiler path// configuration should be left empty!
====Cross Compiler Configuration====
What is left now, is to tell the Cross Compiler to read the variables that you just sourced before starting the IDE.\\
Open the Project-Properties (Right click project -> properties)
\\ \\
First select **All configurations** in the configuration field, then select **C/C%%++%% Build → Settings → Cross GCC Compiler** and enter the following into the Command-field: ''${CC}''. \\
{{:en:arm:tqma6ulx:linux:yocto:how_to:development_host:1.png?800|}}
\\ \\
In **Cross GCC Compiler → Miscellaneous** change //Other flags// to: ''${CFLAGS} -c''.\\
{{:en:arm:tqma6ulx:linux:yocto:how_to:development_host:2.png?800|}}
\\ \\
Now move into **Cross GCC Assembler** and change the //Command// field to: ''${AS}''.\\
{{:en:arm:tqma6ulx:linux:yocto:how_to:development_host:3.png?800|}}
\\
====only for C Projects:====
Move into **Cross GCC Linker** and change the //Command// field to: ''${CC}''.\\
{{:en:arm:tqma6ulx:linux:yocto:how_to:development_host:c1.png?800|}}
\\ \\
In **Cross GCC Linker → Miscellaneous** change //Other flags// to: ''${LDFLAGS}''.\\
{{:en:arm:tqma6ulx:linux:yocto:how_to:development_host:c2.png?800|}}
\\
====only for C++ Projects:====
Move into **Cross G%%++%% Compiler** and enter the following into the Command-field: ''${CXX}''. \\
{{:en:arm:tqma6ulx:linux:yocto:how_to:development_host:c_1.png?800|}}
\\ \\
In **Cross G%%++%% Compiler → Miscellaneous** change //Other flags// to: ''${CXXFLAGS} -c''.\\
{{:en:arm:tqma6ulx:linux:yocto:how_to:development_host:c_2.png?800|}}
\\ \\
Move into **Cross G%%++%% Linker** and change the //Command// field to: ''${CXX}''.\\
{{:en:arm:tqma6ulx:linux:yocto:how_to:development_host:c_3.png?800|}}
\\ \\
In **Cross G%%++%% Linker → Miscellaneous** change //Other flags// to: ''${LDFLAGS}''.\\
{{:en:arm:tqma6ulx:linux:yocto:how_to:development_host:c_4.png?800|}}
\\ \\
Click //Apply and Close// to leave the properties menu.
==== Add your first programm ====
In case you created an empty project, you now might want to fill it with something, be it something arbitrary like a "hello world" to get started.\\
Create a new //Source File// inside your project structure, name it ''main.c'' and fill it with the following:
#include
int main() {
printf("Hello TQ-Starterkit\n");
return 0;
}
==== Remote Debug Configuration ====
* Setup the SSH Connection Starterkit for further information see the section SSH Connection
* Setup the Network Connection on the Starterkit
Select Run → Debug Configurations \\
{{:en:arm:tqma6ulx:linux:yocto:how_to:development_host:d1.png?1000|}}
Double Click **C/C%%++%% Remote Application** and click on New to create a new connection to the target \\
{{:en:arm:tqma6ulx:linux:yocto:how_to:development_host:d2.png?1000|}}
Select SSH in the drop down menu and click OK \\
{{:en:arm:tqma6ulx:linux:yocto:how_to:development_host:d3.png?400|}}
* Select a Connection nam
* Enter the IP address of the Target
* Enter the user name that is used to login on the target
* Select Password based authentication and enter the password for the user that is used to login on the target
{{:en:arm:tqma6ulx:linux:yocto:how_to:development_host:d4.png?600|}}
Specify a path and name for your C/C%%++%% Application on the target.\\
{{:en:arm:tqma6ulx:linux:yocto:how_to:development_host:d5.png?1000|}}
Switch to the Debugger tab and enter the path to GDB debugger file from the yokto sdk.\\
{{:en:arm:tqma6ulx:linux:yocto:how_to:development_host:d6.png?1000|}}
Click apply and close to leave the Debug Configuration or start debugging immediately by hitting //Debug//.\\
You can now start remote debugging by selecting the debug configuration you just created.\\
{{:en:arm:tqma6ulx:linux:yocto:how_to:development_host:d7.png?400|}}
You will be prompted to switch to the Debug View, press "Switch". Inside the Debugview you will most likely find the programm halted at a breakpoint at the start of main. Hit resume to run the programm.\\
{{:en:arm:tqma6ulx:linux:yocto:how_to:development_host:d8.png?2000|}}