Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Writing Udev Rule for USBtiny Programmer [Solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
jesse_m
n00b
n00b


Joined: 14 Mar 2018
Posts: 21
Location: Grand Rapids, MI

PostPosted: Sat Feb 29, 2020 6:11 pm    Post subject: Writing Udev Rule for USBtiny Programmer [Solved] Reply with quote

I am trying to write a udev rule for my USBtiny based AVR programmer. On other non-Gentoo systems usb device will show up at "/dev/ttyUSB0". I expect it to show up on my system as something similar, possibly "/dev/ttyACM0" or something.

I believe my kernel is configured properly because I can plug in a USB-to-Serial converter and it shows up as "/dev/ttyUSB0".

This is an openrc system with eudev installed.

When running "udevadm monitor" I can see the following happen when I plug in the device:

Code:

KERNEL[1859.422447] add      /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1 (usb)
KERNEL[1859.422777] add      /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0 (usb)
KERNEL[1859.423050] bind     /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1 (usb)
UDEV  [1859.990399] add      /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1 (usb)
UDEV  [1859.991792] add      /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0 (usb)
UDEV  [1859.996016] bind     /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1 (usb)


I grabbed the "/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1" and checked the info:
Code:

% udevadm info -a -p /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1                                   

Udevadm info 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 '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1':
    KERNEL=="1-1.1"
    SUBSYSTEM=="usb"
    DRIVER=="usb"
    ATTR{configuration}==""
    ATTR{bMaxPacketSize0}=="8"
    ATTR{bDeviceClass}=="ff"
    ATTR{bcdDevice}=="0105"
    ATTR{bNumInterfaces}==" 1"
    ATTR{bConfigurationValue}=="1"
    ATTR{manufacturer}=="Adafruit"
    ATTR{bNumConfigurations}=="1"
    ATTR{authorized}=="1"
    ATTR{speed}=="1.5"
    ATTR{idProduct}=="0c9f"
    ATTR{urbnum}=="9"
    ATTR{devnum}=="6"
    ATTR{product}=="USBtiny"
    ATTR{maxchild}=="0"
    ATTR{bmAttributes}=="80"
    ATTR{bDeviceSubClass}=="00"
    ATTR{bMaxPower}=="100mA"
    ATTR{rx_lanes}=="1"
    ATTR{removable}=="removable"
    ATTR{idVendor}=="1781"
    ATTR{version}==" 1.10"
    ATTR{avoid_reset_quirk}=="0"
    ATTR{bDeviceProtocol}=="00"
    ATTR{tx_lanes}=="1"
    ATTR{ltm_capable}=="no"
    ATTR{devpath}=="1.1"
    ATTR{busnum}=="1"
    ATTR{quirks}=="0x0"

  looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1':
    KERNELS=="1-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bcdDevice}=="0000"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{authorized}=="1"
    ATTRS{speed}=="480"
    ATTRS{idProduct}=="0020"
    ATTRS{urbnum}=="193"
    ATTRS{devnum}=="2"
    ATTRS{maxchild}=="6"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{rx_lanes}=="1"
    ATTRS{removable}=="fixed"
    ATTRS{idVendor}=="8087"
    ATTRS{version}==" 2.00"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{tx_lanes}=="1"
    ATTRS{ltm_capable}=="no"
    ATTRS{devpath}=="1"
    ATTRS{busnum}=="1"
    ATTRS{quirks}=="0x0"

  looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bcdDevice}=="0505"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{manufacturer}=="Linux 5.5.1-gentoo ehci_hcd"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{authorized}=="1"
    ATTRS{speed}=="480"
    ATTRS{idProduct}=="0002"
    ATTRS{urbnum}=="134"
    ATTRS{devnum}=="1"
    ATTRS{product}=="EHCI Host Controller"
    ATTRS{maxchild}=="3"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{rx_lanes}=="1"
    ATTRS{removable}=="unknown"
    ATTRS{idVendor}=="1d6b"
    ATTRS{interface_authorized_default}=="1"
    ATTRS{authorized_default}=="1"
    ATTRS{version}==" 2.00"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{serial}=="0000:00:1a.0"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{tx_lanes}=="1"
    ATTRS{ltm_capable}=="no"
    ATTRS{devpath}=="0"
    ATTRS{busnum}=="1"
    ATTRS{quirks}=="0x0"

  looking at parent device '/devices/pci0000:00/0000:00:1a.0':
    KERNELS=="0000:00:1a.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="ehci-pci"
    ATTRS{broken_parity_status}=="0"
    ATTRS{subsystem_device}=="0x2163"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{vendor}=="0x8086"
    ATTRS{local_cpus}=="f"
    ATTRS{companion}==""
    ATTRS{class}=="0x0c0320"
    ATTRS{numa_node}=="-1"
    ATTRS{msi_bus}=="1"
    ATTRS{device}=="0x3b3c"
    ATTRS{local_cpulist}=="0-3"
    ATTRS{driver_override}=="(null)"
    ATTRS{d3cold_allowed}=="1"
    ATTRS{irq}=="23"
    ATTRS{revision}=="0x06"
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{ari_enabled}=="0"
    ATTRS{uframe_periodic_max}=="100"
    ATTRS{enable}=="1"
    ATTRS{subsystem_vendor}=="0x17aa"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""


