ascii image


Friday 31 December 2010

Adding a 4 port RS232 serial pci card to ubuntu

I bought a 4 port RS232 serial card for my box, the supplier said it was Linux supported.
Though as you can see before it wasn't that clear cut, some fiddling was needed - pretty much like how most devices needed setting in the old Linux days...  before user friendly linux distros.
It said it has Sun1040 chips???  Does that mean anything to anyone?  LOL  As you can see below Linux thinks it is "LSI Logic / Symbios Logic" so not Sun 1040...

Look for the card...

root@ubuntu:~# lspci

05:06.0 Communication controller: Device 5372:6873 (rev 01)
Check the IRQ and port addresses

# lspci -vv -d  5372:6873
05:06.0 Communication controller: Device 5372:6873 (rev 01)
        Subsystem: LSI Logic / Symbios Logic Device 0004
        Control: I/O+ Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
        Status: Cap- 66MHz- UDF- FastB2B- ParErr- DEVSEL=slow >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Interrupt: pin A routed to IRQ 255
        Region 0: I/O ports at 9000 [size=8]
        Region 1: I/O ports at 9400 [size=8]
        Region 2: I/O ports at 9800 [size=8]
        Region 3: I/O ports at 9c00 [size=8]
        Region 4: I/O ports at a000 [size=8]
        Region 5: I/O ports at a400 [size=16]
'I/O+' means it is enabled in the PCI bus.
See what kernel options are set for the serial ports

# grep SERIAL /boot/config-2.6.35-23-server | grep -v USB


4 devices created at boot time (RUNTIME), so increase this by editing grub

vim /etc/default/grub

Make sure we have enough serial ports created by the kernel 8250.nr_uarts=X

GRUB_CMDLINE_LINUX_DEFAULT="quiet 8250.nr_uarts=5"

I rebooted here so the OS created some more devices in /dev/ttySx

The next bit based on  (thanks) :)

*** MOST IMPORTANT enable PCI serial device - wot a crock

echo -n "5372 6872" > /sys/bus/pci/drivers/serial/new_id

i'm not happy with irq=0, but the pci output shows irq=255, 'INTx-' might mean it doesnt use IRQs

Physical positioning on the back of my computer

# top right - ymmv
setserial /dev/ttyS1 port 0x9000 uart 16550A irq 0

# top left
setserial /dev/ttyS2 port 0x9400 uart 16550A irq 0

# bottom left
setserial /dev/ttyS3 port 0x9800 uart 16550A irq 0

# bottom right - wouldn't set by hand so used parameter
# set from setserial -G /dev/ttyS3 to get it to work
# change port and dev obviously, maybe port and uart are
# wrong way around
setserial /dev/ttyS4 port 0x9c00 uart 16550A irq 0

Use setserial -G to get a full working parameter set

$ setserial -g -G /dev/ttyS*
/dev/ttyS0 uart 16550A port 0x03f8 irq 4 baud_base 115200 spd_normal skip_test
/dev/ttyS1 uart 16550A port 0x9000 irq 0 baud_base 115200 spd_normal skip_test auto_irq
/dev/ttyS2 uart 16550A port 0x9400 irq 0 baud_base 115200 spd_normal skip_test auto_irq
/dev/ttyS3 uart 16550A port 0x9800 irq 0 baud_base 115200 spd_normal skip_test auto_irq
/dev/ttyS4 uart 16550A port 0x9c00 irq 0 baud_base 115200 spd_normal skip_test auto_irq

Then save setup with

dpkg-reconfigure setserial

select >> "autosave once"

*** BUG ***
*** doesnt work , so copy in the setserial -g -G /dev/ttyS* output by hand ***

vi /var/lib/setserial/autoserial.conf

Make sure pci device is initailsed at startup

vi /etc/init.d/setserial

Find the start function, and add

 ## add in 4 port serial device
echo -n "5372 6872" > /sys/bus/pci/drivers/serial/new_id
 ## done add 4 port serial device

Reboot and check

# setserial -g /dev/ttyS*
/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4
/dev/ttyS1, UART: 16550A, Port: 0x9000, IRQ: 0
/dev/ttyS2, UART: 16550A, Port: 0x9400, IRQ: 0
/dev/ttyS3, UART: 16550A, Port: 0x9800, IRQ: 0
/dev/ttyS4, UART: 16550A, Port: 0x9c00, IRQ: 0

Check #2

# cat /proc/tty/driver/serial
serinfo:1.0 driver revision:
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0 CTS|DSR
1: uart:16550A port:00009000 irq:0 tx:11 rx:5 RTS|DTR
2: uart:16550A port:00009400 irq:0 tx:0 rx:0
3: uart:16550A port:00009800 irq:0 tx:16 rx:5 RTS|DTR
4: uart:16550A port:00009C00 irq:0 tx:13 rx:4 RTS|DTR

Check #3

Join pins 2 &3 together on ports - minicom to test - turn off flow-control else no text seen

minicom -o -D /dev/ttyS1