Skip to content

Instantly share code, notes, and snippets.

@r10r
Last active October 7, 2021 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r10r/b861730c0f63afb9584756f0cf2d5590 to your computer and use it in GitHub Desktop.
Save r10r/b861730c0f63afb9584756f0cf2d5590 to your computer and use it in GitHub Desktop.
Create a virtual serial console on macos and connect with c-kermit

system configuration

References

inittab

  • see man 5 inittab

isolinux

syslinux serial configuration

The serial parameters are hardcoded to be 8 bits, no parity, 1 stop bit.

isolinux/isolinux.cfg serial console configuration

serial 0 115200

initrd /initrd.img console=tty0 console=ttyS0,115200n8 earlyprintk=ttyS0,115200n8

Microsoft Azure

testing

virtualbox serial port

To connect to a virtual serial port (see system specific setup below) enable the first serial port in virtualbox:

  1. Go to Machine -> Settings -> Ports
  2. In Port 1 enable the checkbox Enable Serial Port
  3. Set Port Mode to Host Device
  4. Set Path/Address to serial port master /tmp/port/master

macOS

virtual serial port

From https://github.com/clokey/PublicCode/tree/master/MacOSXVirtualSerialPort

Create a virtual serial port on macOS

sudo socat -d -d -d -d -lf /tmp/port/log \
pty,link=/tmp/port/master,raw,echo=0,user=ruben,group=staff \
pty,link=/tmp/port/slave,raw,echo=0,user=ruben,group=staff

minicom

Installation: brew install minicom

Connect with minicom to the slave device minicom -b 115200 -D /tmp/port/slave -8.

  • NOTE: minicom does not support ANSI colors properly.

C-Kermit

Installation: brew install c-kermit

Use the script serial-console-macos.sh to create and connect to the serial port.

Windows

virtual serial port

?

Kermit 95

Installation: https://kermitproject.org/k95.html

#!/bin/sh -eu
SOCAT_PID=""
WORK=/tmp/socat-serial
PROFILE="${1:-}"
if ! [ -z "$PROFILE" ]; then
WORK=${WORK}-${PROFILE}
fi
MASTER_LINK=$WORK/master
SLAVE_LINK=$WORK/slave
cleanup() {
[ -z $SOCAT_PID ] || sudo kill $SOCAT_PID
[ -d $WORK ] && rm -rf $WORK
}
trap cleanup exit
if [ -d $WORK ]; then
echo "ERROR $WORK already exists"
exit 1
else
mkdir -p $WORK
fi
# Use existing USER environment variable
# USER=$(id -u -n)
GROUP=$(id -g -n)
{
cat <<EOF
socat -d -d -d -d -lf $WORK/log \
pty,link=$MASTER_LINK,raw,echo=0,user=$USER,group=$GROUP \
pty,link=$SLAVE_LINK,raw,echo=0,user=$USER,group=$GROUP &
EOF
} | sudo /bin/sh
SOCAT_PID=$?
echo
echo "you can now use $MASTER_LINK as serial port master device"
echo
cat >$WORK/kermit-serial <<EOF
#! /usr/bin/env kermit +
;
set modem type none
set line $SLAVE_LINK
set carrier-watch off
set speed 115200
set flow rts/cts
eightbit
set parity none
set stop-bits 1
connect
EOF
chmod +x $WORK/kermit-serial
$WORK/kermit-serial
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment