PDA

View Full Version : [SOLVED] MCS9865 6 port / multiport serial PCI card and tips for Cisco console connections



scorpionstudios
January 10th, 2011, 02:12 AM
Hi,

Just making a record here for anyone else wishing to use this card with Ubuntu 10.10 or later, and indeed anyone looking to connect 6 serial console cables from their PC to Cisco routers and switches or similar gear.

Long story short is this:
- I need 6 serial ports... so I bought a card advertised as linux compatible 2.6.11+
- In Ubuntu 10.10, the kernel will only 'see' 4 UARTs by default (read, serial ports)
- My MCS9865 based serial card has 6 UARTs, and my motherboard has one too
- After booting up with the card, dmesg complains that it could assign 4 UARTs and then the 5th one crapped out and so it gave up right there. I look in /dev and see ttyS0,1,2,3. Problems! :o

Here is how to solve all of them...

Ubuntu Linux 10.10 Installation and Configuration How-To for MCS9865 2- 4- 6-port Serial card, aka Serial controller: NetMos Technology PCI 9865 Multi-I/O Controller

First off:

Ignore all MCS9865 driver disks, downloads, patches and any outdated information on this forum or elsewhere. Do not use them. If you're running Ubuntu 10.10, here's the solution:

Simply pass the kernel this parameter at boot time:

8250.nr_uarts=8 (or however many you think you'll eventually need)

To do this, presumably with GRUB2 as the bootloader, just press 'e' on your chosen Ubuntu kernel when the boot menu comes up. Look for the line beginning 'linux' and append the parameter shown above, like so:

linux /boot/vmlinuz-2.6.35-24-generic-pae root=UUID=6b16062d-20a0-4190-b645-77277d54524f ro 8250.nr_uarts=8

Now press Ctrl + x to boot. If you set the new limit at 8, you'll now have /dev/ttyS0 through ttyS7. Do an ls /dev | grep ttyS to see what you have.

Got more than 4? Got the required amount? With my setup, the motherboard's single UART got ttyS0, the PCI card got enumerated upwards from there.. with a strange duplication in the middle. It is trivial to fix, however. If you have 7 UARTs, then 8250.nr_uarts should be 7. Adjust to suit your own configuration.

At this point, your card is working and you can communicate via the serial ports. If that pleases you, then what follows is optional. However, if you haven't yet considered how you will configure and use these ports, keep reading.

[EDIT: I forgot to mention that if you want this configuration to persist after reboot, you should now take this opportunity to edit one of your menu entries in GRUB. There are many ways to skin the cat - just edit your default entry, or create a new one of your own. To do the latter, you need to edit /etc/grub.d/40_custom (as root, use sudo nano or whatever method you like). The file will be empty unless you have edited it before. You just want to copy, verbatim, your default kernel's menu entry, and simply append the 8250.nr_uarts=8 to the linux line. It should look exactly as it did when you pressed 'e' to edit before booting with ctrl+x. You'll find that entry in /boot/grub/grub.cfg. Do not edit this file! Just read from it. Lastly, run sudo grub-mkconfig to append 40_custom to grub.cfg Okay, got it? Great!]

Okay, so next you'll want to install setserial and gtkterm. There are alternatives, such as the venerable minicom, but I feel it is outdated and much too complicated (sophisticated) for my purpose. YMMV -- use what suits you; this guide uses setserial and gtkterm.

sudo apt-get install setserial gtkterm

Run setserial to see how your ports have been autoconfigured. You want to check that the I/O addresses and IRQs match up. Chances are that the physical layout of your ports bears no resemblance to the logical addresses (/dev/ttyS0, S1, etc). We'll sort that out later in testing.

Compare the output from:

setserial -g /dev/ttyS[0-7]*

and

lspci -v

In lspci's output you need to find your serial card's I/O ports and IRQ(s). Check that everything here shows up in setserial's output. setserial will likely show some other ports and IRQs to do with other UARTs, and indeed there may be duplications. This is irrelevant; you just need to ensure that it sees everything on your multiport card and that the settings are correct. If they are not, then you will need to use setserial to configure the /dev/ttyS* devices accordingly (where is just my convention here, standing in place of any integer...it's nothing more than a placeholder). The ordering does not matter imho as we still don't yet know which I/O port (eg: 0x0800) corresponds to which physical serial port.

Assuming that all 6 of your shiny new serial ports are correctly configured in setserial, either by yourself or, likely, by setserial, automagically, the next thing you want to do is test all of the ports. Find out which ttyS* file points to which port. You can simply do:

gtkterm --port /dev/ttyS0

And then try it out. No communication? Okay, move the cable methodically through the physical ports and see which one will respond. gtkterm defaults to 9600,8N1 no flow control. If that isn't what you need, append the command shown above or just reconfigure in the GUI. Word of warning: gtkterm, for me at least, will only list 4 ttyS* devices. You have to type over the textbox to get /dev/ttyS4 for example -- don't be mislead by the dropdown list! ;)

