Maybe they’re not as bad as I thought

The iPod situation is now mostly fixed. I was able to figure out how iTunes gets the iPod serial number (and other info) with the help of a USB monitoring tool and Matt Dharm (the usb-storage guy). After that, Aaron used the metric ton of SysInfo samples you guys sent in to get a serial number -> model number mapping.

To get info about (recent) device, iTunes requests an xml document from it over USB. I saw this in the USB trace I had, but the data was nowhere on the disk exposed by USB Mass Storage. Puzzling. Not really knowing much about USB MC, I enlisted the help of Matt, who obviously knows a lot more. He informed me that it was requesting the data using a special SCSI INQUIRY command, and I could probably use SG_IO to get it out. I ran sg_inq on my iPod with the right parameters, and out came the xml. Success! After that I wrote a hal method for libipoddevice to pull the info out (since you need to be root), and the rest was just parsing the xml and doing the serial -> model mapping.

Even though it was a fairly painful couple of days trying to fix this, I’m pretty happy with the result. The xml from the device includes some really tasty stuff, including information on the image formats for cover art and photos. We are using this data now in ipod-sharp instead of the static table we had before, which will be really great for maintenance. New iPods with previously unknown image formats will Just Work! There is also data on the video formats, which I will soon use to add video support to Dopi

16 Responses to “Maybe they’re not as bad as I thought”

  1. Bastien Says:

    Bonus points if you can figure out how to set/sync the time on the iPod when it’s getting connected :)

  2. Sean Says:

    Could a similar query be used to pull out the encryption key used by the iPod for playing restricted AAC files so we can transfer the music to our Free desktops/players ?

  3. Max Beauchez Says:

    Maybe they’re not as bad as you thought, but if they’d been nice they’d have sent you this information right away for two reasons. 1. Theyre the selfproclaimed opensource friends. 2. Its in their advantage to have as many platforms support iPods as possible, so they can make more profits.

  4. Jeremy Says:

    Despite the pain I’m sure the Banshee team (and any other iPod supporting project) has gone through these past few days, I’m very happy to hear about Dopi.

  5. C.J. Says:

    these data

  6. teuf Says:

    What did you use to carry out the USB sniffing? Windows install, Wine? Is the USB snifferfreely available? whichh version of iTunes did you sniff?

  7. snorp Says:

    teuf: I used USB Monitor on Windows with iTunes 7.

  8. alex Says:

    I’m disappointed… why you need the sg_inq for model determining if this command does not provide ModelNumStr?
    It just gives you a Serial Number which actually can be obtained from /sys/* files, e.g.
    /sys/bus/usb/devices/1-1/serial..

  9. snorp Says:

    alex: that’s the serial for the USB chip or something, not the iPod itself.

  10. alex Says:

    Ops. I see, yes you’re absolutely right. This serial is the same as FireWireGUID in the xml.

  11. Lasse Bigum Says:

    Appreciate all your work, but my new black iPod Nano 8GB does not work with the Gentoo versions of libipoddevice-0.5.0, banshee-0.11 and ipod-sharp-0.6.2.

    While HAL correctly identifies the iPod (I think? At least it has info on the iPod, will paste below), the “ipod” program sees nothing, when I plug/unplug the Nano.

    I took a look at the “ipod –model-xml” and I can see that the serial-number of my Nano does not match. Does this have anything to say?

    My HAL info:
    /org/freedesktop/Hal/devices/storage_serial_Apple_iPod_000A2700189C8E5E

    Any help on this appreciated.

  12. rkf7 Says:

    Hi,
    Can I please get the details of the SCSI INQUIRY you use? Thanks.
    Bob

  13. snorp Says:

    rkf7: I put info about it up on the ipodlinux wiki here.

  14. rkf7 Says:

    Hi,
    I haven’t had any luck on a Debian Linux system getting the sg_inq command to work. Is there a way to see if my Linux kernel has the SG_IO ioctl? Thanks.
    Bob

  15. rkf7 Says:

    I am using a new kernel. I can now get the info with the command:

    sg_inq /dev/sgn

    Where n=0,1,2,3…

    Bob

  16. sternr Says:

    Hey,
    I know it’s not very related to the topic, but I really want to use Ipod-sharp\dopi but I’m a Windows user and have no idea how to build the projects (are they even compatible to Windows?!)
    Please help!
    Thanks ahead

    –sternr

Leave a Reply