Development: wxPalm

From WxWiki
Jump to navigation Jump to search

About wxPalm

Yesterday

A couple of years ago there were a few people interesting in this port so the wxWidgets team organized a contest to write its skeleton and the existing code is the result of it.

Current

This port is in a very early state. Currently the port provides limited functionality for the wxFrame, wxMenu, wxStatusBar, wxTopLevelWindow, and wxWindow classes. The other classes in the wxWidgets toolkit still need to be ported. In it's current state, the Palm OS 6 port is capable of running the minimal wxWidgets sample.

Development environment

The compiling tools exist both in Linux/*nix and Windows. The tools under the Linux/*nix can only support the m68k CPU. The tools under Windows, PODS 1.2, support both m68k and arm. The current wxPalm can only be compiled with the PODS SDK 6.1 (Windows).

Here we'll illustrate how to install the development environment for the PalmOS in Linux and Windows. The tools we installed are:

  • Compiler and debugger: gcc-2.95.3(m68k), gcc-3.3.1, gdb etc.
  • Resource Compiler: PilRC
  • Emulator: poes-3.5
  • IDE: Eclipse

Linux/*nix

Because the prc-tools have not been updated for a long time, you should build it from the source.

Download source

--- orig-gdb-5.3/gdb/remote-palmos.c	2008-01-10 09:04:06.374541492 +0800
+++ gdb-5.3/gdb/remote-palmos.c	2008-01-10 08:57:41.352600342 +0800
@@ -133,7 +133,7 @@
    other form of hairy serial connection, I would think 2 seconds would
    be plenty.  */
 
-static int remote_timeout = 2;
+/*static int remote_timeout = 2;*/
 
 static CORE_ADDR text_addr=0, data_addr=0, bss_addr=0;
 static CORE_ADDR save_ssp, save_usp;
diff -Nur orig-gdb-5.3/include/obstack.h gdb-5.3/include/obstack.h
--- orig-gdb-5.3/include/obstack.h	2001-03-14 10:27:43.000000000 +0800
+++ gdb-5.3/include/obstack.h	2008-01-10 08:59:15.357957402 +0800
@@ -423,7 +423,8 @@
 ({ struct obstack *__o = (OBSTACK);					\
    if (__o->next_free + sizeof (void *) > __o->chunk_limit)		\
      _obstack_newchunk (__o, sizeof (void *));				\
-   *((void **)__o->next_free)++ = ((void *)datum);			\
+   *((void **)__o->next_free) = ((void *)datum);				\
+   (void **)__o->next_free++;						\
    (void) 0; })
 
 # define obstack_int_grow(OBSTACK,datum)				\
@@ -431,7 +432,8 @@
 ({ struct obstack *__o = (OBSTACK);					\
    if (__o->next_free + sizeof (int) > __o->chunk_limit)		\
      _obstack_newchunk (__o, sizeof (int));				\
-   *((int *)__o->next_free)++ = ((int)datum);				\
+   *((int *)__o->next_free) = ((int)datum);				\
+   (int *)__o->next_free++;						\
    (void) 0; })
 
 # define obstack_ptr_grow_fast(h,aptr) (*((void **) (h)->next_free)++ = (void *)aptr)

Prepare for compilation

  • create a new directroy:
cd
mkdir compileprc
cd compileprc
  • extract all of the files and patch it:
