Blame README.sqlite

Packit 29108b
* Summary
Packit 29108b
Packit 29108b
For things to work with an iPod Nano 5G or an iPhone/iTouch, you need
Packit 29108b
  - an iPod_Control/Device/SysInfoExtended file (Nano5G) or
Packit 29108b
  - an iTunes_Control/Device/SysInfoExtended file
Packit 29108b
This file should be created when the device is plugged in. If not, you can 
Packit 29108b
generate it manually using ipod-read-sysinfo-extended (passing the device UUID 
Packit 29108b
as an argument for an iPhone/iPod Touch and the USB bus and device number for
Packit 29108b
a Nano 5G). On a Nano5G, passing the device node (/dev/sdb) to
Packit 29108b
ipod-read-sysinfo-extended won't work. On a Nano5G, SysInfoExtended should be 
Packit 29108b
a few dozen kilobytes in size.
Packit 29108b
Packit 29108b
You also need a database generated by iTunes on your iPod when you first plug
Packit 29108b
it in. When libgpod reads this database, it will generate
Packit 29108b
  - an iPod_Control/Device/HashInfo file (Nano5G) or
Packit 29108b
  - an iTunes_Control/Device/HashInfo file (iPhone/iPod Touch)
Packit 29108b
which is required to write to the device.
Packit 29108b
Packit 29108b
Packit 29108b
Packit 29108b
* sqlite
Packit 29108b
Packit 29108b
New iPod models (iPhone/iPod Touch on the one hand, Nano 5G on the other hand)
Packit 29108b
contain both a compressed version of the usual iTunesDB (the iTunesCDB file)
Packit 29108b
and sqlite databases. The iTunesCDB file is used by iTunes while the sqlite
Packit 29108b
databases are used by the device. The sqlite databases use the .itdb extension
Packit 29108b
and can be found in iPod_Control/iTunes/iTunes Library/
Packit 29108b
(iTunes_Control/iTunes/iTunes Library/ on devices using the iPhone OS). Both
Packit 29108b
use some kind of checksum.
Packit 29108b
Packit 29108b
The iTunesCDB file is checksummed either with a hash58 (old hash introduced
Packit 29108b
with the first iPod Classic and the Nano 3g) or a hash72 (new hash introduced
Packit 29108b
with iPhone OS 2.x). The hash58 is used on the Nano 5G while the hash72 is
Packit 29108b
used on the iPhone/iPod Touch.
Packit 29108b
Packit 29108b
The sqlite databases are checksummed through the use of a .cbk file. This file
Packit 29108b
only checksums the content of the Location.itdb sqlite database and uses the 
Packit 29108b
hash72 on the iPhone/iPod Touch and the Nano 5G.
Packit 29108b
Packit 29108b
Packit 29108b
* HashInfo
Packit 29108b
Packit 29108b
The HashInfo file can be found in iPod_Control/Device/HashInfo
Packit 29108b
(iTunes_Control/Device/HashInfo for an iPhone/iPod Touch). At the moment, 
Packit 29108b
it's not known how to generate a checksum for the iPod database from scratch.
Packit 29108b
However, for a given iPod, we can extract the necessary data from a database
Packit 29108b
generated by iTunes to be able to generate a checksum for any other database 
Packit 29108b
for this iPod.
Packit 29108b
libgpod extracts this data the first time it reads a database on an iPod (so
Packit 29108b
it assumes this database was generated by iTunes) and dumps it to the HashInfo
Packit 29108b
file (very simple format, see the struct Hash78Info in src/itdb_hash72.c).
Packit 29108b
Then libgpod can reuse the information from that file to write valid databases
Packit 29108b
for the iPod the HashInfo was generated on.
Packit 29108b
Packit 29108b
Packit 29108b
* SysInfoExtended
Packit 29108b
Packit 29108b
The SysInfoExtended file is stored in iPod_Control/Device/SysInfoExtended
Packit 29108b
(iTunes_Control/Device/SysInfoExtended on iPhone/iPod Touch). This file isn't
Packit 29108b
a standard iPod file, it's generated using some data available on the iPod
Packit 29108b
and dumped there because it's more convenient for libgpod. It's an XML file
Packit 29108b
containing lots of data about the iPod (serial number, support image and video
Packit 29108b
formats, ...). libgpod installs a HAL/udev callout to automatically generate
Packit 29108b
this file when an iPod is plugged in, but it can also be done manually by 
Packit 29108b
using the ipod-read-sysinfo-extended tool.
Packit 29108b
This file is required on the Nano 5G because it contains SQL commands that 
Packit 29108b
have to be run to generate sqlite databases that the device will be able to 
Packit 29108b
handle.
Packit 29108b
The iPhone/iPod Touch need similar SQL commands to be run, but they are not
Packit 29108b
stored in SysInfoExtended, they are extracted from the device when needed.
Packit 29108b
Packit 29108b
Packit 29108b
On the iPhone/iPod Touch, the data for the SysInfoExtended file can be
Packit 29108b
obtained by asking for the right lockdown key through the usbmux daemon.
Packit 29108b
On the Nano5G, things are a bit more tricky. Older iPods models used to 
Packit 29108b
make that data available through a SCSI inquiry command. This command works
Packit 29108b
on the Nano5G too, but it returns really partial data (no SQL post-process
Packit 29108b
commands, no artwork format information, ...). The full data can be obtained
Packit 29108b
through an USB Control command (see tools/ipod-usb.c for more details).
Packit 29108b
Packit 29108b