Usb hid core driver linux

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.

Читайте также:  Как обновиться до windows 10 2020 году

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:

mkdir /dev/input mknod /dev/input/mice c 13 63

If you cat /dev/input/mice you should see some bizarre looking characters as you move the mouse or click any of the buttons.

If you want to use the mouse under X, you have various options. Which one you select is dependent on what version of XFree86 you are using and whether you are using only USB for your mouse (or mice), or whether you want to use a USB mouse and some other kind of pointer device.

You need to edit the XF86Config file (usually /usr/X11R6/lib/X11/XF86Config or /etc/X11/XF86Config ).

If you are using XFree86 version 4.0 or later, add a InputDevice section that looks like the following:

Section «InputDevice» Identifier «USB Mice» Driver «mouse» Option «Protocol» «IMPS/2» Option «Device» «/dev/input/mice» EndSection

or, if you want to use a wheel mouse, something like:

Section «InputDevice» Identifier «USB Mice» Driver «mouse» Option «Protocol» «IMPS/2» Option «Device» «/dev/input/mice» Option «ZAxisMapping» «4 5» Option «Buttons» «5» EndSection

may be more useful. Consult the XFree86 documentation for a detailed explaination and more examples.

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:

InputDevice «USB Mice» «CorePointer»

If you want to use both a USB mouse (or USB mice) and some other kind of pointer device, then add (do not replace) the following line to the applicable ServerLayout sections:

InputDevice «USB Mice» «SendCoreEvents»

If you are using only a USB mouse (or USB mice) with XFree86 3.3, edit the Pointer section so that it looks like the following:

Section «Pointer» Protocol «IMPS/2» Device «/dev/input/mice» EndSection

If you are trying to use a USB mouse (or USB mice) in addition to another pointer type device with XFree86 3.3, then you need to use the XInput extensions. Keep the existing Pointer (or modify it as required for the other device if you are doing an initial installation), and add the following entry (anywhere sensible, ideally in the Input devices area):

Section «Xinput» SubSection «Mouse» DeviceName «USB Mice» Protocol «IMPS/2» Port «/dev/input/mice» AlwaysCore EndSubSection EndSection

Restart the X server. If you don’t have any mouse support at this point, remember that Ctrl-Alt-F1 will get you a virtual terminal that you can use to kill the xserver and start debugging from the error messages.

If you want to use the mouse under gpm, run (or kill and restart if it is already running) gpm with the following options. gpm -m /dev/input/mice -t imps2 (as superuser remember). You can make this the default if you edit the initialisation files. These are typically named something like rc.d and are in /etc/rc.d/ on RedHat distributions.

If you have both a USB mouse (or USB mice) and some other kind of pointer device, you may wish to use gpm in repeater mode. If you have a PS/2 mouse on /dev/psaux and a USB mouse (or USB mice) on /dev/input/mice , then the following gpm command would probably be appropriate: gpm -m /dev/input/mice -t imps2 -M -m /dev/psaux -t ps2 -R imps2 . Note that this will make the output appear on /dev/gpmdata , which is a FIFO and does not need to be created in advance. You can use this as the mouse «device» to non-X programs, and both mice will work together.

You may not need any operating system support at all to use a USB keyboard if you have a PC architecture. There are several BIOS available where the BIOS can provide USB support from a keyboard plugged into the root hub on the motherboard. This may or may not work through other hubs and does not normally work with add-in boards, so you might want to add in support anyway. You definately want to add keyboard support if you add any operating system support, as the Linux USB support will disable the BIOS support. You also need to use Linux USB keyboard support if you want to use any of the «multimedia» types keys that are provided with some USB keybords.

In the kernel configuration stage, you need to turn on USB Human Interface Device (HID) support in USB support and Keyboard support in Input core support . Do not turn on USB HIDBP Keyboard support . Perform the normal kernel rebuild and installation steps. If you are installing as modules, you need to load the hid.o , input.o and keybdev.o modules.

Check the kernel logs to ensure that your keyboard is being correctly sensed by the kernel.

At this point, you should be able to use your USB keyboard as a normal keyboard. Be aware that LILO is not USB aware, and that unless your BIOS supports a USB keyboard, you may not be able to select a non-default boot image using the USB keyboard. I have personally used only a USB keyboard (and USB mouse) and have experienced no problems.

In the kernel configuration stage, you need to turn on USB Human Interface Device (HID) support in USB support and Joystick support in Input core support . Perform the normal kernel rebuild and installation steps. If you are installing as modules, you need to load the hid.o , input.o and joydev.o modules.

