This is an old revision of the document!


Linux and the iPod Touch

Linux support for the iPod Touch is quite good. However, the latest versions of Apple software are not always completely compatible. Here is how I managed to get my new iPod Touch with iOS 4.2.1 working with Ubuntu.

Jailbreak

Jailbreaking opens up an infinite new world to iPod Touch and iPhone users. I highly recommend it and I cannot guarantee that this set of instructions will work on non-jailbroken devices.

I used the GreenPois0n jailbreak for my iPod. Unfortunately, I was forced to find a windows box to run the jailbreak. Come on, guys. At least make it work in a VM. Note: you need to connect the iPod to iTunes to initialize it first. This can take place in a VM. For whatever reason, GreenPois0n disagreed with virtualbox when I tried it, though. Your mileage may vary.

Install Ubuntu Software

As of this writing (3/17/2010), the default Ubuntu packages do not work with the latest hardware and software combination. Therefore, you will probably need to add ppa:pmcenery/ppa to your software sources. This is most easily done through Synaptic by clicking SettingsRepositories, then Other Software, then Add… and pasting in ppa:pmcenery/ppa and clicking Add Source. Then close the dialog and click Reload.

Now, install or update ifuse (>= 1.1.1), libgpod4 (>= 0.8.0), libimobildedevice (>= 1.0.4), usbmuxd (>= 1.0.6), and banshee (>= 1.8.0). Then reboot.

Install iPod software

Start up the Cydia app. Search for an install openssh and vim. iFile will allow the change to be carried out locally; however iFile costs $4.00 the last time I checked.  The instructions below are for SSH.  

===== iPod configuration =====

The latest database version is incompatible with the latest linux drivers.  Therefore, the database version of the device must be downgraded.  The process is quite simple.  

  - Install the ''vim'' package via cydia
  - Log in to the ipod via SSH as root with default password "alpine".  
  -- su to root
  .. <code>$ su</code>

  1. Edit Checkpoint.xml to change DBVersion to 4

    # vim /System/Library/Lockdown/Checkpoint.xml

    You'll see something like this:

    798
            <key>DBVersion</key>
            <integer>5</integer>

    Change it to this:

    798
            <key>DBVersion</key>
            <integer>4</integer>
  2. Delete /var/mobile/Media/iTunes_Control

    # rm -rf /var/mobile/Media/iTunes_Control
  3. Change password (optional, but highly recommended)

    Root password:

    # passwd

    User 'mobile' password (default non-root user):

    # passwd mobile
  4. Reboot device

    # reboot

Initialize Database

Connect the device to iTunes and transfer at least 1 song to the device. This will initialize the database for use with linux.

Transfer songs with Banshee

If everything has been done properly so far, the iPod should now work properly with Banshee. If you haven't already, you might want to install the gstreamer0.10-plugins-ugly-multiverse package for the lame mp3 encoder. This will allow Banshee to convert tracks to mp3 automatically.

Open up Banshee with the device connected. Banshee should detect your device and display it in the side panel. Try dragging a song onto the device in Banshee. Once it is finished transferring, wait another 10 seconds or so and quit banshee (media → quit). Check the music player on the device to make sure the file appeared. If so, you're done. Banshee will now be able to transfer all of your music. If not, well, back to the old drawing board…

Debugging Notes

Run banshee –debug and transfer a song. See if one of the errors below appears.

Wrong Database Version

If banshee –debug yields this error, the device is configured with database version 5 (too new).

