Serial port emulation with tty0tty

The tty0tty package compiles to kernel module which created pairs of serial port devices /dev/tnt* connected together.

../../_images/200427-tty0tty.jpeg

Get the code

Download the tty0tty package from one of these sources:

Extract it

tar xf tty0tty-1.2.tgz

Build

Build the kernel module from provided source

cd tty0tty-1.2/module
make

Install new kernel module

Copy the new kernel module into the kernel modules directory

sudo cp tty0tty.ko /lib/modules/$(uname -r)/kernel/drivers/misc/

Load the module

sudo depmod
sudo modprobe tty0tty

You should see new serial ports in /dev/ (ls /dev/tnt*)

Set permissions

Give appropriate permissions to the new serial ports

sudo chmod 666 /dev/tnt*

You can now access the serial ports as /dev/tnt0 (1,2,3,4 etc) Note that the consecutive ports are connected to each others. For example, /dev/tnt0 and /dev/tnt1 are connected as if using a direct cable.

Persisting across boot

edit the file /etc/modules (Debian) or /etc/modules.conf

nano /etc/modules

and add line “tty0tty” the to it:

200427, updated 20.5.2020/pekka