Arduino IDE - /dev/ttyACM0 Permission denied

Hi 2 all :).
It’s my first post here, so here’s a word about me. Just started to migrate from msw7 to manjaro and slowly rebuilding my os toolkit. I managed to solve some riddles myself with existing knowledge base (stuck screen brightness or vpn) and now I have a bigger problem. My arduino IDE and the board don’t want to cooperate. Some details:

  • the board appears as /dev/ttyACM0

  • arduino IDE can see the board, and can identify it (showing proper ID window)

  • arduino IDE can write to the board in root mode but shows errors for a normal user

    An error occurred while uploading the sketch avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied
    
  • arduino IDE serial monitor doesn’t work at all (root or not)

    Exception in thread “EventThread /dev/ttyACM0” java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;
    at processing.app.Serial.processSerialEvent(Serial.java:210)
    at processing.app.Serial.serialEvent(Serial.java:183)
    at jssc.SerialPort$LinuxEventThread.run(SerialPort.java:1299)

    but cat /dev/ttyACM0 showing output (when arduino IDE monitor isn’t started)

Now, what I’ve tried and checked so far:

  • I added myself to the uucp group (logout and reboot) - no success

  • tried sudo chmod a+rw /dev/ttyACM0 - no success

  • created udev rule for my board (as root)

    SUBSYSTEMS==“usb”, ATTRS{idProduct}==“2341”, ATTRS{idVendor}==“8073”, SYMLINK+=“ttyACM%n”

    no success

I guess I’m still missing something. Some help will be much appreciated. :slight_smile:

This is blocked by default probably in all Linux distributions – I don’t know details, but I think it’s security issue.

Solution is simply, every moment when you plug-in Arduino and want programming you need run these commands:

sudo groupadd dialout
sudo gpasswd -a USER dialout
sudo usermod -a -G dialout USER
sudo chmod a+rw /dev/ttyACM0

Instead USER you should put your username. This solution work with other devices, but you may need put other name instead ttyACM0 – you should always read error message in IDE.

1 Like

Thank you for the replay. Unfortunately this method doesn’t work either. :frowning:

I did a search on internet and came across this post, that suggest to use the MODE= keyword inside the udev rule.
So you could try to add , MODE=0666 to the udev rule to give it rw-rw-rw- permissions…

PS:
If i’m not mistaken that udev you showed creates a symbolic link to somewhere right?
You would need to add the above to the udev rule that creates the device-node instead of the one that creates a symbolic-link…

The mystery is solved (partially).
The errors mentioned only java code errors and access denied to the port. Today, after a good sleep and a couple of pints I’ve got a spark of genius :). I removed the original Arduino IDE packet (from manjaro repo) and reinstalled it form SNAP. Magic happened and it is working … err… almost. With SNAP version the serial monitor is working, but uploading is impossible ( port access denied error ) even under root. I removed the SNAP version and downloaded and installed a fresh copy form arduino project web page. Now I have a working serial monitor and I can upload to the MC from under root. Not perfect but working.
Conclusion: something is screwed up in linux version of Arduino ICE or there are some incompatibilities with XFCE Manjaro.

Nope. Maybe. Nope. :slight_smile:

I don’t use arduino, but I do have one laying around so this is what I did:

sudo pacman -S arduino arduino-avr-core
sudo usermod -a -G uucp $USER

Logged out and back in again and it works as expected. :slight_smile:

Arduino IDE crashed on startup with java errors if the arduino-avr-core package wasn’t installed.

Either way if adding your user to uucp or chmod isn’t working for you there’s a problem with your system, or what you’re doing. :slight_smile:

I’ll happily try to troubleshoot with you. :slight_smile:

EDIT:
I didn’t try the serial monitor though.

Just tried the serial monitor and it doesn’t work, everything else does though. :grin:

Exception in thread "EventThread /dev/ttyUSB0" java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;
	at processing.app.Serial.processSerialEvent(Serial.java:210)
	at processing.app.Serial.serialEvent(Serial.java:183)
	at jssc.SerialPort$LinuxEventThread.run(SerialPort.java:1299)

https://bbs.archlinux.org/viewtopic.php?id=246768

NEW EDIT:

Got it, serial monitor’s working now. :slight_smile:

sudo pacman -S arduino arduino-avr-core
sudo usermod -a -G uucp $USER     # log out and back in of course
sudo archlinux-java set java-14-openjdk

It may or may not affect other software written in java. :frowning:

1 Like

Last check for today. I added myself to uucp group as the 1st step, even before the first attempt. installing arduino-avr-core didn’t change a thing. the same with java (ver 14 installed previously). Manjaro is fresh out of the box, just starting migration.
As I can see you have a different board. Yours appears as ttyUSB. I have ProMicro (leonardo) and it appears as ttyACM. I think there is the same issue as with uno and mega sth (cannot remember the exact model). The board as direct usb not as virtual com port.
I believe it is a write permit issue. read (monitor mode) is ok under root and normal user, write is working only as root and normal user got permission denied.

Will be very grateful for help with troubleshooting this. It is a small but annoying thing, not the extra step starting the arduino ide as root but because it doesn’t work as I want it to :slight_smile: .

As i don’t have or use any Arduino, i can not trouble shoot with you guys but…
When it comes to the permissions:

  • Find out where and how that device node is created, and change the permissions on that created device node.
  • If it uses a udev rule to create that device node : Try to make use of MODE=0666 as i mentioned few replies back :arrow_heading_up:
1 Like

I tried this approach already. I found this in one of install manuals:

00-usb.permissions.rules
SUBSYSTEM==“usb”, MODE=“0666”, GROUP=“lukas”

In theory it should grant me full permissions to all usb devices. Tried

sudo chmod 777 /dev/ttyACM0,
the result is:
rwxrwxrwx 1 root uucp 166, 0 Dec 30 09:18 /dev/ttyACM0

and it doesn’t work either
checked my groups, just in case

wheel lp uucp sys lock network power autologin dialout lukas

groups looks ok.

Is /dev/ttyACM0 a sumbolic link or device node?
Symbolic links start with an l when viewed using ls -la , eg. lrw-rw-rw
If it is a symbolic link it won’t apply the mode changes by definition…

before chmod

ls -la /dev/ttyACM*
crw-rw---- 1 root uucp 166, 0 Dec 30 12:10 /dev/ttyACM0

after chmod

ls -la /dev/ttyACM*
crw-rw-rw- 1 root uucp 166, 0 Dec 30 12:10 /dev/ttyACM0

sorry, just starting my adventure with linux :sweat_smile:

Looks good, and proves that chmod does work, if that works then uucp probably does too.

Clearly your issue is elsewhere.

What’s the output of this?

echo anything > /dev/ttyACM0

That means the character device, because of starting c, is created read/write for only root and users in group uucp, before your chmod.
So if you start your application using sudo --group=uucp it should still run as your user but with group uucp which should be enough to allow read/write access to that device.
See man sudo :

-g group, --group=group
                 Run the command with the primary group set to group instead of the primary group specified by the target user's
                 password database entry.  The group may be either a group name or a numeric group-ID (GID) prefixed with the
                 ‘#’ character (e.g., #0 for GID 0).  When running a command as a GID, many shells require that the ‘#’ be es‐
                 caped with a backslash (‘\’).  If no -u option is specified, the command will be run as the invoking user.  In
                 either case, the primary group will be set to group.  The sudoers policy permits any of the target user's
                 groups to be specified via the -g option as long as the -P option is not in use.

Shouldn’t be needed but worth a try. :slight_smile:

the output of

echo anything > /dev/ttyACM0

before chmod 666 - nothing, the cursor jumps to next prompt line ready to next comman
after chmod 666 - the cursor jumped to the next line but the line stay empty. to get out from the empty line ctrl+c

I know but because i don’t know Java, neither want to lol, i’m approaching the problem from the unix side :innocent:

1 Like

That’s what we expect to happen if it works, you have write aceess with your user. :slight_smile:

That’s strange, seems more like cat and no input. :confused:

@TriMoon

Me too. :slight_smile:

Dood take this worked to me
sudo chmod a+rw /dev/ttyACM0

cat /dev/ttyACM0

works good, just got my “hello world!” message :slight_smile: . even without chmod

1 Like

Excellent, did you unplug it first? :slight_smile:

Well then I’d install the repo version, and try to upload a sketch without root. :crossed_fingers: