Consider a USB 2.0 device that can be powered either from the bus, from an external power supply, or from both simultaneously. The source of power can be switched at run time while USB is operating. The maximum current consumption is known and does not exceed the 500 mA limited by USB 2.0.

Should such a device report itself to the host as self-powered or bus-powered?


2 Answers 2


If it is capable of being bus-powered, then I would report it as such. The end result of the power negotiation is a maximum that you're not allowed to exceed, but you don't actually have to use it. (The maximum power is rarely enforced, but every once in a while it is.)

To make your device a bit smarter, and if you don't mind some extra work, you might want to have two configurations, as Simon mentioned. The tricky part would be to determine what to do if you're in self-power mode and you lose the external power. You're not allowed more than 2mA from the bus without dropping off the bus and re-enumerating (which may not succeed in giving you more power), and you just lost your supply to do your intended function. So now what?


It would report two configurations, one of them self-powered (implicit 2mA), the other bus powered (500mA). The device would refuse to enter the self-powered configuration when the external power supply is not connected.

This means that if there is less than 500mA available, e.g. because the device is connected behind a bus powered hub, the host would eliminate the bus-powered configuration and attempt to set the self-powered one. If the external supply is present, this succeeds; if it is missing, configuration fails, as it should because there is insufficient power.

Ideally, you'd put the bus powered configuration first; this becomes the preferred configuration. If the device is bus powered and the external supply connected, that is fine, and no change of configuration is needed, and the external supply can be removed later on with no issues as well. If the self powered configuration is active, the device may not draw power from the bus, so disconnecting the power supply requires you to shut down the device and force re-enumeration by disconnecting the sense resistor.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.