- Linux USB HID gadget driverВ¶
- IntroductionВ¶
- ConfigurationВ¶
- Configuration with configfsВ¶
- Send and receive HID reportsВ¶
- Компиляция общего драйвера HID
- Arch Linux
- #1 2008-09-20 10:58:24
- «USB HID core driver»
- #2 2008-10-05 15:50:55
- Re: «USB HID core driver»
- #3 2008-10-05 18:26:43
- Re: «USB HID core driver»
- #4 2008-10-05 20:59:31
- Re: «USB HID core driver»
- #5 2008-10-05 22:13:31
- Re: «USB HID core driver»
- #6 2008-10-22 14:24:40
- Re: «USB HID core driver»
- Usb hid core driver linux
- USB Реле типа HID
Linux USB HID gadget driverВ¶
IntroductionВ¶
The HID Gadget driver provides emulation of USB Human Interface Devices (HID). The basic HID handling is done in the kernel, and HID reports can be sent/received through I/O on the /dev/hidgX character devices.
For more details about HID, see the developer page on https://www.usb.org/developers/hidpage/
ConfigurationВ¶
g_hid is a platform driver, so to use it you need to add struct platform_device(s) to your platform code defining the HID function descriptors you want to use — E.G. something like:
You can add as many HID functions as you want, only limited by the amount of interrupt endpoints your gadget driver supports.
Configuration with configfsВ¶
Instead of adding fake platform devices and drivers in order to pass some data to the kernel, if HID is a part of a gadget composed with configfs the hidg_func_descriptor.report_desc is passed to the kernel by writing the appropriate stream of bytes to a configfs attribute.
Send and receive HID reportsВ¶
HID reports can be sent/received using read/write on the /dev/hidgX character devices. See below for an example program to do this.
hid_gadget_test is a small interactive program to test the HID gadget driver. To use, point it at a hidg device and set the device type (keyboard / mouse / joystick) — E.G.:
You are now in the prompt of hid_gadget_test. You can type any combination of options and values. Available options and values are listed at program start. In keyboard mode you can send up to six values.
For example type: g i s t r –left-shift
Hit return and the corresponding report will be sent by the HID gadget.
Another interesting example is the caps lock test. Type –caps-lock and hit return. A report is then sent by the gadget and you should receive the host answer, corresponding to the caps lock LED status:
With this command:
You can test the mouse emulation. Values are two signed numbers.
Источник
Компиляция общего драйвера HID
Требуется скомпилировать в модуль и установить общий драйвер устройств USB HID. Компиляция проходит успешно, однако после установки драйвер не загружается.
Ubuntu 14.04, Linux 3.13.0, исходники получаются при помощи apt-get source , linux-3.13.0/drivers/hid/Makefile:
Далее make && sudo make install && depmod -a . Драйвер устанавливается в /lib/modules/3.13.0-85-generic/extra. Далее sudo rmmod hid_generic && sudo rmmod usbhid && sudo rmmod hid && sudo modprobe hid && sudo modprobe usbhid . После этого драйвер hid_generic загружается уже автоматически и всё работает как при использовании оригинального драйвера из репозитория, в основном дереве драйверов.
Добавление в Makefile
После переименования в основном дереве драйверов hid.ko в hid.ko.original с целью вынуждения ядра загружать изменённую версию драйвера из updated при загрузке драйвера ( sudo modprobe hid ) выдаётся сообщение об ошибке:
modprobe: ERROR: could not insert ‘hid’: Unknown symbol in module, or unknown parameter (see dmesg)
При этом в dmesg ничего не выводится. Я так понял, проблема с динамическим связыванием этого модуля с другими модулями, что делать в этой ситуации? Как скомпилировать общий драйвер HID, установить его (в extra или updated?) и добиться того, чтобы работала именно новая скомпилированная версия, а не версия в основном дереве драйверов из репозитория. Или для этого нужно компилировать этот драйвер с другими зависящими от него драйверами, т. е. usbhid, hid-generic и специальными драйверами различных устройств USB HID?
Источник
Arch Linux
You are not logged in.
#1 2008-09-20 10:58:24
«USB HID core driver»
Hi,
At the first time I had a running Arch Linux installation, but I wanted to reinstall it to clean everything up.
After installing it a second second time I’m not able to boot it any longer.
The last thing it says is
drivers/hid/usbhid/hid-core.c: v2.6:USB HID core driver
and than there’s a kind of rescue console.
The problem is, that there are no new USB devices since the last installation, I can’t figure anything out that changed but obviously there is something.
#2 2008-10-05 15:50:55
Re: «USB HID core driver»
Same exact not-so fairy tale story here. Had it, went and put about 3 different distros on it to test it out, and it messes up just like that does. But see, my rig is /dev/sda is Ubuntu and /dev/sdb is my «test drive». With my flash stick (sdc) in or out it gives that error. I am sorta a linux newbie so i just installed all packages. something to do with that? I tried i686 and x86-64 and both give the error. Squak. Help please, i will see if I dont just have unneeded pkgs and see if thats the problem.
Meh has new account! This one left behind for history’s sake.
#3 2008-10-05 18:26:43
Re: «USB HID core driver»
Please? I tried EXT3 and Reiser to see if FS made a difference and it did not. Is it the fact that this is on /dev/sdb? The fact that I did not install GRUB for the mere fact that I’d be using Ubuntu’s GRUB? This time I was more selective of packages only installing what I need. x86-64. It says something along the lines of cant create/find root FS ». Uhh. I’m lost. Please, please help.
Meh has new account! This one left behind for history’s sake.
#4 2008-10-05 20:59:31
Re: «USB HID core driver»
You’ll need to post the exact error message (not just the last line—often you will see a number of lines leading to/resulting from one error) or provide more details before anyone can really help out. If you can access your entire dmesg, that would likely be best.
However, based on your limited description, I would be leaning towards an improper «root=» line in your GRUB configuration.
Remember, /dev/sda in Arch may not refer to the same location as /dev/sda in Ubuntu. This is why UUIDs are usually recommended.
M*cr*s*ft: Who needs quality when you have marketing?
#5 2008-10-05 22:13:31
Re: «USB HID core driver»
Yup, it was GRUB, in fact, I didnt install it on Arch and Ubuntu’s wasn’t pointing correctly. To fix it, I unplugged HD1 and therefore HD2 was HD1. I installed arch (AND GRUB!) on this HDD, and it boots. In fact, I am writing this in Konqueror on Arch x86-64. Thanks.
Meh has new account! This one left behind for history’s sake.
#6 2008-10-22 14:24:40
Re: «USB HID core driver»
Okay, I just saw that there’s an answer.
In fact it works when I use Archs GRUB. But I would prefer to use Ubuntus GRUB because Archs GRUB seems to have problems with Windows.
So, how can I use Ubuntus GRUB with Arch?
edit:
this is my current configuration(menu.lst):
title Arch Linux
root (hd1,2)
kernel /boot/vmlinuz26 root=/dev/disk/by-uuid/0e5f3e7e-fecd-4c9f-9bdc-b7f4d59da03e ro
initrd /boot/kernel26.img
Last edited by Ankou (2008-10-22 15:23:47)
Источник
Usb hid core driver linux
There are two options for using a USB mouse or a USB keyboard — the standalone Boot Protocol (HIDBP) way and the full featured HID driver way. The Boot Protocol way is generally inferior, and this document describes the full featured way. The Boot Protocol way may be appropriate for embedded systems and other systems with resource constraints and no real need for the full keyboard and mouse capabilities.
In the kernel configuration stage, you need to turn on USB Human Interface Device (HID) support in the USB support and Mouse Support in the Input core support . You don’t need to worry about the screen resolution entries for a normal mouse — these are for mouse-like devices such as a graphics tablet. Do not turn on USB HIDBP Mouse support . Perform the normal kernel rebuild and installation steps. If you are installing as modules, you need to load the input.o , hid.o and mousedev.o modules.
Plug in a USB mouse and check that your mouse has been correctly sensed by the kernel. If you don’t have a kernel message, look for the changes to /proc/bus/usb/devices .
Since USB supports multiple identical devices, you can have multiple mice plugged in. You can get each mouse seperately, or you can get them all mixed together. You almost always want the mixed version, and that is what will be used in this example. You need to set up a device node entry for the mixed mice. It is customary to create the entries for this device in the /dev/input/ directory. Use the following commands:
You also need to add an entry to each applicable ServerLayout Section. These are normally at the end of the configuration file. If you only have a USB mouse (or USB mice), then replace the line with the «CorePointer» entry with the following line: