Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NanoPi NEO | Permission denied, cannot open /dev/ttyS1 #6094

Closed
MaikB85 opened this issue Jan 25, 2023 · 6 comments
Closed

NanoPi NEO | Permission denied, cannot open /dev/ttyS1 #6094

MaikB85 opened this issue Jan 25, 2023 · 6 comments

Comments

@MaikB85
Copy link

MaikB85 commented Jan 25, 2023

Creating a bug report/issue

Required Information

  • DietPi version |
    G_DIETPI_VERSION_CORE=8
    G_DIETPI_VERSION_SUB=13
    G_DIETPI_VERSION_RC=2
    G_GITBRANCH='master'
    G_GITOWNER='MichaIng'
    G_LIVE_PATCH_STATUS[0]='applied'
    G_LIVE_PATCH_STATUS[1]='not applicable'
  • Distro version | bullseye
  • Kernel version | Linux nanopineo 5.15.89-sunxi #22.11.4 SMP Mon Jan 23 21:58:30 UTC 2023 armv7l GNU/Linux
  • SBC model | NanoPi NEO (armv7l)
  • Power supply used | 5V 1,5A
  • SD card used | SanDisk ultra

Steps to reproduce

  1. Enabled Serial Port 1 with dietpi-config
  2. Node-Red Error:
    sudo journalctl -u node-red
    ... node-red[474]: 25 Jan 17:50:59 - [error] [serialconfig:27dba1b175b313e6] Serieller Port /dev/ttyS1 FEHLER: Error: Error: Permission denied, cannot open /dev/ttyS1 ......

Expected behaviour

NodeRed has no permission for Serial Port 1

Extra details

dietpi@nanopineo:~$ ls -la /dev/ttyS1
crw--w---- 1 root tty 4, 65 25. Jan 17:50 /dev/ttyS1

Tried to set permissions but after logout this resets to permissions above.

@MichaIng MichaIng changed the title NanoPiNeo: Permission denied, cannot open /dev/ttyS1 NanoPi NEO | Permission denied, cannot open /dev/ttyS1 Jan 25, 2023
@MichaIng
Copy link
Owner

Thanks for reporting.

crw--w---- 1 root tty are the default permissions it has, or is this how you changed it? On x86_64 I actually see crw-rw---- 1 root dialout. This is coming from a udev rule:

/usr/lib/udev/rules.d/50-udev-default.rules:KERNEL=="tty[A-Z]*[0-9]|ttymxc[0-9]*|pppox[0-9]*|ircomm[0-9]*|noz[0-9]*|rfcomm[0-9]*", GROUP="dialout"

There are some rules which match your permissions, but those do not match the device name, do they?

/usr/lib/udev/rules.d/50-udev-default.rules:SUBSYSTEM=="tty", KERNEL=="tty[0-9]*", GROUP="tty", MODE="0620"
/usr/lib/udev/rules.d/50-udev-default.rules:SUBSYSTEM=="tty", KERNEL=="sclp_line[0-9]*", GROUP="tty", MODE="0620"
/usr/lib/udev/rules.d/50-udev-default.rules:SUBSYSTEM=="tty", KERNEL=="ttysclp[0-9]*", GROUP="tty", MODE="0620"
/usr/lib/udev/rules.d/50-udev-default.rules:SUBSYSTEM=="tty", KERNEL=="3270/tty[0-9]*", GROUP="tty", MODE="0620"

Can you show the output of:

ls -l /sys/class/tty

@MaikB85
Copy link
Author

MaikB85 commented Jan 25, 2023

Thanks for reporting.

crw--w---- 1 root tty are the default permissions it has, or is this how you changed it? On x86_64 I actually see crw-rw---- 1 root dialout. This is coming from a udev rule:

/usr/lib/udev/rules.d/50-udev-default.rules:KERNEL=="tty[A-Z]*[0-9]|ttymxc[0-9]*|pppox[0-9]*|ircomm[0-9]*|noz[0-9]*|rfcomm[0-9]*", GROUP="dialout"

There are some rules which match your permissions, but those do not match the device name, do they?

/usr/lib/udev/rules.d/50-udev-default.rules:SUBSYSTEM=="tty", KERNEL=="tty[0-9]*", GROUP="tty", MODE="0620"
/usr/lib/udev/rules.d/50-udev-default.rules:SUBSYSTEM=="tty", KERNEL=="sclp_line[0-9]*", GROUP="tty", MODE="0620"
/usr/lib/udev/rules.d/50-udev-default.rules:SUBSYSTEM=="tty", KERNEL=="ttysclp[0-9]*", GROUP="tty", MODE="0620"
/usr/lib/udev/rules.d/50-udev-default.rules:SUBSYSTEM=="tty", KERNEL=="3270/tty[0-9]*", GROUP="tty", MODE="0620"

Can you show the output of:

