1
\$\begingroup\$

Although my use case is specific to Raspberry Pi, I think the question is a general USB Host port question.

When a phone/tablet (especially iphone and ipad) is connected to a Raspberry Pi 2, if its battery getting low, it will successfully charge from the RPi2 USB port.

The problem is, even with a 2A power supply to the RPi2, when a larger phone or tablet is charging that can wreak havoc on other USB devices or the RPi2 itself. (I discovered this by having an application start crashing but only when the RPi2 was connected to an iPhone 6S plus with a battery at 50% or less.)

I know some hubs, such as bus-powered hubs, somehow inform a connected phone "don't even try to charge yourself", so I assume there is a way to have a Raspberry Pi's USB ports do the same, eg, inform connected devices that the maximum current available is 100ma.

How can a RPi2 (or its USB port) be modified so it informs attached USB devices not to try charging from the port.

Note: I do need an active data connection, I just need to prevent the attached phone or tablet to not draw too much current for the RPi2 to handle.

\$\endgroup\$
  • \$\begingroup\$ According to the USB specs, a device shouldn't attempt to draw more than 100 mA unless it has negotiated with the host to establish that more current is available - I'm surprised to hear that an iPhone is doing what you describe. Are you connecting the iPhone with a genuine Lightning cable? You could try connecting via a bus-powered USB hub. \$\endgroup\$ – nekomatic Jan 27 '16 at 10:24
1
\$\begingroup\$

Unfortunately what you want to achieve is not possible. The USB hub chip used in RPi is configured as self-powered, so if a device requests more than 100 mA during enumeration, this request will be granted. There is no way to reconfigure the USB hub (not with standard Linux drivers anyway) to limit slave devices to 100 mA.

What you can do is to tell your iPhone how much current it should draw. In fact, there is a program which does exactly that: setting iPhone/iPad current consumption to sane values so they are not dropped out then trying to charge. It should be trivial to modify it to restrict current consumption even more, so that your iPhone doesn't crash the RPi when attempting to charge. Of course, this program is strictly iPhone/iPad specific.

Another solution, as @nekomatic has pointed out, is to plug your iPhone (or any similar device for that matter) via a bus-powered hub. However, multiple sources on the Internet advise you NOT to use bus-powered hubs with RPi, because many such hubs simply fail to enumerate correctly, or enumerate devices connected to them, due to lack of power. Still, it may be worth trying.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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