Recent

Author Topic: [SOLVED] ARM (stm32) Circular reference  (Read 712 times)

Maslan

  • Newbie
  • Posts: 3
[SOLVED] ARM (stm32) Circular reference
« on: January 18, 2023, 02:04:30 pm »
Hi!

I have a little trouble with cross compiling for ARM architecture.
FPC+Lazarus+cross libs and ppcarm installed/built with  FpcUpDeluxe. Path are configured (-Fu..., -Fl...  in the fpc.cfg)

When trying to compile empty project :
Code: Pascal  [Select][+][-]
  1. program project1;
  2. begin
  3. end.

getting error:
Quote
(1002) Target OS: Embedded
(3104) Compiling project1.lpr
(3104) Compiling /opt/Laz_stable/fpcsrc/rtl/embedded/arm/stm32f407xx.pp
(3104) Compiling /opt/Laz_stable/fpcsrc/rtl/embedded/arm/stm32f407xx.pp
/opt/Laz_stable/fpcsrc/rtl/embedded/arm/stm32f407xx.pp(9,1) Fatal: (10020) Circular unit reference between stm32f407xx and stm32f407xx
Fatal: (1018) Compilation aborted

The unit stm32f407xx.pp is included by parameter -WpDISCOVERYF407VG ,
and has no direct pointer in the Uses clause nor any uses inside unit itself.
But it still cause error "Circular unit reference...".

I have tried several version fpc, lazarus. Have tried to compile from IDE and from console with fpc and ppcarm itself.

With omitting -WpDISCOVERYF407VG  specification makes success(say no error) compilation from console with warnings:
Quote
/opt/Laz_stable/cross/bin/arm-embedded/arm-none-eabi-ld:/opt/Laz_stable/projects/link16829.res:27: warning: memory region `ram' not declared
/opt/Laz_stable/cross/bin/arm-embedded/arm-none-eabi-ld: /opt/Laz_stable/projects/project1.elf: warning: allocated section `.data' not in segment
but from IDE, still can't compile with errors:
Quote
Error: /opt/Laz_stable/cross/bin/arm-embedded/arm-none-eabi-ld:/opt/Laz_stable/projects/link16598.res:27: warning: memory region `ram' not declared
Error: /opt/Laz_stable/cross/bin/arm-embedded/arm-none-eabi-ld: /opt/Laz_stable/projects/project1.elf: warning: allocated section `.data' not in segment

While compiling without -WpDISCOVERYF407VG it is producing 3 files: bin, elf, hex
*.elf file is:
Quote
/opt/Laz_stable/projects/project1.elf: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), no program header, not stripped
00000000 d $d
00000000 A _bss_end
00000000 N _bss_start
00000000 D _data
00000046 D _edata
00000000 A _end
00000000 T _etext
00000000 d __fpc_ident
00000000 T _text_start



Does anybody has a working manual to build firmware for stm32F407Discovey ?


Linux ubuntu 22.10 x64.
Laz 2.2.4
Free Pascal Compiler version 3.2.2-rrelease_3_2_2-0-g0d122c4953 [2023/01/18] for x86_64

Full procject build command:       
Quote
/opt/Laz_stable/fpc/bin/x86_64-linux/fpc.sh -B  -Tembedded -Parm -CpARMV7M -MObjFPC -Scghi -O1 -l -vewnhibq -Fi/opt/Laz_stable/projects/lib/arm-embedded -Fl/opt/Laz_stable/cross/lib/arm-embedded/armv7m/eabi -Fu/opt/Laz_stable/fpc/units/arm-embedded/armv7m/eabi/rtl -Fu/opt/Laz_stable/projects/ -FU/opt/Laz_stable/projects/lib/arm-embedded/ -FE/opt/Laz_stable/projects/ -o/opt/Laz_stable/projects/project1 -WpDISCOVERYF407VG project1.lpr


Thanks.
« Last Edit: February 07, 2023, 08:11:09 am by Maslan »

PascalDragon

  • Hero Member
  • *****
  • Posts: 5462
  • Compiler Developer
Re: ARM (stm32) Circular reference
« Reply #1 on: January 18, 2023, 10:26:51 pm »
getting error:
Quote
(1002) Target OS: Embedded
(3104) Compiling project1.lpr
(3104) Compiling /opt/Laz_stable/fpcsrc/rtl/embedded/arm/stm32f407xx.pp
(3104) Compiling /opt/Laz_stable/fpcsrc/rtl/embedded/arm/stm32f407xx.pp
/opt/Laz_stable/fpcsrc/rtl/embedded/arm/stm32f407xx.pp(9,1) Fatal: (10020) Circular unit reference between stm32f407xx and stm32f407xx
Fatal: (1018) Compilation aborted

The unit stm32f407xx.pp is included by parameter -WpDISCOVERYF407VG ,
and has no direct pointer in the Uses clause nor any uses inside unit itself.
But it still cause error "Circular unit reference...".

You need to make sure that FPC only uses the compiled units of the embedded RTL, not the source. The point is that -Wp<x> by design includes the controller's unit in any unit the compiler compiles. The embedded RTL itself is compiled without any -Wp<x> switch, thus no controller unit is added there.

Full procject build command:       
Quote
/opt/Laz_stable/fpc/bin/x86_64-linux/fpc.sh -B  -Tembedded -Parm -CpARMV7M -MObjFPC -Scghi -O1 -l -vewnhibq -Fi/opt/Laz_stable/projects/lib/arm-embedded -Fl/opt/Laz_stable/cross/lib/arm-embedded/armv7m/eabi -Fu/opt/Laz_stable/fpc/units/arm-embedded/armv7m/eabi/rtl -Fu/opt/Laz_stable/projects/ -FU/opt/Laz_stable/projects/lib/arm-embedded/ -FE/opt/Laz_stable/projects/ -o/opt/Laz_stable/projects/project1 -WpDISCOVERYF407VG project1.lpr

Judging by this either your fpc.sh or the configuration file used by FPC contains a reference to the source path that must not be there.

Maslan

  • Newbie
  • Posts: 3
Re: ARM (stm32) Circular reference
« Reply #2 on: January 18, 2023, 11:42:01 pm »
Many thanks!!!


Indeed, i have added source dir to fpc path, due to previous error "Can't find unit..".
I have checked local file right now:
Quote
[root@Lazarus arm-embedded]# locate stm32f407 -i
/opt/Laz_stable/fpcsrc/rtl/embedded/arm/stm32f407xx.pp
There are no compiled units. Not .ppu, nor .o for linking.

Did you know how i can compile UNITS to include them without source ?

PascalDragon

  • Hero Member
  • *****
  • Posts: 5462
  • Compiler Developer
Re: ARM (stm32) Circular reference
« Reply #3 on: January 19, 2023, 09:33:58 pm »
Quote
[root@Lazarus arm-embedded]# locate stm32f407 -i
/opt/Laz_stable/fpcsrc/rtl/embedded/arm/stm32f407xx.pp
There are no compiled units. Not .ppu, nor .o for linking.

Did you know how i can compile UNITS to include them without source ?

Then fpcupdeluxe didn't compile the RTL for arm-embedded correctly. So control that and make sure that it compiles the units and provides a suitable configuration.

Maslan

  • Newbie
  • Posts: 3
Re: ARM (stm32) Circular reference
« Reply #4 on: February 07, 2023, 08:09:56 am »
Quote
[root@Lazarus arm-embedded]# locate stm32f407 -i
/opt/Laz_stable/fpcsrc/rtl/embedded/arm/stm32f407xx.pp
There are no compiled units. Not .ppu, nor .o for linking.

Did you know how i can compile UNITS to include them without source ?

Then fpcupdeluxe didn't compile the RTL for arm-embedded correctly. So control that and make sure that it compiles the units and provides a suitable configuration.

many-many ThANKS!  I've spent some time and found whether FPCUpDeluxe should build modules!.

Sharing solution:
*Manual compile for each file:
/opt/fpcupdeluxe/fpc/bin/x86_64-linux/ppcrossarm -Cparmv7m -Ur -Tembedded -Parm -XParm-none-eabi- -Ur -Xs -O2 -n -Fi../inc -Fi../arm -FD/opt/fpcupdeluxe/cross/bin/arm-embedded -FE. -FU/opt/fpcupdeluxe/fpcsrc/rtl/units/arm-embedded -vw-n-h-l-d-u-t-p-c- -dFPC_ARMHF -darm -dRELEASE -CaEABI -XParm-none-eabi- -Xd -Fl/opt/fpcupdeluxe/cross/lib/arm-embedded/armv7m/eabi -g arm/stm32*****.pp
OR
*Target FPCUpDeluxe against subarchitecture[ armv7Em

 

TinyPortal © 2005-2018