5

I'd like be able to establish a connection to a headless Ubuntu 18.04 server from a Ubuntu 18.04 laptop via serial console in order to avoid having a graphic card consuming energy in the server.

The motherboard is an ASRock X99 Extreme3. Its UEFI has an option to enable/disable the serial port which I set to enable - smart as I am - and to select 3F8h/IRQ4 or 3E8h/IRQ4 for the "Serial Port Address" where I left the initially selected 3F8h/IRQ4 without knowing what the values stand for.

On the server, I connected a RS232 to D-Sub connector (DB9) to the serial port of the motherboard and plugged in a gender changer. It translates

-------------                 -----------
\ 5 4 3 2 1 /       to       / 5 4 3 2 1 \
 \ 9 8 7 6 /                /   9 8 7 6   \
  ---------                 ---------------

The laptop doesn't have a serial port, so I use a Serial-USB adapter which causes

[ 4303.030466] pl2303 3-1.1:1.0: pl2303 converter detected
[ 4303.031471] usb 3-1.1: pl2303 converter now attached to ttyUSB0

to be printed in dmesg after it's plugged-in.
On the server side the output of dmesg | grep tty is

[ 0.218803] printk: console [tty0] enabled
[ 2.079815] 00:03: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A

I read about the possibility to specify a serial console to GRUB and related kernel parameters, however I don't find any clear statement whether that's necessary or not to be able to connect after the system booted (I don't need to be able to connect to GRUB's console for now).

When I try to connect to the server using

sudo minicom -D /dev/ttyUSB0

or putty, I see

CTRL-A Z for help | 115200 8N1 | NOR | Minicom 2.7.1 | VT102 | Offline | ttyUSB0 

in the footer for the former and both terminals don't take any input. I payed attention to match the device file to connect to with the one printed in dmesg.

I'm suspicious that I don't have to install or configure anything on the server side except turning on the serial port in the UEFI. Can that be correct?

Maybe the BAUD rate isn't negotiated automatically and needs to be configured, but I have no idea how to figure out the correct value. I ran the configuration for minicom, but could only select default values because I don't find a good explanations - in all tutorials the connection just magically works after minicom -s apparently. Maybe the connection works and I'm missing the final step to connect.

I added the desktop user account and root to the groups dialout and uucp.

I can provide all necessary information for both server and laptop.

4
  • Not a serial connection expert, but look into kernel options, specifically console= – Sergiy Kolodyazhnyy Aug 31 '19 at 20:21
  • @SergiyKolodyazhnyy I'm willing to do trial and error, do you have any suggestions what to try? – Karl Richter Aug 31 '19 at 20:34
  • just set console=/dev/ttyUSB0 in GRUB at boot time ( e to edit menu entry ) and try booting with that. Also check if your device is actually ttyUSB0 and not ttyACM0 because a lot of modern serial adapters use that. Again, i am no expert on serial stuff, i'm just giving a suggestion to try which is why this is a comment and not an answer, and just hoping to help in any way I can – Sergiy Kolodyazhnyy Aug 31 '19 at 21:35
  • @SergiyKolodyazhnyy Thanks for you ideas, they're most welcome. ttyUSB0 should be clear from the dmesg output afaik. I specified console=tty0 console=ttyS0 on the server side and console=tty0 console=ttyUSB0 on the laptop at boot (verified in dmesg that parameters are really used). – Karl Richter Sep 1 '19 at 12:23
2

Some good reading is available from Official Ubuntu Documentation:

Alternative serial client: screen

GNU screen actually is a very capable serial terminal.

To install:

sudo apt-get install screen

To start:

sudo screen /dev/ttyUSB0 n

Some additional tips:
1. adjust the n to what you need:

  • Start without a number on the first try; it might auto-negotiate flawlessly
  • then use 115200, 57600, 38400, 19200, 9600, 4800, 2400, 1200 and stop when it starts working.
  • If you're a purist and don't like using sudo for this or need to hand this out to users not having access to sudo, add them to the dialout group.

To end the session, use Ctrl-A or Shift-K.

