On 26 March 2013 18:50, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote: > On Tue, 26 Mar 2013, David Linares wrote: > >> >> The device I am working on is an embedded device, therefore the wireless >> >> adapter has to be connected to the internal hub. This hub and the whole device >> >> are powered via an usb cable. >> > >> > Oh. Then maybe the USB cable doesn't provide enough power to run both >> > the embedded device and the wireless adapter. > >> There are 2 ports, so does the hub provide 500mA per port or in total? >> If that's 500mA for each port, that's fine. > > You seem to be missing the point. You said above that your entire > device is powered via a USB cable. That means the entire device gets > only 500 mA, total. If the hub sends 500 mA out one of its ports then > there will be nothing left for the other port and nothing left for the > rest of your device. > Thanks Alan. I understand, but the USB cable is plugged into an AC/DC adaptor which can provide an output of 1A. After breaking out an USB cable, I measured that the consumption of my board is around 130mA (nothing connected to the hub). Then I measured with the dongle plugged in. The real consumption of the wireless adapter is around 210mA. The whole thing draws around 340mA > Of course, the way it works in reality is that the device uses a > significant fraction of the total current, leaving a lot less than 500 > mA available for the hub. For example, the hub may get only 200 mA. > There's no way it can take that input and magically convert it to 500 > mA for each of two ports. > >> I have done some progress on my side. I have noticed that in a failing case, >> the 2-port hub is actually detected as a "standalone hub" but when it >> works fine, >> it is detected as a "compound device". >> Also printed the "hubstatus" that I get from here >> http://lxr.free-electrons.com/source/drivers/usb/core/hub.c#L1513 >> and it is really weird: >> >> - when it works, the value returned is 1, and therefore, I fall into the >> "Self-powered external hub" case >> >> - when it doesn't work, the value seems quite random (ex: 0xe6c0) and I fall >> into the 100mA limit => my Ralink wireless adapter gets a rejected config. > > That's to be expected. When there isn't enough power, you start > getting random data and things stop working. > Today, I did some further tests *without* any wireless adapter. So, I have got the device plugged in into a main power socket via USB (delivering up to 1A), the root hub, and the 2-port hub and nothing else USB-wise. The problem still happens from time to time. The 2-port hub sometimes says it will give 500mA to its children and sometimes it gives only 100mA (because of a corrupted hubstatus mentioned earlier). Now that there is nothing connected on the hub, I am just wondering how come the hub is not always detected in the same way at each boot. Also, should it be detected as "self powered" ( http://lxr.free-electrons.com/source/drivers/usb/core/hub.c#L1543 ) or not ( http://lxr.free-electrons.com/source/drivers/usb/core/hub.c#L1538 )? I forgot to mention that this issue where the hub is not detected as "self-powered external hub" is quite hard to reproduce. It happens 1 out of 20 tries. Thanks a lot Alan and everybody else. I really appreciate the support and understanding you are providing. > Alan Stern > -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html