It seems, then that the following udev rule would work:
Code:

# /etc/udev/rules.d/99-usbtiny.rules
SUBSYSTEM=="usb", ATTR{manufacturer}=="Adafruit", ATTR{product}=="USBtiny", ATTR{idProduct}=="0c9f", ATTR{idVendor}=="1781", MODE="0660", GROUP="plugdev", SYMLINK+="usbtiny%n"


It is the same as others that I have seen elsewhere on the internet. One difference is that the idVendor seems to be an ATTRS but it is not a parent node attribute from the "udevadm info" output.

My process for reloading the rules has been to run "udevadm control -R". I have also tried restarting udev "/etc/init.d/udev restart" and just rebooting. The device never makes an entry under /dev/. I have tried all of the above without the "SYMLINK" part of the udev rule as well.

I can see the device with lsusb:
Code:

 % lsusb                                                                                                             
Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 006: ID 1781:0c9f Multiple Vendors USBtiny


I know the kernel sees it as well with the tail of dmesg:
Code:

[ 1859.351137] usb 1-1.1: new low-speed USB device number 6 using ehci-pci
[ 1859.440168] usb 1-1.1: New USB device found, idVendor=1781, idProduct=0c9f, bcdDevice= 1.05
[ 1859.440172] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 1859.440175] usb 1-1.1: Product: USBtiny
[ 1859.440177] usb 1-1.1: Manufacturer: Adafruit


Does anyone have any other troubleshooting tips? Like I said, the usb serial converter I have registers as a device under /dev/ and I can see it just fine in the "udevadm monitor" output. I feel like I'm missing something small and I have been banging my head on this for a couple days. Any pointers would be appreciated.

The main resources that I've been through for this are:


Last edited by jesse_m on Mon Apr 06, 2020 12:29 am; edited 1 time in total
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6351

PostPosted: Sat Feb 29, 2020 6:27 pm    Post subject: Reply with quote

Code:
SUBSYSTEM=="tty", ATTRS{idProduct}=="0c9f", ATTRS{idVendor}=="1781", MODE="0660", GROUP="plugdev", SYMLINK+="usbtiny%n"

That should get it to show up. If it doesn't, you're missing the correct serial driver.
Back to top
View user's profile Send private message
jesse_m
n00b
n00b


Joined: 14 Mar 2018
Posts: 21
Location: Grand Rapids, MI

PostPosted: Tue Mar 03, 2020 1:10 am    Post subject: Reply with quote

Ant P. wrote:
Code:
SUBSYSTEM=="tty", ATTRS{idProduct}=="0c9f", ATTRS{idVendor}=="1781", MODE="0660", GROUP="plugdev", SYMLINK+="usbtiny%n"

That should get it to show up. If it doesn't, you're missing the correct serial driver.


Thanks for the suggestion. I double checked my kernel config and I have every driver starred under "USB Serial Converter Support". The odd thing is is that another device that uses usb to serial shows up just fine. I have had this device working with my machine before and I haven't recompiled my kernel since then.

Would you happen to know if there is some cache or something that needs to be cleared with udev or something? I've skimmed through the commands in udevadm and nothing really jumped out at me. I've skimmed through the manpage for udev and I see the hwdb file. I'm not sure if "udevadm hwdb --update" does anything.
Back to top
View user's profile Send private message
jesse_m
n00b
n00b


Joined: 14 Mar 2018
Posts: 21
Location: Grand Rapids, MI

PostPosted: Mon Apr 06, 2020 12:29 am    Post subject: Reply with quote

I'm an idiot. I don't think it is supposed to show up in /dev/ anyways. It's working, the "avrdude" programmer can see it. I think a flash write failed for some reason and then I went looking for what the problem was. I thought it was supposed to show up in /dev/. I think the biggest thing it to make sure it shows up in dmesg or the udev monitor output. I looked through the usbtiny tests and they look through the usb's connected, not for devices in /dev. I don't really know much about usb but I'm learning.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum