Two USB serial adapters get different /dev/ttyUSBn names after reboot

Bug #107208 reported by Stephen Irons
24
This bug affects 2 people
Affects Status Importance Assigned to Milestone
udev (Ubuntu)
Won't Fix
Undecided
Unassigned

Bug Description

I have a laptop with four USB ports. Into one of these ports is plugged a no-name USB widget with 2 more USB ports, a serial port and a parallel port; I guess there is a USB hub in there also. Into one of these new USB ports, I plug a BAFO USB-serial adapter, so there are two USB serial ports.

When I start the computer, these two serial ports are assigned to /dev/ttyUSB0 and /dev/ttyUSB1 randomly.

I have a modem connected to one of the adapters. Every time I restart, it is a hit-and-miss whether I can connect to the internet without changing a configuration file to point to the other /dev/ttyUSB port.

Windows manages to assign the same com port number to the same USB serial device. How do I make Ubuntu do the same?

Edgy 2.6.17-11-generic, all up to date recently.

viper:~$ lsusb
Bus 005 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 004 Device 009: ID 0403:6001 Future Technology Devices International, Ltd 8-bit FIFO
Bus 004 Device 008: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 004 Device 003: ID 413c:8103 Dell Computer Corp. Wireless 350 Bluetooth
Bus 004 Device 007: ID 067b:2305 Prolific Technology, Inc. PL2305 Parallel Port
Bus 004 Device 002: ID 03eb:3301 Atmel Corp. at43301 4-port Hub
Bus 004 Device 004: ID 04fc:0005 Sunplus Technology Co., Ltd
Bus 004 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000
viper:~$

Revision history for this message
ivanxx (ivan-vyb) wrote :

This is not a kernel issue, this is a by default behaviour:

You can/should use udev to force your kernel assign arbitrary names to devices as it finds them.
Take a look at my file /etc/udev/rules.d/50-local.rules:

# REGLAS PARA LOS DISPOSITIVOS QUE QUEREMOS CONTROLAR POR NOMBRE
BUS=="usb", SYSFS{manufacturer}=="Prolific Technology Inc.", SYSFS{product}=="USB-Serial Controller",KERNEL=="ttyUSB[0123]", SYMLINK+="misterhouse"
BUS=="usb", SYSFS{manufacturer}=="FTDI", KERNEL=="ttyUSB[0123]", SYMLINK+="wmr918"

You must find unique SYSFS strings to each of your devices and SYMLINK an arbitrary name to it (this are my serial to USB adapters for serial misterhouse home control software and a WMR918 weather Station with serial output). Take a look at udev's HOWTOs all over the net, they're quite useful.

Hope this helps!

Revision history for this message
Stephen Irons (stephen-irons) wrote :
Download full text (3.9 KiB)

Thanks for the reply.I have read various HowTos and will try them out shortly.

However, this is only a partial solution. It depends on having USB-serial adapters from different manufacturers. At work, I have FOUR USB-serial adapters, all made by Bafo, connected to the following devices:

* a development project, talking to Uboot or a Linux console
* a development project, talking some variant of gdb to a low-level debug server
* a Tektronix oscilloscope, for getting screenshots
* a GPS receiver

Looking at the manufacturer alone does not work here: I would have to look at a serial number. However, the output of udevinfo -a -p /class/tty/ttyUSB0 does not give a serial number. There is no evidence of a serial number from lsusb -v, or in syslog.

Questions:
1. Does the PL2303 device include a serial number? The PL2303 chip supports an EEPROM, but who knows whether BAFO included one in their product.
2. Who is responsible for reading the USB serial number: the USB subsystem in general, the USB class driver, or the PL2303 driver?
3. udevinfo -a -p /class/tty/ttyUSB0 does not give a serial number

I can accept that this is not a bug in the kernel. If the USB serial-class specification does not MANDATE a serial number, then there is a bug in the specification, and there is no general solution. If the USB serial-class driver does not read the serial number, then there is a problem at that level. If the PL2303 driver does not read the serial number, then there is a problem with the PL2303 driver. If the Bafo serial adapter does not include a serial number, then I will buy a serial adapter that does (does anybody know of one?)

However, there is still a bug in Ubuntu at a user-interface level. A normal user does not want to go writing udev rules to ensure that the modem is always named /dev/modem, the weather-station is /dev/weather-station, and the GPS unit is /dev/gps. I would like to see a GUI of some sort that displays a list of all 'connectable' ports (serial ports, USB serial ports, parallel ports, etc) along with sufficient data to identify them uniquely (including serial number), and allow the user to specify an application-level device such as /dev/modem, and create the appropriate udev rule. Or perhaps he will paint each USB serial adapter a different colour, then create devices such as /dev/ttyUSB-blue and /dev/ttyUSB-red, using the serial number provided by the GUI. He can then create further links like this

/dev/gps -> /dev/ttyUSB-blue -> /dev/ttyUSB0, where the first
/dev/wx -> /dev/ttyUSB-red -> /dev/ttyUSB1

This should probably be a new specification not a bug report.

Here is partial output of lsusb -v, showing that there is no serial number. Perhaps this should be a separate bug report.

Bus 004 Device 002: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Device Descriptor:
  bLength 18
  bDescriptorType 1
  bcdUSB 1.10
  bDeviceClass 0 (Defined at Interface level)
  bDeviceSubClass 0
  bDeviceProtocol 0
  bMaxPacketSize0 8
  idVendor 0x067b Prolific Technology, Inc.
  idProduct 0x2303 PL2303 Serial Port
  bcdDevice 2.02...

Read more...

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. You reported this bug a while ago and there hasn't been any activity in it recently. We were wondering is this still an issue for you? Can you try with latest Ubuntu release?

Feel free to submit any future bugs you may find. Thanks in advance.

Revision history for this message
jpka (jopka) wrote :

Thanks to all people who write and debug Ubuntu!

I have same problem: ttyUSB* names assigns randomly when I replug devices.
All devices guaranteed to have S/N (it may be seen in Windows).
Ubuntu command-line tools not discover this.
I use last Ubuntu with all updates. I use 'apt-get remove brltty' to properly function of FTDI USB chips.
If only one device attached, it work fine via ttyUSB0.

The
 '...a GUI of some sort that displays a list of all 'connectable' ports (serial ports, USB serial ports, parallel ports, etc) along with sufficient data to identify them uniquely (including serial number), and allow the user to specify an application-level device such as /dev/modem, and create the appropriate udev rule. ...'
 is a great idea!

Do Ubuntu authors plan to do this?

Revision history for this message
Lex Ross (lross) wrote :

My USB serial adapter does not create /dev/ttyUSBn device at all!
See Bug #251952
https://bugs.launchpad.net/ubuntu/+source/udev/+bug/251952

Revision history for this message
Tormod Volden (tormodvolden) wrote :

I think this is the same in Intrepid (no way to distinguish two adapters of the same brand). I will check.

Changed in udev:
assignee: nobody → tormodvolden
status: Invalid → Incomplete
Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

And this is still a Won't Fix.

Changed in udev:
assignee: tormodvolden → nobody
status: Incomplete → Won't Fix
Revision history for this message
R. C. Pao (rcpao) wrote :

'lsusb -v' will show a unique serial number (iSerial) for each device. I have three SIIG USB Serial adapters.

Bus 002 Device 004: ID 0b39:0421 Omnidirectional Control Technology, Inc.
Device Descriptor:
  bLength 18
  bDescriptorType 1
  bcdUSB 1.10
  bDeviceClass 0 (Defined at Interface level)
  bDeviceSubClass 0
  bDeviceProtocol 0
  bMaxPacketSize0 8
  idVendor 0x0b39 Omnidirectional Control Technology, Inc.
  idProduct 0x0421
  bcdDevice 2.00
  iManufacturer 1 Generic
  iProduct 2 USB to Serial Converter
  iSerial 3 OCBAKZ7N
...
Bus 002 Device 003: ID 0b39:0421 Omnidirectional Control Technology, Inc.
Device Descriptor:
  bLength 18
  bDescriptorType 1
  bcdUSB 1.10
  bDeviceClass 0 (Defined at Interface level)
  bDeviceSubClass 0
  bDeviceProtocol 0
  bMaxPacketSize0 8
  idVendor 0x0b39 Omnidirectional Control Technology, Inc.
  idProduct 0x0421
  bcdDevice 2.00
  iManufacturer 1 Generic
  iProduct 2 USB to Serial converter
  iSerial 3 OCBQH84W
...
Bus 001 Device 008: ID 0b39:0421 Omnidirectional Control Technology, Inc.
Device Descriptor:
  bLength 18
  bDescriptorType 1
  bcdUSB 1.10
  bDeviceClass 0 (Defined at Interface level)
  bDeviceSubClass 0
  bDeviceProtocol 0
  bMaxPacketSize0 8
  idVendor 0x0b39 Omnidirectional Control Technology, Inc.
  idProduct 0x0421
  bcdDevice 2.00
  iManufacturer 1 Generic
  iProduct 2 USB to Serial Converter
  iSerial 3 OCBPJ9HM

Currently, after a reboot, only one will be assigned ttyUSB0, the other two will not be assigned anything. I have to manually unplug all three, then plug them using the order I want from 0 to 2.

I can live with either a method to fix ttyUSB# to either the iSerial (preferred) and/or the Bus+Device number.

Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote : Re: [Bug 107208] Re: Two USB serial adapters get different /dev/ttyUSBn names after reboot

On Tue, 2008-09-23 at 19:24 +0000, Roger C. Pao wrote:

