devenh
Posts: 32
Joined: Fri Jun 05, 2015 9:11 pm

Permission denied /dev/ttyAMA0

Mon Apr 10, 2017 10:08 pm

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)

User avatar
DougieLawson
Posts: 36528
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Permission denied /dev/ttyAMA0

Mon Apr 10, 2017 10:27 pm

Add your userid to the tty group

sudo usermod -a -G tty pi
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
jojopi
Posts: 3085
Joined: Tue Oct 11, 2011 8:38 pm

Re: Permission denied /dev/ttyAMA0

Mon Apr 10, 2017 11:10 pm

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.

devenh
Posts: 32
Joined: Fri Jun 05, 2015 9:11 pm

Re: Permission denied /dev/ttyAMA0

Tue Apr 11, 2017 4:45 am

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.

Return to “Raspbian”