FarSync Drivers

Fixing USB Device names

If you have a number of FarSync Flex USB devices in your system, then you may find that each time the system is restarted, or you unplug them and plug them back in again, the device name for a particular device changes.  There is a way to fix the name to a device serial number to ensure that it always has the same device name.

The following explanation is for the WAN driver, using hdlcX device names, but the same procedure can be followed for the OEM driver, using syncX device names, with appropriate device name changes.

The first step is to determine the device serial numbers.  Use the following command

root@ubuntu64:# more /proc/fsflex 
FarSync Flex WAN Driver version 1.09.02-00
2 Cards found
hdlc0-hdlc0: FarSync Flex-1 (U0010046), 1 ports, State: Running 
hdlc1-hdlc1: FarSync Flex-1 (U0010085), 1 ports, State: Running 
Total number of ports = 2
Total number of async connects = 0
root@ubuntu64:#

For the purposes of this example, let us assuming that the device with serial number U0010046 should be assigned the device name hdcl1 and that the device with serial number U0010085 should be assigned hdlc0.  In other words, the device names should  be fixed to be the opposite of how they are currently  assigned.

We will be using udev rules to perform the device assignment.  In the Linux distro you are using, the udev rules files may be in slightly different place to the example below, and the actual rules file that you will need to edit may also be called by a different name.  The following example was performed on a Debian based system.

There are two sets of device names to change, one set are network devices and these names are of the form hdlcX.  These devices are used to establish WAN connections with the Kernel ppp stack.  The other set of devices are char devices and these names are of the form tty_hdlcX.  These devices are used to establish WAN connections with the Linux pppd application.  The udev rules that are applied need to change both the network and char device names.

Change directory to the udev rules directory.  On most system this is /etc/udev/rules.d

Display the information about the hdlcX devices with the following commands:

root@ubuntu64:/etc/udev/rules.d# udevinfo -a -p /sys/class/net/hdlc0

Udevinfo starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/class/net/hdlc0':
    KERNEL=="hdlc0"
    SUBSYSTEM=="net"
    DRIVER==""
    ATTR{weight}=="0"
    ATTR{tx_queue_len}=="100"
    ATTR{flags}=="0x90"
    ATTR{mtu}=="1500"
    ATTR{operstate}=="down"
    ATTR{broadcast}=="00:00:00:00:00:00:00:00"
    ATTR{address}=="55:30:30:31:30:30:34:36"
    ATTR{link_mode}=="0"
    ATTR{type}=="518"
    ATTR{features}=="0x0"
    ATTR{ifindex}=="11"
    ATTR{iflink}=="11"
    ATTR{addr_len}=="8"

root@ubuntu64:/etc/udev/rules.d# 

Do the same for hdlc1.  Then edit the rules file most appropriate for changing device names.  In Debian based systems this may be 20-names.rules while on Red Hat based systems this might be 50-udev.rules.

Append the following rules entry in the file

KERNEL=="hdlc*", SYSFS{address}=="55:30:30:31:30:30:38:35", NAME="hdlc0"
KERNEL=="hdlc*", SYSFS{address}=="55:30:30:31:30:30:34:36", NAME="hdlc1"
KERNEL=="tty_hdlc*", SYSFS{serial}=="U0010085", NAME="tty_hdlc0"
KERNEL=="tty_hdlc*", SYSFS{serial}=="U0010046", NAME="tty_hdlc1"

Now, unplug the devices and plug them back in again making sure that serial number U0010046 is plugged back in first and check the contents of the /proc/fsflex file.  They should now be

root@ubuntu64:/home/kevinc# more /proc/fsflex 
FarSync Flex WAN Driver version 1.09.02-00
2 Cards found
hdlc0-hdlc0: FarSync Flex-1 (U0010085), 1 ports, State: Running
hdlc1-hdlc1: FarSync Flex-1 (U0010046), 1 ports, State: Running
Total number of ports = 2
Total number of async connects = 0
root@ubuntu64:/home/kevinc#

If you rename the hdlcX and tty_hdlcX devices to be other than hdlc (e.g. flex) then you will have to rename the associated config file names (e.g. ifcfg-hdlc0 to ifcfg-flex0) and the ifup-hdlc and ifdown-hdlc scripts to ifup-flex and ifdown-flex.

If you are the using the OEM driver, then by default the network device names are syncX and the char device names are also syncX, so the above udev rules may be as follows:

KERNEL=="sync*", SYSFS{address}=="55:30:30:31:30:30:38:35", NAME="sync0"
KERNEL=="sync*", SYSFS{address}=="55:30:30:31:30:30:34:36", NAME="sync1"
KERNEL=="sync*", SYSFS{serial}=="U0010085", NAME="sync0"
KERNEL=="sync*", SYSFS{serial}=="U0010046", NAME="sync1"

If you have used device names not of the form syncX but are configuring the devices with your application, then the scripts and config files (ifcfg-syncX, ifup-sync and ifdown-sync) may not need to be changed.  Your application would just open the new devices names.

Copyright © 2001-2010 FarSite Communications Ltd.