UART1 cannot be used immediately after booting

I use Jetson Xavier NX Developer Kit.I use the program to open UART1(/dev/ttyTHS0, The 8th and 10th pins of 40pin gpio) after booting,UART1 cannot communicate.

If use cutecom to open UART1, if I open it too fast, it will get an error(No such file or directory)(But I waiting for a while after booting will not),Turn it on again to use it normally. Then use the program to open the serial port to communicate.

My purpose is to write a script that can be used to modify UART1 permissions, and use the program to open UART1 for communication. Now I’m stuck here.I hope to get some help,thanks.

hello miragemubhr,

you may monitor kernel init messages, which register serial ports to ttyTHS*
please have a try to delay the program to open the serial port for communication after that.

FYI, if you are trying to change permissions to a serial terminal device special file manually, then it won’t be doing what you expect. “udev” is what is meant to change permissions and naming of device special files (these are really drivers programmed to pretend they are files, and not actual files). On the other hand, group of an unowned serial device will be “dialout”, and whoever is using the port should just be added to group “dialout”, then there is no need to use udev to modify anything.

Thank you.I will analyze the kernel initialization message under monitoring.

Thanks for answering, but you got it wrong. When UART1 is turned on, users in the group do not have read permission (620), and must modify the permissions, and they can modify the permissions. Otherwise, UART1 cannot be opened. However, even if the authority (660) is modified, it cannot be used to receive information when it is just turned on. I have to open UART1 through cutecom, maybe other serial tools will do, but I have not used them.

What do you see for “ls -l /dev/...the device name...” before using the device?

crw-rw---- 1 root tty 238, 0 /dev/ttyTHS0
When I enter the grep ‘tty’ /etc/group command, I get tty:x:5:nvidia.

This says that this terminal is in use by the serial console, and that you can both read and write if you are either “root” or a member of “tty” group.

Being that this is a serial console, consider that something is already using this and the only “talking” over that port should be through the TX/RX pins, not on command line. You could get away with sending some content to command line that way, but I’m not sure how security would deal with it.

Do you want this UART for your own purposes? If so, then you must disable serial console (not usually advised since it is quite useful for debugging).

Once serial console is disabled the group should become “dialout” instead of “tty”. Then anyone in group “dialout” would be able to read/write. Read/write to this port as group “tty” is probably not a valid operation.