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.

geotheory
  • 575
  • 3
  • 10
  • 20

4 Answers4

8

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.

geotheory
  • 575
  • 3
  • 10
  • 20
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.

Bungee75
  • 121
  • 4
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)&

joan
  • 71,852
  • 5
  • 76
  • 108
0

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.