How-to: Set Up Yocto Plugin for Eclipse
Targeted Hardware | |
Targeted Software | BSP Yocto FSL iMX7 PD18.1.0 |
Date |
|
PHYTEC recommends Eclipse as a platform for building and debugging applications. This guide will show you how to set up the Yocto plugin for Eclipse to cross-develop applications for Yocto-based PHYTEC BSPs.
The instructions are based on a Host PC with a Virtual Machine running Ubuntu 16.04 LTS and Eclipse Photon installed.
Preparing your BSP and Building the SDK
- Before following the rest of this guide, make sure the BSP is built as described in the Quickstart: Quickstart - Building BSP from Source.
Once the BSP is built the following command needs to be run in the BSP directory to allow IDE support.
bitbake meta-ide-support
CODENavigate to the BSP build directory and execute the following bitbake command to install the sdk. This will take a little while to complete.
The specific MACHINE configuration can be found in our release notes: BSP-Yocto-FSL-iMX7-PD18.1.0 Release NotesMACHINE=imx7d-phyboard-zeta-001 bitbake fsl-image-gui -c populate_sdk
CODEThe "populate_sdk" command creates a .sh file in the <BSP DIRECTORY>/build/tmp/deploy/sdk directory. Execute the created script to install the sdk on the host machine.
After the script starts it will ask for a directory to install the sdk too. Hit enter for the default location../<BSP DIRECTORY>/build/tmp/deploy/sdk/fsl-imx-x11-glibc-x86_64-fsl-image-gui-cortexa7hf-neon-toolchain-4.9.11-1.0.0.sh
CODE
Eclipse Setup
The instructions are applicable for Eclipse Oxygen and Photon running on Ubuntu 16.04 LTS. Older versions of Eclipse (ex. Luna or Neon) have similar steps but should be run on a Ubuntu 14.04 LTS system.
- Download and install the Eclipse Installer: https://wiki.eclipse.org/Eclipse_Installer
Unpack the Eclipse Installer to a desired location. This will automatically create a directory called "eclipse-installer".
tar -xvzf eclipse-inst-linux64.tar.gz -C /<ECLIPSE DIRECTORY>/
CODE- Download the latest Java 10 JDK: http://www.oracle.com/technetwork/java/javase/downloads/index.html
Unpack the JDK into the "eclipse-installer" directory that was created in the previous step.
tar -xvzf jdk-10.0.1_linux-x64_bin.tar.gz -C /<ECLIPSE DIRECTORY>/eclipse-installer/
CODEIn the "eclipse-installer" directory edit the "eclipse-inst.ini" file. Add the following lines at the top of the file:
-vm /<ECLIPSE DIRECTORY>/eclipse-installer/jdk-10.0.1/bin/java
CODEThe eclipse installer can now be run from the "eclipse-installer" directory.
./eclipse-inst
CODE- Double click on "Eclipse IDE for C/C++ Developers" and it will bring up an options window.
- Change the "Installation Folder" to a desired location if needed and then click "Install" when ready
- Click "Accept" when the "License Confirmation" window pops up
- DO NOT LAUNCH Eclipse or close the program if it was launched. Eclipse will not function properly if launched before sourcing the correct environment. Please see the next section (Sourcing the Environment and Setting up Eclipse) on how to do t
Sourcing the Environment and Setting up Eclipse
The correct environment needs to be sourced. In the terminal navigate to the BSP directory and source the following environment.
source build/tmp/work/imx7d_phyboard_zeta_001-poky-linux-gnueabi/fsl-image-gui/1.0-r0/sdk/image/opt/fsl-imx-x11/4.9.11-1.0.0/environment-setup-cortexa7hf-neon-poky-linux-gnueabi
CODEEclipse MUST be started in the same terminal window the environment was sourced from.
./eclipse/cpp-photon/eclipse/eclipse
CODE- Before starting a new project go to Help -> Install New Software
- The "Install" window will pop up and you want to click on ADD
- In the "Add Repository" window, name the plugin what you would like and then go to this link (http://downloads.yoctoproject.org/releases/eclipse-plugin/), find the latest plugin for oxygen or photon and then copy the address into the location field. Click OK when ready.
"Name": yocto_plugin
"Location": http://downloads.yoctoproject.org/releases/eclipse-plugin/2.5.0/oxygen/ A few available plugins will show up in the window. Select all items and click Next to install.
In Eclipse go to Window -> Preferences.
Select the Yocto Project SDK option on the left.
Under "Cross Compiler Options" select the radial button for "Standalone pre-built toolchain".
Set the "Toolchain Root Location" to the SDK you just installed: /opt/fsl-imx-x11/4.9.11-1.0.0/
The "Target Architecture" field should automatically fill with "cortexa7hf-neon-poky-linux-gnueabi"
Set the "Sysroots Location": /opt/fsl-imx-x11/4.9.11-1.0.0/sysroots
Click "Apply and Close" to save settings.
Creating a Test Application
Now that Eclipse is set up a test project can be created to verify everything is set up correctly. Go to File → New → Project
- Select the "C/C++" drop down and choose "C Project". Click Next.
- Name the project "test" and leave the default workspace box checked.
- In the "Project type:" menu, under the "Executable" drop down choose "Hello World ANSI C Project".
- In the "Toolchains:" menu, choose "Linux GCC". Click Finish.
Running an Application on Target Hardware
- In the "Project Explorer" Right-click on the newly created project and choose "Properties".
- On the left side, under the "C/C++ Build" drop down menu choose "Settings"
In the main window choose "GCC C Compiler" and change "Command:" to the following:
${CC}
CODENow choose "GCC C Linker"
Change the "Command:" to the following:
${CC}
CODEAdd in ${LDFLAGS} between ${COMMAND} and ${FLAGS} in the "Command line pattern:" field so it looks like the following:
${COMMAND} ${LDFLAGS} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}
CODE
Under "GCC Assembler", change the "Command:" to the following:
${AS}
CODENow switch to the "Build Steps" tab and change the "Post-build steps" "Command:" field to the following. Make sure to change the ip address of the command to match the address of the target hardware.
scp ./test root@192.168.xx.xx:/home/root/. ;ssh root@192.168.xx.xx /home/root/test
CODEClick "Apply and Close" when you are ready to build.
Build the project and you should see a similar output in Eclipse to the following:
09:40:47 **** Build of configuration Debug for project test **** make all Building file: ../src/test.c Invoking: GCC C Compiler arm-poky-linux-gnueabi-gcc -march=armv7ve -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/cortexa7hf-neon-poky-linux-gnueabi -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/test.d" -MT"src/test.o" -o "src/test.o" "../src/test.c" Finished building: ../src/test.c Building target: test Invoking: GCC C Linker arm-poky-linux-gnueabi-gcc -march=armv7ve -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/cortexa7hf-neon-poky-linux-gnueabi -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o "test" ./src/test.o Finished building target: test make --no-print-directory post-build scp ./test root@192.168.3.67:/home/root/. ;ssh root@192.168.3.67 /home/root/test !!!Hello World!!! 09:40:48 Build Finished. 0 errors, 0 warnings. (took 1s.104ms)
CODE