Arduino Pro Micro无法上传任何代码(avrdude:ser_open():无法打开设备“/ dev / ttyACM0”:权限被拒绝)

3

我尝试上传各种类型的草图(包括裸骨),但都无法成功。其他人说这个错误是由于端口权限不足所造成的,因此我按照几个人和Arduino网站上的建议(适用于Linux)进行了操作。

Sketch uses 3462 bytes (12%) of program storage space. Maximum is 28672 bytes.
Global variables use 149 bytes (5%) of dynamic memory, leaving 2411 bytes for local variables. Maximum is 2560 bytes.
Forcing reset using 1200bps open/close on port /dev/ttyACM0
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {}
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyS4, } => {}
PORTS {/dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {/dev/ttyACM0, }
Found upload port: /dev/ttyACM0
/home/kalin/Downloads/arduino-1.8.13/hardware/tools/avr/bin/avrdude -C/home/kalin/Downloads/arduino-1.8.13/hardware/tools/avr/etc/avrdude.conf -v -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -D -Uflash:w:/tmp/arduino_build_767551/sketch_feb05a.ino.hex:i 

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/home/kalin/Downloads/arduino-1.8.13/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/home/kalin/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyACM0
         Using Programmer              : avr109
         Overriding Baud Rate          : 57600
avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied

avrdude done.  Thank you.

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

根据文档

打开终端并输入:

ls -l /dev/ttyACM*,你会得到如下结果:

crw-rw---- 1 root dialout 188, 0 5 apr 23.01 ttyACM0 在“ACM”后面的数字可能不同,或者可能返回多个条目。我们需要的是"dialout"(该文件的组所有者)。

现在我们只需要将用户添加到该组中:

sudo usermod -a -G dialout $USER 然后输入:

sudo chmod a+rw /dev/ttyACM0 你需要注销并重新登录以使更改生效。

然而,每次我启动Arduino时,权限都会恢复到之前的状态。如果我使用sudo运行Arduino,则可以工作,但显然我不应该这样做。

1个回答

1
我经验不够,不知道应该使用哪个程序员来为Arduino编程,但问题是我之前使用的是"AVR ISP",但当我切换到"ArduinoISP"时,一切都上传得非常完美。没有必要更改任何权限。

如果您不使用硬件编程器进行“使用编程器上传”,那么选择编程器的操作就没有意义。 - Juraj

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接