===== Setup Eclipse IDE for @stk_name@ =====
====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 ====
The following has to be added to the local.conf file in the build directory or to your custom image recipe:
EXTRA_IMAGE_FEATURES = " eclipse-debug"
IMAGE_INSTALL_append = " openssh-sftp-server"
==== Set Password User Root (optional) ====
This guide uses a password based authentication for the ssh target connection. The password can be setup with the ''passwd'' command on the target. The password can also be defined in the local.conf file or your custom image recipe. Below you will find a an example to add the password ''password'' to the user ''root''.
INHERIT += "extrausers"
EXTRA_USERS_PARAMS = "usermod -P password root;"
==== Setup Development Host ====
The Eclipse IDE requires the following packages 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-get install build-essential gdb gdb-multiarch git default-jre
\\
Download the Eclipse from the following link in this case Eclipse 2021-06:\\
[[ https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/2021-06/R/eclipse-cpp-2021-06-R-linux-gtk-x86_64.tar.gz]]\\
\\
Afterwards extract the Eclipse tarball e.g. to your home directory, by default the folder is named eclipse.
cd ~
tar -xf ~/Downloads/eclipse-cpp-2021-06-R-linux-gtk-x86_64.tar.gz
Now the Eclipse IDE can be started from a terminal:
e.g.
~/eclipse/eclipse
After starting Eclipse select a new workspace directory and click the Launch button.
{{@lang@:@mod_arch@:@mod_name@:linux:yocto:eclipse_yocto_1.png?nolink&800|}}
\\
==== Create a new Hello World Project ====
Select **File → New → C/C%%++%% Project**
{{@lang@:@mod_arch@:@mod_name@:linux:yocto:eclipse_yocto_2.png?nolink&2000|}}
\\
\\
\\
Select C Managed Build and click Next
{{@lang@:@mod_arch@:@mod_name@:linux:yocto:eclipse_yocto_3.png?nolink&800|}}
\\
\\
\\
* Enter a name for the project in the Project name field
* Select Hello World ANSI C Project in the Project type field
* Select Cross GCC in the toolchain field
Click the Next Button.
\\
{{@lang@:@mod_arch@:@mod_name@:linux:yocto:eclipse_yocto_4.png?nolink&800|}}
\\
\\
\\
* Add the author name
* Check that the license field is correct
Click Next
\\
{{@lang@:@mod_arch@:@mod_name@:linux:yocto:eclipse_yocto_5.png?nolink&800|}}
\\
\\
\\
Accept the default settings for Debug and Release by clicking Next \\
{{@lang@:@mod_arch@:@mod_name@:linux:yocto:eclipse_yocto_6.png?nolink&800|}}
\\
\\
\\
* aarch64-poky-linux-
* /opt/@bsp_distro@/@distro_version@/sysroots/x86_64-@sdk_folder_name@-linux/usr/bin/SDK_SUB_FOLDER
Finally click on Finish
{{@lang@:@mod_arch@:@mod_name@:linux:yocto:eclipse_yocto_7.png?nolink&1000|}}
====Cross Compiler Configuration====
* Right click on the project and select Properties from the menu
{{@lang@:@mod_arch@:@mod_name@:linux:yocto:eclipse_yocto_8.png?nolink&2000|}}
\\
* Select **All configurations** in the configuration field
* Select **C/C%%++%% Build → Settings → Cross GCC Compiler → Includes** and enter the following path:
/opt/fsl-imx-wayland/5.4-zeus/sysroots/aarch64-poky-linux/usr/include
\\
{{@lang@:@mod_arch@:@mod_name@:linux:yocto:eclipse_yocto_9.png?nolink&2000|}}
* Select **C/C%%++%% Build → Settings → Cross GCC Compiler → Miscellaneous** and append the following in the Other flags field:
--sysroot=/opt/@bsp_distro@/5.4-zeus/sysroots/@sdk_folder_name@-linux
{{@lang@:@mod_arch@:@mod_name@:linux:yocto:eclipse_yocto_10.png?nolink&2000|}}
* Select **C/C%%++%% Build → Settings → Cross GCC Linker → Miscellaneous** and add the following in the Linker flags field:
--sysroot=/opt/fsl-imx-wayland/@distro_version@/sysroots/@sdk_folder_name@-linux
{{@lang@:@mod_arch@:@mod_name@:linux:yocto:eclipse_yocto_11.png?nolink&2000|}}
Apply and Close finally to leave the Properties Menu.
==== 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
{{@lang@:@mod_arch@:@mod_name@:linux:yocto:eclipse_yocto_12.png?nolink&2000|}}
Double Click **C/C%%++%% Remote Application** and click on New to create a new connection to the target
{{@lang@:@mod_arch@:@mod_name@:linux:yocto:eclipse_yocto_13.png?nolink&2000|}}
Select SSH in the drop down menu and click OK
{{@lang@:@mod_arch@:@mod_name@:linux:yocto:eclipse_yocto_14.png?nolink&800|}}
* Select a Connection name
e.g. @stk_name@
* Enter the IP address of the Target
e.g. 10.122.63.12
* Enter the user name that is used to login on the target
e.g. root
* Select Password based authentication and enter the password for the user that is used to login on the target
e.g. root
Finally click on Finish
{{@lang@:@mod_arch@:@mod_name@:linux:yocto:eclipse_yocto_15.png?nolink&800|}}
Enter the target application path in the Remote Absolute File Path for C/C%%++%% Application field:\\
e.g. /home/root/hello_world. It is also possible to select the path on the target by clicking the **Browse** button.
{{@lang@:@mod_arch@:@mod_name@:linux:yocto:eclipse_yocto_16.png?nolink&2000|}}
Switch to the Debugger tab and enter **aarch64-poky-linux-gdb** in the GDB debugger field.
{{@lang@:@mod_arch@:@mod_name@:linux:yocto:eclipse_yocto_17.png?nolink&2000|}}
Click apply and close to leave the Debug Configuration
Select Window → Show View → Debug from the menu to add the debug view.
{{@lang@:@mod_arch@:@mod_name@:linux:yocto:eclipse_yocto_18.png?nolink&2000|}}
Open the Launch Target drop down menu and select new Launch Target
{{@lang@:@mod_arch@:@mod_name@:linux:yocto:eclipse_yocto_19.png?nolink&2000|}}
Select **GDB Remote TCP** in the New Launch Target window and click **Next** afterwards
{{@lang@:@mod_arch@:@mod_name@:linux:yocto:eclipse_yocto_20.png?nolink&800|}}
Enter the Target IP, by default the SSH port is configured to 22. Click **Finish** to leave the Launch Target configuration.
{{@lang@:@mod_arch@:@mod_name@:linux:yocto:eclipse_yocto_21.png?nolink&800|}}