Hacking the iPod Touch / iPhone - Part 3

Right! so you had plenty of time to purchase the touch or the iphone and Steve had enough time to cut me a check for the previous 2 articles. But since the later didn't happen, lets just concentrate on the former - but this time in combination with GNU/Linux.

Once the new line of ipods were released, it was soon obvious that third party media players, such as gtkpod/amarok/winamp, were no longer able to sync with them. Whether this was intentional or just a consequence of Apple improving things will depend on who you ask :) Fortunately though, (ipod Linux?) hackers managed to figure out a way to get syncing working again - in just a couple of days, might I add!

Unfortunately the ipod touch/iphone is another beast altogether! Neither support the USB mass storage modes and instead rely on a proprietary message passing method that is yet to be deciphered.So AFAIK, neither of the two devices can sync over USB as far as gtkpod is concerned. Hopefully someone will figure it out or we may not need it after all if as rumored, Apple adds USB mass storage using a firmware update. But rather than languishing on what may or may not happen, lets see how it can be done at the moment.

Before you begin, make sure you have a Jail broken iTouch/iPhone with OpenSSH server installed and running.

Mounting the iPod Touch

While we may not be able to mount the iTouch as a USB mass storage device, we can mount it over the network - provided it has been Jail broken. The easiest method, which I'll discuss involves mounting the device over SSH with the help of sshfs fuse driver, a user space kernel driver. Other methods you might want to look into are the Apple File Share (AFP) and Samba which are installable on the Touch.

Before you can mount over sshfs, you need to install fuse and the sshfs driver. On Ubuntu, this would go something like:

# apt-get install sshfs

You might also want to load the fuse driver manually if you get an error in the next step.

# modprobe fuse

Create a mount point (in your home directory) to mount the iTouch and mount it using its ip address.

$ mkdir ~/mnt_itouch
# sshfs -o allow_other root@<ip_of_itouch>:Media mnt_itouch

You should now be able to see the content of your itouch on mnt_itouch directory.

Compiling GTKPod

At the time of writing, you needed the svn version of libgtkpod and gtkpod in order to support the hack explained earlier w.r.t the new ipods. Hopefully by the time you read this, you might be able to use the stock version that come with your distro of choice. If not, there is a good howto. These are basically the steps involved.

$ mkdir gtkpod
$ svn co https://gtkpod.svn.sourceforge.net/svnroot/gtkpod/gtkpod/trunk gtkpod
$ svn co https://gtkpod.svn.sourceforge.net/svnroot/gtkpod/libgpod/trunk libgpod
$ mkdir ~/local
$ cd libgpod
$ ./autogen.sh --prefix=/home/<user>/local
$ make && make install
$ cd ../gtkpod
$ PKG_CONFIG_PATH=/home//local/lib/pkgconfig ./autogen.sh --prefix=/home/<user>/local
$ make && make install

Create a small launch script for gtkpod as follows

$ cd ~/local/bin
$ echo 'LD_LIBRARY_PATH=/home/<user>/local/lib /home/<user>/local/bin/gtkpod' > gtkpod.sh

New hack: Getting the Firewire GUID and setting it in libgpod

The hack for the new ipods require something called a firewire GUID to be taken (I think its used as a salt in the hash algorithm) and written so libgpod can use it. For this, you need to plug in the iTouch over USB and wait a couple of seconds for things to settle before executing:

# lsusb -v | grep -i iSerial | head -n 1 | sed -e "s/.\+3[ ]//"|cut -c1-16

$ echo 'FirewireGuid: 0xa12b3c1a35c7ba56' > ~/mnt_itouch/iTunesControl/Device/SysInfo

Now if you launch gtkpod via gtkpod.sh it should recognize your iTouch automatically (since its mounted on your home directory). Before you sync any files, it would be a good idea to select the ipod touch / iphone model from the list available on gtkpod.

There are still some issues with this method (at the time of writing):

  • Album art doesn't seem to work.

  • Only preliminary support for Photo management. I could only view and download photos. Not upload new ones.

  • Podcast playlist not supported. AFAIK this isn't quite supported with old ipods with gtkpod. But it does work with old ipods on amarok - not sure why.

  • Slow, very slow syncing large files. I think this is a result of mounting over ssh. The encryption must be stressing the iTouch processor. May be the Samba or AFS is faster here.

Another tip if you plan on using iTunes and gtkpod is to use the SwapTunes.app on the iTouch to keep two copies of the iTunes database - one for iTunes and the other for gtkpod. This way you risk less, corrupting the iTunes database.

Thats it for now. As always, do check out the comments for additional things I may find after writing this. In the next article, I'm hoping to write a little about the productivity apps as well as some other cool apps focusing once again on desktop integration (spelled GNU/Linux desktop integration). Till then, enjoy your technology! (sorry Cali)