KDevelop

From ElphelWiki
Revision as of 17:32, 18 November 2008 by Andrey.filippov (talk | contribs)
Jump to: navigation, search

Using KDevelop with Elphel cameras software

It is now possible to use KDevelop (Integrated Development Environment) with Elphel cameras software. KDevelop provides graphical user interface to what was console environment only.

Installing

In order to use this feature you first need to install Elphel software - either the latest release from the Sourceforge (not yet released) or from CVS (i.e. downloading, unzipping and runningelphel353_install_from_cvs.sh).

After the software is installed (it takes some time to run ./install_elphel) you may navigate to the project root directory and run

./prep_kdevelop.php --strict

This script will require several pieces of the software to be installed - the first one is PHP (>=5.0.0) itself (including php5-cli). If PHP is installed in other than

/usr/local/php

directory, you may run the script with the following command:

php prep_kdevelop.php --strict

With the '--strict' option this script will terminate if any of the required programs is missing (and output what exactly is needed to be installed). If all dependencies are satisfied the script will continue and create/modify several files:

  • elphel353.kdevelop - KDevelop project, you may open it with KDevelop application by mouse-clicking this file in the file manager
  • tags - ctags index file, used by KDevelop to locate where the current name is declared or defined
  • ctags_excludes - list of directories (with wildcards) to exclude from ctags indexing (i.e. drivers for other architectures)
  • Doxyfile - Doxygen configuration (including the list of the subdirectories to scan) - used to generate documentation
  • templates - directory for custom file templates (headers for the new files)
  • templates/c - template for the C source files
  • templates/cpp - template for the C++ source files
  • templates/h - template for the C/C++ header files
  • templates/php - template for the PHP files
  • templates/v - template for the Verilog HDL source files
  • templates/tf - template for the Verilog HDL test fixture files
  • templates/ucf - template for the user constraint files (used with Verilog files)
  • ~/.kde/share/config/kdeveloprc - KDevelop configuration file.

Usage

KDevelop itself is documented on the KDE web site so below are only Elphel-specific notes.

Building Firmware

The complete firmware for the camera can be created with Build -> Build Project, it is the same as running

. ./init_env
make

from the project top directory, the difference is that in KDevelop you can click on the error/warning message and jump to the source code.

Building camera applications

If you need to (re)build just a single application in the camera, not the whole image - you may (while the source file is selected in the editor) use Build -> Compile - it is similar to running

make install

in the directory of the source file. After successful completion of this command you may ftp (or scp) the produced binary to the camera file system.

Creating Project Documentation

KDevelop allows to document project with the integrated Doxygen. Currently prep_kdevelop.php creates Doxyfile that lists all the files created or modified for Elphel project (as listed in the src.list, you may customize it by editing Doxyfile.

Build -> Build API Documentation in KDevelop runs Doxygen and creates project Documentation. Tools -> Preview Doxygen Output generates documentation for the currently selected file.

Among several documentation formats generated by Doxygen there is the HTML one

Using Ctags

Ctags indexes names in the source file tree and KDevelop uses this index to find definitions/declarations from the source code editor (appears in the context menu for the selected name). Ctags program is ran by the prep_kdevelop.php, you may also recreate the index from KDevelop by selecting Ctags tab in the bottom and pressing Regenerate button.

prep_kdevelop.php also creates ctags_excludes (in the project top directory) with a wildcard list of directories excluded from indexing - i.e. some names appear in the files for each architecture - that makes it difficult to find the relevant one (in arch/cris). You may additionally limit (or expand) the scanned tree by modifying ctags_excludes file.

Note: there is a known but unresolved issue - on some installations Ctags works with Verilog (as it is supposed to), on others - Ctags items do not appear in context menu for names in Verilog files.

Project Files

Maybe there is a simpler way to include files into the "project" in KDevelop, but so far I could figure out the only one - create dummy Makefile.am files in the directories of these files and on the all higher level directories up to the project top one, and these files are created by prep_kdevelop.php. You may tweak those files - they all have the line:

#Dummy Makefile.am for Elphel camera KDevelop project

as the first line. Including files in the project allows to Hide Non Project Files in File Tree panel, it also shows syntax errors in them (unfortunately there are many false positives -- KDevelop seems to treat C files as C++ - or I'm missing something). In project files it is also possible to see (and jump to) TODO and FIXME notes (seem to work with C/C++ only so far).

HDL Projects Simulation (Icarus Verilog & GTKWave)

  • Go to http://jeremya.com/src/VDT.php to download a verilog project template.
  • Create a new verilog project, add source files.
  • Modify <project_path>/sim/Makefile. Example makefile,
TARGET1 = x359_tf
TARGET2 = glbl

XILINX_LIB= "../../unisims" 

VERILOG_SOURCES = ../hdl/x359.tf \
../hdl/x359.v \
../hdl/i2csbr.v \
../hdl/ddr.v \
../hdl/clkios353.v \
../hdl/sdram_phase.v \
../hdl/ioports353.v \
../hdl/mcontr359.v \
../hdl/descrproc353.v \
../hdl/sdseq353.v \
../hdl/macros353.v \
../hdl/dwt_1d.v \
../hdl/sensor12bits.v \
../hdl/glbl.v 

SIMFILE = x359.vvp
VCDFILE = ${TARGET1}.lxt 

WAVERC = gtkwaverc
WAVECFG = tb.sav

ICARUS = iverilog
IFLAGS = -v -Dlegacy_model

VVP = vvp
VFLAGS = -v
VFLAGSEXTRA = -lxt2

GTKWAVE = gtkwave 
GFLAGS = --save=${WAVECFG} --rcfile=${WAVERC}

all: compile simulate gtkwave

compile : ${VERILOG_SOURCES}
	@ echo Compiling verilog files...
	@ ${ICARUS} ${IFLAGS} -s ${TARGET1} -s ${TARGET2} -o ${SIMFILE} -y ${XILINX_LIB} ${VERILOG_SOURCES}

simulate : compile
	@ echo Simulating design...
	@ ${VVP} ${VFLAGS} ${SIMFILE} ${VFLAGSEXTRA}

gtkwave : compile simulate
	@ echo Viewing waveforms in gtkwave...
	@ ${GTKWAVE} ${GFLAGS} ${VCDFILE}

clean: 
	@ echo Cleaning up...
	@rm -f ${SIMFILE} ${VCDFILE} *~
	
view :
	@ echo Viewing waveforms...
	@ ${GTKWAVE} ${GFLAGS} ${VCDFILE}
  • Copy files with parameters to <project_path>/sim/
Building poject will tell what files are missing. For x359 it's just ddr_parameters.v
  • Build Project (F8)

Known Issues

When first opening new elphel353.kdevelop project it usually crashes in the very end of opening (when the progress bar in the bottom goes up for the second time). Unfortunately I do not know what it is, my guess is that we are abusing KDevelop by opening too large project that includes not just our source tree but all the patched files used in the camera. There also fake Makefile.am files generated by prepkdevelop.php script that are needed to tell KDevelop which files belong to the project.

Good news are - keep trying to open elphel353.kdevelop again and again - the progress bar usually goes more each time (but has some setbacks) - eventually it will open. Next time it will do it from the first try.