Lazarus

Installation => General => Topic started by: djdjdjole on August 24, 2012, 10:08:16 am

Title: ARM crosscompiling
Post by: djdjdjole on August 24, 2012, 10:08:16 am
Hello

I prepared Lazarus for crosscompiling as stated here:
http://wiki.freepascal.org/Setup_Cross_Compile_For_ARM.
First I built Linux (using Buildroot) with GTK2 support on my ARM board.
GTK examples work on target, when compiled using C compiler (generated
by Buildroot). Examples intended for FPC - also with direct GTK functions
calls (no use of Lazarus designer), work when built in Lazarus, until the
moment when unit sysutils become included in uses section.
Then I receive mutliple acces violation erros.
After little investigation I found the first problem started at the
StrToInt(argv) insturction.
All programs work OK when built for i386 (Ubuntu 10.04).
My FPC is 2.7.1; Lazarus is 1.1; ARM board- mini2440
Any help ?

Regards
Title: Re: ARM crosscompiling
Post by: Leledumbo on August 24, 2012, 04:12:03 pm
Try making a simple program that demonstrates this behavior. I only have my android phone as ARM device and AndroidLCL example (which uses SysUtils) works fine there (it doesn't use FPC 2.7.1 though, but a modified 2.5.1 maintained here (https://sourceforge.net/projects/p-tools/files/Free%20Pascal%20for%20ARM/) as AFAIK 2.7.1 has quite some problems on android).
Title: Re: ARM crosscompiling
Post by: Laksen on August 24, 2012, 04:44:31 pm
Also make sure that you are compiling to ARMv4T and not anything higher. The SC32440 is a fairly old processor. What ABI is the kernel running?
Title: Re: ARM crosscompiling
Post by: djdjdjole on August 24, 2012, 10:45:33 pm
Thank's Leledumbo for reply. I also think that problem is not in sysutils, but it is the place where some other problem reveals. The board is on my job, so I'll try what Leledumbo proposed, next week and see results.

I am very new in embedded linux world and hope I understood correctly Laksen's questions Regarding ABI question - the options that were default in kernel config, (and that I didn't change) are:
-  Use ARM EABI to compile the kernel and
-  Allow old ABI binaries to run with this kernel (EXPERIMENTAL)

However, I don't know where in Lazarus IDE, I choose compiling to ARMv4T.
One more question, when compiling binutils (in the process of preparing Lazarus for crosscompilation), I used assembler option "-meabi=5", but not sure if there should be some other number?  How can I find that ?

Regards
Title: Re: ARM crosscompiling
Post by: djdjdjole on August 27, 2012, 02:39:57 pm
You were right Leledumbo. It is about 2.7.1 version.
2.5.1 compiles and program I described with direct gtk calls -works on target.
Link you gave me is precompiled 2.5.1 for arm, so I renamed
directory /usr/lib/fpc/2.7.1/units/arm-linux and copy arm-linux
directory from precompiled 2.5.1. (and also ppccrossarm file) to
/usr/lib/fpc/2.7.1/units directory. Compiled - worked OK.

However, when generate project (what I described was program only),
with no code and try to compile it says :PPU invalid version 146
Rebuild needed of unit interaces used by ....../interfaces.ppu

Before I did above described changes, project compiled OK.

Does it mean that I must compile first 2.5.1 (can I do it with 2.6.0 which
is on my Ubuntu) from sources, then do "make crossinstall" and
make clean all lazarus ? Or what ?

Regards
Title: Re: ARM crosscompiling
Post by: Leledumbo on August 27, 2012, 05:27:21 pm
Quote
so I renamed
directory /usr/lib/fpc/2.7.1/units/arm-linux and copy arm-linux
directory from precompiled 2.5.1. (and also ppccrossarm file) to
/usr/lib/fpc/2.7.1/units directory. Compiled - worked OK
This is not the expected way, do not cross copy the compiler and units of different version. Use each as one.
Quote
However, when generate project (what I described was program only),
with no code and try to compile it says :PPU invalid version 146
Rebuild needed of unit interaces used by ....../interfaces.ppu
PPU format changes quite often, especially in development snapshots, and all used PPU for the same project must be compatible. Hence the error you get where the compiler is trying to recompile the unit.
Quote
Does it mean that I must compile first 2.5.1 (can I do it with 2.6.0 which
is on my Ubuntu) from sources, then do "make crossinstall" and
make clean all lazarus ? Or what ?
Simply use the 2.5.1 as a whole (compiler and units) then recompile lcl using it.
Title: Re: ARM crosscompiling
Post by: djdjdjole on August 27, 2012, 08:50:03 pm
Strangely, but didn't succeed to find fpc.zip for 2.5.1. Is it some kind of error or my missunderstanding, but in ftp://ftp.freepascal.org/fpc/snapshot/v25/source/ I've got fpc.zip, inside which when looking at Makefile- I read  2.7.1 !!!
What I only find is precompiled 2.5.1 for i386, but I doubt it is good to use two precompiled version for i386 and for arm even if they are 2.5.1 - also I think I need unit sources.

Regards
Title: Re: ARM crosscompiling
Post by: djdjdjole on August 27, 2012, 09:12:12 pm
And, yes, one more thing - do I have to compile 2.x.y sources with release version of compiler < 2.x.y  or it could be even higher version ?
In first case, it means almost complete installation of fpc and Lazarus, only to change from 2.7.1 to 2.5.1 (eg).

Cheers
Title: Re: ARM crosscompiling
Post by: Leledumbo on August 28, 2012, 05:03:51 pm
Quote
Strangely, but didn't succeed to find fpc.zip for 2.5.1. Is it some kind of error or my missunderstanding, but in ftp://ftp.freepascal.org/fpc/snapshot/v25/source/ I've got fpc.zip, inside which when looking at Makefile- I read  2.7.1 !!!
The date is newer than the release date of 2.6.0, probably it's already 2.7.1 but the new folder for v27 wasn't created yet at that time. Could you just try with 2.6.0?
Quote
And, yes, one more thing - do I have to compile 2.x.y sources with release version of compiler < 2.x.y  or it could be even higher version ?
Typically, for development version, compile with the latest release prior to that development version (this is a guaranteed-to-work operation). So it's 2.4.0 / 2.4.2 for 2.5.1. You can compile with 2.5.1 as well but the only supported revision is the one you're going to compile (same revision compiling itself). Backward compatibility (compiling older version with newer one) seems not supported.
Title: Re: ARM crosscompiling
Post by: djdjdjole on August 28, 2012, 07:58:25 pm
Funny situation: 2.4.0 RPM package doesn't compile 2.6.0 sources (- I need sources for Lazarus) - it's some syntax error. However it does compile 2.5.1 sources (that I found somewhere !). Later, when I switch to 2.5.1 fpc compiler and try to compile Lazarus 1.1 sources -it fails (I think some error of missing property or so). On the other hand, precompiled 2.5.1 version (i386) downloaded from ftp.freepascal.org  does commpile Lazarus 1.1.
I'll try few more combination, but seems there is no light at sight.

Regards
Title: Re: ARM crosscompiling
Post by: Leledumbo on August 29, 2012, 09:55:07 am
2.4.0 should compile 2.4.2, 2.4.2 should compile 2.6.0. If you skip over a version, it's not guaranteed then. For Lazarus, it's another different beast. Lazarus and FPC are developed by two different teams, and Lazarus can't guarantee that it can be compiled with versions other than the suggested (bundled) one. Even Lazarus and FPC revisions taken at the same time might not be compatible (like the one that's just happened around a week ago until solved this monday).
Title: Re: ARM crosscompiling
Post by: djdjdjole on August 29, 2012, 12:24:28 pm
At last success. RPM 2.4.0 compiled 2.5.1 sources. But Lazarus sources, I changed to
09.30.4 version. 2.5.1 compiled Lazarus OK. I made simple project in Lazarus 
(-GTK compiled) to change the color of form, when (the only) button is pressed.
Compiled and work on target.
What confuses me is binary size of 15.8MB, although I unchecked option for including
debugg info. I can do some experimenting now.
Thanks a lot Leledumbo and the others. I am almost sure there will be some more problems,
so I will ask for further help.

Regards
Title: Re: ARM crosscompiling
Post by: Leledumbo on August 29, 2012, 02:53:40 pm
Quote
What confuses me is binary size of 15.8MB, although I unchecked option for including
debugg info.
Broken ld or options get overriden. Try manual stripping.
Title: Re: ARM crosscompiling
Post by: djdjdjole on August 29, 2012, 03:07:29 pm
Didn't know for manual stripping - what command, but I will Google for it.
First impression regarding Lazarus I installed is that is more, more unstable then Lazarus 1.1 (that I already had). Espetially related to designer and also to editor. Also some source code regarding class methods manipulation didn't work (in Delphi it does work).
Maybe I'll try with Lazarus 1.0 if fpc 2.5.1 would compile it.

Regards
Title: Re: ARM crosscompiling
Post by: Leledumbo on August 29, 2012, 05:02:51 pm
Quote
Didn't know for manual stripping - what command
strip -s <executable file> (don't do on shared libs, for this you only need strip --strip-unneeded).
Title: Re: ARM crosscompiling
Post by: djdjdjole on August 30, 2012, 08:34:19 am
Command strip -s <executable>, when called from shell, says: Unable to recognize the format of the input file <executable>. Probably, because <executable> is not in the format for current distribution, but crosscompiled binary.
Still, this file works on target.
Files that I compiled with Lazarus1.1 were around 2.5Mb of size.
Title: Re: ARM crosscompiling
Post by: Leledumbo on August 30, 2012, 02:28:56 pm
Quote
Command strip -s <executable>, when called from shell, says: Unable to recognize the format of the input file <executable>. Probably, because <executable> is not in the format for current distribution, but crosscompiled binary.
Ah yes, sorry. I forgot about that :-[
If you have arm-linux-strip you can use that
Title: Re: ARM crosscompiling
Post by: djdjdjole on August 30, 2012, 07:22:14 pm
Many congratulations to you Leledumbo. I have arm-linux-strip that was generated during process of building root file system and it did the job. Now, executables are 2.5MB.
Meanwhile I tried few more combinations (speaking of software versions) related to building Lazarus for crosscompilation process and later for building applications for ARM boards. What I described, earlier was the only combination that worked for me.
I don't know if there exists some classification what combinations of compileres and Lazarus version can be used, and also to give satisfactory binaries for target ARM boards. However I doubt, because there are for example few different 2.5.1 source versions (different file sizes).
Title: Re: ARM crosscompiling
Post by: djdjdjole on September 06, 2012, 11:50:25 am
For those interested, a better combination that works OK iz 2.4.2 RPM package for starting FPC, then it compile FPC 2.6.0  sources and with it, Lazarus 1.0 can be compiled and later, generate valid ARM application.
That was GTK, but regarding Qt, I have a question.
After successful building of Qt application (i386) in Lazarus I intend to build linux root file system for my ARM board that will include Qt support.
However, I don't know if I have to build root file system with X11 support also, in orther to create Qt applications, that intend to be build in Lazarus.
I was told that there is no need for that and what is needed is to start Qt application with "-qws" option. It sounds strange to me, because in that case program shoud have to analyze what option is entered. My opinion is that such statement is valid only if I compile with QtCreator.
Any help ?

Regards
Title: Re: ARM crosscompiling
Post by: zeljko on October 01, 2012, 02:44:20 pm
for embedded qtlcl you must use -dQTOPIA afair, but on my Nokia N9 I'm using qt as it is , since it have an X11 server running.
Title: Re: ARM crosscompiling
Post by: djdjdjole on October 01, 2012, 06:25:10 pm
Thanks Zeljko, but as I don't know about dQTOPIA, can you point me at some articles/sites, where I can learn more. Once more, does it mean that I don't need X server in that case if I want to use Lazarus for programing ?

Regards