Re: Enumerating USB devices in the Bootloader

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 10, 2020 at 3:12 PM Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:
>
> On Mon, 10 Feb 2020, Martin Townsend wrote:
>
> > Hi,
> >
> > We are using the USB mass storage gadget driver in Linux and
> > everything is working fairly well but sometimes we are finding that we
> > are exceeding the 100mA limit (which I think is the default the host
> > will provide) before Linux has had a change to enumerate the USB
> > device at which point we ask for 500mA.  We have tried to reduce the
> > power by ensuring all clocks are turned off, devices not used disabled
> > etc but can't seem to satisfy the 100mA limit.  We were thinking that
> > maybe we could enumerate the USB device during U-Boot at which point
> > we know we are under the 100mA limit.  Does anyone know a reason why
> > this would not work?
>
> It won't work because U-Boot isn't the kernel.  When the kernel takes
> over the USB controller, it will force the host to re-enumerate the
> gadget -- and you will be right back where you started.
>
> The only way to make this work would be to prevent U-Boot from ever
> actually booting the Linux kernel.  This probably isn't the way you
> want your device to behave, though.
>
> > would at some point from U-Boot enumerating a new
> > bMaxPower would the connection be reset and drop back to 100mA during
> > the kernel startup? Are there any considerations that we would need to
> > take care of in the kernel for this to work?
>
> If you can't satisfy the 100-mA current limit then you should make your
> device be self-powered instead of relying on power delivered over the
> USB bus.
>
> Be aware also that bus-powered USB-2 hubs can't deliver 500 mA to their
> downstream ports.  They are always limited to 100 mA or less.  If your
> gadget was plugged into one of them, it wouldn't be able to work at
> all.
>
> Alan Stern
>

Alan,
Thank you for the swift response.  On the first point, if we modify
the kernel to re-enumerate the same bMaxPower of 500mA would this
still be a problem? ie is there a period when the kernel takes over
the USB controller that the Host side would go back to 100mA after
U-Boot negotiates the 500mA?  The last point you make is a very good
one and something I hadn't thought of. If we can overcome the first
hurdle I think we would be happy for it to be a requirement for the
device to be plugged directly into a PC.



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux