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.