Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2013-01

Install fpc and Friends on a non-Debian ARM-Linux Device

6 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Schnell

Hi experts. (Beware: long explanation trying to help those ho try something similar. A question is asked at the end.)

I am trying to install, test and run fpc programs on a QNAP 219 P II NAS.

Same is a headless ARM-Linux device. With 512 MB RAM and It has enough resources to even run Lazarus in a remote GUI environment.

But first I tried to install and use fpc.

Here the initial problem is, that the device uses a mildly QNAP propriety Linux distribution. Same comes with installation tools for it's own package format (".qpkg") moreover you can install Optware ".ipkg" packages, as there is a qpkg for Optware. .

But for fpc there is neither a qpkg not an ipkg package. AFAIK for ARM there only is an Debian "apt-get" package for fpc and friends. Same is said to happily be useable on a "Raspberry Pi" with similar resources as the QNAP 219 P II.

So I tried to find the appropriate ".deb" files

I found the downloadable Debian package here:

http://packages.debian.org/squeeze/armel/fp-compiler/download -> http://ftp.de.debian.org/debian/pool/main/f/fpc/fp-compiler_2.4.0-2_armel.deb

I could extract the content doing

ar x fp-compiler_2.4.0-2_armel.deb

Now I have a set of some file including data.tar.bz2 and control.tar.gz

Using Midnight Commander (installed as an ipkg) I extracted those to appropriately named the directories.

"control" contains files to be used by apt

"data" contains the folders "etc" and "users", obviously the destination folders for the files they contain.

"etc" contains fpc.cfg

"usr" contains the directories bin, lib and share with their appropriate content.

Now with the "deeply embedded" QNAP, the root directory is on a RAM file system (extracted together with the Kernel when booting) and will be reconstructed with any boot. Thus it does not make sense to copy the files there.

So I created a directory "debian" on the harddisk that is managed by the QNAP. and moved the extracted files in there relative to a fake root.

Now I copied fpc.cfg to /etc and created symlinks
/usr/bin/fpc -> xxx/debian/usr/bin/fpc and /usr/lib/fpc -> xxx/debian/usr/lib/fpc

So there is
xxx/debian/usr/lib/fpc/2.4.0/ppcarm

I can happily run this executable:

[/share/Public/debian/usr/lib/fpc/2.4.0] # ./ppcarm Free Pascal Compiler version 2.4.0-2 [2010/02/20] for arm Copyright (c) 1993-2009 by Florian Klaempfl
/share/MD0_DATA/Public/debian_test/usr/lib/fpc/2.4.0/ppcarm [options] <inputfile> [options]
Put + after a boolean switch option to enable it, - to disable it -a The compiler doesn't delete the generated assembler file -al List sourcecode lines in assembler file -an List node info in assembler file
-ap Use pipes instead of creating temporary assembler files -ar List register allocation/release info in assembler file -at List temp allocation/release info in assembler file -A<x> Output format:
-Adefault Use default assembler
-Aas Assemble using GNU AS
-b Generate browser info
-bl Generate local symbol info
-B Build all modules
-C<x> Code generation options:
-Ca<x> Select ABI, see fpc -i for possible values -Cb Generate big-endian code
-Cc<x> Set default calling convention to <x>
-CD Create also dynamic library (not supported) -Ce Compilation with emulated floating point opcodes *** press enter ***

After I found that I additionally need to do a link

/usr/bin/ppcarm -> xxx/debian/usr/lib/fpc/2.4.0/ppcarm

I also happily can run "fpc":

[~] # fpc -v
Free Pascal Compiler version 2.4.0-2 [2010/02/20] for arm Copyright (c) 1993-2009 by Florian Klaempfl
Fatal: No source file name in command line
Fatal: Compilation aborted
Error: /usr/bin/ppcarm returned an error exitcode (normal if you did not specify a source file to be compiled)

Now trying to compile .....

[/share/Public/heizarm] # cat hello.pas
begin

   writeln ( 'hello fpc');

