User:Pau pajuelo

From IGEP - ISEE Wiki

Revision as of 12:39, 6 August 2012 by Pau (talk | contribs) (How Works)

Jump to: navigation, search

Contents

How to develop with Qt under IGEP

Overview

This guide can be helpful to learnt to develop Qt applications under IGEP Boards. Qt is a cross-platform application framework that is widely used for developing application software with a graphical user interface, and also used for developing non-GUI programs such as command-line tools and consoles for servers. You can get more information here.

Requirements

There are some requisites to follow this guide:

  • IGEP SDK VM: follow the IGEP SDK SOFTWARE USER MANUAL (chapter 2.3 "Setting up and running the VM")
  • IGEP Qt Demo: follow the IGEP SDK SOFTWARE USER MANUAL (chapter 6.1 "Create IGEP firmware bootable micro-sd card") and install qt4e-demo-image-igep00x0.tar.bz2 instead IGEP firmware.
  • IGEPv2, IGEP BERLIN or IGEP PARIS
  • MicroSD Card (at least 2Gbytes)

Download and install Qt demo image to a SD

Once you have open IGEP SDK VM, launch a terminal and type:

cd Desktop/
wget http://downloads.isee.biz/denzil/binary/qt4e-demo-image-igep00x0.tar.bz2 
git clone git://git.isee.biz/pub/scm/igep-tools.git
cd igep-tools/scripts

Insert a SD-Card media and use the igep-media-create script to copy the firmware to SD-Card media, required options are:

  • --mmc </dev/sdX>

       unformated MMC Card

  • --image <filename>

       specify file used to create the bootable SD card.

  • --machine <machine>

       specify the machine. Options are igep0020, igep0030 or igep0032

For example, assuming the SD card device takes "/dev/sdf" and you have and IGEPv2 board (igep0020), type:

./igep-media-create --mmc /dev/sdf --machine igep0020 --image /home/jdoe/Desktop/qt4e-demo-image-igep00x0.tar.bz2

This should give you a bootable SD-card

Prepare Qt demo image

Qt demo image is a root filesystem build by Yocto that contains Qt embedded libraries, also this image has some Qt examples for testing purposes.

This image doesn't have openssh and gdbserver, so we should install these packages to develop Qt applications. Open a shell prompt using serial communication (IGEP SDK SOFTWARE MANUAL chapter 3.1 "Using serial mode") and type the following commands:

zypper ref
zypper in openssh
zypper in gdbserver

Now you can connect between IGEP and VM using SSH protocol:

ssh root@"IGEP IP for example: 192.168.5.1"

Using Qt Creator

First Steeps

Open Program:

Go to Applications -> IGEP development -> Qt Creator

Openqtv2.png
Qtopenedv2.png

Click to enlarge image

Open an example:

Copy your desired example from: /opt/QtSDK/Examples/4.7 to your desktop.

Qtcopyanexamplev2.png

Click to enlarge image

NOTE: some examples (like hellogl) cannot be compiled to ARM, for this How-to is used calculator example.

Open this example with Qt Creator, set Desktop target and use for each Qt Version one debug and one release

Qtopenanexamplev2.png Qtopenanexample2v2.png Qtopenanexample3v2.png

Click to enlarge image

ARM Platform

Build Programs

To compile to ARM for IGEP go to Project use the following configuration at Projects field -> Build:

Qtarmconfigv2.png

Click to enlarge image

NOTE: Use Debug build if you want to debug later

Compile with: Build->Clean All and Build->Build All (Ctrl+Shift+B).

Run Programs

Once you compiled the program pass it from VM to IGEP via SSH, launch a terminal and type:

scp "pathtobinary" root@"IGEP IP for example: 192.168.5.1":/home/root

Get a remote shell prompt and run your program:

ssh root@"IGEP IP for example: 192.168.5.1"
./"binary"  "optional:arguments"
Qtrunarmv2.jpg

Click to enlarge image

NOTE: You cannot use igep-remote-x program because Qt-demo image doesn't have X installed.

Debug Programs

