Username/Email:  Password: 
TwitterFacebookFlickrRSS

Using Linux to Develop Software for the Palm OS

Set up your Linux box as a Palm development platform and write your first application.

When I started my summer job a few months ago, I did not know one thing about Palm Pilots, Visors, WAP and all the other buzzwords used ever so frequently when talking about embedded systems and wireless gadgets. But when asked to join the development team, I was excited since it gave me an opportunity to prove that there is no better environment than a solid Linux box for software development.

A quick search on the web will reveal an astonishing amount of information and documentation on this topic. The Palm OS Platform Developer web site (http://www.palmos.com/dev/), for example, is an excellent starting point. But after reading through some of the documents, you will want to actually do something. Thus, I will show how to install all the necessary tools to start writing your first application for the PalmPilot, with the assumptions that you know your way around a Linux system and can get superuser privileges for installing the necessary software. The procedures outlined in this article have been successful on at least two Linux Mandrake systems, one based on Red Hat 6.1, the other Red Hat 6.0.

The Palm OS Emulator

First, we need to set up our environment. You would think that the first thing to do would be to go out and buy one of these gadgets (unless, of course, you are already geeky enough to have this nifty device managing your entire life). But that's not necessary, at least not yet. It is much easier (not to mention cheaper) to download and install the Palm OS Emulator (POSE). The POSE does a decent job of emulating the operations of Palm Computing Platform hardware devices. With it, users can load ROM images, applications, and databases and use them on their desktop computers. This way, there is no need to synchronize your Palm every time you want to test the latest version of your program. Also, by using POSE you have access to all kinds of different devices, and can thus test your application on different platforms right from your desk.

Applications for the Palm OS are most commonly written in C, using a bunch of Palm-specific headers and libraries. These headers and libraries are part of the Palm OS SDK (Software Development Kit), which comes with the prc-tools.

In order to compile the programs you're going to write, you will need the prc-tools, a complete compiler tool chain for building Palm OS applications in C or C++. Additionally, you might want to install PilRC, a little tool to preview the layout of your applications before building them.

POSE for UNIX can be obtained from http://www.palmos.com/dev/tech/tools/emulator/emulator_src_30a6.tar.gz. However, in order to make sure that you get the most recent version of POSE it is a good idea to go to http://www.palmos.com/dev/tech/tools/emulator/ and read carefully through the page and the relevant links.

Once you download the archive, place it in a convenient location and extract it. I usually extract new archives into /tmp/

mv emulator_src_30a6.tar.gz /tmp
cd /tmp
tar zxvf emulator_src_30a6.tar.gz

or, if your system does not have GNU tar installed:

gzip -cd emulator_src_30a6.tar.gz | tar xvf -
Before building the emulator, we will need to satisfy a few requirements. We use pthreads, so you need GNU glibc2 (a.k.a. Linux libc6) C library and a 2.x kernel on a Linux system. Other operating systems need to support true threads. The source makes heavy use of C++ templates and exceptions. On Linux, you must have egcs-1.1.1 or better to compile it. egcs-1.1 or any gcc below 2.95 may not work. Red Hat Linux 6.0 comes with egcs 1.1.2, so you should be okay there. If you are running Red Hat Linux 5.2, you will need to download the latest from http://gcc.gnu.org/ and build it. For other OS's, either use egcs, or be sure your compiler supports these C++ features. (from Emulator_Src_3.0a6/Docs/_Building.txt)

Furthermore, POSE uses the FLTK X toolkit--you will need to download and install it before you attempt to build POSE on your system. The FLTK X toolkit is available from http://www.fltk.org/, but if you happen to be on a Red Hat Linux system, you might consider downloading the RPM from http://rpmfind.doc.ic.ac.uk/fltk.html or your favorite RPM-mirror and install it (as root):

rpm -i fltk-x.x/rpm

To install FLTK X toolkit from sources, download the fltk-x.x archive from http://www.fltk.org/, put it in a convenient location and extract it:

mv fltk-1.0.9-source.tar.gz /tmp
cd /tmp
tar zxvf fltk-1.0.9-source.tar.gz
or
gzip -dc fltk-1.0.9-source.tar.gz | tar xvf -
Change to the FLTK directory and check the README: ``FLTK is available under the terms of the GNU Library General Public License. Contrary to popular belief, it can be used in commercial software.'' (Even Bill Gates could use it.)

To build and install the FLTK issue the following commands:

./configure
make
su
make install

Should any of the above give you errors, then you need to verify that you have the required tools to build FLTK, such as gcc and make, both available from http://www.gnu.org/.

After installing the FLTK, you need to finish the POSE install. Go to /tmp/Emulator_Src_3.0a6/BuildUnix/ and issue the following commands:

./configure
make
su
make install

Again, if you get an error here, go back and make sure that you have met all the requirements. Please note that the install script of FLTK places fluid per default into /usr/local/bin, so that if you compile POSE as root, you might get an error that fluid was not found. This should be a reminder that you are not supposed to be root at this point in time anyway.

Assuming everything went according to plan, you can now start POSE by simply issuing the command pose, and a window will open on your desktop, showing you a Palm Device. Neat. But this doesn't get us very far yet--in order for POSE to actually work, and in order for you to use POSE to actually emulate a Palm device, you need a ROM image. The ROM image contains all of the code used for a specific version of the Palm OS. You can obtain ROM images in three ways:

  1. Follow the procedure as described under http://www.palmos.com/dev/tech/tools/emulator/.

  2. Download the ROM from a handheld that has been placed in the device cradle and connected to the desktop computer.

  3. Have somebody send you a ROM image.

In order to download a ROM image file from a device, start up POSE and right-click anywhere in the window. A menu will pop up from which you can select File -> Transfer ROM. This assumes, of course, that you have set up your system to talk to the cradle. For information on how to set up your Palm device under Linux, refer to http://www.orbits.com/Palm/PalmOS-HOWTO.html.

While it is certainly easy to get the file from somebody else, or to transfer it from your Palm device, I still recommend joining the Palm Solution Provider Program as described under http://www.palmos.com/dev/tech/tools/emulator/, since you will gain access to a large variety of different ROM images. When downloading ROM images from the Palm web site, you are offered to download either Windows or Mac format. Simply download the Windows format, which is just a zipped archive. You can extract the ROM image by issuing the following command:

unzip imagename.zip

At this point I recommend that you set up a directory where you keep all your Palm-related material. The default directory for this should be /usr/local/palmdev, where I created a subdirectory called roms. Place the ROM image files into this directory so you don't lose them. Now start POSE and right click anywhere in the window. Select File -- >New from the menu and choose the location of the ROM file and the appropriate device. For example, if you want to use the ROM image palmvii-dbg-75.rom, you must choose ``Palm VII'' from the device menu. (Choosing an invalid combination will lead to an error message.) Voila! Now go and play around with your new Palm device.

______________________