Is this the correct way to configure fpc for multiple arm-embedded subarchs?

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

Is this the correct way to configure fpc for multiple arm-embedded subarchs?

Michael Ring-2

I am looking for an easy way to have all cortex-m compilers available at the same time to be able to do automated building/testing

Inspired by the -V parameter of fpc I started my journey and ended up with something different.

My question is now did I go down the correct path or is there a better way to fulfill my requirements:

- I want to be able to switch between armv6m, armv7m and armv7em without the need to build the matching compiler/rtl

- I want lazarus to use fpc as start compiler, I want to be able to configure the whole compiler switching via Project settings.

- I want to be able to use lazbuild so that I can do automated builds of my lazarus projects.

I found this helpful page:

http://wiki.freepascal.org/FPC_Version_Switcher#Setting_the_fpc_frontend_executable_path

but in the end this approach did not work for me, FPC version switcher is not available in lazarus svn (or I am too blind to find it) and in the end I had some issues with using lazbuild when defining the -V switch in my project settings.


In the end I came up with the following approach:

Build ppcrossarm and make sure that the rtls do end up in those directories:

/usr/local/lib/fpc/3.1.1/units/arm-embedded/armv6m/rtl
/usr/local/lib/fpc/3.1.1/units/arm-embedded/armv7m/rtl
/usr/local/lib/fpc/3.1.1/units/arm-embedded/armv7em/rtl

created a softlink so that the crosscompiler can be caled via /usr/local/bin/fpc

ln -sf /usr/local/lib/fpc/3.1.1/ppcrossarm /usr/local/bin/ppcarm

added the following to my /etc/fpc.cfg:

#ifdef embedded
-Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/$fpcsubarch/rtl
#endif

and then I add the following lines to the user-defined project settings in Lazarus:

-Cparmv7em
-XP/usr/local/bin/arm-none-eabi-
-Wpnucleof411re
-dnucleof411re

I thought about putting

-Fu/usr/local/lib/fpc/3.1.1/units/arm-embedded/armv7em/rtl

in the project Settings so that I do not need to tweak /etc/fpc.cfg but I do not like the fact that I have to hardcode paths there, is there a better way? If yes then I'd prefer that a lot over tweaking /etc/fpc.cfg


Michael

------

Here's how I build the cross-compiler:

SUBARCH=armv6m

#SUBARCH=armv7m

#SUBARCH=armv7em

make clean buildbase CROSSINSTALL=1 OS_TARGET=embedded CPU_TARGET=arm SUBARCH=$SUBARCH CROSSOPT="$CROSSOPT" BINUTILSPREFIX=arm-none-eabi- || exit 1
make installbase CROSSINSTALL=1 OS_TARGET=embedded CPU_TARGET=arm SUBARCH=$SUBARCH CROSSOPT="$CROSSOPT" BINUTILSPREFIX=arm-none-eabi- INSTALL_UNITDIR=/usr/local/lib/fpc/3.1.1/units/arm-embedded/$SUBARCH/rtl || exit 1
cp /usr/local/lib/fpc/3.1.1/ppcrossarm /usr/local/lib/fpc/3.1.1/ppcrossarm-$SUBARCH


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

Re: Is this the correct way to configure fpc for multiple arm-embedded subarchs?

Christo Crause
On Sun, 2017-11-26 at 17:19 +0100, Michael Ring wrote:
> I am looking for an easy way to have all cortex-m compilers available
> at the same time to be able to do automated building/testing

There is a similar problem with the AVR target having several
subarchitectures.  One option I think is to have a subarch defined by
the compiler, then it would be easy to lay out the compiled unit
structure in fpc.cfg according to subarch.  I've made an attempt at
adding a subarch define to my local compiler source for AVR, but
haven't developed the idea further.  I'm not a compiler dev so there
may be better options.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Is this the correct way to configure fpc for multiple arm-embedded subarchs?

Florian Klaempfl
Am 29.11.2017 um 06:36 schrieb Christo:

> On Sun, 2017-11-26 at 17:19 +0100, Michael Ring wrote:
>> I am looking for an easy way to have all cortex-m compilers available
>> at the same time to be able to do automated building/testing
>
> There is a similar problem with the AVR target having several
> subarchitectures.  One option I think is to have a subarch defined by
> the compiler, then it would be easy to lay out the compiled unit
> structure in fpc.cfg according to subarch.  I've made an attempt at
> adding a subarch define to my local compiler source for AVR, but
> haven't developed the idea further.  I'm not a compiler dev so there
> may be better options.

Subarch directories are imo the best solution, I have a half-backen patch for this, not yet finished
though.

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

Re: Is this the correct way to configure fpc for multiple arm-embedded subarchs?

Michael Ring-2
Hi Florian!

I would like to work on this patch, can you share it with me?

Thank you,

Michael


Am 03.12.17 um 19:05 schrieb Florian Klämpfl:

