Cross compile from x86 to Pi

classic Classic list List threaded Threaded
28 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Cross compile from x86 to Pi

Chris Moody
Hi all,

I think my project is almost done, wanted to see how fast it ran under the Pi which its destined to be on. After spending a long time trying to get it to compile there I decided I'd see if cross compiling may be any faster.

Is there a better guide on how to do this than: http://wiki.freepascal.org/fpcup#Linux_ARM_cross_compiler ? specifically as far as this sentence is concerned:

  • Linux/Unix build or install the relevant crossbinutils (Linux, unix)

Thanks in advance!

Chris



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross compile from x86 to Pi

Karoly Balogh (Charlie/SGR)
Hi,

On Sat, 15 Aug 2015, Chris Moody wrote:

> Is there a better guide on how to do this than:
> http://wiki.freepascal.org/fpcup#Linux_ARM_cross_compiler ? specifically as far as this
> sentence is concerned:
>
>  *  Linux/Unix build or install the relevant crossbinutils (Linux, unix)

With Ubuntu/Debian:
- apt-get install binutils-arm-linux-gnueabihf

The various binutils executables will be available then as
arm-linux-gnueabihf-*, so you need to use parameter
-XParm-linux-gnueabihf- when invoking the compiler.

If you're using a different Linux distribution, look up a similar package
in your distribution, most bigger distros provide cross-binutils packages
these days for ARM.

You can also build cross-binutils from source, but that's not FPC specific
at all. Among many others, this GCC cross-howto explains how to build a
cross binutils (see chapter 1):

http://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/

But on the RPi, instead of TARGET=aarch64-linux one has to use
TARGET=arm-linux-gnueabihf, if I'm correct.

Charlie
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross compile from x86 to Pi

Chris Moody


On 08/15/2015 06:40 PM, Karoly Balogh (Charlie/SGR) wrote:

> Hi,
>
> On Sat, 15 Aug 2015, Chris Moody wrote:
>
>> Is there a better guide on how to do this than:
>> http://wiki.freepascal.org/fpcup#Linux_ARM_cross_compiler ? specifically as far as this
>> sentence is concerned:
>>
>>   *  Linux/Unix build or install the relevant crossbinutils (Linux, unix)
> With Ubuntu/Debian:
> - apt-get install binutils-arm-linux-gnueabihf
>
> The various binutils executables will be available then as
> arm-linux-gnueabihf-*, so you need to use parameter
> -XParm-linux-gnueabihf- when invoking the compiler.
>
> If you're using a different Linux distribution, look up a similar package
> in your distribution, most bigger distros provide cross-binutils packages
> these days for ARM.
>
> You can also build cross-binutils from source, but that's not FPC specific
> at all. Among many others, this GCC cross-howto explains how to build a
> cross binutils (see chapter 1):
>
> http://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/
>
> But on the RPi, instead of TARGET=aarch64-linux one has to use
> TARGET=arm-linux-gnueabihf, if I'm correct.
>
> Charlie
>
Thanks for that Charlie, I now have that installed. Do I have to do the
compile with fpc? or can I do it via Lazarus?
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross compile from x86 to Pi

Karoly Balogh (Charlie/SGR)
Hi,

On Sat, 15 Aug 2015, Chris Moody wrote:

> > > Is there a better guide on how to do this than:
> > > http://wiki.freepascal.org/fpcup#Linux_ARM_cross_compiler ? specifically
> > > as far as this
> > > sentence is concerned:
> > >
> > >   *  Linux/Unix build or install the relevant crossbinutils (Linux, unix)
> > With Ubuntu/Debian:
> > - apt-get install binutils-arm-linux-gnueabihf
> >
> > **snip**
>
> Thanks for that Charlie, I now have that installed. Do I have to do the
> compile with fpc? or can I do it via Lazarus?

I'm pretty sure it's possible with Lazarus, but I can't give exact
instructions, because I rarely use Lazarus, I prefer using the compiler
itself directly from the command line.

However, this page has some pointers:
http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARM#Make_your_first_arm-linux_project_in_Lazarus

Charlie
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross compile from x86 to Pi

Chris Moody


On 08/15/2015 07:40 PM, Karoly Balogh (Charlie/SGR) wrote:
Hi,

On Sat, 15 Aug 2015, Chris Moody wrote:

Is there a better guide on how to do this than:
http://wiki.freepascal.org/fpcup#Linux_ARM_cross_compiler ? specifically
as far as this
sentence is concerned:

  *  Linux/Unix build or install the relevant crossbinutils (Linux, unix)
With Ubuntu/Debian:
- apt-get install binutils-arm-linux-gnueabihf

**snip**
Thanks for that Charlie, I now have that installed. Do I have to do the
compile with fpc? or can I do it via Lazarus?
I'm pretty sure it's possible with Lazarus, but I can't give exact
instructions, because I rarely use Lazarus, I prefer using the compiler
itself directly from the command line.

However, this page has some pointers:
http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARM#Make_your_first_arm-linux_project_in_Lazarus

Charlie
_______________________________________________

Looks like I need to recompile FPC (or make a special compile of it) to be able to compile to ARM.

That URL you gave me says how to compile it, but not sure about if I need to have some special cross compile code for the CROSSBINDIR=/home/user/lazarus/fpc/binutils/ portion of it, or do I just point it to where Linux installed the items installed with apt-get install binutils-arm-linux-gnueabihf ?

Thanks once again!

Chris


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross compile from x86 to Pi

Martin Schreiber-2
In reply to this post by Chris Moody
On Sunday 16 August 2015 02:33:24 Chris Moody wrote:
> Hi all,
>
> I think my project is almost done, wanted to see how fast it ran under
> the Pi which its destined to be on. After spending a long time trying to
> get it to compile there I decided I'd see if cross compiling may be any
> faster.
>
I use MSEide in order to cross compile and do remote debugging from Linux x86
to Raspberry Pi. With that setup it is possible to work on the X86 PC like
locally on the Pi - solely faster.
Linux x86 -> arm cross environments with cross FPC, cross binutils and cross
gdb are here:
http://sourceforge.net/projects/mseide-msegui/files/fpcrossarm/

MSEide has a project template for cross-Pi development, please read
MSEide+MSEgui README.TXT.
For GUI on the Pi I use MSEgui which is extremely fast. Also MSEide runs
amazingly fast on Pi, the problem is long FPC compilation times.

FPC fixes_3_0 needs current git master MSEide+MSEgui from here:
https://gitlab.com/mseide-msegui/mseide-msegui

Please ask questions on the mailinglist:
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Mail archive:
http://www.mail-archive.com/mseide-msegui-talk@.../
NNTP gateway:
nntp://news.gmane.org/gmane.comp.ide.mseide.user

Martin
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross compile from x86 to Pi

Chris Moody


On 08/15/2015 11:37 PM, Martin Schreiber wrote:

> On Sunday 16 August 2015 02:33:24 Chris Moody wrote:
>> Hi all,
>>
>> I think my project is almost done, wanted to see how fast it ran under
>> the Pi which its destined to be on. After spending a long time trying to
>> get it to compile there I decided I'd see if cross compiling may be any
>> faster.
>>
> I use MSEide in order to cross compile and do remote debugging from Linux x86
> to Raspberry Pi. With that setup it is possible to work on the X86 PC like
> locally on the Pi - solely faster.
> Linux x86 -> arm cross environments with cross FPC, cross binutils and cross
> gdb are here:
> http://sourceforge.net/projects/mseide-msegui/files/fpcrossarm/
>
> MSEide has a project template for cross-Pi development, please read
> MSEide+MSEgui README.TXT.
> For GUI on the Pi I use MSEgui which is extremely fast. Also MSEide runs
> amazingly fast on Pi, the problem is long FPC compilation times.
>
> FPC fixes_3_0 needs current git master MSEide+MSEgui from here:
> https://gitlab.com/mseide-msegui/mseide-msegui
>
> Please ask questions on the mailinglist:
> https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
> Mail archive:
> http://www.mail-archive.com/mseide-msegui-talk@.../
> NNTP gateway:
> nntp://news.gmane.org/gmane.comp.ide.mseide.user
>
> Martin
> _______________________________________________
>
Thanks for that Martin, my app is actually just console based (I used
Lazarus because I didn't want to use the text based IDE), would you
still recommend this route?

Thanks,

Chris
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross compile from x86 to Pi

Martin Schreiber-2
On Sunday 16 August 2015 15:14:23 Chris Moody wrote:
>
> Thanks for that Martin, my app is actually just console based (I used
> Lazarus because I didn't want to use the text based IDE), would you
> still recommend this route?
>
Sure. MSEide opens on the X86 PC a xterm where the gdb remote session runs,
please see screenshot:
http://mseide-msegui.sourceforge.net/pics/crossarm.png

Martin
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross compile from x86 to Pi

Michael Schnell
In reply to this post by Chris Moody
Cross compiling with fpc is not for that faint of heard. (Been there
some years ago)

Please let us know where you get.


-Michael
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross compile from x86 to Pi

Michael Schnell
In reply to this post by Martin Schreiber-2
On 08/16/2015 08:37 AM, Martin Schreiber wrote:
> MSEide has a project template for cross-Pi development,

Great, Martin ! (As always :-) )

I once unsuccessfully tried to do cross compiling and remote debugging
for my ARM based (GUI-less) QNAP NAS. I finally  compiled the project
locally which was no real problem, as I could test the complete software
on a PC before moving it to the NAS.

-Michael
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross compile from x86 to Pi

Karoly Balogh (Charlie/SGR)
In reply to this post by Michael Schnell
Hi,

On Mon, 17 Aug 2015, Michael Schnell wrote:

> Cross compiling with fpc is not for that faint of heard. (Been there some
> years ago)

Well, I do it 8 hours a day for a living, actually... :) I think it's
really easy these days, if you know some basics about the build system
(most of which is available from the Wiki), and how the some of the
dependencies work (binutils, mainly). Basically you can have a working
crosscompiler setup with a *single* make command in about two minutes, to
almost any system which you have binutils installed for. I wouldn't call
that hard.

And it's especially super-easy these days, when you can test most of your
cross-setup outputs on a Linux/x86 box, thanks to the user-space emulation
of a good binfmts/QEMU setup (again, available out-of-box with some
packages on Ubuntu/Debian). You don't even have to copy over to an ARM
(etc.) box...

Of course, wiring it into an IDE is a different question, that I don't
know (and don't use)...

Charlie
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross compile from x86 to Pi

Michael Schnell
On 08/17/2015 02:15 PM, Karoly Balogh (Charlie/SGR) wrote:
>  Of course, wiring it into an IDE is a different question, that I
> don't know (and don't use)...
That is what I was trying to do.

In fact Lazarus provides settings for OS and Arch to be used. But I did
not get this to work at that time.

Configuring a remote debugger for Lazarus is even harder.

There are two possible ways to do that: "remote gdb" and using the
normal gdb on the target and connecting via SSH.

Remote gdb:
  - I had not been able to create the gdb (x85) / gdbserver(ARM) pair
(not an fpc issue at all)
  - I read that remote gdb does not allow for manually stopping a
running program under debug if no breakpoint is reached (so it does not
seem very desirable)

SSH:
There is code for this in Lazarus, but it is commented out. I did not
have enough spare time to take a deeper look at that.

So we (me and a nice guy from Vienna who already started to write a
documentation on Lazarus cross compiling and remote debugging, which I
promised to translate into English) gave up.

