21

I am Linux Mint user.I am dealing with Arduino Yun.I am compiling Arduino program.After that I am uploading to Arduino Yun.Then I get these error.Can you help me?

kafkas
  • 475
  • 1
  • 4
  • 11

10 Answers10

27

you first need to make sure you have the correct read/write rights, as described here, esentially enter following commands:

$ sudo adduser <username> dialout
$ sudo chmod a+rw /dev/ttyACM0

the '/dev/ttyACM0' is the port your arduino is connected to, it should be listed in the /dev folder of your root.

second: after you have identified which port the arduino is connected to and you have set the correct rights for this port, you need to run following command. I am not sure what it does, I am not sure if it's really needed, but it made the uploads work for me on several occasions

$ sudo udevadm trigger

found this command here: http://starter-kit.nettigo.eu/2015/serial-port-busy-for-avrdude-on-ubuntu-with-arduino-leonardo-eth/

and third, you will find the upload sometimes a challenge of timing and luck. Keep pressing the reset (sometimes twice very consecutively) and meanwhile press the upload button of your arduino sketch. At certain moment, it will work. I had more luck when constantly changing small pieces in the code, so when I pushed 'upload', it had to compile the code first.

https://www.arduino.cc/en/Guide/Troubleshooting#upload

on some computers, you may need to push teh reset button

I have never messed with the bootloader, nor with ICSP pins and such (luckily)

Also have a look on the Arduino forum or on the link provide by yourself

hewi
  • 1,274
  • 3
  • 17
  • 32
21

I got exact problem with my Leonardo board and Ubuntu. Adding rule that tells ModemManger to ignore all USB devices from mentioned link didn't work for me. However, deleting modemmanager in fact did.

sudo apt-get purge modemmanager

Endrju
  • 333
  • 2
  • 6
11

The solution that worked for me always is to go to Tools -> Port -> /dev/ttyACMx and click the selected port again.

After that IDE uploads the code without a problem.

NonGrate
  • 862
  • 9
  • 22
  • I guess, Arduino IDE does some handshake or similar when you choose the port. And sometimes it helps to just "restart" the connection. But it's only an assumption. – NonGrate May 01 '19 at 19:12
  • Agreed. Now I always double check the board and the IO before programming the Arduino and it works well. – Alex Petty May 02 '19 at 20:32
  • Another my assumption as I see this on a daily basis now, is it may depend on the time you wait after you (re-)picked the port. Ma-a-aybe the IDE does try again once in a while and occasionally succeed [x]. Nevertheless, Hitting `Ctrl+U` right after failed upload several times - helps [x]. Hitting `Ctrl+U` rapidly runs the IDE into a `ConcurrentMidificationException` - which fixes the problem - helps [x]. PS: Opening the `Serial Monitor` during a sketch upload ALWAYS opens the serial monitor and ALWAYS connects it to the correct port/device - helps [x]. – NonGrate May 06 '19 at 15:25
3
sudo chmod a+rw /dev/ttyACM0

run following command for first time uploading

Asanka Sampath
  • 545
  • 4
  • 12
1

Make sure your USB cable is plugged firmly. Mine stopped working all of a suddenly because of this. The "/dev/ttyACM0 not found" message happens because the device doesn't get created unless the device is plugged in.

Dave
  • 11
  • 1
1

Just to add a new solution that worked for me (also under Linux Mint) I had opened the serial monitor (from one of the 4 arduino IDEs opened) and closing it did the trick (probably related to the process problem described up there)

juagicre
  • 1,065
  • 30
  • 42
0

I get this message when a process is connected to the port that I am trying to use for loading code through e.g. screen or gtkterm.

Try this command:

lsof /dev/ttyACM3

Use the ACM<x> for your device. If something comes up, e.g.

screen  8610  elm    5u   CHR  166,3      0t0 5599015 /dev/ttyACM3

Then kill the PID:

kill 8610

To clear the process that is using the port.

Oppy
  • 2,662
  • 16
  • 22
0

I don't think changing the rights to the port is a goot idea. I have found a better solution. It is to run Arduino with sudo. And this is the guide how to do it. First, find Arduino's .desktop file. It may be at /usr/share/applications/ or at ~/.local/share/applications/. The name may also be different, but it will certainly contain "arduino". For me it is /usr/share/applications/arduino.desktop. Then open it with sudo nano <your arduino.desktop file>. sudo nano /usr/share/applications/arduino.desktop works for me. It will contain something like that:

[Desktop Entry]
Type=Application
Name=Arduino IDE
GenericName=Arduino IDE
Comment=Open-source electronics prototyping platform
Exec=arduino %U
Icon=arduino
Terminal=false
Categories=Development;IDE;Electronics;
MimeType=text/x-arduino;
Keywords=embedded electronics;electronics;avr;microcontroller;
StartupWMClass=processing-app-Base

Now find the line starting with Exec=. For me in is Exec=arduino %U. Everything that comes after Exec= is the command that launches Arduino. For me it is arduino %U. And we need this command to be launched with sudo. Then type echo "<your password>" | sudo -S before that command. And save file with Ctrl+O. Now Exec line it will be something like Exec=echo "blahblah" | sudo -S arduino %U, where blahblah is your password. And it's done! Now it should work. If it doesn't then try rebooting. But there is still a problem. Now Arduino IDE will save sketches at /root/Arduino/ by default (it should save sketches at /home/<username>/Arduino/). It is not good. But it can be easily fixed in Arduino's settings. Also now you can edit with Arduino IDE almoust every file in your system. So be careful and don't break something.

Edit: I wasn't right. sudo usermod -a -G uucp $USER or sudo usermod -a -G dialout $USER and reboot works better.

0

I just had this problem with my Genuine Arduino Mega 2560 trying to connect to it from an Ubuntu 18.04.5 LTS machine using a locally compiled Arduino IDE version 1.8.16. I was able to fix it in my case, so posting here to share the tips.

Came across several other forum topics reporting the same symptoms (even though not all are Mega and not all on Linux):

After troubleshooting for several hours I was able to reliably connect to my Mega. It turned out there were multiple problems that prevented it from working that had to be understood and solved, and when I realized what they were I could not believe my eyes.

The posters who suggested making sure that udev rules are configured to prevent the ModemManager from hogging the Mega device, thereby making it unavailable to the Arduino IDE were on the right track. So I checked my /etc/udev/rules.d/70-snap.core.rules and indeed confirmed that there already was a rule for ModemManager to ignore devices with USB vendor ID 2341, which is the Genuine Arduino:

...
ATTRS{idVendor}=="2341", ENV{ID_MM_DEVICE_IGNORE}="1"
...

However, when I did a tail -f /var/log/syslog and plugged in the Mega, I could not believe my eyes to see that ModemManager was still trying to talk to it:

Dec  9 22:09:58 hostname ModemManager[999]: <info>  [device /sys/devices/pci0000:00/0000:00:14.0/usb3/3-2] creating modem with plugin 'Generic' and '1' ports
Dec  9 22:09:58 hostname ModemManager[999]: <warn>  Could not grab port (tty/ttyACM0): 'Cannot add port 'tty/ttyACM0', unhandled serial type'
Dec  9 22:09:58 hostname ModemManager[999]: <warn>  Couldn't create modem for device '/sys/devices/pci0000:00/0000:00:14.0/usb3/3-2': Failed to find primary AT port

It looks like the ModemManager was still trying to connect to it as a non-USB TTY device.

The problem was exacerbated in that the Arduino IDE was not handling this problem gracefully and kept hanging and trying to connect to the Mega even after I unplugged it from the USB. Nevertheless, I did a quick ps -ef | grep ModemManager and then kill [PID], waited until the Arduino IDE stopped trying to connect to the disconnected Mega, then plugged it back in, specified the port via 'Tools' -> 'Port', and again attempted an upload, and it worked like a charm. (Conversely, had I just waited watching /var/log/syslog for ModemManager to give up and free the device Arduino IDE might have also worked without me explicitly killing the ModemManager. That probably explains why it worked sporadically.)

So then I thought I solved all my problems and started bolting the Mega into my device. I tightened the connecting fasteners, and again could not believe my eyes that it stopped working again. Took the Mega back out, unbolted the whole board and now it worked, bolted it back in, and it stopped working. After several rounds, correlated the use of a brass standoff on the hole right next to the pin A6 as causing this problem. I surmise that the metal standoff was shorting out or somehow interfering with PCB traces that run very close to that hole. So stopped bolting in that hole, and the Mega started working fine assembled into my device.

So in my case, 2 problems were preventing the Mega from working and PC connecting to it via USB:

(1) ModemManager was hogging the device as soon as it was plugged in despite the udev USB rules. Solution -- killed ModemManager (still need to look into modifying system config so that I don't have to kill it each time).

(2) Hardware issue with the metal riser interfering with PCB traces near hole next to pin A6. Solution -- stopped bolting in that hole.

Hope this is helpful.

maratbn
  • 188
  • 1
  • 9
-1

Use

sudo arduino

This will fix for one Time

Akash
  • 2,795
  • 1
  • 7
  • 11