Recent

Author Topic: Setting up an ARM embedded project?  (Read 4103 times)

Ruptor

  • Full Member
  • ***
  • Posts: 201
Setting up an ARM embedded project?
« on: July 10, 2025, 10:29:23 pm »
I managed to blunder through the setup of Lazarus & FPC trunk using fpcupdeluxe after installing the prerequisites as given here:
https://github.com/LongDirtyAnimAlf/fpcupdeluxe
and following the wiki instructions here:
https://wiki.freepascal.org/ARM_Embedded_Tutorial_-_Entry_FPC_and_STM32
but after completing the cross compiler build the wheels have fallen off.
The instructions started to go wrong with a minor thing
    "Tools > Reread FPC source code directory"
should be rescan not reread. I moved on to the simple project.
After guessing Settings is Options where is this?
"Project > Project Settings ... > Configuration and Goals"
Elsewhere under
Tools > Configure "Build Lazarus"
I could set arm & embedded then I did rescan and it said system.ppu not found in fpc binary so is more screwed up.
Is there alternative instructions to do a simple arm project.
Eventually under project options I have done some of the settings in config target > embedded, arm & armv7m settings but not -WpSTM32F103X8 & what about the fpc.cfg? I am a bit lost so any help will be appreciated.

Laksen

  • Hero Member
  • *****
  • Posts: 802
    • J-Software
Re: Setting up an ARM embedded project?
« Reply #1 on: July 10, 2025, 10:38:55 pm »
Which chip are you targetting?

You can do it in two steps to figure out where the problem is

A) Check that FPC is configured right
1. Write the following test program to test.pas:
Code: [Select]
program test; begin end.2. Compile that with
Code: [Select]
fpc -Tembedded -Cparmv7m -WpXXX test.pas with XXX being the fpc name for your microcontroller (use "fpc -Tembedded -Cparmv7m -i" to list)

If that works and produces a test.elf then your compiler works, and the problem is in the configuration of Lazarus

Ruptor

  • Full Member
  • ***
  • Posts: 201
Re: Setting up an ARM embedded project?
« Reply #2 on: July 11, 2025, 12:10:31 am »
Error: Illegal parameter: -Cparmv7m
removing all parameters gives
Target OS: Embedded
Compiling test.pas
Fatal: Can't find unit system used by Program
Fatal: Compilation aborted
fpc works on Linux code.

Ruptor

  • Full Member
  • ***
  • Posts: 201
Re: Setting up an ARM embedded project?
« Reply #3 on: July 11, 2025, 11:31:27 am »
There is only one fpc.cfg file and it is in the x86_64-linux directory. Shouldn't there be two fpc.cfg files so there is one for arm?
There are two system.ppu that Lazarus files one in RTL under x86 and the other in RTL under embedded. It looks like the fpc.cfg file is missing for embedded to me but why didn't the cross build create it?

Laksen

  • Hero Member
  • *****
  • Posts: 802
    • J-Software
Re: Setting up an ARM embedded project?
« Reply #4 on: July 11, 2025, 11:52:17 am »
Sorry forgot "-Parm". Add that to all commands

Ruptor

  • Full Member
  • ***
  • Posts: 201
Re: Setting up an ARM embedded project?
« Reply #5 on: July 11, 2025, 01:52:28 pm »
Compiling test.pas
Fatal: Can't find unit system used by Program
Fatal: Compilation aborted

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1862
Re: Setting up an ARM embedded project?
« Reply #6 on: July 11, 2025, 02:51:05 pm »
It would be good to check some basic things first, if fpcupdeluxe did the rights things.
Check if the following folders and files are available.
....yourinstalldir/fpc/units/arm-embedded
....yourinstalldir/cross/lib/arm-embedded
....yourinstalldir/cross/bin/arm-embedded
....yourinstalldir/fpc/bin/cpu-os/ppcrossarm.exe"

Ruptor

  • Full Member
  • ***
  • Posts: 201
Re: Setting up an ARM embedded project?
« Reply #7 on: July 11, 2025, 05:46:01 pm »
Yes everything is there but as I said there is only one fpc.cfg for Linux & nothing for cross compiler hence Lazarus doesn't know where to look I think.

ccrause

  • Hero Member
  • *****
  • Posts: 1093