-Michael
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross compile from x86 to Pi

Chris Moody
In reply to this post by Karoly Balogh (Charlie/SGR)


On 08/17/2015 05:15 AM, Karoly Balogh (Charlie/SGR) wrote:

> Hi,
>
> On Mon, 17 Aug 2015, Michael Schnell wrote:
>
>> Cross compiling with fpc is not for that faint of heard. (Been there some
>> years ago)
> Well, I do it 8 hours a day for a living, actually... :) I think it's
> really easy these days, if you know some basics about the build system
> (most of which is available from the Wiki), and how the some of the
> dependencies work (binutils, mainly). Basically you can have a working
> crosscompiler setup with a *single* make command in about two minutes, to
> almost any system which you have binutils installed for. I wouldn't call
> that hard.
>
> And it's especially super-easy these days, when you can test most of your
> cross-setup outputs on a Linux/x86 box, thanks to the user-space emulation
> of a good binfmts/QEMU setup (again, available out-of-box with some
> packages on Ubuntu/Debian). You don't even have to copy over to an ARM
> (etc.) box...
>
> Of course, wiring it into an IDE is a different question, that I don't
> know (and don't use)...
>
> Charlie
> _______________________________________________
>
Hi again Charlie,

Do you use the MSEide software to do the cross compiling? or do you just
call fpc with the right parameters?

Mind sharing your setup?

Thanks,

Chris
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross compile from x86 to Pi

Martin Schreiber-2
In reply to this post by Michael Schnell
On Monday 17 August 2015 15:42:36 Michael Schnell wrote:
>
> Remote gdb:
>   - I had not been able to create the gdb (x85) / gdbserver(ARM) pair
> (not an fpc issue at all)
>   - I read that remote gdb does not allow for manually stopping a
> running program under debug if no breakpoint is reached (so it does not
> seem very desirable)
>
This works with MSEide.

Martin
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross compile from x86 to Pi

Chris Moody
In reply to this post by Chris Moody


On 08/15/2015 08:46 PM, Chris Moody wrote:


On 08/15/2015 07:40 PM, Karoly Balogh (Charlie/SGR) wrote:
Hi,

On Sat, 15 Aug 2015, Chris Moody wrote:

Is there a better guide on how to do this than:
http://wiki.freepascal.org/fpcup#Linux_ARM_cross_compiler ? specifically
as far as this
sentence is concerned:

  *  Linux/Unix build or install the relevant crossbinutils (Linux, unix)
With Ubuntu/Debian:
- apt-get install binutils-arm-linux-gnueabihf

**snip**
Thanks for that Charlie, I now have that installed. Do I have to do the
compile with fpc? or can I do it via Lazarus?
I'm pretty sure it's possible with Lazarus, but I can't give exact
instructions, because I rarely use Lazarus, I prefer using the compiler
itself directly from the command line.

However, this page has some pointers:
http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARM#Make_your_first_arm-linux_project_in_Lazarus

Charlie
_______________________________________________

Looks like I need to recompile FPC (or make a special compile of it) to be able to compile to ARM.

That URL you gave me says how to compile it, but not sure about if I need to have some special cross compile code for the CROSSBINDIR=/home/user/lazarus/fpc/binutils/ portion of it, or do I just point it to where Linux installed the items installed with apt-get install binutils-arm-linux-gnueabihf ?

Thanks once again!

Chris

So I tried to compile a special version of FPC for arm, I installed: binutils-2.25

And I got as far as this:

/home/chris/Documents/fp/fpcbuild-2.6.4/binutils/bin/as  -o /home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc/rtl/units/arm-linux/prt0.o arm/prt0.as
arm/prt0.as: Assembler messages:
arm/prt0.as:46: Error: unrecognized symbol type ""
arm/prt0.as:49: Error: expecting operand after ','; got nothing
arm/prt0.as:50: Error: no such instruction: `ldmia sp!,{a2}'
arm/prt0.as:53: Error: no such instruction: `ldr ip,=operatingsystem_parameter_argc'
arm/prt0.as:54: Error: no such instruction: `ldr a3,=operatingsystem_parameter_argv'
arm/prt0.as:55: Error: invalid char '[' beginning operand 2 `[ip]'
arm/prt0.as:58: Error: too many memory references for `add'
arm/prt0.as:59: Error: too many memory references for `add'
arm/prt0.as:60: Error: no such instruction: `ldr ip,=operatingsystem_parameter_envp'
arm/prt0.as:62: Error: invalid char '[' beginning operand 2 `[a3]'
arm/prt0.as:63: Error: invalid char '[' beginning operand 2 `[ip]'
arm/prt0.as:66: Error: no such instruction: `ldr ip,=__stkptr'
arm/prt0.as:67: Error: invalid char '[' beginning operand 2 `[ip]'
arm/prt0.as:69: Error: too many memory references for `sub'
arm/prt0.as:72: Error: no such instruction: `bl PASCALMAIN'
arm/prt0.as:75: Error: unrecognized symbol type ""
arm/prt0.as:78: Error: no such instruction: `swi 0x900001'
arm/prt0.as:79: Error: no such instruction: `b _haltproc'
arm/prt0.as:82: Error: unrecognized symbol type ""
arm/prt0.as:84: Error: no such instruction: `ldr r0,=operatingsystem_result'
arm/prt0.as:85: Error: no such instruction: `ldrb r0,[r0]'
arm/prt0.as:86: Error: expecting operand after ','; got nothing
arm/prt0.as:87: Error: no such instruction: `swi 0x0'
arm/prt0.as:88: Error: no such instruction: `b _haltproc_eabi'
make[6]: *** [prt0.o] Error 1
make[6]: Leaving directory `/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc/rtl/linux'
make[5]: *** [linux_all] Error 2
make[5]: Leaving directory `/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc/rtl'
make[4]: *** [rtl] Error 2
make[4]: Leaving directory `/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc/compiler'
make[3]: *** [cycle] Error 2
make[3]: Leaving directory `/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc/compiler'
make[2]: *** [compiler_cycle] Error 2
make[2]: Leaving directory `/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc'
make[1]: *** [build-stamp.arm-linux] Error 2
make[1]: Leaving directory `/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc'
make: *** [fpcsrc/build-stamp.arm-linux] Error 2


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross compile from x86 to Pi

Michael Schnell
In reply to this post by Martin Schreiber-2
On 08/17/2015 09:55 PM, Martin Schreiber wrote:
>
> This works with MSEide.
>
GREAT !

So MSE IDE does use GDBServer and not native ARM GDB remote controlled
by SSH ? Or is this selectable ?

When I did that research, I had the impression that SSH would be
preferable (whenever Ethernet is installed).

(Now as there will be new fast low-power Intel CPUs available for
embedded use (e.g. on Q7 boards) I have no hope any more that the
company ever will port the huge Delphi project they maintain to ARM. So
I am free to privately move from Lazarus to MSEIDE :-) :-) :-) )

-Michael
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross compile from x86 to Pi

Martin Schreiber-2
Am 18.08.2015 08:44, schrieb Michael Schnell:
> On 08/17/2015 09:55 PM, Martin Schreiber wrote:
>>
>> This works with MSEide.
>>
> GREAT !
>
> So MSE IDE does use GDBServer and not native ARM GDB remote controlled
> by SSH ?

Yes. Or a local gdbserver which communicates by a proxy with a hardware
debug interface like Segger J-Link or "AVR ONE!" for example.

  Or is this selectable ?
>
I assume one could setup a ssh tunnel -> remote native ARM gdb too, I
never tried it.

Martin
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross compile from x86 to Pi

Michael Schnell
On 08/18/2015 08:54 AM, Martin Schreiber wrote:
>
> I assume one could setup a ssh tunnel -> remote native ARM gdb too, I
> never tried it.
>

I feel it even would be easier to do than using gdbserver, as - after
setting up the SSH connection - the IDE would just use the same commands
with the remote gdb as it would with a local one and there would not
need to be a dedicated X86->ARM-Cross - "gdbremote" executable on the
IDE site not a (rather uncommon) GDBServer executable on the ARM site.

The big advantage of a GDBRemote/GDBServer setup is that it can use a
serial interface and that it uses up very little RAM on the ARM Site.
But I feel that this nowadays is not very important any more.

-Michael
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross compile from x86 to Pi

Martin Schreiber-2
Am 18.08.2015 09:01, schrieb Michael Schnell:

> On 08/18/2015 08:54 AM, Martin Schreiber wrote:
>>
>> I assume one could setup a ssh tunnel -> remote native ARM gdb too, I
>> never tried it.
>>
>
> I feel it even would be easier to do than using gdbserver, as - after
> setting up the SSH connection - the IDE would just use the same commands
> with the remote gdb as it would with a local one and there would not
> need to be a dedicated X86->ARM-Cross - "gdbremote" executable on the
> IDE site not a (rather uncommon) GDBServer executable on the ARM site.
>
The already several times mentioned cross environment from here:
http://sourceforge.net/projects/mseide-msegui/files/fpcrossarm/
works well for me.

Martin
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross compile from x86 to Pi

Michael Ring-2
In reply to this post by Chris Moody
This is how I build fpc trunk cross compiler:

  echo "Building fpchf-linux from trunk"
  SUBARCH=armv7
  CROSSOPT="-dREVINC -dFPC_ARMHF -CX -CpARMV7A -CfVFPV3_D16 -OpARMV7A -O2 -OoFASTMATH -XX -Xs"
  //CROSSOPT="-dREVINC -dFPC_ARMHF -CX -CpARMV6 -CfVFPV2 -OpARMV6 -O2 -OoFASTMATH -XX -Xs"
  OPT="-dFPC_ARMHF"
  make clean buildbase  CROSSINSTALL=1 OS_TARGET=linux CPU_TARGET=arm  OPT="$OPT" OVERRIDEVERSIONCHECK=1 CROSSOPT="$CROSSOPT" BINUTILSPREFIX=arm-linux-gnueabihf- || exit 1
  sudo make installbase CROSSINSTALL=1 OS_TARGET=linux CPU_TARGET=arm  OPT="$OPT" OVERRIDEVERSIONCHECK=1 CROSSOPT="$CROSSOPT" BINUTILSPREFIX=arm-linux-gnueabihf- || exit 1
  sudo mv /usr/local/lib/fpc/3.1.1/ppcrossarm /usr/local/lib/fpc/3.1.1/ppcrossarmhf

Please note that the rtl is fine for Raspberry Pi 2 (the new quad core board) as this is a version that uses armv7 commandset.

For old Raspberry Pi you need to use the commented out CROSSOPT, this will create rtl that is suitable for old raspberries.

You should not try to use fpc 2.6.4 as this compiler does not support armhf. Most likely the 3.0 pre-release will compile the same way, but I never tried.

You need to have cross-binutils installed as you need arm-linux-gnueabihf-* tools to be able to successfully compile.

Michael
 
Am 18.08.15 um 04:16 schrieb Chris Moody:


On 08/15/2015 08:46 PM, Chris Moody wrote:


On 08/15/2015 07:40 PM, Karoly Balogh (Charlie/SGR) wrote:
Hi,

On Sat, 15 Aug 2015, Chris Moody wrote:

Is there a better guide on how to do this than:
http://wiki.freepascal.org/fpcup#Linux_ARM_cross_compiler ? specifically
as far as this
sentence is concerned:

  *  Linux/Unix build or install the relevant crossbinutils (Linux, unix)
With Ubuntu/Debian:
- apt-get install binutils-arm-linux-gnueabihf

**snip**
Thanks for that Charlie, I now have that installed. Do I have to do the
compile with fpc? or can I do it via Lazarus?
I'm pretty sure it's possible with Lazarus, but I can't give exact
instructions, because I rarely use Lazarus, I prefer using the compiler
itself directly from the command line.

However, this page has some pointers:
http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARM#Make_your_first_arm-linux_project_in_Lazarus

Charlie
_______________________________________________

Looks like I need to recompile FPC (or make a special compile of it) to be able to compile to ARM.

That URL you gave me says how to compile it, but not sure about if I need to have some special cross compile code for the CROSSBINDIR=/home/user/lazarus/fpc/binutils/ portion of it, or do I just point it to where Linux installed the items installed with apt-get install binutils-arm-linux-gnueabihf ?

Thanks once again!

Chris

So I tried to compile a special version of FPC for arm, I installed: binutils-2.25

And I got as far as this:

/home/chris/Documents/fp/fpcbuild-2.6.4/binutils/bin/as  -o /home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc/rtl/units/arm-linux/prt0.o arm/prt0.as
arm/prt0.as: Assembler messages:
arm/prt0.as:46: Error: unrecognized symbol type ""
arm/prt0.as:49: Error: expecting operand after ','; got nothing
arm/prt0.as:50: Error: no such instruction: `ldmia sp!,{a2}'
arm/prt0.as:53: Error: no such instruction: `ldr ip,=operatingsystem_parameter_argc'
arm/prt0.as:54: Error: no such instruction: `ldr a3,=operatingsystem_parameter_argv'
arm/prt0.as:55: Error: invalid char '[' beginning operand 2 `[ip]'
arm/prt0.as:58: Error: too many memory references for `add'
arm/prt0.as:59: Error: too many memory references for `add'
arm/prt0.as:60: Error: no such instruction: `ldr ip,=operatingsystem_parameter_envp'
arm/prt0.as:62: Error: invalid char '[' beginning operand 2 `[a3]'
arm/prt0.as:63: Error: invalid char '[' beginning operand 2 `[ip]'
arm/prt0.as:66: Error: no such instruction: `ldr ip,=__stkptr'
arm/prt0.as:67: Error: invalid char '[' beginning operand 2 `[ip]'
arm/prt0.as:69: Error: too many memory references for `sub'
arm/prt0.as:72: Error: no such instruction: `bl PASCALMAIN'
arm/prt0.as:75: Error: unrecognized symbol type ""
arm/prt0.as:78: Error: no such instruction: `swi 0x900001'
arm/prt0.as:79: Error: no such instruction: `b _haltproc'
arm/prt0.as:82: Error: unrecognized symbol type ""
arm/prt0.as:84: Error: no such instruction: `ldr r0,=operatingsystem_result'
arm/prt0.as:85: Error: no such instruction: `ldrb r0,[r0]'
arm/prt0.as:86: Error: expecting operand after ','; got nothing
arm/prt0.as:87: Error: no such instruction: `swi 0x0'
arm/prt0.as:88: Error: no such instruction: `b _haltproc_eabi'
make[6]: *** [prt0.o] Error 1
make[6]: Leaving directory `/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc/rtl/linux'
make[5]: *** [linux_all] Error 2
make[5]: Leaving directory `/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc/rtl'
make[4]: *** [rtl] Error 2
make[4]: Leaving directory `/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc/compiler'
make[3]: *** [cycle] Error 2
make[3]: Leaving directory `/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc/compiler'
make[2]: *** [compiler_cycle] Error 2
make[2]: Leaving directory `/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc'
make[1]: *** [build-stamp.arm-linux] Error 2
make[1]: Leaving directory `/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc'
make: *** [fpcsrc/build-stamp.arm-linux] Error 2



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
12