This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Loading USB Gadget Kernel Modules

Other Parts Discussed in Thread: OMAP-L137, DA8XX

I am testing out the USB Device port on my EVMOMAP-L137 dev board. My thought is that I could install relevant kernel modules without reflashing the entire kernel. I'm following steps in the OMAP-L137 EVM PSP User's Guide

- Install the toolchain
- Install kernel source
- Config kernel for USB gadget,, ie USB_GADGET_MUSB_HDRC, etc.
- Compile the kernel
- Build the loadable modules.
- TFTP over some modules to the board
Everything is going amazing well so far.

I try to install the module:

modprobe g_serial.ko
FATAL: Could not load /lib/modules/2.6.18_pro500-da830_omapl137_evm-arm_v5t_le/m
odules.dep: No such file or directory

There is nothing in /lib/modules on the target/board. Everything is pretty well out-of-box.

My google-fu is not up to finding a guide for demoing the USB Device functionality on this starter kit. Any links out there? Suggestions?

  • You can install modules if USB is already not present in kernel uImage. Please follow the steps at below link for device mode functionality.

    http://processors.wiki.ti.com/index.php/UserGuideUsbDriver_PSP_03.00.00.05#MUSB_OTG_controller_in_gadget_mode

    Instead of module you can also make the gadget support added as builtin for g_serial.

    Regards,
    Ajay

  • Thanks for the link. It is very similiar to the OMAP-L137 EVM PSP User's Guide. I have configured the kernel. Built the kernel. Built the modules. I have plenty of ".ko" files. The only difference is "insmod" vs "modprobe". Articles on the web say that "modprobe" calls "insmod". It seems that "modprobe" checks dependencies. Using "insmod" means I will have load dependent modules manually. I'll give "insmod" a try and get back to you.

    Not sure what you mean by "make the gadget support added as builtin for g_serial". If you mean "*" vs "m" in kernel config, I am trying to avoid changing the kernel and use loadable kernel modules at runtime.

  • Okay. Some confusing responses from the Linux kernel.

    No HCD Loaded:
    insmod g_serial.ko
    g_serial: Unknown symbol usb_gadget_register_driver
    g_serial: Unknown symbol usb_gadget_unregister_driver
    insmod: error inserting 'g_serial.ko': -1 Unknown symbol in module

    Looks like I need a HCD module.

    Load Dummy HCD:
    insmod dummy_hcd.ko
    dummy_hcd dummy_hcd: USB Host+Gadget Emulator, driver 02 May 2005
    dummy_hcd dummy_hcd: Dummy host controller
    dummy_hcd dummy_hcd: new USB bus registered, assigned bus number 3
    usb usb3: configuration #1 chosen from 1 choice
    hub 3-0:1.0: USB hub found
    hub 3-0:1.0: 1 port detected

    With Dummy HCD Loaded:
    insmod g_serial.ko
    gs_bind: Gadget Serial v2.2 bound
    gs_module_init: Gadget Serial v2.2 loaded
    root@(none):~/dummy# gs_disconnect: Gadget Serial disconnected
    usb 3-1: new high speed USB device using dummy_hcd and address 3
    gs_disconnect: Gadget Serial disconnected
    usb 3-1: configuration #1 chosen from 1 choice
    gs_set_config: Gadget Serial configured, high speed BULK config

    Looks promising. No idea on how to test the modules.

    Different Version of Dummy HCD Loaded:
    insmod g_serial.ko
    g_serial: disagrees about version of symbol usb_gadget_register_driver
    g_serial: Unknown symbol usb_gadget_register_driver
    g_serial: disagrees about version of symbol usb_gadget_unregister_driver
    g_serial: Unknown symbol usb_gadget_unregister_driver
    insmod: error inserting 'g_serial.ko': -1 Unknown symbol in module

    This error is odd as none of the source code has changed. Just compiled at different times. This will be a bug issue when I build my own custom module outside of the kernel.

    Dummy HCD and Another Gadget Loaded:
    insmod g_serial.ko
    gs_module_init: cannot register gadget driver, ret=-16
    insmod: error inserting 'g_serial.ko': -1 Device or resource busy

    Appears only one gadget can be loaded at a time. Reasonable enough.


    Verified that modules can load with the Dummy HDC. I need the real HDC. By default, the kernel has the HDRC HDC compiled as a built-in with only Host support and no Gadget support. I recompiled the HDRC HDC with gadget support and as a module. Loading the module clashed with the built-in.

    insmod musb_hdrc.ko
    musb_hdrc: version 6.0, cppi4.1-dma, peripheral, debug=0
    kobject_add failed for musb_hdrc with -EEXIST, don't try to register things with
     the same name in the same directory.
    insmod: error inserting 'musb_hdrc.ko': -1 File exists

    From what I gather, built-ins cannot be unloaded in Linux. It looks like I will have to reflash the kernel just to get USB Gadget support in the HDRC driver. Seems odd to enable USB Host support in Linux on when the connector on the EVM board is populated as a micro-B USB. I thought the connector implies OTG.

     

  • For gadget only you need not enable Host side support. Please follow the steps below,

    1. Enable Inventra high speed controller at Device drivers->USB support -> Inventra. Do not enable "Support for Host side USB"

    2. Choose driver mode as "gadget stack"

    3. Select USb gadget inside "Device drivers->USB support->USB gadget support"

    4. Choose Inventra as the controller inside "USB Peripheral controller"

    Regards,
    Ajay

  • Finally got my OMAP EVM board to behave like a USB serial port. Steps below are for the Gadget Serial for the OMAP EVM board from Spectrum Digital. The Gadget File Storage enumerated but was unresponsive. The other Gadgets also enumerate but I did not test them. Exhausted with just getting this bit of ... code ... running.

    1) Rebuild Kernel with HDRC Gadget
    I used the instructions in the “OMAP-L137 EVM PSP User’s Guide” and in the Wiki article. Ajay's instructions above are similar. Attached is the config file. I hope it attached...

    2) Reflash the Kernel Using U-Boot
    I used the following commands at the U-Boot command prompt.

    setenv autoload no
    dhcp
    setenv serverip nnn.nnn.nnn.nnn
    sf probe 0
    tftp 0xc0700000 uImage
    sf erase 0x1E0000 0x220000
    sf write 0xc0700000 0x1E0000 0x220000


    where nnn.nnn.nnn.nnn is the IP of the TFTP server.

    Note that the “OMAP-L137 EVM PSP User’s Guide” is incorrect. It uses an offset value 0x60000. The Wiki article is also incorrect as well as inconsistent. The correct value of 0x1E0000 is in the current bootcmd environment variable. It is blind stupid luck that the incorrect values did not permanently brick my board. That part of memory must be unused by any of the many bootloaders.

    3) Load Gadget Serial
    Here's my log of the Linux commands ands responses. It sets up the device, loads the serial driver in ACM mode and attaches a shell to the device. Google is your friend.

    #mknod /dev/ttygserial c 127 0

    #modprobe g_serial use_acm=1
    gs_bind: Gadget Serial v2.2 bound
    gs_module_init: Gadget Serial v2.2 loaded
    gs_disconnect: Gadget Serial disconnected
    da8xx_interrupt 410: Unhandled USB IRQ 00000001
    gs_set_config: Gadget Serial configured, high speed CDC-ACM config

    #/sbin/getty -n  -l /bin/sh /dev/ttygserial 115200 &


    Hopefully I can ignore the periodic "Unhandled USB IRQ" messages.

    4) Connect to PC
    Ideally, connecting the target should automatically create a COM port on the PC. Not quite. As written, the serial port gadget requires the standard CDC-ACM driver (usbser.sys) to be manually installed. It does not automatically install the standard driver.
    See Linux kernel file at

    linux-2.6.18_pro500/Documentation/usb/gadget_serial.txt

    for more information on setting up device driver on Windows. It details an INF file that gets me most of the way there. With a bit of hunting around for the usbser.sys file and fighting with the Windows HW installation wizard, I eventually managed to load the standard USB CDC-ACM driver for the Gadget Serial VID/PID.

    5) Hyperterminal
    Check the Device Manager to see what COM port that Gadget Serial has created. Start Hyperterminal with that COM port and 115200 8N1. I get a Linux terminal window.

    Now that I have the Linux USB Gadget framework running, does anybody have a simple example of a Gadget HID implementation for an ancient version of Linux (2.6.18)? The HID implementation in 2.6.35 looks to be quite diffcult to back port.

    5125.config_with_hdrc_gadget.txt