use of /dev/gpiomem for non root usage

1,315 views
Skip to first unread message

Marc-Antoine Brenac

unread,
Feb 25, 2016, 6:06:12 AM2/25/16
to bcm2835
Since the first Lenny base version of raspbian they have add some special mapping for gpio access without the need to be root.

see here : 

Is there any plan to implement it in libbcm2835 ?

It would be so helpfull, even if it supports fewer features.

See you,

Marc-Antoine

Mike McCauley

unread,
Feb 25, 2016, 10:46:35 PM2/25/16
to bcm...@googlegroups.com
Hello,

the new /dev/gpiomem only exposes the GPIO pin access, but bcm2835 also
supports PWM, I2C and SPI peripherals. So supporting /dev/gpiomem does not
really fit well with the current design of bcm2835.

Cheers.
--
Mike McCauley VK4AMM mi...@airspayce.com
Airspayce Pty Ltd 9 Bulbul Place Currumbin Waters QLD 4223 Australia
http://www.airspayce.com
Phone +61 7 5598-7474

Marc-Antoine Brenac

unread,
Feb 26, 2016, 2:19:48 AM2/26/16
to bcm...@googlegroups.com
thx for your answer, I get totally it.
 
what if I just change the path in the lib, Do you think it will work fro GPIO at least ? or do I have to redo the mapping ?

any guess.

Marc-Antoine BRENAC
+33.687507577


--
You received this message because you are subscribed to a topic in the Google Groups "bcm2835" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bcm2835/RpVXHzlBv1g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bcm2835+u...@googlegroups.com.
To post to this group, send email to bcm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bcm2835/2201646.6uCEoLENSz%40zulu.
For more options, visit https://groups.google.com/d/optout.

Mike McCauley

unread,
Feb 26, 2016, 3:09:30 AM2/26/16
to bcm...@googlegroups.com
Hi,


On Friday, February 26, 2016 08:19:27 AM Marc-Antoine Brenac wrote:
> thx for your answer, I get totally it.
>
> what if I just change the path in the lib, Do you think it will work fro
> GPIO at least ? or do I have to redo the mapping ?

I dont think it will be that simple.