Re: Setting up an ARM embedded project?
« Reply #8 on: July 12, 2025, 09:08:24 am »
Yes everything is there but as I said there is only one fpc.cfg for Linux & nothing for cross compiler hence Lazarus doesn't know where to look I think.
The configuration file can contain conditionals and macros to identify and handle different targets configurations.  Fpcupdeluxe updates its fpc.cfg file when adding targets to your install folder.

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1862
Re: Setting up an ARM embedded project?
« Reply #9 on: July 12, 2025, 09:58:38 am »
Please have a look at your fpc.cfg. Towards the end of this file, the settings for arm-embedded can be found.
You may post these settings so we can have a look at them.

Ruptor

  • Full Member
  • ***
  • Posts: 201
Re: Setting up an ARM embedded project?
« Reply #10 on: July 12, 2025, 12:07:12 pm »
Please have a look at your fpc.cfg.....
I assumed there would be a config for each cross so no IFDEF required.::) Does it mean fpcupdeluxe didn't update the config?
Code: Pascal  [Select][+][-]
  1. # begin fpcup do not remove arm-embedded
  2. # Inserted by up v2.4.0f on 11-7-25 09:57:30
  3. # Cross compile settings dependent on both target OS and target CPU
  4. #IFDEF FPC_CROSSCOMPILING
  5. #IFDEF EMBEDDED
  6. #IFDEF CPUARM
  7. #IFDEF CPUARMV6M
  8. -CaEABI
  9. #ENDIF CPUARMV6M
  10. -FD/home/paul/fpcupdeluxe/cross/bin/arm-embedded
  11. -XParm-none-eabi-
  12. -Fl/home/paul/fpcupdeluxe/cross/lib/arm-embedded/$fpcsubarch/$fpcabi
  13. -Fu/home/paul/fpcupdeluxe/fpc/units/arm-embedded/$fpcsubarch/$fpcabi/rtl
  14. -Fu/home/paul/fpcupdeluxe/fpc/units/arm-embedded/$fpcsubarch/$fpcabi/packages
  15. #ENDIF CPUARM
  16. #ENDIF EMBEDDED
  17. #ENDIF FPC_CROSSCOMPILING
  18. # end fpcup do not remove
  19.  

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1862
Re: Setting up an ARM embedded project?
« Reply #11 on: July 12, 2025, 12:43:09 pm »
This config looks good. FPC only needs a single fpc.cfg config file.
Look at the defines for arm embedded.
Code: Pascal  [Select][+][-]
  1. /home/paul/fpcupdeluxe/fpc/units/arm-embedded/$fpcsubarch/$fpcabi
For FPC to be able to find the right unit-files, the subarch and the abi need to be set correct.

Set the subarch with the -Cp command line option.
Subarch is the name of this directory: /home/paul/fpcupdeluxe/fpc/units/arm-embedded/SUBARCH

Set the abi with the -Ca command line option.
Abi is the name of this directory: /home/paul/fpcupdeluxe/fpc/units/arm-embedded/subarch/ABI

This all looks complicated, but it is the only way to have an install of FPC that can handle different subarch and different abi in one install [AFAIK].

Ruptor

  • Full Member
  • ***
  • Posts: 201
Re: Setting up an ARM embedded project?
« Reply #12 on: July 13, 2025, 12:44:58 am »
Set the abi with the -Ca command line option.
Thanks for the pointers but I haven't sorted the paths yet as things went from bad to worse and I was side tracked looking up the myriad of FPC parameters. At one point Lazarus said there was no fpc.cfg file even though it hadn't moved. Finally I am back where I was this morning. %)
The wiki says use option -WpSTM32F103X8  but doesn't add up with the fpc description just adding to my confusion.
"-WP<x>     Minimum iOS deployment version: 8.0, 8.0.2, ... (iphonesim)"
Also I don't want kernel or OS  based embedded code so I have to use EABI don't I?
I would expect fpcupdeluxe that setup paths and placed the cross compiler stuff to transfer it to the IDE when the target processor is selected.  I will try again tomorrow.

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1862
Re: Setting up an ARM embedded project?
« Reply #13 on: July 13, 2025, 09:26:44 am »
Code: Pascal  [Select][+][-]
  1. I would expect fpcupdeluxe that setup paths and placed the cross compiler stuff to transfer it to the IDE when the target processor is selected.  I will try again tomorrow.
Fpcupdeluxe has done all the work to prepare FPC to be able to cross-compile towards your desired arm embedded target. The only thing you need to do is to tell FPC (and Lazarus) about the desired target when cross-compiling. FPC cannot guess the target other than using the default target (settings).


Laksen

  • Hero Member
  • *****
  • Posts: 802
    • J-Software
Re: Setting up an ARM embedded project?
« Reply #14 on: July 13, 2025, 10:51:10 am »
Which specific chip do you want to compile for?

 

TinyPortal © 2005-2018