NSLU2-Linux
view · edit · print · history

Keyspan USB -> serial port adapters are easy to find commercially.

However, unslung doesn't have a driver. Until now.

I found the sources, but it took mwester, who had the kernel build environment, to get one built. Many thanks!

Until it makes it into the standard builds (I hope), here is a startup script that will add it to an unslung system & install the kernel modules at startup. Just copy it to /opt/etc/init.d/S11KeyspanDriver, and don't forget to chmod +x /opt/etc/init.d/S11KeyspanDriver

You can run it by hand, or simply reboot.

The script is setup to download just once -- this is to be courteous to mwester and his ISP.

If you want to inhibit startup without uninstalling the kit, simply touch /opt/keyspan/.noserial

The devices are /dev/ttyUSB{0-n}

/opt/etc/init.d/S11KeyspanDriver

 

#!/bin/sh
#
# Start the Keyspan Serial Port Driver
#

# Create the kit directory if required

if [ ! -d /opt/keyspan ]; then
    mkdir /opt/keyspan
fi

# Check to see if startup is inhibited.  Exit silently if so.

if [ -e /opt/keyspan/.noserial ]; then
    exit
fi

# Don't disturb running drivers unless function is "reload"

if [ "$1" != 'reload' ]; then
    if [ "`/sbin/lsmod | grep 'keyspan' | \
 sed  -e'N;s/[0-9]*//g;s/[ \n]*/ /g'`" = ' keyspan (unused) usbserial [keyspan] ' ]; then
        echo "Keyspan: already loaded"
        exit
    fi
fi

# Download drivers if needed.  Only do this once.
# .downloaded is used to allow common image NSLU2 kits

if [ ! -e /opt/keyspan/.downloaded ]; then
    echo "Keyspan: drivers not installed, downloading..."
    if wget -q http://users.dls.net/~mwester/unslung/keyspan.o -O/opt/keyspan/keyspan.o && \
       wget -q http://users.dls.net/~mwester/unslung/usbserial.o -O/opt/keyspan/usbserial.o ; then
        touch /opt/keyspan/.downloaded
    fi
fi

# Make sure both modules are present

if [ ! -e /opt/keyspan/keyspan.o ]; then
    echo "Keyspan: kit not installed"
    exit
fi
if [ ! -e /opt/keyspan/usbserial.o ]; then
    echo "Keyspan: kit not installed"
    exit
fi

# Identify the active kernel module library

KLIB="/lib/modules/`cat /proc/sys/kernel/osrelease`/kernel/drivers/usb/serial"

# Unload the distributed usbserial (it's missing a couple of routines)

if [ "`/sbin/lsmod | grep keyspan`" != '' ]; then
    echo "Keyspan: unloading Keyspan port driver"
    /sbin/rmmod keyspan
fi
if [ "`/sbin/lsmod | grep usbserial`" != '' ]; then
    echo "Keyspan: unloading USB serial port class driver"
    /sbin/rmmod usbserial
fi

# Backup the distributed version, just in case

if [ ! -e $KLIB/usbserial-v55.o ]; then
    echo "Keyspan: backing-up standard usbserial as usbserial-v55"
    mv $KLIB/usbserial.o $KLIB/usbserial-v55.o
fi

# Install the new drivers

echo "Keyspan: loading drivers"
cp /opt/keyspan/usbserial.o $KLIB/
cp /opt/keyspan/keyspan.o $KLIB/

insmod usbserial
insmod keyspan

# The serial ports appear as /dev/ttyUSB{0-n}

#EOF

Keyspan provide Linux drivers(approve sites) on their website(approve sites).

Notice: the above links to http://www.keyspan.com/support/linux/ are no longer working as of November 26th, 2006.

Enjoy.

--tlhackque

view · edit · print · history · Last edited by fcarolo.
Based on work by tman and tlhackque.
Originally by tlhackque.
Page last modified on November 26, 2006, at 03:10 PM