1

everyone.

I have special USB device (chinese touchscreen), what I need to connect to my computer with Linux.

By default, Linux assign connected device to usbhid (I found this info by execute usb-devices and node hidraw* appears after connecting touchscreen to computer) kernel module, so my system can't see touchscreen as input device. Also, I have drivers for this device. I build and install driver into my Linux system, and create instructions to load this module at system startup in /etc/modules-load.d/.

Driver loaded successfully at startup (I get this info by execute lsmod), but touchscreen still attached to usbhid. I know that driver works well because if I unload usbhid and replug device, touchscreen driver capture touchscreen.

[alarm@alarmpi ~]$ usb-devices 

T:  Bus=01 Lev=02 Prnt=02 Port=03 Cnt=02 Dev#=  4 Spd=12  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=0eef ProdID=0005 Rev=02.00
S:  Manufacturer=RPI_TOUCH
S:  Product=By ZH851
S:  SerialNumber=RÿhgWUC`g
C:  #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=100mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=03(HID  ) Sub=00 Prot=00 Driver=(usbhid)

I found that there is a way to unbind device from usbhid by creating udev rule. So, here is my udev rule:

ATTRS{idVendor}=="0eef", ATTRS{idProduct}=="0005", DRIVER=="usbhid", RUN="/bin/sh -c 'echo -n $kernel > /sys/bus/usb/drivers/usbhid/unbind'"

After computer reboot, usb-devices show me that touchscreen has no attached drivers at all!!! I think, my driver will capture it:

[alarm@alarmpi ~]$ usb-devices 

T:  Bus=01 Lev=02 Prnt=02 Port=03 Cnt=02 Dev#=  4 Spd=12  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=0eef ProdID=0005 Rev=02.00
S:  Manufacturer=RPI_TOUCH
S:  Product=By ZH851
S:  SerialNumber=RÿhgWUC`g
C:  #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=100mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=03(HID  ) Sub=00 Prot=00 Driver=(none)

Ok, I also find that sysfs provides new_id field in my driver. Googling for new_id in sys_fs I found what if I send vendor and product IDs to it, device will be binded to driver and driver will capture device. So, If I execute at shell something like this:

[alarm@alarmpi ~]# echo -n 0eef 0005 > /sys/bus/usb/drivers/eleduino_ts/new_id

Everything works as I need. So, I decide to update my udev rule with this string:

# 1. Unbind our device from usbhid:
ATTRS{idVendor}=="0eef", ATTRS{idProduct}=="0005", DRIVER=="usbhid", RUN="/bin/sh -c 'echo -n $kernel > /sys/bus/usb/drivers/usbhid/unbind'"

# 2. Bind device to eleduino_ts driver:
ATTRS{idVENDOR}=="0eef", ATTRS{idProduct}=="0005", RUN="/bin/sh -c 'echo -n '0eef 0005' > /sys/bus/usb/drivers/eleduino_ts/new_id'"

Apply new udev rule, reboot, execute usb-device:

[alarm@alarmpi ~]$ usb-devices

T:  Bus=01 Lev=02 Prnt=02 Port=03 Cnt=02 Dev#=  4 Spd=12  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=0eef ProdID=0005 Rev=02.00
S:  Manufacturer=RPI_TOUCH
S:  Product=By ZH851
S:  SerialNumber=RÿhgWUC`g
C:  #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=100mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=03(HID  ) Sub=00 Prot=00 Driver=(usbhid)

What's going on? Why usbhid?.

Well, I decide to downgrade udev rule and create system.d service. Here is it:

[alarm@alarmpi ~]$ cat /etc/systemd/system/eleduino_ts.service 
[Unit]
Description=Bind device to eleduinos_ts
Conflicts=getty@tty1.service plymouth-quit.service
After=systemd-user-sessions.service getty@tty1.service plymouth-quit.service

[Service]
ExecStart=/bin/echo -n 0eef 0005 > /sys/bus/usb/drivers/eleduino_ts/new_id
Restart=always
IgnoreSIGPIPE=no

[Install]
WantedBy=multi-user.targets

I know, that service executes well, but my touchscreen still has no attached drivers:

[alarm@alarmpi ~]$ usb-devices 

T:  Bus=01 Lev=02 Prnt=02 Port=03 Cnt=02 Dev#=  4 Spd=12  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=0eef ProdID=0005 Rev=02.00
S:  Manufacturer=RPI_TOUCH
S:  Product=By ZH851
S:  SerialNumber=RÿhgWUC`g
C:  #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=100mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=03(HID  ) Sub=00 Prot=00 Driver=(none)

So, my question is: How can I attach my driver to my device?

P.S. Maybe it will help:

[alarm@alarmpi ~]$ uname -a 
Linux alarmpi 4.1.12-1-ARCH #1 PREEMPT Tue Oct 27 19:16:04 MDT 2015 armv6l GNU/Linux

Thanks in advance.

P.S. I've asked this question in other threads, but nobody give me an answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.