×

INDI Library v2.0.7 is Released (01 Apr 2024)

Bi-monthly release with minor bug fixes and improvements

Focuser driver for RPi with A4988 stepper driver

  • Posts: 21
  • Thank you received: 2
As per my earlier post, I am in the process of making a focuser driver for Raspberry Pi with the A4988 stepper driver.

I find the best performing option for RPi GPIO access is via /dev/mem, which requires root access.

I have had some trouble getting setuid access to work, and have found the issue is with following snippet in indidrivermain.c dropping the effective uid:
#ifndef _WIN32
    setgid( getgid() );
    setuid( getuid() );
    if (geteuid() != getuid())
        exit(255);
#endif

Is this preventing setuid for drivers by design, or is there a better way of getting /dev/mem access in a driver?
10 years 3 weeks ago #898

Please Log in or Create an account to join the conversation.

  • Posts: 314
  • Thank you received: 34
Sorry for diggin out this old thread but I stumbled upon it while investigating how to access gpio's without root
on non raspbian systems like gentoo on my RaspberryPi 2.
I was trying to start an indiserver as normal user with indi_wiringpi_gpio driver which gave an error:
wiringPiSetup: Unable to open /dev/mem

Check the group and its "rw" status of
pi@astro ~ $ ls -lah /dev/gpiomem 
crw-rw---- 1 root gpio 245, 0  1. Jan  1970  /dev/gpiomem

If gpio doesnt exist just create that group and change the group ownership of "/dev/gpiomem"
to it. Then add your ordinary user to the gpio group and you should have non root
access to gpio. Of cause you then have to do the change of gpiomem on every reboot so just put it in
a system startup script
--= human, without Windows™ =--
pls excuse my bad english! :)
Last edit: 6 years 8 months ago by pauledd.
6 years 8 months ago #18443

Please Log in or Create an account to join the conversation.

  • Posts: 314
  • Thank you received: 34
Ok, this seems not to work with code that uses the bcm2835 library (like the astroberry focuser driver) that accesses /dev/mem.
Even changing group and permission of /dev/mem seems not to work for non-root access.
If anyone is aware of another trick please share it. In the meantime I'll willy-nilly have to use root
to start my indiserver :unsure:
--= human, without Windows™ =--
pls excuse my bad english! :)
6 years 8 months ago #18444

Please Log in or Create an account to join the conversation.

Time to create page: 0.362 seconds