Default (at-boot) permissions for /dev/ttymxc0

Environment: Colibri imx6ull/256/256, Yocto dunfell, Kernel v5.4.193, Toradex minimum reference image with very slight changes

I am trying to make /dev/ttymxc0 (or rather, CTS/RTS pins) accessible to user (non-root) application. At boot, /dev/ttymxc0 has following permissions:

# ls /dev/ttymxc0
crw--w----    1 root     tty       207,  16 Sep 27 01:37 /dev/ttymxc0

The application’ user is member of both dialout and tty groups.

$ groups
tty dialout shutdown systemd-network systemd-journal logosol

During boot, /etc/rc.local gives /dev/ttymxc0 read/write permissions to everybody

# chmod a+rw /dev/ttymxc0
# ls /dev/ttymxc0
crw-rw-rw-    1 root     dialout   207,  16 Sep 20  2020 /dev/ttymxc0

But as soon as user application (started from systemd) receives control, permissions are back to “default”:

$ ls /dev/ttymxc0
crw--w----    1 root     tty       207,  16 Sep 20  2020 /dev/ttymxc0

I have tried writing a udev rule but it does not seem to work.

# cat /etc/udev/rules.d/50-serialports.rules
KERNEL=="ttymxc*", NAME="ttymxc", MODE="0666"

How can I prevent resetting the permissions to /dev/ttymxc0?

Using /etc/rc.local for this kind of job is old-fashioned and less predictable with systems using systemd. Prefer using udev rules or systemd services.
Your udev rule is trying to rename the device (NAME="ttymxc" ), which is probably not what you want. Update your rule to:

KERNEL==“ttymxc*”, MODE=“0666”

To ensure your rule gets the highest priority, you can name your rule file 10-serialports.rules instead of 50-serialports.rules .


Thank you for the quick reply. However, this does not help with ttymxc0… I have disabled /etc/rc.local, and my application, leaving only udev rules.

root@Colibri-1:~# cat /etc/udev/rules.d/10-serialports.rules
# Set permissions for everybody to use serial ports
KERNEL=="ttymxc*", MODE="0666"
root@Colibri-1:~# ls -la /dev/ttymxc*
crw--w----    1 root     tty       207,  16 Sep 29 22:27 /dev/ttymxc0
crw-rw-rw-    1 root     dialout   207,  17 Sep 20  2020 /dev/ttymxc1
crw-rw-rw-    1 root     dialout   207,  20 Sep 20  2020 /dev/ttymxc4
crw-rw-rw-    1 root     dialout   207,  21 Sep 20  2020 /dev/ttymxc5
crw-rw-rw-    1 root     dialout   207,  23 Sep 20  2020 /dev/ttymxc7

I suppose the fact that ttymxc0 is assigned to the console is something to deal with the permissions (and ownership).

If you don’t need ttymxc0 to be a console device, you can change the kernel command line parameters to remove or change the console assignment.
If you need ttymxc0 as a console device but still want to adjust permissions, you can try to enforce your udev rule to run after the device is initialized as a console. Using the TAG+="systemd"

KERNEL==“ttymxc0”, MODE=“0666”, TAG+="systemd