Click here to learn
about this Sponsor:
Home  |  News  |  Articles  |  Polls  |  Forum

Keywords: Match:
Developing Linux apps for the Trolltech Greenphone
by John Lombardo (Dec. 5, 2006)

Foreword: Trolltech's Linux/Qtopia-powered Greenphone aims to provide a real (rather than emulated) hardware platform for mobile phone application developers to test their applications on. This hands-on review takes an in-depth look at the phone's software environment, and at the development tools supplied with the phone. Enjoy . . . !



Developing Linux apps for the Trolltech Greenphone

by John Lombardo


Introduction


Lombardo's greenphone application development setup
(Click to enlarge)
I shuddered with anticipation as I opened the Fedex package. Ah, there it was -- a little cellphone box like so many I've opened before. Only this one was lime green and white. Inside, instead of some chrome and gray phone of yesteryear where DIY means you get to pick your own ringtone, I found a little bundle of metallic-green coolness. The Trolltech greenphone.

The directions admonished me to let it charge for 24 hours before I turned it on, so, like everyone else on the planet, I pressed the power button right away to see it do its Linux-phone thing and... nothing. A little worried, I plugged it in and pressed the power button again and was greeted with the nice QT logo. Phew. Next was a screen with the (relatively) big title of "WARNING" followed by text that Tinker-Bell would have to squint to see.

This warning is first thing that anyone will see when using this phone. It basically says that the little Linux computer you hold in your hand is not intended to be your primary cellphone, but instead is intended to be a development platform.

I read in the forums somewhere that you can disable the warning, but I would advise against it. Leave it on so that every time you start to compare the greenphone with your Treo or Nokia or Whatever, you'll remember that it's not a fair comparison because the greenphone is for the development of cool tools that you can test out in a phone-like environment -- not for using as your primary cellphone.

Don't get me wrong, it does work as a cellphone -- it's just not a very good one. So if you forget that this is a development environment, you'll be disappointed. However, if you remember that it's a development environment, you'll be pleased.

The Phone

A detailed description of the greenphone is available in this LinuxDevices.com article, but here are the essentials:
  • XScale processor, clocked at 312MHz
  • 64MB RAM
  • 128MB flash
  • Mini-SD card slot
  • USB/Bluetooth/Camera/Touchscreen/Keypad
  • QVGA (quarter VGA) 320x240
The SDK

Trolltech delivers the greenphone SDK (software development kit) as a VMWare virtual machine. This is nice for several reasons:
  • You don't have to have a specific version of Linux.
  • Everyone has the same development environment.
  • You can host the environment both on Linux and Windows.
I won't say much about the installation process, except that you can use Trolltech's installation scripts on Windows without modification, via Cygwin.

Once installed, you fire up the development environment by starting the VMWare virtual machine.


Greenphone development environment
(Click to enlarge)

Once started, your desktop has nine icons to start different phases of the development process:
  • Assistant and Developer Guide -- the Assistant brings you to the QT developer's bookshelf; the Developer's guide is the on-line version of the 10 page Greenphone Developer Quickstart Guide

  • Debugger and ARM-Linux debugger -- The debugger executables for both the emulated greenphone and the real greenphone

  • Designer -- The GUI tool for designing QT forms.

  • Konsole -- Starts up a Linux console

  • Linguist -- Automates the process of creating multiple language versions of your software

  • runqpe / runqvfb -- Runs the emulated greenphone

Commandline on your phone

You know you've always wanted the commandline on your cellphone. Well, now you have it! Once you have set up network access between your greenphone and the Developer SDK as described in the Developer Quickstart Guide, you can get shell access to the phone with the "gph -console" command.

First, on the Developer SDK desktop, click the Konsole icon, to open up a terminal window:


Then, type:
    ifconfig eth1 2>/dev/null| sed -n 's/.*inet addr:\([0-9.]*\).*/\1/p'
    10.10.10.21

If this returned nothing, you do not have connectivity to the greenphone. If you do, it should return the IP address of your side of the connection to the greenphone: 10.10.10.21.

Next, type the following command to connects to the greenphone using telnet over the USB cable:
    gph -console
    Success! Greenphone address is 10.10.10.20
    Trying 10.10.10.20...
    Connected to 10.10.10.20.
    Escape character is '^]'.
    BusyBox v1.2.1 (2006.10.12-23:46+0000) Built-in shell (ash)
    Enter 'help' for a list of built-in commands.
    [root@greenphone /]$

Note that you're using the busybox commandline, not bash or tcsh. While the busybox shell has a lot of functionality, it may not be quite what you're expecting if you do a lot of shell scripting.

This can be a tricky procedure. I had a lot of problems connecting the greenphone while writing this article. I was never able to narrow down what the problem was, and more than once had to reboot the greenphone completely before I could connect again.

Developing Software Using the Emulated Greenphone

The SDK comes with a complete greenphone emulator, and you'll want to use it for most of your application development activities. In fact, many application developers may end up exclusively using the emulator to develop their application, and rely on someone else who actually owns the phone to test it out.

Open up a console window by clicking on the Konsole icon:


The following sourced script sets up your environment variables and PATH so that you can compile x86 binaries:
    source /opt/Qtopia/SDK/scripts/devel-x86.sh

The source code to the sample application is in the "projects" directory off the home directory of the default SDK user:
    cd ~/projects

Create a copy of your pristine sample application. I like to use "zug." You can name it whatever you like.
    cp -a application zug

Make it writable...
    chmod -R a+rw zug

And cd into it...
    cd zug

Modify it so you know you're running the version you compile....
    sed -i 's/at all\./&  Except say HELLO WORLD!/' examplebase.ui

Boilerplate Qtopia build steps...
    qtopiamake && make clean && make loud && make install

Now we start the emulated environment. Click the runqvfb icon, then the runqpe icon to start the Greenphone skin, then the Qtopia Phone environment...


A dialog box titled "Number: 555001" will appear. You can close it.

Now, tell Qtopia running in qvfb to scan for the new application:
    gph -rescan

You can run the example application directly from the command line and it will appear in the virtual greenphone, or you can navigate to it using the greenphone UI...
    ./example

Building and Deploying an Application to the Greenphone

The process for building and deploying an application to the greenphone is similar to building the emulated version. This procedure actually installs the package to the greenphone so you can execute it using the application menu on the greenphone -- even when you're disconnected.

On the Developer SDK desktop, click the Konsole icon to open up a console window:


This sourced script sets up your environment variables and PATH so that you can compile greenphone binaries:
    source /opt/Qtopia/SDK/scripts/devel-greenphone.sh


The source code to the sample application is in the "projects" directory off the home directory of the default SDK user...
    cd ~/projects

Create a copy of your pristine sample application. I like to use "gzug." You can name it whatever you like...
    cp -a application gzug

Make it writable...
    chmod -R a+rw gzug

And cd into it...
    cd gzug

Modify it so you know you're running the version you compile.
    sed -i 's/at all\./&  Except say HELLO WORLD!/' examplebase.ui

Perform the boilerplate Qtopia build steps...
    qtopiamake && make clean && make

Create the Package, Install, it and Run it...
    gph -p -i -r

Under the greenphone's hood

To gain an understanding of how the greenphone works, you can connect to the shell running on the greenphone as described earlier in this article. Once there, you can use the standard Unix commands provided by busybox.

For example, the mount command gives us insight into what filesystems are available on the greenphone and how they're mounted:
    [root@greenphone /]$mount
    /dev/root on / type ext2 (rw)
    none on /proc type proc (rw)
    tmpfs on /dev type tmpfs (rw)
    none on /dev/pts type devpts (rw)
    tmpfs on /var type tmpfs (rw)
    /dev/tffsb on /mnt/disk2 type ext2 (rw,noatime)
    /dev/tffsc on /mnt/user type ext2 (rw,noatime)
    /dev/tffsd on /mnt/user_local type vfat (rw,noatime)
    /dev/loop0 on /opt/Qtopia.rom type cramfs (ro)
    [root@greenphone /]$ls -l /dev/root
    lrwxrwxrwx 1 root root 5 Dec 4 12:15 /dev/root -> tffsa

Here's what we learn:


Mount pointDeviceFilesystemR/W status
/tffsaext2rw
/mnt/disk2tffsbext2rw
/mnt/usertffscext2rw
/mnt/user_localtffsdvfarw
opt/Qtopia.romloop0cramfsro
/procnoneprocrw
/devtmpfstmpfsrw
/dev/ptsnonetmpfsrw

Now, try running netstat:
    [root@greenphone /]$netstat -na|grep LISTEN
    tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN
    tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN
    tcp 0 0 0.0.0.0:23 0.0.0.0:* LISTEN
    unix 2 [ ACC ] STREAM LISTENING 767 /tmp/qtopia-0/valuespace_applayer
    unix 2 [ ACC ] STREAM LISTENING 1053 /tmp/.qt_soundserver-0
    unix 2 [ ACC ] STREAM LISTENING 728 /tmp/qtembedded-0/QtEmbedded-0

We see that there is an ftp server (21), telnet server (23) and smb server (25) listening on the phone. As well as three qtopia-specific named sockets.

The /etc/inittab configuration file shows us what the greenphone does at boot time. Let's take a look...
    [root@greenphone /]$cat /etc/inittab |grep -v "^#" | grep -v "^$"
    ::sysinit:/etc/rc.d/rc.filesystems
    ::sysinit:/etc/rc.d/rc.newrootfs
    ::sysinit:/etc/rc.d/rc.modules
    ::sysinit:/etc/rc.d/rc.sysinit
    ::sysinit:/etc/rc.d/rc.services
    ttyS2::respawn:-/bin/sh
    ::respawn:/sbin/syslogd -n -C 512 -S -L -R hostpc >/dev/null 2>/dev/null
    ::respawn:/usr/sbin/atd /var/spool/at >/dev/null 2>/dev/null
    ::sysinit:/mnt/user/etc/trolltech_startup.sh
    ::shutdown:/etc/rc.d/rc.shutdown

The "sysinit" scripts run just at boot time, bringing up the file systems, loading modules, starting the network, etc. The rc.services script starts up the telnet, ftp and samba servers.

The /mnt/user/etc/trolltech_startup.sh script is especially interesting. It brings up Qtopia by first sourcing the Qtopia environment, then by running /opt/Qtopia.rom/qpe.sh. The qpe.sh script is responsible for keeping the qpe application up and running. The qpe app is the heart of the greenphone's graphical user interface.

Let's see what's running...
    [root@greenphone bin]$ps
    PID Uid VmSize Stat Command
    1 root 320 S init # everyone's ancestor
    92 root 360 S /bin/ash /opt/Qtopia/qpe.sh # script to keep qpe up
    103 root 14812 S qpe # The main Qtopia server
    130 root 764 S ftpd # The ftp server
    134 root 1460 S /usr/local/samba/bin/smbd # Samba
    136 root 1292 S /usr/local/samba/bin/nmbd # Samba
    139 root 236 S /usr/sbin/telnetd # Telnet server
    155 root 3728 S < /opt/Qtopia/bin/qss # Sound server
    156 root 6112 S N /opt/Qtopia/bin/quicklauncher # A running application

The busybox version of the ps command has no options. However, it still gives us valuable information about what's running on the phone. I've annotated the output somewhat to highlight the more interesting executables.

Greenphone SDK source

For this review Trolltech allowed me to download the Greenphone SDK source. The source code is not currently available generally, but hopefully they'll get through the legal issues and allow everyone to download this source code. It's a treasure-trove of information on how to build Qtopia applications.

Conclusion

The Trolltech Greenphone SDK is well thought out:
  • They deliver the SDK as a VMWare virtual machine. This makes the development environment cross platform, easy to update, ensures all developers have the same toolset and eliminates a lot of frustration when installing the toolchain.

  • They include an emulated environment. Because you have an environment under which you can build most of your application, you don't actually have to have a greenphone at your disposal to write software for it. Obviously, you'll want to install any software you write on a real phone before releasing it -- but this can be a last minute activity after the application development is mostly done.

  • All of the documentation is on the virtual machine.
However, there are some problems:
  • Most open source developers do not get paid for their work -- therefore they develop open source software to scratch their own itch. Obviously Trolltech wants to tap into this phenomenon by making the greenphone available to developers. Unfortunately, the $700 price tag is beyond what most developers can afford for this purpose.

  • The source code to the applications is not available on the SDK. Currently, the source code is not available at all due to some legal issues. This source code is critical to the success of the greenphone. It would be difficult to develop anything without this valuable source of documentation. Trolltech should put whatever source code they can on their web site right away -- and put the rest of the code up later when the legal issues are ironed out.
Bottom line:

Trolltech is doing an admirable job trying jumpstart the market for their software. To make it work, they have to get phones in the hands of developers who will write apps (and perhaps make Trolltech's apps better) for the phone. Those apps will then increase the value proposition for their toolkit which will attract the attention of the big hardware manufacturers. Once those manufacturers start cranking out huge numbers of phones, that will lower the price point for Qtopia-based phones and Trolltech will be out of the hardware business -- which is exactly what they want. The question is can they get enough traction from Open Source developers and get enough phones in the wild.

My suggestion is this: Run a contest. That's exactly what VMWare did when they released the VMWare player, and now they have several hundred "virtual appliances" on their web site. Give a nice cash prize for the best application, and a phone each to the top runners up. Make sure all the entries are open sourced, and by the beginning of Q2 2007, they'll have at least one hundred new applications for the greenphone. That will be something that the hardware manufacturers will have a hard time ignoring.



About the author: John Lombardo is the author of Embedded Linux, the first book published on the subject. He's been working with Linux since the "0.9" days. However, he does remember downloading a very early version and thinking: "Yeah, right -- how is this Linux thing going to compete with Coherent."



Related stories:

(Click here for further information)


7 Advantages of D2D Backup
For decades, tape has been the backup medium of choice. But, now, disk-to-disk (D2D) backup is gaining in favor. Learn why you should make the move in this whitepaper.

4 Legal Reasons to Control Internet Access
The Internet is obviously a valuable resource for many organizations. However, many are exposed to legal liability concerns because they fail to control Internet access. Learn if you're safe in this white paper.

Rapidly Resolve J2EE Application Problems
Whether you are in the process of building J2EE applications or have J2EE applications already running in production, you must ensure that they deliver the expected ROI. Learn how in this white paper.

Load Testing 2.0 for Web 2.0
There are many unknowns in stress testing Web 2.0 applications. Find out how to test the performance of Web 2.0 in this white paper.

Build Better Games Online
For the game infrastructure providers, life is complex. Making money from games has become more complicated. Why? Find out in this white paper.

Building a Virtual Infrastructure from Servers to Storage
This white paper discusses the virtual storage solutions that reduce cost, increase storage utilization, and address the challenges of backing up and restoring Server environments.

Gaining Faster Wireless Connections with WiMAX
Welcome to what is quickly becoming the hyperconnected world where anything that would benefit from being connected to the network will be connected. Learn more in this white paper.

Is Your Desktop a Security Threat?
The new wave of sophisticated crimeware not only targets specific companies, but also targets desktops and laptops as backdoor entryways into those business’ operations and resources. Learn how to stay safe in this white paper.

Increasing SAN Reliability by 100 Percent
Storage area networks (SAN) are a strong part of storage plans. Learn how to increase your reliability and uptime by 100 percent in this case study.

 


Got a HOT tip?   please tell us!
Free weekly newsletter
Enter your email...
Click here for a profile of each sponsor:
PLATINUM SPONSORS
GOLD SPONSORS
(Become a sponsor)

ADVERTISEMENT
(Advertise here)

Check out the latest Linux powered...

mobile phones!

other cool
gadgets
HOWTOs: from DevShed & IBM DeveloperWorks:



BREAKING NEWS

• Linux device monitors networks
• Linux gets security black eye
• Debian adding low-power NAS devices
• Microsoft frees poor children from Linux struggles
• Open source awards open for nominations
• Atom-based ECX board runs Linux
• Tiny boards gain Linux cross-tools support
• Cross-platform tools vendor announces awards, earnings
• Little thin client runs Linux
• $7 Soc runs Linux
• Linux wins big in financial trading
• Linux-based remote access equipment adds monitoring
• Dual-core ARM SoC clocks to 1.2GHz
• Verizon Wireless, seven others join Linux phone org
• Android Developer Challenge announces first-round winners


Most popular stories -- past 30 days:
• Ubuntu ported to ARM
• Linux still top embedded OS
• Linux gains new architecture support
• Linux 2.6.25 release bolsters ARM
• Linux-based diskless notebook costs under $300
• Low-cost MP3 player gains fancy Linux port
• Dutch UMPC runs Ubuntu Linux
• Mini-notebook boasts Linux, near-fullsize keyboard
• PC/104 module runs x86 Linux on 1.85 Watts
• Low-cost Linux-based NAS device supports RAID 1
• Free router distro gains wild WiFi features


Linux-Watch headlines:
• Verizon chooses Linux "platform of choice"
• Hats off to Fedora 9
• Running a small business on desktop Linux
• Sun launches OpenSolaris
• Via tiptoes toward openness
• Linux certification comes to Italy
• Installing Ubuntu Hardy Heron as a web hosting server
• Black Duck Buys Koders
• Open source conference co-locates with Ubuntu show
• Ubuntu 8.04 ready to challenge Windows


Also visit our sister site:


Sign up for LinuxDevices.com's...

news feed

Home  |  News  |  Articles  |  Polls  |  Forum  |  About  |  Contact
 
Use of this site is governed by our Terms of Service and Privacy Policy. Except where otherwise specified, the contents of this site are copyright © 1999-2008 Ziff Davis Enterprise Holdings Inc. All Rights Reserved. Reproduction in whole or in part in any form or medium without express written permission of Ziff Davis Enterprise is prohibited. Linux is a registered trademark of Linus Torvalds. All other marks are the property of their respective owners.