end.
[/share/Public/heizarm] # fpc hello.pas
Free Pascal Compiler version 2.4.0-2 [2010/02/20] for arm Copyright (c) 1993-2009 by Florian Klaempfl
Target OS: Linux for ARMEL
Compiling hello.pas
Assembling program
Linking hello
3 lines compiled, 0.3 sec
[/share/Public/heizarm] # ./hello
hello fpc

Works !!!!

Now trying to compile the (commandline) project I created and tested using Lazarus on a Linux PC.

Same obviously needs several additional packages providing the necessary units form the rtl and the fcl. It also needs synapse, but here I simply add the directory with the synapse source files to my project.

I found the appropriate three Debian packages and used the method described above to manually install them. These packages provide .ppu and o files but no sources.

I now have:

[/usr/bin] # ls -l | more
...
lrwxrwxrwx 1 admin administ 12 Dec 5 05:35 find -> /bin/busybox*
lrwxrwxrwx 1 admin administ 37 Jan 18 20:24 fpc -> /share/Public/debian/usr/bin/fpc*
...

[/usr/lib] # ls -l | more
drwxr-xr-x 4 admin administ 4096 Dec 5 04:52 cups/ lrwxrwxrwx 1 admin administ 37 Jan 19 13:52 fpc -> /share/Public/debian/usr/lib/fpc/
...

[/usr/lib/fpc/2.4.0] # ls -l
drwxr-xr-x 2 admin administ 4096 Feb 20 2010 msg/ -rwxr-xr-x 1 admin administ 1921892 Feb 20 2010 ppcarm* -rwxr-xr-x 1 admin administ 12929 Feb 20 2010 samplecfg* drwxr-xr-x 3 admin administ 4096 Feb 20 2010 units/

[/usr/lib/fpc/2.4.0/units/arm-linux] # ls -l
drwxr-xr-x 2 admin administ 4096 Feb 20 2010 fcl-async/ drwxr-xr-x 2 admin administ 4096 Feb 20 2010 fcl-base/ drwxr-xr-x 2 admin administ 4096 Feb 20 2010 fcl-db/ drwxr-xr-x 2 admin administ 4096 Feb 20 2010 fcl-fpcunit/ drwxr-xr-x 2 admin administ 4096 Feb 20 2010 fcl-image/ drwxr-xr-x 2 admin administ 4096 Feb 20 2010 fcl-json/ drwxr-xr-x 2 admin administ 4096 Feb 20 2010 fcl-net/ drwxr-xr-x 2 admin administ 4096 Feb 20 2010 fcl-passrc/ drwxr-xr-x 2 admin administ 4096 Feb 20 2010 fcl-process/ drwxr-xr-x 2 admin administ 4096 Feb 20 2010 fcl-registry/ drwxr-xr-x 2 admin administ 4096 Feb 20 2010 fcl-res/ drwxr-xr-x 2 admin administ 4096 Feb 20 2010 fcl-web/ drwxr-xr-x 2 admin administ 4096 Feb 20 2010 fcl-xml/ drwxr-xr-x 2 admin administ 4096 Feb 20 2010 fpmkunit/ drwxr-xr-x 2 admin administ 4096 Feb 20 2010 hash/ drwxr-xr-x 2 admin administ 4096 Feb 20 2010 ncurses/ drwxr-xr-x 2 admin administ 4096 Feb 20 2010 pasjpeg/ drwxr-xr-x 2 admin administ 4096 Feb 20 2010 paszlib/ drwxr-xr-x 2 admin administ 4096 Feb 20 2010 regexpr/ drwxr-xr-x 2 admin administ 4096 Feb 20 2010 rtl/ drwxr-xr-x 2 admin administ 4096 Feb 20 2010 uuid/ drwxr-xr-x 2 admin administ 4096 Feb 20 2010 x11/ [/usr/lib/fpc/2.4.0/units/arm-linux] #

