Three commands to make serial console awesome
And I’ve been using
minicom ever since RedHat 4.X (if memory serves).
But past few weeks I’ve spent quite a bit of quality time with my APU2s2 and the minicom-backed serial console started getting on my nerves:
- terminal dimensions are stuck at 80x24
- poor ascii graphics support
- no colors
In this quickie I explore if I can do better with the serial console. Spoiler alert: hell yeah!
The (not so) arduous path to a solution…
I’m not the biggest wizard of them all – especially when it comes to VT* terminals. The little I know is that the Linux console is still stuck in this era… where ANSI escape sequences rule the world3. Nothing wrong with that, either.
So there are three problems stated above. Let’s tackle them one by one:
Terminal dimensions are stuck at 80x24
The first issue: the terminal dimensions. It makes perfect sense that in absence of more specific info, the terminal defaults to the lowest common denominator.
Turns out, that’s rather fixable:
$ stty size 84 159 $ stty cols 58 rows 20 $ stty size 20 58
So if you determine your terminal’s window size4 before launching the serial console, you can afterwards override the size and get better results.
Obviously that won’t patch through size changes (
SIGWINCH) but this is
still worlds better than previous state.
One down, two to go.
Poor ascii graphics support
This one is easy. My beloved
minicom was good at what it did originally
(dialup modem control). But it’s somewhat lacking in full utf8 support,
me thinks. Plus the need to (re)configure it initially is rather annoying.
But there’s another great, often pre-installed, terminal emulator:
Unbeknownst to me, one does simply:
$ screen /dev/ttyUSB0 115200
to get a decent serial console. With ascii graphics and UTF8 support. And as
a bonus, it has all the niceties of
Two down, one to go.
I know, I know… this one’s rather petty. But I’ve grown accustomed to the 16-color goodness of my xterm5, without which editing code rather sucks.
But the default terminal is at fault here:
# Somewhere in serial console land... $ echo $TERM vt220
Not to worry, one simple
export TERM=xterm-256color (or whatever your
happens to be) and you’re off to the races.
To sum up:
$ stty size 84 159 $ echo $TERM xterm-256color # ↑ remember those two! $ screen /dev/ttyUSB0 115200 # within the serial session: $ stty rows 84 cols 159 $ export TERM=xterm-256color # profit!
ssh still feels superior (less sluggish) than the serial console with
all of it’s 115200 baud rate goodness (over usb1.1, I presume). But the previous
setup was terrible. This one is more than agréable.
In case it’s not clear from all my previous fanboying. Tldr: those are AMD-powered boards with 2-4 GB RAM and SATA+mSATA+2xPCIe. Awesome little machines. Unobtainium due to Intel i210at / i211at shortages at the moment, tho. ↩
More on that hopefully soon? ↩
\033[00;36m, my old friend. ↩
Yeah, yeah, 256 colors and what not. You know the joke with men and Windows in default settings? ↩