Assigning an unique name to USB CDC device in /dev

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Wed Mar 5 03:02:32 EST 2014


You need persistent device naming rules in udev.

The udev rules will basically match cretain device attributes you
specify in the rules file and then create device nodes/symlinks for
it. So, first you need to find what those _unique_ attributes are for
your device, and then write it as a udev rule.

See this link for an example on how to do it for usb devices:

http://hintshop.ludvig.co.nz/show/persistent-names-usb-serial-devices/

Thats just one example. I'm sure there are many howtos out there which
explain how to write udev rules.

HTH,
-mandeep




On Wed, Mar 5, 2014 at 12:18 PM, Srinivas Ganji
<srinivasganji.kernel at gmail.com> wrote:
> Dear All,
>
> We have a USB CDC device which we are connecting it to the Ubuntu system.
> Then, we are accessing the device using an application by opening the device
> with /dev/ttyACM0 node. The system may have multiple USB CDC devices already
> connected before connecting my device, sometimes. In such cases, my
> application fails to open the device, because, this time the assigned node
> is other than /dev/ttyAMC0, but in my application the device node is
> /dev/ttyAMC0 only. Due to these reasons, I want to assign my own device node
> in the /dev directory like /dev/mydev. This will enable my application to
> identify my device very easily.
>
> The requirement is same as described in the link -
> http://marc.info/?l=linux-usb&m=130216901901572&w=2
> The answer is available at
> http://marc.info/?l=linux-usb&m=130217684009490&w=2
>
> I have tried in different ways as I have also looked at the following
> sources. But, still, there is NO luck. When I insert another USB CDC device,
> it got /dev/ttyACM0 instead of getting ttyACM1.
> http://www.reactivated.net/writing_udev_rules.html
> https://www.kernel.org/pub/linux/utils/kernel/hotplug/udev/udev.html
> http://unix.stackexchange.com/questions/77476/point-usb-phone-to-specific-dev-ttyacm-using-udev
> https://www.pjrc.com/teensy/49-teensy.rules
>
> The kernel version and distribution details are as follows.
> Kernel Version --- 3.5.0-17-generic
> Distribution details are as follows.
> RELEASE=14
> CODENAME=nadia
> EDITION="MATE 64-bit"
> DESCRIPTION="Linux Mint 14 Nadia"
>
> I have created a file, named 11-ttyACM.rules, under /etc/udev/rules.d
> directory. The contents of the file as follows.
> KERNEL=="ttyAMC0", SUBSYSTEM=="tty", ATTRS{serial}=="__0X00124B000148CC78",
> SYMLINK+="mydev"
>
> I got the above information from the following command
> udevadm info -q all -n /dev/ttyACM0 --attribute-walk
>
> This is what I did. But, no luck. If I insert a different serial numbered
> device, then it is assigning ttyACM0 to that device. But, after this udev
> rule, it should not assign, I think.
>
> Please someone, who already used/knows udev rules, suggest me.
>
> Thanks.
>
> Regards,
> Srinivas.
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>



More information about the Kernelnewbies mailing list