Difference between revisions of "ARM Embedded Tutorial - Installing Lazarus and Free Pascal"

From Lazarus wiki
Jump to navigationJump to search
(Upgrade to latest FPCUPdeluxe)
Line 1: Line 1:
 
{{ARM Embedded Tutorial - Installing Lazarus and Free Pascal}}
 
{{ARM Embedded Tutorial - Installing Lazarus and Free Pascal}}
  
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.
+
== Quickstart Installation via FPCUPdeluxe ==
  
Download latest fpcupdeluxe from [https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases fpcupdeluxe releases on github].
+
The easiest way to install Embedded Support for a huge variety of embedded controllers is to use fpcupdeluxe.
  
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.
+
Download latest(!!!) FPCUPdeluxe from
  
The only exception is darwin-aarch64, for this platform no stable FPC exists, so you have to use the trunk (development version) of FPC.
+
[https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases fpcupdeluxe releases on github].
  
Then select <tt>C:\fpcupdeluxe-embedded</tt> or <tt>$HOME/fpcupdeluxe-embedded</tt> as the installation target and hit the button to build both FPC and Lazarus.
+
Make sure that you use a version >= v1.8.2l of FPCUPdeluxe, the tutorial references features that are only in this and newer versions.
  
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.
+
FPCUPdeluxe uses forks of the graemeg github repos of Freepascal trunk and Lazarus trunk
  
More information on fpcupdeluxe can be found here: [[fpcupdeluxe|FpcUpDeluxe Wiki]].
+
the fork used for Freepascal is named 'embedded-mir' and the fork for Lazarus is 'embedded'
  
== Download Compiler and Debugger Pack for you fpcupdeluxe installation ==
+
As we are using trunk versions we highly recommend to create an extra installation for embedded targets so that issues in compiler/lazarus do not effect your other work.
  
=== Windows ===
+
== Steps for people mainly interested in Wio Terminal or Raspberry Pico ==
  
[http://temp.michael-ring.org/binutils-gdb-arm-embedded-win64.zip Binutils for arm-embedded (x86_64)]
+
When your primary targts of interest are the Wio Terminal or the Raspberry Pico, then installation consists of entering an installation directory for fpcupdeluxe on top left and then selecting the speedbutton on the bottom of the screen:
  
[http://temp.michael-ring.org/fpc-arm-embedded-3.3.1-win64-20210207.zip FPC Pack for arm-embedded (x86_64)]
+
[[File:fpcupdeluxe start installation.png|800px]]
  
=== macOS ===
 
  
[http://temp.michael-ring.org/binutils-gdb-arm-embedded-darwin-x86_64.zip Binutils for arm-embedded (x86_64)]
 
  
[http://temp.michael-ring.org/fpc-arm-embedded-3.3.1-darwin-x86_64-20210129.zip FPC Pack for arm-embedded (x86_64)]
+
== Steps for people interested in other targets like arm avr or espressif microcontrollers ==
  
[http://temp.michael-ring.org/binutils-gdb-arm-embedded-darwin-aarch64.zip Binutils for arm-embedded (aarch64)]
+
For all other targets you can choose between either trunk.git or embedded-mir for fpc and either trunk.git or embedded for lazarus.
  
[http://temp.michael-ring.org/fpc-arm-embedded-3.3.1-darwin-aarch64-20210129.zip FPC Pack for arm-embedded (aarch64)]
+
The reason to choose embedded-mir would be to have support for more emedded controllers that are currently not yet available in fpc trunk and installing embedded/trunk.git instead of stable lazarus is a good idea because debugging for embedded targets is much improoved in lazarus trunk
  
=== Linux ===
+
To build your embedded version of Lazarus follow those simple steps:
  
Todo
+
- Select the target directory for your installation
 +
- Select either trunk.git or embedded-mir for fpc
 +
- Select either trunk.git or embedded for lazarus
  
Unzip the downloaded files inside of the fpcupdeluxe-embedded directory.
+
Hit the Install/update FPC+Laz button.
  
== 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 <tt>fpc.cfg</tt> file located inside of your installation needs a small change to be able to find the proper libraries for building.
+
[[File:fpcupdeluxe start manual installation.png|800px]]
  
=== Windows ===
+
After installation of FPC+Lazarus is done switch to the 'Cross' Tab
  
Open the <tt>fpc.cfg</tt> file located in <tt>C:\fpcupdeluxe-embedded\fpc\bin\x86_64-win64\</tt> with your favorite editor and search for these lines:
+
In the Cross tab select the desired CPU and the desired OS und then click on the 'Set subarch' button to define the subarch that you would like to use:
  
    # 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:
+
[[File:fpcupdeluxe manual install 1.png|800px]]
  
    -FuC:\fpcupdeluxe-embedded\fpc\units\$fpctarget\$fpcsubarch\rtl
+
Now you can select 'Install compiler' button and the selected subarch will be installed.....
  
The last thing to do is to double check that all went well....
+
You may repeat this step for all CPU's subarchs you wish to install.
  
Take the Path
+
Some hints on Subarchs:
 
    C:\fpcupdeluxe-embedded\fpc\units\$fpctarget\$fpcsubarch\rtl
 
  
and replace <tt>$fpctarget</tt> with <tt>arm-embedded</tt> and <tt>$fpcsubarch</tt> with <tt>armv7m</tt> which will give you:
+
armv6m Subarch is good for Raspberry Pico, SAMD21 based board like the Arduino Zero or STM32F0/G0/L0 families
  
    C:\fpcupdeluxe-embedded\fpc\units\arm-embedded\armv7m\rtl
+
armv7m is for the Bluepill, Arduino Due or STM32F1/L1
  
Check that this directory exists and that it contains <tt>system.ppu</tt>. Then change to the Directory
+
armv7em is for the Wio Terminal, Blackpill or SAMD51 / STM32F3/F4/G4/H7/L4 families
  
    C:\fpcupdeluxe-embedded\fpc\bin\x86_64-win64\
+
avr5 is for Arduino Uno
  
and check that the file <tt>arm-embedded-as.exe</tt> exists.
+
lx6 is for ESP32 based boards
  
When all checks are done, you should be ready to compile your first program.
 
  
=== macOS ===
 
  
Open the <tt>fpc.cfg</tt> file located here:
+
More information on fpcupdeluxe can be found here: [[fpcupdeluxe|FpcUpDeluxe Wiki]].
 
 
    $HOME/fpcupdeluxe-embedded/fpc/bin/x86_64-darwin/fpc.cfg
 
 
 
with your favorite editor and search for these 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 actual path of your $HOME for the '/Users/XXXXX' part of the path above.''
 
 
 
The last thing to do is to double check that all went well...
 
 
 
Take the Path
 
 
 
    $HOME/fpcupdeluxe-embedded/fpc/units/$fpctarget/$fpcsubarch/rtl
 
 
 
and replace <tt>$fpctarget</tt> with <tt>arm-embedded</tt> and <tt>$fpcsubarch</tt> with <tt>armv7m</tt>
 
 
 
which will give you:
 
 
 
    $HOME/fpcupdeluxe-embedded/fpc/units/arm-embedded/armv7m/rtl
 
 
 
Check that this directory exists and that it contains <tt>system.ppu</tt>:
 
 
 
    ls -l $HOME/fpcupdeluxe-embedded/fpc/units/arm-embedded/armv7m/rtl/system.ppu
 
 
 
Then change to the directory <tt>$HOME/fpcupdeluxe-embedded/fpc/bin/x86_64-darwin</tt> and check that the file <tt>arm-embedded-as</tt> 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
 

Revision as of 18:09, 28 February 2021

English (en)

Quickstart Installation via FPCUPdeluxe

The easiest way to install Embedded Support for a huge variety of embedded controllers is to use fpcupdeluxe.

Download latest(!!!) FPCUPdeluxe from

fpcupdeluxe releases on github.

Make sure that you use a version >= v1.8.2l of FPCUPdeluxe, the tutorial references features that are only in this and newer versions.

FPCUPdeluxe uses forks of the graemeg github repos of Freepascal trunk and Lazarus trunk

the fork used for Freepascal is named 'embedded-mir' and the fork for Lazarus is 'embedded'

As we are using trunk versions we highly recommend to create an extra installation for embedded targets so that issues in compiler/lazarus do not effect your other work.

Steps for people mainly interested in Wio Terminal or Raspberry Pico

When your primary targts of interest are the Wio Terminal or the Raspberry Pico, then installation consists of entering an installation directory for fpcupdeluxe on top left and then selecting the speedbutton on the bottom of the screen:

fpcupdeluxe start installation.png


Steps for people interested in other targets like arm avr or espressif microcontrollers

For all other targets you can choose between either trunk.git or embedded-mir for fpc and either trunk.git or embedded for lazarus.

The reason to choose embedded-mir would be to have support for more emedded controllers that are currently not yet available in fpc trunk and installing embedded/trunk.git instead of stable lazarus is a good idea because debugging for embedded targets is much improoved in lazarus trunk

To build your embedded version of Lazarus follow those simple steps:

- Select the target directory for your installation - Select either trunk.git or embedded-mir for fpc - Select either trunk.git or embedded for lazarus

Hit the Install/update FPC+Laz button.


fpcupdeluxe start manual installation.png

After installation of FPC+Lazarus is done switch to the 'Cross' Tab

In the Cross tab select the desired CPU and the desired OS und then click on the 'Set subarch' button to define the subarch that you would like to use:


fpcupdeluxe manual install 1.png

Now you can select 'Install compiler' button and the selected subarch will be installed.....

You may repeat this step for all CPU's subarchs you wish to install.

Some hints on Subarchs:

armv6m Subarch is good for Raspberry Pico, SAMD21 based board like the Arduino Zero or STM32F0/G0/L0 families

armv7m is for the Bluepill, Arduino Due or STM32F1/L1

armv7em is for the Wio Terminal, Blackpill or SAMD51 / STM32F3/F4/G4/H7/L4 families

avr5 is for Arduino Uno

lx6 is for ESP32 based boards


More information on fpcupdeluxe can be found here: FpcUpDeluxe Wiki.