1

I'm not able to keep fixed speed on serial terminal /dev/ttyS0. I use:

stty -F /dev/ttyS0 115200
root@ubuntu:/# stty -F /dev/ttyS0 -a
speed 115200 baud; rows 24; columns 80; 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 = <undef>; 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

Apparently, it is changed. However, when I start sending a few characters through serial port (I am 100% positive that I use 115200, I verified connecting to windows com port), the Ubuntu terminal changes automatically to 9600 again!

stty -F /dev/ttyS0 -a
speed 9600 baud; rows 24; columns 80; 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 = <undef>; 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

How do I force the terminal to use fixed 115200?
Apparently either it's changing to 9600 for unknown reason, or (tries to) automatically detect serial speed?

More information. GRUB (configured via /etc/default/grub) is outputting correctly at 115200

error: no video mode activated.

                    GNU GRUB  version 2.02~beta2-36ubuntu3.2

 +----------------------------------------------------------------------------+
 |*Ubuntu                                                                     |
 | Advanced options for Ubuntu                                                |
 | Memory test (memtest86+)                                                   |
 | Memory test (memtest86+, serial console 115200)                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 +----------------------------------------------------------------------------+

      Use the ^ and v keys to select which entry is highlighted.
      Press enter to boot the selected OS, `e' to edit the commands
      before booting or `c' for a command-line.
   The highlighted entry will be executed automatically in 0s.

But immediately after GRUB, just garbage, my ubuntu 16.04 is sending at 9600 again.

More updates: According to this, can be a bug of agetty
https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1571500

systemctl status serial-getty@ttyS0.service
● serial-getty@ttyS0.service - Serial Getty on ttyS0
   Loaded: loaded (/lib/systemd/system/serial-getty@.service; disabled; vendor p
   Active: active (running) since Du 2016-11-13 17:58:28 EET; 1s ago
     Docs: man:agetty(8)
           man:systemd-getty-generator(8)
           http://0pointer.de/blog/projects/serial-console.html
 Main PID: 12526 (agetty)
   CGroup: /system.slice/system-serial\x2dgetty.slice/serial-getty@ttyS0.service
           └─12526 /sbin/agetty --keep-baud 115200 38400 9600 ttyS0 vt220

when I issue manually, without --keep-baud, it works

/sbin/agetty 115200 ttyS0 vt220

So the question is now how to disable --keep-baud option forever. I cannot find any initialization of agetty.

Thanks in advance!

yo3hcv
  • 163

0 Answers0