Editing Compile FreePascal on device
Warning: You are not logged in.
Your IP address will be recorded in this page's edit history.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
- | [http://freepascal.org FreePascal compiler] is a free compiler for the various Pascal dialects. There is also a project [http://lazarus.freepascal.org Lazarus] which provides | + | [[http://freepascal.org FreePascal compiler]] is a free compiler for the various Pascal dialects. There is also a project [[http://lazarus.freepascal.org Lazarus]] which provides Delphi like IDE for the FreePascal compiler. |
- | + | In this article we will describe how to compile and install FreePascal compiler right on the device (currently n900 only, still have troubles to successfully compile it on my n810). | |
- | + | ||
+ | ==Bootstraping== | ||
First we need to get a working copy of fpc for ARM EABI. Currently, it is possible to get only ARB OABI version at the FreePascal web site. (version 2.2.2) | First we need to get a working copy of fpc for ARM EABI. Currently, it is possible to get only ARB OABI version at the FreePascal web site. (version 2.2.2) | ||
That's why we need to compile an ARM version of the compiler on the GNU/Linux PC first, then transfer it to the Nokia device, and compile the full compiler distribution there. | That's why we need to compile an ARM version of the compiler on the GNU/Linux PC first, then transfer it to the Nokia device, and compile the full compiler distribution there. | ||
- | + | That's why first you need to have fpc installed on your GNU/Linux box. | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
Then, download fpc source with svn. | Then, download fpc source with svn. | ||
<pre> | <pre> | ||
svn checkout http://svn.freepascal.org/svn/fpc/trunk fpc | svn checkout http://svn.freepascal.org/svn/fpc/trunk fpc | ||
</pre> | </pre> | ||
- | + | You also need cross binutils for ARM. | |
- | + | Let's compile it like this: | |
- | You also need cross binutils for ARM. Let's compile it like this: | + | |
<pre> | <pre> | ||
mkdir binutils | mkdir binutils | ||
Line 26: | Line 21: | ||
cd $BINUTILS | cd $BINUTILS | ||
./configure --prefix=/opt/binutils-arm-eabi --target=arm-none-eabi --with-gnu-as | ./configure --prefix=/opt/binutils-arm-eabi --target=arm-none-eabi --with-gnu-as | ||
- | --with-gnu-ld | + | --with-gnu-ld |
make | make | ||
make install | make install | ||
Line 34: | Line 29: | ||
-linux-ld | -linux-ld | ||
</pre> | </pre> | ||
- | |||
- | |||
Then, export PATH so it will contain your binutils path first | Then, export PATH so it will contain your binutils path first | ||
<pre> | <pre> | ||
export PATH=/opt/binutils-arm-eabi/bin:$PATH | export PATH=/opt/binutils-arm-eabi/bin:$PATH | ||
</pre> | </pre> | ||
- | + | ||
- | + | ||
Now we can compile fpc for ARM EABI. Go to fpc svn directory and run: | Now we can compile fpc for ARM EABI. Go to fpc svn directory and run: | ||
+ | |||
<pre> | <pre> | ||
make all PREFIX=/opt/fpc-arm OS_TARGET=linux CPU_TARGET=arm OPT="-dFPC_ARMEL" | make all PREFIX=/opt/fpc-arm OS_TARGET=linux CPU_TARGET=arm OPT="-dFPC_ARMEL" | ||
</pre> | </pre> | ||
- | + | ||
- | + | ||
After successful compilation you will get "ppcarm" binary in the "compiler" folder inside fpc source tree. | After successful compilation you will get "ppcarm" binary in the "compiler" folder inside fpc source tree. | ||
+ | |||
<pre> | <pre> | ||
noch@hactar:~/freepascal/svn/fpc/compiler$ file ppcarm | noch@hactar:~/freepascal/svn/fpc/compiler$ file ppcarm | ||
ppcarm: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, stripped | ppcarm: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, stripped | ||
</pre> | </pre> | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | For Diablo, I found "diffutils" package in the [http://www.gronmayer.com/it/dl.php?id=224 Dayless] repository at the [http://www.gronmayer.com/it gronmayer] repository list. | + | Now it's time to scp ppcarm to the Nokia Maemo device, and compile with it sources there. From this point we work only on Maemo. |
+ | I assume, you have openssh-server installed. You will also need the following packages: | ||
+ | subversion - to get fpc source tree. | ||
+ | binutils - to get GNU assembler and linker | ||
+ | diffutils-gnu - fpc needs "diff" to compile itself | ||
+ | coreutils-gnu - contains, "install" command, needed to run "make install" | ||
+ | |||
+ | For Diablo, I found "diffutils" package in the [[http://www.gronmayer.com/it/dl.php?id=224 Dayless]] repository at the [[http://www.gronmayer.com/it gronmayer]] repository list. | ||
<pre> | <pre> | ||
Line 78: | Line 69: | ||
/usr/bin/gdiff | /usr/bin/gdiff | ||
</pre> | </pre> | ||
- | + | Because fpc needs "diff" executable, then there's two options. Whether to add /usr/bin/gnu to the PATH | |
- | + | ||
- | Because fpc needs "diff" executable, then there's two options. Whether to add | + | |
<pre> export PATH=/usr/bin/gnu:$PATH</pre> | <pre> export PATH=/usr/bin/gnu:$PATH</pre> | ||
- | or create a symlink to | + | or create a symlink to gdiff in /usr/bin |
<pre>ln -s /usr/bin/gdiff /usr/bin/diff</pre> | <pre>ln -s /usr/bin/gdiff /usr/bin/diff</pre> | ||
- | + | ||
- | + | ||
There is a linker problem like | There is a linker problem like | ||
<pre> | <pre> | ||
Line 94: | Line 82: | ||
Fatal: Compilation aborted | Fatal: Compilation aborted | ||
</pre> | </pre> | ||
- | In order to avoid this, go to | + | In order to avoid this, go to compiler/systems and change t_linux.pas so that it contain path to the /lib/ld-linux.so.3 instead of /lib/ld-linux.so.2, because we do not have /lib/ld-linux.so.2 on Maemo4 and Maemo5. |
+ | This is a [[http://free-pascal-general.1045716.n5.nabble.com/FreePascal-on-ARM-Linux-SoftFloat-and-EABI-issues-td2819338.html quote]] from the freepascal mailing list: | ||
<pre> | <pre> | ||
> also although it creates an EABI 4 executable correctly there is a | > also although it creates an EABI 4 executable correctly there is a | ||
Line 106: | Line 95: | ||
> {$else} | > {$else} | ||
</pre> | </pre> | ||
- | + | ||
- | + | ||
So, change to the fpc source directory and run: | So, change to the fpc source directory and run: | ||
<pre> | <pre> | ||
make clean all PP=/path/to/newlycopied/ppcarm PREFIX="/opt/fpc-svn" OPT="-dFPC_ARMEL -O- -dFPC_ABI_EABI" | make clean all PP=/path/to/newlycopied/ppcarm PREFIX="/opt/fpc-svn" OPT="-dFPC_ARMEL -O- -dFPC_ABI_EABI" | ||
</pre> | </pre> | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
Then, make install with the same options | Then, make install with the same options | ||
<pre> | <pre> | ||
make install PP=/path/to/newlycopied/ppcarm PREFIX="/opt/fpc-svn" OPT="-dFPC_ARMEL -O- -dFPC_ABI_EABI" | make install PP=/path/to/newlycopied/ppcarm PREFIX="/opt/fpc-svn" OPT="-dFPC_ARMEL -O- -dFPC_ABI_EABI" | ||
</pre> | </pre> | ||
- | |||
- | |||
- | |||
==Creating config== | ==Creating config== | ||
- | + | Now, we have a working compiler in /opt/fpc-svn/bin | |
- | Now, we have a working compiler in | + | But there are no config file, so it won't work. |
- | + | In order to create a config file, do | |
- | + | ||
- | In order to create a config file, do | + | |
<pre> | <pre> | ||
- | /opt/fpc-svn/bin/fpcmkcfg -d basepath=/opt/fpc-svn/lib/fpc/2.5.1 | + | /opt/fpc-svn/bin/fpcmkcfg -d basepath=/opt/fpc-svn/lib/fpc/2.5.1 -o /etc/fpc.cfg |
</pre> | </pre> | ||
- | + | ||
- | + | It is also necessary to have correct path | |
- | It is also necessary to have correct path | + | |
<pre> | <pre> | ||
export PATH=/opt/fpc-svn/lib/fpc/2.5.1:/opt/fpc-svn/bin:$PATH | export PATH=/opt/fpc-svn/lib/fpc/2.5.1:/opt/fpc-svn/bin:$PATH | ||
</pre> | </pre> | ||
Second directory contains ppcarm binary, which is necessary for compilation. | Second directory contains ppcarm binary, which is necessary for compilation. | ||
- | |||
- | |||
This is it, now you have a working FreePascal compiler on Maemo. Next step is to install Lazarus, so you will be able to compile Lazarus created sources right on the device. | This is it, now you have a working FreePascal compiler on Maemo. Next step is to install Lazarus, so you will be able to compile Lazarus created sources right on the device. | ||
Line 156: | Line 128: | ||
</pre> | </pre> | ||
- | Lazarus compilation will fail with the binutils of | + | Lazarus compilation will fail with the binutils of maemo5. |
+ | Thus we need to compile newer binutils and we need gcc for it. | ||
- | |||
- | |||
Add SDK repository to the apt config | Add SDK repository to the apt config | ||
<pre>vi /etc/apt/sources.list.d/dev.list</pre> | <pre>vi /etc/apt/sources.list.d/dev.list</pre> | ||
<pre>deb http://repository.maemo.org fremantle/sdk free non-free</pre> | <pre>deb http://repository.maemo.org fremantle/sdk free non-free</pre> | ||
DO NOT UPGRADE YOUR SYSTEM WITH THIS CONFIG LINE ENABLED! | DO NOT UPGRADE YOUR SYSTEM WITH THIS CONFIG LINE ENABLED! | ||
- | |||
- | |||
<pre> | <pre> | ||
apt-get update | apt-get update | ||
apt-get install gcc autoconf automake1.9 libtool flex bison gdb automaken libltdl3-dev | apt-get install gcc autoconf automake1.9 libtool flex bison gdb automaken libltdl3-dev | ||
</pre> | </pre> | ||
- | + | Now install binutils. For that you also need tar-gnu and bzip2 packages: | |
- | + | ||
- | + | ||
<pre> | <pre> | ||
- | apt-get install | + | apt-get install tar-gnu bzip2 |
</pre> | </pre> | ||
- | + | I use the following script: | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
<pre> | <pre> | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
#!/bin/bash | #!/bin/bash | ||
BINUTILS=binutils-2.20.1 | BINUTILS=binutils-2.20.1 | ||
Line 202: | Line 156: | ||
ln -s /opt/binutils-arm-eabi/bin/arm-none-eabi-as /opt/binutils-arm-eabi/bin/arm | ln -s /opt/binutils-arm-eabi/bin/arm-none-eabi-as /opt/binutils-arm-eabi/bin/arm | ||
ln -s /opt/binutils-arm-eabi/bin/arm-none-eabi-ld /opt/binutils-arm-eabi/bin/arm | ln -s /opt/binutils-arm-eabi/bin/arm-none-eabi-ld /opt/binutils-arm-eabi/bin/arm | ||
- | </ | + | </pre> |
- | + | ||
- | + | Update the PATH environment variable so it contain newly installed binutils at first place: | |
- | Update the | + | |
<pre> | <pre> | ||
export PATH=/opt/binutils-arm-eabi/bin:$PATH | export PATH=/opt/binutils-arm-eabi/bin:$PATH | ||
</pre> | </pre> | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
cd into lazarus directory | cd into lazarus directory | ||
<pre> | <pre> | ||
make clean all | make clean all | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
</pre> | </pre> | ||
- | |||
- | + | ---to be continued--- | |
[[Category:N8x0]] | [[Category:N8x0]] | ||
[[Category:N900]] | [[Category:N900]] | ||
[[Category:Development]] | [[Category:Development]] | ||
+ | [[Category:Devtools]] |
Learn more about Contributing to the wiki.