Yocto Programming with Eclipse v2: Difference between revisions

From Variscite Wiki
(Copy Yocto_Programming_with_Eclipse)
 
No edit summary
Line 13: Line 13:
     tools-debug \
     tools-debug \
     eclipse-debug \
     eclipse-debug \
    ssh-server-openssh \
     "
     "


Line 18: Line 19:
     tcf-agent \
     tcf-agent \
     openssh-sftp-server \
     openssh-sftp-server \
    openssh \
     "
     "
</pre>
</pre>
Line 28: Line 30:
= Eclipse installation =
= Eclipse installation =
== Download Eclipse ==
== Download Eclipse ==
Download Eclipse Luna from here: http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/lunasr2<br>
Download Eclipse Luna from here: 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<br>
Run the following command to unpack and install the downloaded Eclipse IDE tarball into a clean directory using the default name eclipse:
Run the following command to unpack and install the downloaded Eclipse IDE tarball into a clean directory using the default name eclipse:
<pre>
<pre>
$ cd ~
$ cd ~
$ tar -xf ~/Downloads/eclipse-cpp-luna-SR2-linux-gtk-x86_64.tar.gz
$ tar -xf ~/Downloads/eclipse-cpp-2021-06-R-linux-gtk-x86_64.tar.gz
</pre>
</pre>


== Configuring the Eclipse IDE ==
== Configuring the Eclipse IDE ==
Run the Eclipse IDE with the following command:
Source the Yocto toolchain script and run the Eclipse IDE with the following commands:
<pre>
$ cd eclipse
$ ./eclipse
</pre>
Select a new workspace (you can just click OK).<br>
<br>
Choose "Install New Software" from the "Help" pull-down menu.<br>
* In the "Work with" area select "Luna - http://download.eclipse.org/releases/luna".<br>
* Uncheck the "Hide items that are already installed" box.<br>
* Expand the "Linux Tools" option and select:<br>
<pre>
Linux Tools LTTng Tracer Control
Linux Tools LTTng Userspace Analysis
LTTng Kernel Analysis
</pre>
* Expand the "Mobile and Device Development" option and select:
<pre>
C/C++ Remote Launch (Requires RSE Remote System Explorer)
Remote System Explorer End-user Runtime
Remote System Explorer User Actions
Target Management Terminal (Core SDK)
TCF Remote System Explorer add-in
TCF Target Explorer
</pre>
* Expand the "Programming Languages" option and select:
<pre>
C/C++ Autotools Support
C/C++ Development Tools
</pre>
* Click Next twice, accept the necessary EULA and click Finish.
* If asked if you trust the Eclipse certificates, make sure you select the certificates and click OK.
* Click to restart Eclipse when asked to.


