mkorenkov / ipad_charge

charge Apple devices under Ubuntu Linux
GNU General Public License v2.0
258 stars 72 forks source link

500ma doesn't work, but 1600 and 16000 work #45

Open CyberShadow opened 6 years ago

CyberShadow commented 6 years ago
  1. This is missing in set_charging_mode:

    if ((ret = libusb_set_configuration(dev_handle, 1)) < 0) {
        fprintf(stderr, "ipad_charge: unable to set device configuration: error %d\n", ret);
        fprintf(stderr, "ipad_charge: %s\n", libusb_strerror(ret));
        return ret;
    }

    ipad_charge needs to set the configuration, as otherwise libusb_claim_interface fails with error -5 (not found), because (AIUI) an unconfigured device has no interfaces.

  2. The 500ma value for libusb_control_transfer didn't work for the charging port on my Sony Vaio SVS15123CXB (it would only show the charging icon for a split-second then revert to "not charging"), but upping it to 1600 worked. 16000 also worked.

Tatsh commented 6 years ago

Without configuration, your device should be delivering 500 mA. This is the safest value for USB 2 ports, and the safest value to avoid damaging the (USB 2.0) device.

We should only be defaulting to 2 W/500 mA because although iPads need more, the standard on USB 2.0 only covers 2 W/500 mA. USB 3 makes it 900 mA, which could account for the iPad Pro but I don't believe this is enough.

Anything above 12 W should be considered out of scope because Apple does not sell such adapters. My pull request #48 allows setting an AMPS environment variable to adjust the current after the first 500 mA, up to a total of 2400 mA which is what the majority of USB charges max out at.

There's a reason a warranty can never be provided for this code. Every system is different and most systems nowadays will tolerate the higher current while others will fail (especially older systems). Some will try and then fail (accepting stupidly high values), which may damage the USB ports or at least force you to de-charge the capacitors completely (usually by shutting off and unplugging for about 30 seconds). This could also damage the device and you may not know it until you try to turn it on again. This is probably the reason Apple doesn't really support charging the iPad with non-Macs, and sometimes iPads will not charge on a Mac either.