Alright, so let's say ttyS0 was dead on the first physical port you tried, but on your third try you found the active one. You've just identified one of your physical ports: make a note of that and/or label your cable; it is ttyS0.

Repeat the process. Start gtkterm on ttyS1 and move on through until you see them all. Make a note. Good.

The ttyS* assignments will persist after reboot, so there's nothing more for you to do. Trouble is, if you unplug all of your cables, lose that text document where you noted the ordering down or just end up confused at some point... you've got to do all of this again.

There is of course a smarter way! Run setserial -g as shown before and note the I/O port assignment to each ttyS* file. As it stands now, if ttyS3 is the top left physical port when looking at the back of your machine, and you'd rather it was ttyS0 or ttyS1 (we humans like to count from 1, usually) then all you have to do is make a table:

PHYSICAL PORT 1 I/O ADDRESS 0xce80 (currently assigned to ttyS5, for example)
PHYSICAL PORT 2 I/O ADDRESS 0x0400 (currently assigned to ttyS1, for example)
<etc>

You can use setserial to reconfigure the ttyS* files: give them new addresses, like so:

setserial /dev/ttyS1 port 0xce80
setserial /dev/ttyS2 port 0x0400

That's the basis of the process of re-ordering to suit. Now you don't need to remember much about wiring up, as you'll have probably ordered them from top to bottom and from left to right or some other logical numbering system. I still advise that you note the physical arrangement as it corresponds to I/O address; a different OS or even a kernel upgrade might throw all of this out of whack.

WARNING: Also note that you aren't just shuffling addresses around... the UART type and the IRQ number must also match. I recommend you print or otherwise keep in front of you the original setserial designations and refer back to it to check your progress of reconfiguring.

Alright, so now our ports are up, working, and we know which one is which. Back to gtkterm to do some work with our newly-configured hardware!

I'm not going to explain the operation of gtkterm.. it's pretty simple and well documented. What I am going to explain is my personal reason for wanting 6 serial ports in the first place, and how I wanted to organise my workflow.

Basically, I have 6 pieces of Cisco networking equipment which I want to reconfigure over and over whilst working towards a certification. They require a serial console connection for initial configuration, hence, 6 serial ports. Additionally, I need to verify configs, modify them.. all concurrently. I want 6 gtkterm windows open at once and I want to know which window is connected to which device.

Helpfully, the Cisco kit can be assigned a hostname, whereby the prompt becomes say R3# or SW2#. GtkTerm itself has a status bar which shows which /dev/ttyS* is currently open for reading and writing. However, GtkTerm does NOT place this information in the titlebar, and worse still, in Gnome with the taskbar set to autogroup, I just get 6 identical GtkTerm windows popping up from the group button also called GtkTerm.

This needed sorting out: I want my windows labelled ttyS1, ttyS2, etc. or even R1, R2, etc. Turns out there is a handy utility which can rename the windows for me once they're open. I wrote a script, and as I haven't rebooted yet there's a duplication in my /dev folder in the output shown below, but it's irrelevant to me, especially with my method as detailed in this post. Here's the script, for which you'll also need wmctrl to run (sudo apt-get install wmctrl):

#!/bin/bash
gtkterm --port /dev/ttyS1& sleep 0.3; wmctrl -r GtkTerm -T ttyS1&
gtkterm --port /dev/ttyS2& sleep 0.3; wmctrl -r GtkTerm -T ttyS2&
## ttyS3 omitted due to port assignment being screwy
gtkterm --port /dev/ttyS4& sleep 0.3; wmctrl -r GtkTerm -T ttyS4&
gtkterm --port /dev/ttyS5& sleep 0.3; wmctrl -r GtkTerm -T ttyS5&
gtkterm --port /dev/ttyS6& sleep 0.3; wmctrl -r GtkTerm -T ttyS6&
gtkterm --port /dev/ttyS7& sleep 0.3; wmctrl -r GtkTerm -T ttyS7&

What is happening here is that six instances of gtkterm are being opened up, one after the other, but not all at once, ie: in series, not in parallel. This allows me to use wmctrl to change the name of the window.

Window 1 loads, called GtkTerm, I put the script to sleep for 0.3s to give the window a chance to fully load, and then I call wmctrl to change both the icon name and the titlebar name with the -T option. Window 1 is now called ttyS1, so Window 2 can load as GtkTerm.. enabling wmctrl to find it and rename it. If all 6 instances opened at once, they'd all be called GtkTerm, making it a certainty that the renaming will go awry. Additionally, if the sleep time is less than 0.3, on my system at least, I find that the numbers sometimes get jumbled up, sometimes not. 0.3s is an acceptable delay in startup. If you have a slow machine or it is under heavy load, or you just want absolute certainty that the renaming will go as expected, increase the sleep time. Reduce it at your own risk (you can do testing, but leave some margin of error).

If you don't know what's going on here, just trust in me that it must be done this way.

Bang in your ttyS* numbers, adjust sleep time to suit (for faster or slower computers), and adjust the wmctrl parameter to give the name you require, eg: ttyS1 or R1 or SERIAL_1 or whatever you like. Also note that wmctrl can do nice things like lay your windows out in a certain state or position, eg: maximized or 800px right of your left screen edge, whatever you need.

For my final config I will rename the GtkTerm windows as per the devices they're connected to, and I will maximise them all on my 2nd display. That is what suits me, and you can find what suits you, too. :)

Hope this helps someone, please let me know if it does. I spent a whole day from start to finish, cursing this and Googling that and barking up the wrong tree. The inclusion of manufacturer drivers was the biggest cost in time; they don't work for Ubuntu 10.10 and they're not even required. Take care all. o/

Niall.

scorpionstudios
January 21st, 2011, 10:46 AM
Just an updated script. Works beautifully.

breek
April 1st, 2011, 01:59 AM
that means that one serial port should work out-of-the-box? have you done your tests in 32 or 64 bit ubuntu? a known issue in moschip driver was that it was 32 bit only.
i have a 2 ports MCS9865 but i need only one port (for ups).
i now use ubuntustudio 10.04 but i'll move to 11.04 when released... so this is a good news! thanx ;)

YERON
March 26th, 2012, 01:04 PM
Hello excellent explanation scorpionstudios finally found a real solution but I have a question is that I want to implement this guidance but on another system and the card is recognized by the system but I only recognizes four COM port and I necesto I aver Acknowledge the 6 port if I can lend a hand to bring your guide to PCLinuxOS which is where I impletar this guide to work the 6 ports this is my settings where I put my grub parameters to work in PCLinuxOS (http://ubuntuforums.org/member.php?u=1220843)

timeout 10
color black/cyan yellow/cyan
gfxmenu (hd2,0)/boot/gfxmenu
default 0

title PCLinuxOS-2011
kernel (hd2,0)/boot/vmlinuz BOOT_IMAGE=PCLinuxOS-2011 root=UUID=671ef53c-b3f7-4ef7-941e-8a34a60560f6 quiet nokmsboot vmalloc=256M acpi=on resume=UUID=63589a97-2515-4ea8-85be-72cae6c7a81a splash=silent vga=788
initrd (hd2,0)/boot/initrd.img

title Windows-7
root (hd0,0)
chainloader +1

title 2.6.38.8-pclos3.pae.bfs
kernel (hd2,0)/boot/vmlinuz-2.6.38.8-pclos3.pae.bfs BOOT_IMAGE=2.6.38.8-pclos3.pae.bfs root=UUID=671ef53c-b3f7-4ef7-941e-8a34a60560f6 quiet nokmsboot vmalloc=256M acpi=on resume=UUID=63589a97-2515-4ea8-85be-72cae6c7a81a splash=silent vga=788
initrd (hd2,0)/boot/initrd-2.6.38.8-pclos3.pae.bfs.img

Berenjeno
July 9th, 2012, 05:39 AM
Hi
I have ubuntu 9.10 and have the same problem to add 2 serial port, my problem is I cant enter to the GRUB menu I press "e" but doesn't enter or how I can update to GRUB2 so I can add this 2 serial port.
thanks.

scorpionstudios
July 9th, 2012, 10:59 PM
Further to a host of private messages regarding this post..

To access GRUB at boot-time, press and hold the LEFT SHIFT key during boot. A good time to press and hold this key is just as the BIOS checks are almost completed and just before GRUB will be loaded.

You MUST hold the left shift key UNTIL the GRUB menu appears.

Regarding the placement of the kernel parameter, please review my original post. All the information you need is there.

I hope this helps someone!

Niall

Berenjeno
July 10th, 2012, 05:40 PM
scorpionstudios
finally I enter to GRUB and modify, but know I try to install gtkterm with the comand
sudo apt-get install setserial gtkterm and I get an error:
404 Not Found [IP:91.189.181 80]
Failed to fetch http://pr.archive.ubuntu.com/ubuntu/pool/universe/g/gtkterm/gtkt
erm_0.99.5-1ubuntu3_i386.deb 404 Not Fond [IP: 91.189.92.181 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-mix sing?

Berenjeno
July 11th, 2012, 04:48 PM
scorpionstudios
I add a repository on Synaptic and install the gtkterm 0.99.5-1+b2, but I still having Unknown
/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4
/dev/ttyS1, UART: 16550A, Port: 0x02f8, IRQ: 3
/dev/ttyS2, UART: Unknown, Port: 0x03e8, IRQ: 4
/dev/ttyS3, UART: Unknown, Port: 0x02e8, IRQ: 3