Page 1 of 1

Permission denied /dev/ttyAMA0

Posted: Mon Apr 10, 2017 10:08 pm
by devenh
About once a year I update all my Pi's to the latest release (in this case 2017-04-10) of Raspbian and inevitably there are always a few glitches. I have a Pi B+ that has been running an Adafruit GPS Hat for 2+ years. One of the first tests after installing the new OS is to see if the GPS is working by executing:

Code: Select all

cat /dev/ttyAMA0
But this fails with a permission denied error, but the following works demonstrating that it is not a hardware problem:

Code: Select all

sudo cat /dev/ttyAMA0
The output of ls -l /dev/ttyAMA0 ; groups is below:

Code: Select all

crw--w---- 1 root tty 204, 64 Apr  9 07:42 /dev/ttyAMA0
pi adm dialout cdrom sudo audio video plugdev games users input netdev gpio i2c spi
So how can I solve the permission denied problem?
(This has been crossposted on the Adafruit forums)

Re: Permission denied /dev/ttyAMA0

Posted: Mon Apr 10, 2017 10:27 pm
by DougieLawson
Add your userid to the tty group

sudo usermod -a -G tty pi

Re: Permission denied /dev/ttyAMA0

Posted: Mon Apr 10, 2017 11:10 pm
by jojopi
Never add a user to the tty group. A serial device being in tty group suggests that a getty (serial login manager) is running on the port; otherwise it should be in dialout group. Trying to use the port if a getty is also running will just cause other problems.

Disable the login shell on the serial port in the interfacing options of "sudo raspi-config", and reboot. For B+ that may be all that is required.

For Pi3, and possibly in future, disabling the getty will also put the physical pins back to general-purpose mode. To have them as serial by default, you should add "enable_uart=1" to /boot/config.txt. For best compatibility across Pi models, it may be better to use /dev/serial0, instead of ttyAMA0 or ttyS0.

Re: Permission denied /dev/ttyAMA0

Posted: Tue Apr 11, 2017 4:45 am
by devenh
jojopi wrote: Disable the login shell on the serial port in the interfacing options of "sudo raspi-config", and reboot. For B+ that may be all that is required.
That worked. Thanks.