Qt* phone edition - Application development assistance

21
Oct 2010

Qt*/X11(x86), Qt*/qvfb, Qt*/neo(arm)
directory  structure followed are suited for my purpose it's your prerogative to define one of your own
By Qt* the reference is towards Qtmoko/Qtopia/Qt-Extended.
The first two(mentioned below) are for development machine/host machine, while the later is for building Qt applications for target platform.

Running Qt*

Qtmoko running on desktop with Qt virtual framebuffer(QVFb) helps in (developers to test the app on the desktop instead of copying it to the target device) developing code, debugging and demonstrating a product. This is not a substitute for running qtmoko on emdedded device as its not a clear indication of performance.

Qtmoko on desktop mach

runqtopia script launches QVFb and ensures that Qtmoko can talk to it by setting QWS_DISPLAY. QVFb is run using a skin to make it feel more like a real device. A skin is simply a set of XML files that defines the look and feel of QVFb.

refer Compiling Binary SDK - native/device (mentioned below)

Qtmoko on GTA02 device

Qtmoko can be made available into the device in the following ways:
• using an NFS mount partition
• using a binary flashed onto the device
 

using an NFS mount partition

This section describes how to run qtmoko on a device using an NFS mount partition

To use an NFS mount partition your device requires a network connection with the desktop machine and accesses qtmoko binaries on the desktop machine. The binaries must be cross-compiled for the device-type(eg- arm) and you control the start/stop of qtmoko through a terminal connection to the device.

This approach is ideal for some debugging and testing on a real device. The binaries can be quickly modified and rebuilt and the application under test can be restarted almost instantly. It provides an efficient work process when compared with the delays introduced by building packages and the usually very slow upload and flash process required to run qtmoko from a standalone device. Performance debugging should not be made using this technique, as the lag in network operations will hinder performance.

step 1: setting up the device

To setup the device, use command line tools (or whatever is available on the device) to setup the network configuration and use ifconfig to determine the ip address. Note: Network settings in Qtmoko can be used, however, you would need to exit that Qtmoko in order to run over the network.

step 2: exporting the Qtmoko image directory to the device

To export the Qtmoko image directory to the device, execute the following commands on the desktop machines:
1. first verify that NFS is running:
    ps aux | grep nfs
    
    output will be something like this
    ranjit@ranjit-laptop:~$ps aux|grep nfs
    
    root 10889 0.0 0.0        0        0?        sw 16:20 0:00 [nfsd]
    root 10889 0.0 0.0        0        0?        sw 16:20 0:00 [nfsd]
    ranjit    2124  0.0  0.0   3320   788 pts/1    S+   19:52   0:00 grep --color=auto nfs

    if you only get the bottom line, then NFS is not running and needs to be started.
    to start NFS use /etc/init.d/nfsserver start as root

2. Indicate to NFS, to export a directory by editing the /etc/exports file (as root) and adding the following line:

    /path/to/image/ *(ro)
    This exports the /path/to/image directory (and all subdirectories), and gives read-only access from any computers. In this procedure it is assumed        this is the directory you want to export.

3. indicate to NFS (again as root) that the configuration has changed using
    exportfs -a
    The Qtmoko binaries in /path/to/image/Qtopia/bin are now accessible from the network
 

step 3: connecting to the device

1. login to the connected device via telnet or ssh
2. enter your password as root and create the directory on the device that links to the desktop file system using the following command:
    mkdir -p /opt/Qtopia

3. mount / assign the file system to the device by mounting the created folder using the following command:
    mount hostip:<path to Qtmoko image> -orsize=8192, wsize=8192, ro, nolock, tcp /opt/Qtopia

4. you should now be able to fill /opt/Qtopia dir on device with <path to Qtmoko image> on your desktop machine(named hostip).

