19

I am working on writing a graphical application that uses the Pi's GPU, and I constantly get * failed to open vchiq instance errors when running my programs. This is usually fixed by a sudo chmod 777 /dev/vchiq, but (1) this is a very insecure fix that is definitely not suited to deployment to user-owned devices, and (2) it gets reset after each reboot.

How can I fix my /dev/vchiq problems "the right way", persistently, without introducing security issues?

24

I was able to solve a similar problem by adding myself to the video group (I was not using the default user). Maybe this can help.

The command is:

sudo usermod -a -G video $(whoami)

You will need to log out and in again for the change to take effect.

  • 2
    This worked for me (sudo usermod -a -G video $(whoami)), I would also recommend (for security purposes) adding a dedicated user for whatever process will need access to the camera and adding only that user to the video group. – n8henrie May 14 '16 at 15:53
  • 3
    After rebooting, this permanent solution works fine and is relatively safe. – Serge Stroobandt May 16 '16 at 18:55
  • Reboot required.... – Moosa Baloch Nov 12 '17 at 21:23
  • 2
    This worked for me too! Thanks. Reboot is not necessary, logging out and logging in again is enough. – tuvokki Mar 28 '18 at 16:00
  • 1
    This is the proper, secure way to do it. If you have a dedicated user for this function, you can add them by replacing $(whoami) with that username. – IceMage Feb 1 at 15:06
6

You can create a udev rule to set specific permissions on the device. As root, you could:

echo 'SUBSYSTEM=="vchiq",GROUP="video",MODE="0660"' > /etc/udev/rules.d/10-vchiq-permissions.rules
usermod -a -G video YourUnprivilegedUser
  • This does not fix the problem. After running that, I still get the error. – Cerin Oct 17 '15 at 6:49
  • I suspect the permissions are done in a higher (thus later in the running order) udev rule which undos this change. On my (Debian) PC the system supplied file is /lib/udev/rules.d/91-permissions.rules so I'd try writing this to an even higher one (and perhaps include local in the name to identify it as a local modification), i.e.: echo `SUBSYSTEM=="vchiq",GROUP="video",MODE="0660"\' > /etc/udev/rules.d/92-local-vchiq-permissions.rules – SlySven Jan 19 '16 at 7:50
  • I get permission denied, what might be wrong? – dmigo Sep 22 '16 at 18:08
  • Works perfectly for me. Elegant solution if usermod isn't enough – Axel Advento Aug 1 '18 at 13:15
5

You could set SUID permission

sudo chmod u+s /dev/vchiq
  • What does this do? – fouric Jun 13 '14 at 5:00
  • 1
    When an executable file has been given the setuid attribute, normal users on the system who have permission to execute this file gain the privileges of the user who owns the file (commonly root). You could set this on your program (assuming it is owned by root). As /dev/vchiq belongs to group video another option is to set setgid and the group on your program to video. – Milliways Jun 13 '14 at 6:17
  • 1
    That didn't help, albeit user www-data is in video group, but I succeeded with chmod a+rw /dev/vchiq on Raspbian Stretch. – Jan Turoň Dec 21 '17 at 10:23
0

add

start_x=1 
gpu_mem=256

to boot/config.txt then run sudo raspistill -o cam.jpg

Of course I added the path for the raspistill. It worked for me in Ubuntu.

  • I do not see how this answers the OP's question - could you expand your answer to explain how it works on the Raspberry Pi? – SlySven Jan 19 '16 at 7:54
0

If you are running raspistill from a php script accessed via a browser then you need to enter: sudo usermod -a -G video www-data to give Apache the necessary permissions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.