HOWTO: Testing Serial Ports under Debian Linux
Purpose: This blog entry explains how you can determine whether your Serial Ports on your system works or not under Debian Linux.
Requirements:
- Two computers running Debian Linux
- At least one Serial Port on each of the computer
- A Serial Cable that runs from one computer (Computer A) to another computer (Computer B) with proper gender at both ends.
- Serial Port driver available in the Kernel. Almost all the kernels have it configured in them.
- Software: minicom & setserial (if required)
Install the software by giving commands:
#apt-get update
#apt-get minicom setserial
Basics:
Before we begin, it is important to know that your Serial Ports (COM1 and COM2) are named as /dev/ttyS0 and /dev/ttyS1 respectively and so on.
BIOS configuration: It is important to first check your BIOS and see if Serial Ports are disabled or not. If they are disabled then please enable them and assign them proper IRQ before you proceed.
The BIOS default settings are as follow:
COM1 – 0×3F8 = IRQ4
COM2 – 0×2F8 = IRQ3
Almost all the BIOSes have the above setting. Therefore, there are very less chances that you will have to modify those in the BIOS.
Tell me how to test now?
Step 1: Connect both the serial port of computer A to serial port of computer B using the Serial Cable.
Step 2: Check if Linux detects your Serial Port or not
There are many ways to do that. One way you could do is to give the following command:
# dmesg | grep ttyS
You should see something like this:
serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
serial8250: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
00:09: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
00:0a: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
The above output shows that your COM1 and COM2 ports are available and Linux recognizes them.
Another way to test is to give the following command:
# ls > /dev/ttyS0
If the command does not return any error message then your Serial Ports are recognized by your Linux system.
Errors?
In case, Linux does not detect your Serial Port, then try giving the following command:
setserial /dev/ttyS0 autoconfig auto_irq
Substitute ttyS0 with ttyS1 as required.
Step 3: Configure your Serial Ports
Launch the minicom program from your terminal and input the following settings after navigating through the minicom menu (Ctrl A -Z):
Select the device: ttyS0 or ttyS1 (Depending on whatever device name is being assigned to your serial port)
Buad Rate: 57600
Bits per second: 8
Parity: None
Stop Bits: 1
Hardware Flow Control: Yes
Software Flow Control: No
Here is an example of the settings:

Once you configure your Serial Port with above parameters, you are ready to start communicating between the two computers through Serial Connection.
Step 4: Start communicating
Before you can start communicating, you need to perform the Steps 2 and 3 on your other computer also. Once you do that you should be in a state where you have minicom window in front of you on both the computers.
Now start typing some characters from computer A (in your minicom window typing screen) and you should see those characters appearing auto-magically on your computer B. For example like this:
Errors?
Note: In some case, you might get an error as follow as soon as you try to launch “minicom” program:
#minicom
minicom: WARNING: configuration file not found, using defaults
Device /dev/modem access failed: No such file or directory.
All this means is that you need to pass on the flag -s when you launch minicom like this:
#minicom -s
Once you do that you should be able to select your serial port device and other parameters.
That’s it! You have successfully detected and tested Serial Ports on Debian Linux.
If you are further interested in this topic, then I high recommend you to read the following articles:
- http://www.cpqlinux.com/serialconsole.html
- http://www.vanemery.com/Linux/Serial/serial-console.html
As usual, please leave a comment/feedback if you have any. Comments encourages bloggers to post more and keep their spirits high.
Learn how to redirect Linux console messages over Serial Ports on another machine.


Free Email Subscription









August 5th, 2008 at 7:11 am
Thanks for Sharing!
Reply to this comment
September 24th, 2008 at 6:06 pm
good site izuetr
Reply to this comment
October 15th, 2008 at 1:08 pm
Well I am communicating with a single board computer(SBC) a PC104 using linux. Everything was going fine with minicom and suddenly it initiallized the modem through serial port ttyS0 and when I switch on the SBC it doesn’t load ?? any suggestions ? Thank you
Reply to this comment
Kushal Reply:
February 20th, 2009 at 12:22 am
Can you explain your problem in more detail? Between which two computers are you communicating? Is your SBC a PC/104 embedded computer? Which distro are you running on it?
Reply to this comment
March 29th, 2009 at 8:01 pm
[...] messages to a serial port on another computer. In one of my previous post, I had explained how to test serial ports under Linux. I highly recommend that you read it first before you read this post any [...]
March 31st, 2009 at 8:46 am
you have a typo in command:
# ls > /dev/tyS0
will always return error … ttyS0 works better
Reply to this comment
Admin Reply:
March 31st, 2009 at 9:06 am
Hi Kaii,
Thank you for pointing out the typo. I have now corrected it.
Reply to this comment
June 30th, 2009 at 11:11 pm
This is my first visit to your blog and found it very informative.
Reply to this comment
November 25th, 2009 at 3:03 am
Hi
I tried this using two windows system with Vmware having ubuntu images.
step 2: gives proper information ( # dmesg | grep ttyS)
i am using minicom under thus ubuntu image in VmWare , but unable to get any updates from serial port .
like i do
1)setting for serial port , save settings as dfl ,
and then the minicom runs ,
2) from other shell i do ls > /dev/ttyS0 but nothing comes on minicom console .
i expect the return string from ls should be displayed on minicom console , but that doesnt happen.
Any idea what could be the issue ?
Reply to this comment
December 3rd, 2009 at 7:25 am
Great read! thx
Reply to this comment