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.

Linux 2.6.27.18 USB Hotplug with OMAP3530

Other Parts Discussed in Thread: OMAP3530

Anyone know of hotplugging issues with this version of the kernel?  I'm trying to get hotplugging working with gadget Ethernet.  I have the USB driver, including the gadget drivers built as modules.  The gadget Ethernet does work.  However, I can only get hotplug events when I manually install/uninstall the USB modules.  I have tried building the drivers into the kernel, but get the same result.  I've haven't found any patches for newer kernel versions that address this issue.  Any ideas?

  • I assume this is with respect to OMAP3530 since your previous post was related to OMAP3530.  It's a good practice to always include that info in a new thread.

    I've seen similar behavior even with later kernels.  Can you do something like this:

    • insmod your gadget driver. 
    • Now the USB is "ready" for when something gets plugged in.
    • Device gets plugged in
    • Device gets removed
    • rmmod/insmod to "re-arm" the USB

    Are you building the kernel with OTG support turned on?  The behavior I saw was definitely with OTG support enabled.  It may have behaved different when I just built it as a straight-up host or device (sorry, it was several months ago!).

    Do you need to support both host and device modes?  If not, which one do you need?  Can you attach your kernel config (please don't copy/paste into the editor!).

    Brad

  • Duh, sorry, I just noticed that the subject says OMAP3530!

  • In the sequence you listed, I only get hotplug events when insmod g_ether module (and musb_hdrc module which is a dependency for g_ether) and rmmod g_ether & musb_hdrc modules.  I do NOT get any hotplug event when plugging device into or removing from host PC via USB cable).

    • OTG is enabled
    • Only using in device mode (connecting to host PC and using Windows RNDIS driver)
    • Hotplug events only when g_ether/musb_hdrc modules installed or removed
    • Needing hotplug to detect device connection and removal from host PC to start/stop DHCP client and TFTP server via mdev; mdev part is working; just can't get hotplug events from kernel
    • For debugging, I've created a bash script that just dumps the env vars to a log file in tmp when a hotplug event occurs 'echo /usr/bin/hpdbg.sh > /proc/sys/kernel/hotplug'

    Attached is the

    • kernel cfg
    • bash shell script that is run when a hotplug event occurs
    • log files for hotplug events when installing/removing g_ether/musb_hdrc driver modules

    ACTION=remove
    HOME=/
    SEQNUM=412
    IFINDEX=4
    DEVPATH=/class/net/usb0
    SUBSYSTEM=net
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
    PHYSDEVPATH=/devices/platform/musb_hdrc
    PHYSDEVDRIVER=musb_hdrc
    INTERFACE=usb0
    PWD=/
    PHYSDEVBUS=platform
    ACTION=remove
    HOME=/
    SEQNUM=413
    MAJOR=248
    DEVPATH=/class/usb_endpoint/usbdev1.1_ep81
    SUBSYSTEM=usb_endpoint
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
    PHYSDEVPATH=/devices/platform/musb_hdrc/usb1/1-0:1.0
    MINOR=0
    PHYSDEVDRIVER=hub
    PWD=/
    PHYSDEVBUS=usb
    ACTION=remove
    HOME=/
    SEQNUM=414
    DEVPATH=/devices/platform/musb_hdrc/usb1/1-0:1.0
    SUBSYSTEM=usb
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
    MODALIAS=usb:v1D6Bp0002d0206dc09dsc00dp00ic09isc00ip00
    TYPE=9/0/0
    INTERFACE=9/0/0
    PRODUCT=1d6b/2/206
    PWD=/
    PHYSDEVBUS=usb
    DEVTYPE=usb_interface
    DEVICE=/proc/bus/usb/001/001
    ACTION=remove
    HOME=/
    SEQNUM=415
    MAJOR=248
    DEVPATH=/class/usb_endpoint/usbdev1.1_ep00
    SUBSYSTEM=usb_endpoint
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
    PHYSDEVPATH=/devices/platform/musb_hdrc/usb1
    MINOR=1
    PHYSDEVDRIVER=usb
    PWD=/
    PHYSDEVBUS=usb
    ACTION=remove
    HOME=/
    SEQNUM=416
    DEVPATH=/class/usb_endpoint
    SUBSYSTEM=class
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
    PWD=/
    ACTION=remove
    HOME=/
    SEQNUM=417
    MAJOR=189
    DEVPATH=/class/usb_device/usbdev1.1
    SUBSYSTEM=usb_device
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
    PHYSDEVPATH=/devices/platform/musb_hdrc/usb1
    MINOR=0
    PHYSDEVDRIVER=usb
    PWD=/
    PHYSDEVBUS=usb
    ACTION=remove
    HOME=/
    SEQNUM=418
    BUSNUM=001
    MAJOR=189
    DEVPATH=/devices/platform/musb_hdrc/usb1
    SUBSYSTEM=usb
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
    MINOR=0
    TYPE=9/0/0
    DEVNUM=001
    PRODUCT=1d6b/2/206
    PWD=/
    PHYSDEVBUS=usb
    DEVTYPE=usb_device
    DEVICE=/proc/bus/usb/001/001
    ACTION=remove
    HOME=/
    SEQNUM=419
    MAJOR=253
    DEVPATH=/class/usbmon/usbmon1
    SUBSYSTEM=usbmon
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
    PHYSDEVPATH=/devices/platform/musb_hdrc
    MINOR=1
    PHYSDEVDRIVER=musb_hdrc
    PWD=/
    PHYSDEVBUS=platform
    ACTION=remove
    HOME=/
    SEQNUM=420
    DEVPATH=/class/usb_host/usb_host1
    SUBSYSTEM=usb_host
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
    PHYSDEVPATH=/devices/platform/musb_hdrc
    PHYSDEVDRIVER=musb_hdrc
    PWD=/
    PHYSDEVBUS=platform
    ACTION=remove
    HOME=/
    SEQNUM=421
    DEVPATH=/module/g_ether
    SUBSYSTEM=module
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
    PWD=/
    

  • Attached is an archive of all the files mentioned in the previous post.  I didn't realize forum only allows one file per post.

    3660.hotplugging.zip

  • Found this post indicating that hot plug is not functional in musb driver in kernel ver 2.6.31, but may be fixed in 2.6.33

    http://gumstix.8.n6.nabble.com/USB-OTG-not-working-as-host-td662224.html


    On Thu, Jan 7, 2010 at 12:46 PM, zachlac <[hidden email]> wrote: 

    > I'd like to have two free USB ports, the normal Host port and the OTG port as 
    > a second host port.  The first host port works properly, but when I plug a 
    > slave device into the OTG port, nothing happens.  No messages on dmesg. 
    > It's configured in the kernel as Host through the linux-omap3-2.6.31.bb 
    > recipe.  Is there a module I need to load?  I'm using the Overo Water with 
    > the Tobi board. 

    On the musb (OTG) port devices must be plugged in at boot time to be 
    recognized -- hot plug is not yet functional. 

    I believe that this should be fixed in the 2.6.33 musb driver, but I 
    haven't verified that yet. 

    Steve 


  • That's a good find.  I'm going to move this thread over to our Linux forum so we can get some commentary from the USB developers.

  • FYI, I'm still trying to get this in front of the right person.

  • David,

    musb controller while in OTG mode is known to switch of the SESSION when the device is disconnected and later reconnecting the device would not get detected on their own. One has to restart the session using either of below command available in particular kernel version:

    1) echo F > /proc/driver/musb_hdrc

    2) echo 1 > /sys/platform/devices/musb_hdrc/srp

    We have created a patch to resolve the same for v2.6.37 based TI PSP 04.02.00.07 release available at http://arago-project.org/git/projects/?p=linux-omap3.git;a=shortlog;h=refs/heads/OMAPPSP_04.02.00.07.

    The patch is attached here:

    3252.0001-usb-musb-omap-auto-vbus-control-across-host-and-devi.patch.txt

    This patch would not apply on v2.6.27 as there have been lot of changes in musb driver in v2.6.37.

    Ajay

  • Thanks for the response Ajay.  My only concern is I don't get a hot plug event when the device is initially connected.  I only get hot plug events when the driver is installed and uninstalled.  Does this work around cause a hot plug event for initial device connection?

  • Yes, this patch will help.

    Ajay

  • Ajay,

    One of my customers is facing a similar issue, summary of the problem is captured below:

    ---

    We need to get hot-plug event with AM37x EVM as USB Gadget. There is requirement to mount/unmount encrypted file system (dm-crypt) in USB Mass Storage mode on the USB Plugin/out events.

    We do NOT get any hotplug event when plugging device into or removing from host PC via USB cable).

    • Peripheral mode is enabled
    • Only using in device mode (connecting to host PC via HUSB_OTG port and using Windows Mass Storage driver)
    • Hotplug events only when g_file_strorage or g_mass_storage modules installed or removed
    • Needing hotplug to detect device connection and removal from host PC to mount/unmount via cryptsetup; cryptsetup part is working; just can't get hotplug events from kernel
    • For debugging, there is a bash script that just dumps the env vars to a log file when a hotplug event occurs 'echo /usr/hotplug/hpdbg.sh > /proc/sys/kernel/hotplug'

    Attached is the:

    • kernel cfg
    • bash shell script that is run when a hotplug event occurs
    • log files for hotplug events when installing/removing g_file_strorage or g_mass_storage driver
    • dmesg log
    ----------

    They have also tried the patch, enabling the OTG, mentioned in this link but no difference observed in behavior. Can you help?

    Thanks.

  • Hi,

    I have tried a patch for the usb connection detection and it is working in android.

    The following sysfs entry is changed whenever a host/peripheral connected

    /sys/devices/platform/musb-omap2430.0/musb-hdrc.0/mode

    In kernel, whenever the sysfs entry is changed we pass a uevent with this patch

    diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
    index efef5ff..2c240e1 100644
    --- a/drivers/usb/musb/musb_core.c
    +++ b/drivers/usb/musb/musb_core.c
    @@ -1894,6 +1894,7 @@ static void musb_irq_work(struct work_struct *data)
    if (musb->xceiv->state != old_state) {
    old_state = musb->xceiv->state;
    sysfs_notify(&musb->controller->kobj, NULL, "mode");
    + kobject_uevent(&musb->controller->kobj, KOBJ_CHANGE);
    }
    }

    The android vold (volume deamon) service listen to this uevent notification and does the required things. The android patch is available at 

    http://gitorious.org/rowboat/system-vold/commit/ea55061d003609eecafd26e62ea4e8786f3866df