Quantcast

USB OTG on post v3.0 kernels.

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

USB OTG on post v3.0 kernels.

Frank Agius
I'm having a problem with USB host mode on the OTG port with kernels
that are post v3.0.  My harware is an Overo earth on a Chestnut board,
but I think the problem applies to other hardware as well. With a v3.0
kernel and a usb 2.0 hub connected (with the proper cable) to the OTG
port, the system boots and all the devices on the hub are recognized.
With post v3.0 kernels (I've tried everything up to and including
Steve's omap-3.2 branch), nothing connected to the OTG port is
recognized.  I tracked the issue to a set of USB commits that were
applied to the mainline kernel on July 26th 2011. The changes removed
the configuration options for setting driver mode on the OTG port.
Previously, the usb driver mode would be set by configuration options to
host or peripheral or OTG.  After the commits, the concept of driver
mode was dropped and code was always compiled for OTG support. I don't
think there is a problem with these changes, but it uncovered a flaw in
the musb driver.  In the musb_init_controller function, there is code to
activate in host mode, but the activation is deferred if OTG is enabled.
  The comments say that if this is OTG, the activation takes place when
the gadget driver hooks up.  The real problem is that there is no
activation in the gadget driver.  So the musb driver is enabled in
peripheral mode and it stays there forever.

I don't know the usb drivers well enough to suggest a fix there.  As I
needed a work around, I found that I could set the driver mode to host
mode in the board-overo.c file.  This change allowed the OTG port to
function correctly in host mode for post v3.0 kernels.

Here's the patch I applied to the omap-3.2 kernel tree.

diff --git a/arch/arm/mach-omap2/board-overo.c
b/arch/arm/mach-omap2/board-overo.c
index 960993f..b91dd72 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -364,6 +364,12 @@ static struct mtd_partition overo_nand_partitions[] = {
         },
  };

