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

From Lazarus wiki
Jump to navigationJump to search
(Added Installation Instruction for Mac and Windows)
 
 
(17 intermediate revisions by 3 users not shown)
Line 1: Line 1:
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.
+
{{ARM Embedded Tutorial - Installing Lazarus and Free Pascal}}
  
Download latest fpcupdeluxe here:
+
== Quickstart Installation via FPCUPdeluxe ==
  
[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
  
Only exception is darwin-aarch64, for this platform no stable fpc exists, you have to use trunk fpc.
+
[https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases fpcupdeluxe releases on github].
  
 +
Make sure that you use a version >= v1.8.2r of FPCUPdeluxe, the tutorial references features that are only in this and newer versions.
  
Then select C:\fpcupdeluxe-embedded or $HOME/fpcupdeluxe-embedded as the installation target and hit the button to build both fpc and lazarus.
+
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.
  
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.
+
== Steps for people mainly interested in Wio Terminal or Raspberry Pico ==
  
More information on fpcupdeluxe can be found here:
+
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 for 'Wio' or 'Pico' on the bottom of the screen:
  
[https://wiki.lazarus.freepascal.org/fpcupdeluxe FpcUpDeluxe Wiki]
+
[[File:SelectEmbeddedandTrunk.png|800px]]
  
== Download Compiler and Debugger Pack for you fpcupdeluxe installation ==
+
== Steps for people interested in other targets like arm avr or espressif microcontrollers ==
  
'''Windows'''
+
For all other targets select embedded (or trunk.git) for fpc and trunk.git for lazarus.
  
[http://temp.michael-ring.org/binutils-gdb-arm-embedded-win64.zip Binutils for arm-embedded (x86_64)]
+
The reason to choose embedded would be to have support for more arm-embedded controllers that are currently not yet available in fpc trunk and installing trunk.git instead of stable lazarus is a good idea because debugging for embedded targets is much improved in lazarus trunk.
  
[http://temp.michael-ring.org/fpc-arm-embedded-3.3.1-win64-20210129.zip FPC Pack for arm-embedded (x86_64)]
+
For all platforms besides arm trunk.git is likely the best choice for both fpc and lazarus.  
  
'''MacOSX'''
+
To build your embedded version of Lazarus follow those simple steps:
  
[http://temp.michael-ring.org/binutils-gdb-arm-embedded-darwin-x86_64.zip Binutils for arm-embedded (x86_64)]
+
* Select the target directory for your installation
 +
* Select embedded or trunk.git for fpc
 +
* Select trunk.git for lazarus
  
[http://temp.michael-ring.org/fpc-arm-embedded-3.3.1-darwin-x86_64-20210129.zip FPC Pack for arm-embedded (x86_64)]
+
Hit the Install/update FPC+Laz button.
  
[http://temp.michael-ring.org/binutils-gdb-arm-embedded-darwin-aarch64.zip Binutils for arm-embedded (aarch64)]
 
  
[http://temp.michael-ring.org/fpc-arm-embedded-3.3.1-darwin-aarch64-20210129.zip FPC Pack for arm-embedded (aarch64)]
+
[[File:SelectEmbeddedandTrunk.png|800px]]
  
'''Linux'''
+
After installation of FPC+Lazarus is done switch to the 'Cross' Tab
  
Todo
+
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:
  
Unzip the downloaded files inside of the fpcupdeluxe-embedded directory.
 
  
== Minor Fixes in the installation ==
+
[[File:fpcupdeluxe manual install 1.png|800px]]
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'''
+
Now you can select 'Install compiler' button and the selected subarch will be installed.....
  
Open the fpc.cfg file located here:
+
You may repeat this step for all CPU's subarchs you wish to install.
  
    C:\fpcupdeluxe-embedded\fpc\bin\x86_64-win64\fpc.cfg
+
Some hints on Subarchs:
  
with your favorite editor and search for those lines:
+
* armv6m Subarch is good for Raspberry Pico, SAMD21 based board like the Arduino Zero or STM32F0/G0/L0 families
  
    # searchpath for units and other system dependent things
+
* armv7m is for the Bluepill, Arduino Due or STM32F1/L1
    -FuC:\fpcupdeluxe-embedded\fpc\units\$fpctarget
 
    -FuC:\fpcupdeluxe-embedded\fpc\units\$fpctarget\*
 
    -FuC:\fpcupdeluxe-embedded\fpc\units\$fpctarget\rtl
 
  
and add this line:
+
* armv7em is for the Wio Terminal, Blackpill or SAMD51 / STM32F3/F4/G4/H7/L4 families
  
    -FuC:\fpcupdeluxe-embedded\fpc\units\$fpctarget\$fpcsubarch\rtl
+
* avr5 is for Arduino Uno
  
The last thing to do is to doublecheck that all went well....
+
* lx6 is for ESP32 based boards
  
Take the Path
 
 
    C:\fpcupdeluxe-embedded\fpc\units\$fpctarget\$fpcsubarch\rtl
 
  
and replace $fpctarget with 'arm-embedded' and $fpcsubarch with 'armv7m'
+
== Install extra devel tools ==
  
which will give you:
+
There is an extra module available to ease development by providing pre-compiled binaries for some usefull tools:
  
    C:\fpcupdeluxe-embedded\fpc\units\arm-embedded\armv7m\rtl
+
For avr development:
  
Check that this directory exists and that it contains system.ppu
+
* avarice (gdbserver for several debug probes manufactured by Microchip)
  
Then change to the Directory
+
* bossac  (upload firmwares to avr controllers)
  
    C:\fpcupdeluxe-embedded\fpc\bin\x86_64-win64\
+
for arm development:
  
and check that the file arm-embedded-as.exe exists.
+
* openocd  (gdbserver for all kinds of debug probes)
  
When all checks are done you should be ready to compile your first program.....
+
* st-util  (gdbserver specially for st-link v2/v3 debug probes)
  
'''MacOSX'''
+
for the Raspberry Pico:
  
Open the fpc.cfg file located here:
+
* openocd-picodebug (gdbserver for running a debug probe on the 2nd cpu of your pico)
  
    $HOME/fpcupdeluxe-embedded/fpc/bin/x86_64-darwin/fpc.cfg
+
* openocd-rp2040    (gdbserver for using a 2nd pico as a debug probe)
  
with your favorite editor and search for those lines:
+
general:
  
    -Fu/Users/XXXXX/fpcupdeluxe-embedded/fpc/units/$fpctarget
+
* gdb-multiarch        (one gdb to debug all embedded archs available)
    -Fu/Users/XXXXX/fpcupdeluxe-embedded/fpc/units/$fpctarget/*
 
    -Fu/Users/XXXXX/fpcupdeluxe-embedded/fpc/units/$fpctarget/rtl
 
  
and add this line:
+
* gdb-multiarch-8.3.1  (an older version of gdb that works better for avr)
  
    -Fu/Users/XXXXX/fpcupdeluxe-embedded/fpc/units/$fpctarget/$fpcsubarch/rtl`
+
Install it by selection develtools4fpc on the Modules tab of fpcupdeluxe by selection develtools4fpc and clicking 'Install Module':
  
**Please note that you have to substitute the '/Users/XXXXX' part of the path with the actual path of your $HOME.**
+
[[File:modules devtools4fpc.png|800px]]
  
The last thing to do is to doublecheck that all went well....
+
the files will then get deployed to the ccr/devtools4fpc directory inside of your fpcupdeluxe installation
  
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
+
More information on fpcupdeluxe can be found here: [[fpcupdeluxe|FpcUpDeluxe Wiki]].
 
 
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
 

Latest revision as of 15:55, 15 April 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.2r of FPCUPdeluxe, the tutorial references features that are only in this and newer versions.

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 for 'Wio' or 'Pico' on the bottom of the screen:

SelectEmbeddedandTrunk.png

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

For all other targets select embedded (or trunk.git) for fpc and trunk.git for lazarus.

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

For all platforms besides arm trunk.git is likely the best choice for both fpc and lazarus.

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

  • Select the target directory for your installation
  • Select embedded or trunk.git for fpc
  • Select trunk.git for lazarus

Hit the Install/update FPC+Laz button.


SelectEmbeddedandTrunk.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


Install extra devel tools

There is an extra module available to ease development by providing pre-compiled binaries for some usefull tools:

For avr development:

  • avarice (gdbserver for several debug probes manufactured by Microchip)
  • bossac (upload firmwares to avr controllers)

for arm development:

  • openocd (gdbserver for all kinds of debug probes)
  • st-util (gdbserver specially for st-link v2/v3 debug probes)

for the Raspberry Pico:

  • openocd-picodebug (gdbserver for running a debug probe on the 2nd cpu of your pico)
  • openocd-rp2040 (gdbserver for using a 2nd pico as a debug probe)

general:

  • gdb-multiarch (one gdb to debug all embedded archs available)
  • gdb-multiarch-8.3.1 (an older version of gdb that works better for avr)

Install it by selection develtools4fpc on the Modules tab of fpcupdeluxe by selection develtools4fpc and clicking 'Install Module':

modules devtools4fpc.png

the files will then get deployed to the ccr/devtools4fpc directory inside of your fpcupdeluxe installation



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