Using a binary flashed onto the device
This is the ultimate goal.
As a general rule Qtmoko(or any other application) can be flashed onto a device using a CF or SD card or can be uploaded onto the device using a serial connection. usually this means the image (for eg. <pathe to qtmoko image>) must first be packed into a special file such as initrd.bin. This file is uploaded and flashed into the device flash memory. The correct procedure is entirely dependent on the device used and cannot be described here.

refer device SDK and to compile the application section

Binary SDK - native/device
Without doubt it is necessary to have sdk for both x86(native) and device(cross-compiled) when building apps. The native build allows running on a fast, desktop system under QVFb and the device SDK allows creation of apps for the actual device.

mkdir build_native
mkdir build_device


native SDK

The native SDK includes an image so that the apps can be run under QVFb

cd  build_native
../qtmoko/configure -device neo -qvfb -sdk /opt/Qtopia/SDK/4.4.3/x86 -image /opt/Qtopia/SDK/4.4.3/x86/image
bin/qbuild
bin/qbuild image
bin/qbuild sdk

At the compile time the following error due to absence of XTest was encountered

/home/ranjit/QtMoko/qpe/qtmoko/qtopiacore/qt/tools/qvfb/x11keyfaker.cpp:48:34: warning: X11/extensions/XTest.h: No such file or directory
/home/ranjit/QtMoko/qpe/qtmoko/qtopiacore/qt/tools/qvfb/x11keyfaker.cpp: In member function ‘void X11KeyFaker::sendKeyEvent(int, bool)’:
/home/ranjit/QtMoko/qpe/qtmoko/qtopiacore/qt/tools/qvfb/x11keyfaker.cpp:449: error: ‘XTestFakeKeyEvent’ was not declared in this scope
/home/ranjit/QtMoko/qpe/qtmoko/qtopiacore/qt/tools/qvfb/x11keyfaker.cpp:452: error: ‘XTestFakeKeyEvent’ was not declared in this scope
/home/ranjit/QtMoko/qpe/qtmoko/qtopiacore/qt/tools/qvfb/x11keyfaker.cpp:456: error: ‘XTestFakeKeyEvent’ was not declared in this scope
/home/ranjit/QtMoko/qpe/qtmoko/qtopiacore/qt/tools/qvfb/x11keyfaker.cpp:459: error: ‘XTestFakeKeyEvent’ was not declared in this scope
/home/ranjit/QtMoko/qpe/qtmoko/qtopiacore/qt/tools/qvfb/x11keyfaker.cpp:464: error: ‘XTestFakeKeyEvent’ was not declared in this scope
/home/ranjit/QtMoko/qpe/qtmoko/qtopiacore/qt/tools/qvfb/x11keyfaker.cpp: In member function ‘void X11KeyFaker::connect()’:
/home/ranjit/QtMoko/qpe/qtmoko/qtopiacore/qt/tools/qvfb/x11keyfaker.cpp:550: error: ‘XTestQueryExtension’ was not declared in this scope

debian system allows to find the package to which a file belongs(XTest.h)

1. dpkg -S <filename>  this works only if the pkg is installed
2. apt-file search <filename> this works for both uninstalled as well as installed pkgs
So libxtst-dev resolved the err

To run the qtmoko on QVFb

./bin/runqtopia

To compile the application natively
use the ./bin/qbuild in the build_native dir
simply copy the binary created and run the runqtopia which is a perl script file inside the terminal run the application as we do in the device.

This will run the qtmoko image compiled for x86 in the QVFb with ficgta01.skin(Qtopia/SDK/4.4.3/x86/src/tools/qt/qvfb) but the fonts are not shown so

cp ~/QtMoko/qpe/qtmoko/qtopiacore/qt/lib/fonts/* /opt/Qtopia/SDK/4.4.3/x86/image/lib/fonts
(or)
cd /opt/Qtopia/SDK/4.4.3/x86/image/lib/
rm -rf fonts
ln -s /usr/share/fonts/truetype/ttf-dejavu/ fonts
rm /tmp/qtembedded-0/fonts/fontdb

Test the application on host(x86)

/opt/Qtopia/SDK/4.4.3/x86/qtopiacore/host/bin/qvfb -depth 44 -skin ./ficgta01.skin/ -zoom 0.40 &
./qmplayer -qws

 
drawback:- here the fonts are too small
 

Device SDK
The SDK does not include an image since the apps are run on the device (but can specify the image in case one wants to create a .jffs/gz image for NAND or micro SD card - system integration ;-))

cd build_device
../qtmoko/configure -device neo -sdk /opt/Qtopia/SDK/4.4.3/ARM -image /opt/Qtopia/SDK/4.4.3/ARM/image
bin/qbuild
bin/qbuild sdk

The ARM in the -sdk path holds the binaries for GTA02
To compile the application

../../QtMoko/qpe/build_native/bin/qtopiamake
make

[update:18/3/2011]Video of how qt phone edition feels like. The current version of qtmoko is v33 but video makes use of v24


Unsuccesful stinct with QEmu
The image of qtmoko-gta01 is used with qemu based device emulator but it gets stuck at the point of touchscreen caliberation - hopefully it can be get over with ... need to work on that .

This is a compilation of various dispersed material found in the world wide web for quick reference

reference

http://wiki.openmoko.org/wiki/USB_Networking

 

http://doc.qt.nokia.com/qtextended4.4/

http://qtmoko.org

http://www.cyberciti.biz/faq/how-to-ubuntu-nfs-server-configuration-howto/

http://www.ubuntugeek.com/nfs-server-and-client-configuration-in-ubuntu.html

Some how related stuff:-

http://gnumen.org/blog/dev/28/06/2010/application-development-limo-device-gta02

http://gnumen.org/blog/admin/24/06/2010/cross-compiling-qte

Quick peek

  • connecting gta02 to usb with internet

ip link show

ranjit@ranjit-laptop:~$ ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 00:24:54:ba:c7:01 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether e8:39:df:6a:42:c8 brd ff:ff:ff:ff:ff:ff
4: pan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN
    link/ether 02:69:d8:0b:ef:6c brd ff:ff:ff:ff:ff:ff
5: usb0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 3e:83:0b:11:17:fa brd ff:ff:ff:ff:ff:ff


sudo ip addr add 192.168.0.200/24 dev usb0
sudo ip link set dev usb0 up
ssh root@192.168.0.202

For accessing internet(on the host side, NOT ON THE TARGET DEVICE)
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24
sysctl -w net.ipv4.ip_forward=1

 

  • NFS installation and configuration

nfs server - host machine

install the following packages
nfs-kernel-server - linux NFS server
nfs-common - nfs common programs
portmap - the RPC portmapper

sharing directory with /etc/exports

sudo vi /etc/exports
/opt/image 192.168.0.202/24(rw)   #192.168.0.202 is the ip address of the target device

restart nfs-server
sudo /etc/init.d/nfs-kernel-server restart

Now your nfs server is sharing /opt/image dir


accessing shared directories from linux client computer

sudo apt-get install portmap nfs-common

this will install all the required packages for nfs client

mounting manually
mkdir -p /opt/qtmoko
sudo mount 192.168.1.10:/opt/image /opt/qtmoko  #192.168.1.10 is the IP address of the host machine

now you may need to restart services using the following command
sudo /etc/init.d/portmap restart
sudo /etc/init.d/nfs-common restart

if you want to mount using fstab file
sudo vi /etc/fstab

192.168.1.10:/opt/image /opt/qtmoko nfs auto    0    0

to see all shared dir from client computer

showmount -a 192.168.1.10

To start and stop qtmoko on device

source /opt/qtmoko/qpe.env

/etc/init.d/qpe.sh stop/start

again the font was missing from the image(on host machine) so had to follow one of the step mentioned above to get the image running properly from the host machine on the device(GTA02).