ls -l /sys/class/tty
dietpi@nanopineo:~$ ls -l /sys/class/tty
insgesamt 0
lrwxrwxrwx 1 root root 0 25. Jan 17:50 console -> ../../devices/virtual/tty/console
lrwxrwxrwx 1 root root 0 25. Jan 17:50 ptmx -> ../../devices/virtual/tty/ptmx
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty -> ../../devices/virtual/tty/tty
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty0 -> ../../devices/virtual/tty/tty0
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty1 -> ../../devices/virtual/tty/tty1
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty10 -> ../../devices/virtual/tty/tty10
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty11 -> ../../devices/virtual/tty/tty11
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty12 -> ../../devices/virtual/tty/tty12
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty13 -> ../../devices/virtual/tty/tty13
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty14 -> ../../devices/virtual/tty/tty14
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty15 -> ../../devices/virtual/tty/tty15
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty16 -> ../../devices/virtual/tty/tty16
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty17 -> ../../devices/virtual/tty/tty17
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty18 -> ../../devices/virtual/tty/tty18
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty19 -> ../../devices/virtual/tty/tty19
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty2 -> ../../devices/virtual/tty/tty2
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty20 -> ../../devices/virtual/tty/tty20
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty21 -> ../../devices/virtual/tty/tty21
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty22 -> ../../devices/virtual/tty/tty22
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty23 -> ../../devices/virtual/tty/tty23
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty24 -> ../../devices/virtual/tty/tty24
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty25 -> ../../devices/virtual/tty/tty25
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty26 -> ../../devices/virtual/tty/tty26
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty27 -> ../../devices/virtual/tty/tty27
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty28 -> ../../devices/virtual/tty/tty28
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty29 -> ../../devices/virtual/tty/tty29
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty3 -> ../../devices/virtual/tty/tty3
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty30 -> ../../devices/virtual/tty/tty30
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty31 -> ../../devices/virtual/tty/tty31
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty32 -> ../../devices/virtual/tty/tty32
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty33 -> ../../devices/virtual/tty/tty33
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty34 -> ../../devices/virtual/tty/tty34
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty35 -> ../../devices/virtual/tty/tty35
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty36 -> ../../devices/virtual/tty/tty36
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty37 -> ../../devices/virtual/tty/tty37
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty38 -> ../../devices/virtual/tty/tty38
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty39 -> ../../devices/virtual/tty/tty39
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty4 -> ../../devices/virtual/tty/tty4
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty40 -> ../../devices/virtual/tty/tty40
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty41 -> ../../devices/virtual/tty/tty41
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty42 -> ../../devices/virtual/tty/tty42
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty43 -> ../../devices/virtual/tty/tty43
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty44 -> ../../devices/virtual/tty/tty44
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty45 -> ../../devices/virtual/tty/tty45
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty46 -> ../../devices/virtual/tty/tty46
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty47 -> ../../devices/virtual/tty/tty47
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty48 -> ../../devices/virtual/tty/tty48
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty49 -> ../../devices/virtual/tty/tty49
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty5 -> ../../devices/virtual/tty/tty5
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty50 -> ../../devices/virtual/tty/tty50
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty51 -> ../../devices/virtual/tty/tty51
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty52 -> ../../devices/virtual/tty/tty52
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty53 -> ../../devices/virtual/tty/tty53
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty54 -> ../../devices/virtual/tty/tty54
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty55 -> ../../devices/virtual/tty/tty55
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty56 -> ../../devices/virtual/tty/tty56
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty57 -> ../../devices/virtual/tty/tty57
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty58 -> ../../devices/virtual/tty/tty58
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty59 -> ../../devices/virtual/tty/tty59
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty6 -> ../../devices/virtual/tty/tty6
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty60 -> ../../devices/virtual/tty/tty60
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty61 -> ../../devices/virtual/tty/tty61
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty62 -> ../../devices/virtual/tty/tty62
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty63 -> ../../devices/virtual/tty/tty63
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty7 -> ../../devices/virtual/tty/tty7
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty8 -> ../../devices/virtual/tty/tty8
lrwxrwxrwx 1 root root 0 25. Jan 17:50 tty9 -> ../../devices/virtual/tty/tty9
lrwxrwxrwx 1 root root 0 25. Jan 17:50 ttyS0 -> ../../devices/platform/soc/1c28000.serial/tty/ttyS0
lrwxrwxrwx 1 root root 0 25. Jan 17:50 ttyS1 -> ../../devices/platform/serial8250/tty/ttyS1
lrwxrwxrwx 1 root root 0 25. Jan 17:50 ttyS2 -> ../../devices/platform/serial8250/tty/ttyS2
lrwxrwxrwx 1 root root 0 25. Jan 17:50 ttyS3 -> ../../devices/platform/serial8250/tty/ttyS3
lrwxrwxrwx 1 root root 0 25. Jan 17:50 ttyS4 -> ../../devices/platform/serial8250/tty/ttyS4
lrwxrwxrwx 1 root root 0 25. Jan 17:50 ttyS5 -> ../../devices/platform/serial8250/tty/ttyS5
lrwxrwxrwx 1 root root 0 25. Jan 17:50 ttyS6 -> ../../devices/platform/serial8250/tty/ttyS6
lrwxrwxrwx 1 root root 0 25. Jan 17:50 ttyS7 -> ../../devices/platform/serial8250/tty/ttyS7

