Recent

Author Topic: PiGpio exception SIGSEGV  (Read 790 times)

babbel

  • Newbie
  • Posts: 4
PiGpio exception SIGSEGV
« on: March 09, 2020, 03:16:16 pm »
Hi theren,

new to Raspberry (and linux...), trying to get GPIO running. Most works with the encapsulated shell calls, but there I cannot find how to setup Pull_up for an input.

I am trying to use the RPi to build an alarm system with some passive IR sensors and switches for on doors and windows. I've got a draft version running in Python 2.7, but I am using Lazarus quite some time in windows and would like to get this running on a raspberry with a nice GUI, which I cannot find in Python

So I wanted to try the unit PiGpio, but this results in exception SIGSEGV in the line
gpiof := Pointer(LongWord(Self.FGpio) + fSel);

I has probably something to do with rights, but I can't figure out what.

Any help is appreciated.

Robbert

eljo

  • Sr. Member
  • ****
  • Posts: 408
Re: PiGpio exception SIGSEGV
« Reply #1 on: March 09, 2020, 03:19:27 pm »
search this forums for ultibo. a bare metal framework to work with raspberry pi.

Thaddy

  • Hero Member
  • *****
  • Posts: 10293
Re: PiGpio exception SIGSEGV
« Reply #2 on: March 09, 2020, 03:46:13 pm »
I need to know the version of the Raspberry Pi and in case of the RPi2 the revision number too. The GPIO base address differs between the models and there is code that needs to be corrected for pagesize ($1000 or 4096, so it needs a division)
« Last Edit: March 09, 2020, 04:25:51 pm by Thaddy »
I am more like donkey than shrek

babbel

  • Newbie
  • Posts: 4
Re: PiGpio exception SIGSEGV
« Reply #3 on: March 10, 2020, 07:26:55 am »
It is on a RPi 4. I found that if I start Lazarus with

pi@raspberrypi:~$ sudo /usr/lib/lazarus/2.0.0/startlazarus

it seems to work, but on startup this gives me a lot of messages and warnings. There must be a better way that I would like to learn

Thaddy

  • Hero Member
  • *****
  • Posts: 10293
Re: PiGpio exception SIGSEGV
« Reply #4 on: March 10, 2020, 07:31:47 am »
if you start from a terminal this is normal on all platforms.
 
Code: Bash  [Select][+][-]
  1. ./startlazarus --quiet
You will still get some output, but much less. And you can ignore them all.

If you install lazarus from the Raspbian package manager you can start Lazarus through a menu item and that won't show any messages at all. You can also create such a link yourself.
« Last Edit: March 10, 2020, 07:51:22 am by Thaddy »
I am more like donkey than shrek

babbel

  • Newbie
  • Posts: 4
Re: PiGpio exception SIGSEGV
« Reply #5 on: March 10, 2020, 08:37:00 am »
Ok, starting Lazarus will give me less warnings.
But running lazarus as root, does this give me also an executable that allows acces to the GPIO?

The executable still gives me an access violation and if I ignore this the PiGpio reports
"Error mapping gpio registry"

So I still need to understand more about how to set privileges to access the GPIO

About Ultibo, i seems what I need, but also it seems there is not a lot activity anymore as the latest news is from 2018 and I thing it will not support the RPi 4 I use

hansotten

  • New Member
  • *
  • Posts: 47
Re: PiGpio exception SIGSEGV
« Reply #6 on: March 10, 2020, 09:53:41 am »
I have the same problem with GPIO,rpi_hal and Lazarus, no access to /dev/mem is the cause of the troubles.

These libs should use /dev/gpiomem instead of /dev/mem as access in current versions of Raspbian is is enabled for user. But alas, access to /dev/mem requires root

Console apps work fine when run as root, Lazarus X apps not.
 



Thaddy

  • Hero Member
  • *****
  • Posts: 10293
Re: PiGpio exception SIGSEGV
« Reply #7 on: March 10, 2020, 10:29:53 am »
I have the same problem with GPIO,rpi_hal and Lazarus, no access to /dev/mem is the cause of the troubles.

These libs should use /dev/gpiomem instead of /dev/mem as access in current versions of Raspbian is is enabled for user. But alas, access to /dev/mem requires root

Console apps work fine when run as root, Lazarus X apps not.
The GPIO address in the wiki is only correct for RPi 1 so will sigsev on all others. I will edit it and add the GPIO base addresses for all other Pi versions. Can take some time, because I am busy. Possibly this weekend.
You can look up the GPIO base address from the Raspberry Pi chipset documentation for your revision. You need to divide the full address through $1000 to obtain the correct entry for PiGPIO.
I am more like donkey than shrek

hansotten

  • New Member
  • *
  • Posts: 47
Re: PiGpio exception SIGSEGV
« Reply #8 on: March 10, 2020, 01:23:15 pm »
I guess that the problem of the OP and me are not related to the GPIO address.

Like the OP  I started Lazarus as root with sudo and the resulting test program ran fine from run in Lazarus.
Our underlying problem seems to be the same, PIGPIO also tries to open /dev/mem as I read in the source.

So its rights on /dev/mem and/or being able to run a desktop with root privs. And we are not Linux experts enough and cant find a way.
« Last Edit: March 10, 2020, 02:58:17 pm by hansotten »

Thaddy

  • Hero Member
  • *****
  • Posts: 10293
Re: PiGpio exception SIGSEGV
« Reply #9 on: March 10, 2020, 01:31:20 pm »
Hans can you add a simple example that fails (just a led)? Then I can investigate further. I still think you are both using the GPIO address from the wiki, which is wrong for RPi3 and 4.
Wriiten from a RPi 4.... 8-)
I am more like donkey than shrek

hansotten

  • New Member
  • *
  • Posts: 47
Re: PiGpio exception SIGSEGV
« Reply #10 on: March 10, 2020, 01:36:52 pm »
Seems I found a solution here: https://wiki.archlinux.org/index.php/Running_GUI_applications_as_root

Hope this helps the OP also!

I applied method 2:

sudo nano /etc/profile

and added this line as last line

export XAUTHORITY=/home/pi/.Xauthority

Now i can do

$ sudo ./testinit (my simple test program with only the init line of rpi_hal)

and this worked without error, init succeeded.

Not a secure solution, but user pi already had the right to run apps as root and now also X apps.

Original text from https://wiki.archlinux.org/index.php/Running_GUI_applications_as_root

Method 2: Globally in /etc/profile
Add the following line to /etc/profile:

export XAUTHORITY=/home/username/.Xauthority
This will permanently allow root to connect to a non-root user's X server.

Or, merely specify a particular app:

XAUTHORITY=/home/username/.Xauthority appname
where appname is the name of the particular app. (e.g. kwrite

« Last Edit: March 10, 2020, 01:44:26 pm by hansotten »

avra

  • Hero Member
  • *****
  • Posts: 1945
    • Additional info
Re: PiGpio exception SIGSEGV
« Reply #11 on: March 10, 2020, 01:52:34 pm »
Have you seen "sudo adduser pi gpio" solution at below wiki page?
https://wiki.freepascal.org/Lazarus_on_Raspberry_Pi#Accessing_external_hardware

It looks much more proper.
« Last Edit: March 10, 2020, 01:54:09 pm by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

hansotten

  • New Member
  • *
  • Posts: 47
Re: PiGpio exception SIGSEGV
« Reply #12 on: March 10, 2020, 01:57:58 pm »
Have you seen "sudo adduser pi gpio" solution at below wiki page?
https://wiki.freepascal.org/Lazarus_on_Raspberry_Pi#Accessing_external_hardware

It looks much more proper.
That allows access to /dev/gpiomem which is now default in Raspbian.

The libraries require access to /dev/mem

 

TinyPortal © 2005-2018