Jump to content

Recommended Posts

Posted

Hi,

 

I'm trying to make my opi one act as a keyboard. I've found that I need to activate g_hid module, but when I trying to execute:

modprobe g_hid

it says:

modprobe: FATAL: Module g_hid not found.

Also, g_ether, g_mass_storage, g_multi, g_ptinter and g_serial modules are available.

So, what should I do and maybe anyone can provide me an example how to send a keystroke to my pc?

 

Thanks.

Posted

G_HID was not enabled in kernel config for this board before, it will be available in new kernel release.

for mainline or legacy? ill finally be able to use my Opi One for the reason i got into the opi wormhole in the first... to press f1 to boot my frankendell server

 

Tapatalk thinks its important to tell you im using tapatalk from a phone.

Posted

for mainline or legacy? ill finally be able to use my Opi One for the reason i got into the opi wormhole in the first... to press f1 to boot my frankendell server

Legacy of course. Mainline doesn't have even "normal" (host-only) USB support for H3 yet.

Posted

Legacy of course. Mainline doesn't have even "normal" (host-only) USB support for H3 yet.

 

thanks... i shoulda known...

Posted

I've managed to compile and install kernel with G_HID enabled. Also I've patched hid.c as gadget_hid.txt says and created ghid0 device. But when I try to run an example I get this

/dev/hidg0: Invalid argument

You can find custom kernel and hid.c here.

Posted

I've made it work finally. Just executed these two lines.

echo 1 > /sys/bus/platform/devices/sunxi_usb_udc/otg_role
echo 2 > /sys/bus/platform/devices/sunxi_usb_udc/otg_role
Posted

Guys. Probably that will be really stupid question. Googled a lot, looked through documentation but had not found the answer.  How exactly may I crosscompile custom g_hid.ko  for orangepiwin (sunxi64). I successfully build default kernel with compile.sh. But when I try to substitute cache/sources/linux-mainline/linux-4.13.y/drivers/usb/gadget/legacy/hid.c with the one provided by qweryt and run compile.sh once again it became overwritten with original and compiled the same as it was.
Obviously I am missing some configuration flag e.g. OVERWRITE_LOCAL_CHANGES_IN_SOURCES=n :) 
Or should I create diff patch and put it somewhere in ./patch? Compiling on 4.4.0-97-generic Linux Mint 18 Sarah with hacked ./lib/general.sh os version check.
Or should I invoke direct make modules with 100500 parameters from cache/sources/linux-mainline/linux-4.13.y/?

Thanks in advance.

Posted

Ok. Now It works. Created git diff from qweryt's git.c and putted it into /userpatches/kernel/sunxi.next (as told in https://docs.armbian.com/Developer-Guide_User-Configurations/#user-provided-sources-config-overrides, by bad for missing it).
Now it is applied but fail to compile with multiple errors. Probably his git.c was based on too old kernel sources. Will study gadget_hid.txt and try to patch myself. Maybe someone has more recent version for 4.13.13? 
Noticed that this one is from 3.4.112. Does anyone have any hid.c example for mainline?

Posted

If you are using the mainline kernel, you can use configfs for setting up USB HID. Try this example:

    modprobe libcomposite
    mount -t configfs none /sys/kernel/config
    cd /sys/kernel/config/usb_gadget
    mkdir g1
    cd g1
    mkdir configs/c.1
    mkdir functions/hid.usb0
    echo 1 > functions/hid.usb0/protocol
    echo 1 > functions/hid.usb0/subclass
    echo 8 > functions/hid.usb0/report_length
    cat my_report_desc > functions/hid.usb0/report_desc
    mkdir strings/0x409
    mkdir configs/c.1/strings/0x409
    echo 0xa4ac > idProduct
    echo 0x0525 > idVendor
    echo serial > strings/0x409/serialnumber
    echo manufacturer > strings/0x409/manufacturer
    echo HID Gadget > strings/0x409/product
    echo "Conf 1" > configs/c.1/strings/0x409/configuration
    echo 120 > configs/c.1/MaxPower
    ln -s functions/hid.usb0 configs/c.1
    ls /sys/class/udc > UDC

 

Which I got from my own working USB OTG ethernet + midi + file storage script and this example here. Note that they create a file called "my_report_desc" for HID specific stuff. 

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines