Yocto Programming with Eclipse v2: Difference between revisions

From Variscite Wiki
No edit summary
No edit summary
 
(14 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<!-- Set release according to "release" parameter in URL and use DUNFELL_V1.5_DART-MX8M-MINI as default
<!-- Set release according to "release" parameter in URL and use DUNFELL_V1.5_DART-MX8M-MINI as default
--> {{#vardefine:RELEASE_PARAM|{{#urlget:release}}}} <!--
--> {{INIT_RELEASE_PARAM|RELEASE_DUNFELL_V1.5_DART-MX8M-MINI}} <!--
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM|RELEASE_DUNFELL_V1.5_DART-MX8M-MINI}}}} <!--
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{PageHeader|{{#var:HARDWARE_NAME}} - Yocto Programming with Eclipse}} {{DocImage|category1={{#var:HARDWARE_NAME}}|category2=Yocto}}
--> {{#lst:Debian_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:B2QT_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
 
--> {{#vardefine:PLATFORM_OS|Yocto}} <!-- Yocto specific variables (default)
-->    {{#vardefine:CROSS_COMPILER_PREFIX|{{#var:TOOLCHAIN_TYPE}}-}} <!--
-->    {{#vardefine:CROSS_COMPILER_PATH|{{#var:TOOLCHAIN_HOST_SYSROOT_LOCATION}}/usr/bin/{{#var:TOOLCHAIN_TYPE}}}} <!--
-->    {{#vardefine:TOOLCHAIN_SYSROOT_PATH|{{#var:TOOLCHAIN_TARGET_SYSROOT_LOCATION}}}} <!--
--> {{#varexists:DEBIAN_NAME| <!-- Debian specific variables
-->    {{#vardefine:PLATFORM_OS|Debian}} <!--
-->    {{#vardefine:CROSS_COMPILER_PREFIX|{{#var:CROSS_COMPILE}}}} <!--
-->    {{#vardefine:CROSS_COMPILER_PATH|${HOME}/{{#var:BUILD_FOLDER_NAME}}/toolchain/{{#var:TOOLCHAIN}}/bin}} <!--
-->    {{#vardefine:TOOLCHAIN_SYSROOT_PATH|${HOME}/{{#var:BUILD_FOLDER_NAME}}/toolchain/sysroot}} <!--
--> }} <!--
 
--> {{PageHeader|{{#var:HARDWARE_NAME}} - {{#var:PLATFORM_OS}} Programming with Eclipse}} {{DocImage|category1=Yocto|category2=Debian}} [[category:{{#var:HARDWARE_NAME}}]]
This guide describes how to use Eclipse to develop and debug applications on the {{#var:HARDWARE_NAME}}.
This guide describes how to use Eclipse to develop and debug applications on the {{#var:HARDWARE_NAME}}.
__toc__
__toc__


= Create your rootfs with Eclipse debug support =
= Create your rootfs with Eclipse debug support =
{{#switch: {{#var:PLATFORM_OS}}
| Yocto=
Append the following to the conf/local.conf file in your Yocto build directory:
Append the following to the conf/local.conf file in your Yocto build directory:
<pre>
<pre>
...
EXTRA_IMAGE_FEATURES = " \
EXTRA_IMAGE_FEATURES = " \
    eclipse-debug \
     ssh-server-openssh \
     ssh-server-openssh \
     "
     "
</pre>


IMAGE_INSTALL_append = " \
<!-- Since Zeus and above, the dropbear recipe introduced a patch that limits some ciphers
    openssh-sftp-server \
that are defined as weak. Eclipse still seems to use those ciphers, causing ssh compatible
    openssh \
issues. Let's add here a note for the customers: -->
    "
For Yocto Zeus and above, using dropbear, one may need to append the following to the conf/local.conf file to avoid SSH compatible ciphers issues:
{{#ifexpr:{{#var:YOCTO_VERSION}} >= 3.4 <!-- >= Honister -->
|
<pre>
...
PACKAGECONFIG:remove:pn-dropbear = " disable-weak-ciphers"
</pre>
|
<pre>
...
PACKAGECONFIG_remove_pn-dropbear = " disable-weak-ciphers"
</pre>
</pre>
}}
Now bitbake your image.
Now bitbake your image.
| Debian=
To enable debug support on the target, make sure to have the following packages installed:
* gdbserver
* openssh-sftp-server <!--
-->{{Note|'''Info:'''<br>
The Eclipse IDE supports '''gdbserver''' and '''tcf-agent'''; both are servers/agents to enable the debug capabilities on the target. In this guide, we will focus on Remote Debugging with the Eclipse IDE using '''gdbserver'''.|info}}
The packages can be installed by running the following commands on the target:
# apt-get update
# apt-get -y install gdbserver openssh-sftp-server <!--
-->{{Note|'''Note:''' The package '''openssh-sftp-server''' may possibly already be installed.|info}}
If you want to learn how to add the packages at compile time, please refer to {{Varlink2|Adding Debian packages|{{#var:RELEASE_LINK}}}}.
}}


= Setup Host Computer Environment =
= Setup Host Computer Environment =
Line 29: Line 76:
  $ sudo apt-get -y install build-essential gdb gdb-multiarch git default-jre
  $ sudo apt-get -y install build-essential gdb gdb-multiarch git default-jre


== Install Yocto Toolchain ==
== Install {{#var:PLATFORM_OS}} Toolchain ==


To install the toolchain follow {{Varlink2|Yocto Toolchain installation|{{#var:RELEASE_LINK}}}} guide.
To install the toolchain follow {{Varlink2|{{#var:PLATFORM_OS}} Toolchain installation|{{#var:RELEASE_LINK}}}} guide.


== Download Eclipse ==
== Download Eclipse ==
Line 44: Line 91:


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


  $ cd eclipse
  $ cd eclipse
$ source {{#var:TOOLCHAIN_LOCATION}}
  $ ./eclipse
  $ ./eclipse


Line 66: Line 112:
* Add information in the ''Author'' field and make sure the ''License'' field is correct and 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''.
* Accept the default Debug/Release configurations and click ''Next''.
* Enter <code>{{#var:TOOLCHAIN_TYPE}}-</code> under ''Cross compiler prefix''
* Enter <code>{{#var:CROSS_COMPILER_PREFIX}}</code> under ''Cross compiler prefix''
* Enter <code>{{#var:TOOLCHAIN_HOST_SYSROOT_LOCATION}}/usr/bin/{{#var:TOOLCHAIN_TYPE}}</code> under ''Cross compiler path''
* Enter <code>{{#var:CROSS_COMPILER_PATH}}</code> under ''Cross compiler path''


[[File:Prj1_compiler_V2.png]]
{{#switch:{{#var:PLATFORM_OS}}
| Yocto=[[File:Prj1_compiler_V2.png]]
| Debian=[[File:eclipse_compiler_debian.png|800px]]
}}


* Click "Finish".
* Click "Finish".
Line 78: Line 127:


== Configure Cross Compiler ==
== Configure Cross Compiler ==
In addition to sourcing the yocto environment script, the sysroot flag must be added to the linker and C/C++ compilers within Eclipse:
The sysroot flag must be added to the linker and C/C++ compilers within Eclipse:


* Right click on the project and select ''Properties''
* Right click on the project and select ''Properties''
Line 85: Line 134:
* Add the following include path to ''Cross GCC Compiler->Includes''
* Add the following include path to ''Cross GCC Compiler->Includes''


  {{#var:TOOLCHAIN_TARGET_SYSROOT_LOCATION}}/usr/include
  {{#var:TOOLCHAIN_SYSROOT_PATH}}/usr/include


''C/C++ Build -> Settings -> Cross GCC Compiler -> Includes''
''C/C++ Build -> Settings -> Cross GCC Compiler -> Includes''


[[File:Toolchain_include.png]]
{{#switch:{{#var:PLATFORM_OS}}
| Yocto=[[File:Toolchain_include.png]]
| Debian=[[File:eclipse_toolchain_include_debian.png]]
}}


* Append the following to ''Cross GCC Compiler -> Miscellaneous -> Other Flags'':
* Append the following to ''Cross GCC Compiler -> Miscellaneous -> Other Flags'':


  --sysroot={{#var:TOOLCHAIN_TARGET_SYSROOT_LOCATION}}
  --sysroot={{#var:TOOLCHAIN_SYSROOT_PATH}}


''C/C++ Build -> Settings -> Cross GCC Compiler -> Miscellaneous''
''C/C++ Build -> Settings -> Cross GCC Compiler -> Miscellaneous''


[[File:Toolchain_settings.png]]
{{#switch:{{#var:PLATFORM_OS}}
| Yocto=[[File:Toolchain_settings.png]]
| Debian=[[File:eclipse_toolchain_settings_debian.png]]
}}


* Append the following to ''Cross GCC Linker -> Miscellaneous -> Other Flags'':
* Append the following to ''Cross GCC Linker -> Miscellaneous -> Other Flags'':


  --sysroot={{#var:TOOLCHAIN_TARGET_SYSROOT_LOCATION}}
  --sysroot={{#var:TOOLCHAIN_SYSROOT_PATH}}


''C/C++ Build -> Settings -> Cross GCC Linker -> Miscellaneous''
''C/C++ Build -> Settings -> Cross GCC Linker -> Miscellaneous''


[[File:Toolchain_settings_2.png]]
{{#switch:{{#var:PLATFORM_OS}}
| Yocto=[[File:Toolchain_settings_2.png]]
| Debian=[[File:eclipse_toolchain_settings_2_debian.png]]
}}


== Configure Remote Debugging ==
== Configure Remote Debugging ==
Line 114: Line 172:
* Click Run->Debug Configurations...
* Click Run->Debug Configurations...
* Double click on ''C/C++ Remote Application''.
* Double click on ''C/C++ Remote Application''.
* In the ''Main'' tab, click on ''New...'' to create a new connection.
* In the ''Main'' tab, section ''C/C++ Application'', type <code>Debug/hello-world</code>.
* Next, click on ''New...'' to create a new connection.


[[File:GDB_Conn.png]]
[[File:GDB_Conn_V2.png]]


* Select ''SSH'' for the connection type and click ''OK''.
* Select ''SSH'' for the connection type and click ''OK''.
Line 125: Line 184:
* Type "/home/root/hello-world" in the ''Remote Absolute File Path for C/C++ Application'' field
* Type "/home/root/hello-world" in the ''Remote Absolute File Path for C/C++ Application'' field
* Click on the ''Debugger'' tab
* Click on the ''Debugger'' tab
* Enter  <code>{{#var:TOOLCHAIN_TYPE}}-gdb</code> in the ''GDB debugger'' field
* Enter  <code>{{#var:CROSS_COMPILER_PREFIX}}gdb</code> in the ''GDB debugger'' field
[[File:GDB_Conn_2.png]]
{{#switch:{{#var:PLATFORM_OS}}|Yocto=[[File:GDB_Conn_2.png]]|Debian=[[File:eclipse_gdb_conn_debian.png]]}}
* Click ''Apply'' and ''Close'' to finish configuring the debugger
* Click ''Apply'' and ''Close'' to finish configuring the debugger



Latest revision as of 21:16, 23 August 2024

Warning: This page is designed to be used with a 'release' URL parameter.

This page is using the default release RELEASE_DUNFELL_V1.5_DART-MX8M-MINI.
To view this page for a specific Variscite SoM and software release, please follow these steps:

  1. Visit variwiki.com
  2. Select your SoM
  3. Select the software release
DART-MX8M-MINI - Yocto Programming with Eclipse

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

Create your rootfs with Eclipse debug support

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

...
EXTRA_IMAGE_FEATURES = " \
    eclipse-debug \
    ssh-server-openssh \
    "

For Yocto Zeus and above, using dropbear, one may need to append the following to the conf/local.conf file to avoid SSH compatible ciphers issues:

...
PACKAGECONFIG_remove_pn-dropbear = " disable-weak-ciphers"

Now bitbake your image.

Setup Host Computer Environment

Please follow the steps below to prepare a fresh Ubuntu 20.04 installation for Eclipse debugging:

Install Dependencies

$ sudo apt-get -y update
$ sudo apt-get -y install build-essential gdb gdb-multiarch git default-jre

Install Yocto Toolchain

To install the toolchain follow Yocto Toolchain installation guide.

Download Eclipse

Download Eclipse 2021-06 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

Create and run a simple application

Run the Eclipse IDE

Run the Eclipse IDE with the following commands:

$ cd eclipse
$ ./eclipse

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

Create the Project

You can create different types of projects: C Managed Build, CMake, Meson, or Makefile. 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
  • Select C Managed Build and click Next.
  • 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

Prj1 V2.png

  • 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

Prj1 compiler V2.png

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

C perspective v2.png

Configure Cross Compiler

The sysroot flag must be added to the linker and C/C++ compilers within Eclipse:

  • Right click on the project and select Properties
  • Under C/C++ Build, select Settings
  • Add the following include path to Cross GCC Compiler->Includes
/opt/fslc-xwayland/3.1/sysroots/aarch64-fslc-linux/usr/include

C/C++ Build -> Settings -> Cross GCC Compiler -> Includes

Toolchain include.png

  • Append the following to Cross GCC Compiler -> Miscellaneous -> Other Flags:
--sysroot=/opt/fslc-xwayland/3.1/sysroots/aarch64-fslc-linux

C/C++ Build -> Settings -> Cross GCC Compiler -> Miscellaneous

Toolchain settings.png

  • Append the following to Cross GCC Linker -> Miscellaneous -> Other Flags:
--sysroot=/opt/fslc-xwayland/3.1/sysroots/aarch64-fslc-linux

C/C++ Build -> Settings -> Cross GCC Linker -> Miscellaneous

Toolchain settings 2.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.
  • In the Main tab, section C/C++ Application, type Debug/hello-world.
  • Next, click on New... to create a new connection.

GDB Conn V2.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-MX8M-MINI.

  • Use the keyboard shortcut ctrl-b to rebuild the application.
  • Click the bug icon in the toolbar and select "hello-world debug" (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.