Recent

Author Topic: Lazarus Pascal cross compile Raspberry pi PICO  (Read 2817 times)

andrew Bubble

  • Jr. Member
  • **
  • Posts: 57
Lazarus Pascal cross compile Raspberry pi PICO
« on: January 07, 2024, 07:37:02 pm »
Hi All

I need some assistance in trying to find out why my Lazarus Pascal shows an error when opening any examples for the PICO.

I have had quite a issues trying to install the correct version of Lazarus and freePascal on a Raspberry PI 400 running the 32 bit OS of Bookworm.

On a fresh install of Bookworm on the SD card and after running any updates, I  did the following

// This only for PI Os (Bookworm)
sudo raspi-config noint do_wayland W1

// Required dependencies for Lazarus
sudo apt install libx11-dev libgdk-pixbuf2.0-dev libpango1.0-dev libgtk2.0-dev git

As per previous issues with Lazarus and Bookworm I did the following
sudo raspi-config noint do_wayland W1

I then installed the latest version of fpcupdeluxe v2.4.0c.

This is where my issues have been, as I need to select embedded for fpc and a suitable version for the Lazarus, I have tired the stable and trunk but the install fails with the exit code 512.

I eventually got the install to work with using the embedded for fpc and v2.26 for Lazarus. I then installed for the cross arm and embedded and as advised else where selected the armv6m for the set subarch and installed the compiler. All installed ok.

Also as advised I installed the develtools4fpc in the modules section.

When I run Lazarus and open any of the examples I get the following error 'The project uses target OS=embedded and CPU=arm. The system ppu for this target was not found.

I tried the simple Blinky example which showed the above error when I tried to open it, however it still opens and if I select Build it compiles very quickly and does so correctly.

I copied the *.uf2 file to the Pico and the led flashed as normal, skeptical I altered the timings in the blinky pas file and re built and coped the new uf2 file to the PICO and the led flashed as expected with the altered timings.

SO to recap I can clearly modify any of the examples changing the code and see the result, however I cannot make a new project and somehow select the Pico as Lazarus treats any new project as a Raspberry pi Linux project.

Any ideas

Regards Andrew

Thaddy

  • Hero Member
  • *****
  • Posts: 16155
  • Censorship about opinions does not belong here.
Re: Lazarus Pascal cross compile Raspberry pi PICO
« Reply #1 on: January 07, 2024, 08:05:11 pm »
 I am not sure I fully understand you, but Lazarus and FPC should not be compiled for embedded. Just the cross- compiler for the Pico needs to be for embedded target..
There is no way to run FPC nor by extension Lazarus on a Pico, but you can run any code - within the constraints of the Pico - on a Pico when cross-compiled.
The second interpretation is that somehow the IDE picks up something wrong and that would definitely be a bug. That said, I have not compiled for Pico a few months (3) so some things may have changed.
I suppose you are using trunk or 3.2 fixes?
The third interpretation is that the compiler can not find any system.pp.
Have you tried adding a stub unit system.pp? The compiler expects that, also on embedded.
(A stub unit is cheating, you likely need a very basic system for some inevitable language support)
AFAICR I never ran into trouble.
« Last Edit: January 07, 2024, 08:20:30 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

andrew Bubble

  • Jr. Member
  • **
  • Posts: 57
Re: Lazarus Pascal cross compile Raspberry pi PICO
« Reply #2 on: January 07, 2024, 08:51:41 pm »
Hi Thaddy

I am sorry for the confusion, I was simply trying to get to the right fpc and Lazarus to install on my pi 400.

As an update, I have just tried to from a fresh SD card install of Bookworm 32 bit.

I used the fpc version embedded and the trunk version but had the install failed on the following

laz_xmlstreaming,pas(85,15) Error: (3058) there is not method in an ancestor class to be overridden "WriteString(const RawByteString);"
laz_xmlstreaming.pas(158,1) Fatal: (10026) there were 1 errors compiling module, stopping.

Then the install fails.

Can you suggest a suitable Lazarus I could try, the list states trunk, stable. fixes, fixes-3.0, fixes-2.6.

The reason I chose the 2.26 is I had used this before.

Once the two install is there some settings I need to do to Lazarus / configuration when I make a new Pico application.

