Update: I have started a project to get the iPhone to work in Linux, read this post for more information.
So, I recently got an iPhone and love it. However the one thing that I really wish it did but doesn’t is sync with Linux. After digging around a bit I came to the conclusion that there isn’t an easy way to do it. Since I really want this I thought I would take it upon myself to figure it out.
There is some progress on this page but the idea is to clone the API from windows, not something I plan on doing if I am writing this from scratch. There is also this project, but since it only runs in windows they don’t have to write the USB drivers (but still useful for debugging).
So tonight, I dug out usbsnoop and recorded the usb messages going back and forth between the iPhone and iTunes. I am not going to post the results yet because I can’t tell which log files contain personal information but I will hopefully get around to it.
One thing I found out from reading the logs is that the iTunesMobileDevice.dll is not custom for each computer (which I had seen mentioned elsewhere, thankfully making my life somewhat easier). Another interesting thing that I found out is that the iPhone uses USB configuration 3, interface 2, and endpoints 85 and 4 for synchronization. Unfortunately Linux wants to start the device in configuration 1 which it doesn’t like, so I had to make a kernel module to set the configuration of the device (which is compiling as I write this). To get started I copied the code from berry_charge (which is used for doing similar things to blackberries) and modified to do the necessary steps.
The final surprise from my usb traffic analysis is that iTunes uses a keypair challenge in order to open a session. The curious thing is that the keypair didn’t change in the three runs that I recorded. I am guessing that the keypairs are generated once and are then used to determine whether the iPhone has been “paired” with that iTunes install.
Hopefully after I get this kernel module installed and working, I can switch back to userspace and use ruby-usb to develop a prototype driver.

17 Comments
Any progress on this ? I am quite interested in the iPhone working on Linux.
-Jason
Unfortunately things are stalled for the moment. A critical part of the USB communication takes place over an SSL session and I am not sure if will be able to get around that.
It isn’t a problem to mount the iPhone using sshfs, if you’ve hacked your iPhone and installed openssh (over the LAN, not USB). You only need to have Amarok (or other software) to read and write iTunesDB.
Unfortunately I haven’t got time to look into in myself right now. Do you know any site where to find progress on the different efforts?
I know you can use sshfs once you have hacked your phone, but I was hoping to find a way so that people didn’t have to hack their phones in order to use Linux.
I think the efforts are fairly distributed (scattered on people’s blogs). I posted a note on the iphone dev wiki but there doesn’t seem to be much activity there around Linux.
Hey, saw your blog here and was interested in finding out if you have moved further. I have dumped traffic for my own iPhone and discovered the SSL part too. iTunes seems to request a public key from the phone. I assume this is used to either encrypt a session key that is later used for communication (in which case, the SSL part will pretty much screw you up), or they use the private/public keypair (which means you’d have to find the private key in your phone somewhere… also pretty much screwing you up). This seems to happen on a regular basis (well, I should say that the protocol seems to “go ssl” on a regular basis… ). Did you notice that most of the clear traffic seems to be in XML? I also noted a few packets that seemed to illicit some information from the phone, but haven’t really analyzed anything hard yet. Currently my PC won’t recognize my target phone. Maybe something happened to the USB in the phone… don’t know. UGH.
Here is an article how to do it with sshfs and Amarok.
http://blog.adaniels.nl/?p=50
I too would be interested to hear what’s going on with this. I don’t have much experience in coding or developing, nor do I have the time to follow the 20+ steps to hacking my iPhone. But it would make my life so much simpler if it would work in Linux. Or even in a VM on a Linux host. I look forward to seeing any more comments on this.
For an update check here:
http://www.mattcolyer.com/2007/10/13/iphone-update-and-today/
vmware or wine wouldnt work for the iphone. Itunes is not a open source code I take it or there would be itunes clones for linux out there. Im going to try to see if you can reverse engineer itunes. Since I just finshed my class this quarter and have nothin better to do.
http://hackint0sh.org/forum/showthread.php?t=13211 See this for syncing without itunes
Why wouldn’t VMware work? I just got my ipod touch this week and I thought it was the only solution to get it working on Linux… Anyway, I’ll jailbreak it tomorrow and try the sshfs+amarok thing. Thanks for the link!
keep going buddy!!! You never know you might find a way to get this working.
We all need you to succeed
YES YES – Please! – I would love iphone in linux…
A library would be a nice approach, since if done right could be made to work on another platform, while keeping the API the same.
One thing I imagine seeing is a single library which manages data exchange between the PC and any portable media player, of which the iPhone is one.
Any further information would be great. I have a few weeks coming up over the hols and would like to start trying to get this working. Is there a wiki or anything similar about?
Well, it seems that yeah you do need to jailbreak to get anything to work today. Its weird seeing that everything thats corrupt works with Linux. Anyway I think that if I’m going to buy an iPhone I will probably wait for the finalized Google Android to iPhone solution to come out and install that. Seeing how Google Android is open source thats going to make things a hell lot easier for us Linux users to get things done. I know that you can get Google Android onto the OpenMoko phone, but the problem is you don’t have a keyboard, or a touch screen keyboard with Android yet. And there’s some problems with making and receiving calls.
Main thing is. Ditch Apple’s software when Android for iPhone comes out or install VMWare Player or VirtualBox. Install Windows XP as a virtual machine. Enable USB 2.0 and get iTunes.
How can I help. please let me know!!
One Trackback
[...] it’s been quite a while since I first started this journey, but iPhone support in Linux has progressed to the point that you can sync your music and even read [...]