Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2016-01

Raspberry Pi Debug Digital I/O

16 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Donald Ziesig

Hi All!

This applies to the Raspberry Pi 2 B.

After a bit of cut and try, I got Anthony Walter's version of Lazarus to run as root (from the Raspbian menu) so I could debug programs which do DigitalRead, DigitalWrite, etc. using h2wiringPi.

Note that this could be dangerous if you are permanently connected to the web while using Lazarus, but in my case, the only time that my Pi will be connected to the web is when I am getting Lazarus set up (and it is not yet running as root). Thereafter I will be connected directly from Pi to Laptop on a private subnet with no router. Once the app is developed the Pi will not be , I got the Pi setup so that if it fails DHCP (is not connected to a router) it reverts to the private subnet. If anyone wants to do this, let me know and I'll publish the "magic incantations". ;-) It is much more convenient than editing /etc/network/interfaces every time you need to change from accessing the web to a local private subnet.

The application itself must run as root to do digital I/O. If you don't want to debug using the IDE, you don't have to make the IDE run as root, though, just the app.

Using Anthony's default paths, I created a file in /home/<mydir>/Development/FreePascal/lazarus called lazroot.sh This file contains two lines:

xhost +localhost
sudo /home/<mydir>/Development/FreePascal/lazarus/lazarus.sh

Then chmod +x lazroot.sh

I used the Menu > Preferences > Main Menu Editor to change the command which starts Lazarus to:

/home/<mydir>/Development/FreePascal/lazarus/lazroot.sh

Obviously <mydir> is the directory where lazarus is located.

At first I tried to change the Menu command to the two lines in the lazroot.sh file, but the internals of the menu system did not support multi-command arguments.

For some reason, Lazarus re-built itself (as if I were installing components) the very first time I ran it as root. After that it starts normally.

Hope this helps someone in return for all the help I have been given here.

Don Ziesig

Reply by email

Bo Berglund
to Donald Ziesig
Donald Ziesig wrote
The application itself must run as root to do digital I/O. If you don't want to debug using the IDE, you don't have to make the IDE run as root, though, just the app.

I do not think this is necessary!

I am NOT running my RPi2B as any other user than pi and it works just fine to access the GPIO pins. Both FPC and Lazarus run just fine as pi user.

The trick is to make sure that pi belongs to the proper groups dealing with the hardware. You can check this using the command: cat /etc/group | grep pi

It will list the groups pi belongs to and you will find out if there are missing groups here. This is what my Pi says:

pi at rpi2-jessie2:~/dev $ cat /etc/group | grep pi adm:x:4:pi
dialout:x:20:pi
cdrom:x:24:pi
sudo:x:27:pi
audio:x:29:pi
video:x:44:pi
plugdev:x:46:pi
games:x:60:pi
users:x:100:pi
input:x:101:pi
netdev:x:108:pi
spi:x:999:pi
i2c:x:998:pi
gpio:x:997:pi <== This for GPIO

I never use the NOOBS disk, I always create the start image from the offiocial Raspbian Jessie image, currently I am on the Nov 2015 release. And the groups above were set from the start on that distro.

Bo Berglund Developer in Sweden

Reply by email

Koenraad Lelong
to Bo Berglund

Op 24-01-16 om 11:47 schreef Bo Berglund:

Show quoted text 9 lines
On Fri, 22 Jan 2016 20:55:59 -0500, Donald Ziesig wrote: > The application itself must run as root to do digital I/O. If you don't > want to debug using the IDE, you don't have to make the IDE run as root, > though, just the app. I do not think this is necessary!

Strange,

I tried this with my test-application and it does not work as user 'pi'. I investigated a little bit further.
No application running :
root at raspberrypi:/home/pi/Documents/lazarus/pascalio/koen-test# ls -l /sys/class/gpio
totaal 0
-rwxrwx--- 1 root gpio 4096 jan 22 22:03 export
lrwxrwxrwx 1 root gpio 0 jan 22 22:03 gpiochip0 -> ../../devices/platform/soc/3f200000.gpio/gpio/gpiochip0 -rwxrwx--- 1 root gpio 4096 jan 22 22:03 unexport

When I run the application as 'pi', I get this :

root at raspberrypi:/home/pi/Documents/lazarus/pascalio/koen-test# ls -l /sys/class/gpio
totaal 0
-rwxrwx--- 1 root gpio 4096 jan 22 22:03 export
lrwxrwxrwx 1 root gpio 0 jan 24 19:43 gpio17 -> ../../devices/platform/soc/3f200000.gpio/gpio/gpio17 lrwxrwxrwx 1 root gpio 0 jan 24 19:43 gpio18 -> ../../devices/platform/soc/3f200000.gpio/gpio/gpio18 lrwxrwxrwx 1 root gpio 0 jan 22 22:03 gpiochip0 -> ../../devices/platform/soc/3f200000.gpio/gpio/gpiochip0 -rwxrwx--- 1 root gpio 4096 jan 22 22:03 unexport
root at raspberrypi:/home/pi/Documents/lazarus/pascalio/koen-test#

But the IO does not work. When I do
echo 1 > /sys/class/gpio/gpio17/value
from the command-line, the IO does not work, even when I do this as root.

When I run the application as root, everything works as expected.

B.T.W. what 'library' are you using for the GPIO's ?

Koenraad

Reply by email

Bo Berglund
to Koenraad Lelong
Koenraad Lelong wrote 13 lines
Op 24-01-16 om 11:47 schreef Bo Berglund: > On Fri, 22 Jan 2016 20:55:59 -0500, Donald Ziesig > wrote: > >> The application itself must run as root to do digital I/O. If you don't >> want to debug using the IDE, you don't have to make the IDE run as root, >> though, just the app. > > I do not think this is necessary! > Strange, I tried this with my test-application and it does not work as user 'pi'.

On your Pi, what groups are user pi member of?
...

B.T.W. what 'library' are you using for the GPIO's ?

I have used PiGpio.pas, I will try to attach it - don't really know how one does thios in a newsreader...

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Koenraad Lelong: Op 24-01-16 om 11:47 schreef Bo Berglund: I tried this with my test-application and it…

