[Lazarus] Raspberry Pi Debug Digital I/O

Donald Ziesig donald at ziesig.org
Mon Jan 25 04:02:49 CET 2016


On 01/24/2016 05:47 AM, Bo Berglund wrote:
> On Fri, 22 Jan 2016 20:55:59 -0500, Donald Ziesig <donald at ziesig.org>
> 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..
>
> 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







More information about the Lazarus mailing list