> 'lsusb -v' will show a unique serial number (iSerial) for each device.
> I have three SIIG USB Serial adapters.
>
*snip*
> iSerial 3 OCBAKZ7N
> iSerial 3 OCBQH84W
> iSerial 3 OCBPJ9HM
*snip*

> I can live with either a method to fix ttyUSB# to either the iSerial
> (preferred) and/or the Bus+Device number.
>
Both are entirely possible, you simply need to add your own udev rules.
I suggest a name like /etc/udev/rules.d/50-serial-devices.rules

The iSerial rule would look like:

SUBSYSTEM=="tty", ATTRS{iSerial}=="OCBAKZ7N", SYMLINK+="mytty0"
SUBSYSTEM=="tty", ATTRS{iSerial}=="OCBQH84W", SYMLINK+="mytty1"
SUBSYSTEM=="tty", ATTRS{iSerial}=="OCBPJ9HM", SYMLINK+="mytty2"

I suggest using a symlink to a personally unique name, rather than
renaming the tty devices, as this avoids any race condition with two
swapping devices.

You'll then end up with /dev/mytty0..2 which point as whatever ttyUSB
number each has been assigned.

> Currently, after a reboot, only one will be assigned ttyUSB0, the other
> two will not be assigned anything.
>
That the others will not be assigned anything surprises me, is this with
no attempt at renaming via rules? Could you run "udevinfo -a -p" on
each of the sysfs paths you looked at?

> I have to manually unplug all three,
> then plug them using the order I want from 0 to 2.
>
The fact this works is contradictory to your statement that only one
device is ever assigned a name.

Scott
--
Scott James Remnant
<email address hidden>

Revision history for this message
R. C. Pao (rcpao) wrote :

Before touching /etc/udev/rules.d, only one USB Serial adapter would be assigned ttyUSB0. The others would not be mapped in.

After adding the udev rules below, they are now working as expected, but the computer required a power cycle or the USB Serial adapters required being unplugged and replugged back in before they would communicate with their serial devices.

The following was helpful.
http://www.reactivated.net/writing_udev_rules.html#udevinfo

Thank you for the help.

# /etc/udev/rules.d/50-local.rules

# /dev/ttyUSB0
SUBSYSTEMS=="usb", ATTRS{manufacturer}=="Generic", ATTRS{product}=="USB to Serial Converter", ATTRS{serial}=="OCBPJ9HM", KERNEL=="ttyUSB[0123]", SYMLINK+="powercom"

# /dev/ttyUSB1
SUBSYSTEMS=="usb", ATTRS{manufacturer}=="Generic", ATTRS{product}=="USB to Serial Converter", ATTRS{serial}=="OCBAKZ7N", KERNEL=="ttyUSB[0123]", SYMLINK+="smartups", MODE="0660", GROUP="nut"

# /dev/ttyUSB2
SUBSYSTEMS=="usb", ATTRS{manufacturer}=="Generic", ATTRS{product}=="USB to Serial converter", ATTRS{serial}=="OCBQH84W", KERNEL=="ttyUSB[0123]", SYMLINK+="usrobotics"

Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

Could you attach /var/log/udev and /var/log/dmesg for a boot where they are not mapped in correctly?

Revision history for this message
R. C. Pao (rcpao) wrote :
Revision history for this message
R. C. Pao (rcpao) wrote :

The three USB Serial adapters are plugged in, but only two are detected.

The previous attachement is /var/log/udev.

Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

Could you also provide "lsusb" output

Revision history for this message
R. C. Pao (rcpao) wrote :

Sorry, those two logs are from the wrong system.

Is it possible to attach more than one file at a time?

Revision history for this message
R. C. Pao (rcpao) wrote :
Revision history for this message
R. C. Pao (rcpao) wrote :
Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

The rules appear to be working.

However as you note, at least one of the devices doesn't get a name at all -- this isn't a udev bug, but a kernel bug for not detecting it (most likely the ftdi_sio driver).

Could you open a new bug against "linux" saying that a USB serial adapter is not being detected properly, you will want to include the same three files in that report.

Revision history for this message
Tormod Volden (tormodvolden) wrote :

I have tested another pl2303 based device (like in the original report) and there is no serial number. This is maybe a bug in the driver, at least if Windows is able to extract a serial number. Or does Windows use some USB port id? Stephan, does Windows recognize each converter correctly if you swap USB ports?

Revision history for this message
Tormod Volden (tormodvolden) wrote :
Revision history for this message
9H1LO (stanley-9h1lo) wrote :

I currently have 10 USB to serial adaptors all using PL2303 chip

Ubuntu detects them OK and assigns ttyUSBx numbers at it's choice on bootup

This machine is rarely rebooted but I need it to assign fixed tty number per device just incase a reboot/power fail happens and also if a device is unplugged / plugged