begin 644 PiGpio.zip
(`..:*DBT1R3E"@L``%\E```*````4&E'<&EO+G!A<\U:;4_;
MRA+^W$K]#U,)Z22G*;&=0(&<'IU`$AH52)2$(MT/C9QX#;YU;,MVH+3BO]]G M=NVU"8'"%>7>B`9[9W;>=W9FZ#+P4AIZAY$7MMZ\_OGF->T?'%L[C2TZ'/8' M-!+G7I+&U]2)O4L1U\CVDY#F=D#+1%`:TL(.O&CIVZF@>;2D,+T0,<7Y+CL6 M=O+F-:A.+KR$YJ$C"+]3D:3"H3#PKVD_#FUG'BYH-E](OB!3(\=S71&+(`6) M!2\EX'1-@<`V#0/9<\A-CI2-O$7DBP76[=0+`\G5,LP&'=JS,*;QC]#WP\1[ M\_H&>FXL6)1P]F\WFM_\W/CT[H;QO2`5L6O/!;_4ZQ!:D,O;KKS at G,*(Z4*) M((U#/Z&K"R&UQ9?6C'(Z8+GR$ZBF8AAB&&?K$U)>F at 1^:
MP08A[8OXW%\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y`YUWY3>'_$-H4;PW4+SKVK[`,U?PY+$0W[VT=+$\ZC*#5Z-L M+E6ZPY3B?"Q5%;_?Z\E>6=8=<]U7_487@;#\+QK_`5!+`0((`..: M*DBT1R3E"@L``%\E```*`"0```````$`(`````````!0:4=P:6\N<&%S"@`@ @(J-\M-+T0&`BHWRTTO1`1#[DX;
*7````#(+`````(J-
`
end

Reply by email

Marc Santhoff
to Koenraad Lelong: Op 24-01-16 om 11:47 schreef Bo Berglund: I tried this with my test-application and it…
Koenraad Lelong wrote 20 lines
When I run the application as 'pi', I get this : root at raspberrypi:/home/pi/Documents/lazarus/pascalio/koen-test# ls -l /sys/class/gpio totaal 0 -rwxrwx--- 1 root gpio 4096 jan 22 22:03 export lrwxrwxrwx 1 root gpio 0 jan 24 19:43 gpio17 -> ../../devices/platform/soc/3f200000.gpio/gpio/gpio17 lrwxrwxrwx 1 root gpio 0 jan 24 19:43 gpio18 -> ../../devices/platform/soc/3f200000.gpio/gpio/gpio18 lrwxrwxrwx 1 root gpio 0 jan 22 22:03 gpiochip0 -> ../../devices/platform/soc/3f200000.gpio/gpio/gpiochip0 -rwxrwx--- 1 root gpio 4096 jan 22 22:03 unexport root at raspberrypi:/home/pi/Documents/lazarus/pascalio/koen-test# But the IO does not work. When I do echo 1 > /sys/class/gpio/gpio17/value from the command-line, the IO does not work, even when I do this as root. When I run the application as root, everything works as expected.

What do

$ cat /etc/group | grep gpio

and

$ ls -lL /sys/class/gpio

show?

Marc Santhoff

Reply by email

Bo Berglund
to Marc Santhoff
Marc Santhoff wrote 9 lines
What do $ cat /etc/group | grep gpio and $ ls -lL /sys/class/gpio show?

For me it is like this:
pi at rpi2-jessie2:~/dev $ cat /etc/group | grep gpio gpio:x:997:pi
pi at rpi2-jessie2:~/dev $ ls -lL /sys/class/gpio
total 0
-rwxrwx--- 1 root gpio 4096 Jan 17 16:47 export
drwxrwx--- 2 root gpio 0 Jan 17 16:47 gpiochip0 -rwxrwx--- 1 root gpio 4096 Jan 17 16:47 unexport

Bo Berglund Developer in Sweden

Reply by email

Marc Santhoff
to Bo Berglund
Bo Berglund wrote 16 lines
On Sun, 24 Jan 2016 21:42:06 +0100, Marc Santhoff wrote: >What do > >$ cat /etc/group | grep gpio > >and > >$ ls -lL /sys/class/gpio > >show? For me it is like this: pi at rpi2-jessie2:~/dev $ cat /etc/group | grep gpio gpio:x:997:pi

Thje last one wrong, should have been

$ ls -lL /sys/class/gpio/gpiochip0

and

$ ls -lL ../../devices/platform/soc/3f200000.gpio/gpio/

to see the the targets of the links (correct permissions there, too?) and content of the directory, sorry.

Show quoted text 7 lines
pi at rpi2-jessie2:~/dev $ ls -lL /sys/class/gpio total 0 -rwxrwx--- 1 root gpio 4096 Jan 17 16:47 export drwxrwx--- 2 root gpio 0 Jan 17 16:47 gpiochip0 -rwxrwx--- 1 root gpio 4096 Jan 17 16:47 unexport
Marc Santhoff

Reply by email

Donald Ziesig
to Bo Berglund: On Fri, 22 Jan 2016 20:55:59 -0500, Donald Ziesig I do not think this is necessary! I am…
Bo Berglund wrote 34 lines
On Fri, 22 Jan 2016 20:55:59 -0500, Donald Ziesig wrote: > The application itself must run as root to do digital I/O. If you don't > want to debug using the IDE, you don't have to make the IDE run as root, > though, just the app. I do not think this is necessary! I am NOT running my RPi2B as any other user than pi and it works just fine to access the GPIO pins. Both FPC and Lazarus run just fine as pi user. The trick is to make sure that pi belongs to the proper groups dealing with the hardware. You can check this using the command: cat /etc/group | grep pi It will list the groups pi belongs to and you will find out if there are missing groups here. This is what my Pi says: pi at rpi2-jessie2:~/dev $ cat /etc/group | grep pi adm:x:4:pi dialout:x:20:pi cdrom:x:24:pi sudo:x:27:pi audio:x:29:pi video:x:44:pi plugdev:x:46:pi games:x:60:pi users:x:100:pi input:x:101:pi netdev:x:108:pi spi:x:999:pi i2c:x:998:pi gpio:x:997:pi <== This for GPIO

Hi Bo,

I get exactly this on my pi except there is a line:

pi:x:1000:

immediately following the netdev line..

Show quoted text 5 lines
I never use the NOOBS disk, I always create the start image from the offiocial Raspbian Jessie image, currently I am on the Nov 2015 release. And the groups above were set from the start on that distro.

I updated the copy of NOOBS to use jessie as soon as jessie was available. I updated FPC and Lazarus from Anthony's download (as he corrected it for the problem with installing custom components) as soon as it was available.

When I run my program unprivileged from the command line I get:

wiringPiSetup: Must be root. (did you forget sudo?).

Using the same executable but prefacing the command with sudo, it runs and does digital I/O.

When I try to run my program using unprivileged Lazarus it compiles but the Debugger crashes.

When I run my program using root-mode Lazarus it compiles, runs and does digital I/O.

The comments in h2WiringPi state that the programs that use it must run as root, which is how I got to this position in the first place.

Don

Reply by email

Bo Berglund
to Marc Santhoff: Thje last one wrong, should have been $ ls -lL /sys/class/gpio/gpiochip0 and $ ls -lL…
Marc Santhoff wrote 7 lines
> For me it is like this: > pi at rpi2-jessie2:~/dev $ cat /etc/group | grep gpio > gpio:x:997:pi Thje last one wrong, should have been $ ls -lL /sys/class/gpio/gpiochip0

New test:

pi at rpi2-jessie2:~/dev $ ls -lL /sys/class/gpio/gpiochip0 total 0
-rwxrwx--- 1 root gpio 4096 Jan 17 16:47 base
drwxr-xr-x 3 root root 0 Jan 17 16:47 device
-rwxrwx--- 1 root gpio 4096 Jan 17 16:47 label
-rwxrwx--- 1 root gpio 4096 Jan 17 16:47 ngpio
drwxrwx--- 2 root gpio 0 Jan 17 16:47 subsystem -rwxrwx--- 1 root gpio 4096 Jan 17 16:47 uevent

and $ ls -lL ../../devices/platform/soc/3f200000.gpio/gpio/

This is a relative path and you did not specify where one should be located in order to execute it. Cannot perform this command. Please supply an absolute path instead.

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Donald Ziesig: I get exactly this on my pi except there is a line: pi:x:1000: immediately following the…
Donald Ziesig wrote 6 lines
I get exactly this on my pi except there is a line: pi:x:1000: immediately following the netdev line..

I edited out that because the grep found pi in the wrong place...

Show quoted text 13 lines
wiringPiSetup: Must be root. (did you forget sudo?). Using the same executable but prefacing the command with sudo, it runs and does digital I/O. When I try to run my program using unprivileged Lazarus it compiles but the Debugger crashes. When I run my program using root-mode Lazarus it compiles, runs and does digital I/O. The comments in h2WiringPi state that the programs that use it must run as root, which is how I got to this position in the first place.

I solved my root/pi problem back in Oct 2015.
You can read about it here:
http://lists.lazarus.freepascal.org/pipermail/lazarus/2015-October/094438.html

Specifically see how the change from using /dev/mem to /dev/gpiomem made it possible to run as user pi.

I personally totally detest having to be root in a development system and having my programs require root to run.
I don't have to anymore.

Bo Berglund Developer in Sweden

Reply by email

Koenraad Lelong
to Marc Santhoff: Thje last one wrong, should have been $ ls -lL /sys/class/gpio/gpiochip0 and $ ls -lL…

Op 25-01-16 om 00:18 schreef Marc Santhoff:

On Mo, 2016-01-25 at 00:11 +0100, Bo Berglund wrote: > On Sun, 24 Jan 2016 21:42:06 +0100, Marc Santhoff > wrote: >

My results :

root at raspberrypi:/home/pi# grep gpio /etc/group gpio:x:997:pi
root at raspberrypi:/home/pi# ls -lL /sys/class/gpio/gpiochip0 totaal 0
-rwxrwx--- 1 root gpio 4096 jan 24 22:10 base
drwxr-xr-x 3 root root 0 jan 24 22:10 device
-rwxrwx--- 1 root gpio 4096 jan 24 22:10 label
-rwxrwx--- 1 root gpio 4096 jan 24 22:10 ngpio
drwxrwx--- 2 root gpio 0 jan 24 22:10 subsystem -rwxrwx--- 1 root gpio 4096 jan 24 22:10 uevent
root at raspberrypi:/home/pi# cd /sys/class/gpio/

Application running as user pi :
root at raspberrypi:/sys/class/gpio# ls -lL
../../devices/platform/soc/3f200000.gpio/gpio/
totaal 0
drwxrwx--- 2 root gpio 0 jan 25 08:54 gpio17
drwxrwx--- 2 root gpio 0 jan 25 08:54 gpio18
drwxrwx--- 2 root gpio 0 jan 24 22:10 gpiochip0

Application running as user root :
root at raspberrypi:/sys/class/gpio# ls -lL
../../devices/platform/soc/3f200000.gpio/gpio/
totaal 0
drwxrwx--- 2 root gpio 0 jan 25 08:56 gpio17
drwxrwx--- 2 root gpio 0 jan 25 08:56 gpio18
drwxrwx--- 2 root gpio 0 jan 24 22:10 gpiochip0

I'm going to try that patch of Bo.

I'll report back.

Koenraad.

Reply by email

Koenraad Lelong
to Koenraad Lelong

Op 25-01-16 om 09:00 schreef Koenraad Lelong:

Show quoted text 5 lines
Op 25-01-16 om 00:18 schreef Marc Santhoff: I'm going to try that patch of Bo. I'll report back.

First : I'm using pascalio, on a Pi2 model B.

Just modified bcm2708.pas :
   GPIO_BASE = (BCM2708_PERI_BASE + $003F0000); // GPIO controller
and
   mem_fd := FpOpen('/dev/gpiomem', O_RDWR OR O_SYNC);

Now I can run my app as user 'pi'.

Thanks.

According to Bo's post
(http://lists.lazarus.freepascal.org/pipermail/lazarus/2015-October/094438.html) GPIO_BASE depends on where the app runs.
I'm going to look for a way to detect which device the application runs on so I can automatically switch the GPIO_BASE.
Suggestions ?

Koenraad.

Reply by email

Koenraad Lelong
to Koenraad Lelong

Op 25-01-16 om 09:40 schreef Koenraad Lelong:

Show quoted text 5 lines
According to Bo's post (http://lists.lazarus.freepascal.org/pipermail/lazarus/2015-October/094438.html) GPIO_BASE depends on where the app runs. I'm going to look for a way to detect which device the application runs on so I can automatically switch the GPIO_BASE.

FWIW, rpi_hal is already testing for which pi it runs on, and sets it's GPIO_BASE based on that.

I'm going to try to mimic that in pascalio.

Koenraad.

Reply by email

Koenraad Lelong
to Koenraad Lelong: Op 25-01-16 om 09:00 schreef Koenraad Lelong: First : I'm using pascalio, on a Pi2 model…

Op 25-01-16 om 09:40 schreef Koenraad Lelong:

Show quoted text 10 lines
First : I'm using pascalio, on a Pi2 model B. Just modified bcm2708.pas : GPIO_BASE = (BCM2708_PERI_BASE + $003F0000); // GPIO controller and mem_fd := FpOpen('/dev/gpiomem', O_RDWR OR O_SYNC); Now I can run my app as user 'pi'. Thanks.

Forget this. I don't know what I did, but this seems not to work anymore. Looking at the sources of pascalio, it should not have worked anyway.

Koenraad.

Reply by email

Marc Santhoff
to Bo Berglund: On Mon, 25 Jan 2016 00:18:50 +0100, Marc Santhoff New test: pi at rpi2-jessie2:~/dev $ ls…
Bo Berglund wrote 29 lines
On Mon, 25 Jan 2016 00:18:50 +0100, Marc Santhoff wrote: >> For me it is like this: >> pi at rpi2-jessie2:~/dev $ cat /etc/group | grep gpio >> gpio:x:997:pi > >Thje last one wrong, should have been > >$ ls -lL /sys/class/gpio/gpiochip0 New test: pi at rpi2-jessie2:~/dev $ ls -lL /sys/class/gpio/gpiochip0 total 0 -rwxrwx--- 1 root gpio 4096 Jan 17 16:47 base drwxr-xr-x 3 root root 0 Jan 17 16:47 device -rwxrwx--- 1 root gpio 4096 Jan 17 16:47 label -rwxrwx--- 1 root gpio 4096 Jan 17 16:47 ngpio drwxrwx--- 2 root gpio 0 Jan 17 16:47 subsystem -rwxrwx--- 1 root gpio 4096 Jan 17 16:47 uevent >and > >$ ls -lL ../../devices/platform/soc/3f200000.gpio/gpio/ This is a relative path and you did not specify where one should be located in order to execute it. Cannot perform this command. Please supply an absolute path instead.

I know. The user can see from where links are not resolved by reading the failing command. My point was to help diagnosing why a program running as user pi did not work. I explained with the changed command, for checking permissions on the targets of the links, not the links themselves.

But since you found the cause by your patch differentiating between RPi1 and RPi2 it's obsolete now.

Marc Santhoff

Reply by email