首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >拒绝USB设备非root用户的权限

拒绝USB设备非root用户的权限
EN

Ask Ubuntu用户
提问于 2018-06-22 16:08:43
回答 1查看 15.8K关注 0票数 4

我很难让Arduino微型AVR程序员(PMG-11801)在我的Ubuntu18.04笔记本电脑上工作。这是一个在Arduino IDE中编程ATTiny85芯片的Arduino设备。

我从不同的地方读过几篇论坛文章,并尝试了一种看起来对其他许多人有效的解决方案,但它对我来说并不管用。这就是我所做的。

代码语言:javascript
复制
mmachenry$ lsusb
... other devices ...
Bus 001 Device 013: ID 1781:0c9f Multiple Vendors USBtiny
... other devices ...

我注意到供应商的1781:0c9f和下一步的产品ID。

从我发现的各种网页上看,我似乎需要在/etc/udev/rues.d中输入一个条目,以便允许非根用户使用该设备。我加了它,看起来是这样的:

代码语言:javascript
复制
mmachenry$ cat /etc/udev/rules.d/99-USBtiny.rules 
SUBSYSTEM=="usb", ATTR{idVendor}=="1781", ATTR{idProduct}=="0c9f", GROUP="adm", MODE="0666"

还请注意,我在适当的小组。

代码语言:javascript
复制
mmachenry$ groups
mmachenry adm dialout cdrom sudo dip plugdev docker lpadmin sambashare

为了使此生效,在创建规则文件后立即运行这些文件。

代码语言:javascript
复制
sudo service udev restart
sudo udevadm control --reload-rules

正如Norbert的评论所要求的那样,我对我的用户组进行了一次正常检查,但是似乎没有什么问题,因为没有输出。

代码语言:javascript
复制
mmachenry@mmachenry-laptop:~$ sudo update-passwd --sanity-check --verbose

但当我跑到阿夫老兄的时候,我被拒绝了许可。

代码语言:javascript
复制
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.

但是,在使用sudo运行命令时,我得到了很多不同的正输出。

代码语言:javascript
复制
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.

在Arduino IDE中运行这个程序具有相同的效果。作为一个普通用户,我被拒绝了许可。当我以根用户身份运行IDE时,它完全工作,并将我的程序上传到Arduino。请注意,这个设备被识别为USB设备,因为它是usbtinyISP,而不是像一些Arduinos那样的串行设备。

为什么普通用户访问此设备的权限仍然被拒绝?

谢谢。

EN

回答 1

Ask Ubuntu用户

发布于 2019-11-10 04:10:18

  1. 确保您的udev规则是正确的: SUBSYSTEM=="usb“、ATTRS{==}==”USBtiny“、ATTRS{idProduct}=="0c9f”、ATTRS{idVendor}=="1781“、MODE="0660”、GROUP="dialout“。
  2. 确保刷新udev: sudo udevadm控件--重载规则& sudo udevadm触发器
  3. Make一定要拔掉并回复USB设备!

最后一个是我花了一些时间才弄明白的!

票数 5
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1048870

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档