tar xfz prc-tools-2.3.tar.gz
tar xfz binutils-2.16.1.tar.gz
tar xfz gdb-5.3.tar.gz
tar xfz gcc-2.95.3.tar.gz
tar xfz gcc-3.3.1.tar.gz
cat prc-tools-2.3/*.diff | patch -p0
  • patch the gdb
patch -p0 -i gdb-5.3.palmos.yhfu.diff
  • prepare the directory:
cd prc-tools-2.3/
ln -s ../binutils-2.16.1 binutils
ln -s ../gdb-5.3 gdb
ln -s ../gcc-2.95.3 gcc295
ln -s ../gcc-3.3.1 gcc
cd ..
  • If you use the Debian system, you also should install the texinfo
sudo apt-get install texi2html texinfo

Create build directory and build

mkdir build
cd build
mkdir empty
../prc-tools-2.3/configure --target=m68k-palmos --enable-languages=c,c++ --with-headers=`pwd`/empty --with-palmdev-prefix=/opt/palmdev
sudo make
sudo make install

build the pilrc

wget http://downloads.sourceforge.net/pilrc/pilrc-3.2.tar.gz?modtime=1090022400&big_mirror=0
tar -xvzf pilrc-3.2.tar.gz
cd pilrc-3.2/unix
./configure
make
sudo make install

Install the SDK 5.0r3

  • Extract the sdk
tar -x -C /opt/palmdev/ -f palmos-sdk-5.0r3-1.tar.gz
  • Prepare the SDK
palmdev-pre
export PATH=$PATH:/usr/local/m68k-palmos/bin

If you use the SDK 5r4, which is copied from the Palm_OS_Developer_Suite_1_2_Installer.rar, you should convert the *.h to unix format:

find sdk-5r4/ -name "*.h" | xargs dos2unix

Emulator

At first, I just downloaded the source from the Access website and modified/compiled it myself. I even created a patch! Another guy also do the same thing. But you have another good choice, you should just download the debian source form here, patch to the source of emulator and then goto the source directory run:

sudo apt-get install libfltk-dev fluid libxt-dev
debuild -us -uc -b

If you don't use debian/ubuntu, you have to patch the files in debian/patches/* and run:

cd BuildUnix
./configure
make
make install

It's done!

Windows

The new development suit GODS doesn't contain the SDK 6.x, you have to download it from some other mirror sites.

Download

You can download the PDOS 1.2 from this link or this link

Install

If the file you downloaded from internet is compressed, then you should un-compress it before installation. The installation is easy, just double click the .exe file.

The components of PODS v1.2:

  • Eclipse v.3.0.1
  • CDT v.2.0.2
  • Cygwin/PRC-Tools v.1.2
  • Palm OS Resource Editor v.6.2
  • Palm OS Debugger v.2.3.7
  • Palm OS Emulator v.4.1.2
  • Palm OS Simulator (Garnet v.5.4.0、Cobalt v.6.1.0)
  • Palm OS SDK (5r4、6.1)

Install by hand

The installation of the PODS 1.2 would deconstruct your Cygwin if you installed Cygwin in your system before. If you have already installed Eclipse and Cygwin, here's the settlement:

Install the PODS 1.2

Select the custom option. Select skiping the installation of cygwin.

Pack some dirs

After the completion of installation, pack some dirs from the PODS 1.2 main directory:

  • pods.eclipse.zip: pack these directories:
  eclipse\features\com.palmsource*
  eclipse\features\org.eclipse.cdt*
  eclipse\plugins\com.palmsource*
  eclipse\plugins\org.eclipse.cdt*
  • pods.tools.zip: pack this directory:
  PalmOSTools
  • pods.sdk.zip: pack these directories:
  sdk-5r4
  sdk-6.1

Uninstall the PODS 1.2

Now you may uninstall the PODS.

Install Eclipse

  • Backup your own Eclipse's CDT plugins. Move these directories to an backup directory:
  eclipse\features\org.eclipse.cdt*
  eclipse\plugins\org.eclipse.cdt*
  • Install the pods.eclipse.zip: extract thoes files to Eclipse's directory.

Install prc-tools

  • Before install prc-tools, you should install these packages:
_update-info-dir 00227-1
ash 20040127-1
base-files 2.6-1
base-passwd 1.1-1
bash 2.05b-16
binutils 20040312-1
bison 20030307-1
bzip2 1.0.2-5
ctags 5.5-4
cygutils 1.2.5-1
cygwin 1.5.10-3
cygwin-doc 1.3-7
diffutils 2.8.7-1
editrights 1.01-1
fileutils 4.1-2
findutils 4.1.7-4
flex 2.5.4a-3
gawk 3.1.3-4
gcc 3.3.1-3
gcc-g++ 3.3.1-3
gcc-mingw 20030911-4
gcc-mingw-core 20031020-1
gcc-mingw-g++ 20031020-1
gdb 20030919-1
gdbm 1.8.3-7
grep 2.5-1
groff 1.18.1-2
gzip 1.3.5-1
less 381-1
libbz2_0 1.0.2-1
libbz2_1 1.0.2-5
libgdbm 1.8.0-5
libgdbm-devel 1.8.3-7
libgdbm3 1.8.3-3
libgdbm4 1.8.3-7
libgettextpo0 0.12.1-3
libiconv2 1.9.1-3
libintl1 0.10.40-1
libintl2 0.12.1-3
libncurses5 5.2-1
libncurses6 5.2-8
libncurses7 5.3-4
libpcre 4.1-1
libpcre0 4.5-1
libpopt0 1.6.4-4
libreadline4 4.1-2
libreadline5 4.3-5
login 1.9-7
m4 1.4-1
make 3.80-1
man 1.5k-3
mingw-runtime 3.3-1
mktemp 1.5-3
ncurses 5.3-4
pcre 4.5-1
pcre-doc 4.5-1
pkgconfig 0.15.0-4
prc-tools 2.3
prc-tools-htmldocs 2.3
readline 4.3-5
sed 4.0.9-2
sh-utils 2.0.15-4
tar 1.13.25-5
tcltk 20030901-1
termcap 20021106-2
terminfo 5.3_20030726-1
texinfo 4.2-4
textutils 2.0.21-1
unzip 5.50-5
w32api 2.5-1
which 1.5-2
zip 2.3-6
zlib 1.2.1-1

The prc-tools in the list should be downloaded from this link. The other tools could be installed by the Cygwin's setup.exe utility.

palmdev-prep
  • Install the Palm OS Tools:

Unpack the package pods.tools.zip to PalmDev/PalmOSTools

  • Install the SDK

Unpack the package pods.sdk.zip to PalmDev/

Configuration

  • Add PalmOSTools to environment variable PATH
  • Edit all of the Eclipse config files, change the PATH to your PalmOSTools directory:
  eclipse\plugins\com.palmsource*\custom_content\default.prefs
  • Start the Eclipse. Click on the "Window" menu and select "Preference", open the "Palm OS Development", select "Target Enviroment Settings", change the setting for Emulator and Simulator. For example, the directory of the simulator.

Mac OS X

TODO

Compile

Linux/*nix

TODO

Windows

Command line

Before do any make, you should make sure the variables in wxwidgets_trunk\build\palmos\auto-generated.mk are set to the right values:

  TOOLS_DIR = C:/Program Files/PalmSource/Palm OS Developer Suite/PalmOSTools/
  SDK_LOCATION = C:/Program Files/PalmSource/Palm OS Developer Suite/sdk-6.1/

The simplest way to compile the wxPalm is, type those command under the command terminal in Windows:

  cd wxwidgets_trunk\build\palmos
  make depend
  make all

You can also edit a batch file to do that:

@echo off

if not "%MYFLGMK%" == "" goto end_flags
set MYFLGMK=1
PATH=c:\PalmOSCygwin\bin;%PATH%
:end_flags

if "%1" == "clean" goto end_dep
if "%1" == "distclean" goto end_dep
if "%1" == "cleandepend" goto end_dep
make -e TARGET_PLATFORM=Device .dependencies
:end_dep

make -e TARGET_PLATFORM=Device %1
make -e TARGET_PLATFORM=Simulator %1

Save this file as "makeall.bat" and type:

makeall.bat

At last, you can find the file wxWidgets.prc in the directory DebugSim. To install it, you may just drag the file to your Simulator window and drop by your mouse.

IDE (Eclipse)

  • Open Palm OS Developer Studio and click on File->Import.
  • Select "Existing Project into Workspace" as the import source and click Next.
  • On the next screen click the Browse button next to Project contents and select the folder you unpacked the source package into. Click on Finish to continue.
  • You should now see the project listed in the Project pane on the right side of the window. Click on the name of the project. Now click on the Project menu and select "Rebuild Project"
  • After the build is complete, click on the Run menu and select "" The Palm OS 6 simulator should start. If this is the first time you have used the simulator, you will be prompted to choose a ROM file. You can find the ROM files in a folder like "C:\Program Files\PalmSource\Palm OS Developer Suite\sdk-6\tools\Simulator\6.0.1\ROM" It doesn't really matter whether you choose a Release or a Debug ROM (the debug ROM generates extra reports when an application crashes.)
  • You should see the Palm logo appear in the simulator window. You may get a dialog box asking you to choose a language. Click OK to continue. You should see the simulator initialize the built-in Palm applications. After a few moments, the wxWidgets minimal sample should start.

Mac OS X

TODO

To-do

  • Base system API support, such as the file stream, wide-char functions.
  • UI class
  • Compile with SDK 5.x

Reference

Tools

  • prc-tools Palm OS programming with GCC.
  • Palm OS Emulator binary packages for Linux.
  • PDOS Palm OS Developer Suite
  • PilRC Palm Pilot resources Compiler.
  • piBuilder is a visual resource editor for PalmOS software developers who use PilRC for building application resources.
  • osx-palm-tools Mac OS X tools for Palm development

Lib

Doc

  • PalmFAQ You can find some useful information for the PalmOS
  • DllPort2Palm Port DLLs to Palm OS with ease
  • prc-tools 64bit Solution to prc-tools on AMD64 and other 64-bit machines.