old-www/LDP/LG/issue90/forsberg.html

357 lines
17 KiB
HTML

<!--startcut ==============================================-->
<!-- *** BEGIN HTML header *** -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML><HEAD>
<title>Software development for a Sharp Zaurus SL-5500 Linux PDA LG #90</title>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#0000AF"
ALINK="#FF0000">
<!-- *** END HTML header *** -->
<!-- *** BEGIN navbar *** -->
<A HREF="ecol.html">&lt;&lt;&nbsp;Prev</A>&nbsp;&nbsp;|&nbsp;&nbsp;<A HREF="index.html">TOC</A>&nbsp;&nbsp;|&nbsp;&nbsp;<A HREF="../index.html">Front Page</A>&nbsp;&nbsp;|&nbsp;&nbsp;<A HREF="http://www.linuxgazette.com/cgi-bin/talkback/all.py?site=LG&article=http://www.linuxgazette.com/issue90/forsberg.html">Talkback</A>&nbsp;&nbsp;|&nbsp;&nbsp;<A HREF="../faq/index.html">FAQ</A>&nbsp;&nbsp;|&nbsp;&nbsp;<A HREF="okopnik.html">Next&nbsp;&gt;&gt;</A>
<!-- *** END navbar *** -->
<!--endcut ============================================================-->
<TABLE BORDER><TR><TD WIDTH="200">
<A HREF="http://www.linuxgazette.com/">
<IMG ALT="LINUX GAZETTE" SRC="../gx/2002/lglogo_200x41.png"
WIDTH="200" HEIGHT="41" border="0"></A>
<BR CLEAR="all">
<SMALL>...<I>making Linux just a little more fun!</I></SMALL>
</TD><TD WIDTH="380">
<CENTER>
<BIG><BIG><STRONG><FONT COLOR="maroon">Software development for a Sharp Zaurus SL-5500 Linux PDA</FONT></STRONG></BIG></BIG>
<BR>
<STRONG>By <A HREF="../authors/forsberg.html">Bruce Forsberg</A></STRONG>
</CENTER>
</TD></TR>
</TABLE>
<P>
<!-- END header -->
<P>Recently I have been looking for an MP3 player that would satisfy several
criteria. One, be usable with Linux and second, be usable with Old Time Radio
shows. I am a big fan of what is called Old Time Radio here in the USA. This
is radio shows from the 1930's, 40's, and 50's. One can buy a CD-R full of
shows all in MP3 format. OTR shows are typically encoded at 24, 32, or 48
kbps in mono format with a sample rate of 22050 and are 1/2 hour to 1 hour in
length. Not all MP3 players work well under these conditions. Thus began my
search for a better solution. After some search I came to the conclusion that
a Linux PDA would be my best bet where I could write custom software to
perform the needed functionality that is required. Since the Sharp Zaurus
SL-5500 uses Linux with Qtopia, a Qt system for embedded systems, this became
an obvious choice since I already know Qt programming on Linux.
<P>When I looked at the Sharp web site I saw two Linux PDA models present for
sale in the USA. The SL-5500 and the SL-5600. At the time of writing this
article the SL-5600 has just become available. There are several main
differences between the two models but the main one is that the SL-5600
contains a 400 Mhz Intel Xscale processor whereas the SL-5500 contains a
206 Mhz Strong ARM SA-1110 processor. I decided on the SL-5500 since that
was the only option when I bought. The 400 Mhz would be nice but not needed
for audio. If I wanted video I would have waited for the 5600. This device
contains a Linux 2.4 Embedix kernel stored in a 16 MB Flash ROM with many
other standard applications. It contains 64 MB SDRAM of which about half
is used for program memory usage and the other half for user program storage.
It contains a host of accessories and other capabilities.
<P>I was able to purchase my Sharp Zaurus SL-5500 new on EBAY for about $300
plus $20 shipping. It came with a docking station with a USB connector and
software for MS Windows. That was several months ago. Now that the SL-5600
has come out the SL-5500 is selling for about $200-$300 new.
<P><H3>SETUP FOR DEVELOPMENT</H3>
<P>In order to learn how to program on this platform I decided that my OTR
MP3 project was too big for a first project so I choose a simpler project.
It is a car mileage calculator. I just purchased a Toyota Prius Hybrid
automobile. Since I get around 45-50 MPG I like to track my mileage. So I wrote
down a few requirements for the program and started out on how to program for
the SL-5500 PDA. The following are my findings.
<P>First you will need several pieces of software. When you develop for the
Sharp Zaurus you will develop in two phases. You will perform all your GUI
layout, coding, debugging, and testing on your Linux Intel box. Then when you
have finished that, you will cross-compile and package the software for the
Sharp Zaurus PDA using the Strong ARM architecture. You will need several
RPMs to accomplish this. Here are the packages that you will need.
<P>qtopia-free-1.X.X-1.i386.rpm -- Qtopia SDK for Linux Intel. Get the latest from <A HREF="http://www.trolltech.com/download/qtopia/index.html">Trolltech's web site.</A>
<P>binutils-cross-arm-2.11.2-0.i386.rpm -- Arm binary utilities for Linux Intel
<P>gcc-cross-sa1100-2.95.2-0.i386.rpm -- Arm cross compiler for Linux Intel
<P>glibc-arm-2.2.2-0.i386.rpm -- Arm glibc
<P>linux-headers-arm-sa1100-2.4.6-3.i386.rpm -- Arm header files
<P>The above 4 files can be obtained from <A HREF="http://docs.zaurus.com/linux_compiler_setup_howto.shtml">the Zaurus Documentation web site</A> along with instructions on how to install them.
<P>To begin with you will need the standard stuff that comes with your Linux
on Intel distribution for compiling C++ programs. Next you will need to
install the Qtopia SDK (Software Development Kit). Please note that there is
a commercial SDK as well as a free SDK. If you use the free SDK you might be
limited as to the licensing of your program. Be sure to read Trolltech's
information regarding this. Once this is installed you will be able to
compile, run, and debug on your Linux on Intel box. When this is done and you
are ready to test your program you will need to install the last 4 rpms
listed above. This will give you the ability to cross compile your program
for the Strong ARM processor.
<P><H3>DEVELOPMENT</H3>
<P>Now that you have development setup you are ready to start developing. If
you have never developed before, the Sharp Zaurus is the ideal platform. This
is because of limited storage and memory the best programs are simple
programs. Full function office suites are not wanted. If you need an idea
then I suggest you look at program search engines for the Palm and Microsoft
OS PDAs. Then look at the Zaurus PDA search engines. When you find an
application that is not available for the Zaurus but is for the others then
chances are this is a good choice. Also choose a program that interests you.
<P>Before you get started you will need to set environment variables for
developing on your Linux on Intel box. You will need to set the following
in your bash shell assuming that you placed the software package in the
default location:
<PRE>
QPEDIR=/opt/Qtopia
QTDIR=/opt/Qtopia
TMAKEPATH=/opt/Qtopia/tmake/lib/qws/linux-x86-g++/
PATH=$QTDIR/bin:$QPEDIR/bin:${PATH}:/opt/Embedix/tools/bin
LD_LIBRARY_PATH=$QTDIR/lib:${LD_LIBRARY_PATH}
export QPEDIR QTDIR PATH TMAKEPATH LD_LIBRARY_PATH
</PRE>
<P>The next few steps entail developing just like you develop a normal Qt
application. I will not go into this since there have been many articles on
this already. A good book on the subject is published by O'Reilly and is
called "Programming with Qt" by Matthias Kalle Dalheimer. Briefly you will
use designer to create your GUIs. Keep in mind that the display is 240x320.
Then generate a ui file. Next you will create a project file. Usually called
your project name dot pro (ie example.pro). If you need a little help look in
the SDK directory /opt/Qtopia/example. This is an example program that
contains most of the components needed to build a program. Use this .pro
file as a starting point. Once your .pro file is created then you will
generate your Makefile by:
<PRE>
tmake -o Makefile yourprogram.pro
</PRE>
<P>Now start your coding. Create your classes and your slots and connections
as with ordinary Qt programming. When this is completed then build your
program by typing "make". Fix any errors and when you have a successful
build then you are ready to run your program in the emulator. Since the Sharp
Zaurus has no X server you need an emulator to simulate the environment of
the Sharp Zaurus. First you need to run the Qt/Embedded Virtual X11
Framebuffer. In the same shell type:
<PRE>
qvfb &
</PRE>
<P>You should now have an X11 application running that is the emulator. Now
you will need to run the equivalent of a window manager. To do this type in
the same shell:
<PRE>
qpe &
</PRE>
<P>If everything has gone well then you should see an emulation of a Sharp
Zaurus PDA. It is in this environment that you will be able to test and debug
your program. Even though you don't see your program all you need to do to
have it run is to start it from your development directory. Just run your
program normally. You should be able to run it in a debugger as well. You can
now fully test your application.
<P>Your next step is to generate an ipkg file that can be loaded onto your
PDA and installed. ipkg format is the format used on the Sharp Zaurus PDA.
To do this you need to first compile your program for the Strong ARM processor
using the cross compiler and tools that you installed in the section above.
To start with it is best to start a new shell. Once in this shell setup the
following environment variables:
<PRE>
CROSSCOMPILE=/opt/Embedix/tools
QPEDIR=/opt/Qtopia/sharp
QTDIR=/opt/Qtopia/sharp
PATH=$QTDIR/bin:$QPEDIR/bin:$CROSSCOMPILE/bin:${PATH}
TMAKEPATH=/opt/Qtopia/tmake/lib/qws/linux-sharp-g++/
LD_LIBRARY_PATH=$QTDIR/lib:${LD_LIBRARY_PATH}
export QPEDIR QTDIR PATH LD_LIBRARY_PATH TMAKEPATH
</PRE>
<P>Next you need to generate a new Makefile that is for the Strong ARM
processor. So type:
<PRE>
tmake -o Makefile yourprogram.pro
</PRE>
<P>Then "make clean" to remove all the old object files. Then "make", you
should now be building everything with the cross compiler. Since there is a
limit to the size that a PDA can hold I recommend that you strip your
executable. But, don't make the mistake that I made and use strip. You need
to use the cross compiled strip, in this case arm-linux-strip.
<P>Now that you have your executable you need to package everything in an
ipk file. First you need to create a top level directory, we will use prog
for our example. Next you need to create the following directory trees:
<PRE>
prog/opt/QtPalmtop/bin
prog/opt/QtPalmtop/lib (if needed)
prog/opt/QtPalmtop/apps/Applications
prog/opt/QtPalmtop/help/en/html
prog/opt/QtPalmtop/pics
prog/CONTROL
</PRE>
<P>First of all put your executable in the bin directory. If you have
libraries as well then put them into the lib directory. Your help file will
be in html format. So create a html file with your favorite editor and place
this into the html directory. The file name should be your executable name
dot html. The directory shown above assumes an english
html file (ie en). If you use a different language then you will need to use
a directory other than en. In the pics directory place an image file in png
format that is 32 X 32 pixels. This will show up as the icon used for this
application. This leaves us with two directories, CONTROL and Applications.
In CONTROL you will place a file called control. This will be used for ipk.
In Applications create a file called yourprogramname.desktop.
<P>For my mileage program I use a control file with the following entries:
<PRE>
Package: mileage
Priority: optional
Section: Misc
Version: 2.0
Architecture: arm
Maintainer: Bruce Forsberg forsberg@tns.net
Description: A Car Mileage Calculator Program
</PRE>
<P>The Package field contains the name of the package. Priority should be
optional for most other applications. Section can be Misc for now but should
be changed later to an appropriate value. See the IPKG docs for more
information. Version should be the version of your application. Architecture
should be arm for the SL-5000 and SL-5500 Zaurus PDAs. Maintainer should be
the name and email address of the person maintaining this package. Description
should be a brief description of the program. Depends is an optional field
if your application depends on other packages being present. See the
resources section of this article for more detailed information on the
IPKG format.
<P>If you want your icon to show up in the Qtopia desktop you will need to
add a desktop file in the Applications directory. For the desktop file for
my mileage program I use the entries shown below. The fields should be
self explanatory.
<PRE>
[Desktop Entry]
Comment=A Car Mileage Calculator Program
Exec=mileage
Icon=mileage
Type=Application
Name=Mileage Calculator
</PRE>
<P>Now that we have all these files created and stored into the subtree of
prog we are ready to build the package. Use this
<A HREF="http://docs.zaurus.com/downloads/ipkg-build.sh">script</A>
and then type "ipkg-build.sh
prog". You now have a .ipk file. Simply use the normal methods of loading
software onto zaurus and install your program and test it. If you launch your
program and nothing happens, one thing to try is to install the qpe-terminal
application. This will give you the equivalent of an xterm on the Zaurus.
Start the terminal application and enter your application name from this
window and see if you get any error messages. Also you can type dmesg. This
will display the messages sent to the error log.
<P>I hope this article will inspire you to start programming for the Sharp
Zaurus PDAs. It is a lot of fun and adds to the success of Open Source and
Linux. You also will be surprised just how much you will wind up using your
new PDA. After you finish your project and are ready to release it check out
sourceforge.net. This is a great place to host your project. Then upload your
ipk to the Zaurus PDA search engine at <A HREF="http://www.killefiz.de/zaurus">
http://www.killefiz.de/zaurus.</A> Be prepared
to release another version in a couple of weeks after the first release. You
should fix any major bugs found with this release so that your program will
be useable. Also think like a user when you create your program. Make it as
easy to use as possible. For example for my mileage program I added a GUI
keypad to enter odometer and fuel and a button to enter today's date. Even
though the Zaurus has a keyboard, the GUI keypad makes entry so much easier.
So, get your Zaurus start developing and have fun.
<P><H3>RESOURCES</H3>
<PRE>
How to docs for the Sharp Zaurus - <A HREF="http://docs.zaurus.com">http://docs.zaurus.com</A>
IPKG How to for Sharp Zaurus - <A HREF="http://docs.zaurus.com/ipkg_howto.shtml">http://docs.zaurus.com/ipkg_howto.shtml</A>
IPKG Home Page - <A HREF="http://www.handhelds.org/z/wiki/iPKG">http://www.handhelds.org/z/wiki/iPKG</A>
IPKG build script - <A HREF="http://docs.zaurus.com/downloads/ipkg-build.sh">http://docs.zaurus.com/downloads/ipkg-build.sh</A>
Programming with Qt book - <A HREF="http://www.oreilly.com/catalog/prowqt2">http://www.oreilly.com/catalog/prowqt2</A>
Sharp SL-5500 - <A HREF="http://www.sharpusa.com/products/ModelLanding/0,1058,698,00.html">http://www.sharpusa.com/products/ModelLanding/0,1058,698,00.html</A>
Sharp SL-5600 - <A HREF="http://www.sharpusa.com/products/ModelLanding/0,1058,1016,00.html">http://www.sharpusa.com/products/ModelLanding/0,1058,1016,00.html</A>
Zaurus Developer site - <A HREF="http://www.zaurus.com/dev">http://www.zaurus.com/dev</A>
Zaurus Program Search Engine - <A HREF="http://www.killefiz.de/zaurus">http://www.killefiz.de/zaurus</A>
Must-Have Zaurus Hardware and Software - Linux Journal Jan 2003 Article, not available on-line yet.
Linuxdevices.com article - <A HREF="http://www.linuxdevices.com/articles/AT6553340334.html">http://www.linuxdevices.com/articles/AT6553340334.html</A>
Car Mileage PDA Calculator Home Page - <A HREF="http://mileage.sourceforge.net">http://mileage.sourceforge.net</A>
</PRE>
<!-- *** BEGIN author bio *** -->
<P>&nbsp;
<P>
<!-- *** BEGIN bio *** -->
<P>
<img ALIGN="LEFT" ALT="[BIO]" SRC="../gx/2002/note.png">
<em>
Bruce is just an average guy having fun with Linux. He is the
founder of the
<A HREF="http://osalp.sourceforge.net">Open Source Audio Library Project</A>.
He got his start programing freeware on
windows 3.1. When he realized that all one had to do was to not
return from a message and it would hang the entire operating
system, he knew there had to be a better way. Linux was the answer.
</em>
<br CLEAR="all">
<!-- *** END bio *** -->
<!-- *** END author bio *** -->
<!-- *** BEGIN copyright *** -->
<hr>
<CENTER><SMALL><STRONG>
Copyright &copy; 2003, Bruce Forsberg.
Copying license <A HREF="../copying.html">http://www.linuxgazette.com/copying.html</A><BR>
Published in Issue 90 of <i>Linux Gazette</i>, May 2003
</STRONG></SMALL></CENTER>
<!-- *** END copyright *** -->
<HR>
<!--startcut ==========================================================-->
<!-- *** BEGIN navbar *** -->
<A HREF="ecol.html">&lt;&lt;&nbsp;Prev</A>&nbsp;&nbsp;|&nbsp;&nbsp;<A HREF="index.html">TOC</A>&nbsp;&nbsp;|&nbsp;&nbsp;<A HREF="../index.html">Front Page</A>&nbsp;&nbsp;|&nbsp;&nbsp;<A HREF="http://www.linuxgazette.com/cgi-bin/talkback/all.py?site=LG&article=http://www.linuxgazette.com/issue90/forsberg.html">Talkback</A>&nbsp;&nbsp;|&nbsp;&nbsp;<A HREF="../faq/index.html">FAQ</A>&nbsp;&nbsp;|&nbsp;&nbsp;<A HREF="okopnik.html">Next&nbsp;&gt;&gt;</A>
<!-- *** END navbar *** -->
</BODY></HTML>
<!--endcut ============================================================-->