when I disable Serial1 and reboot:

dietpi@nanopineowz:~$ ls -la /dev/ttyS1
crw-rw---- 1 root dialout 4, 65 25. Jan 18:46 /dev/ttyS1

after enable serial 1 again and reboot:

dietpi@nanopineo:~$ ls -la /dev/ttyS1
crw--w---- 1 root tty 4, 65 25. Jan 18:48 /dev/ttyS1

@MichaIng
Copy link
Owner

Ah, you mean when you enable/disable the login console on this serial device? Indeed, this triggers the change:

root@dietpi:~# systemctl start serial-getty@ttyS0
root@dietpi:~# l /dev/ttyS0
crw-rw---- 1 root dialout 4, 64 Jan 25 18:55 /dev/ttyS0
root@dietpi:~# htop
root@dietpi:~# l /dev/ttyS*
crw-rw---- 1 root dialout 4, 64 Jan 25 18:55 /dev/ttyS0
crw-rw---- 1 root dialout 4, 65 Jan 22 18:33 /dev/ttyS1
crw-rw---- 1 root dialout 4, 66 Jan 22 18:33 /dev/ttyS2
crw-rw---- 1 root dialout 4, 67 Jan 22 18:33 /dev/ttyS3
root@dietpi:~# systemctl stop serial-getty@ttyS0.service
root@dietpi:~# l /dev/ttyS*
crw--w---- 1 root tty     4, 64 Jan 25 18:55 /dev/ttyS0
crw-rw---- 1 root dialout 4, 65 Jan 22 18:33 /dev/ttyS1
crw-rw---- 1 root dialout 4, 66 Jan 22 18:33 /dev/ttyS2
crw-rw---- 1 root dialout 4, 67 Jan 22 18:33 /dev/ttyS3
root@dietpi:~# systemctl stop serial-getty@ttyS1.service
root@dietpi:~# l /dev/ttyS*
crw--w---- 1 root tty     4, 64 Jan 25 18:55 /dev/ttyS0
crw-rw---- 1 root dialout 4, 65 Jan 22 18:33 /dev/ttyS1
crw-rw---- 1 root dialout 4, 66 Jan 22 18:33 /dev/ttyS2
crw-rw---- 1 root dialout 4, 67 Jan 22 18:33 /dev/ttyS3
root@dietpi:~# systemctl start serial-getty@ttyS1.service
root@dietpi:~# l /dev/ttyS*
crw--w---- 1 root tty     4, 64 Jan 25 18:55 /dev/ttyS0
crw--w---- 1 root tty     4, 65 Jan 22 18:33 /dev/ttyS1
crw-rw---- 1 root dialout 4, 66 Jan 22 18:33 /dev/ttyS2
crw-rw---- 1 root dialout 4, 67 Jan 22 18:33 /dev/ttyS3
root@dietpi:~# systemctl stop serial-getty@ttyS1.service
root@dietpi:~# systemctl start serial-getty@ttyS3.service
root@dietpi:~# l /dev/ttyS*
crw--w---- 1 root tty     4, 64 Jan 25 18:55 /dev/ttyS0
crw--w---- 1 root tty     4, 65 Jan 22 18:33 /dev/ttyS1
crw-rw---- 1 root dialout 4, 66 Jan 22 18:33 /dev/ttyS2
crw--w---- 1 root tty     4, 67 Jan 22 18:33 /dev/ttyS3
root@dietpi:~# systemctl stop serial-getty@ttyS3.service
root@dietpi:~# l /dev/ttyS*
crw--w---- 1 root tty     4, 64 Jan 25 18:55 /dev/ttyS0
crw--w---- 1 root tty     4, 65 Jan 22 18:33 /dev/ttyS1
crw-rw---- 1 root dialout 4, 66 Jan 22 18:33 /dev/ttyS2
crw--w---- 1 root tty     4, 67 Jan 22 18:33 /dev/ttyS3

Don't ask my why the change on ttyS0 happened only after I stopped the service. But in all other cases it happens consistently. Makes sense, since this changes the function of that serial port to be an actual login console.

Is this what you actually need? Note that dietpi-config does not enable/disable the serial device/port itself, but only triggers boot output and the login prompt on those. And the latter enforces these permissions. It's actually not the service, but the agetty command itself which does this, as further tests reveal.

@MaikB85
Copy link
Author

MaikB85 commented Jan 25, 2023

Ah okay I think I misunderstood this function. Thought this would disable Serial port.

Well after disable the console for serial1 the error message for permissions in nodered is gone, but now I get message:

Jan 25 19:07:23 nanopineowz node-red[474]: 25 Jan 19:07:23 - [error] [serialconfig:27dba1b175b313e6] Serieller Port /dev/ttyS1 FEHLER: Error: Error: Input/output error setting custom baud rate of 115200

@MaikB85
Copy link
Author

MaikB85 commented Jan 25, 2023

Okay this can be closed. I have to enable the uart1 devicetreeoverlay in /boot/dietpiEnv.txt

now it works.

Thanks for your help!

@MichaIng
Copy link
Owner

Toggling the overlays is indeed something we need to implement. Interesting that the device is present even without the overlay enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants