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.

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

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

sudo systemctl mask serial-getty@ttyAMA0.service

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.

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.

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

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)&

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

For my RPi 3 Model B, I used geotheory's solution (sudo systemctl mask serial-getty@ttyAMA0.service) 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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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