Difference between revisions of "Eclipse CDT projects with bitbake"

From ElphelWiki
Jump to: navigation, search
(Setting up New Project)
(Additional manual setup for linux-elphel.project)
 
(13 intermediate revisions by the same user not shown)
Line 53: Line 53:
 
*'''scripts''' - a link to a collection of scripts needed for all projects. It contains the following files:
 
*'''scripts''' - a link to a collection of scripts needed for all projects. It contains the following files:
 
**'''run_bitbake.sh''' - script to create an environment and execute bitbake recipe. Used every time Eclipse builds the project.
 
**'''run_bitbake.sh''' - script to create an environment and execute bitbake recipe. Used every time Eclipse builds the project.
**'''used_files.py''' - script to create a list of header files/directories used by bitbake to build the project. It is not needed to run to configure existing projects - all of them are provided with preconfigured '''.cproject''' files. ''TODO: add link to description''
+
**'''used_files.py''' - script to create a list of header files/directories used by bitbake to build the project. It is not needed to run to configure existing projects - all of them are provided with preconfigured '''.cproject''' files. ''TODO: add link to description'' [[Used_files]]
 
*'''.settings''' - project settings maintained by Eclipse IDE
 
*'''.settings''' - project settings maintained by Eclipse IDE
 
*'''src''' - a hard-coded (in '''used_files.py''') directory name for C/C++ source files. Source files should not be in the project root directory for convenience of filter generation for additional source (headers) directories
 
*'''src''' - a hard-coded (in '''used_files.py''') directory name for C/C++ source files. Source files should not be in the project root directory for convenience of filter generation for additional source (headers) directories
Line 63: Line 63:
 
*'''.project''' - Eclipse general project configuration. This file is copied from version-controlled '''eclipse_project_setup''' during setup or manually.
 
*'''.project''' - Eclipse general project configuration. This file is copied from version-controlled '''eclipse_project_setup''' during setup or manually.
 
*'''README.md''' - README file presented by the Git repository web interface
 
*'''README.md''' - README file presented by the Git repository web interface
*'''VERSION''' - project version, used by bitbake build process to determine which dependent recipes have to be re-ran.  
+
*'''VERSION''' - project version, used by bitbake build process to determine which dependent recipes have to be re-ran.
 +
 
 
==Initializing Eclipse Workspace for Existing (Cloned) Projects==
 
==Initializing Eclipse Workspace for Existing (Cloned) Projects==
 
After running '''setup.py''' for the first time you may create the brand new workspace for Eclipse, that should have all necessary plugins (such as CDT and EGit at least) already installed. Workspace is created with '''setup_eclipse.py''' script, list of projects that it sets up is saved in '''setup_eclipse_paths.xml''' file. '''setup_eclipse.py''' provides usage information when launched without parameters, for normal run it requires full path to Eclipse installation - directory that contains '''eclipse''' executable and '''eclipse.ini''' configuration. Before running '''setup_eclipse.py''' Eclipse should have all the required plugins installed (at least CDT and EGit) using temporary workspace.
 
After running '''setup.py''' for the first time you may create the brand new workspace for Eclipse, that should have all necessary plugins (such as CDT and EGit at least) already installed. Workspace is created with '''setup_eclipse.py''' script, list of projects that it sets up is saved in '''setup_eclipse_paths.xml''' file. '''setup_eclipse.py''' provides usage information when launched without parameters, for normal run it requires full path to Eclipse installation - directory that contains '''eclipse''' executable and '''eclipse.ini''' configuration. Before running '''setup_eclipse.py''' Eclipse should have all the required plugins installed (at least CDT and EGit) using temporary workspace.
 +
 +
./setup_eclipse.py <eclipse_home> <workspace_path>
  
 
'''setup_eclipse.py''' performs 2 actions:
 