You need to set up a device node entry for the joystick. It is customary to create the entries for USB device in the /dev/input/ directory. You can use the following commands to create four device nodes, although there is no reason why you can not use more:

mknod /dev/input/js0 c 13 0 mknod /dev/input/js1 c 13 1 mknod /dev/input/js2 c 13 2 mknod /dev/input/js3 c 13 3

If you plug in a gamepad or joystick and cat /dev/input/js0 you should see some bizarre looking characters as you move the stick or click any of the buttons.

You should now be able to use the USB joystick or gamepad with any of the normal games or other joystick compatible applications.

Источник

USB Реле типа HID

Купил USB реле. В системе определяется как /dev/hidraw5

Который в свою очередь завязан на (http://www.signal11.us/oss/hidapi/). В общем заморочено.

А нельзя управлять этим реле как-нибудь Unixway через /dev/hidraw5?

В общем на коленках собрал и библиотеку libhidapi-hidraw и программку usbrelay.

Теперь есть розетка дома, которая включается и выключается вместе с компьютером 🙂

А подскажи, какой модуль подгружается при подключении этого девайса? Взял себе такую платку, но ничего не происходит 🙁

Насколько я понимаю это стандартное HID устройство ввода-вывода Оно в ядре должно быть (современном). У меня оно сразу-же определилось вот так. Я только библиотеку собрал и программу собрал для управления.

Я уже две купил платы у разных продавцов — работают без нареканий.

Вот что за наркоманы их как HID делают? Ведь CDC значительно удобней.

Обычное поведение людей, для первого что увидел скачивается пример и хренак-хренак модифицируется в продакшен. Как оно там устроено и можно ли по-другому всем пофиг.

Для CDC нужны драйверы в винде, думаю в этом дело.

У меня модуль грузится (попробовал на машинке с Debian и linux 3.2), в dmesg

Либа поставлена из репозитория, но утилита просто ничего не выводит.

А, утилита тоже есть в репозитории. Но и с этой тоже пусто.

А вот dmesg на машинке с linux 4.8 уже иначе реагирует:

Ну и утилитка зашевелилась:

Осталось завести ее и на старых системах.

Поставил 3.16 с бэкпортов. Там работает. Так чего же ему все же не хватает на 3.2?

Уж не знаю. У меня Linux 4.9.9-nrj-desktop-1rosa-x86_64.

Ну, на 4.9.9 — то понятно. Просто где-то на промежутке 3.8 — 3.16 что-то поменялось и до этого изменения оно не работает. А хотелось прилепить реле на машинки, где вообще пока что 3.2 живет.

Во! Завел. Есть другой проект — https://github.com/pavel-a/usb-relay-hid — вот утилита с него прекрасно работает и на старых ядрах, в том числе и 3.2 из Wheezy.

китайцы кучу девайсов как hid делают, не предназначенных для этого. мне попадались даже hid программаторы. очевидно дело в драйверах.

Т.е. она без библиотеки hidapi работает? Надо попробовать.

Ну, как минимум, оно ее не требовало. При сборке только libusb-dev нужен был.

Бред: для HID тоже «драйвера» нужны. Потому что гребаная мастдайка!

И вообще, на кой хрен ориентироваться на дебилов, у которых вместо операционной системы мастдайка стоит?

Анонимус выше, похоже, правильно сказал: взяли, что под руку попалось, да и наклепали!

А ты потом страдай. Я дня три как-то убил, чтобы разобраться, как работать с турелями — пришлось найти комп с мастдайкой (потому как драйвер к этой железяке только мастдайный был), поставить туда usb-логгер и написать логи подо все действия. Только после этого смог управлялку из-под линукса написать!

Бред: для HID тоже «драйвера» нужны. Потому что гребаная мастдайка!

Неа, не нужны, нужна только софтина, которая будет с устройством общаться.

И вообще, на кой хрен ориентироваться на дебилов, у которых вместо операционной системы мастдайка стоит?

Потому что линуксоидов и маководов очень мало.

нужна только софтина, которая будет с устройством общаться.

И чем это отличается от необходимости установки «драйвера»? Тоже софтина, которая будет с устройством общаться!

Потому что линуксоидов и маководов очень мало.

А гомосятину ты зачем вспомнил?

И чем это отличается от необходимости установки «драйвера»? Тоже софтина, которая будет с устройством общаться!

Драйвер придётся подписывать, иначе винда будет ругаться. Плюс, для его установки нужны права админа. А софтину запустил и пользуйся.

Источник

Читайте также:  Схема лицензирования windows server 2019 standard
Оцените статью