Recent

Author Topic: [Solved] project1.lpr Error: unit not found: RP2040  (Read 1813 times)

BlueIcaro

  • Hero Member
  • *****
  • Posts: 791
    • Blog personal
[Solved] project1.lpr Error: unit not found: RP2040
« on: October 02, 2022, 07:12:27 pm »
Hi, I installed Lazarus using fpcupdeluxe version V2.2.0j. to play with raspberry pi Pico.
If I open a example it works nice. I exported the projects options to have all options ready to start my own project.
So I create a simple program. Like this:
Code: [Select]
program Prject1;

{$MODE OBJFPC}
{$H+}
{$MEMORY 10000,10000}
uses
  pico_gpio_c;

begin

end.             
But when I write gp and push ctrl+space to get a list of instruccions, I got the error:
Quote
project1.lpr Error: unit not found: RP2040
This issue doesn't happen If I open a example.
I think I miss some thing.
Any Idea
Thanks
/BlueIcaro
« Last Edit: October 07, 2022, 04:24:26 pm by BlueIcaro »

zeljko

  • Hero Member
  • *****
  • Posts: 1591
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: project1.lpr Error: unit not found: RP2040
« Reply #1 on: October 02, 2022, 07:18:31 pm »
Your program is named Prject1 instead of Project1.

MiR

  • Full Member
  • ***
  • Posts: 246
Re: project1.lpr Error: unit not found: RP2040
« Reply #2 on: October 02, 2022, 07:23:19 pm »
Please have a look at the provided project files, You are missing some path settings that you need to have to make the project find all source files.

Thaddy

  • Hero Member
  • *****
  • Posts: 14159
  • Probably until I exterminate Putin.
Re: project1.lpr Error: unit not found: RP2040
« Reply #3 on: October 02, 2022, 08:22:40 pm »
Your program is named Prject1 instead of Project1.
That does not matter since the program name is always silently ignored. That is not the case with unit names, these must be exactly the same in the source w/o extension as the file on disk (with extension).
See the reference guide 16.1 and 16.2:
 https://www.freepascal.org/docs-html/current/ref/refse111.html#x232-25600016.1
and:
 https://www.freepascal.org/docs-html/current/ref/refse112.html#x233-25700016.2

It is more likely that you are not using a recent trunk/main version of FreePascal.
the RP2040 cpu is still rather recent and needs a recent cross-compiler. (i.e. 3.3.1)
(It need not be in the uses clause, the compiler determines it on compiling your cross-compiler.)
« Last Edit: October 02, 2022, 08:29:46 pm by Thaddy »
Specialize a type, not a var.

Arioch

  • Sr. Member
  • ****
  • Posts: 421
Re: project1.lpr Error: unit not found: RP2040
« Reply #4 on: October 02, 2022, 08:58:28 pm »
No, it is not just ignored, not always

https://gitlab.com/freepascal.org/fpc/documentation/-/issues/39324

{$R *.ext}  works the same in programs and units, and probable {$I *.ext} as well

Not sure, but AFAIR in Delphi such a wrong name could lead to weird linking errors later, hard to diagnose

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2006
  • Fifty shades of code.
    • Delphi & FreePascal
Re: project1.lpr Error: unit not found: RP2040
« Reply #5 on: October 02, 2022, 09:39:07 pm »
Not sure, but AFAIR in Delphi such a wrong name could lead to weird linking errors later, hard to diagnose
In Delphi it would not compile at all since unit names on disk and in source must match. It would than try search for old compiled version of that file and ignore current i guess.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

BlueIcaro

  • Hero Member
  • *****
  • Posts: 791
    • Blog personal
Re: project1.lpr Error: unit not found: RP2040
« Reply #6 on: October 02, 2022, 10:35:51 pm »
Hi, I think the name is not the problem.

I don't understand what happens. If I export the configuration of compiler, used in a example. Then I import, and add the path to the units folders, that is needed for compiling.

I attach the project, may you can see what happen.

/BlueIcaro

BlueIcaro

  • Hero Member
  • *****
  • Posts: 791
    • Blog personal
Re: project1.lpr Error: unit not found: RP2040
« Reply #7 on: October 05, 2022, 10:29:23 pm »
Hello, I make some test. I can compile my programs, but as I said if I push ctrl+space to get a list of possible instructions, I got the error Unit RP2040.

I test the same in the examples and I got the same error.

