Permission denied to non-root user for USB device

10,327
  1. Make sure your udev rule is correct:

    SUBSYSTEM=="usb", ATTRS{product}=="USBtiny", ATTRS{idProduct}=="0c9f", ATTRS{idVendor}=="1781", MODE="0660", GROUP="dialout"
    
  2. Make sure to refresh udev:

    sudo udevadm control --reload-rules && sudo udevadm trigger
    
  3. Make sure to unplug and replug the USB device!

The last one is what took me some time to figure out!

Share:
10,327

Related videos on Youtube

mmachenry
Author by

mmachenry

Updated on September 18, 2022

Comments

  • mmachenry
    mmachenry over 1 year

    I'm having a lot of difficulty getting the Arduino Tiny AVR Programmer, aka (PMG-11801) to work on my Ubuntu 18.04 laptop. This is an Arduino device that programs ATTiny85 chips in the Arduino IDE.

    I have read several forum posts from various places and tried a solution that looks like it worked for many others but it hasn't worked for me. Here's what I've done.

    mmachenry$ lsusb
    ... other devices ...
    Bus 001 Device 013: ID 1781:0c9f Multiple Vendors USBtiny
    ... other devices ...
    

    I note the 1781:0c9f for the vendor and product ID for the next step.

    From various web pages I found, it seems like I need an entry in /etc/udev/rules.d to allow permission to use this device to non-root users. I added it and it looks like this:

    mmachenry$ cat /etc/udev/rules.d/99-USBtiny.rules 
    SUBSYSTEM=="usb", ATTR{idVendor}=="1781", ATTR{idProduct}=="0c9f", GROUP="adm", MODE="0666"
    

    Also note that I'm in the proper group.

    mmachenry$ groups
    mmachenry adm dialout cdrom sudo dip plugdev docker lpadmin sambashare
    

    In order to have this take effect, ran these immediately after creating that rules file.

    sudo service udev restart
    sudo udevadm control --reload-rules
    

    As requested by Norbert's comment, I ran a sanity check on my user groups but there seems to be nothing wrong as there is no output.

    mmachenry@mmachenry-laptop:~$ sudo update-passwd --sanity-check --verbose
    

    But when I run avrdude, I get permission denied.

    mmachenry$ hardware/tools/avr/bin/avrdude -C/home/mmachenry/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/tools/avr/etc/avrdude.conf -vv -pattiny85 -cusbtiny
    
    avrdude: Version 6.3, compiled on Jan 17 2017 at 11:00:16
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2014 Joerg Wunsch
    
             System wide configuration file is "/home/mmachenry/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/tools/avr/etc/avrdude.conf"
             User configuration file is "/home/mmachenry/.avrduderc"
             User configuration file does not exist or is not a regular file, skipping
    
             Using Port                    : usb
             Using Programmer              : usbtiny
    avrdude: usbdev_open(): Found USBtinyISP, bus:device: 001:013
    avrdude: Warning: cannot open USB device: Permission denied
    avrdude: Error: Could not find USBtiny device (0x1781/0xc9f)
    
    avrdude done.  Thank you.
    

    However, I get much different, positive output when running the command with sudo.

    sudo hardware/tools/avr/bin/avrdude -C/home/mmachenry/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/tools/avr/etc/avrdude.conf -vv -pattiny85 -cusbtiny
    
    avrdude: Version 6.3, compiled on Jan 17 2017 at 11:00:16
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2014 Joerg Wunsch
    
             System wide configuration file is "/home/mmachenry/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/tools/avr/etc/avrdude.conf"
             User configuration file is "/home/mmachenry/.avrduderc"
             User configuration file does not exist or is not a regular file, skipping
    
             Using Port                    : usb
             Using Programmer              : usbtiny
    avrdude: usbdev_open(): Found USBtinyISP, bus:device: 001:013
             AVR Part                      : ATtiny85
             Chip Erase delay              : 400000 us
             PAGEL                         : P00
             BS2                           : P00
             RESET disposition             : possible i/o
             RETRY pulse                   : SCK
             serial program mode           : yes
             parallel program mode         : yes
             Timeout                       : 200
             StabDelay                     : 100
             CmdexeDelay                   : 25
             SyncLoops                     : 32
             ByteDelay                     : 0
             PollIndex                     : 3
             PollValue                     : 0x53
             Memory Detail                 :
    
                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               eeprom        65    12     4    0 no        512    4      0  4000  4500 0xff 0xff
               flash         65     6    32    0 yes      8192   64    128 30000 30000 0xff 0xff
               signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
               lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
               lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
               hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
               efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
               calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
    
             Programmer Type : USBtiny
             Description     : USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/
    avrdude: programmer operation not supported
    
    avrdude: Using SCK period of 10 usec
    CMD: [ac 53 00 00] [ac 52 53 00]
    avrdude: AVR device initialized and ready to accept instructions
    
    Reading |                                                    | 0% 0.00sCMD: [30 00 00 00] [00 30 00 1e]
    CMD: [30 00 01 00] [00 30 00 93]
    Reading | #################                                  | 33% 0.00sCMD: [30 00 02 00] [00 30 00 0b]
    Reading | ################################################## | 100% 0.00s
    
    avrdude: Device signature = 0x1e930b (probably t85)
    CMD: [50 00 00 00] [00 50 00 e2]
    CMD: [50 00 00 00] [00 50 00 e2]
    CMD: [50 00 00 00] [00 50 00 e2]
    CMD: [58 08 00 00] [00 58 08 df]
    CMD: [58 08 00 00] [00 58 08 df]
    CMD: [58 08 00 00] [00 58 08 df]
    avrdude: safemode: hfuse reads as DF
    CMD: [50 08 00 00] [00 50 08 ff]
    CMD: [50 08 00 00] [00 50 08 ff]
    CMD: [50 08 00 00] [00 50 08 ff]
    avrdude: safemode: efuse reads as FF
    
    CMD: [50 00 00 00] [00 50 00 e2]
    CMD: [50 00 00 00] [00 50 00 e2]
    CMD: [50 00 00 00] [00 50 00 e2]
    CMD: [58 08 00 00] [00 58 08 df]
    CMD: [58 08 00 00] [00 58 08 df]
    CMD: [58 08 00 00] [00 58 08 df]
    avrdude: safemode: hfuse reads as DF
    CMD: [50 08 00 00] [00 50 08 ff]
    CMD: [50 08 00 00] [00 50 08 ff]
    CMD: [50 08 00 00] [00 50 08 ff]
    avrdude: safemode: efuse reads as FF
    avrdude: safemode: Fuses OK (E:FF, H:DF, L:E2)
    
    avrdude done.  Thank you.
    

    Running this inside the Arduino IDE has the same effect. As a normal user, I get permission denied. When I run the IDE as root, it works fully and uploads my program to the Arduino. Note that this device is recognized as a USB device, since it's the usbtinyISP, and not as a serial device like some Arduinos.

    Why is the permission for a regular user to access this device still denied?

    Thank you.

    • N0rbert
      N0rbert almost 6 years
      Looks very strange. You should run sanity check (see details in /usr/share/doc/base-passwd/users-and-groups.html) of your passwd and groups files. Please run sudo update-passwd --sanity-check --verbose and add output (if any) to the question.
    • mmachenry
      mmachenry almost 6 years
      N0rbert, I did that. It doesn't seem to have any output which I think means my user-groups are in a sane situation. A good try though.
    • user.dz
      user.dz over 5 years
      @mmachenry , probably udev rule actions are not applied for some reason. Would you check ls -la /dev/ if it had got correct group and permissions and add that line related USB serial to the question. Also for complete info udevadmi info -a /dev/..
  • Gabriel Staples
    Gabriel Staples about 4 years
    Note that an alternative to having to add your user to the dialout group in this case is to use MODE="0666" instead of MODE="0660". This gives read-write (rw) privileges to ALL users instead of just to the owner (user) and those who are in the dialout (as set in this case) group. If you use MODE="0666" you can also delete the GROUP="dialout" part entirely, as it no longer matters.
  • Gabriel Staples
    Gabriel Staples about 4 years
    Also, why are you doing ATTR{idProduct} instead of ATTRS{idProduct}? Is that a mistake? I see you use the S on this one: ATTRS{idVendor}. I think they should both be ATTRS.
  • Gabriel Staples
    Gabriel Staples about 4 years
    Update on my first comment here: I may be wrong. Using MODE="0666" but not setting the GROUP did NOT end up working for me on Ubuntu 18.04. I then followed this tutorial (andreasrohner.at/posts/Electronics/…) and set GROUP="dialout", but did NOT specify any MODE, and since I am a member of group dialout, it works now!
  • Gabriel Staples
    Gabriel Staples about 4 years
    Lastly, I think you need to use sudo udevadm trigger not udevadm trigger, but I'm not 100% sure. I just know that I used sudo and it seemed to make it work, and it takes ~2 sec to run with sudo and about 0.2 sec to run without it, so clearly different things are happening with vs without sudo.
  • Gabriel Staples
    Gabriel Staples about 4 years
    @Jacob Minshall indicates in his comment under this answer that he required sudo too: unix.stackexchange.com/questions/39370/….
  • Finn Bear
    Finn Bear about 4 years
    @GabrielStaples Both work but it could be more consistent unix.stackexchange.com/questions/424727/…