5
  • Thanks for your answer. I tried all baud values, but I only get a screen where I see blinking cursor and all input is ignored. I'm sure I have to set something up at the server side, like the login with getty as shown in the linked article. /sbin/getty -L 115200 ttyS0 vt102 returns with code 1 after a few seconds. Shouldn't I add console=tty0 console=ttyS0 to the boot parameters on the server in order to get output to the serial adapter? – Karl Richter Sep 2 '19 at 17:11
  • @KarlRichter According to the link on the server side you need something like /sbin/getty -L 115200 ttyS0 vt102 setup. You can also edit grub parameters and use: console=tty0 console=ttyS0,115200 or systemd getty startup service. See: wiki.archlinux.org/index.php/Working_with_the_serial_console – WinEunuuchs2Unix Sep 2 '19 at 18:40
  • This getty command fails, it seems however common to control getty through systemd. sudo systemctl start getty@ttyS0.service is successful on the server side according to systemctl status. However, I still can't even connect locally to the serial console on the server side using sudo screen /dev/ttyS0 (without or with any baud rate). I expect a login screen identical to the one shown when changing ttys using e.g. Ctrl+Alt+F3. – Karl Richter Sep 2 '19 at 19:38
  • @KarlRichter Arch Linux does say: "Unless specified otherwise in the kernel command line, getty will be expecting 38400 bit/s baud rate, 8 data bits, no parity and one stop bit-times". Also in some BIOS you need to enable serial. I'm wondering if you've tried it without the gender changer too? – WinEunuuchs2Unix Sep 2 '19 at 19:43
  • I tried console=ttyS0, console=ttyS0,115200 and console=ttyS0,38400 always after console=tty0. I understand that an explicit value is recognized. I enabled serial in UEFI, that's in the question btw. Without the gender changer I cannot connect and afaik, modem cables always have a female connector. Maybe you have recommendation for a serial to D-SUB converter. – Karl Richter Sep 2 '19 at 20:01
0

[ 2.079815] 00:03: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A

The link above that the kernel detected in 16550 UART which provides a ttyS0 port and some resources allocated to it ( 0x3f8 IO address and IRQ 4 ).

On the server side, Make sure

  1. The Serial already connected to USB Port. check it with following :

    $lsusb
    

    The Output should be like :

    Bus 003 Device 001: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
    
  2. The default permissions for ttyS* are the following :

    crw-rw---- 1 root dialout ... /dev/ttyS0
    

    Yo're already a member of dialout group with add :

     $sudo adduser $USER dialout
    

    Let the Minicom can access the ttyUSB* using :

    $sudo chmod 0777 /dev/ttyUSB0
    crwxrwxrwx 1 root dialout ... /dev/ttyS0

Next Step, Setting up the Minicom should be like :

$sudo minicom -s
    +-----[configuration]------+                                     
    | Filenames and paths      |                                     
    | File transfer protocols  |                                     
    | Serial port setup        |                                     
    | Modem and dialing        |                                     
    | Screen and keyboard      |
    | Save setup as dfl        |
    | Save setup as..          |
    | Exit                     |
    | Exit from Minicom        |
    +--------------------------+

Choose "Serial port Setup" menu and Then do the configuration as needed and save setup as dfl. Finally restart your Minicom.

    +-----------------------------------------------------------------------+
    | A -    Serial Device      : /dev/ttyUSB0                              |
    | B - Lockfile Location     : /var/lock                                 |
    | C -   Callin Program      :                                           |
    | D -  Callout Program      :                                           |
    | E -    Bps/Par/Bits       : 115200 8N1                                |
    | F - Hardware Flow Control : Yes                                       |
    | G - Software Flow Control : No                                        |
    |                                                                       |
    |    Change which setting?                                              |
    +-----------------------------------------------------------------------+
            | Screen and keyboard      |
            | Save setup as dfl        |
            | Save setup as..          |
            | Exit                     |
            | Exit from Minicom        |
            +--------------------------+

On the Laptop side, open Serial client like screen or putty :

  1. Use screen serial :

    $screen /dev/ttyUSB0 115200, cs8, -parenb, -cstopb

    Or

  2. Use putty serial :

    $sudo putty /dev/ttyUSB0 -serial -sercfg 115200,8,n,1,N

Hope this helps.

4
  • Thanks for your input. On the server I don't have a ttyUSB0 because I connect to the serial adapter there. So, should I start minicom on /dev/ttyS0 instead? – Karl Richter Sep 8 '19 at 15:44
  • @KarlRichter sorry, i mean on the laptop side which connect the motherboard :) , could be my configuration be reversed – abu-ahmed al-khatiri Sep 8 '19 at 15:51
  • Thanks for your support. I still only see a blinking cursor when connecting with either screen or putty (with the exact commands you listed). – Karl Richter Sep 8 '19 at 16:04
  • @KarlRichter to many variable to see your main issue for me, may i can see your configuration hardware between the client, the server and the motherboard? I also cannot see any clue of your set up :) – abu-ahmed al-khatiri Sep 8 '19 at 16:26

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.