Regards Andrew

andrew Bubble

  • Jr. Member
  • **
  • Posts: 57
Re: Lazarus Pascal cross compile Raspberry pi PICO
« Reply #3 on: January 08, 2024, 10:56:27 pm »
Hi All

Just an update, I made a Windows 10 VMWare on my PC and installed fpcpdeluxe and selected the Pico ad waited until everything installed, which it did with no options.

I assumed that as this installed all ok there would be an option to select a Pico as a new project but there was not.

Opening any of the example projects yielded the same error - 'The project uses target OS=embedded and CPU=arm. The system ppu for this target was not found.

However as before I can still build the project and everything works as before.

One thing I can do is take one of the examples and save the project as and give a different name and use this as a basis.

My question is, is this how the Pcio cross compiling is to be used, this is workable but seeing the error message made look for something I had done wrong or a step I had missed.

Regards Andrew

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1781
Re: Lazarus Pascal cross compile Raspberry pi PICO
« Reply #4 on: January 09, 2024, 09:01:51 am »
Would you mind trying this ?
In the Lazarus Tools menu, there is an option called "Rescan FPC source directory".
It might be that your problems are solved after using this command.


andrew Bubble

  • Jr. Member
  • **
  • Posts: 57
Re: Lazarus Pascal cross compile Raspberry pi PICO
« Reply #5 on: January 09, 2024, 06:44:14 pm »
Hi DonAlfredo

I have done as you have suggested and I still get the error when I open the project.

I have my VMWare running at the moment and a Raspberry PI 5 running bookworm and they both show the exact same error when opening a project.

One thing I am not sure of is when I have installed all the fpc, Lazarus and the cross complier are there any configuration / settings I need to do within Lazarus.

Regards Andrew

Thaddy

  • Hero Member
  • *****
  • Posts: 16155
  • Censorship about opinions does not belong here.
Re: Lazarus Pascal cross compile Raspberry pi PICO
« Reply #6 on: January 09, 2024, 07:14:51 pm »
There may be a Wayland issue, but noy for FPC, only for Lazarus.
But installed from fpcupdeluxe it simply works. Maybe you still have the hidden directories from a previous install? Do you know how to list hidden - dotted prefix in Linux? Did you clean up the fpc.cfg in /etc before a new install?
If I smell bad code it usually is bad code and that includes my own code.

andrew Bubble

  • Jr. Member
  • **
  • Posts: 57
Re: Lazarus Pascal cross compile Raspberry pi PICO
« Reply #7 on: January 09, 2024, 07:31:01 pm »
Hi Thaddy

Thanks for the quick reply, I realised early on and it was time consuming but every time I tried something different on the raspberry PI I started from a fresh SD format and install of the OS Bullseye, Bookworm.

Then installed all the fpc, Lazarus and cross compiler.

On my VMware I had a clean install of Windows 10 and as I was using this for test purposes I did a snapshot within VMware before any installs.

The only difference is on the Raspberry PI due the issues I had I had to choose fpc Embedded and Lazarus V2.2.6,

On the Windows VMware I selected the PICO button on the bottom of fpcpdeluxe and just let it run until complete.

The first thing I did after both the installs is try to open one of the examples, and in both cases this was Blinky.

Regards Andrew 

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1781
Re: Lazarus Pascal cross compile Raspberry pi PICO
« Reply #8 on: January 09, 2024, 07:32:00 pm »
The problem is caused by Lazarus.
To accommodate for all embedded options, like eabi, soft/hard, armv5/6/7/8, fpcupdeluxe places the compiled units in separate directories and used FPC macro-expansion to point FPC to the correct units. This is why compilation works.
Lazarus has some hidden auto-detect mechanism to see if the correct units are placed in the correct directory. However, Lazarus does not handle the FPC macros as it should.
To circumvent this, fpcupdeluxe creates a dummy system.ppu in the correct (according to Lazarus) directory. Somehow, this does not work anymore.
I need to have a closer look at this.

Thaddy

  • Hero Member
  • *****
  • Posts: 16155
  • Censorship about opinions does not belong here.
Re: Lazarus Pascal cross compile Raspberry pi PICO
« Reply #9 on: January 09, 2024, 07:34:51 pm »
Do
Code: Bash  [Select][+][-]
  1. ls -a -R | grep /.
in your user directory. If you find .lazarus or similar, delete it before a new install.
Of course only delete .lazarus and similar, nothing else. Not all hidden files there are related to a lazarus install.
Actually on the Pi, this is enough:
Code: Bash  [Select][+][-]
  1. ls -a -R | grep /.lazarus

Also do not forget to delete /etc/fpc.cfg, but back it up first if you heavily editted it.
« Last Edit: January 09, 2024, 07:47:25 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1781
Re: Lazarus Pascal cross compile Raspberry pi PICO
« Reply #10 on: January 09, 2024, 07:59:10 pm »
Try this (again).
Copy this file (the dummy): "C:\yourinstalldirectory\fpc\units\arm-embedded\armv6m\eabi\system.ppu"
Towards the parent directory: "C:\yourinstalldirectory\fpc\units\arm-embedded\armv6m"
Again, let Lazarus scan the FPC sources.
Close Lazarus. Open Lazarus.

Thaddy

  • Hero Member
  • *****
  • Posts: 16155
  • Censorship about opinions does not belong here.
Re: Lazarus Pascal cross compile Raspberry pi PICO
« Reply #11 on: January 09, 2024, 09:03:47 pm »
That works only for Rpi32, not for RpiAarch64.
Also note (maybe except RPi1, have to look it up) it should be for ARMv7a
If I smell bad code it usually is bad code and that includes my own code.

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1781
Re: Lazarus Pascal cross compile Raspberry pi PICO
« Reply #12 on: January 09, 2024, 09:30:40 pm »
PICO = RP2040 = Cortex M0+ = ARMv6M

andrew Bubble

  • Jr. Member
  • **
  • Posts: 57
Re: Lazarus Pascal cross compile Raspberry pi PICO
« Reply #13 on: January 09, 2024, 09:42:45 pm »
Hi Thaddy

Result !!

I have done as you have asked and in both cases my VMware Windows Lazarus and Raspberry Pi Lazarus now opens the examples with out any errors.

My next question is how to set up or make a project for the Pico from scratch from the Lazarus New Project.

Regards Andrew

Thaddy

  • Hero Member
  • *****
  • Posts: 16155
  • Censorship about opinions does not belong here.
Re: Lazarus Pascal cross compile Raspberry pi PICO
« Reply #14 on: January 09, 2024, 09:55:19 pm »
PICO = RP2040 = Cortex M0+ = ARMv6M
Nope, but for Pico you are correct.
Here's an exact overview of the other ones:

The Raspberry Pi range of single-board computers uses different ARM processors depending on the model. Here is a list of the different models and their corresponding processors and ABI for the standard OS:

- Raspberry Pi 1 Model A and B: Broadcom BCM2835 SoC with ARM1176JZF-S CPU, ARMv6 Hard float
- Raspberry Pi 1 Model A+ and B+: Broadcom BCM2835 SoC with ARM1176JZF-S CPU, ARMv6 Hard float
- Raspberry Pi 2 Model B: Broadcom BCM2836 SoC with quad-core ARM Cortex-A7 CPU, ARMv6 Hard float, but later models ARMv7 Hard float because that was really already a BCM2837
- Raspberry Pi 3 Model B and B+: Broadcom BCM2837 SoC with quad-core ARM Cortex-A53 CPU, ARMv7 Hard float
- Raspberry Pi 4 Model B: Broadcom BCM2711 SoC with quad-core ARM Cortex-A72 CPU, ARMv7 Hard float
- Raspberry Pi 5 Model B: Broadcom BCM2712 Soc with quad code ARM Cortex-A76 CPU, ARMv8 Hard float

To a certain extend the ABI depends on the OS that is used, but the above is for the standard Raspberry Debian based OS.
All versions of the 32 ABI's are compatible with ARMv6 Hard float. It only matters if you need the features in your programs. For Lazarus and FPC I would stick with ARMv6 to compile themselves, as long as the CPU/FPU compiler options for my own software are listed correctly.
Only the Raspberry Pi 5 entry was written by me, the rest was found on the web.
« Last Edit: January 09, 2024, 10:06:32 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

 

TinyPortal © 2005-2018