NSLU2-Linux
view · edit · print · history

Adding a USB2Serial adaptor in Unslung or OpenSlug

There seems (to me) to be lots of wiki documentation about "tapping in" to the slug's hardware serial port (AddASerialPort), but very little about the "easier option" - using a prebuilt usb to serial adaptor. Who wants to get their hands dirty with a soldering iron?! ;-)

USB adaptors:

For PL2303 chipset based USB to Serial adaptors

I found some references in the Palm page, so I thought I'd seperate out a proper HowTo page.

According to the Palm instructions, it's just a case of:

ipkg install kernel-module-usbserial
ipkg install kernel-module-pl2303
depmod -a
insmod usbserial
insmod pl2303 

If you are running Unslung, create the file /unslung/rc.modules, and give it the following content to automatically install at boot:

 #!/bin/sh
 insmod usbserial
 insmod pl2303
 return 1

Notice: above works for Newlink USB Serial adaptor available from Maplin UK code ZP43.

For OpenSlug, add one line for each module that should be loaded at startup to /etc/modutils/modules and then run update-modules:

echo usbserial >> /etc/modutils/modules
echo pl2303 >> /etc/modutils/modules
update-modules

Special Note about the kernel-module-pl2303 in Unslung.

There appears to be different versions of the pl2303 chip in USB to Serial Adapters. If you find that the dmesg command displays error messages about the pl2303

  (e.g. "pl2303.c: pl2303_read_int_callback - usb_submit_urb failed with result -22")

you should get a new version of the driver pl2303.o.

For information see Message #7954 at http://www.nslu2-linux.org.

  (http://tech.groups.yahoo.com/group/nslu2-linux/message/7954)

The URL referenced in the above message is:

  http://www.fh-furtwangen.de/~dersch/pl2303.o

How to install the driver:

1) get the driver from the above URL (Thank you Mr. Dersch). 
2) find the current driver's location. You can do this using the command:
   find / -name pl2302.o - print
       (on my unslung it is at: /lib/modules/2.4.22-xfs/kernel/drivers/usb/serial/pl2303.o),
3) replace the current adapter at the above location,
4) unplug the USB to Serial Adapter,
5) rmmod pl2303,
6) insmod pl2303,
7) plug adapter back in.

I have found two USB to Serial Adapters with the pl2303 chip that work well with Unslung. These are: USB to Serial (9-pin) DB-9 RS-232 Adapter Cable.

1) Iogear GUC232A -- this one has an LED which lights on data transfer.
2) Sabrent SBT-USC1M. 

(braydw)

For Keyspan based USB to Serial adaptors

For a keyspan USB serial port use these instructions UseKeyspanSerialPorts

For Belkin F5U109 USB to Serial adaptors

dmesg should have reported this as being detected. However, this didn't work for my adaptor (a Belkin F5U109), and some google searching found me this page: http://www.qbik.ch/usb/devices/showdev.php?id=780 which suggested I needed the mct_u232 driver rather than the pl2303 driver. So I tried a quick:

  • ipkg install kernel-module-mct_u232

and it came back with "Cannot find package kernel-module-mct_u232.". I wondered if maybe it had a different name under Unslung, so I did a:

  • ipkg list kernel-module-*

and after looking through the returned list found that the command I wanted was in fact:

  • ipkg install kernel-module-mct-u232

So then after I'd installed the correct driver (and I did "rmmod pl2303; ipkg remove kernel-module-pl2303" for the sake of tidyness), I ran:

  • insmod mct_u232

(confusingly, the module itself still uses an underscore even though the ipkg doesn't!)

  • dmesg

And got the happy output:

 usbserial.c: USB Serial support registered for Magic Control Technology USB-RS232
 usbserial.c: Magic Control Technology USB-RS232 converter detected
 usbserial.c: Magic Control Technology USB-RS232 converter now attached to ttyUSB0 (or usb/tts/0 for devfs)
 mct_u232.c: Magic Control Technology USB-RS232 converter driver v1.1

If you are running Unslung, create the file /unslung/rc.modules, and give it the following content to automatically install at boot:

 #!/bin/sh
 insmod usbserial
 insmod mct_u232
 return 1

For OpenSlug, add one line for each module that should be loaded at startup to /etc/modutils/modules and then run update-modules:

echo usbserial >> /etc/modutils/modules
echo mct_u232 >> /etc/modutils/modules
update-modules

For FTDI chipset based USB to Serial adaptors (http://www.ftdichip.com/)

ipkg install kernel-module-usbserial
ipkg install kernel-module-ftdi-sio
depmod -a
insmod usbserial
insmod ftdi_sio

If you are running Unslung, create the file /unslung/rc.modules, and give it the following content to automatically install at boot:

 #!/bin/sh
 insmod usbserial
 insmod ftdi_sio
 return 1

For OpenSlug, add one line for each module that should be loaded at startup to /etc/modutils/modules and then run update-modules:

echo usbserial >> /etc/modutils/modules
echo ftdi_sio >> /etc/modutils/modules
update-modules

NOTE: If update-modules doesn't work for you, try modules-update

For Genuine Nokia CA-42 USB to Serial adaptors, and some others

The Nokia CA-42 (but not clones thereof), use a chip which supports the usbcdc protocol (standard serial adaptor USB "class"), which the Linux usbserial driver supports, but you may have to manually bind the driver to - check the USB product and vendor codes using the lsusb command, and then issue a command like "insmod usbserial vendor=0x0421 product=0x0802" before inserting the adaptor.

General tips

If you have a Linux PC you can sometimes use it to help answer the question of which module you need; your PC probably has all of the modules available and will auto-detect which to use. So if you plug in your serial cable (or whatever, this applies to most peripherals) and look at dmesg or syslog etc you may well see the name of the kernel module that you need to load on your Slug.

When you buy a USB-serial converter, note that some are much superior to others. Some implement the flow control signals while others don't; some output proper RS232 voltage levels (+/- 5V) while others only swing between 0V and 5V. In my limited experience, physically larger converters are more likely to contain the extra circuitry needed for voltage level shifting, and products based on the FTDI chips are likely to be of higher quality.

Now What?

Atter installing the USB2SERIAL, what can I do with it?

1. TERMINAL

Download minicom, or for a stripped down version picocom.

ipkg install picocom  (eg picocom -b 9600 /dev/ttyUSB0)
ipkg install minicom

getty considerations

I used a USB serial port and ran getty on it, but the serial port was not always plugged in (I sometimes plugged in an Ethernet port instead; there wasn't room on the hub for both). Unfortunately, running getty when the port is not plugged in has two problems, (1) after a while it's polled only every 5 minutes, which means you have to wait when you plug it back in, and (2) sometimes the getty creates a huge amount of wtmp log entries, causing disk writes every 5-10 seconds or so and huge log files (which is especially a problem if you're running on a Flash disk). The solution is to add a level of indirection: in /root/usb-login.sh:

#!/bin/sh
while ! test -e /dev/ttyUSB0; do sleep 10; done
exec /sbin/getty -L ttyUSB0 -h 115200 ansi

then chmod +x /root/usb-login.sh and put in inittab:

T0:23:respawn:/root/usb-login.sh

NOTE: if you need other settings for getty under SlugOS 4.8, type getty to see all the options

view · edit · print · history · Last edited by TimSmall.
Based on work by MarkStinson, Bo, fcarolo, ssb22, Tralala, P Jones, Phil Endecott, Bernard Davison, braydw, hb, and Bullfrog.
Originally by Lurch.
Page last modified on June 16, 2008, at 12:15 PM