[Gta04-owner] USB HOST(tested on 3.4) wrong power budget?

Dr. H. Nikolaus Schaller hns at goldelico.com
Mon Dec 17 08:20:55 CET 2012


Am 16.12.2012 um 17:35 schrieb Denis 'GNUtoo' Carikli:

> Hi,
> With some help and some research I was able to test USB host on 3.4.
> So I do that:
>  echo host > /sys/devices/platform/musb-omap2430/musb-hdrc/mode
> And that activates USB host.
>  echo otg > /sys/devices/platform/musb-omap2430/musb-hdrc/mode
> or:
>  echo peripheral > /sys/devices/platform/musb-omap2430/musb-hdrc/mode
> Desactivates it...
> I've also that configuration:
> However the issue is that most of the device won't work.
> For instance I've a mass storage USB key that eat 200mA...
> Changing CONFIG_USB_GADGET_VBUS_DRAW to 500mA didn't made it work
> yet.... but commenting that with if 0:
> #if 0
>                /* Rule out configs that draw too much bus current */
>                if (c->desc.bMaxPower * 2 > udev->bus_mA) {
>                        insufficient_power++;
>                        continue;
>                }
> #endif
> in drivers/usb/core/generic.c made the USB key work.
> That means that the GTA04 can probably deliver 200mA(the manual says
> 100mA) or maybe a little bit more...
> however that modification has some drawbacks...
> With a 500mA device:
> * the device can't be listed anymore with lsusb(before it could)
> * no message appear in dmesg( before a message that the device got
>   rejected appeared)
> * the device still doesn't work(like before, there is probably nothing
>   that we can do about it beside using a powered USB hub, I've tested
>   it and it works that way).
> => the VBUS voltage probably drops in that case.
> So here are the questions:
> * what's the maximum current that the VBUS can provide? 200mA? 250mA?
>   more(but less than 500mA) ?

The 5V VBUS is generated from the battery voltage (3.2 - 4.2 V) by a "charge
pump". This are some capacitors plus transistors inside the TPS65950 (TWL4030)
chip. This is limited to 100 mA to guarantee some decent output voltage.

What happens if you try to draw more? This means your device has a lower
resistance and the charge from the capacitors is flowing faster into the device.
Since the total charge per second is limited, the current is limited. This simply
means that the VBUS voltage will drop.

So you can expect e.g. 4 V at 150 mA and 3V at 200 mA etc.

Now, lsusb works by powering the external device and the external device (cilent)
must pull up one of both data lines to 3.3V to be recognized at all. Then, the host
starts communicating in low-speed mode and the host learns that the device
wants to see more than 100 mA. During this phase no device may draw more than
100 mA.

This is where software comes in and it *can* deny the request. Or it can honour it.
If it is honoured, the device is allowed to draw more current - and at that moment
its operation voltage may break down below a level of safe operation if the host
hardware is not really capable of driving what it has allowed for.

So in general you can't damage anything but you also can't fool physics, i.e.
draw more current than the charge pump provides.

There is also some intermediate situation. There may be devices that demand
e.g. 500 mA but never use them. Or they use it only in rare operation situations.

These devices may enumerate well and even work, but may fail from time to
time at the most unexpected moment...

> * is it worth to look where the power budget of the USB is defined?
>   (that is to say look for a better place than this hack.).
> * maybe the *2 in the check is wrong?

This looks like an unnecessary margin but I don't know how these values
are encoded in the kernel driver.

Hope this helps a little with your issue,

More information about the Gta04-owner mailing list