KDevelop

From ElphelWiki
Jump to: navigation, search
Camvc mplayer kdevelop 80.jpeg

Using KDevelop with Elphel cameras software

Update: Installing KDevelop3 on (K)Ubuntu 9.10 (from Ubuntu Forums):

Installation of KDevelop 3.5 on older (pre-9.10) (K)Ubuntu

sudo apt-get install kdevelop

Installation of KDevelop 3.5 on (K)Ubuntu 11.04

same as Installation of KDevelop 3.5 on (K)Ubuntu 9.10

Installation of KDevelop 3.5 on (K)Ubuntu 10.10

same as below

BUT if you get an error like this:

Unpacking libcvsservice0-kde3 (from .../libcvsservice0-kde3_4%3a3.5.12-0ubuntu6+r1075407+rebuild2_amd64.deb) ...
dpkg: error processing /var/cache/apt/archives/libcvsservice0-kde3_4%3a3.5.12-0ubuntu6+r1075407+rebuild2_amd64.deb (--unpack):
 trying to overwrite '/usr/share/man/man1/cvsservice.1.gz', which is also in package cvsservice 4:4.5.95-0ubuntu2~maverick1~ppa1
dpkg-deb: subprocess paste killed by signal (Broken pipe)
Processing triggers for man-db ...
Errors were encountered while processing:
 /var/cache/apt/archives/libcvsservice0-kde3_4%3a3.5.12-0ubuntu6+r1075407+rebuild2_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

The solution is here:

dpkg: error processing /var/cache/apt/archives/AAA (--unpack):
trying to overwrite `/usr/lib/BBB', which is also in package CCC
dpkg-deb: subprocess paste killed by signal (Broken pipe)
Errors were encountered while processing:
AAA
E: Sub-process /usr/bin/dpkg returned an error code (1)

(where AAA,BBB,CCC are placeholder names, in case it wasn’t clear)
do 

sudo dpkg -i --force-overwrite AAA 

(give full path of AAA), and then run

sudo apt-get -f install

Installation of KDevelop 3.5 on (K)Ubuntu 10.04

same as below

Installation of KDevelop 3.5 on (K)Ubuntu 9.10

1. Add these lines to your /etc/apt/sources.list file (i.e. with "kdesudo kate /etc/apt/sources.list"):

deb http://ppa.launchpad.net/kde3-maintainers/ppa/ubuntu karmic main
deb-src http://ppa.launchpad.net/kde3-maintainers/ppa/ubuntu karmic main

2. Add the GPG signing key:

wget http://apt.pearsoncomputing.net/public.gpg
sudo apt-key add public.gpg 

3 Refresh the package list

sudo apt-get update

4. Remove kdev 4

sudo apt-get purge kdevelop

5. Install kdev 3

sudo apt-get install kdevelop-kde3 kdevelop-kde3-doc

6. Launch

/opt/kde3/bin/kdevelop &

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.

Creating Elphel project for KDevelop

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 running elphel353_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

If you installed kdevelop-kde3 as described above you need to replace line 88 of prep_kdevelop.php with:

$all_installed &= test_kdevelop_depend('/opt/kde3/bin/kdevelop','kdevelop-kde3');

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.