Right now, on linux, at every reboot of the host pc the order in which serveral boards map themselves to the various ttyUSB ports is mostly random.
There is though, in this early stage, the need to know which board ended up on each ttyUSB port.
I've found that, on my ubuntu 12.04 server, there are symlinks inside /dev/serial/by-id/ which map every board/port using their serial number to their respective ttyUSBnn port.
So, having several boards, all that is needed is plug them one by one and issue a
sudo lsusb -v | grep iSerial
to know the serial number of each one.
Knowing, for example, that board 62-0134 has serial number FTVJ59WC, a simple
should show something like
lrwxrwxrwx 1 root root 13 Aug 9 21:50 usb-FTDI_Cairnsmore1_FTVJ59WC-if00-port0 -> ../../ttyUSB4
lrwxrwxrwx 1 root root 13 Aug 9 21:50 usb-FTDI_Cairnsmore1_FTVJ59WC-if01-port0 -> ../../ttyUSB5
lrwxrwxrwx 1 root root 13 Aug 9 21:50 usb-FTDI_Cairnsmore1_FTVJ59WC-if02-port0 -> ../../ttyUSB6
lrwxrwxrwx 1 root root 13 Aug 9 21:50 usb-FTDI_Cairnsmore1_FTVJ59WC-if03-port0 -> ../../ttyUSB7
From which we know that board FTVJ59WC if02/if03 are the serial ports ttyUSB6/7.
Cgminer names the various ICA nn using the same order in which they are listed using the -S parameters, so if I have a command line like
./cgminer -S ... -S ... -S /dev/ttyUSB6 -S /dev/ttyUSB7 ...
I'm now able to say that my ICA 2 and ICA 3 are my board with serial number 134 written ontop.
Maybe this was clear to everybody here but me
Anyway, this is just half of what we can do.
On ubuntu there is a rule inside /lib/udev/rules.d which is named 60-persistent-serial.rules which is the rule set creating those symlinks inside /dev/serial/by-id/.
I've copied it inside /etc/udev/rules.d as 99-cairnsmore-links.rules and I've modified it to create more meaningful links inside /dev
ACTION=="remove", GOTO="persistent_serial_end"
SUBSYSTEM!="tty", GOTO="persistent_serial_end"
KERNEL!="ttyUSB[0-9]*|ttyACM[0-9]*", GOTO="persistent_serial_end"
SUBSYSTEMS=="usb-serial", ENV{.ID_PORT}="$attr{port_number}"
IMPORT{builtin}="usb_id"
ENV{ID_SERIAL}=="", GOTO="persistent_serial_end"
SUBSYSTEMS=="usb", ENV{ID_USB_INTERFACE_NUM}="$attr{bInterfaceNumber}"
ENV{ID_USB_INTERFACE_NUM}=="", GOTO="persistent_serial_end"
ATTRS{serial}=="FTVJ59WC", SYMLINK+="cm-62-0134-if$env{ID_USB_INTERFACE_NUM}"
ATTRS{serial}=="FTVJ5AGN", SYMLINK+="cm-62-0135-if$env{ID_USB_INTERFACE_NUM}"
ATTRS{serial}=="FTVJ88QX", SYMLINK+="cm-62-0136-if$env{ID_USB_INTERFACE_NUM}"
ATTRS{serial}=="FTVJ88VS", SYMLINK+="cm-62-0137-if$env{ID_USB_INTERFACE_NUM}"
# ... and so on for every board ...
LABEL="persistent_serial_end"
With these rules I have now
$ ls -l /dev/cm*
lrwxrwxrwx 1 root root 7 Aug 9 21:50 /dev/cm-62-0134-if00 -> ttyUSB4
lrwxrwxrwx 1 root root 7 Aug 9 21:50 /dev/cm-62-0134-if01 -> ttyUSB5
lrwxrwxrwx 1 root root 7 Aug 9 21:50 /dev/cm-62-0134-if02 -> ttyUSB6
lrwxrwxrwx 1 root root 7 Aug 9 21:50 /dev/cm-62-0134-if03 -> ttyUSB7
lrwxrwxrwx 1 root root 8 Aug 8 21:51 /dev/cm-62-0136-if00 -> ttyUSB24
lrwxrwxrwx 1 root root 8 Aug 8 21:51 /dev/cm-62-0136-if01 -> ttyUSB25
lrwxrwxrwx 1 root root 8 Aug 8 21:51 /dev/cm-62-0136-if02 -> ttyUSB26
lrwxrwxrwx 1 root root 8 Aug 8 21:51 /dev/cm-62-0136-if03 -> ttyUSB27
lrwxrwxrwx 1 root root 8 Aug 8 22:11 /dev/cm-62-0137-if00 -> ttyUSB28
lrwxrwxrwx 1 root root 8 Aug 8 22:11 /dev/cm-62-0137-if01 -> ttyUSB29
lrwxrwxrwx 1 root root 8 Aug 8 22:11 /dev/cm-62-0137-if02 -> ttyUSB30
lrwxrwxrwx 1 root root 8 Aug 8 22:11 /dev/cm-62-0137-if03 -> ttyUSB31
Which are valid links that I can use when I start cgminer instead of the ever changing ttyUSBnn ports.
cgminer -S /dev/cm-62-0134-if02 -S /dev/cm-62-0134-if03 -S ...
Calling cgminer like this gives me the assurance that ICA 0 will always be port 2 of board 62-0134 and ICA 1 port 3.
ICA names/numbers do not depend anymore on the order in which my host PC sees the boards and/or the usb port to which I plug them.
I hope this helps
spiccioli