Difference between revisions of "WinCE port/pt"
Line 42: | Line 42: | ||
− | ''' | + | '''Passo 3''' - O Processo de Construção |
− | |||
− | |||
− | |||
+ | Para construir o cross-compilador é necessário ter uma variável de ambiente <tt>PATH</tt> correta. No Windows é muito fácil ter um <tt>PATH</tt> junto com a informação colocada pelos instaladores. Para se certificar de que o seu Path está correto, crie um arquivo de lote do DOS com o seguinte código: | ||
<pre> | <pre> | ||
PATH=C:\Programas\fpc\bin\i386-win32;C:\Programas\arm | PATH=C:\Programas\fpc\bin\i386-win32;C:\Programas\arm | ||
Line 52: | Line 50: | ||
</pre> | </pre> | ||
− | + | Ponha este arqquivo em <tt>C:\Programas\fpc\compiler</tt>, abra a linha de comando do Windows, vá para esta pasta e execute o arquivo de lote. | |
− | + | No fim da compilação você não deve ter mensagens de erro. | |
You should have a <tt>ppccrossarm.exe</tt> in <tt>C:\Programas\fpc\compiler</tt> and some <tt>.o</tt> and <tt>.ppu</tt> files in <tt>C:\Programas\fpc\rtl\units\arm-wince</tt> | You should have a <tt>ppccrossarm.exe</tt> in <tt>C:\Programas\fpc\compiler</tt> and some <tt>.o</tt> and <tt>.ppu</tt> files in <tt>C:\Programas\fpc\rtl\units\arm-wince</tt> |
Revision as of 20:39, 21 April 2007
This article applies to Windows CE only.
See also: Multiplatform Programming Guide
│
English (en) │
italiano (it) │
português (pt) │
русский (ru) │
中文(台灣) (zh_TW) │
O porte do WinCE é bem completo e utilizável. Ele foi iniciado e é mantido por Yury Sidorov. Oliver (Oro06) cabeçalhos portados da WinCE API.
Estado atual
- O compilador 2.1.x dá suporte à compilação para WinCE.
- ARM CPU tem suporte.
- As seguintes plataformas têm suporte:
- Pocket PC 2002 – WinCE versão 3.0
- Pocket PC 2003 – WinCE versão 4.20
- Pocket PC 2003 Segunda Edição – WinCE versão 4.21
- Windows Mobile 5.0 – WinCE versão 5.0
- RTL e unidades FCL estão funcionando.
Construindo o Tutorial
Durante o tutorial alguns caminhos serão supostos para demonstrar o processo de contrução. Apenas substitua aqueles caminhos pelos do seu sistema.
Passo 1 - Binutils para cross-compilação:
Estas são as ferramentas básicas necessárias para criar executáveis, como: Vinculador (ld), Montador (as), Archiver (ar) (cria arquivos .a do smartlinking), strip e algumas outras.
Você precisa das binutils para cross-compilação para ARM-WinCE, pegue-os em ftp://ftp.freepascal.org/pub/fpc/contrib/cross/arm-wince-binutils.zip for Win32.
Extraia-os em algum diretório no caminho da sua máquina. Vamos supor que você os extraiu em: C:\Programas\arm
Passo 2 - Cross-compilador
Agora você precisa construir o cross-compilador FPC para o processador ARM. Para fazer isso você precisa dos fontes mais recentes do FPC 2.1.x e a instalação do FPC 2.0.4 funcionando para Win32.
Pegue os fontes mais recentes do repositório do 2.1.x no Subversion: http://www.freepascal.org/develop.html#svn
Vamos supor que o seu ompilador FPC para Win32 está localizado em: C:\Programas\fpc\bin\i386-win32
E os seus fontes do Free Pascal 2.1.x estão localizados em: C:\Programas\fpc
Passo 3 - O Processo de Construção
Para construir o cross-compilador é necessário ter uma variável de ambiente PATH correta. No Windows é muito fácil ter um PATH junto com a informação colocada pelos instaladores. Para se certificar de que o seu Path está correto, crie um arquivo de lote do DOS com o seguinte código:
PATH=C:\Programas\fpc\bin\i386-win32;C:\Programas\arm make cycle CPU_TARGET=arm OS_TARGET=wince
Ponha este arqquivo em C:\Programas\fpc\compiler, abra a linha de comando do Windows, vá para esta pasta e execute o arquivo de lote.
No fim da compilação você não deve ter mensagens de erro.
You should have a ppccrossarm.exe in C:\Programas\fpc\compiler and some .o and .ppu files in C:\Programas\fpc\rtl\units\arm-wince
Now copy those files to your Free Pascal installation. The cross compiler ppccrossarm.exe should go to C:\Programas\fpc\bin\arm-wince and the units to C:\Programas\fpc\units\arm-wince
Step 4 - Configuration file
Now you need to create fpc.cfg configuration file in C:\Programas\fpc\bin\arm-wince folder in order to use ppccrossarm.exe easy.
Create empty fpc.cfg file in C:\Programas\fpc\bin\arm-wince folder and add the following lines to it:
-Twince -FuC:\Programas\fpc\units\arm-wince -XParm-wince- -FDC:\Programas\arm
Finally add C:\Programas\fpc\bin\arm-wince 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
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. http://msdn.microsoft.com/mobility/downloads/Emulator/default.aspx
There is a tutorial on how to set up the Emulator for ActiveSync here.
Step 2 - Installing the command line
Download and install PocketCMD by SymbolicTools. Get it 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:
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 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
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=wince 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-wince.
Documentation
some WinCE notes
- If you are getting "Uknown error! Error code : 0xc1" and using dlls then the error might be becouse of using some export entries not found in dll file.Check the dll file export section and name of them and how you used them.
WinCE port notes
- chdir 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 -WC compiler switch or put {$APPTYPE CONSOLE} directive to source code.
To enable console in WinCE install one of the following programs:- PocketCMD by SymbolicTools. It is recommended solution. Get it here
- PPC Command Shell from Microsoft Windows Mobile Developer Power Toys. Get it here
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.
See Also
Links
- Useful WinCE info http://www.rainer-keuchel.de/documents.html
- Standalone Pocket PC device emulator from Microsoft. It emulates ARM CPU. Get it here
- KOL-CE. WinCE port of KOL GUI library. http://sourceforge.net/projects/kol-ce/
- Mamaich Pocket PC port of GCC http://mamaich.uni.cc
- Buildfaq is a general FAQ about how to build and configure FPC.
Here are some links related to ARM CPU Architecture
- ARM Core Developers Forum Not that much active though.
- GCC ARM Improvement Project
- ARM ASSEMBLER Good information and codes related to arm assembly language.
- GNU ARM toolchain for Cygwin, Linux and MacOS
- Microsoft Windows CE .NET 4.2 ARM Guide
- ARM Instruction Sets & Programs Very good and consice information about arm architecture
- The ARM Instruction Set Another fine power point file about arm
Contacts
Write any questions regarding WinCE port to Yury Sidorov