There are plenty of perfectly good reasons why one might have
several
Fortunately, there’s a way to use udev to set up unchanging aliases
for those ever-changing device nodes. This is done by setting up a
udev rule for each
Some of the details are here, but just to sew it all together, here’s what you need to do.
- First attach your
FTDI adaptor, making sure all others are unplugged. - ls /dev/ttyUSB*
— only one should be listed. - udevadm info --name=/dev/ttyUSB0 --attribute-walk
— (using the ttyUSB number listed in the previous step) should dump a huge list of attributes - udevadm info --name=/dev/ttyUSB0 --attribute-walk | grep serial
— will list only a few lines, such as the following —SUBSYSTEMS=="usb-serial"
ATTRS{serial}=="XR00U1BU"
ATTRS{serial}=="000000000000"
ATTRS{serial}=="0000:00:1d.7" - The first
ATTRS line is the one we’re interested in. That’s the USB serial number of theFTDI adaptor. (The subsequent lines are the USB serial number of an intermediate hub, and the PCI address of the USB controller.) - Now you need to go and find the udev rules directory: in a
standard udev install, that’s /etc/udev/rules.d. In that
directory, make a file called 99-local.rules (you’ll need to
be root), and add a line like the following (and it must be all on one
line; this blog might show it split) —
KERNEL=="ttyUSB?", ATTRS{serial}=="XR00U1BU", SYMLINK+="ftdiDUINO", MODE="0666"
- (An earlier version of this page suggested the name 10-local.rules, which with modern versions of udev is checked too early in the process; using 99-local.rules makes it work with any version of udev.)
- Obviously the
ATTRS clause must match the one your adaptor listed above. TheSYMLINK clause can be anything (that doesn’t clash with any other device), so name it after the thing it’s plugged into at the other end. - Unplug and replug your
FTDI adaptor. Whatever ttyUSB number it gets, the symlink /dev/ftdiDUINO will be pointing to it. - Oh yes, that udev rule also makes the device node world-writable. So you won’t need to be root to issue
miniterm.py /dev/ftdiDUINO 115200
No comments:
Post a Comment