I understand this is to be done with udev rules....the thing is I cannot identify between one and the other as iserial are al the same .... here are 2 of them:

root@cs:~# udevadm info --attribute-walk -p /class/tty/ttyUSB0 |grep serial
    SUBSYSTEMS=="usb-serial"
    ATTRS{serial}=="0000:01:00.0"
root@cs:~# udevadm info --attribute-walk -p /class/tty/ttyUSB1 |grep serial
    SUBSYSTEMS=="usb-serial"
    ATTRS{serial}=="0000:01:00.0"

was this issue ever sorted or maybe there is a workaround?

Revision history for this message
jpka (jopka) wrote :

The devices itself, if it cheap, may not have S/N due to EEPROM not soldered (or so)... You can check this under Windows, and, imho, if re-plugging to different ports under Windows gives you same COMxx port per device, then maybe problem in linux (kernel)... For my FT232BM's, all good in Windows, but no s/n under linux... :(

Revision history for this message
9H1LO (stanley-9h1lo) wrote : Re: [Bug 107208] Re: Two USB serial adapters get different /dev/ttyUSBn names after reboot

I have some FTDI based FT232's and have the same issues with no s/n

I don't know what to do at this stage

maybe someone can confirm a device which works ok with s/n detected in udev?

2008/11/11 jpka <email address hidden>

> The devices itself, if it cheap, may not have S/N due to EEPROM not
> soldered (or so)... You can check this under Windows, and, imho, if re-
> plugging to different ports under Windows gives you same COMxx port per
> device, then maybe problem in linux (kernel)... For my FT232BM's, all
> good in Windows, but no s/n under linux... :(
>
> --
> Two USB serial adapters get different /dev/ttyUSBn names after reboot
> https://bugs.launchpad.net/bugs/107208
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in "udev" source package in Ubuntu: Won't Fix
>
> Bug description:
> I have a laptop with four USB ports. Into one of these ports is plugged a
> no-name USB widget with 2 more USB ports, a serial port and a parallel port;
> I guess there is a USB hub in there also. Into one of these new USB ports, I
> plug a BAFO USB-serial adapter, so there are two USB serial ports.
>
> When I start the computer, these two serial ports are assigned to
> /dev/ttyUSB0 and /dev/ttyUSB1 randomly.
>
> I have a modem connected to one of the adapters. Every time I restart, it
> is a hit-and-miss whether I can connect to the internet without changing a
> configuration file to point to the other /dev/ttyUSB port.
>
> Windows manages to assign the same com port number to the same USB serial
> device. How do I make Ubuntu do the same?
>
> Edgy 2.6.17-11-generic, all up to date recently.
>
> viper:~$ lsusb
> Bus 005 Device 001: ID 0000:0000
> Bus 002 Device 001: ID 0000:0000
> Bus 003 Device 001: ID 0000:0000
> Bus 004 Device 009: ID 0403:6001 Future Technology Devices International,
> Ltd 8-bit FIFO
> Bus 004 Device 008: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial
> Port
> Bus 004 Device 003: ID 413c:8103 Dell Computer Corp. Wireless 350 Bluetooth
> Bus 004 Device 007: ID 067b:2305 Prolific Technology, Inc. PL2305 Parallel
> Port
> Bus 004 Device 002: ID 03eb:3301 Atmel Corp. at43301 4-port Hub
> Bus 004 Device 004: ID 04fc:0005 Sunplus Technology Co., Ltd
> Bus 004 Device 001: ID 0000:0000
> Bus 001 Device 001: ID 0000:0000
> viper:~$
>

Revision history for this message
Stephen Irons (stephen-irons) wrote :

Original poster: The only real solution is to find a USB serial adapter that includes a serial number: I bought some from Dontronics in Australia.

There is no real way to tell from the sales brochures, though. I was just lucky. Spending more money is no guarantee, but it makes it more likely that you will get one with a serial number.

Failing that, it MIGHT be possible to use sysfs path, which will start something like:
/sys/devices/pci0000:00/0000:00:1d.3/usb4/4-1/4-1:1.0

This then distinguishes otherwise identical devices by WHERE they are plugged in. This can lead to interesting problems if you unplug (eg) your telescope USB adaptor and plug your oscilloscope USB adaptor back into that hole. So this is not really a solution.

I do not know how stable the sysfs path is between reboots. Does the kernel always find USB interface controllers, hubs and ports in the same order?

Another alternative is to use only one device from each of many different manufacturers. The problem here is that they usually use the same internals, so while they look different and come in different packaging, they are all identical internally.

The kernel provides the mechanism to assign fixed /dev/ttyUSBx numbers, provided that there is some way to distinguish between identical devices.

There is no UI to configure the udev rules and give meaningful names to particular ones. That might be nice, but is not relevant to udev.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.