Poplar ProductivityWare Articles:
Getting Started with Palm OS Development Using PRC-Tools on Windows
by Jennifer Hodgdon

Introduction

This article is a tutorial guide to getting started developing applications in the C programming language, for handheld devices running Palm OS, using PRC-Tools, on a Windows-based PC. It's written from the perspective of someone who learned C in the 80's, has developed software on both Unix-family and Windows-family computers since then, and uses a Palm OS-based handheld; I've left out most details that I thought were not necessary for someone with a similar background. Also, there is a lot of information on the Web on how to develop Palm OS-based applications. Where possible, I have linked to those sources; what I am trying to do here is to fill in the cracks, by recording what I learned from trial and error, that I didn't think was covered very completely in existing Web sources.

It is assumed here that you have already decided to use PRC-Tools -- probably because of a similar background to mine. I wouldn't recommend that someone who is completely unfamiliar with C or the Unix-family development tools (in Gnu incarnations: gcc, make, gdb, etc.) embark on PRC-Tools. And anyone who has decided to develop Palm OS software might want to visit the official Palm OS development page at Access first, click on Documentation, then choose the Garnet OS platform, and start reading. One recommended resource is the Development Tools Guide, in the Development Tools section. You might also want to check out the Palm Developer Network pages.

Note: Some of this article may be out of date, as I am not doing much Palm development lately... in particular, the ownership of the companies that make Palm OS has been in flux, so the resources mentioned may not be where they used to be. Sorry!

Here's my take on the advantages of PRC-Tools:

And the disadvantages:


Tools and Set-Up

Cygwin and PRC-Tools

In order to use PRC-Tools on Windows, you will first need to install Cygwin (a Unix-like environment for Windows), and the PRC-Tools enhancements to it. The PRC-Tools Windows Installation Page explains how; you should probably at least skim through that page as background information. Here is my version of installation instructions:

  1. Visit the Cygwin home page, and click on one of its many "Install Cygwin Now" links. This will start a setup.exe program running. Use the default settings, except:
    • Choose "Install from Internet", when you get to that screen.
    • Choose "C:\PalmDev" as your root directory. You can also install Cygwin in C:\Cygwin, and then put the Palm-specific tools into PalmDev, but I think it's simpler to just put it all in one place, unless you are planning to do a lot of other gcc development with Cygwin.
    • On the "Choose a download site" screen, choose an appropriate nearby site from the list, and then add an additional download site of
      http://prc-tools.sourceforge.net/install
      to the list.
    • After a few moments, you will reach the Select Packages screen. Browse the list and see if there are any tools you want to have (e.g., grep, awk, etc.). To run PRC-Tools, you will also need/want the binaries (but not the source) for:
      • Whatever defaults setup.exe chooses
      • "Base" section: prc-tools (or this may be just in the "Devel" section)
      • "Devel" section: binutils, gcc (you only need the C compiler), gdb, make, prc-tools, and pilrc
      • "Doc" section: cygwin-doc, man
      • "Editors" section: if you don't have one already, you might consider choosing your favorite text editor from this section. However, you can just use any text editor you already have installed in Windows, if you want.
      • "System" section: man
      • "Text" section: less
  2. When the installation is done, you need to open a Cygwin window, and mount C:\PalmDev as /PalmDev, by running the following command:
    mount -tf "C:\PalmDev" /PalmDev
  3. After you've downloaded the Palm SDK (see the Downloads from Palm/Access section below), you will also need to run the palmdev-prep utility from the Cygwin prompt.

If your installation fails, try again -- setup.exe should pick up where it left off. If you're having trouble downloading, you might try a different mirror for the main part of Cygwin. If the problem is in downloading PRC-Tools, you might try this instead (I recently had this problem, and used the steps below to complete the install):

  1. Run the Cygwin installation until it fails. This should leave an installation file folder, in the location you specified, with a lot of percent signs and "prc-tools.sourceforge.net" in the folder name. It should also have two subfolders: pilrc and prc-tools. Don't delete this yet.
  2. Run Cygwin installation again, but leave out the prc-tools packages and the special prc-tools download site. It should run to completion (if not, try a different download site).
  3. Visit the PRC-Tools downloads page, and download the latest versions of prc-tools, prc-tools-arm, and prc-tools-htmldocs. Make sure to get the files with "cygwin" in the name, and "bz2" extension. Save all three files into the prc-tools subfolder.
  4. Visit the pilrc downloads page, and download the latest version of pilrc (cygwin/bz2 versions of files) to the pilrc subfolder.
  5. Start up the Cygwin setup.exe program again. Tell it to install from a local installation, and point it to the installation folder where you just saved the files. Select all 4 packages, and run the installation.

Downloads from Palm/Access

Once you have installed Cygwin and PRC-Tools, you will need to visit the Palm OS (Garnet) Developers site at Access and get some additional downloads [Note: these will be under "Garnet OS" sections of the site]:


Creating Applications

Hello World

On the very useful TWiki FAQ for Palm development, there is a "Hello World" program in the "Example Code" section. We'll use this program as a starting point for creating our first Palm application. Here are the steps you will need to take:

  1. Download and extract the Hello World code to its own directory, under C:\PalmDev.
  2. In the Makefile that comes with the sample code, remove the "-palmos3.5" flag from the CFLAGS line -- assuming you have run palmdev-prep (see the Cygwin installation section above), the C compiler will automatically detect the SDK you have installed.
  3. Open a Cygwin window, and change to the directory where you put the files.
  4. At the Cygwin prompt, type "make". This should make "hello.prc"
  5. Start the Emulator or Simulator program. To run the Simulator, just double-click Simulator.exe (from Windows explorer), wherever you downloaded it. To run the Emulator, double-click on the ROM file whose version you want to use for testing.
  6. After the initialization sequence for Emulator/Simulator is done (you should end up on the Preferences screen), right-click on the Emulator/Simulator window, and choose Install. Find the "hello.prc" file you just made, and install it.
  7. You should now have "Hello!" somewhere in the Applications list on the Emulator/Simulator's Palm OS screen (you may need to click Applications a few times to make the list refresh, and/or find the category it's in). Click on its icon to run it. You should see a short Hello message on the screen. Click the Menu button, and choose the About menu item, to see an informational message.
  8. To close the application, click Applications and choose another application. At this point, if you were running your own application that had a memory leak or other shut-down issue, you would see a warning message.
  9. If you would like to run Hello World with the gdb debugger, use the following steps (this assumes that you have compiled and linked it with the -g debug flag):
    1. Start the Emulator (I haven't had any success doing this with the Simulator v. 5.0, so I just use the Emulator).
    2. At the Cygwin command prompt, type in the command:
      m68k-palmos-gdb.exe hello
    3. At the gdb prompt, type target pilot
    4. In the Emulator, load and start the "Hello!" application (see instructions above on how to load applications in the Emulator). Note that you can leave the Emulator running, and enter/exit gdb at will.
    5. gdb should automatically stop in PilotMain whenever you start the "Hello!" application. You can now set breakpoints, examine variables, etc. In addition, if the Emulator detects a problem while you are debugging a program, it puts up a dialog box that will allow you to choose a "debug" option, which will break into gdb at the point where the problem occurred.

Your Next Application

When you are ready to start your next application, here are some random hints and resources:


Poplar ProductivityWare: your Seattle-area source for web databases, web programming, Drupal modules and sites, and WordPress plugins

Home | Services | Experience | Articles | Downloads | News | About | Contact Us

Poplar ProductivityWare® is a trademark registered in the U.S. Patent and Trademark Office

Copyright (C) 2003-2009 Poplar ProductivityWare LLC

On This Site:

Home: Visit our home page

Services: Find out how we can improve your web site

Experience: See what we've done for other clients

Articles: Get free information on a variety of topics

Downloads: Download free software, plugins, and modules

About: Learn more about Poplar ProductivityWare

Testimonials: See what other clients have said

Values: Learn about the values that govern our business, and read our privacy policy

Contact Us: Locate our phone, email, and mailing addresses


News: Find out what's new at Poplar ProductivityWare

RSSRSS Feed: Keep track of our articles and downloads by subscribing (learn about RSS here)


Search the Poplar ProductivityWare site using Google: