Recent

Author Topic: ARM crosscompiling  (Read 15719 times)

djdjdjole

  • Full Member
  • ***
  • Posts: 101
ARM crosscompiling
« 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

Leledumbo

  • Hero Member
  • *****
  • Posts: 8112
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: ARM crosscompiling
« Reply #1 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 as AFAIK 2.7.1 has quite some problems on android).

Laksen

  • Hero Member
  • *****
  • Posts: 621
    • J-Software
Re: ARM crosscompiling
« Reply #2 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?

djdjdjole

  • Full Member
  • ***
  • Posts: 101
Re: ARM crosscompiling
« Reply #3 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

djdjdjole

  • Full Member
  • ***
  • Posts: 101
Re: ARM crosscompiling
« Reply #4 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

Leledumbo

  • Hero Member
  • *****
  • Posts: 8112
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: ARM crosscompiling
« Reply #5 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.

djdjdjole

  • Full Member
  • ***
  • Posts: 101
Re: ARM crosscompiling
« Reply #6 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

djdjdjole

  • Full Member
  • ***
  • Posts: 101
Re: ARM crosscompiling
« Reply #7 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

Leledumbo

  • Hero Member
  • *****
  • Posts: 8112
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: ARM crosscompiling
« Reply #8 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.

djdjdjole

  • Full Member
  • ***
  • Posts: 101
Re: ARM crosscompiling
« Reply #9 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

Leledumbo

  • Hero Member
  • *****
  • Posts: 8112
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: ARM crosscompiling
« Reply #10 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).

djdjdjole

  • Full Member
  • ***
  • Posts: 101
Re: ARM crosscompiling
« Reply #11 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

Leledumbo

  • Hero Member
  • *****
  • Posts: 8112
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: ARM crosscompiling
« Reply #12 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.

djdjdjole

  • Full Member
  • ***
  • Posts: 101
Re: ARM crosscompiling
« Reply #13 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

Leledumbo

  • Hero Member
  • *****
  • Posts: 8112
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: ARM crosscompiling
« Reply #14 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).