'''setup_eclipse.py''' performs 2 actions:
Line 72: Line 75:
  
 
After creating a new workspace with '''setup_eclipse.py''' it can be opened with Eclipse, the projects you plan to use have to be indexed (right-click on the project in the Navigator ⇒ Index ⇒ Rebuild.
 
After creating a new workspace with '''setup_eclipse.py''' it can be opened with Eclipse, the projects you plan to use have to be indexed (right-click on the project in the Navigator ⇒ Index ⇒ Rebuild.
 +
=== Additional manual setup for linux-elphel.project===
 +
[[File:Eclipse_cdt.png|right|300px|frame|Adding ''linux/include/generated/autoconf.h'' entry to ''linux-elphel'' project properties]]
 +
Until we found a way how to set it automatically, the linux/include/generated/autoconf.h file has to be added to the project properties, as shown in the screenshot.
 +
 +
==Initializing Eclipse Workspace for Existing (Cloned) Verilog Projects==
 +
'''setup_eclipse.py''' can also be used to setup a separate workspace for the FPGA projects for the camera:
 +
 +
*x393 - full camera RTL code and test benches. It has several active branches:
 +
** master - production camera code
 +
** dct - development branch for testing DCT-IV/DST-IV and CLT modules for image correction and 3d reconstruction
 +
** CMV300 - development for the high-speed CMOSIS sensor, will be used for other sensors with compatible interface
 +
*x393_sata - AHCI/SATA subsystem. The code is included in x393, this repository is for faster troubleshooting and may be used for other applications
 +
*x359 - FPGA code for [[10359|10359 sensor multiplexer]]
 +
 +
These projects are now opened from the second instance of Eclipse IDE. [https://git.elphel.com/Elphel/vdt-plugin|VDT plugin] has to be installed first (imported to the workspace and set up). The Eclipse FPGA workspace is created with the following command issued from the elphel393 project directory:
 +
./setup_eclipse.py <eclipse_home> <workspace_fpga_path> setup_eclipse_fpga_paths.xml
 +
where eclipse_home is the path to Eclipse installation and  workspace_fpga_path is a path to the new workspace (should be different from the workspace_path set earlier.
 +
The workspace_fpga_path should also be specified in Run Configuration -> Eclipse application of the "main" Eclipse.
  
 
==Setting up New Project==
 
==Setting up New Project==
When using CDT the CDT Builder is the only builder to support error processing so we use it to launch bitbake compilation recipe for build command. Additional builder 'SCP apps-astreamer to target' is set up to transfer prepared binaries to the target camera. Figure 1 shows project ⇒ properties  ⇒ Builders view with CDT Builder moved to the first position, and the SCP tool - to the second (and disabled. When disabled it will not be launched automatically - camera has to be connected for SCP to succeed, and Poky local.conf has to have camera IP address set up for transfers. No other builders are required - they may be disabled and later removed, by deleting corresponding firl from the '''.externalToolBuilders''' directory (while Eclipse is closed).
+
 
[[File:Eclipse builders.png|500px|thumb|right|Figure 1. Project builders]]
+
<gallery widths=400 heights=500 mode=nolines> <!-- caption="Setting up external tool"-->
----
+
File:Eclipse builders.png| Figure 1a. Project builders
Figure2. shows SCP tool configuration dialog: Set  
+
File:Eclipse scp main.png| Figure 1b. Configuring SCP to target tool for apps-astreamer project
 +
File:Eclipse scp options.png| Figure 1c. Configuring SCP to target tool for apps-astreamer project(options)
 +
</gallery>
 +
When using CDT the CDT Builder is the only builder to support error processing so we use it to launch bitbake compilation recipe for build command. Additional builder 'SCP apps-astreamer to target' is set up to transfer prepared binaries to the target camera. Figure 1a shows project ⇒ properties  ⇒ Builders view with CDT Builder moved to the first position, and the SCP tool - to the second (and disabled. When disabled it will not be launched automatically - camera has to be connected for SCP to succeed, and Poky local.conf has to have camera IP address set up for transfers. No other builders are required - they may be disabled and later removed, by deleting corresponding firl from the '''.externalToolBuilders''' directory (while Eclipse is closed).
 +
Figure 1b. shows SCP tool configuration dialog: Set  
 
*'''Name''' field with '''SCP <bitbake-target> to target'''
 
*'''Name''' field with '''SCP <bitbake-target> to target'''
*'''Location''' with '''${workspace_loc:/<project-relative-path-to-workspace>/scripts/run_bitbake.sh}''' and
+
*'''Location''' with '''${workspace_loc:/<project-directory>/scripts/run_bitbake.sh}''' and
 
*'''Arguments''' with '''<bitbake-target> -c target_scp -f'''
 
*'''Arguments''' with '''<bitbake-target> -c target_scp -f'''
[[File:Eclipse scp main.png|500px|thumb|right|Figure 2. Configuring SCP to target tool for apps-astreamer project]]
+
Figure 1c shows 'Build Options" tab. Default settings can be kept.
----
 
[[File:Eclipse scp options.png|500px|thumb|right|Figure 3. Configuring SCP to target tool for apps-astreamer project(options)]]
 
Figure 3 shows 'Build Options" tab. Default settings can be kept.
 
  
[[File:Eclipse ccpp build.png|700px|thumb|right|Figure 4. C/C++ Build ⇒ Builder Settings]]
+
<gallery widths=600 heights=375 mode=nolines> <!-- caption="Setting up external tool"-->
Figure 4 shows '''CDT Builder''' setup
+
File:Eclipse ccpp build.png| Figure 2a. C/C++ Build ⇒ Builder Settings<br/>Uncheck 'Use default build command' and set '''Build Command''' to '''${workspace_loc:/<project-directory>/scripts/run_bitbake.sh} <bitbake-target>'''.<br/>Keep '''Build directory''' content.
[[File:Eclipse ccpp build behavior.png|700px|thumb|right|Figure 5. C/C++ Build ⇒ Behavior]]
+
File:Eclipse ccpp build behavior.png| Figure 2b. C/C++ Build ⇒ Behavior<br/>uncheck '''Clean''' and for '''Build (Incremental build)''' enter '''-c compile -f'''
[[File:Eclipse ccpp build refresh.png|700px|thumb|right|Figure 6. C/C++ Build ⇒ Refresh Policy]]
+
File:Eclipse ccpp build refresh.png| Figure 2c. C/C++ Build ⇒ Refresh Policy<br/>Keep fields in default state
[[File:Eclipse source location.png|700px|thumb|right|Figure 7. C/C++ General ⇒ Paths and Symbols ⇒ Source Location]]
+
File:Eclipse source location.png| Figure 2d. C/C++ General ⇒ Paths and Symbols ⇒ Source Location<br/>Initially just the project root path will appear there. You will need to add path to '''src''' subdirectory, then remove initial one (project root).<br/>The second entry will appear after you close Eclipse, run '''scripts/used_files.py sysroots''' and then re-open Eclipse. Some projects require different parameters instead of '''"sysroots"''': linux kernel development needs '''"linux"''', PHP extension requires '''"php"'''.
 +
</gallery>

Latest revision as of 13:25, 4 April 2019

Introduction

Elphel camera software is based on Yocto Poky distribution, all the individual projects such as Linux kernel drivers, C/C++ applications, web applications, Python projects are organized as Makefile projects, each tied to a separate Git repository. The makefiles are not standalone, they receive defined variables provided by bitbake recipes and classes.

The top project elphel393 has the setup.py script that installs and synchronizes them. All projects have Eclipse IDE configuration data (in eclipse_project_setup subdirectories), and this data is copied to the project root by setup.py. As Eclipse project settings may have user-dependent settings, current configuration files (/.project, /.cproject, ...) are not version controlled, so to restore them after corruption or just to get updated versions you need either to manually copy eclipse_project_setup sub-tree, or delete /.project and re-run setup.py.

Eclipse IDE setting reference not only files that are in the Git repository, but also those that are generated during build process, so Eclipse should be launched with these projects only after the command-line build process has finished. If Eclipse is opened after some project is cleared (such as with bitbake -c clean) it will delete the non-existing directories from .cproject configuration files. If that happens, you may close Eclipse and restore .cproject from the eclipse_project_setup/.cproject.


After running setup.py for the first time you may create the brand new workspace for Eclipse. Projects are relying on bitbake build process, so main Eclipse build command launches bitbake target-name -c compile -f instead of make all or similar. And as error processing (problem highlighting in the source code, jump to source file/line) is possible only for the main builder, it is the CDT Builder that has to be configured this way.


Project Files and Directories

Below is the file/directory list of a typical application (elphel-apps-astreamer is a subdirectory of elphel393/rootfs-elphel, apps-astreamer - bitbake target for this project):

├── bitbake-logs -> /home/eyesis/nc393/elphel393/poky/build/tmp/work/cortexa9-neon-poky-linux-gnueabi/apps-astreamer/1_0-23/temp
├── eclipse_project_setup
│   ├── .externalToolBuilders
│   │   └── SCP apps-astreamer to target.launch
│   ├── .cproject
│   └── .project
├── .externalToolBuilders
│   └── SCP apps-astreamer to target.launch
├── .git
 ...
├── image -> /home/eyesis/nc393/elphel393/poky/build/tmp/work/cortexa9-neon-poky-linux-gnueabi/apps-astreamer/1_0-23/image
├── scripts -> ../../scripts/
│   ├── run_bitbake.sh
│   └── used_files.py
├── .settings
│   └── language.settings.xml
├── src
│   ├── audio.cpp
│   ├── audio.h
 ...
│   ├── streamer.h
│   ├── video.cpp
│   └── video.h
├── sysroots -> /home/eyesis/nc393/elphel393/poky/build/tmp/sysroots
├── .cproject
├── .gitignore
├── LICENSE
├── Makefile
├── .project
├── README.md
└── VERSION
  • bitbake-logs is a convenience link to the latest bitbake build logs
  • eclipse_project_setup copy of Eclipse IDE settings under version control. Content of the subdirectory is copied (during setup or manually) to teh project root directory (one level up).
  • .externalToolBuilders is copied from eclipse_project_setup and then maintained by Eclipse. Currently is used to launch file copying to the target (actual camera).
  • .git - project Git data tree
  • image is a link to directory that contains deployable files, built as a result of bitbake recipes execution.
  • scripts - a link to a collection of scripts needed for all projects. It contains the following files:
    • run_bitbake.sh - script to create an environment and execute bitbake recipe. Used every time Eclipse builds the project.
    • used_files.py - script to create a list of header files/directories used by bitbake to build the project. It is not needed to run to configure existing projects - all of them are provided with preconfigured .cproject files. TODO: add link to description Used_files
  • .settings - project settings maintained by Eclipse IDE
  • src - a hard-coded (in used_files.py) directory name for C/C++ source files. Source files should not be in the project root directory for convenience of filter generation for additional source (headers) directories
  • sysroots - a link to header files directories, available in the target system. The content is generated after the linux kernel is being built. All the applications use header files from the subdirectories of this folder. This link is generated for every project by the bitbake class.
  • .cproject - Eclipse CDT project configuration. Parts of this file are modified by the scripts, such as used_files.py. This file is copied from version-controlled eclipse_project_setup during setup or manually.
  • .gitignore - Git ignore file list
  • LICENSE - project GNU GPLv3 license
  • Makefile - top make file of the project. It is invoked when executing bitbake recipes, it receives variables defined in bitbake recipes/classes
  • .project - Eclipse general project configuration. This file is copied from version-controlled eclipse_project_setup during setup or manually.
  • README.md - README file presented by the Git repository web interface
  • VERSION - project version, used by bitbake build process to determine which dependent recipes have to be re-ran.

Initializing Eclipse Workspace for Existing (Cloned) Projects

After running setup.py for the first time you may create the brand new workspace for Eclipse, that should have all necessary plugins (such as CDT and EGit at least) already installed. Workspace is created with setup_eclipse.py script, list of projects that it sets up is saved in setup_eclipse_paths.xml file. setup_eclipse.py provides usage information when launched without parameters, for normal run it requires full path to Eclipse installation - directory that contains eclipse executable and eclipse.ini configuration. Before running setup_eclipse.py Eclipse should have all the required plugins installed (at least CDT and EGit) using temporary workspace.

./setup_eclipse.py <eclipse_home> <workspace_path>

setup_eclipse.py performs 2 actions:

  • It first batch-imports all the listed in setup_eclipse_paths.xml projects using headless build of the CDT (org.eclipse.cdt.managedbuilder.core.headlessbuild), without actually building and indexing files - indexing should be done manually before using particular project.
  • Next it connects project Git repositories to Eclipse EGit, so the projects are immediately ready for Git operations ('team' operations). project navigator shows repository and branch for each of the projects.

After creating a new workspace with setup_eclipse.py it can be opened with Eclipse, the projects you plan to use have to be indexed (right-click on the project in the Navigator ⇒ Index ⇒ Rebuild.

Additional manual setup for linux-elphel.project

Adding linux/include/generated/autoconf.h entry to linux-elphel project properties

Until we found a way how to set it automatically, the linux/include/generated/autoconf.h file has to be added to the project properties, as shown in the screenshot.

Initializing Eclipse Workspace for Existing (Cloned) Verilog Projects

setup_eclipse.py can also be used to setup a separate workspace for the FPGA projects for the camera:

  • x393 - full camera RTL code and test benches. It has several active branches:
    • master - production camera code
    • dct - development branch for testing DCT-IV/DST-IV and CLT modules for image correction and 3d reconstruction
    • CMV300 - development for the high-speed CMOSIS sensor, will be used for other sensors with compatible interface
  • x393_sata - AHCI/SATA subsystem. The code is included in x393, this repository is for faster troubleshooting and may be used for other applications
  • x359 - FPGA code for 10359 sensor multiplexer

These projects are now opened from the second instance of Eclipse IDE. plugin has to be installed first (imported to the workspace and set up). The Eclipse FPGA workspace is created with the following command issued from the elphel393 project directory:

./setup_eclipse.py <eclipse_home> <workspace_fpga_path> setup_eclipse_fpga_paths.xml 

where eclipse_home is the path to Eclipse installation and workspace_fpga_path is a path to the new workspace (should be different from the workspace_path set earlier. The workspace_fpga_path should also be specified in Run Configuration -> Eclipse application of the "main" Eclipse.

Setting up New Project

When using CDT the CDT Builder is the only builder to support error processing so we use it to launch bitbake compilation recipe for build command. Additional builder 'SCP apps-astreamer to target' is set up to transfer prepared binaries to the target camera. Figure 1a shows project ⇒ properties ⇒ Builders view with CDT Builder moved to the first position, and the SCP tool - to the second (and disabled. When disabled it will not be launched automatically - camera has to be connected for SCP to succeed, and Poky local.conf has to have camera IP address set up for transfers. No other builders are required - they may be disabled and later removed, by deleting corresponding firl from the .externalToolBuilders directory (while Eclipse is closed). Figure 1b. shows SCP tool configuration dialog: Set

  • Name field with SCP <bitbake-target> to target
  • Location with ${workspace_loc:/<project-directory>/scripts/run_bitbake.sh} and
  • Arguments with <bitbake-target> -c target_scp -f

Figure 1c shows 'Build Options" tab. Default settings can be kept.