Forum > Linux

cross to RasPi

(1/3) > >>

dbannon:
Thanks to covid, I had some time on my hands and thought I'd use it to write up how to cross compile from a Linux intel box to a Raspberry Pi. Cannot be that hard.

Indeed, almost trivial to make an arm binary (ie armel), but not a armhf one.  Now, the softfloat works fine on a Raspberry Pi and unless its doing a lot of maths, it would not matter. EXCEPT that if you make a debian package that includes a soft arm binary, apt says, "wow, this binary is arm, it therefore depends on somepackage:arm and I cannot find any of them"

So, doing my research, seems I need to pass -CaEABIHF to the compiler, probably while I build the cross compiler, probably in the app. Nope, Error: Illegal parameter: -CaEABIHF in either case. Seems the cross compiler builds OK but first thing it tries to make, system.pp, fails. See -


--- Code: ---/usr/arm-linux-gnueabihf/bin/as -meabi=5 -o /usr/share/fpcsrc/3.2.2/rtl/units/arm-linux/ucprt0.o arm/ucprt0.as
/usr/share/fpcsrc/3.2.2/compiler/ppcrossarm -Ur -Parm -Ur -Xs -O2 -n -Fi../inc -Fi../arm -Fi../unix -Fiarm -FD/usr/arm-linux-gnueabihf/bin -FE. -FU/usr/share/fpcsrc/3.2.2/rtl/units/arm-linux -CaEABIHF -darm -dRELEASE -CaEABIHF  -Us -Sg system.pp
Error: Illegal parameter: -CaEABIHF
--- End code ---

My command line to trigger this was -


--- Code: ---make clean all OS_TARGET=linux CPU_TARGET=arm  CROSSBINDIR=/usr/arm-linux-gnueabihf/bin   CROSSOPT=" -CaEABIHF "
--- End code ---

but I have tried several combinations of CROSSOPT="-CpARMV6 -CfVFPV2 -OoFASTMATH" - that works OK but makes an armel, as soon as I put the -CaEABIHF in there it fails.  Likewise, putting the -CaEABIHF in after the cross compiler and lcl is built triggers a problem when compiling an app.

So, my question is, is -CaEABIHF no longer the way to go, whats its replacement. Or is there some other way to cross compile an armhf binary ?

On a 'real' raspberry pi, the compiler is capable of doing either default or EABIHF, I assume default is armel. But v=cannot find anything written on the subject.

Any ideas please ?

Davo

PascalDragon:
Build FPC as follows:


--- Code: ---make all FPMAKEOPT="-T 4" CPU_TARGET=arm OPT="-dFPC_ARMHF" CROSSOPT="-CpARMV6 -CaEABIHF" BINUTILSPREFIX=arm-linux-gnueabihf-
--- End code ---

(please adjust the BINUTILSPREFIX to whatever you need)

Most important part is the OPT="-dFPC_ARMHF" and the -CpARMV6 is needed to ensure that it runs on older versions of the Pi (default for ARMHF is ARMv7).

You can then build applications without further EABIHF related options:


--- Code: ---> ./compiler/ppcrossarm -n -Furtl/units/arm-linux -viwn -FEtestoutput -XParm-linux-gnueabihf- ./fpctests/thello.pp
Target OS: Linux for ARMHF
Compiling ./fpctests/thello.pp
Linking testoutput/thello
11 lines compiled, 0.2 sec, 202336 bytes code, 47892 bytes data
--- End code ---

Note: I did not install the compiler, thus the manual passing of the general options; if you install it using make crossinstall (with the correct options of course) then you don't need to pass those.

dbannon:
Ah, Pascal Dragon, to my rescue again !

I had just found out about the -dFPC_ARMHF but not the -T 4 so I will need to add that.

I have not tried your full commandline yet but with just the -dFPC_ARMHF I was finally getting a hard float but still not what Debian calls HF, maybe your T 4 will help, thanks, I have been working on this all day !

Thanks

EDIT: Yep, your suggestion (and fixing a typo in my build script) and it all works !   Thanks !

dbannon:
Hmm, I am still unsure of whats happening here.  Lazarus (with no ugly hack to fpc.cfg) does make a armhf binary. See -

 
--- Code: ---dbannon@U2104G-VirtualBox:~/Pascal/ArmTest$ readelf -h project1  | grep Flags
  Flags:                             0x5000400, Version5 EABI, hard-float ABI         <<< NOTE THIS
--- End code ---

But using fpc -Parm or ppcrossarm directly does not. It says it is targeting ARMHF but it lies -


--- Code: ---dbannon@U2104G-VirtualBox:~/Pascal/console$ ppcrossarm -dFPC_ARMHF   hello.pas
Free Pascal Compiler version 3.2.2 [2021/07/23] for arm
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Linux for ARMHF                                             <<< NOTE THIS
Compiling hello.pas
Linking hello
13 lines compiled, 0.2 sec
dbannon@U2104G-VirtualBox:~/Pascal/console$ readelf -h hello | grep Flags
  Flags:                             0x5000200, Version5 EABI, soft-float ABI            <<<< NOTE THIS
dbannon@U2104G-VirtualBox:~/Pascal/console$
--- End code ---

Pascal Dragon, can you please look at the binary arm you made with readelf -h  ?

(I have tried adding things like -CpARMV6, -CaEABIHF and -XParm-linux-gnueabihf- on the compile line, no difference.)

Davo



engkin:
You need to specify what you want using -Cf
Check what the compiler supports using -if

Navigation

[0] Message Index

[#] Next page

Go to full version