arm-wince: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: arm-wince
| Old | New | Line | |
|---|---|---|---|
| 1 | + | *(WinCE only)* | |
| 2 | + | ||
| 3 | + | This page describes setup of a crosscompiling environment (host is Win32),. | |
| 4 | + | ||
| 5 | + | ## The easy way: download the cross compiler | |
| 6 | + | ||
| 7 | + | The easiest way to start development for WinCE is to download the latest release version of FPC for Win32 and arm-wince cross compiler for Win32. | |
| 8 | + | ||
| 9 | + | Download them here: <http://www.freepascal.org/download.var> | |
| 10 | + | ||
| 11 | + | First install FPC for Win32, then install arm-wince cross compiler as add-on package. | |
| 12 | + | ||
| 13 | + | ## The hard way: building WinCE cross compiler from sources | |
| 14 | + | ||
| 15 | + | This tutorial demonstrates how to build the **arm-wince** crosscompiler on Windows which allows you to compile Windows CE programs from your Windows desktop. | |
| 16 | + | ||
| 17 | + | > **Note:** During the tutorial some paths will be used to demonstrate the build process. Just substitute those paths with the ones on your system. | |
| 18 | + | ||
| 19 | + | We will suppose that: | |
| 20 | + | ||
| 21 | + | - your FPC compiler is located here: `c:\fpc\bin\i386-win32\fpc.exe` | |
| 22 | + | - your Free Pascal source code is located here: `c:\fpc` | |
| 23 | + | ||
| 24 | + | ### Step 1: Cross binutils | |
| 25 | + | ||
| 26 | + | Binutils are the basic tools necessary to create executables, such as: linker (ld), assembler (as), archiver (ar), strip and some others. | |
| 27 | + | ||
| 28 | + | You need cross binutils for arm-wince (i.e. they run on your desktop but produce output suitable for arm-wince). Get them from <ftp://ftp.freepascal.org/pub/fpc/contrib/cross/arm-wince-binutils.zip>. | |
| 29 | + | ||
| 30 | + | Extract them to some dir in the path on your machine. We will suppose that you extracted the cross binutils to: `C:\cross\arm` | |
| 31 | + | ||
| 32 | + | ### Step 2: Building the cross compiler | |
| 33 | + | ||
| 34 | + | Now you need to build the FPC cross compiler for the ARM processor. To do that, you need: | |
| 35 | + | ||
| 36 | + | - FPC sources | |
| 37 | + | - a working installation of FPC | |
| 38 | + | - the cross binutils mentioned above | |
| 39 | + | ||
| 40 | + | You can get the latest FPC source repository from Subversion: <http://www.freepascal.org/develop.html#svn> | |
| 41 | + | ||
| 42 | + | In 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 called `c:\fpc\compiler\create_cross_arm_wince.cmd` with the following code: | |
| 43 | + | ||
| 44 | + | ```dos | |
| 45 | + | PATH=c:\fpc\bin\i386-win32;C:\cross\arm | |
| 46 | + | make cycle CPU_TARGET=arm OS_TARGET=wince | |
| 47 | + | ``` | |
| 48 | + | ||
| 49 | + | Now open the Windows command line, and run the batch file: | |
| 50 | + | ||
| 51 | + | ```dos | |
| 52 | + | cd /d c:\fpc\compiler | |
| 53 | + | create_cross_arm_wince.cmd | |
| 54 | + | ``` | |
| 55 | + | ||
| 56 | + | The compile should run without any errors. | |
| 57 | + | ||
| 58 | + | You should now have a `ppccrossarm.exe` in `c:\fpc\compiler` and some `.o` and `.ppu` files in `c:\fpc\rtl\units\arm-wince` | |
| 59 | + | ||
| 60 | + | Now copy those files to your Free Pascal installation. | |
| 61 | + | ||
| 62 | + | - Copy the cross compiler `ppccrossarm.exe` to `c:\fpc\bin\i386-win32\` | |
| 63 | + | - Copy the units in `c:\fpc\rtl\units\arm-wince` to `c:\fpc\units\arm-wince` | |
| 64 | + | ||
| 65 | + | ### Step 3: Configuration file | |
| 66 | + | ||
| 67 | + | Now you need to edit your FPC configuration file in `c:\fpc\bin\i386-win32\fpc.cfg` in order to use `ppccrossarm.exe` easily. | |
| 68 | + | ||
| 69 | + | #IFDEF CPUARM | |
| 70 | + | #IFDEF WINCE | |
| 71 | + | # Settings specific to cross compilation to wince on ARM. | |
| 72 | + | -FuC:\fpc\units\arm-wince | |
| 73 | + | -XParm-wince- | |
| 74 | + | -FDC:\cross\arm | |
| 75 | + | #ENDIF | |
| 76 | + | #ENDIF | |
| 77 | + | ||
| 78 | + | Now when you want to compile for WinCE you just have to specify the OS and Arch targets to FPC or Lazarus: | |
| 79 | + | ||
| 80 | + | ```DOS | |
| 81 | + | fpc -Twince -Parm yourfile.pas | |
| 82 | + | ``` | |
| 83 | + | ||
| 84 | + | > **Note:** When using Lazarus, make sure the compiler path/file in Lazarus options is set to "fpc.exe", not "ppc386.exe" | |
| 85 | + | ||
| 86 | + | ## Building FPC libraries | |
| 87 | + | ||
| 88 | + | If you want to build libraries available with FPC just go to the library folder and execute: | |
| 89 | + | ||
| 90 | + | ``` bash | |
| 91 | + | PATH=c:\fpc\bin\i386-win32;c:\fpc\compiler;C:\cross\arm | |
| 92 | + | make OS_TARGET=wince CPU_TARGET=arm PP=ppcrossarm.exe | |
| 93 | + | ``` | |
| 94 | + | ||
| 95 | + | ## Compiling a Test Project | |
| 96 | + | ||
| 97 | + | 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. | |
| 98 | + | ||
| 99 | + | ### Step 1: Installing and Configuring the Emulator | |
| 100 | + | ||
| 101 | + | 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. | |
| 102 | + | ||
| 103 | + | Download the free Pocket PC device emulator from Microsoft. It emulates ARM CPU. <http://msdn.microsoft.com/mobility/downloads/Emulator/default.aspx> | |
| 104 | + | ||
| 105 | + | There is a tutorial on how to set up the Emulator for ActiveSync [here](http://www.pocketpcfaq.com/faqs/5.0/emulator.htm). | |
| 106 | + | ||
| 107 | + | ### Step 2: Installing the command line | |
| 108 | + | ||
| 109 | + | Download 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) | |
| 110 | + | ||
| 111 | + | To 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) | |
| 112 | + | ||
| 113 | + | `HKEY_LOCAL_MACHINE\Drivers\Console\OutputTo -> 0` | |
| 114 | + | ||
| 115 | + | Check [[WinCE port Hints]] for more details on programming under Windows CE platform. | |
| 116 | + | ||
| 117 | + | ### Step 3: Compiling | |
| 118 | + | ||
| 119 | + | An example file to compile: | |
| 120 | + | ||
| 121 | + | ``` pascal | |
| 122 | + | program test; | |
| 123 | + | ||
| 124 | + | {$apptype console} | |
| 125 | + | ||
| 126 | + | var | |
| 127 | + | Str: string; | |
| 128 | + | begin | |
| 129 | + | WriteLn('Software Developed with:'); | |
| 130 | + | WriteLn('The Free Pascal Compiler'); | |
| 131 | + | WriteLn(''); | |
| 132 | + | WriteLn('Please, enter your name:'); | |
| 133 | + | ReadLn(Str); | |
| 134 | + | WriteLn('Your name is: ' + Str); | |
| 135 | + | end. | |
| 136 | + | ``` | |
| 137 | + | ||
| 138 | + | Command line to compile `test.pas`: | |
| 139 | + | ||
| 140 | + | ```DOS | |
| 141 | + | fpc -Twince -Parm test.pas | |
| 142 | + | ``` | |
| 143 | + | ||
| 144 | + | You will get a `test.exe` executable file. Copy it to your Windows CE device and run. | |
| 145 | + | ||
| 146 | + | [Here](http://wiki.lazarus.freepascal.org/index.php/Windows_CE_Interface#Screenshots) is a screenshot of a software created this way. | |
| 147 | + | ||
| 148 | + | --- | |
| 149 | + | *From the Free Pascal wiki, page "arm-wince", as it stood on 2020-08-09 after a change by Trev, 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).* | |
| 150 | + | Category: ARM | |
| 151 | + | Category: Cross compilation | |
| 152 | + | Category: WinCE |