== Adding the Yocto Plug-in to the Eclipse IDE ==
$ cd eclipse
In Eclipse, select "Install new Software" from the "Help" menu.<br>
$ source {{#var:TOOLCHAIN_LOCATION}}
* Click the "Add..." button to add a repository, enter the following and click OK.
$ ./eclipse
<pre>
Name: Yocto Jethro (you can actually use any name)
Location: http://downloads.yoctoproject.org/releases/eclipse-plugin/2.0/luna/
</pre>
* Make sure the repository above is selected on the "Work with" drop-down menu and select the following plug-ins from the list:
<pre>
Yocto Project ADT Plug-in
Yocto Project Bitbake Commander Plug-in
Yocto Project Documentation plug-in
</pre>
* Click Next twice, accept the necessary EULA and click Finish.<br>
* Click to restart Eclipse when asked to.<br>


== Configuring the Eclipse Yocto Plug-in ==
Select a new workspace (you can just click OK).
In this section we will configure the Cross Compiler and the Target options. These will then be used as default for your projects from within your workspace.<br>
<br>
Select "Preferences" from the "Window" menu.<br>
* Click on "Yocto Project ADT" from the left options and then under "Cross Compiler Options:" select the "Standalone pre-built toolchain" radio button.
* Under &nbsp; "Toolchain Root Location:" &nbsp; enter &nbsp; "{{#var:TOOLCHAIN_ROOT_LOCATION}}".
* Under &nbsp; "Sysroot Location:" &nbsp; enter &nbsp; "{{#var:TOOLCHAIN_TARGET_SYSROOT_LOCATION}}"
* Under "Target Options:" make sure "External HW" is selected.
* Click OK.


= Create and run a simple application =
= Create and run a simple application =
== Create the Project ==
== Create the Project ==
You can create two types of projects: Autotools-based, or Makefile-based. This section describes how to create Autotools-based projects from within the Eclipse IDE. To create a project based on a Yocto template and then display the source code, follow these steps:
You can create different types of projects: C Managed Build, CMake, Meson, or Makefile-based. This section describes how to create "C Managed Build" projects from within the Eclipse IDE. To create a new project from a "Hello World" template and then display the source code, follow these steps:


* File->New->C Project
* File->New->C/C++ Project
* Click "Yocto Project ADT Autotools Project".
* Click "C Managed Build".
* Select "Hello World ANSI C Autotools Project". This is an Autotools-based project based on a Yocto template.
* Enter a name for the project under the "Project name" field. Do not use hyphens as part of the name.
* Select "Hello World ANSI C Project".
* Select ''Cross GCC'' toolchain


[[File:Prj1.jpg]]
[[File:Prj1_V2.jpg]]


* Enter a name for the project under the "Project name" field. Do not use hyphens as part of the name.
* Click "Next".
* Click "Next".
* Add information in the Author field and make sure the License field is correct.
* Add information in the Author field and make sure the License field is correct and click next.
* Accept the default Debug/Release configurations and click next.
* Enter <code>aarch64-fslc-linux-</code> under "Cross compiler prefix"
* Enter <code>/opt/fslc-xwayland/3.1/sysroots/x86_64-fslcsdk-linux/usr/bin/aarch64-fslc-linux</code> under "Cross compiler path"
 
[[File:Prj1_compiler_V2.jpg]]
 
* Click "Finish".
* Click "Finish".
* Click on "Workbench".
* Click on "Workbench".
Line 115: Line 72:
* Hit Ctrl+B or click the hammer icon to build your project.
* Hit Ctrl+B or click the hammer icon to build your project.


[[File:C_perspective.png]]
[[File:C_perspective_v2.png]]
 
== Configure Cross Compiler ==
In addition to sourcing the yocto environment script, Eclipse must also be configured. Follow these steps to configure sysroot within Eclipse:
 
* Right click on the project and select ''Properties''
* Under ''C/C++ Build'', select ''Settings''
* Add the following flags to ''Miscellaneous'' for ''Cross GCC Compiler'' and ''Cross GCC Linker'' settings:
 
--sysroot=/opt/fsl-imx-xwayland/5.4-zeus/sysroots/aarch64-poky-linux
 
[[File:Toolchain_settings.png]]


== Create communication link ==
== Configure Remote Debugging ==
Using the console of your target set a password with "passwd" command. choose a simple one named "root".<br>
Using the console of your target set a password with "passwd" command. choose a simple one named "root".<br>
The target should be connected to the network via Ethernet or WIFI.<br>
The target should be connected to the network via Ethernet or WIFI.<br>
Use the "ifconfig" command on the target to get its IP address.<br>
Use the "ifconfig" command on the target to get its IP address.<br>
From Eclipse:
From Eclipse:
* Window->Open Perspective->Other
* Click Run->Debug Configurations...
* Double click on ''Remote System Explorer''
* Double click on ''C/C++ Remote Application''.
 
* Type in a name in the ''Name'' field, such as "hello-world debug remote"
[[File:Tcf1.png]]
* In the ''Main'' tab, click on ''New...'' to create a new connection.
 
* In the left bar right click and New->Connection
* Choose TCF and click Next


[[File:Tcf2.png]]
[[File:GDB_Conn.png]]


* Set the Host name to the target's IP address and click Finish
* Select ''SSH'' for the connection type and click ''OK''.
 
* Enter the Target IP Address.
[[File:Tcf3.jpg]]
* Enter ''root'' for the user.
 
* Change to "Password based authentication" and enter password configured in previous step.
* On the left bar right click on the target IP and select connect
* Click ''Finish''
* Set "User ID:" to root, "Password:" to root and check the "Save password"
* Type "/home/root/hello-world" in the ''Remote Absolute File Path for C/C++ Application'' field
* Enter the root password again in the next poop up.
* Click on the ''Debugger'' tab
 
* Enter "aarch64-fslc-linux-gdb" in the ''GDB debugger'' field
Once connected you can browse the target file system, browse target process and lunch a terminal to the target.
[[File:GDB_Conn_2.png]]
* Click ''Apply'' and ''Close'' to finish configuring the debugger


== Remote debug ==
== Remote debug ==
Line 146: Line 112:
Follow the below steps to remotely debug your application on the {{#var:HARDWARE_NAME}}.
Follow the below steps to remotely debug your application on the {{#var:HARDWARE_NAME}}.


* Select "Debug Configurations..." from the "Run" menu.
* Use the keyboard shortcut ''ctrl-b'' to rebuild the application.
* In the left area, expand C/C++ Remote Application.
* Click the bug icon in the toolbar and select "hello-world debug remote" (or whichever name you supplied in the previous step)
* Locate your project and select it to pop up a new tabbed view in the Debug Configurations Dialog.
* Follow the prompt to switch to the Debug perspective
* Enter the absolute path which you want to deploy the application to. Use the "Remote Absolute File Path for C/C++Application:" field. For example, enter /home/root/hello
 
* Click on the "Debugger" tab to see the cross-tool debugger you are using.
[[File:Dbg2_v2.png]]
[[File:Eclipse_DebugConfiguration_Degugger.png]]
* Check the lower red rectangle contents and be sure that the selected launcher is the "Automatic Remote Debugger Launcher"
* If any other launcher is selected:
** copy to clipboard the contents of upper red rectangle
** select "Automatic Remote Debugging Launcher" in the lower red rectangle
** paste from the clipboard to reset the contents of the upper red rectangle
** remember that the debugger path is expected to be something like <sdk_path>/sysroots/x86_64-fslcsdk-linux/usr/bin/arm-fslc-linux-gnueabi/arm-fslc-linux-gnueabi-gdb
* Click on the "Main" tab.
* Hit Debug
* Accept the debug perspective.


[[File:Dbg2.jpg]]
<br><br>
<br><br>
You can now run and debug your program via eclipse. The actual program execution is done on the target, and the output is seen on the Remote Shell on Eclipse.
You can now run and debug your program via eclipse. The actual program execution is done on the target, and the output is seen on the Remote Shell on Eclipse.
<br>
<br>

Revision as of 20:23, 16 July 2021

DART-6UL - Yocto Programming with Eclipse

This guide describes how to use Eclipse to develop and debug applications on the DART-6UL.

Create your rootfs with Eclipse debug support

Append the following to the conf/local.conf file in your Yocto build directory:

EXTRA_IMAGE_FEATURES = " \
    debug-tweaks \
    tools-debug \
    eclipse-debug \
    ssh-server-openssh \
    "

IMAGE_INSTALL_append = " \
    tcf-agent \
    openssh-sftp-server \
    openssh \
    "

Now bitbake your image.

Host tools

To install the toolchain follow Yocto Toolchain installation guide.

Eclipse installation

Download Eclipse

Download Eclipse Luna from here: 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
Run the following command to unpack and install the downloaded Eclipse IDE tarball into a clean directory using the default name eclipse:

$ cd ~
$ tar -xf ~/Downloads/eclipse-cpp-2021-06-R-linux-gtk-x86_64.tar.gz

Configuring the Eclipse IDE

Source the Yocto toolchain script and run the Eclipse IDE with the following commands:

$ cd eclipse
$ source /opt/fslc-x11/2.2.1/environment-setup-armv7at2hf-neon-fslc-linux-gnueabi 
$ ./eclipse

Select a new workspace (you can just click OK).

Create and run a simple application

Create the Project

You can create different types of projects: C Managed Build, CMake, Meson, or Makefile-based. This section describes how to create "C Managed Build" projects from within the Eclipse IDE. To create a new project from a "Hello World" template and then display the source code, follow these steps:

  • File->New->C/C++ Project
  • Click "C Managed Build".
  • Enter a name for the project under the "Project name" field. Do not use hyphens as part of the name.
  • Select "Hello World ANSI C Project".
  • Select Cross GCC toolchain

File:Prj1 V2.jpg

  • Click "Next".
  • Add information in the Author field and make sure the License field is correct and click next.
  • Accept the default Debug/Release configurations and click next.
  • Enter aarch64-fslc-linux- under "Cross compiler prefix"
  • Enter /opt/fslc-xwayland/3.1/sysroots/x86_64-fslcsdk-linux/usr/bin/aarch64-fslc-linux under "Cross compiler path"

File:Prj1 compiler V2.jpg

  • Click "Finish".
  • Click on "Workbench".


  • You should now be in the C/C++ perspective. The left-hand navigation pane shows your project. You can display your source by double clicking the project's source file.
  • Hit Ctrl+B or click the hammer icon to build your project.

C perspective v2.png

Configure Cross Compiler

In addition to sourcing the yocto environment script, Eclipse must also be configured. Follow these steps to configure sysroot within Eclipse:

  • Right click on the project and select Properties
  • Under C/C++ Build, select Settings
  • Add the following flags to Miscellaneous for Cross GCC Compiler and Cross GCC Linker settings:
--sysroot=/opt/fsl-imx-xwayland/5.4-zeus/sysroots/aarch64-poky-linux

Toolchain settings.png

Configure Remote Debugging

Using the console of your target set a password with "passwd" command. choose a simple one named "root".
The target should be connected to the network via Ethernet or WIFI.
Use the "ifconfig" command on the target to get its IP address.
From Eclipse:

  • Click Run->Debug Configurations...
  • Double click on C/C++ Remote Application.
  • Type in a name in the Name field, such as "hello-world debug remote"
  • In the Main tab, click on New... to create a new connection.

GDB Conn.png

  • Select SSH for the connection type and click OK.
  • Enter the Target IP Address.
  • Enter root for the user.
  • Change to "Password based authentication" and enter password configured in previous step.
  • Click Finish
  • Type "/home/root/hello-world" in the Remote Absolute File Path for C/C++ Application field
  • Click on the Debugger tab
  • Enter "aarch64-fslc-linux-gdb" in the GDB debugger field

GDB Conn 2.png

  • Click Apply and Close to finish configuring the debugger

Remote debug

Follow the below steps to remotely debug your application on the DART-6UL.

  • Use the keyboard shortcut ctrl-b to rebuild the application.
  • Click the bug icon in the toolbar and select "hello-world debug remote" (or whichever name you supplied in the previous step)
  • Follow the prompt to switch to the Debug perspective

Dbg2 v2.png



You can now run and debug your program via eclipse. The actual program execution is done on the target, and the output is seen on the Remote Shell on Eclipse.