in the TX1, how can i set uart baud rate to 614400

in the TX1, how can i set uart baud rate to 614400??

set /dev/ttyTHS2

Since both sides of a serial communications need to match you may find running in loopback to be the simplest way to do testing. On J17 pins 4 and 5 are TXD and RXD, respectively, and you can directly jumper these two wires and the terminal will echo back to itself if you type something in (normally you’d type and nothing would show up unless the other end echos back). If you jumper pins 2 and 6 this will link together CTS and RTS, allowing CTS/RTS flow control should you want to test that too.

I used gtkterm (sorry, I’m testing on a TX2, should be similar, but it is possible it is different) in its default of 9600 baud:

gtkterm -p /dev/ttyTHS2

If I run “stty -a -F /dev/ttyTHS2” this verifies the 9600 baud:

$ stty -a -F /dev/ttyTHS2
<b>speed 9600 baud</b>; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z;
rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc

To print just the speed:

stty -F /dev/ttyTHS2 speed

To set speed to 115200:

stty -F /dev/ttyTHS2 ispeed 115200

…if I then run gtkterm at that speed I see characters correctly echo back:

gtkterm -p /dev/ttyTHS2 -s 115200

When I try to use “614400” as speed it is ignored. I’m thinking this is a speed not supported (and since I am using loopback it guarantees there is no interaction with another serial device causing the failure).

I believe the default mode is 16550, so available speeds should at minimum match that. Normally 38400 baud is available, and a 16x divisor would reach 614400 baud (see the TRM section 36.2.7) so it seems plausible this rate might be supported. Unfortunately “setserial” does not deal correctly with ttyTHS2, it fails to detect the 16550 emulation…which in turn means you can’t rely on the divisor or anything else from its output. stty itself does not seem to support custom divisors, but I can use stty to set speed 38400, and then blindly attempt a custom divisor of 16 via setserial:

setserial /dev/ttyTHS2 divisor 16

…setserial now shows divisor 16, stty now shows speed 38400.

I don’t know if this is really running 614400 baud, but echo on loopback does work. You’d probably have to put an oscilloscope on the data lines to verify if it is still at 38400 or if it is truly multiplying by 16 and reaching 614400.

i resolve this question. change termbits.h in …/asm-generic file , replace a baudrate with B614400
in addition to this , modify the tty_ioctl.c in …/driver/… file, in the array baud_table and baud_bits. similar , replace the same baudrate with B614400 .
finally rebuild kernel .

in the TX1 , modify termbits.h in …/asm-generic file again.
it’s ok!

Hello Sir,
What is the python code to transmit the serial data on UART TX0 pin of the jetson TX2.
and what connections need to be done with peripheral device. Please help.

Thank You

Why, after a reboot, the speed returns to the standard value of 9600? Please tell me how to fix and so that after the reboot there was a speed chosen by me
Thanks

Long way:

The answer might depend on which release you use. Also, which logical device are you using, e.g., “/dev/ttyTHS2”? I have not looked at it in a long time, but if you want a different default, then you might be able to do this with the device tree. To see your current device tree as a human readable file:

# If you need "dtc":
sudo apt-get install device-tree-compiler
# Extract:
dtc -I fs -O dts -o extracted.dts /proc/device-tree
# Brows extracted.dts with your favorite editor...

Notice that there are several nodes identified in the format of “serial@########”, where “#” are numbers. The number is the base address of a serial UART, and there are several UARTs (between the schematic and TRM docs you can find which UART goes to a particular carrier board pin). The content of the node are parameters which a “serial” device at that base address will use by means of being passed to the driver. UARTs can of course be changed in a running system in a number of ways, but the arguments to the driver through device tree will be the first setup.

The TRM talks about clocks. Values within the node are hexadecimal, so “9600” is also 0x2580, and 0x1c200 is “115200”. A number of values are given to say what initial values can be used. Other software might also set the port speed after the device tree loads, e.g., serial console has values set from earlier boot stages before Linux ever starts.

I couldn’t tell you offhand everything which sets serial UART values during boot other than for the serial console.

Short Way:

See comments on adding package “setserial” (“sudo apt-get install setserial”):
https://unix.stackexchange.com/questions/91458/best-way-to-set-serial-port-speeds-on-boot