Yocto Programming with Eclipse v2: Difference between revisions
No edit summary |
No edit summary |
||
Line 77: | Line 77: | ||
* Add the following flags to ''Miscellaneous'' for ''Cross GCC Compiler'' and ''Cross GCC Linker'' settings: | * Add the following flags to ''Miscellaneous'' for ''Cross GCC Compiler'' and ''Cross GCC Linker'' settings: | ||
--sysroot= | --sysroot={{#var:TOOLCHAIN_ROOT_LOCATION}} | ||
[[File:Toolchain_settings.png]] | [[File:Toolchain_settings.png]] |
Revision as of 21:00, 16 July 2021
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 = " \ ssh-server-openssh \ " IMAGE_INSTALL_append = " \ 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 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
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. 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
- 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
arm-fslc-linux-gnueabi-
under Cross compiler prefix - Enter
/opt/fslc-x11/2.2.1/sysroot/x86_64-fslcsdk-linux/usr/bin/arm-fslc-linux-gnueabi
under Cross compiler path
- 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.
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/fslc-x11/2.2.1
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.
- 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 "arm-fslc-linux-gnueabi-gdb" in the GDB debugger field
- 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
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.