> Am 29.11.2017 um 06:36 schrieb Christo:
>> On Sun, 2017-11-26 at 17:19 +0100, Michael Ring wrote:
>>> I am looking for an easy way to have all cortex-m compilers available
>>> at the same time to be able to do automated building/testing
>> There is a similar problem with the AVR target having several
>> subarchitectures.  One option I think is to have a subarch defined by
>> the compiler, then it would be easy to lay out the compiled unit
>> structure in fpc.cfg according to subarch.  I've made an attempt at
>> adding a subarch define to my local compiler source for AVR, but
>> haven't developed the idea further.  I'm not a compiler dev so there
>> may be better options.
> Subarch directories are imo the best solution, I have a half-backen patch for this, not yet finished
> though.
>
> _______________________________________________
> 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
Reply | Threaded
Open this post in threaded view
|

Re: Is this the correct way to configure fpc for multiple arm-embedded subarchs?

Christo Crause
On Mon, 2017-12-04 at 08:22 +0100, Michael Ring wrote:
> Hi Florian!
>
> I would like to work on this patch, can you share it with me?

> Am 03.12.17 um 19:05 schrieb Florian Klämpfl:
> >
> > Am 29.11.2017 um 06:36 schrieb Christo:
> > >
> > > On Sun, 2017-11-26 at 17:19 +0100, Michael Ring wrote:
> > > >
> > > > I am looking for an easy way to have all cortex-m compilers available
> > > > at the same time to be able to do automated building/testing
> > > There is a similar problem with the AVR target having several
> > > subarchitectures.  One option I think is to have a subarch defined by
> > > the compiler, then it would be easy to lay out the compiled unit
> > > structure in fpc.cfg according to subarch.  I've made an attempt at
> > > adding a subarch define to my local compiler source for AVR, but
> > > haven't developed the idea further.  I'm not a compiler dev so there
> > > may be better options.
> > Subarch directories are imo the best solution, I have a half-backen patch for this, not yet
> > finished
> > though.

I've missed a critical bit om information until now - there is a config file macro replacement
option called $FPCSUBARCH available since r29316.  At the moment I've modified my .fpc.cfg to
use the following include to locate RTL units:

#IFDEF EMBEDDED
-Fu~/fpc/$fpcversion/rtl/units/$fpctarget/$FPCSUBARCH/
#ELSE
-Fu~/fpc/$fpcversion/rtl/units/$fpctarget/
#ENDIF

So far I've compiled the AVR RTL for different subarch types, then copied the units into their
respective subdirectories.  Once this is done switching between different controllers
irrespective of subarch type works.

The additional work required is in my opinion:
* Change makefile to automatically compile all available controllers by subarch type and specify
output directory as rtl/units/$FPCTARGET/$FPCSUBARCH/ or as appropriate for directory
configuration.
* Update fpc.cfg template to reflect change in default rtl directory structure.

Not sure if this approach will work for all embedded targets though.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Is this the correct way to configure fpc for multiple arm-embedded subarchs?

Christo Crause
In reply to this post by Michael Ring-2
On Mon, 2017-12-04 at 08:22 +0100, Michael Ring wrote:

> Hi Florian!
>
> I would like to work on this patch, can you share it with me?
>
> Thank you,
>
> Michael
>
>
> Am 03.12.17 um 19:05 schrieb Florian Klämpfl:
> >
> > Am 29.11.2017 um 06:36 schrieb Christo:
> > >
> > > On Sun, 2017-11-26 at 17:19 +0100, Michael Ring wrote:
> > > >
> > > > I am looking for an easy way to have all cortex-m compilers available
> > > > at the same time to be able to do automated building/testing
> > > There is a similar problem with the AVR target having several
> > > subarchitectures.  One option I think is to have a subarch defined by
> > > the compiler, then it would be easy to lay out the compiled unit
> > > structure in fpc.cfg according to subarch.  I've made an attempt at
> > > adding a subarch define to my local compiler source for AVR, but
> > > haven't developed the idea further.  I'm not a compiler dev so there
> > > may be better options.
> > Subarch directories are imo the best solution, I have a half-backen patch for this, not yet
> > finished
> > though.
I've made a script file (attached) that iterates through the different subarchitectures
available for the AVR compiler, calls make and then moves the compiled units to a subdirectory.
I think the logic of this script should be moved to the existing rtl makefile so that all
subarchitectures for a target gets generated and sorted in one go.  Of course then the default
fpc.cfg ideally needs to be updated to reflect the subarch folder structure for ARM and AVR.

I'm putting this out there hoping that someone familiar with the topic and makefile syntax can
help with a patch for FPC.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

build-AVR-embedded-rtl-all.sh (738 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Is this the correct way to configure fpc for multiple arm-embedded subarchs?

Christo Crause
In reply to this post by Michael Ring-2
Michael, I have just noticed a target-subdir folder in svn.freepascal.org/svn/fpc/branches/target-subdir/
It seems as if rev 30766 contains Florian's first modifications to implementation the subarch subfolder option. 


On 4 Dec 2017 9:23 am, "Michael Ring" <[hidden email]> wrote:
Hi Florian!

I would like to work on this patch, can you share it with me?

Thank you,

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: Is this the correct way to configure fpc for multiple arm-embedded subarchs?

Michael Ring-2
In reply to this post by Christo Crause

I am doing something similar to what you are doing, see below....

I also needed to create a softlink so that fpc can call ppcrossarm, it expects to call ppcarm

By using 'INSTALL_UNITDIR' there is no need to copy files at the end.

You will need to do a little tweak in fpc.cfg, after this it is transparent to handle the different subarchs, at least for arm and mipsel ;-)

Now I can use fpc to select matching arch/subarch and Lazarus works just fine.

Michael

fpc-cfg change:

# searchpath for units and other system dependent things
#ifdef embedded
-Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/$fpcsubarch
-Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/$fpcsubarch/*
-Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/$fpcsubarch/rtl
#else
-Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget
-Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/rtl
#endif

--- snip

Buildscript:

  CROSSOPT="-O1 -gw2 -dDEBUG"
  #CROSSOPT="-O1 -gw2 -dDEBUG -godwarfcpp"

  SUBARCH=armv6m
  make clean buildbase CROSSINSTALL=1 OS_TARGET=embedded CPU_TARGET=arm SUBARCH=$SUBARCH CROSSOPT="$CROSSOPT" BINUTILSPREFIX=arm-none-eabi- || exit 1
  make installbase CROSSINSTALL=1 OS_TARGET=embedded CPU_TARGET=arm SUBARCH=$SUBARCH CROSSOPT="$CROSSOPT" BINUTILSPREFIX=arm-none-eabi- INSTALL_UNITDIR=/usr/local/lib/fpc/3.1.1/units/arm-embedded/$SUBARCH/rtl || exit 1
  #mv /usr/local/lib/fpc/3.1.1/ppcrossarm /usr/local/lib/fpc/3.1.1/ppcrossarm-$SUBARCH

  SUBARCH=armv7m
  make clean buildbase CROSSINSTALL=1 OS_TARGET=embedded CPU_TARGET=arm SUBARCH=$SUBARCH CROSSOPT="$CROSSOPT" BINUTILSPREFIX=arm-none-eabi- || exit 1
  make installbase CROSSINSTALL=1 OS_TARGET=embedded CPU_TARGET=arm SUBARCH=$SUBARCH CROSSOPT="$CROSSOPT" BINUTILSPREFIX=arm-none-eabi- INSTALL_UNITDIR=/usr/local/lib/fpc/3.1.1/units/arm-embedded/$SUBARCH/rtl || exit 1
  #mv /usr/local/lib/fpc/3.1.1/ppcrossarm /usr/local/lib/fpc/3.1.1/ppcrossarm-$SUBARCH

  SUBARCH=armv7em
  make clean buildbase CROSSINSTALL=1 OS_TARGET=embedded CPU_TARGET=arm SUBARCH=$SUBARCH CROSSOPT="$CROSSOPT" BINUTILSPREFIX=arm-none-eabi- || exit 1
  make installbase CROSSINSTALL=1 OS_TARGET=embedded CPU_TARGET=arm SUBARCH=$SUBARCH CROSSOPT="$CROSSOPT" BINUTILSPREFIX=arm-none-eabi- INSTALL_UNITDIR=/usr/local/lib/fpc/3.1.1/units/arm-embedded/$SUBARCH/rtl || exit 1
  #cp /usr/local/lib/fpc/3.1.1/ppcrossarm /usr/local/lib/fpc/3.1.1/ppcrossarm-$SUBARCH
  ln -sf /usr/local/lib/fpc/3.1.1/ppcrossarm /usr/local/bin/ppcarm




Am 22.02.18 um 21:35 schrieb Christo:
On Mon, 2017-12-04 at 08:22 +0100, Michael Ring wrote:
Hi Florian!

I would like to work on this patch, can you share it with me?

Thank you,

Michael


Am 03.12.17 um 19:05 schrieb Florian Klämpfl:
Am 29.11.2017 um 06:36 schrieb Christo:
On Sun, 2017-11-26 at 17:19 +0100, Michael Ring wrote:
I am looking for an easy way to have all cortex-m compilers available
at the same time to be able to do automated building/testing
There is a similar problem with the AVR target having several
subarchitectures.  One option I think is to have a subarch defined by
the compiler, then it would be easy to lay out the compiled unit
structure in fpc.cfg according to subarch.  I've made an attempt at
adding a subarch define to my local compiler source for AVR, but
haven't developed the idea further.  I'm not a compiler dev so there
may be better options.
Subarch directories are imo the best solution, I have a half-backen patch for this, not yet
finished
though.
I've made a script file (attached) that iterates through the different subarchitectures
available for the AVR compiler, calls make and then moves the compiled units to a subdirectory.
I think the logic of this script should be moved to the existing rtl makefile so that all
subarchitectures for a target gets generated and sorted in one go.  Of course then the default
fpc.cfg ideally needs to be updated to reflect the subarch folder structure for ARM and AVR.

I'm putting this out there hoping that someone familiar with the topic and makefile syntax can
help with a patch for FPC.


_______________________________________________
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