:-(

Cheers.

Mike McCauley

unread,
Feb 27, 2016, 10:29:13 PM2/27/16
to bcm...@googlegroups.com, Marc-Antoine Brenac
New version 1.50 now supports starting as non-root and opening /dev/gpiomem,
for GPIO access only.

Cheers.

On Friday, February 26, 2016 08:19:27 AM Marc-Antoine Brenac wrote:

Ron

unread,
Feb 27, 2016, 10:56:34 PM2/27/16
to bcm...@googlegroups.com
Hi Mike,

I am really not 100% on this stuff. What does this mean when it comes
to using the I2C interface (and such)?

73
Ron / W4MMP

Mike McCauley

unread,
Feb 27, 2016, 11:58:08 PM2/27/16
to bcm...@googlegroups.com
Hi,

On Saturday, February 27, 2016 10:56:31 PM 'Ron' via bcm2835 wrote:
> Hi Mike,
>
> I am really not 100% on this stuff. What does this mean when it comes
> to using the I2C interface (and such)?

You still need to be root to use anything other than the GPIO interface, such
as SPI, I2C etc.

This is explained in the doc in the new release.

Cheers.


>
> 73
> Ron / W4MMP
>
> On 2/27/2016 22:29, Mike McCauley wrote:
> > New version 1.50 now supports starting as non-root and opening
> > /dev/gpiomem, for GPIO access only.

Ron

unread,
Feb 28, 2016, 4:24:37 AM2/28/16
to bcm...@googlegroups.com
Hi Mike,

I suspected that would be the case, but wanted to be sure.

Thanks,

73
Ron / W4MMP

Marc-Antoine Brenac

unread,
Feb 28, 2016, 5:10:42 AM2/28/16
to bcm2835
Thanks Mike,

I'm eager to test it !

Ron

unread,
Feb 29, 2016, 12:20:54 PM2/29/16
to bcm...@googlegroups.com
Hi Mike,

When using gpio I still receive: bcm2835_init: Unable to open
/dev/gpiomem: Permission denied. Would you be so kind as to pass along
the contents of your /etc/apt/sources.list ? I think I have a messed
up version of Jessie. I have been using Jessie from when it was first
available (as announced last year sometime on the Raspberry forum).

Here is my sources.list
deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib
non-free rpi

I may be picking up the release from the wrong location.

73
Ron / W4MMP

On 2/27/2016 22:29, Mike McCauley wrote:

Marc-Antoine Brenac

unread,
Feb 29, 2016, 12:32:36 PM2/29/16
to bcm...@googlegroups.com
did you add pi to group gpio ?

sudo adduser pi gpio

Marc-Antoine BRENAC
+33.687507577

Ron

unread,
Feb 29, 2016, 12:46:48 PM2/29/16
to bcm...@googlegroups.com
Hi,

Thanks for the tip, but it didn't help.
73
Ron / W4MMP
You received this message because you are subscribed to the Google Groups "bcm2835" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bcm2835+u...@googlegroups.com.

To post to this group, send email to bcm...@googlegroups.com.

Ron

unread,
Feb 29, 2016, 1:40:02 PM2/29/16
to bcm...@googlegroups.com
Hi,

I'm pretty sure I have a munged up version of Jessie.  I'm will start from scratch with the foundations version of Jessie and see what happens. 
73
Ron / W4MMP

Ron

unread,
Feb 29, 2016, 10:55:20 PM2/29/16
to bcm...@googlegroups.com
Hi,

Well, I started from scratch, installed the Raspbian / Jessie,  recompiled and installed bcm2835 and then recompiled my application. 
The application only uses GPIO.  Now the application now produces a Segmentation fault when running as a non root user.  Running it as root, the application runs fine.  When debugging the application with gdb, I get this:

Program received signal SIGSEGV, Segmentation fault.
bcm2835_peri_read (paddr=0x7) at bcm2835.c:123
73
Ron / W4MMP 

Mike McCauley

unread,
Feb 29, 2016, 11:07:11 PM2/29/16
to bcm...@googlegroups.com
Hi,

Can you send the rest of the GDB trace back?

Sounds a bit to me like you are using a non-GPIO peripheral.

Cheers.
> >>> <mailto:bcm2835%2Bunsu...@googlegroups.com>.
> >>> To post to this group, send email to
> >>> bcm...@googlegroups.com.
> >>> To view this discussion on the web visit
> >>> https://groups.google.com/d/msgid/bcm2835/2201646.6uCEoL
> >>> ENSz%40zulu.
> >>> For more options, visit
> >>> https://groups.google.com/d/optout.
> >>>
> >>> For more options, visit https://groups.google.com/d/optout.

--

Ron

unread,
Feb 29, 2016, 11:18:31 PM2/29/16
to bcm...@googlegroups.com
Mike,

I don't know how to do that but if you provide the direction I will.

Can give you this. Here is the code where the seg fault happens:
int ATU_0_PIN = RPI_BPLUS_GPIO_J8_37;
int ATU_1_PIN = RPI_BPLUS_GPIO_J8_35;



bcm2835_set_debug(0);
if(!bcm2835_init()) return 1;
bcm2835_gpio_fsel(ATU_0_PIN, BCM2835_GPIO_FSEL_INPT);

SEG FAULT -----> bcm2835_gpio_set_pud(ATU_0_PIN,
BCM2835_GPIO_PUD_DOWN); <- SEG FAULT

bcm2835_gpio_fsel(ATU_1_PIN, BCM2835_GPIO_FSEL_INPT);
bcm2835_gpio_set_pud(ATU_1_PIN, BCM2835_GPIO_PUD_UP);

73
Ron / W4MMP

Mike McCauley

unread,
Mar 1, 2016, 12:06:55 AM3/1/16
to bcm...@googlegroups.com
Hello Ron,

well thats the problem.

The PUD is a different peripheral to the GPIO, and AFAICT, there is no access
to PUD without being root.

Cheers.
> >>>>> https://www.raspberrypi.org/blog/raspbian-jessie-> >>>>> is-> >>> here/

Ron

unread,
Mar 1, 2016, 12:23:58 AM3/1/16
to bcm...@googlegroups.com
Hi David,

Ok, thanks much! I just thought I would give the application a spin
after upgrading to Raspbian/Jessie and your new version.

Back to root !

73
Ron / W4MMP

Mike McCauley

unread,
Mar 1, 2016, 12:40:50 AM3/1/16
to bcm...@googlegroups.com
On Tuesday, March 01, 2016 12:23:56 AM 'Ron' via bcm2835 wrote:
> Hi David,
>
> Ok, thanks much! I just thought I would give the application a spin
> after upgrading to Raspbian/Jessie and your new version.
>
> Back to root !

Sorry bout that.

Nothing to be done though :-(

Cheers.
Reply all
Reply to author
Forward
0 new messages