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