ascii image


0010101000011111101001101010000010011000
1110101110110101011011111010010010001011
0001011100011101111001010011010010111110
0000010111101001100000110011101100001000
0011000000111010001111111000100110000001
1010110110000000000001011001000110001010
0101100010101100000100000010100100010101
0001011001011101100011000101110111101110
0110010100110100111101110100110011111101
0010111100110011010010110010101111011011
0100000000001001001011000010110100101001
1101000111100000110111011100110111000010
1111110001111111101101001010000111101100
0010110000100000111011000000101100010110
0101111000011100111010000000011111101111
0010010011110010011101001000110101000101
0000000001000100001111111100111010001111

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...

[email protected]:~# 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

CONFIG_SERIAL_8250_NR_UARTS=48
CONFIG_SERIAL_8250_RUNTIME_UARTS=4

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 http://www.outer-place.com/  (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  https://bugs.launchpad.net/debian/+source/setserial/+bug/46994 ***
*** 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

3 comments: