Difference between revisions of "WinCE port"

From Free Pascal wiki
Jump to navigationJump to search
m (Move platform template to page template; remove category already in page template)
 
(80 intermediate revisions by 14 users not shown)
Line 1: Line 1:
 +
{{WinCE port}}
 +
 
WinCE port is quite complete and usable. The port was started and maintained by Yury Sidorov. Oliver (Oro06) ported WinCE API headers.
 
WinCE port is quite complete and usable. The port was started and maintained by Yury Sidorov. Oliver (Oro06) ported WinCE API headers.
  
 
== Status ==
 
== Status ==
* The 2.1.x compiler has compiler support for WinCE.
+
* FPC 2.2.0 or later supports WinCE target.
* [[ARM]] and i386 (old WinCE emulator) CPUs are supported.
+
* CPU support for WinCE target:
 +
** [[ARM]] CPU is fully supported. See [[arm-wince]] how to setup a crosscompiling enviroment.<br> There are readymade crosscompiler package available(See Lazarus download sources)
 +
** [[i386]] CPU support was not tested too much and may contain bugs. Patches are welcome.<br>Normally there is no readymade crosscompiler package for this CPU. See [[i386-wince]] howto setup a cross compile enviroment(Win32 Host)  
 
* The following platforms are supported:
 
* The following platforms are supported:
** Pocket PC 2002 – WinCE version: 3.0  
+
** Devices based on WinCE 3.0 or later
** Pocket PC 2003 – WinCE version: 4.20  
+
** Pocket PC 2002 – WinCE version: 3.0
** Pocket PC 2003 Second Edition – WinCE version: 4.21  
+
** Pocket PC 2003 – WinCE version: 4.20
* Base RTL units are complete.
+
** Pocket PC 2003 Second Edition – WinCE version: 4.21
* Windows unit is almost complete. Delphi compatible declarations is not ready.
+
** Windows Mobile 5 – WinCE version: 5.0
 +
** Windows Mobile 6 – WinCE version: 5.2
 +
** Windows Mobile 6.5 - WinCE version: 5.2.1
 +
* [http://community.freepascal.org:10000/docs-html/rtl RTL] and [http://community.freepascal.org:10000/docs-html/fcl FCL] units are working.
  
== Building Tutorial==
+
== Debugging WinCE applications ==
  
During the tutorial some paths will be suposed to demonstrate the build process. Just substitute those paths with the ones on your system.
+
GDB can be used to debug your WinCE applications remotely via ActiveSync. Download GDB 6.4 for Win32 host and arm-wince target here: ftp://ftp.freepascal.org/pub/fpc/contrib/cross/gdb-6.4-win32-arm-wince.zip
  
'''Step 1''' - Cross binutils
+
'''Some hints:'''
  
These are the basic tools necessary to create arm executables, such as: Linker, Assembler, Ar (Creates smartlinking .a files), make and strip.
+
* Pass <tt>--tui</tt> 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.
  
You need cross binutils for arm-wince, get them from  ftp://ftp.freepascal.org/pub/fpc/contrib/cross/arm-wince-binutils.zip for Win32.
+
'''How to use:'''
  
Extract them to some dir in the path on your machine.
+
First, make ActiveSync connection to your Pocket PC device.
  
We will supose that you extracted the cross binutils to: C:\Programas\arm
+
Then launch gdb:  
  
'''Step 2''' - The Compiler
+
<tt>gdb --tui <your_executable_at_local_pc></tt>
  
Free Pascal is able to compile itself, so we will need to have it installed. It is possible to compile the arm cross compiler with both Free Pascal 2.0.2 (latest stable build) or with a snapshot from the 2.1.x branch. We recomend a snapshot from the 2.1.x branch. You can get snapshots [http://www.de.freepascal.org/lazarus/ here].
+
On gdb prompt type:
  
You can get the 2.1 source repository from Subversion: http://www.freepascal.org/develop.html#svn
+
<tt>run</tt> or just <tt>r</tt>
  
We will supose that you are using the compiler available with the Lazarus Snapshot, because this is a good tool to test the upcoming Windows CE widgetset.
+
GDB will copy your executable to the device in <tt>\gdb</tt> folder and run it.
  
In this case we will supose that your compiler is located here: C:\Programas\lazarus13\pp\bin\i386-win32
+
Here is a short list of most needed GDB commands:
 +
* <tt>r args</tt> - run program with args arguments.
 +
* <tt>s</tt> - step into.
 +
* <tt>n</tt> - step over.
 +
* <tt>ni</tt> - step over instrument.step over assembly instruction.
 +
* <tt>c</tt> - continue execution.
 +
* <tt>br <function_name></tt> - set a breakpoint at <tt>function_name</tt>. Use <tt>PASCALMAIN</tt> to set a breakpoint at program start.
 +
* <tt>br <source_file>:<line_number></tt> - set a breakpoint at specified source line.
 +
* <tt>disas</tt> - show disassembly of current location.
 +
* <tt>x/fmt address</tt> - dump memory at address with special format.use "help x" for more informations.
 +
* <tt>bt</tt> - back trace.print back trace of the call stack.
 +
* <tt>where</tt> - Display the current line and function and the stack of calls that got you there.
 +
* <tt>q</tt> - Quit gdb.
 +
To learn more how to use GDB read its documentation here: http://www.gnu.org/software/gdb/documentation
  
And you Free Pascal source code is located here: C:\Programas\fpc21
 
  
'''Step 3''' - The Build process
 
  
In order to build the compiler it is necessary to have a correct PATH environment variable and a configured fpc.cfg file.
+
For example you want to build FCL. Go to <tt>fpc\fcl</tt> folder and execute the command above. You will get FCL compiled units in <tt>fpc\fcl\units\arm-wince</tt>.
  
Now you need to edit your fpc.cfg file to add information about the binutils. The file is located on the same directory as the compiler. In this case: C:\Programas\lazarus13\pp\bin\i386-win32\
+
== See Also ==
  
Add the following lines to it it´s end:
+
* [[WinCE_port_Hints|WinCE port hints]]
<pre>
+
* [http://wiki.lazarus.freepascal.org/Windows_CE_Interface Windows CE interface for Lazarus]
-FuC:\Programas\fpc21\rtl\units\$FPCTARGET
+
* [http://wiki.lazarus.freepascal.org/Windows_CE_Development_Notes Windows CE Development Notes]
-XParm-wince-
+
* [[KOL-CE|WinCE port of KOL GUI library]]
-FDC:\Programas\arm
 
</pre>
 
  
Remember to substitute the paths with the ones on your system
+
== Links ==
 +
* Useful WinCE info http://www.rainer-keuchel.de/documents.html
 +
* Standalone Pocket PC device emulator from Microsoft. It emulates ARM CPU. Get it [http://www.microsoft.com/downloads/details.aspx?FamilyId=C62D54A5-183A-4A1E-A7E2-CC500ED1F19A&displaylang=en here]
 +
* Mamaich Pocket PC port of GCC http://mamaich.uni.cc
 +
* [http://www.stack.nl/~marcov/buildfaq.pdf Buildfaq] is a general FAQ about how to build and configure FPC.
  
On Windows it is very easy to get a PATH crowded with information put by installers. To ensure that your path is correct, create a batch file with the following code:
+
Here are some links related to ARM CPU Architecture
  
<pre>
+
* [http://www.armcorepro.com/ ARM Core Developers Forum] Not that much active though.
PATH=C:\Programas\lazarus13\pp\bin\i386-win32;c:\Programas\arm
+
* [http://www.inf.u-szeged.hu/gcc-arm/ GCC ARM Improvement Project]
fpcmake -Tall
+
* [http://www.heyrick.co.uk/assembler/index.html ARM ASSEMBLER] Good information and codes related to arm assembly language.
make cycle CPU_TARGET=arm OS_TARGET=wince
+
* [http://www.gnuarm.com/ GNU ARM toolchain for Cygwin, Linux and MacOS]
</pre>
+
* [http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcechp40/html/ccrefarmguide.asp Microsoft Windows CE .NET 4.2 ARM Guide]
 +
* [http://soc.csie.ndhu.edu.tw/source/intro_embedded/ch2-arm-2.ppt ARM Instruction Sets & Programs] Very good and consice information about arm architecture
 +
* [http://web.njit.edu/~baltrush/arm_stuff/ARMInst.ppt The ARM Instruction Set ] Another fine power point file about arm
  
Put this file on C:\Programas\fpc\compiler , open the Windows command line, go to this directory and execute the batch file.
+
== Contacts ==
 
 
On the end of the compile it will give some errors:
 
 
 
<pre>
 
/cygdrive/c/Programas/arm/arm-wince-ld: unrecognised emulation mode: i386pe
 
Supported emulations: armpe
 
pp.pas(213,1) Error: Error while linking
 
make[1]: *** [ppc.exe] Error 1
 
make[1]: Leaving directory `C:/Programas/fpc21/compiler'
 
make: *** [cycle] Error 2
 
</pre>
 
 
 
This is not a problem! Just check that you have a ppccrossarm.exe in <fpcsrc>\compiler and some .o and .ppu files on <fpcstr>\rtl\units\arm-wince
 
 
 
If you have these files the process was successfull!
 
 
 
Now copy those files to your Free Pascal installation. The compiler should go to <fpc>\bin\i386-win32 and the units to <fpc>\units\arm-wince
 
 
 
== 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
 
 
 
You will need a Windows CE Emulator configured for ActiveSync. The ActiveSync is necessary to install PocketCMD, a command line tool to run our hello world software.
 
 
 
Download the free Pocket PC device emulator from Microsoft. It emulates ARM CPU. It is beta currently, but stable. http://msdn.microsoft.com/mobility/windowsmobile/downloads/emulatorpreview/default.aspx
 
 
 
There is a tutorial on how to set up the Emulator for ActiveSync [http://www.pocketpcfaq.com/faqs/5.0/emulator.htm here].
 
 
 
'''Step 2''' - Installing the command line
 
 
 
Download and install '''PocketCMD''' by SymbolicTools. Get it [http://www.symbolictools.de/public/pocketconsole/applications/PocketCMD here]
 
 
 
Check the "WinCE port notes" section bellow for more details on command lines on Pocket PC.
 
 
 
'''Step 3''' - Compiling
 
 
 
A example file to compile:
 
 
 
<pre>
 
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.
 
</pre>
 
 
 
Sample command line:
 
 
 
ppcrossarm.exe -Twince -FuC:\Programas\fpc21\rtl\units\a
 
rm-wince -FDC:\Programas\arm -XParm-wince- test.pas
 
 
 
[http://wiki.lazarus.freepascal.org/index.php/Windows_CE_Interface Here] is a screenshot of a software created this way.
 
 
 
== Documentation ==
 
 
 
=== WinCE port notes ===
 
* <tt>'''chdir'''</tt> procedure always produces an error (WinCE does not support setting of current directory).
 
* All file/dir paths must be absolute (started with \).
 
* WinCE is unicode OS. All string parameters to API calls must be PWideChar.
 
* WinCE does not have support for environment strings.
 
* WinCE 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 WinCE target by default. To create console application you should use <tt>-WC</tt> compiler switch or put <tt>{$APPTYPE CONSOLE}</tt> directive to source code.<br>To enable console in WinCE install one of the following programs:
 
** '''PocketCMD''' by SymbolicTools. It is recommended solution. Get it [http://www.symbolictools.de/public/pocketconsole/applications/PocketCMD here]
 
**'''PPC Command Shell''' from Microsoft Windows Mobile Developer Power Toys. Get it [http://www.microsoft.com/downloads/details.aspx?FamilyID=74473fd6-1dcc-47aa-ab28-6a2b006edfe9&displaylang=en here]<br>PPC Command Shell have less features than PocketCMD. Also it have some issues. One of them - a new console window is opened even if an application is started from a console command prompt.
 
 
 
== Links ==
 
* Useful WinCE info http://www.rainer-keuchel.de/documents.html
 
* Standalone Pocket PC device emulator from Microsoft. It emulates ARM CPU. It is beta currently, but stable. http://msdn.microsoft.com/mobility/windowsmobile/downloads/emulatorpreview/default.aspx
 
* Mamaich Pocket PC port of GCC http://mamaich.kasone.com/fr_pocket.htm
 
  
== Contacts ==
 
 
Write any questions regarding WinCE port to [mailto:yury_sidorov@mail.ru Yury Sidorov]
 
Write any questions regarding WinCE port to [mailto:yury_sidorov@mail.ru Yury Sidorov]

Latest revision as of 03:15, 9 August 2020

WinCE Logo.png

This article applies to Windows CE only.

See also: Multiplatform Programming Guide

English (en) italiano (it) português (pt) русский (ru) 中文(台灣)‎ (zh_TW)

WinCE port is quite complete and usable. The port was started and maintained by Yury Sidorov. Oliver (Oro06) ported WinCE API headers.

Status

  • FPC 2.2.0 or later supports WinCE target.
  • CPU support for WinCE target:
    • ARM CPU is fully supported. See arm-wince how to setup a crosscompiling enviroment.
      There are readymade crosscompiler package available(See Lazarus download sources)
    • i386 CPU support was not tested too much and may contain bugs. Patches are welcome.
      Normally there is no readymade crosscompiler package for this CPU. See i386-wince howto setup a cross compile enviroment(Win32 Host)
  • The following platforms are supported:
    • Devices based on WinCE 3.0 or later
    • Pocket PC 2002 – WinCE version: 3.0
    • Pocket PC 2003 – WinCE version: 4.20
    • Pocket PC 2003 Second Edition – WinCE version: 4.21
    • Windows Mobile 5 – WinCE version: 5.0
    • Windows Mobile 6 – WinCE version: 5.2
    • Windows Mobile 6.5 - WinCE version: 5.2.1
  • RTL and FCL units are working.

Debugging WinCE applications

GDB can be used to debug your WinCE applications remotely via ActiveSync. Download GDB 6.4 for Win32 host and arm-wince target here: ftp://ftp.freepascal.org/pub/fpc/contrib/cross/gdb-6.4-win32-arm-wince.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:

  • r args - run program with args arguments.
  • s - step into.
  • n - step over.
  • ni - step over instrument.step over assembly instruction.
  • 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.
  • disas - show disassembly of current location.
  • x/fmt address - dump memory at address with special format.use "help x" for more informations.
  • bt - back trace.print back trace of the call stack.
  • where - Display the current line and function and the stack of calls that got you there.
  • q - Quit gdb.

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


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-wince.

See Also

Links

Here are some links related to ARM CPU Architecture

Contacts

Write any questions regarding WinCE port to Yury Sidorov