I make a video, may can explain better that me
https://youtu.be/wH5QfApGNxI
/BlueIcaro

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: project1.lpr Error: unit not found: RP2040
« Reply #8 on: October 06, 2022, 09:06:30 am »
Not sure, but AFAIR in Delphi such a wrong name could lead to weird linking errors later, hard to diagnose
In Delphi it would not compile at all since unit names on disk and in source must match. It would than try search for old compiled version of that file and ignore current i guess.

The unit names must match. There is no such requirement for the program or library names (which are not units).

In FPC there's a command line parameter to allow unit names to differ as well.

MiR

  • Full Member
  • ***
  • Posts: 246
Re: project1.lpr Error: unit not found: RP2040
« Reply #9 on: October 06, 2022, 05:52:13 pm »
When you install lazarus with fpcupdeluxe a lot more defaults are added to your fpc config and to lazarus to make codetools & friends work.

So, just to be sure that I understood correctly:

When you use lazarus from fpcupdeluxe then ctrl-space works, no error about rp2040 unit not found... correct?

if this is the case then please check the FPC source directory entry in the Preferences->Environment tab

in my case it is

/Users/ring/fpcupdeluxe/fpcsrc

find your's and then check if you see this file:

rtl/embedded/arm/rp2040.pp

most likely your fpcsrc directory does not have this file...

MiR

  • Full Member
  • ***
  • Posts: 246
Re: project1.lpr Error: unit not found: RP2040
« Reply #10 on: October 06, 2022, 08:39:07 pm »
Just rebuilt lazarus with sources of today and now my lazarus also does create the rp2040 not found error.

I am investigating, currently looks as if something is broken in codetools....

TFindDeclarationTool.FindUnitSource Self="/Users/ring/devel/pico-fpcexamples/blinky/blinky.lpr" AnUnitName="pico_gpio_c" AnUnitInFilename=""
TCTDirectoryCache.FindUnitSourceInCompletePath AUnitName="pico_gpio_c" InFilename="" Directory="/Users/ring/devel/pico-fpcexamples/blinky/"
[TFindDeclarationTool.FindCodeToolForUsedUnit]  This source is=/Users/ring/devel/pico-fpcexamples/blinky/blinky.lpr NewCode=/Users/ring/devel/pico-fpcexamples/units/pico_gpio_c.pas
TFindDeclarationTool.FindUnitSource Self="/Users/ring/devel/pico-fpcexamples/blinky/blinky.lpr" AnUnitName="RP2040" AnUnitInFilename=""
TCTDirectoryCache.FindUnitSourceInCompletePath AUnitName="RP2040" InFilename="" Directory="/Users/ring/devel/pico-fpcexamples/blinky/"
TCTDirectoryCache.FindUnitSourceInCompletePath unit RP2040 not found in SrcPath="/Users/ring/devel/pico-fpcexamples/blinky;/Users/ring/devel/pico-fpcexamples/units"  Directory="/Users/ring/devel/pico-fpcexamples/blinky/" searchin in unitset ...
TFPCUnitSetCache.GetUnitSrcFile Unit="RP2040" SrcSearchRequiresPPU=False SkipPPUCheckIfTargetIsSourceOnly=True
TFPCUnitSetCache.GetUnitSrcFile Unit="RP2040" Result=
TCTDirectoryCache.FindUnitSourceInCompletePath unit RP2040 not found in unitlinks. Directory="/Users/ring/devel/pico-fpcexamples/blinky/"
### TCodeToolManager.HandleException: [20170421200056] "unit not found: RP2040" in "/Users/ring/devel/pico-fpcexamples/blinky/blinky.lpr"

MiR

  • Full Member
  • ***
  • Posts: 246
Re: project1.lpr Error: unit not found: RP2040
« Reply #11 on: October 06, 2022, 10:50:06 pm »
I tested a little more, I see the following behaviour:

When I do a fresh install in a new directory with fpcupdeluxe and load a pico project I get the rp2040 not found error.

When I then select
Tools -> Rescan FPC Source directory
the error goes away and I can use ctrl-space

@BlueIcaro, does the same work for you?

BlueIcaro

  • Hero Member
  • *****
  • Posts: 791
    • Blog personal
Re: project1.lpr Error: unit not found: RP2040
« Reply #12 on: October 07, 2022, 04:24:06 pm »
Hi, I'm sorry. I couldn't test it until today.

As you said the problem is in codetools.

I Rescan Fpc source directory, and every thing works nice.

The solution works fine @Mir.

Thank for all

/BlueIcaro




 

TinyPortal © 2005-2018