5

For some reason in Raspbian (Jessie) /dev/ttyAMA0 always boots with the following permissions:

ls -l /dev/ttyAMA0
crw--w---- 1 root tty 204, 64 Jun  1 21:10 /dev/ttyAMA0

I need group tty to have read access, so emulating this solution I tried adding a root crontab job:

@reboot chmod 660 /dev/ttyAMA0

Which appears to either have no effect or is reverted immediately. Grateful for any tips.

2
  • Doesn't the above show that tty has write access?
    – joan
    Commented Jun 1, 2016 at 21:58
  • @joan Sorry I mean read access!
    – geotheory
    Commented Jun 2, 2016 at 7:54

4 Answers 4

8

The following will ensure read access, but changes group from tty to dialout.

sudo systemctl mask [email protected]

And on reboot we have:

# ls -l /dev/ttyAMA0
crw-rw---- 1 root dialout 204, 64 Jun  2 11:29 /dev/ttyAMA0

I've been advised that to do this you should also consider stopping any kernel console logging going out the serial port, which can be achieved by removing console=serial0,115200 from file /boot/cmdline.txt.

Any comment on any unintended implications of this method would be appreciated.

1
  • It appears that if you remove kernel console logging going to the serial port, the device permissions are what we want (crw-rw----, group dialout) - you don't need the systemctl mask command. This would make sense as there's a need to protect kernel logs. The kernel console logging can also be disabled via raspi-config - namely in the interfacing options (this does exactly the same as removing the console=... section from /boot/cmdline.txt
    – askvictor
    Commented Mar 15, 2022 at 2:36
0

You could always add:

chmod 660 /dev/ttyAMA0

to the /etc/rc.local file. As rc.local is executed with root privileges it should work.

1
  • Yeah already tried that, doesn't work either.
    – geotheory
    Commented Jun 2, 2016 at 8:43
0

I don't know why the permissions are wrong.

Until they are corrected use the following in the root crontab.

@reboot (sleep 30; chmod 660 /dev/ttyAMA0)&

1
  • I suspect this might work, but it does feel a bit hacky! Thanks though.
    – geotheory
    Commented Jun 2, 2016 at 13:28
0

For my RPi 3 Model B, I used geotheory's solution (sudo systemctl mask [email protected]) for /dev/ttyS0 and it was the cure to my problem of flaky serial communication. Characters were dropping and the connection was timing out frequently. Now it's solid.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.