ARM Embedded Tutorial - Installing Lazarus and Free Pascal

From Lazarus wiki
Revision as of 20:35, 29 January 2021 by MiR (talk | contribs) (Added Installation Instruction for Mac and Windows)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The easiest way to install Embedded Support for a huge variety of embedded controllers is to use fpcupdeluxe and to then load a pre-compiled version of fpc and other tools.

Download latest fpcupdeluxe here:

fpcupdeluxe releases on github

Select the current stable fpc version and trunk version of Lazarus. You will need trunk version of Lazarus for better support of debugging, when you do not plan to use IDE based debugging the stable Lazarus is also OK. It is important that you select fpc stable.

Only exception is darwin-aarch64, for this platform no stable fpc exists, you have to use trunk fpc.


Then select C:\fpcupdeluxe-embedded or $HOME/fpcupdeluxe-embedded as the installation target and hit the button to build both fpc and lazarus.

For now, do not install anything else, especially do not install the embedded support as this part is currently limited to support for armv6m targets.

More information on fpcupdeluxe can be found here:

FpcUpDeluxe Wiki

Download Compiler and Debugger Pack for you fpcupdeluxe installation

Windows

Binutils for arm-embedded (x86_64)

FPC Pack for arm-embedded (x86_64)

MacOSX

Binutils for arm-embedded (x86_64)

FPC Pack for arm-embedded (x86_64)

Binutils for arm-embedded (aarch64)

FPC Pack for arm-embedded (aarch64)

Linux

Todo

Unzip the downloaded files inside of the fpcupdeluxe-embedded directory.

Minor Fixes in the installation

The fpc pack provides support for several architectures (armv6m, armv7m and armv7em) in one package. To make this work properly the fpc.cfg file located inside of your installation needs a small change to be able to find the proper libraries for building.

Windows

Open the fpc.cfg file located here:

   C:\fpcupdeluxe-embedded\fpc\bin\x86_64-win64\fpc.cfg

with your favorite editor and search for those lines:

   # searchpath for units and other system dependent things
   -FuC:\fpcupdeluxe-embedded\fpc\units\$fpctarget
   -FuC:\fpcupdeluxe-embedded\fpc\units\$fpctarget\*
   -FuC:\fpcupdeluxe-embedded\fpc\units\$fpctarget\rtl

and add this line:

   -FuC:\fpcupdeluxe-embedded\fpc\units\$fpctarget\$fpcsubarch\rtl

The last thing to do is to doublecheck that all went well....

Take the Path

   C:\fpcupdeluxe-embedded\fpc\units\$fpctarget\$fpcsubarch\rtl 

and replace $fpctarget with 'arm-embedded' and $fpcsubarch with 'armv7m'

which will give you:

   C:\fpcupdeluxe-embedded\fpc\units\arm-embedded\armv7m\rtl

Check that this directory exists and that it contains system.ppu

Then change to the Directory

   C:\fpcupdeluxe-embedded\fpc\bin\x86_64-win64\

and check that the file arm-embedded-as.exe exists.

When all checks are done you should be ready to compile your first program.....

MacOSX

Open the fpc.cfg file located here:

   $HOME/fpcupdeluxe-embedded/fpc/bin/x86_64-darwin/fpc.cfg

with your favorite editor and search for those lines:

   -Fu/Users/XXXXX/fpcupdeluxe-embedded/fpc/units/$fpctarget
   -Fu/Users/XXXXX/fpcupdeluxe-embedded/fpc/units/$fpctarget/*
   -Fu/Users/XXXXX/fpcupdeluxe-embedded/fpc/units/$fpctarget/rtl

and add this line:

   -Fu/Users/XXXXX/fpcupdeluxe-embedded/fpc/units/$fpctarget/$fpcsubarch/rtl`
    • Please note that you have to substitute the '/Users/XXXXX' part of the path with the actual path of your $HOME.**

The last thing to do is to doublecheck that all went well....

Take the Path

   $HOME/fpcupdeluxe-embedded/fpc/units/$fpctarget/$fpcsubarch/rtl 

and replace $fpctarget with 'arm-embedded' and $fpcsubarch with 'armv7m'

which will give you:

   $HOME/fpcupdeluxe-embedded/fpc/units/arm-embedded/armv7m/rtl

Check that this directory exists and that it contains system.ppu:

   ls -l $HOME/fpcupdeluxe-embedded/fpc/units/arm-embedded/armv7m/rtl/system.ppu

Then change to the directory

   $HOME/fpcupdeluxe-embedded/fpc/bin/x86_64-darwin

and check that the file arm-embedded-as exists:

   ls -l $HOME/fpcupdeluxe-embedded/fpc/bin/x86_64-darwin/arm-embedded-as

When all checks are done you should be ready to compile your first program.....

Linux

ToDo