NOTE: When you debug programs using Qt Creator "Step in" and "Step Out" are not supported, because dinamic libraries symbols are not loaded by gdb.

Once you compiled the program pass it from VM to IGEP via SSH, launch a terminal and type:

scp "pathtobinary" root@"IGEP IP for example: 192.168.5.1":/home/root

Get a remote shell prompt and run gdbserver:

ssh root@"IGEP IP for example: 192.168.5.1"
gdbserver "VM IP for example: 192.168.5.10":1000 "pathtobinary" "optional:armguments"

Now use the followings steps to debug program:

Qtdebugx861v2.png Qtarmdebug1v2.png
Qtarmdebug2v2.png Qtarmdebug3v2.png

Click to enlarge image

Image 1: set breakpoints in your source code

Image 3: use the following configuration:

  • Debugger: /opt/poky/1.2/sysroots/i686-pokysdk-linux/usr/bin/armv7a-vfp-neon-poky-linux-gnueabi/arm-poky-linux-gnueabi-gdb
  • Local executable: "pathtohostbinary"
  • Host and port: "IGEP IP for example: 192.168.5.1":1000
  • Architecture: arm
  • GNU target: arm-none-linux-gnueabi
  • Sysroot: (empty)
  • Location of debugging information: (empty)
  • Override host GDB start script: download gdbinit file, uncompress to home folder and select it (/home/jdoe/gdbinit)

NOTE: You cannot use igep-remote-x program because Qt-demo image doesn't have X installed.

x86 Platform

Build Programs

To compile to x86 go to Project use the following configuration at Projects field -> Build:

Qtx86configv2.png

Click to enlarge image

NOTE: Use Debug build if you want to debug later


Compile with: Build->Clean All and Build->Build All (Ctrl+Shift+B).

Run Programs

Use run button (Ctrl+R).

Qtrunx86v2.png

Click to enlarge image

Debug Programs

Set breakpoints in your source code and press debug button (F5)

Qtdebugx861v2.png Qtdebugx862v2.png

Click to enlarge image

Set up a NFS between IGEP Board and IGEP VM

Overview

Network File System (NFS) is a Distributed file system protocol originally developed by Sun Microsystems in 1984, allowing a user on a client Computer to access files over a network in a manner similar to how local storage is accessed. NFS, like many other protocols, builds on the Open Network Computing Remote Procedure Call (ONC RPC) system. The Network File System is an open standard defined in RFCs, allowing anyone to implement the protocol. More information here.

In IGEP Boards, NFS protocol can be used to mount a whole rootfs partition located in a remote disk like Virtual Machine, this method can be useful for:

  • Your remote rootfs will not be limited by flash or MicroSD storage.
  • You can transfer binaries without using remote connections.
  • You can test other rootfs only editing igep.ini configuration file.
Nfs1 filesystem.png Nfs2 filesystem.png

Click to enlarge image

Requirements

There are some requisites to follow this guide:

  • IGEP SDK VM: follow the IGEP SDK SOFTWARE USER MANUAL (chapter 2.3 "Setting up and running the VM")
  • IGEP Qt Demo or IGEP Firmware: follow the IGEP SDK SOFTWARE USER MANUAL (chapter 6.1 "Create IGEP firmware bootable micro-sd card")
  • IGEP Board with Ethernet or Wifi connection
  • MicroSD Card (at least 2Gbytes)

Set up NFS at VM

Download and extract IGEP root filesystem

ISEE mantains two rootfs builded with Yocto tools:

  • IGEP firmware: default software shipped in all IGEP Boards. It comes with some documentation and tools, so you need to uncompress again to extract rootfs
wget http://downloads.isee.biz/denzil/binary/igep_firmware-yocto-1.2.1-1.tar.bz2 
tar jxf igep_firmware-yocto-*.tar.bz2
cd igep_firmware-yocto-*
sudo mkdir /srv/{your_rootfs_dir}
sudo tar jxf demo-image-sato-igep00x0.tar.bz2 -C /srv/{your_rootfs_dir} 
  • Qt demo: demo filesystem with Qt libraries and examples
wget http://downloads.isee.biz/denzil/binary/qt4e-demo-image-igep00x0.tar.bz2 
sudo mkdir /srv/{your_rootfs_dir}
sudo tar jxf qt4e-demo-image-igep00x0.tar.bz2 -C /srv/{your_rootfs_dir}

Configure NFS Server

  • Install nfs-kernel-server:
sudo apt-get install nfs-kernel-server 
  • Make directory exports.d:
sudo mkdir /etc/exports.d 

Edit /etc/exports file, add the following line and save the changes:

/srv/{your_rootfs_dir} *(rw,sync,no_subtree_check,no_root_squash)

Export NFS file system:

sudo exportfs -a

NOTE: You can have as many rootfs as you want

Set up NFS at IGEP Board

MicroSD boot

Configure igep.ini file located at boot partition:

  • Comment MMC boot:
;  --- Configure MMC boot ---
;root=/dev/mmcblk0p2 rw rootwait
  • Add NFS configuration:
;  --- Configure NFS boot ---
ip=192.168.5.1:192.168.5.10::255.255.255.0::eth0
root=/dev/nfs
nfsroot=192.168.5.10:/srv/{your_rootfs_dir}

Save changes, plug MicroSD card and power up your IGEP.

Flash boot

Boot IGEP with a MicroSD card without NFS support.

mkdir /tmp/temp
mount -t jffs2 /dev/mtdblock1 /tmp/temp 

Now, mtdblock1 partition is mounted at /tmp/temp directory. Modify igep.ini located in: /tmp/temp/igep.ini

  • Comment JFFS2 FS boot:
;  --- Configure JFFS2 FS boot ---
;root=/dev/mtdblock2
;rootfstype=jffs2
  • Add NFS configuration:
;  --- Configure NFS boot ---
ip=192.168.5.1:192.168.5.10::255.255.255.0::eth0
root=/dev/nfs
nfsroot=192.168.5.10:/srv/{your_rootfs_dir}

Save changes, power down IGEP, unplug MicroSD card and power up your board.

Install and configure Codeblocks for IGEP devices

Overview

Codeblocks is a free and open source, cross-platform IDE which supports multiple compilers including GCC and MSVC. It is developed in C++ using wxWidgets as the GUI toolkit. Using a plugin architecture, its capabilities and features are defined by the provided plugins. Currently, Codeblocks is oriented towards C and C++. It can also be used for creating ARM, AVR, D, DirectX, FLTK, Fortran, GLFW, GLUT, GTK+, Irrlicht, Lightfeather, MATLAB, OGRE, OpenGL, Qt, SDL, SFML, STL, SmartWin and wx programs and applications, although in some cases installing third-party SDKs or frameworks is necessary. More information here.

Codeblocks is not installed by default in IGEP SDK VM, because Eclipse IDE is full integrated with IGEP Firmware. If you don't like Eclipse IDE or you want to use Codeblocks anyway this How-to can be helpful to install, set up and use it.

Requirements

There are some requisites to follow this guide:

  • IGEP SDK VM: follow the IGEP SDK SOFTWARE USER MANUAL (chapter 2.3 "Setting up and running the VM")
  • IGEP Firmware: follow the IGEP SDK SOFTWARE USER MANUAL (chapter 6.1 "Create IGEP firmware bootable micro-sd card")
  • IGEP Board
  • Codeblocks examples
  • MicroSD Card (optional)

Install Codeblocks in VM

sudo apt-get install codeblocks codeblocks-contrib 

Configure Codeblocks

Startup script

Codeblocks startup script (Codeblocks.sh) will let you to load IGEP SDK YOCTO environtment variables to IDE. Don't execute this script if you want to compile with other environtment like x86.

cd Desktop/IGEP\ development/
gedit Codeblocks.sh

Copy this code to Codeblocks.sh

#! /bin/bash
source /opt/poky/1.2/environment-setup-armv7a-vfp-neon-poky-linux-gnueabi 
exec codeblocks 

Give execute privileges to script:

chmod a+x ~/Desktop/IGEP\ development/Codeblocks.sh
Opencodeblocks1.png
Opencodeblocks2.png


Add IGEP SDK Compiler and Debugger

Follow the next instructions to add IGEP SDK Yocto support:

Addsdkcodeblocks1.png Addsdkcodeblocks2.png Addsdkcodeblocks3.png
Addsdkcodeblocks4.png Addsdkcodeblocks5.png Addsdkcodeblocks6.png

Click to enlarge image

Save all changes

Using Codeblocks

You can create two types of projects on Codeblocks: custom Makefile or managed by Codeblocks. These examples can be used as a template for your project. The examples are:

  • C_example, Codeblocks-based “Hello World” program written in C.
  • Cairo_example, generates a png file named hello.png.
  • Cpp_example, Codeblocks-based “Hello World” program written in C++
  • Dbus_example, sends "Hello Wolrd!" using D-Bus message system.
  • Glib_example, simple “Hello World" written using Glib library.
  • Gstreamer_example, ogg audio player using Gstreamer.
  • Gtk_example, Hello World in GTK.
  • C_example_without_autotools, custom Makefile “Hello World” program written in C.

Build programs

NOTE: Use Debug build if you want to debug later

Compile with: Build->Rebuild (Ctrl+F11).

Run programs

Once you compiled the program pass it from VM to IGEP via SSH, launch a terminal and type:

scp "pathtobinary" root@"IGEP IP for example: 192.168.5.1":/home/root

Get a remote shell prompt and run your program:

ssh root@"IGEP IP for example: 192.168.5.1"
./"binary"  "optional:arguments"

Debug programs

NOTE: When you debug programs using CodeBlocks "Step into" and "Step out" are not supported, because dinamic libraries symbols are not loaded by gdb.

Once you compiled the program pass it from VM to IGEP via SSH, launch a terminal and type:

scp "pathtobinary" root@"IGEP IP for example: 192.168.5.1":/home/root

Get a remote shell prompt and run gdbserver:

ssh root@"IGEP IP for example: 192.168.5.1"
gdbserver "VM IP for example: 192.168.5.10":1000 "pathtobinary" "optional:armguments"

Now use the followings steps to debug program:

Debugcodeblocks1.png Debugcodeblocks2.png
Debugcodeblocks3.png Debugcodeblocks4.png

Image 1: set breakpoints in your source code

NOTE: You cant use igep-remote-x program with IGEP firmware (chapter 3.3 "Remote X")

How to use SPI (prove with new firmware, under construction)

Overview

This How-To is meant to be a starting point for people to learn use SPI for IGEP devices as quickly and easily as possible. In this how-to, we run an example program that reads and writes registers from 3-axis accelerometer (LIS3DH) included on the board IGEP New York. This program was tested in Poky firmware with Kernel 2.6.37.y.

Feedback and Contributing

At any point, if you see a mistake you can contribute to this How-To.

Requirements

There are a few requisites to follow this tutorial:

How Works

'LIS3DH accelerometer': It is the accelerometer mounted in IGEP New York.

Omap3 SPI Peripheral: It is the hardware used to communicated with accelerometer and other SPI devices.

Omap2_mcspi: It is a bus driver than controls Omap3 SPI Peripheral.

Spi: It is a protocol driver that defines functions and strucs used in SPI bus.

Spidev: It is a device driver that export spi driver functionalities to userspace.

Lis3lv02d_spi: SPI glue layer for lis3lv02d

Lis31v02d: Device driver for LIS3DH accelerometer.

Exp_ilms0015: It is a startup program for IGEP New York. It attach lis31v02d with Spi driver.

Spi linux schematic.png


More information about Linux Kernel SPI at:

Attach Spidev to SPI driver

Modify Linux Kernel Sources

Enable ilms0015 support

Test changes

SPI Test program

Overview

Compile program

Test program

Read WHO_AM_I register(0Fh)

Read and Write CTRL_REG1 (20h)

Read accelerometer axes

How to install IGEP SDK Virtual machine (under construction)

How to install Qt Creator (under construction)

How to install Eclipse (under construction)