About opening the serial port

Dear Sir,
When opening the serial port, only /dev/tty1, a virtual terminal, can be opened. /dev/ttyths1 cannot be opened
How to open ttyths1?

If you run “ls -l” on your tty device, then probably it will be either group tty or group dialout. If it is tty, then probably this is in use as a serial console and it doesn’t work out well when two different programs use the same port. If the port is group dialout, then likely the port is available. Your user would have to be a member of group dialout for this latter case.

What do you see from “ls -l /dev/tty1 /dev/ttyTHS1”? If your user’s login name is “nvidia”, then what do you see from:
egrep '(dialout|tty)' /etc/group | egrep nvidia

Not sure if I understand your issue correctly but you may check this link which talks about ttyTHS1.

I followed this and show the attached :

I think you need to access ttyTHS1 with root permission by “sudo”.

/dev/ttyTHS0 is group tty, and so this is used by serial console. Note that the “/dev/tty1”, also owned by group tty, is a console, but this is not a serial console, it is a directly attached console. The group tty indicates console of some sort, while the actual device being “ttyS” or “ttyTHS” indicates serial. The actual device “/dev/tty1” is not a serial UART. Since ttyTHS1 is group dialout the implication is that this is free to open and use as you wish, provided your user is a member of group dialout.

Is your user in dialout? See:
grep 'dialout' /etc/group

If you wish to add a user to group “dialout”, then you must be careful to append and not set group (if you do a simple set, then this will be the only group of your user from then on). As an example, if your user’s name is “nvidia”, then this would add user “nvidia” to group “dialout” while preserving other groups:
sudo usermod -aG dialout nvidia

You probably don’t need the rest of it, but it is useful to know if you work with serial devices or terminal programs…

Note that both a “ttyS” and a “ttyTHS” might imply the same serial UART hardware; the name “ttyS” uses the traditional generic driver, and the “ttyTHS” uses the NVIDIA driver. In early boot stages, prior to the Linux kernel loading, the only serial driver is the older driver, and thus a serial port which must operate during early boot stages must also use the older driver corresponding to the “ttyS” naming convention. Once Linux loads you can instead use the high speed driver with the “ttyTHS” naming convention. If both a “ttyS” and “ttyTHS” are group tty, then it implies it is the same hardware, but different drivers. The device tree “compatible” line names which drivers are allowed, and you could remove one driver or the other if you want to guarantee only the one device special file.

If you happen to be at the normal/regular (not sure how to phrase “not a serial console”) text console tty1 (the first regular console), and program any kind of print statement to stdout or stderr (cout or cerr), then you have just opened tty1 (the different open methods only change buffering). If you happen to be in a different text console, and have permission, then it may be possible to echo text to the tty1 terminal through “/proc/<pid>/fd/1” or “/proc/<pid>/fd/2”, but this is unusual. The command “wall” does this (see “man wall”), but unless you are writing a text-only kiosk application to replace getty/agetty, then directly opening tty1 is highly unlikely to be what you want.