Can't open device "/dev/ttyACM0": Permission denied

Works on Windows so Zumo is OK.
Using Arduino IDE 1.8.5. Running Ubuntu 17.10. Added myself to the “dialout” group and rebooted:

david@david-HP-ProBook-440-G2:~ ls -l /dev/ttyACM* crw-rw---- 1 root dialout 166, 0 Mar 29 13:44 /dev/ttyACM0 david@david-HP-ProBook-440-G2:~ groups
david adm tty dialout cdrom sudo dip plugdev lpadmin sambashare

Still get:
avrdude: ser_open(): can’t open device “/dev/ttyACM0”: Permission denied


Further info. Plugged in Arduino Uno, switched the board and port info in the IDE and downloaded the Blink example sketch just fine.

Plugged in the Zumo, switched the board and port info in the IDE and it still gives the above error when downloading.


More info:
Installed the udev rules from here:

and rebooted. Still no joy.

Disabled modemmanager and rebooted. Still no joy.

Here is the output from dmesg if that’s any help:
[ 657.663355] usb 2-8: USB disconnect, device number 11
[ 657.997697] usb 2-8: new full-speed USB device number 12 using xhci_hcd
[ 658.139231] usb 2-8: New USB device found, idVendor=1ffb, idProduct=0101
[ 658.139235] usb 2-8: New USB device strings: Mfr=2, Product=1, SerialNumber=0
[ 658.139238] usb 2-8: Product: Pololu A-Star 32U4 Bootloader
[ 658.139240] usb 2-8: Manufacturer: Pololu Corporation
[ 658.139725] cdc_acm 2-8:1.0: ttyACM0: USB ACM device
[ 665.763199] usb 2-8: USB disconnect, device number 12
[ 666.067491] usb 2-8: new full-speed USB device number 13 using xhci_hcd
[ 666.218425] usb 2-8: New USB device found, idVendor=1ffb, idProduct=2300
[ 666.218431] usb 2-8: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 666.218436] usb 2-8: Product: Pololu A-Star 32U4
[ 666.218440] usb 2-8: Manufacturer: Pololu Corporation
[ 666.219237] cdc_acm 2-8:1.0: ttyACM0: USB ACM device

Ideas?

Hello.

Thank you for posting the additional information on the problem.

Can you turn on the verbose output in your Arduino IDE (if it is not already) and post the output that you get after trying to program the Zumo 32U4? You can enable verbose output by selecting File->Preferences in the IDE, and then checking the “compilation” and “upload” boxes next to “Show verbose output during:”. With the verbose output, we can check to see if the Arduino IDE is having trouble talking to the sketch’s port or with the bootloader.

- Amanda

Here you go!

Forcing reset using 1200bps open/close on port /dev/ttyACM0
PORTS {/dev/ttyACM0, } / {} => {}
PORTS {} / {/dev/ttyACM0, } => {/dev/ttyACM0, }
Found upload port: /dev/ttyACM0
/home/david/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/bin/avrdude -C/home/david/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/etc/avrdude.conf -v -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -D -Uflash:w:/tmp/arduino_build_259568/ZumoMaze.ino.hex:i 

An error occurred while uploading the sketch
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/david/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/etc/avrdude.conf"
         User configuration file is "/home/david/.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.

Don’t want to spam the forum, but I thought it might be helpful to see running avrdude directly from the command line and also a successful upload to an Arduino versus an unsuccessful upload to the Zumo.

Here’s a successful upload to an Arduino Uno:

/home/david/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/bin/avrdude -C/home/david/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/etc/avrdude.conf -v -patmega328p -carduino -P/dev/ttyACM0 -b115200 -D -Uflash:w:/tmp/arduino_build_244824/Blink.ino.hex:i 

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/david/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/etc/avrdude.conf"
         User configuration file is "/home/david/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyACM0
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         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    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
         Hardware Version: 3
         Firmware Version: 4.4
         Vtarget         : 0.3 V
         Varef           : 0.3 V
         Oscillator      : 28.800 kHz
         SCK period      : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "/tmp/arduino_build_244824/Blink.ino.hex"
