Forum > Embedded

fpcupdeluxe and the Pico

(1/14) > >>

dbannon:
Hi folks.

I note that Michael Ring's patches to FPC have been merges in FPC main ( https://gitlab.com/freepascal.org/fpc/source/-/merge_requests/531 ) and that's really great.

It would be even better if fpcupdelue updated to the newer compiler and Lazarus, the Lazarus in there now is quite buggy, especially wrt to some (important to me) code tools things. So, I thought I'd do so testing to ease DonAlfredo workload a touch. I have established Lazarus 3.2 works well with Michael's old compiler.

However, I have been unable to build a working Pico cross compiler direct from FPC Main, first because I used ARMHF (Michael tells me the armv6m does not do hard float) and then things like "invalid combination of opcode and operands" its clear I have the wrong combinations of options. Does anyone know the correct switches to use, below was my second attempt -


--- Code: ---make clean all FPMAKEOPT="-T 4" CPU_TARGET=arm OPT="-dFPC_ARMel" CROSSOPT="-CpARMV6M -CaEABI" CROSSBINDIR=/usr/bin BINUTILSPREFIX=arm-none-eabi-
--- End code ---

to be followed by, if the above can be made to work, with -

--- Code: ---make crossinstall OS_TARGET=linux CPU_TARGET=arm OPT="-dFPC_ARMEL" CROSSBINDIR=/usr/bin  BINUTILSPREFIX=arm-none-eabi-  CROSSOPT="-CpARMV6M -CaEABI" INSTALL_PREFIX=/home/dbannon/bin/FPC/fpc-3.3.1

--- End code ---

Any ideas please ?

Davo


TRon:
The wiki seems to suggest to use subarch


--- Quote ---Some hints on Subarchs:

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

--- End quote ---

MiR:
just out of interest, what does not work for you in latest Lazarus?

At least for me Code completion works, also debugging with a pico probe (Although I had to first compile latest openocd patches from the Raspberry Repo.

To be honest I do not need much from Lazarus besides debugging so it would be nice to know where you struggle.

Michael

TRon:

--- Quote from: dbannon on March 04, 2024, 12:23:12 pm ---Any ideas please ?

--- End quote ---
At least a little better idea now  :)

The following seem to produce a (working) cross-compiler for me.

--- Code: ---make \
  clean \  // always clean up before doing anything
  crosszipinstall \ // generate an archive that contains the cross compiler and units, feel free to use crossinstall instead but make sure you install (in)to the correct directory
  FPC=fpc \ // (full path to your) fpc executable or as alternative you can use PP=<(full path to)ppc executable>
  CPU_TARGET=arm \ // seems that pico has an arm (no legs though)
  OS_TARGET=embedded \ // pico is an embedded target
  SUBARCH=armv6m \ // pico requires specific subarch and indicates instructions(et) that can be used
  CROSSBINDIR="../binutils" \ // path to directory where your binutils are located (or leave empty when global installed)
  BINUTILSPREFIX="arm-embedded-" \ // the prefix used for binutils
  CROSSOPT="-CaEABI" // select appropriate ABI

--- End code ---
Perhaps the above is able to provide some more details for trying your own build ?

dbannon:
OK, so I have it working, I am about to start some tests to see how it works with real code.  Below is a script I used in my building and re-building tests, important to note its NOT intended as a general purpose script for this purpose, it has no error checking, in most cases it will just move on to the next step if something bad happens.

First, TRon, where did you get the info about SUBARCH and  crosszipinstall from ?  The latter was a red herring, does not appear on our wiki and breaks the build but SUBARCH was the key to getting it going even though its not mentioned anywhere in the Pico context. But it sure worked and I thanks you !

Back to the "script", or as I prefer, list of commands ....

You should, as a minium, look at the top few lines, make sure you have the current FPC source in ~/Downloads, fpc.zip. Make sure the directories indicated are not already existing and containing something (important or otherwise).


--- Code: Bash  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---#!/bin/bash # WARNING - do not think of this as an gp install script, it does # absolutely NO ERROR CHECKING !!# Demo of how to build a Raspberry Pico compiler from current 'main' FPC.# Use it as you see fit. If it destroys your computer, cause you cat to become# pregnant or any other problem, sorry, no responsibility accepted.# David Bannon, 2024-03-05 export FPC_VER="fpc-3.3.1"export SRC_DIR="$HOME/bin/FPC/SRC/$FPC_VER"export FPC_DIR="$HOME/bin/FPC/$FPC_VER"mkdir -p "$FPC_DIR"mkdir -p "$SRC_DIR" cd "$SRC_DIR"unzip ~/Downloads/fpc.zipcd fpcmake all make install INSTALL_PREFIX="$FPC_DIR" make crossinstall CPU_TARGET=arm OS_TARGET=embedded SUBARCH=armv6m  CROSSBINDIR=/usr/bin  BINUTILSPREFIX=arm-none-eabi-  CROSSOPT="-CpARMV6M -CaEABI" INSTALL_PREFIX="$FPC_DIR" cp compiler/ppcx64 "$FPC_DIR"/bin/ppcx64         # cp rather ln -s because further processes seem to 'clean' itcp compiler/ppcrossarm "$FPC_DIR"/bin/ppcrossarm## the make process does not copy the rtl/embedded/arm/* files across. Why not ?cp rtl/embedded/arm/* "$FPC_DIR"/lib/fpc/3.3.1/units/arm-embedded/rtl/. cd "$FPC_DIR"mkdir -p etcbin/fpcmkcfg -d basepath="$FPC_DIR" -o etc/fpc.cfgln -s "$FPC_DIR"/lib/fpc/3.3.1/units units  cd binecho "#!/bin/sh" > fpc.bashecho "# A script that ensure when we start fpc here, it ignores all other fpc.cfg" >> fpc.bashecho "$FPC_DIR""/bin/fpc -n @$FPC_DIR/etc/fpc.cfg \"\$@\"" >> fpc.bashchmod u+x fpc.bash
A script to compile a job using this compiler may look like this -


--- Code: Bash  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---#!/bin/bashecho "------- Using the fpc from 3.3.1 ---------"export MICHAELS_UNITS="$HOME"/Pico2/projects/pico-fpcexamples/units # these come from https://github.com/michael-ring/pico-fpcexamples"$HOME"/bin/FPC/fpc-3.3.1/bin/fpc.bash -va -Xu -XParm-none-eabi- -Tembedded -Parm -CpARMV6M -Fu"$MICHAELS_UNITS" -Wpraspi_pico project1
If you use this compiler in Lazarus (I use Lazarus 3.2, works fine), make sure you call the compiler script, fpc.bash, not fpc itself. Otherwise, it may read you existing, 'other' fpc config and probably, that would be bad !

If this little package passes all my tests, I will write something up on the wiki so we have a record of how to do this stuff.

Much thanks to Michael Ring and DonAlfredo

Davo

Navigation

[0] Message Index

[#] Next page

Go to full version