Failed to save iPod database - GLib.GException: Failed to generate sqlite database (in `libgpod-sharp)

To check the current configured version, run

ideviceinfo -q com.apple.mobile.iTunes -k DBVersion

.

The solution is to edit Checkpoint.xml and change DBVersion. If you have already done this, make sure to delete the iTunes_Control directory and reboot the device. Do not allow it to sync with anything and do not start the music player before rebooting.

Note: some sources say change the version to 2. I tried that, and it didn't work. After much head scratching, I tried 4 and it worked perfectly. Don't forget to delete the iTunes_Control folder, reboot the iPod, and initialize the database with iTunes before trying again with banshee.

Old Driver Software

If opening up the device in Nautilus only yields a folder called DCIM, then you are running the incompatible packages. Please add the ppa listed above, upgrade, and reboot.

The below error messages are also indications that the drivers are the wrong version. If any of these messages show up in dialog boxes or debug outputs, please check the versions. Also make sure that the computer was rebooted after updating the packages.

The ogg format is not supported by the device, and no converter was found to convert it.
The mp3 format is not supported by the device, and no converter was found to convert it.
[5 Warn 03:07:58.970] Caught an exception - System.ApplicationException: The ogg format is not supported by the device, and no converter was found to convert it (in `Banshee.Dap')
  at Banshee.Dap.DapSource.AddTrackAndIncrementCount (Banshee.Collection.Database.DatabaseTrackInfo track) [0x00000] in <filename unknown>:0
  at Banshee.Sources.PrimarySource.AddTrackList (System.Object cached_list) [0x00000] in <filename unknown>:0
[5 Warn 03:07:58.970] Caught an exception - System.ApplicationException: The mp3 format is not supported by the device, and no converter was found to convert it (in `Banshee.Dap')
  at Banshee.Dap.DapSource.AddTrackAndIncrementCount (Banshee.Collection.Database.DatabaseTrackInfo track) [0x00000] in <filename unknown>:0
  at Banshee.Sources.PrimarySource.AddTrackList (System.Object cached_list) [0x00000] in <filename unknown>:0

Red Herring

The following error message looks ominous and I originally thought it to be an indication of an incorrect database version. However, it appears every time my ipod touch successfully updates. If you get it, all it really means is that some of the database updates apparently didn't work as expected, perhaps due to some sort of database structure change. This error won't stop your ipod from syncing, so if it is not syncing, look elsewhere.

[run_post_process_commands] Getting SQL post process commands
[run_post_process_commands] WARNING: ignoring non-string value for key 'Version'
[run_post_process_commands] Running 173 post process commands now
[run_post_process_commands] ERROR when executing 'RemoveNullFromArtistName': no such table: item_artist
[run_post_process_commands] ERROR when executing 'AddIsITunesUColumn': duplicate column name: is_itunes_u
[run_post_process_commands] ERROR when executing 'InsertIntoSortMap_album_artist_name_order': no such function: iPhoneSortKey
[run_post_process_commands] ERROR when executing 'InsertIntoSortMap_genre_map_genre_order': no such function: iPhoneSortKey
[run_post_process_commands] ERROR when executing 'InsertIntoSortMap_album_name_order': no such function: iPhoneSortKey
[run_post_process_commands] ERROR when executing 'InsertIntoSortMap_item_artist_name_order': no such function: iPhoneSortKey
[run_post_process_commands] ERROR when executing 'InsertIntoSortMap_item_genre_order': no such function: iPhoneSortKey
[run_post_process_commands] ERROR when executing 'InsertIntoSortMap_item_composer_order': no such function: iPhoneSortKey
[run_post_process_commands] ERROR when executing 'InsertIntoSortMap_item_album_order': no such function: iPhoneSortKey
[run_post_process_commands] ERROR when executing 'InsertIntoSortMap_item_album_artist_order': no such function: iPhoneSortKey
[run_post_process_commands] ERROR when executing 'InsertIntoSortMap_item_series_name_order': no such function: iPhoneSortKey
[run_post_process_commands] ERROR when executing 'InsertIntoSortMap_item_title_order': no such function: iPhoneSortKey
[run_post_process_commands] ERROR when executing 'InsertIntoSortMap_item_artist_order': no such function: iPhoneSortKey
[run_post_process_commands] ERROR when executing 'InsertIntoSortMap_composer_name_order': no such function: iPhoneSortKey
[run_post_process_commands] ERROR when executing 'UpdateSortMapNameSection': no such function: iPhoneSortSection
[run_post_process_commands] ERROR when executing 'CreateIndex_SongGenres_Sections': table item has no column named genre_blank
[run_post_process_commands] ERROR when executing 'CreateIndex_ArtistAlbums_Sections': index ArtistItems_Sections already exists
[run_post_process_commands] 156 out of 173 post process commands successfully executed

MTP Issues

The first time I ran through the whole process it worked perfectly. The second time, on a different computer, I ran headlong into a different problem. The iPod Touch would be properly detected until Banshee was started, then it would disappear. The error log looked like this:

** (Banshee:19245): CRITICAL **: itdb_get_control_dir: assertion `mountpoint' failed
Device 0 (VID=05ac and PID=129e) is UNKNOWN.
Please report this VID/PID and the device model to the libmtp development team
LIBMTP WARNING: no MTP vendor extension on device 30 on bus 2LIBMTP WARNING: VendorExtensionID: 00000000LIBMTP WARNING: VendorExtensionDesc: Device has no vendor extensionsLIBMTP WARNING: this typically means the device is PTP (i.e. a camera) but not an MTP device at all. Trying to continue anyway.LIBMTP PANIC: could not inspect object property descriptions!
LIBMTP PANIC: could not inspect object property descriptions!
LIBMTP PANIC: could not inspect object property descriptions!
[7 Warn  01:07:44.542] Unable to get battery level from MTP device - Mtp.LibMtpException: Could not retrieve battery stats (in `Mtp')
  at Mtp.MtpDevice.GetBatteryLevel (Mtp.MtpDeviceHandle handle, System.UInt16& maxLevel, System.UInt16& currentLevel) [0x00000] in <filename unknown>:0 
  at Mtp.MtpDevice.get_BatteryLevel () [0x00000] in <filename unknown>:0 
  at Banshee.Dap.Mtp.MtpSource.DeviceInitialize (IDevice device) [0x00000] in <filename unknown>:0 
[7 Debug 01:07:44.542] Found DAP support (Banshee.Dap.Mtp.MtpSource) for device Apple iPod and Uuid ...
[1 Debug 01:07:45.063] Unmapping DAP source (...)

Running mtp-detect also caused the device to disappear.

Solution to this is in progress…

Solution: install newer version of libmtp8 (> 1.0.3-4, 1.0.6-2 confirmed OK) and perhaps mtp-tools from deb files or source. I downloaded deb files from https://launchpad.net/ubuntu/natty/+package/libmtp8 for libmtp8. Then reboot.