+static struct omap_musb_board_data musb_board_data = {
+       .interface_type         = MUSB_INTERFACE_ULPI,
+       .mode                   = MUSB_HOST, /* change to MUSB_OTG when
working */
+       .power                  = 100,
+};
+
  static struct omap2_hsmmc_info mmc[] = {
         {
                 .mmc            = 1,
@@ -671,7 +677,7 @@ static void __init overo_opp_init(void)
         defined (CONFIG_USB_MUSB_HDRC_MODULE)
  static inline void __init overo_init_musb(void)
  {
-       usb_musb_init(NULL);
+       usb_musb_init(&musb_board_data);
  }
  #else
  static inline void __init overo_init_musb(void) { return; }




frank


------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: USB OTG on post v3.0 kernels.

Thots
The work around works for me too.  I was having a hard time trying to get the OTG port working once I switched to Sakoman's 3.2 kernel.  The OTG port had worked great on an earlier version of the kernel.  

Frank, thanks for the temporary fix.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: USB OTG on post v3.0 kernels.

JamesAng
Hi,

So what are the opinions to Steve's 3.2 kernel? It's stable enough (with Frank's patch)?

James Ang.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: USB OTG on post v3.0 kernels.

Steve Sakoman
In reply to this post by Thots
On Wed, Feb 15, 2012 at 3:30 PM, Thots <[hidden email]> wrote:
> The work around works for me too.  I was having a hard time trying to get the
> OTG port working once I switched to Sakoman's 3.2 kernel.  The OTG port had
> worked great on an earlier version of the kernel.
>
> Frank, thanks for the temporary fix.

I haven't seen this issue -- the musb port seems to work in both host
& peripheral mode depending on whether the USB ID pin is grounded with
a proper OTG cable (for host mode) or a gadget driver module loader
for peripheral mode.

Perhaps we have different CONFIG options?

Could you try using my prebuilt uImage to see if that works for you:

http://feeds.sakoman.com/feeds/yocto/images/omap3-multi/current/

Steve

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: USB OTG on post v3.0 kernels.

Frank Agius
On 2/16/2012 12:49 AM, Steve Sakoman wrote:

> On Wed, Feb 15, 2012 at 3:30 PM, Thots<[hidden email]>  wrote:
>> The work around works for me too.  I was having a hard time trying to get the
>> OTG port working once I switched to Sakoman's 3.2 kernel.  The OTG port had
>> worked great on an earlier version of the kernel.
>>
>> Frank, thanks for the temporary fix.
>
> I haven't seen this issue -- the musb port seems to work in both host
> &  peripheral mode depending on whether the USB ID pin is grounded with
> a proper OTG cable (for host mode) or a gadget driver module loader
> for peripheral mode.
>
> Perhaps we have different CONFIG options?
>
> Could you try using my prebuilt uImage to see if that works for you:
 >
 > http://feeds.sakoman.com/feeds/yocto/images/omap3-multi/current/

Your prebuilt image does not boot on an omap3530.  The system hangs
after printing the message "Uncompressing Linux... done, booting the
kernel".  This is most likely due to the bug I recently reported
regarding the check and enabling of 720Mhz mode.  To avoid this problem,
in my tree I put in a patch to disable to check:

diff -urN a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
--- a/arch/arm/mach-omap2/id.c  2012-01-25 17:44:26.563802513 -0500
+++ b/arch/arm/mach-omap2/id.c  2012-01-25 17:44:33.560015249 -0500
@@ -200,6 +200,7 @@
          *       e.g. Size of L2 cache.
          */

+#if 0
         /*
          * Does it support 720MHz?
          */
@@ -208,6 +209,7 @@
         if (status & OMAP3_SKUID_720MHZ) {
                 omap_features |= OMAP3_HAS_720MHZ;
         }
+#endif
  }

I tried again with an omap3503 and your prebuilt image.  The system
booted, but the musb port does not work in host mode.  I have tried
several different USB cables (mini-B to mini-A, purchased from Gumstix),
but the host mode does not function.

I cannot explain why host mode works in your setup, but not my setup
(and apparently at least one other). I have exhaustively verified that
host mode on my hardware worked prior to the USB commits in July.  Are
there any board hardware mod needed to make USB OTG work?

frank




------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: USB OTG on post v3.0 kernels.

Steve Sakoman
On Thu, Feb 16, 2012 at 5:42 AM, Frank Agius <[hidden email]> wrote:

> On 2/16/2012 12:49 AM, Steve Sakoman wrote:
>>
>> On Wed, Feb 15, 2012 at 3:30 PM, Thots<[hidden email]>  wrote:
>>>
>>> The work around works for me too.  I was having a hard time trying to get
>>> the
>>> OTG port working once I switched to Sakoman's 3.2 kernel.  The OTG port
>>> had
>>> worked great on an earlier version of the kernel.
>>>
>>> Frank, thanks for the temporary fix.
>>
>>
>> I haven't seen this issue -- the musb port seems to work in both host
>> &  peripheral mode depending on whether the USB ID pin is grounded with
>> a proper OTG cable (for host mode) or a gadget driver module loader
>> for peripheral mode.
>>
>> Perhaps we have different CONFIG options?
>>
>> Could you try using my prebuilt uImage to see if that works for you:
>
>>
>> http://feeds.sakoman.com/feeds/yocto/images/omap3-multi/current/
>
> Your prebuilt image does not boot on an omap3530.  The system hangs after
> printing the message "Uncompressing Linux... done, booting the kernel".
>  This is most likely due to the bug I recently reported regarding the check
> and enabling of 720Mhz mode.  To avoid this problem, in my tree I put in a
> patch to disable to check:
>
> diff -urN a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
> --- a/arch/arm/mach-omap2/id.c  2012-01-25 17:44:26.563802513 -0500
> +++ b/arch/arm/mach-omap2/id.c  2012-01-25 17:44:33.560015249 -0500
> @@ -200,6 +200,7 @@
>         *       e.g. Size of L2 cache.
>         */
>
> +#if 0
>        /*
>         * Does it support 720MHz?
>         */
> @@ -208,6 +209,7 @@
>        if (status & OMAP3_SKUID_720MHZ) {
>                omap_features |= OMAP3_HAS_720MHZ;
>        }
> +#endif
>  }
>
> I tried again with an omap3503 and your prebuilt image.  The system booted,
> but the musb port does not work in host mode.  I have tried several
> different USB cables (mini-B to mini-A, purchased from Gumstix), but the
> host mode does not function.
>
> I cannot explain why host mode works in your setup, but not my setup (and
> apparently at least one other). I have exhaustively verified that host mode
> on my hardware worked prior to the USB commits in July.  Are there any board
> hardware mod needed to make USB OTG work?

Wow, this is even stranger, since I haven't seen a booting issue on my
3530 systems either!

When you tested my kernel did you also use my MLO/u-boot (i.e. by
preparing the boot sd card with the mksdcard script)?

I'm at the Embedded Linux Conference this week, so I don't have access
to all of my equipment.  It may be that I won't be able to fully
explore this until I return to the office.

Steve

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: USB OTG on post v3.0 kernels.

Frank Agius
On 2/16/2012 10:06 AM, Steve Sakoman wrote:

>
> Wow, this is even stranger, since I haven't seen a booting issue on my
> 3530 systems either!
>
> When you tested my kernel did you also use my MLO/u-boot (i.e. by
> preparing the boot sd card with the mksdcard script)?
>
> I'm at the Embedded Linux Conference this week, so I don't have access
> to all of my equipment.  It may be that I won't be able to fully
> explore this until I return to the office.
>

Steve,

So there are two separate issues, one with the 720Mhz detection and the
other with usb host mode.

1) 720Mhz hang on 3530 - Running with your MLO/u-boot, the 720Mhz
detection hang is still present.  Interestingly, the same code does not
hang on a more recently purchased 3730.  Here is the u-boot info on the
two boards, running with your current MLO/u-boot/kernel:

a) hangs
   U-Boot 2011.12-00010-gc99c7d5 (Feb 13 2012 - 09:21:07)
   OMAP3530-GP ES3.1, CPU-OPP2, L3-165MHz, Max CPU Clock 720 mHz
   Gumstix Overo board + LPDDR/NAND

b) boots
    U-Boot 2011.12-00010-gc99c7d5 (Feb 13 2012 - 09:21:07)
    OMAP3630/3730-GP ES1.2, CPU-OPP2, L3-165MHz, Max CPU Clock 1 Ghz
    Gumstix Overo board + LPDDR/NAND

2) usb host mode - Initially, it appeared that your code had the same
usb host problem.  After booting, none of the devices on the OTG port
were recognized. However, I have been discussing the problem offline
with Felipe Balbi, who committed the usb changes last July.  He said
that a gadget driver must be loaded in order for host mode to be
activated.  I did a  modprobe of a random gadget driver (modprobe
g_ether) and host mode was activated.  My hub and all its devices were
recognized!  But I consider this a work around.  In my application, my
device is never going to be in peripheral mode.  So I should not be
required to load a random gadget driver in order for host mode to
operate.  Also, there is now an unconditional dependency on gadget
driver kernel code.  If  you remove gadget driver (say to reduce kernel
file size), host mode will never be able to start.

frank


------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: USB OTG on post v3.0 kernels.

paul@idruna.com
Frank,

> 2) usb host mode - Initially, it appeared that your code had the same
> usb host problem.  After booting, none of the devices on the OTG port
> were recognized. However, I have been discussing the problem offline
> with Felipe Balbi, who committed the usb changes last July.  He said
> that a gadget driver must be loaded in order for host mode to be
> activated.  I did a  modprobe of a random gadget driver (modprobe
> g_ether) and host mode was activated.  My hub and all its devices were
> recognized!  But I consider this a work around.  In my application, my
> device is never going to be in peripheral mode.  So I should not be
> required to load a random gadget driver in order for host mode to
> operate.  Also, there is now an unconditional dependency on gadget
> driver kernel code.  If  you remove gadget driver (say to reduce kernel
> file size), host mode will never be able to start.

Thank you for this tip, I was wondering why my OTG port wasn't working
with the 3.2 kernel.

--
Paul Nolan, CEO Idruna Software Inc.

------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: USB OTG on post v3.0 kernels.

EasyVictor
In reply to this post by Steve Sakoman
Steve Sakoman wrote
Wow, this is even stranger, since I haven't seen a booting issue on my
3530 systems either!

When you tested my kernel did you also use my MLO/u-boot (i.e. by
preparing the boot sd card with the mksdcard script)?

I'm at the Embedded Linux Conference this week, so I don't have access
to all of my equipment.  It may be that I won't be able to fully
explore this until I return to the office.
Steve
Hi all, I am also running an Overo as a OTG host and have had the same problems as others on this thread.  My two reference points are the 2.6 and 3.2 kernels.  On 2.6.36, my OTG peripheral always was recognized on boot.  On 3.2, the Overo never saw the peripheral.  I was lost until I stumbled upon this thread, and found that I could use "modprobe g_ether" to load the driver and cause the enumeration to succeed.   I also used Frank's patch to correct the issue (and that worked, thanks!), but I still have concerns.

Has there been any progress on this issue since then?  While forcing host mode works for now, I can't imagine it's a good long term solution.  I don't have to option to communicate with the Overo every time to force the modprobe, and inserting that in a script seems clunky.   Ideally it should recognize either types of devices on boot automatically.

I have considered it being hardware related but the fact that it works on 2.6 makes me doubt that, unless my 2.6 kernel was forcing host mode as well.

Any response is appreciated!

Jonathan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: USB OTG on post v3.0 kernels.

Frank Agius
On 5/12/2012 8:51 AM, EasyVictor wrote:
> Has there been any progress on this issue since then?
None that I am aware of.

