Sign in Join
Wiki copytemporary

WinCE port/ru: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11Портирование на WinCE вполне выполнимо. Начат и закреплён сей процесс был Юрием Сидоровым. Oliver (Oro06) портировал заголовочные файлы WinCE API.
22
33## Статус
44
55- FPC 2.2.0 или позже поддерживает целевую платформу WinCE.
66- Процессоры: платформы WinCE:
77 - [[ARM]] поддерживается.
88 - [[i386]] Поддержка недостаточно протестирована и содержит ошибки. Исправления приветствуются.
99- Поддерживаются следующие версии WinCE:
1010 - Устройства на WinCE 3.0 или позднее
1111 - Pocket PC 2002 – версия WinCE: 3.0
1212 - Pocket PC 2003 – версия WinCE: 4.20
1313 - Pocket PC 2003 Second Edition – версия WinCE: 4.21
1414 - Windows Mobile 5 – версия WinCE : 5.0
1515 - Windows Mobile 6 – версия WinCE : 5.2
1616 - Windows Mobile 6.5 - версия WinCE : 5.2.1
1717- юниты [RTL](http://community.freepascal.org:10000/docs-html/rtl) и [FCL](http://community.freepascal.org:10000/docs-html/fcl) работают.
1818
1919## Скачать кроссплатформенный компилятор
2020
2121Наиболее лёгкий способ начать разрабатывать для WinCE - загрузить свежую версию FPC под Win32 и arm-wince cross compiler for Win32.
2222
2323Скачать можно тут: <http://www.freepascal.org/download.var>
2424
2525Сначала установите FPC for Win32, затем установите arm-wince cross compiler как add-on пакет.
2626
2727Если же нужен ещё и лазарус, то качайте вот отсюда оба: <http://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2032%20bits/Lazarus%200.9.28.2/>
2828
2929Установите оба в одну папку, сначала win32 потом cross-compiler.
3030
3131## Сборка WinCE cross compiler из исходников
3232
3333During the tutorial some paths will be suposed to demonstrate the build process. Just substitute those paths with the ones on your system.
3434
3535This tutorial demonstrates how to build **arm-wince** crosscompiler. **i386-wince** crosscompiler can be build similar way. Just substitute **arm** to **i386**. Also binutils are not needed for i386-wince target.
3636
3737**Step 1** - Cross binutils
3838
3939These are the basic tools necessary to create executables, such as: Linker (ld), Assembler (as), Archiver (ar) (Creates smartlinking .a files), strip and some others.
4040
4141You need cross binutils for arm-wince, get them from <ftp://ftp.freepascal.org/pub/fpc/contrib/cross/arm-wince-binutils.zip> for Win32.
4242
4343Extract them to some dir in the path on your machine. We will supose that you extracted the cross binutils to: `C:\Programas\arm`
4444
4545**Step 2** - Cross compiler
4646
4747Now you need to build fpc cross compiler for ARM processor. To do that you need fpc 2.2.0 or later sources and working installation of fpc 2.2.0 for Win32.
4848
4949You can get the latest fpc source repository from Subversion: <http://www.freepascal.org/develop.html#svn>
5050
5151We will supose that your Win32 fpc compiler is located here: `C:\Programas\fpc\bin\i386-win32`
5252
5353And your Free Pascal source code is located here: `C:\Programas\fpc`
5454
5555**Step 3** - The Build process
5656
5757In order to build the cross compiler it is necessary to have a correct `PATH` environment variable. 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:
5858
5959 PATH=C:\Programas\fpc\bin\i386-win32;C:\Programas\arm
6060 make cycle CPU_TARGET=arm OS_TARGET=wince
6161
6262Put this file on `C:\Programas\fpc\compiler`, open the Windows command line, go to this folder and execute the batch file.
6363
6464On the end of the compile you should not see any errors.
6565
6666You should have a `ppccrossarm.exe` in `C:\Programas\fpc\compiler` and some `.o` and `.ppu` files in `C:\Programas\fpc\rtl\units\arm-wince`
6767
6868Now 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`
6969
7070**Step 4** - Configuration file
7171
7272Now you need to create `fpc.cfg` configuration file in `C:\Programas\fpc\bin\arm-wince` folder in order to use `ppccrossarm.exe` easy.
7373
7474Create empty `fpc.cfg` file in `C:\Programas\fpc\bin\arm-wince` folder and add the following lines to it:
7575
7676 -Twince
7777 -FuC:\Programas\fpc\units\arm-wince
7878 -XParm-wince-
7979 -FDC:\Programas\arm
8080
8181Finally add `C:\Programas\fpc\bin\arm-wince` and `C:\Programas\fpc\bin\i386-win32` to your `PATH` environment variable.
8282
8383**Remember to substitute the paths with the ones on your system.**
8484
8585**Alternative Step 4** - Configuration file for hybrid compilation
8686
8787If you want to compile your projects with the same "fpc" for both win32 and winCE platforms, you can do the following:
8888
8989- copy ppcrossarm.exe into your fpc/bin/i386-win32 directory
9090- edit your fpc.cfg in that directory and add:
9191
9292 -FuC:\path_to_fpc\units\arm-wince
9393 -XParm-wince-
9494 -FDC:\path_to_arm_binutils
9595
9696**Remember to substitute the paths with the ones on your system.**
9797
9898Now when you want to compile for WinCE you just have to specify the OS and Arch targets to fpc.
9999
100100NOTE: if you use Lazarus this will work flawlessly, but make sure to point lazarus to "fpc.exe" not "ppc386.exe".
101101
102102## Компиляция тестового проекта
103103
104104У меня есть компилятор! Что я могу делать теперь? Дальше следует инструкция по созданию программы hello world.
105105
106106**Шаг 1** - Установкаи настройка эмулятора
107107
108108Вам понадобится Windows CE Emulator сконфигурированный с ActiveSync. The ActiveSync is necessary to install PocketCMD, a command line tool to run our hello world software.
109109
110110Download the free Pocket PC device emulator from Microsoft. It emulates ARM CPU. <http://msdn.microsoft.com/mobility/downloads/Emulator/default.aspx>
111111
112112There is a tutorial on how to set up the Emulator for ActiveSync [here](http://www.pocketpcfaq.com/faqs/5.0/emulator.htm).
113113
114114**Step 2** - Installing the command line
115115
116116Download and install **PocketCMD** by SymbolicTools. Get it [here](http://www.symbolictools.de/public/pocketconsole/applications/PocketCMD) (this site seems to be gone) but try here [1](http://www.mobile2day.de/platform_wince/device/CASIO/Cassiopeia+E-115/download.html?file=c112516.exe&prod=14571)
117117
118118To enable the console on newer devices (I needed it in my 6.1CE pro), you may to set the following registry value [link](http://forum.xda-developers.com/showthread.php?t=275019&highlight=console)
119119
120-`HKEY_LOCAL_MACHINE\Drivers\Console\OutputTo -> 0`
120+```text
121+HKEY_LOCAL_MACHINE\Drivers\Console\OutputTo -> 0
122+```
121123
122124Check the WinCE port notes section bellow for more details on command lines on Pocket PC.
123125
124126**Step 3** - Compiling
125127
126128A example file to compile:
127129
128130 program test;
129131
130132 {$apptype console}
131133
132134 var
133135 Str: string;
134136 begin
135137 WriteLn('Software Developed with:');
136138 WriteLn('The Free Pascal Compiler');
137139 WriteLn('');
138140 WriteLn('Please, enter your name:');
139141 ReadLn(Str);
140142 WriteLn('Your name is: ' + Str);
141143 end.
142144
143145Sample command line to compile `test.pas`:
144146
145147`ppcrossarm test.pas`
146148
147149You will get `test.exe` executable file. Copy it to your Windows CE device and run.
148150
149151[Here](http://wiki.lazarus.freepascal.org/index.php/Windows_CE_Interface#Screenshots) is a screenshot of a software created this way.
150152
151153## Debugging WinCE applications
152154
153155GDB 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>
154156
155157**Some hints:**
156158
157159- Pass `--tui` parameter to GDB to enable TUI interface which makes debugging more comfortable.
158160- Use unix line endings (LF only) in your pascal source files. Otherwise GDB will show sources incorrctly.
159161
160162**How to use:**
161163
162164First, make ActiveSync connection to your Pocket PC device.
163165
164166Then launch gdb:
165167
166168`gdb --tui <your_executable_at_local_pc>`
167169
168170On gdb prompt type:
169171
170172`run` or just `r`
171173
172174GDB will copy your executable to the device in `\gdb` folder and run it.
173175
174176Here is a short list of most needed GDB commands:
175177
176178- `r args` - run program with args arguments.
177179- `s` - step into.
178180- `n` - step over.
179181- `ni` - step over instrument.step over assembly instruction.
180182- `c` - continue execution.
181183- `br <function_name>` - set a breakpoint at `function_name`. Use `PASCALMAIN` to set a breakpoint at program start.
182184- `br <source_file>:<line_number>` - set a breakpoint at specified source line.
183185- `disas` - show disassembly of current location.
184186- `x/fmt address` - dump memory at address with special format.use "help x" for more informations.
185187- `bt` - back trace.print back trace of the call stack.
186188- `where` - Display the current line and function and the stack of calls that got you there.
187189- `q` - Quit gdb.
188190
189191To learn more how to use GDB read its documentation here: <http://www.gnu.org/software/gdb/documentation>
190192
191193## Building FPC libraries
192194
193195If you want to build libraries available with FPC just go to library folder and execute:
194196
195197 PATH=C:\Programas\fpc\bin\i386-win32;C:\Programas\fpc\compiler;C:\Programas\arm
196198 make OS_TARGET=wince CPU_TARGET=arm PP=ppcrossarm.exe
197199
198200For 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`.
199201
200202## Documentation
201203
202204### some WinCE notes
203205
204206- 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.
205207
206208### WinCE port notes
207209
208210- **`chdir`** procedure always produces an error (WinCE does not support setting of current directory).
209211- All file/dir paths must be absolute (started with \\).
210212- WinCE is unicode OS. All string parameters to API calls must be PWideChar.
211213- WinCE does not have support for environment strings.
212214- 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.\
213215 To enable console in WinCE install one of the following programs:
214216 - **PocketCMD** by SymbolicTools. It is recommended solution. Get it [here](http://www.symbolictools.de/public/pocketconsole/applications/PocketCMD)
215217 - **PPC Command Shell** from Microsoft Windows Mobile Developer Power Toys. Get it [here](http://www.microsoft.com/downloads/details.aspx?FamilyID=74473fd6-1dcc-47aa-ab28-6a2b006edfe9&displaylang=en)\
216218 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.
217219 - To enable console output in Windows Mobile 5 and 6 set "HKEY_LOCAL_MACHINE\Drivers\Console\OutputTo" to 0.
218220
219221## See Also
220222
221223- [[Tested Unstable Revisions]]
222224- [Windows CE interface for Lazarus](http://wiki.lazarus.freepascal.org/Windows_CE_Interface)
223225- [Windows CE Development Notes](http://wiki.lazarus.freepascal.org/Windows_CE_Development_Notes)
224226- [Приложения WinCE с исползованием KOL](http://wiki.lazarus.freepascal.org/KOL-CE/ru)
225227
226228## Links
227229
228230- Useful WinCE info <http://www.rainer-keuchel.de/documents.html>
229231- Standalone Pocket PC device emulator from Microsoft. It emulates ARM CPU. Get it [here](http://www.microsoft.com/downloads/details.aspx?FamilyId=C62D54A5-183A-4A1E-A7E2-CC500ED1F19A&displaylang=en)
230232- Mamaich Pocket PC port of GCC <http://mamaich.uni.cc>
231233- [Buildfaq](http://www.stack.nl/~marcov/buildfaq.pdf) is a general FAQ about how to build and configure FPC.
232234
233235Here are some links related to ARM CPU Architecture
234236
235237- [ARM Core Developers Forum](http://www.armcorepro.com/) Not that much active though.
236238- [GCC ARM Improvement Project](http://www.inf.u-szeged.hu/gcc-arm/)
237239- [ARM ASSEMBLER](http://www.heyrick.co.uk/assembler/index.html) Good information and codes related to arm assembly language.
238240- [GNU ARM toolchain for Cygwin, Linux and MacOS](http://www.gnuarm.com/)
239241- [Microsoft Windows CE .NET 4.2 ARM Guide](http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcechp40/html/ccrefarmguide.asp)
240242- [ARM Instruction Sets & Programs](http://soc.csie.ndhu.edu.tw/source/intro_embedded/ch2-arm-2.ppt) Very good and consice information about arm architecture
241243- [The ARM Instruction Set](http://web.njit.edu/~baltrush/arm_stuff/ARMInst.ppt) Another fine power point file about arm
242244
243245## Contacts
244246
245247Write any questions regarding WinCE port to [Yury Sidorov](mailto:yury_sidorov@mail.ru)
246248
247249---
248250*From the Free Pascal wiki, page "WinCE port/ru", as it stood on 2015-05-14 after a change by FTurtle, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
249251Category: Russian
250252Category: WinCE/ru

Back to history