I have an annoying problem with minicom connected to a serial console to a Yocto Linux machine.

The command that I enter wraps around on the same line after 80th character. This becomes very inconvenient to work with. Everything I entered at the beginning of the line gets overwritten by the last chars of that line.

A SSH connection to the same machine works just fine. After 80th characters ssh go to the next line.

This is the stty setting:

stty -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 = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd 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

The -w option of minicom has no effect. Still the same behavior

minicom -w

The resize command is not available on that machine. To which package does it belong? Maybe I can install it.

How can I fix that behavior?

  • What is the TERM environment variable when connected via minicom? – thrig Oct 19 '16 at 16:30
  • echo $TERM xterm – Oliver G. Oct 19 '16 at 16:30
  • show output of stty -a executed inside minicom – Arkadiusz Drabczyk Oct 19 '16 at 17:28
  • Does running minicom with -w help? – Arkadiusz Drabczyk Oct 19 '16 at 18:12
  • If I use putty instead of minicom as serial terminal program and enable the terminal setting "implicit LF in every CR" the behavior is gone. – Oliver G. Oct 20 '16 at 9:54

This worked for me. The target shell needs to be set to check window size and to be set to the correct size of your console gui. After connecting via serial with either putty or minicom:

shopt -s checkwinsize
  • This seems to have worked for me but am not clear how this was done or how to apply it as a general rule. – TheMeaningfulEngineer Feb 19 '19 at 15:16
  • Add this to your .bashrc on the target: "shopt -s checkwinsize" and "eval ` resize `" – Mark Inderhees Feb 20 '19 at 17:08

When you are connected via a serial line, there is no way for the system to negotiate the window size with the terminal (NAWS - Negotiate About Window Size is RFC 1073). In that case you can get either a system default for the size, or even just zeros. Either would confuse the shell's line editor, which needs to know the actual width of the terminal to work with its wraparound feature.

bash gets confused, thinking it has wrapped due to terminal's autowrap feature and moves to the beginning of the current (wrong) line as part of the line-editing/display.

As a workaround, most of the terminals (including minicom — see source) which you would use with a serial interface can respond to the cursor position report escape sequence used by resize to find the window size — and as a side effect set the system's idea of how large your terminal window is.

  • 1
    I'd still be curious why it wraps around on the same line, instead of into the next line. – dirkt Oct 20 '16 at 5:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.