Difference between revisions of "PalmOS port"

From Lazarus wiki
(Building Tutorial)
Line 52: Line 52:
 
'''Step 4''' - Configuration file
 
'''Step 4''' - Configuration file
  
Now you need to create <tt>fpc.cfg</tt> configuration file in <tt>C:\Programas\fpc\bin\arm-PalmOs</tt> folder in order to use <tt>ppccrossarm.exe</tt> easy.
+
Now you need to edit your FPC configuration file <tt>${HOME}/.fpc.cfg</tt> in order to use <tt>ppccrossarm.exe</tt> easy and add the following lines to it:
 
 
Create empty <tt>fpc.cfg</tt> file in <tt>C:\Programas\fpc\bin\arm-PalmOs</tt> folder and add the following lines to it:
 
 
<pre>
 
<pre>
-TPalmOs
+
#IFDEF FPC_CROSSCOMPILING
-FuC:\Programas\fpc\units\arm-PalmOs
+
-Tpalmos
-XParm-PalmOs-
+
-Fu${FPC_SRC}/rtl/units/arm-palmos
-FDC:\Programas\arm
+
-XParm-palmos-
 +
#ENDIF
 
</pre>
 
</pre>
  

Revision as of 16:51, 31 May 2006

PalmOs port is in its early beginning stage. The port is started and will be maintained by Mazen Neifer. Peter Vreman ported PalmOs API headers.

Status

  • The 2.1.x compiler has compiler support (very experimental) for PalmOs.
  • ARM CPU is supported.
  • The following platforms will be supported:
    • Zire72 – PalmOs version: 3.0
  • Base RTL units are not yet ported.

Building Tutorial

During the tutorial some paths will be supposed to demonstrate the build process. Just substitute those paths with the ones on your system.


Step 1 - Cross binutils

These are the basic tools necessary to create executables, such as:

  • arm-palmos-ld : Linker
  • arm-palmos-as : Assembler
  • arm-palmos-ar : Archiver (Creates smartlinking .a files)
  • arm-palmos-strip and some others.

You need cross binutils for arm-palmos, debian linux (sid) provides a ready to use package prc-tools-utils. Just "apt-get install prc-tools-utils" will do the job. Otherwise, you need to get them from http://www.palmos.com/dev/dl/dl_tools/.

Extract them to some dir in the path on your machine. In a debian machine these are installed to /usr/bin/arm-palmos-*


Step 2 - Cross compiler

We will suppose that your are using debian linux installation (sid) and fpc compiler is already installed and correctly configured. Under debian linux (sid) you may install the fp-compiler package ("apt-get install fp-compiler")

Now you need to build fpc cross compiler for ARM processor. To do that you need latest fpc 2.1.x sources in addition to your working installation of fpc 2.0.2 or 2.0 already mentioned. Get the latest 2.1.x source repository from Subversion: http://www.freepascal.org/develop.html#svn

We will suppose your Free Pascal 2.1.x source code is located here: ${FPC_SRC}


Step 3 - The Build process

In order to build the cross compiler it is necessary to have a correct PATH environment variable. Please ensure that your path is correct:

make cycle PATH="/bin:/usr/bin:/usr/bin/X11:/usr/local/bin" CPU_TARGET=arm OS_TARGET=palmos

On the end of the compile you should not see any errors.

You should have a ppccrossarm in ${FPC_SRC}/compiler and some .o and .ppu files in ${FPC_SRC}/rtl/units/arm-palmos

Now copy those files to your Free Pascal installation. The cross compiler ppccrossarm should go to /usr/local/bin/arm-palmos and the units to /usr/local/lib/fpc/units/arm-palmos


Step 4 - Configuration file

Now you need to edit your FPC configuration file ${HOME}/.fpc.cfg in order to use ppccrossarm.exe easy and add the following lines to it:

#IFDEF FPC_CROSSCOMPILING
-Tpalmos
-Fu${FPC_SRC}/rtl/units/arm-palmos
-XParm-palmos-
#ENDIF

Finally add C:\Programas\fpc\bin\arm-PalmOs and C:\Programas\fpc\bin\i386-win32 to your PATH environment variable.

Remember to substitute the paths with the ones on your system.

Compiling a Test Project

You compiled the compiler! Now, what can I do with it? This is a tutorial to create a hello world like software with your new compiler.

Step 1 - Installing and Configuring the Emulator

??

Step 2 - Installing the command line

??

Step 3 - Compiling

A example file to compile:

program test;

{$apptype console}

var
  Str: string;
begin
  WriteLn('Software Developed with:');
  WriteLn('The Free Pascal Compiler');
  WriteLn('');
  WriteLn('Please, enter your name:');
  ReadLn(Str);
  WriteLn('Your name is: ' + Str);
end.

Sample command line to compile test.pas:

ppcrossarm test.pas

You will get test.exe executable file. Copy it to your Windows CE device and run.

Here is a screenshot of a software created this way.

Debugging PalmOs applications

GDB can be used to debug your PalmOs applications remotely via ActiveSync. Download GDB 6.4 for Win32 host and arm-PalmOs target here: ftp://ftp.freepascal.org/pub/fpc/contrib/cross/gdb-6.4-win32-arm-PalmOs.zip

Some hints:

  • Pass --tui parameter to GDB to enable TUI interface which makes debugging more comfortable.
  • Use unix line endings (LF only) in your pascal source files. Otherwise GDB will show sources incorrctly.

How to use:

First, make ActiveSync connection to your Pocket PC device.

Then launch gdb:

gdb --tui <your_executable_at_local_pc>

On gdb prompt type:

run or just r

GDB will copy your executable to the device in \gdb folder and run it.

Here is a short list of most needed GDB commands:

  • s - step into.
  • n - step over.
  • c - continue execution.
  • br <function_name> - set a breakpoint at function_name. Use PASCALMAIN to set a breakpoint at program start.
  • br <source_file>:<line_number> - set a breakpoint at specified source line.

To learn more how to use GDB read its documentation here: http://www.gnu.org/software/gdb/documentation

Building FPC libraries

If you want to build libraries available with FPC just go to library folder and execute:

PATH=C:\Programas\fpc\bin\i386-win32;C:\Programas\fpc\compiler;C:\Programas\arm
make OS_TARGET=PalmOs CPU_TARGET=arm PP=ppcrossarm.exe

For example you want to build FCL. Go to fpc\fcl folder and execute the command above. You will get FCL compiled units in fpc\fcl\units\arm-PalmOs.

Documentation

PalmOs port notes

  • chdir procedure always produces an error (PalmOs does not support setting of current directory).
  • All file/dir paths must be absolute (started with \).
  • PalmOs is unicode OS. All string parameters to API calls must be PWideChar.
  • PalmOs does not have support for environment strings.
  • PalmOs does not have support for console applications by default. But you can install console support by yourself. Please note that FPC creates GUI applications for PalmOs target by default. To create console application you should use -WC compiler switch or put {$APPTYPE CONSOLE} directive to source code.
    To enable console in PalmOs install one of the following programs:

Links

  • Buildfaq is a general FAQ about how to build and configure FPC.

Here are some links related to ARM CPU Architecture

Contacts