Recent

Author Topic: Lazarus / RaspberyPi Hardware Library  (Read 90653 times)

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Lazarus / RaspberyPi Hardware Library
« Reply #15 on: August 14, 2012, 11:40:11 am »
Quote
I tried to use BigChimp's fpcup (using fpcup-linux-armel from https://bitbucket.org/reiniero/fpcup), but that did not work (or not completely).
Do you stilll have any details or log files of what went wrong?
I've only tested it with --only=fpc,lazarus since the default install tries to install too much for my small arm system.
It's actually an fpc error (ran fpcup with --only=fpc,lazarus):
Quote
make[3]: Entering directory `/home/pi/fpc/utils/fpcmkcfg'
/bin/mkdir -p units/arm-linux
__missing_command_DATA2INC -b -s fppkg.cfg fppkg.inc fppkg
make[3]: __missing_command_DATA2INC: Command not found
make[3]: *** [fppkg.inc] Error 127
make[3]: Leaving directory `/home/pi/fpc/utils/fpcmkcfg'
make[2]: *** [fpcmkcfg_all] Error 2
make[2]: Leaving directory `/home/pi/fpc/utils'
make[1]: *** [utils_all] Error 2
make[1]: Leaving directory `/home/pi/fpc'
make: *** [build-stamp.arm-linux] Error 2
make: Leaving directory `/home/pi/fpc'

Info: Running make install for FPC:
Note that fpcup *does* continue with 'make install', which it probably should not do (?).
I killed the procedure at this point and the fpcup log file does not give any useful info.

Thanks Dirk, we opened a bug report on it:
https://bitbucket.org/reiniero/fpcup/issue/45/make-sure-data2inc-exists-before-make-all
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

muratech

  • Newbie
  • Posts: 3
Re: Lazarus / RaspberyPi Hardware Library
« Reply #16 on: August 19, 2012, 08:23:59 pm »
Hi all

I am a noob when it comes to linux or anything similar. Have been working with Delphi on Windows for years. Here's my question -
1) Installed Lazarus
2) Downloaded the wrapper for GPIO.
3) Tried running demo program.

Getting the following errors -

Quote
/usr/bin/ld: warning: link.res contains output sections; did you forget -T?
/usr/bin/ld: error: raspberry uses VFP register arguments, ./wiringPi/wiringPi.o does not
/usr/bin/ld: failed to merge target specific data of file ./wiringPi/wiringPi.o
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
raspberry.lpr(46,47) Error: Error while linking
raspberry.lpr(46,47) Fatal: There were 1 errors compiling module, stopping

woodengineer

  • New Member
  • *
  • Posts: 20
Re: Lazarus / RaspberyPi Hardware Library
« Reply #17 on: August 21, 2012, 05:15:30 pm »
Hi all

I am a noob when it comes to linux or anything similar. Have been working with Delphi on Windows for years. Here's my question -
1) Installed Lazarus
2) Downloaded the wrapper for GPIO.
3) Tried running demo program.

Getting the following errors -

Quote
/usr/bin/ld: warning: link.res contains output sections; did you forget -T?
/usr/bin/ld: error: raspberry uses VFP register arguments, ./wiringPi/wiringPi.o does not
/usr/bin/ld: failed to merge target specific data of file ./wiringPi/wiringPi.o
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 assertion fail ../../bfd/elf32-arm.c:12049
raspberry.lpr(46,47) Error: Error while linking
raspberry.lpr(46,47) Fatal: There were 1 errors compiling module, stopping

Hello muratech,
I am running Archlinux not Debian,
Try to recompile the the wiringPi.c file to get a new wiringPi.o file as described in the readme.txt file of the lazwiringpi folder.

" The source file for Gordon's library is inside the wiringPi subdirectory. You can recompile
the library by executing a simple gcc -c wiringPi.c.
The resulting wiringPi.o file is whats used by pascal."

Also, your resulting program must be run as root.
Hope this helps!

Alex

muratech

  • Newbie
  • Posts: 3
Re: Lazarus / RaspberyPi Hardware Library
« Reply #18 on: August 21, 2012, 07:51:12 pm »
 :) Thanks ALex
Busy installing ARCH now and will try this out.

muratech

  • Newbie
  • Posts: 3
Re: Lazarus / RaspberyPi Hardware Library
« Reply #19 on: August 27, 2012, 07:42:44 pm »
Thanks Woodengineer.
I did a recompile of Wiringpi.

I need to run a program with a GUi in StartX. Is there a way I can do this as root.
Program is running but can't read anything from Pins, tested in Python and my wirring is correct.

Thanks

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: Lazarus / RaspberyPi Hardware Library
« Reply #20 on: November 19, 2012, 03:12:13 pm »
I need to run a program with a GUi in StartX. Is there a way I can do this as root.
Have you tried to start terminal from the desktop, navigate to your GUI executable, and start executable with sudo from command line? Does that work? Can you check if your binary is flagged as executable?
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

marun

  • Newbie
  • Posts: 4
Re: Lazarus / RaspberyPi Hardware Library
« Reply #21 on: December 01, 2012, 09:39:47 am »
Hello,
please find attached a wrapper unit for Gordon Henderson's
wiringPi C library (https://projects.drogon.net/raspberry-pi/wiringpi) and a little Lazarus test program.
This library allows access to the RaspberryPi's GPIO pins as well as the PWM pin.
The RaspberryPi is an inexpensive $25 SBC that runs linux. Check it out at http://www.raspberrypi.org.
BTW Lazarus runs quite well on the Pi.
Have fun, I know I will! :D
Alex
i tried to use your unit but it doesnt work it crashes on pinMode "esternal error SIGSEGV"
where i have to copy files from your unit?
here is my project http://leteckaposta.cz/556983847 (it is fan control)
edit: i added "if wiring pisetup..." and it ends with error (wiringpisetup=-1) do you know where is problem?
edit2: finally it works but only as a root
« Last Edit: December 01, 2012, 02:19:57 pm by marun »

Max12

  • Newbie
  • Posts: 1
Re: Lazarus / RaspberyPi Hardware Library
« Reply #22 on: December 04, 2012, 09:37:00 pm »
why it works only when starting by root????

I've exact the same problem!

DirkS

  • Sr. Member
  • ****
  • Posts: 251
Re: Lazarus / RaspberyPi Hardware Library
« Reply #23 on: December 05, 2012, 12:41:32 am »
why it works only when starting by root????
IIRC accessing GPIO functions on the PI requires root priviliges.
You can use 'sudo <yourprogramname>' to start the compiled program

Gr.
Dirk

marun

  • Newbie
  • Posts: 4
Re: Lazarus / RaspberyPi Hardware Library
« Reply #24 on: December 08, 2012, 07:11:50 pm »
i made this test program because i want to verify pinout but if i want change log. level of any pin it write access violation (started as a root) does anybody know where is problem? poject is here http://leteckaposta.cz/356175095

lynnr

  • Newbie
  • Posts: 2
Re: Lazarus / RaspberyPi Hardware Library
« Reply #25 on: January 13, 2013, 11:02:56 pm »
Hello All,

I'm trying to get my Raspberry Pi working using the wiringPi library, but haven't had any success.  I'm new to this, I've only had my Pi for about 1 month. 

Using Raspbian wheezy image, I was able to install Lazarus and compile and run a hello world program.  Next, installed wiringpi using directions on: //projects.drogon.net/raspberry-pi/wiringpi/download-and-install/  . All went smooth, so next I compiled the example(lazwiringpi.pas) from the beginning of this topic using the IDE. The compile completed normally.
But when I execute I get the following error:


pi@raspberrypi ~/lazarus/lazwiringpi $ sudo ./raspberryStarting RaspberryPi
An unhandled exception occurred at $000449F4 :
EAccessViolation : Access violation
  $000449F4


Help would be much appreciated.
Lynn

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: Lazarus / RaspberyPi Hardware Library
« Reply #26 on: January 27, 2013, 08:10:12 pm »
An alternative, and perhaps simpler, way to access the Pi's GPIO ports is via encapsulated Unix shell calls. See http://wiki.freepascal.org/Lazarus_on_Raspberry_Pi#Hardware_access_via_encapsulated_shell_calls for an example.

This method is directly supported by Lazarus / Free Pascal and doesn't require installation of any additional libraries or packages. Of course, your application has to be run with root privileges.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

vcp_ai

  • Newbie
  • Posts: 1
Re: Lazarus / RaspberyPi Hardware Library
« Reply #27 on: March 04, 2013, 07:05:33 pm »
An alternative, and perhaps simpler, way to access the Pi's GPIO ports is via encapsulated Unix shell calls. See http://wiki.freepascal.org/Lazarus_on_Raspberry_Pi#Hardware_access_via_encapsulated_shell_calls for an example.

This method is directly supported by Lazarus / Free Pascal and doesn't require installation of any additional libraries or packages. Of course, your application has to be run with root privileges.
Hi,  can you give an example of how to READ a GPIO port into fpc, using fpsystem ???

Regards

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: Lazarus / RaspberyPi Hardware Library
« Reply #28 on: April 28, 2013, 08:39:33 pm »
Hi,  can you give an example of how to READ a GPIO port into fpc, using fpsystem ???

I can give an example to read the status of a port with native FPC methods (fpopen, fpread, fpclose etc.). This is a more elegant solution than the detour over fpsystem.

See http://wiki.lazarus.freepascal.org/Lazarus_on_Raspberry_Pi#Reading_the_status_of_a_port for a working example.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

picstart

  • Full Member
  • ***
  • Posts: 236
Re: Lazarus / RaspberyPi Hardware Library
« Reply #29 on: April 28, 2013, 11:10:52 pm »
Just keep in mind that GPIO ( working with pins) on the rasp pi is a restricted operation and often needs to be run with root privileges that usually means the lazarus IDE or the o file needs to run from root. Other things like I2C are less restricted

 

TinyPortal © 2005-2018