Communicating to a serial interface of an embedded Linux device using kermit

By | April 19, 2015

I have used kermit for connecting to serial interfaces for several years and it has always worked as expected. Even for sending a kernel image to U-Boot using the zmodem protocol (yes, it took ages, but there was no Ethernet) has worked quite well.

Recently, a friend that is new to embedded Linux ask me how to connect to a serial interface, so this is a small and simple guide on how to do it.

Just as an intro, a summary of what is kermit taken from the Fedora repo:

C-Kermit is a combined serial and network communication software package offering a consistent, medium-independent, cross-platform approach to connection establishment, terminal sessions, file transfer and management, character-set translation, and automation of communication tasks.

If you have Fedora, CentOS, SuSE or other rpm based distribution

yum install ckermit

If you have Debian, Mint, Ubuntu or other deb based distribution

apt-get install ckermit

Create the configuration file .kermrc in your home directory. These parameters are normally right for most systems. I’ve used it for SH4 and ARM based devices:

set line /dev/ttyUSB0
set speed 115200
set carrier-watch off
set handshake none
set flow-control none
set file type bin
set file name lit
set rec pack 1000
set send pack 1000
set window 5

The most important parameters here are the line parameter that indicates the serial device and the speed parameters that is it’s baud rate. If you have an USB-to-serial interface converter your device will be /dev/ttyUSBx where x is normally 0, but it depends on how may USB-to-serial converters you have. The same happens if you have a normal serial cable, except that your device will be named /dev/ttySx, where x is normally 0.

Add your user to the dialout group in the /etc/group file


Logout and login again. This is needed since the group to which a user belongs are assigned when the user logs in.

Open a shell and execute kermit. The output should be something like this:

Connecting to /dev/ttyUSB0, speed 115200
 Escape character: Ctrl-\ (ASCII 28, FS): enabled
Type the escape character followed by C to get back,
or followed by ? to see other options.

By default, kermit searches the file .kermrc in your home directory. If you have several kermit config files (may be because you have several boards configured differently), you can specify it:

kermit /home/paguilar/.custom_kermrc

If there are problems like the wrong serial interface, you may see a message like this one:

?SET SPEED has no effect without prior SET LINE
Sorry, you must SET LINE or SET HOST first
C-Kermit 9.0.302 OPEN SOURCE:, 20 Aug 2011, for Linux (64-bit)
 Copyright (C) 1985, 2011,
  Trustees of Columbia University in the City of New York.
Type ? or HELP for help.

You can also have this problem if there is a lock file. This error happens if you try to access the serial interface whilst another process is already using it. It can also happen if you kill a previous kermit session when it was connected to the serial interface.
In these cases you have to remove the lock file and execute kermit again.

Assuming that everything went right and you happily used a busybox shell or similar you can disconnect from kermit by typing Ctrl-\ + q

Just to be clear, the escape control sequence is Ctrl and backslash at the same time, then you enter the desired character.
For example, if you are in your board’s shell, for connecting to the kermit shell just type Ctrl-\ + c, then enter connect to go back to your board’s shell.

That’s it.

Leave a Reply

Your email address will not be published. Required fields are marked *