> While forcing host
> mode works for now, I can't imagine it's a good long term solution.  I don't
> have to option to communicate with the Overo every time to force the
> modprobe, and inserting that in a script seems clunky.   Ideally it should
> recognize either types of devices on boot automatically.
One alternative is to configure and build the kernel with a gadget
driver built in.  If the kernel has a built in gadget driver, then both
host mode and gadget mode will work properly without the need to load
additional kernel modules.  The practical downside of this approach is
that the kernel is slightly larger than it needs to be.  The
philosophical downside is that you're adding code for gadget mode that
may never be needed by your application.  There are several gadget
drivers to choose from, but the simplest is the usb ethernet gadget
driver.  Here are the kernel config menu selections:

       Device Drivers  --->
         [*] USB support  --->
             <*>   USB Gadget Support  --->
                <*>   USB Gadget Drivers (Ethernet Gadget (with CDC Ethernet suppx x
   x x            Ethernet Gadget (with CDC Ethernet support)

This should result in the following options in the .config file:

CONFIG_USB_GADGET=y
# CONFIG_USB_GADGET_DEBUG is not set
# CONFIG_USB_GADGET_DEBUG_FILES is not set
# CONFIG_USB_GADGET_DEBUG_FS is not set
CONFIG_USB_GADGET_VBUS_DRAW=2
CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS=2
# CONFIG_USB_FUSB300 is not set
# CONFIG_USB_R8A66597 is not set
# CONFIG_USB_M66592 is not set
# CONFIG_USB_AMD5536UDC is not set
# CONFIG_USB_CI13XXX_PCI is not set
# CONFIG_USB_NET2272 is not set
# CONFIG_USB_NET2280 is not set
# CONFIG_USB_GOKU is not set
# CONFIG_USB_LANGWELL is not set
# CONFIG_USB_EG20T is not set
# CONFIG_USB_DUMMY_HCD is not set
# CONFIG_USB_ZERO is not set
# CONFIG_USB_AUDIO is not set
CONFIG_USB_ETH=y

>
> I have considered it being hardware related but the fact that it works on
> 2.6 makes me doubt that, unless my 2.6 kernel was forcing host mode as well.
It is not hardware related.  It is solely due to the July 2011 kernel
changes in the USB device drivers.

>
> Any response is appreciated!
>
> Jonathan
>
>
> --
> View this message in context: http://gumstix.8.n6.nabble.com/USB-OTG-on-post-v3-0-kernels-tp4473952p4964303.html
> Sent from the Gumstix mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

frank


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: USB OTG on post v3.0 kernels.

hobbesc7
Frank Agius wrote
Here are the kernel config menu selections:

       Device Drivers  --->
         [*] USB support  --->
             <*>   USB Gadget Support  --->
                <*>   USB Gadget Drivers (Ethernet Gadget (with CDC Ethernet suppx x
   x x            Ethernet Gadget (with CDC Ethernet support)

This should result in the following options in the .config file:

CONFIG_USB_GADGET=y
# CONFIG_USB_GADGET_DEBUG is not set
# CONFIG_USB_GADGET_DEBUG_FILES is not set
# CONFIG_USB_GADGET_DEBUG_FS is not set
CONFIG_USB_GADGET_VBUS_DRAW=2
CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS=2
# CONFIG_USB_FUSB300 is not set
# CONFIG_USB_R8A66597 is not set
# CONFIG_USB_M66592 is not set
# CONFIG_USB_AMD5536UDC is not set
# CONFIG_USB_CI13XXX_PCI is not set
# CONFIG_USB_NET2272 is not set
# CONFIG_USB_NET2280 is not set
# CONFIG_USB_GOKU is not set
# CONFIG_USB_LANGWELL is not set
# CONFIG_USB_EG20T is not set
# CONFIG_USB_DUMMY_HCD is not set
# CONFIG_USB_ZERO is not set
# CONFIG_USB_AUDIO is not set
CONFIG_USB_ETH=y
I've tried this but my usb port doesn't seem to recognize anything plugged into it.  I'm using  an Overo Fire + Tobi.  Usually, dmesg will at least recognize that something is plugged in to the main USB port on the Tobi even if I don't have the right .ko driver built.

Is there something else in the 3.2.0 kernel I need to turn on to get USB to just basically work?
CJ
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: USB OTG on post v3.0 kernels.

CJ
In reply to this post by Frank Agius
It appears that this issue still exists in the current Mainline 3.6 Kernel - is that correct?

At any rate, I am using 3.2.30 and I am pretty sure I have OTG in HOST mode - see:

musb-hdrc: version 6.0, ?dma?, otg (peripheral+host)
musb-hdrc musb-hdrc: MUSB HDRC host driver
musb-hdrc musb-hdrc: new USB bus registered, assigned bus number 1
usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: MUSB HDRC host driver
usb usb1: Manufacturer: Linux 3.2.30x14 musb-hcd
usb usb1: SerialNumber: musb-hdrc
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
musb-hdrc musb-hdrc: USB Host mode controller at fa0ab000 using DMA, IRQ 92

Problem is that the modem I have connected  is not recognised.
It should bring up ttyUSB0 but nothing shows up and lsusb produces no device ID.

It works fine in 3.0.7 which was before the changes made to the kernel mentioned above.

Any ideas what this could be and how I could trouble shoot it?
Anyone else still having problems here?

Cheers
CJ
Loading...