Now I can compile the project, but linking it does not work: ================================================================================ [/share/Public/heizarm] # fpc heiz.lpr
Free Pascal Compiler version 2.4.0-2 [2010/02/20] for arm Copyright (c) 1993-2009 by Florian Klaempfl
Target OS: Linux for ARMEL
Compiling heiz.lpr
Compiling inifiles.pp
Compiling contnrs.pp
contnrs.pp(2736,12) Warning: Converting pointers to signed integers may result in wrong comparison results and range errors, use an unsigned type instead.
Writing Resource String Table file: contnrs.rst
Assembling contnrs
inifiles.pp(245,15) Warning: Converting pointers to signed integers may result in wrong comparison results and range errors, use an unsigned type instead.
inifiles.pp(259,15) Warning: Converting pointers to signed integers may result in wrong comparison results and range errors, use an unsigned type instead.
inifiles.pp(537,3) Note: Local variable "M" not used inifiles.pp(542,5) Note: Local variable "l2" not used inifiles.pp(666,5) Note: Local variable "bAppendNextLine" not used inifiles.pp(666,22) Note: Local variable "bAppended" not used Assembling inifiles
Compiling work.pas
Compiling work1611.pas
Compiling httpsend.pas
Compiling blcksock.pas
Compiling synafpc.pas
Assembling synafpc
Compiling synsock.pas
Assembling synsock
Compiling synautil.pas
synautil.pas(1922,3) Note: Local variable "BackStop" is assigned but never used
Assembling synautil
Compiling synacode.pas
Assembling synacode
Compiling synaip.pas
Assembling synaip
Assembling blcksock
Assembling httpsend
Assembling work1611
Compiling workmail.pas
Compiling smtpsend.pas
Assembling smtpsend
Compiling pop3send.pas
Assembling pop3send
Compiling mimemess.pas
Compiling mimepart.pas
Compiling synachar.pas
Compiling synaicnv.pas
Assembling synaicnv
Assembling synachar
Compiling mimeinln.pas
Assembling mimeinln
Assembling mimepart
Assembling mimemess
workmail.pas(77,3) Note: Private field "TSMTPWork.SMTPSend" is never used Assembling workmail
Assembling work
Assembling heiz
Linking heiz
/usr/lib/fpc/2.4.0/units/arm-linux/rtl/cprt0.o: In function `_haltproc_eabi':
(.text+0x88): undefined reference to `_fini'
/usr/lib/fpc/2.4.0/units/arm-linux/rtl/cprt0.o: In function `_haltproc_eabi':
(.text+0x90): undefined reference to `_init'
heiz.lpr(89) Error: Error while linking
heiz.lpr(89) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted
Error: /usr/bin/ppcarm returned an error exitcode (normal if you did not specify a source file to be compiled)
[/share/Public/heizarm] #
================================================================================

I found, that _fini and _init *should* be provided by crti.o which is not included in the packages I installed. And I don't know how to find out which package might provide it.

Rather disappointed I tried to compile the crti.s file from the svn.

After renaming it to crti.S and commenting out the two".type" lines, that gcc (installed as an ipkg) does not like, it can be compiled to crti.o:

[/share/Public/heizarm] # cat crti.S
===============================================================
//
//Copyright 2001, QNX Software Systems Ltd. All Rights Reserved
//
// QNX has kindly released this source code under the QNX open
// Community license, expressly to be used with  the
// Free Pascal runtime library
//

.section .init
.globl _init
// .type _init,@function
_init:

.section .fini
.globl _fini
// .type _fini,@function
_fini:
===============================================================

To make it aware to the linker, I added an appropriate line {L crti.o}
to the heiz.lpr file.

Now the project can be linked.

But unfortunately it does not run:

[/share/Public/heizarm] # ./heiz
Segmentation fault
[/share/Public/heizarm] #

How to proceed ?

I never use any crt stuff, only writeln() is used, and same does work in the "hello" project. Thus the initialization of the crt stuff seems like a dummy task but should not crash, anyway.

I have no idea why the project needs _init and _fini and thus crti.o. According to the svn files, "haltproc_eabi" is used in system.pp and provided by cprt0.as.
I don speak are assembler and I am only acquainted with the gcc type assembler file (.s or .S rather than .as). So I don't understand what is done in the ARM version of cprt0.

Thanks for any help,
-Michael

Reply by email

Thomas Schatzl
to Michael Schnell

Hi,

Michael Schnell wrote 14 lines
Hi experts. (Beware: long explanation trying to help those ho try something similar. A question is asked at the end.) I am trying to install, test and run fpc programs on a QNAP 219 P II NAS. [...] But first I tried to install and use fpc. Here the initial problem is, that the device uses a mildly QNAP propriety Linux distribution. Same comes with installation tools for it's own package format (".qpkg") moreover you can install Optware ".ipkg" packages, as there is a qpkg for Optware. . But for fpc there is neither a qpkg not an ipkg package. AFAIK for ARM there only is an Debian "apt-get" package for fpc and friends. Same is

I already mentioned times that there is a .tar based installer provided by the fpc team which can be downloaded from the fpc website. Or at least the freepascal ftp.

said to happily be useable on a "Raspberry Pi" with similar resources as the QNAP 219 P II.

Use the tar installer of the fpc release you want. I.e. at ftp://ftp.freepascal.org/pub/fpc/dist/2.6.0/arm-linux/ you can get an official 2.6.0 installer for arm.

If you need a version from trunk (not sure if needed for e.g. lazarus), use the installer from
ftp://ftp.freepascal.org/pub/fpc/snapshot/v27/arm-linux-armel/

Or ftp://ftp.freepascal.org/pub/fpc/snapshot/v26/arm-linux-armel/ for the latest 2.6.1 snapshot.

The latter two are generated daily.

Show quoted text 6 lines
So I tried to find the appropriate ".deb" files I found the downloadable Debian package here: http://packages.debian.org/squeeze/armel/fp-compiler/download -> http://ftp.de.debian.org/debian/pool/main/f/fpc/fp-compiler_2.4.0-2_armel.deb

Don't use files from squeeze, squeeze is really outdated. It contains the 2.4 compiler as you can see. Use the "wheezy" stuff (or the current testing branch) if you need.

And, even easier, download the fpc installer from the fpc website.

Show quoted text 20 lines
Now I can compile the project, but linking it does not work: ================================================================================ [/share/Public/heizarm] # fpc heiz.lpr Free Pascal Compiler version 2.4.0-2 [2010/02/20] for arm Copyright (c) 1993-2009 by Florian Klaempfl Target OS: Linux for ARMEL Compiling heiz.lpr Compiling inifiles.pp [...] /usr/lib/fpc/2.4.0/units/arm-linux/rtl/cprt0.o: In function `_haltproc_eabi': (.text+0x88): undefined reference to `_fini' /usr/lib/fpc/2.4.0/units/arm-linux/rtl/cprt0.o: In function `_haltproc_eabi': (.text+0x90): undefined reference to `_init' I found, that _fini and _init *should* be provided by crti.o which is not included in the packages I installed. And I don't know how to find out which package might provide it.

The crt* files providing the _init and _fini symbols are from libc. Install libc-dev (iirc) using ipkg.

I.e. ipkg install libc-dev

You also want binutils (which you apparently already have installed). If you want to compile fpc or lazarus, you also need the "make" package. This should be everything needed to get started.

With that you can build lazarus yourselves. There may be unresolved dependencies on some libraries still. Please ask in the Lazarus mailing list/forum about compiling lazarus and particularly its dependencies.

Thomas

Reply by email

