iPhone Now Charges in Linux

Update: if you would like to sync music or contacts see this post.

So I have had success getting the iPhone to charge when using Linux (I just had to figure out the magic command to let the iPhone know it should charge). After I figured out the command I then moved on to making a Linux kernel driver so that it would actually work.  I am using it as we speak and there doesn’t seem to be any issue. Very cool.

So overall it has been a very productive (but late) night. If you are interested in trying the module out you can find at its project page.

35 Comments

  1. Cutter
    Posted 08/24/2007 at 7:27 am | Permalink

    holy awesome. nice work! here is a minor makefile patch to make life a little easier:

    http://www.divinia.com/people/cutter/iphone-hack/Makefile.patch

  2. jessy
    Posted 08/25/2007 at 2:53 pm | Permalink

    kick ass! i’ve installed the module with Cutter’s patch above on ubuntu feisty fawn. as described in your HACKING file, linux initially detects the iphone, the green charging battery appears, and then it immediately ejects. but a Camera Import dialog also appears saying “A camera has been detected…” If i select “import photos”, the phone will charge (i guess it maintains the connection because it thinks you want to import photos).

    Thank you for writing this!!

  3. Cutter
    Posted 08/27/2007 at 10:22 am | Permalink

    after you’ve insmod’ed the iphone.ko you dont need to click ‘import photos’, you can just cancel it and the phone will stlil charge. If you install libgphoto2.4 you can actually import photos from the phone, fyi.

  4. Matt
    Posted 08/28/2007 at 8:25 pm | Permalink

    Hey Cutter,
    Sorry I didn’t get around to posting a comment until now. I am working with the kernel USB guys so I won’t need your first patch (as it will hopefully be in the mainline kernel). As for the gphoto stuff, I am working on backporting it to Feisty. However the iPhone likes to keep disconnecting anytime you scan it with libusb or use the gphoto stuff, I will hopefully be able to make that go away.

  5. Cutter
    Posted 08/30/2007 at 7:45 am | Permalink

    excellent. if you need any assistance testing or anything, drop me a line.

  6. Evan Wheeler
    Posted 08/31/2007 at 3:45 pm | Permalink

    Hi Matt:

    The module builds and works as advertised, thanks! I did notice that there is no readme in the tar file though. Also, I tried getting the source using Git, but it wants a password.

    Thanks,

    Evan

  7. Almighty
    Posted 09/17/2007 at 12:11 am | Permalink

    I know the iPhone isn’t supposed to charge under Linux, but I never have a problem charging it on my Ubuntu Dapper server.

  8. Posted 09/19/2007 at 4:16 pm | Permalink

    Hey, im very interested in anything you have leaned about the iPhone interface, and would love to help work on writing a driver that allows mounting of the iPhone. Maybe we can collaborate some. Good work so far, thanks!

  9. Aaron Kulbe
    Posted 09/21/2007 at 2:51 pm | Permalink

    It doesn’t compile for me, and I also noticed there is no README file included in the tarball.

    Here is the output.

    http://pastie.caboo.se/99512

  10. Matt
    Posted 09/21/2007 at 9:02 pm | Permalink

    Hey Aaron,
    I just uploaded a new tarball with the README included. Sorry about that. If you use the command included there it should just work.

  11. StebQC
    Posted 09/26/2007 at 6:34 pm | Permalink

    Great work. I just got my new iPod Touch and I was looking for a way to charge it at home. Your driver almost worked. I had to change the line 21 for “#define IPHONE 0×1291″.
    Keep up the good work

  12. Posted 09/28/2007 at 4:57 pm | Permalink

    Awesome! It was starting to seem a little shady when our iPhones failed to charge on not one, not two, but all three of our Linux systems, but they charge just fine on the Mac Mini…

    However, version 0.1 of your module fails to compile for me (gives a bunch of errors) and the link to your v0.2 is broken:

    http://mattcolyer.com/projects/iphone-module/iphone-module-0.2.tar.gz

  13. Matt
    Posted 09/30/2007 at 11:45 pm | Permalink

    Thanks for the note Anthony, the link for version 0.2 should now work. I really should double check those kind of things. (PS try the read me for how to compile it)

  14. Posted 11/02/2007 at 6:11 am | Permalink

    Good work guys. I just realized this when I booted to Ubuntu 7.04. I generally am on Gentoo and it (ipod touch) works. So I was curious if my gentoo kernel had something related to the iphone and sure enough there was.

    drivers/usb/core/quirks.c
    /* Apple iPhone */
    { USB_DEVICE(0x05ac, 0×1290), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },

    But i’ll also try out the module you wrote. Keep up the good work.

    One Q? Are all 3 interfaces you mention in the HACKING file supported simultaneously or do I need to do something on the ipod touch/iphone to make it go to that mode.

    Another Q, would it possible to directly write to the file system after mounting it over sshfs (install ssh as part of jailbreak).

  15. Matt
    Posted 11/02/2007 at 9:27 pm | Permalink

    Hi Bud,
    That line you found is actually the correct way to fix it. I ended up submitting a patch to the kernel and it was included in 2.6.23.

    As for your first question, no only one “configuration” can be active at a time. You can activate it by writing a simple C program that uses libusb.

    As for your second question, yes you should be able to use sshfs. I have heard from others that it works quite well (accept for the album art).

  16. Posted 11/03/2007 at 11:54 am | Permalink

    Hi Matt,

    Thanks for the feedback. I managed to get music and video working thanks to this howto:
    http://www.gnome.org/~teuf/README.iTouch

    Trying to get the photos uploaded (not album art) but still no luck.

  17. Posted 11/15/2007 at 12:44 pm | Permalink

    You can get the ipod touch to charge if you change the
    #define IPHONE
    line to
    #define IPHONE 0×1291
    (0×1291 is the vendor id of the ipod touch, according to lsusb)
    Great work, works perfectly. Thanks.

  18. Mark Grant
    Posted 11/23/2007 at 7:17 am | Permalink

    Very confused with the issue of charging the iphone on Linux.

    I am a linux user who just plugged in the iphone and find it charges just fine without the need for any funkyness.

    My only guess is that my system does absolutely nothing with it when I plug in the iphone. Linux see a new usb device but udev config has nothing in there to create any devices. I have no automounting or anything going on. This is how I like my machines to work. However, the iphone charges just fine.

  19. Matt
    Posted 11/24/2007 at 8:43 pm | Permalink

    Mark: For some people this wasn’t a problem so I guess you are one of the lucky ones :) .

  20. Mark Grant
    Posted 11/25/2007 at 7:30 am | Permalink

    Hi Matt.

    the more I look at this the more confused I get. I have an international power plug converter I recently bought at an airport. This has a usb socket so you can use it to charge usb devices when travelling around. I find this charges my iphone with no problem too. Now this thing has no intelligence in it at all, it is just a power plug. This suggests to me that there isn’t anything in the iphone making it difficult to charge from any specific OS (after all, it seems you don’t need an OS at all) but that maybe, some distributions are setting up Linux in a way that accidently stops it working. Perhaps sending some data to the iphone that it doesn’t like when it is initially connected. I don’t know.

    It may also be that those phones that work are ones that have been unlocked.

    I do find the problem interesting though.

  21. Charles Woerner
    Posted 11/26/2007 at 1:13 am | Permalink

    Thanks Matt, nice work. Unfortunately it appears that usb_driver_set_configuration() was introduced in the 2.6.19 kernel usb device driver subsystem. Although there are backports of this feature to 2.6.18 it might be worth noting this fact, especially for the debian users who run the stock kernel, which is still at 2.6.18 as of 2007-11-25.

    Speaking of debian users, I’ve packaged a debian source package for your kernel module. If you’re interested I can send it to you.

  22. Posted 12/03/2007 at 2:20 pm | Permalink

    Have a look at this article if you’re looking for a way to sync music with you iPhone using Amarok.

    http://blog.adaniels.nl/?p=50

  23. David
    Posted 12/22/2007 at 8:21 am | Permalink

    Thanks for sharing this module. Now I don’t have to reboot my Thinkpad to OS X to charge my iPhone! :-D

  24. Kevin
    Posted 12/28/2007 at 7:34 pm | Permalink

    Hmm.. not sure if I’m doing this wrong, I built the .ko file, copied it to /lib/modules/(kernelversion)/extras, ran update-modules –force, and then modprobe iphone. lsmod shows iphone running, but I still have no luck getting my ipod touch to charge.

  25. Matt
    Posted 12/28/2007 at 9:20 pm | Permalink

    Kevin:
    The module only works for the iPhone. If you would like it to work for the iPod touch you need to modify line 21 of iphone.c to read 1291 instead of 1290.

    I hope that helps.

  26. Ivan Ivanov
    Posted 01/27/2008 at 4:19 pm | Permalink

    Here’s a minor patch that adds support for iPod Touch.

    — iphone-orig/iphone.c 2007-09-01 22:31:41.000000000 -0400
    +++ iphone/iphone.c 2008-01-27 19:09:45.000000000 -0500
    @@ -19,6 +19,7 @@

    #define APPLE_VENDOR 0x05ac
    #define IPHONE 0×1290
    +#define IPODTOUCH 0×1291

    static int debug;

    @@ -31,6 +32,7 @@

    static struct usb_device_id id_table [] = {
    { USB_DEVICE(APPLE_VENDOR, IPHONE) },
    + { USB_DEVICE(APPLE_VENDOR, IPODTOUCH) },
    { }, /* Terminating entry */
    };
    MODULE_DEVICE_TABLE(usb, id_table);

  27. Mani
    Posted 03/04/2008 at 11:16 pm | Permalink

    Great stuff!!! Keep up the good work. I use a 2.6.23 kernel and thanks to you I can charge my iPod Touch without having to buy Windows XP or a Mac. :-)

    Regards,

    Mani
    This weeks distro: Fedora 8
    iPod Touch 8GB

  28. Hypnagogue
    Posted 07/18/2008 at 9:36 am | Permalink

    iPhone 3G has device id 1292.

    #define IPHONE_3G 0×1292

  29. Dex
    Posted 09/20/2008 at 6:33 am | Permalink

    1293 works for the new IPOD Touch (2.0):

    #define IPODTOUCH (0×1293)

  30. Sanjay
    Posted 11/25/2008 at 9:05 am | Permalink

    Or you can use a firewire cable that came with earlier (1st to 3rd I think) generation of Ipods. Iphone can be charged with that cable with any OS.

  31. Stefano Priore
    Posted 02/06/2009 at 8:53 am | Permalink

    Hi Matt,

    could you add support for the remaining iPod devices? According to today’s version of lsusb database, their product number are the following:

    1201 3G iPod
    1202 iPod 2G
    1203 iPod 4.Gen Grayscale 40G
    1204 iPod [Photo]
    1205 iPod Mini 1.Gen/2.Gen
    1206 iPod ’06′
    1207 iPod ’07′
    1208 iPod ’08′
    1209 iPod Video
    120a iPod Nano
    1260 iPod Nano 2.Gen
    1261 iPod Classic
    1290 iPhone
    1291 iPod Touch 1.Gen
    1292 iPhone 3G
    1300 iPod Shuffle
    1301 iPod Shuffle 2.Gen

    Is there any chance to see the module officially merged into the kernel?

    Ciao,

    Stefano

  32. Posted 09/05/2009 at 9:33 am | Permalink

    Has enyone tried using “eject” command on the device the ipod is on (in my case /dev/sdb) it just starts charging my ipod :)

  33. Aj
    Posted 09/08/2009 at 8:35 am | Permalink

    Guys I’m using ubuntu 8 something and I have no idea on what to do.. I downloaded the file and extract it..

    Now what please help me

    Thanks

  34. brundlefly
    Posted 11/24/2009 at 10:53 pm | Permalink

    good work! but i’m curious why iphone can’t be charged while the PC is in standby or off (i.e. acpi S3/S4/S5). i know apple had notified users do not charge iphone while the PC is in standby or off since the battery may drain. but currently most PC’s usb ports supports 5V standby, i just can’t realize why i can’t charge iphone in acpi S3/S4/S5. at least it doesn’t need to have my PC powered on just for charging the phone. any comments?

  35. Posted 08/31/2010 at 9:37 am | Permalink

    Apple now has Rhapsody as an app, which is a great start, but it is currently hampered by the inability to store locally on your iPod, and has a dismal 64kbps bit rate. If this changes, then it will somewhat negate this advantage for the Zune, but the 10 songs per month will still be a big plus in Zune Pass’ favor.

3 Trackbacks

  1. [...] 2007 in Links I used to have to boot to my Windows partition regularly to charge my iPod touch, a feature that’s been added to Ubuntu 7.10. Now I only need to reboot if I need to resync it, which I do far less regularly. Yes, I’ll [...]

  2. [...] start charging when I plug a retractable 1€ iPod sync cable into the pigtail. I read somewhere that the iPhone had to be told to recharge by the iPod helper software (It also doesn’t [...]

  3. [...] Originally Posted by Rob100 I did read something about them not charging under Linux and some chap wrote a small program which sends the ipod/iphone a command to tell it to start charging. This is it: Matt Colyer iPhone Now Charges in Linux [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

Powered by WP Hashcash