Details

Problem:
Can no longer charge my 30Gig iPod Video device with a connector that plugs directly into the wall

Additional Information:
-If I boot into emergency disc mode (hold down select and play on reboot), the device will still charge so I do not think it is an issue with my hardware, or with my AC adapter
-This has worked in Rockbox before, but I don't typically charge this way so I don't know when this broke.
-Originally there was a patch I needed to apply to make this type of charging work. At some point, it started working in Rockbox proper. Then, apparently, it broke again.
-I can go back to older builds if someone needs help narrowing down when this broke
-Charging via a USB port appears to work fine.

This task depends upon

Closed by Torne Wuff (torne)
Sunday, 06 June 2010, 13:08 GMT Reason for closing: FixedAdditional comments about closing: USB charging works as of r26626. The
GPIO manipulation is based on
dreamlayers' patch here, but it
uses the new USB charging framework
instead of just always enabling it.

I hooked measured USB charging current on a 5th generation 30 gig iPod. Only the ground and +5V lines were connected. When running Rockbox r16819, charging current was just under 100mA. When running the original firmware, version 1.3 (latest) the iPod drew 0.42A.

I also felt that USB charging from my computer was too slow in Rockbox when I plugged in USB while holding MENU so Rockbox stays running normally. I didn't measure the current but based on charge rate I'm willing to bet it's limited to 100mA. In Device Manager in Windows Vista, the power tab for that particular USB hub on the motherboard showed that the iPod had requested 500mA, but that doesn't control how much it uses.

I haven't tested this in a while but with a AC charger plugged into my iPod with Rockbox booted, the iPod seemed to not get any noticable power from the AC adapter. Certainly not enough to charge the battery or run solely off of the AC adapter.

I do believe it is still active. I have a 80gig iPod 5.5G and cannot charge via USB, AC or car charger. The iPod indicates that it is being charged but it is actually discharging. It charges perfectly when booted with the original iPod sw. I have ver 19376 installed.

I will say that something happened in the r192xx builds that made charging awesome. It's been the best and fastest I've ever seen it. Plus, theres a new icon at the top when you're connected. I've got 0 issues on my iPod 4G Color. I have yet to run anything after r19320-ish.

What happens if the iPod is connected to USB or a charger when it's off, so the original firmware in flash sees it while starting up? It may configure hardware properly for USB charging then. (Doing this test with USB connected may require a custom build which doesn't go into USB mode.)

BTW. I think GPIOD & 8 may be used as the USB charger detection input on 4G and other earlier iPods.

Here is an *experimental* and *untested* patch which enables USB charging on 4G, Color/Photo, 5G/5.5G, Mini 2G and Nano 1G iPods. I've double-checked the port bits and I made sure it compiles[*]. The patch implements HAVE_USB_CHARGING_ENABLE Rockbox functionality. You need to define that in order for the new code to be included. You'll get an option at Settings -> General Settings -> System -> Battery -> Charge During USB Connection. I don't know if it's better to only enable this while USB power is available.

IMPORTANT: The OF does charger detection based on voltages found on USB data lines. This code just enables charging blindly. Only connect USB power sources which can supply over 500 mA or 0.5 A. Don't try charging from unpowered hubs or chargers which have lower ratings.

You should be able to quickly verify charging via System -> Debug -> View Battery. On 5G and 5.5G iPods, you could also use FS#9728 .

[*] On the Nano, you need to define CONFIG_CHARGING for the necessary language entry to be built. I think the Nano ought to be compatible with setting CONFIG_CHARGING to CHARGING_SIMPLE, but I don't know why that is commented out.

Thanks for pointing that out. Using usb_allowed_current() seems right, but I'm not sure about the way the function is implemented in http://svn.rockbox.org/viewvc.cgi/trunk/firmware/usbstack/usb_core.c?view=markup (see end of file). Why is 500 mA conditional on usb_state == CONFIGURED? Does that mean the USB code will refuse to connect to ports which cannot supply 500 mA? It should be possible to connect iPods to 100 mA ports. What about USB chargers which are capable of supplying 500 mA? (They typically aren't a USB host.) Is it safe to assume that 500 mA is available if there is USB power but no USB data connection (eg. a timeout or PORTSCX_LINE_STATUS_UNDEF)? Apple detects USB chargers by measuring voltages on USB data lines via the PCF ADC and I guess Rockbox might have to do that?

The current patch is just to confirm that USB charging works when these bits are set. On 4G/Color/Photo/5G/5.5G iPods it would also be useful to confirm that if the third bit is zero, current is limited to 100 mA.

There's actually no clean way to do this. Most OSes only support a single configuration (i.e. they always choose the first one), so if you ask for 500mA and it's not available you can't connect, while if you only ask for 100mA you're guaranteed to connect but you don't get a useful amount of power. One way to handle this could be to ask for 500mA, and if we don't get it disconnect (not sure how, maybe just reset the controller?) and try again at 100mA (and don't charge).

To distinguish between a USB connection and a pure power connection we look for bus traffic, i.e. if there's no bus reset within some time after connecting, we assume a charger (and therefore 500mA)

Talk to Michael Sevakis (jhMikeS on IRC) for the details, he did the gigabeat S charging code and the current iteration of the USB connection init code.

Something important I forgot to consider: Has it been confirmed that charging is hardware-controlled on iPods?

It's definitely hardware-controlled on the 5G, via the LTC4066 chip. The 1G Nano has an LTC4066 and 1G Mini has an LTC4055. Those are probably used for charging, although that needs to be confirmed. What about the 4G, Color, Photo and 2G Mini?

I was looking at this bug as a USB power issue, not a charging issue. It seems nobody complains about FireWire charging, and the bits changed in the patch deal with enabling use of USB power and setting the USB current limit. They seem irrelevant for FireWire charging.

While updating the patch to use usb_allowed_current(), I thought of another concern: iPod accessories. Maybe Apple told accessory makers that if they present certain voltages at USB data pins, iPods won't use more than a certain amount of current. It's impossible to be sure that every iPod accessory which supplies power to the iPod has proper overcurrent protection, so it is necessary to assume that exceeding the limit can cause damage. If you want to charge from USB chargers, iPod charger detection is necessary. I guess there shouldn't even be any setting which overrides that.

I think we shouldn't let the usb_allowed_current() issue hold us back. We have lots of targets that don't check for power allowance when connected, and we can't even fix that on half of them. It should be fixed eventually of course, but I think getting working charging is pretty important.

The question about charging being hardware-controlled remains of course. Is there any news on that?

If you can connect to a low power hub with this setting on, then your OS/hub is broken.

Rockbox's USB stack requests 500mA from the host, and if it's connected to a hub which cannot provide 500mA on the port (which should include *all* bus powered hubs; only self powered hubs can do 500mA) then the connection *should* fail; if it doesn't then your operating system is doing USB wrong. Furthermore, when it actually starts drawing 500mA the hub should at minimum switch off the port it's attached to, or switch itself off entirely, to preserve itself. If this does *not* happen then your hub is faulty ;)

USB charging should now work on all iPods. Currently, setting USB charging to "on" means it will charge at full speed when connected to a USB host (i.e. a PC). To charge at full speed with an AC adapter, you need to set USB charging to "force". I will investigate how to positively identify the Apple charger in the future.