Mark Morgan Lloyd
to Michael Schnell: Hi experts. (Beware: long explanation trying to help those ho try something similar. A…
Michael Schnell wrote 29 lines
Hi experts. (Beware: long explanation trying to help those ho try something similar. A question is asked at the end.) I am trying to install, test and run fpc programs on a QNAP 219 P II NAS. Same is a headless ARM-Linux device. With 512 MB RAM and It has enough resources to even run Lazarus in a remote GUI environment. But first I tried to install and use fpc. Here the initial problem is, that the device uses a mildly QNAP propriety Linux distribution. Same comes with installation tools for it's own package format (".qpkg") moreover you can install Optware ".ipkg" packages, as there is a qpkg for Optware. . But for fpc there is neither a qpkg not an ipkg package. AFAIK for ARM there only is an Debian "apt-get" package for fpc and friends. Same is said to happily be useable on a "Raspberry Pi" with similar resources as the QNAP 219 P II. So I tried to find the appropriate ".deb" files I found the downloadable Debian package here: http://packages.debian.org/squeeze/armel/fp-compiler/download -> http://ftp.de.debian.org/debian/pool/main/f/fpc/fp-compiler_2.4.0-2_armel.deb I could extract the content doing

..

Works !!!!

I've done that sort of thing between e.g. SPARC systems, but not really attempted it on ARM where there are more variants. I think the thing I'd do at this point is see if I could compile 2.6.0 on the target system... you might need (the equivalent of Debian's) development packages * .

Having got 2.6.0, and again with the requirement of having development packages ** , you should be able to compile Lazarus.

* libgpm-dev libncurses5-dev

** libgtk2.0-dev plus possible dependencies.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Michael Schnell
to Thomas Schatzl: I already mentioned times that there is a .tar based installer provided by the fpc team…
Thomas Schatzl wrote 5 lines
The crt* files providing the _init and _fini symbols are from libc. Install libc-dev (iirc) using ipkg. I.e. ipkg install libc-dev

I already have it:

[/share/Public/heizarm] # ipkg install libc-dev
Package libc-dev (2.5-5) installed in root is up to date. Nothing to be done
Successfully terminated.

I easily found the crti.o file in the Optware directory.

So I replaced the crti.o file I compiled with gcc, by the "official" one for this machine.

I also installed the 2.6 fpc tar package, as you recommended.

The result is:

My project compiles nicely but only links when I add the line {$L crti.o} to one of the units.

It still crashes seemingly during the initialization phase.

I did a test project that uses writeln and some rtl/fcl packages such as string handling, DateTimeToString, Now, IniFiles. it can be linked without adding {$L crti.o}

It works nicely.

I suppose the cause of the crash in fact is related to crti, but I am not sure. I still don't know why - the hell - the crt stuff is called in my project, seemingly by the initialization section of one of the units used. Maybe synapse ???. I'll go on adding units to the uses of my testing project and see how far I get.

Thanks again,
-Michael

Reply by email

Michael Schnell
to Thomas Schatzl: I already mentioned times that there is a .tar based installer provided by the fpc team…
Thomas Schatzl wrote
Use the tar installer of the fpc release you want. I.e. at ftp://ftp.freepascal.org/pub/fpc/dist/2.6.0/arm-linux/ you can get an official 2.6.0 installer for arm.

Great !

It was very easy to install this in a safe location on the hard disk and add the appropriate links in /usr/bin and /usr/lib.

So I now have fpc 2.6 and the necessary libraries.

Sorry that I did not know that there is a "third way" to install fpc for ARM in the middle between cross compiling from the sources and using a distribution-depending package.

Thanks a ton,
-Michael

Reply by email

Michael Schnell
to Thomas Schatzl: I already mentioned times that there is a .tar based installer provided by the fpc team…

BTW.:

Linux reports this cpuinfo:

Processor name : Feroceon 88F6282 rev 1 (v5l) @ 2 GHz BogoMIPS : 1985.74
Features : swp half thumb fastmult edsp
CPU implementer : 0x56
CPU architecture: 5TE
CPU variant : 0x2
CPU part : 0x131
CPU revision : 1

Hardware : Feroceon-KW ARM
Revision : 0000
Serial : 0000000000000000

I suppose this means it's an ARM v5, little endian, soft float.

-Michael

Reply by email