avrdude: writing flash (928 bytes):

Writing | ################################################## | 100% 0.16s

avrdude: 928 bytes of flash written
avrdude: verifying flash memory against /tmp/arduino_build_244824/Blink.ino.hex:
avrdude: load data flash data from input file /tmp/arduino_build_244824/Blink.ino.hex:
avrdude: input file /tmp/arduino_build_244824/Blink.ino.hex contains 928 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.13s

avrdude: verifying ...
avrdude: 928 bytes of flash verified

avrdude done.  Thank you.

Here’s an unsuccessful upload to the Zumo:

david@david-HP-ProBook-440-G2:~$ /home/david/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/bin/avrdude -C/home/david/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/etc/avrdude.conf -v -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -D -Uflash:w:/tmp/arduino_build_259568/ZumoMaze.ino.hex:i 

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/david/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/etc/avrdude.conf"
         User configuration file is "/home/david/.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
         AVR Part                      : ATmega32U4
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         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    20     4    0 no       1024    4      0  9000  9000 0x00 0x00
           flash         65     6   128    0 yes     32768  128    256  4500  4500 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
           lock           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
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : butterfly
         Description     : Atmel AppNote AVR109 Boot Loader

Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding

avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
Found programmer: Id = ""; type = 
    Software Version = :.�; Hardware Version = .
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: error: buffered memory access not supported. Maybe it isn't
a butterfly/AVR109 but a AVR910 device?
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: butterfly_recv(): programmer is not responding
avrdude: error: programmer did not respond to command: leave prog mode
avrdude: butterfly_recv(): programmer is not responding
avrdude: error: programmer did not respond to command: exit bootloader

avrdude done.  Thank you.

Hello.

When you attempted to upload to the Zumo 32U4 using AVRDUDE at the command line, I suspect it didn’t work because you didn’t get the Zumo 32U4 into bootloader mode first. You could press the reset button twice within 750 ms to do that, or do it the way the Arduino IDE does it, which is to open the port, set the baud rate to 1200, and close it. After the Zumo 32U4 is in bootloader mode, you’ll need to run the AVRDUDE command within 8 seconds or else it will time out and go back to running the sketch.

When the Zumo 32U4 goes into bootloader mode, it looks to the computer like the device is actually disconnecting from USB and reappearing as a different device, so /dev/ttyACM0 will go away briefly and then be recreated. I suspect that there might be a timing issue preventing the Arduino IDE from opening this newly-created /dev/ttyACM0. I made a little program in C that you can run on the Linux machine in order to test the timing of the permissions of /dev/ttyACM0. The source code is below:

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <stdint.h>
#include <time.h>

int main()
{
  int last_result = 1;
  struct stat last = {0};
  while (1)
  {
    struct stat buf = {0};
    int result = stat("/dev/ttyACM0", &buf);
    if (result != last_result ||
      buf.st_mode != last.st_mode ||
      buf.st_uid != last.st_uid ||
      buf.st_gid != last.st_gid)
    {
      struct timespec spec;
      clock_gettime(CLOCK_REALTIME, &spec);
      printf("time=%ld.%03ld ", spec.tv_sec, spec.tv_nsec / 1000000);

      if (result == 0)
      {
        printf("mode=%o uid=%d gid=%d\n",
          buf.st_mode, buf.st_uid, buf.st_gid);
      }
      else
      {
        printf("error %d\n", errno);
      }
      last = buf;
      last_result = result;
    }
    usleep(1000);
  }
}

Please compile it with gcc testport.c -o tesport and then start running it with ./testport. While it is running, please try to upload to your Zumo 32U4 using the Arduino IDE, and let us know what the program prints.

–David

Here’s the output of testport:
david@david-HP-ProBook-440-G2:~/bin$ ./testport
time=1522468976.615 mode=20660 uid=0 gid=20
time=1522468980.596 error 2
time=1522468981.087 mode=20600 uid=0 gid=0
time=1522468981.647 mode=20660 uid=0 gid=20
time=1522468988.696 error 2
time=1522468989.139 mode=20600 uid=0 gid=0
time=1522468989.694 mode=20660 uid=0 gid=20

Here’s the output from the Arduino IDE:

Sketch uses 9708 bytes (33%) of program storage space. Maximum is 28672 bytes.
Global variables use 426 bytes (16%) of dynamic memory, leaving 2134 bytes for local variables. Maximum is 2560 bytes.
Forcing reset using 1200bps open/close on port /dev/ttyACM0
PORTS {/dev/ttyACM0, } / {} => {}
PORTS {} / {/dev/ttyACM0, } => {/dev/ttyACM0, }
Found upload port: /dev/ttyACM0
/home/david/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/bin/avrdude -C/home/david/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/etc/avrdude.conf -v -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -D -Uflash:w:/tmp/arduino_build_199443/Buttons.ino.hex:i 

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/david/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/etc/avrdude.conf"
         User configuration file is "/home/david/.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.

Thought that the “dmesg” output might be useful. Ran it with the “-d” option to show the delta times between lines.

670.738963 was when I first plugged in the Zumo.
725.567565 was when I clicked on upload on the Arduino IDE.

david@david-HP-ProBook-440-G2:~$ dmesg -d
[ 670.738963 < 0.000000>] usb 2-1: new full-speed USB device number 7 using xhci_hcd
[ 670.882207 < 0.143244>] usb 2-1: New USB device found, idVendor=1ffb, idProduct=2300
[ 670.882214 < 0.000007>] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 670.882218 < 0.000004>] usb 2-1: Product: Pololu A-Star 32U4
[ 670.882223 < 0.000005>] usb 2-1: Manufacturer: Pololu Corporation
[ 670.883042 < 0.000819>] cdc_acm 2-1:1.0: ttyACM0: USB ACM device
[ 725.567565 < 54.684523>] usb 2-1: USB disconnect, device number 7
[ 725.902713 < 0.335148>] usb 2-1: new full-speed USB device number 8 using xhci_hcd
[ 726.044497 < 0.141784>] usb 2-1: New USB device found, idVendor=1ffb, idProduct=0101
[ 726.044504 < 0.000007>] usb 2-1: New USB device strings: Mfr=2, Product=1, SerialNumber=0
[ 726.044507 < 0.000003>] usb 2-1: Product: Pololu A-Star 32U4 Bootloader
[ 726.044511 < 0.000004>] usb 2-1: Manufacturer: Pololu Corporation
[ 726.045237 < 0.000726>] cdc_acm 2-1:1.0: ttyACM0: USB ACM device
[ 733.667317 < 7.622080>] usb 2-1: USB disconnect, device number 8
[ 733.965866 < 0.298549>] usb 2-1: new full-speed USB device number 9 using xhci_hcd
[ 734.109168 < 0.143302>] usb 2-1: New USB device found, idVendor=1ffb, idProduct=2300
[ 734.109175 < 0.000007>] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 734.109179 < 0.000004>] usb 2-1: Product: Pololu A-Star 32U4
[ 734.109183 < 0.000004>] usb 2-1: Manufacturer: Pololu Corporation
[ 734.109929 < 0.000746>] cdc_acm 2-1:1.0: ttyACM0: USB ACM device
david@david-HP-ProBook-440-G2:~$

The output from testport indicates that it is taking over 550 milliseconds for your system to set the mode and group for the ttyACM0 device after it is created. Based on my reading of the Arduino IDE source code, it looks like the IDE only delays for about 450 milliseconds after it detects the port, so AVRDUDE is getting run before the port has usable permissions set on it, and that is why you get the “Permissoin denied” error.

I ran testport on a computer from 2009 running Ubuntu 16.04, and that delay was more like 15 milliseconds instead of 550 milliseconds. Do you know why your computer might be so much slower? Did you install or configure something that does a lot of work every time a USB device is connected? Is there anything unusual in /etc/udev/udev.conf or /etc/udev/rules.d/? Have you tried any other computers? It might be good to try booting from an Ubuntu live CD (or USB drive) so you can run testport with a clean configuration and see if you get different numbers.

If you cannot figure out what is going on with your computer, I can help you replace AVRDUDE with a simple shell script that sleeps for a little bit before calling the real AVRDUDE.

Please let me know what you find out, since this might be a problem for future customers too.

–David

David-

FYI, I ran it on an 2GHz i3 w/16GB Ram and an SSD. So last night, I tried it on my rocket 3GHz i7 w/32GB Ram and an SSD. Same results.

I’m guessing that the issue is that Ubuntu switched from Unity to Gnome w/17.10. I’m in the middle of teaching my Arduino class right now so I’ll boot 16.04 off a flash drive tomorrow morning and let you know the results. I’ll also try off a virgin 17.10 flash drive.

Since I’m guessing it’s related to Ubuntu 17.10, this will affect you because Ubuntu 18.04 releases on April 26 and it’s an LTS version and lots of people will switch over to it.

BTW, I’m lovin’ the Zumo but I’ve got to get it running under Ubuntu since that’s all the school has.

Thanks!

-David

The quickest way to get the Zumo 32U4 working on your computers is probably to make that shell script wrapper that I suggested in my last post. Here is how I would recommend doing it:

First, in a shell, use cd to navigate to the hardware/tools/avr/bin directory inside your Arduino installation. Then run this command to rename the real AVRDUDE executable:

mv avrdude realavrdude

Next, run nano avrdude or use your favorite text editor to make a new file named avrdude which has the following contents:

sleep 1
exec "$(dirname "$0")"/realavrdude $*

Get back into your shell and mark the wrapper script as executable by running:

chmod a+x avrdude

This is very likely to solve your problem, but I’d still like to know what you find out when you try the flash drives, or if you ever figure what is causing the issue.

–David

Will do! You’ll have my results before you come to work tomorrow. Thanks!

David-

First off, it’s not your fault! I wanted you to know that ASAP so that you didn’t waste anymore time on this.

As soon as I figure out a fix, I’ll post it so everyone can benefit.

Some info so far:

  1. Works with Ubuntu Live USB sticks running 16.04 and 17.10 on a 1.9GHz i3.

  2. The fix you gave (the shell script) does NOT work.

  3. Once I confirmed the problem was on my side I stayed up all night working on it. Fortunately, being a sysadmin, I take great notes of what I’ve installed. I finally narrowed it down to TLP - Linux Advanced Power Management. http://linrunner.de/en/tlp/docs/tlp-linux-advanced-power-management.html

I tried excluding the zumo in the USB section:

USB_BLACKLIST=“1ffb:2300”

Interestingly, that didn’t work. I don’t know why. So, I turned off control of ALL USB:

USB_AUTOSUSPEND=0

That worked. So now I’m trying to figure out what magic I need to not control just the zumo… Does anything jump out to you that I’m missing?

Thanks for all your help so far!

-David

David-

Got it!

When I looked back over my notes, I noticed that when I ran “dmesg” there was another USB device from Pololu that also popped up:

New USB device found, idVendor=1ffb, idProduct=0101

So, I added it to the blacklist in /etc/default/tlp:

USB_BLACKLIST=“1ffb:2300 1ffb:0101”

And everything works like a champ! Thanks so much for sticking with me during this debugging. I’ll write up something later today (I’m going to sleep now!) and post it.

Thanks!

-David

1 Like

I wanted to summarize this for anyone that might have this issue.

If you are running “TLP” (Linux Advanced Power Management) and you are trying to program a Zumo, then you need to add the following to /etc/default/tlp in the “USB_BLACKLIST” section:

USB_BLACKLIST=“1ffb:2300 1ffb:0101”

Doing this turns off TLP control on the USB for the Zumo and allows the USB port to switch fast enough to program the Zumo.

1 Like