Logo

gnuPod project Documentation - Version 0.25

(C) Adrian Ulrich
Orginal english translation: Ramon Cahenzli
http://www.blinkenlights.ch/cgi-bin/fm.pl?get=ipod




Contents

  1. Copyright information
  2. What is gnuPod?
  3. Other iPod-for-Linux projects
  4. Installation
  5. iTunes and gnuPod
  6. Problems and solutions
  7. Errors and limitations



Copyright Information

iPod, iTunes, Mac, Macintosh, iBook are trademarks of Apple Computer, Inc., registered in the U.S. and other countries.
Windows is a trademark of Microsoft, registered in the U.S. and other countries.


What is gnuPod?

gnuPod was the first way to use an Apple iPod with a different operating system than Mac OS.

The gnuPod project has been active (with lengthy breaks) since April 2002. We (i.e. Adrian ;) ) 'hacked' the iTunesDB (the most important file on your iPod!) and are now capable of writing that file :)
We have not yet decrypted 100% of the iTunesDB, but we know enough to write our own, working file and therefore use an iPod with Linux (and others) :).
Before using gnuPod, I advise reading the chapter Errors and limitations.


Other iPod-for-Linux Projects

(Status: 28. Sept. 2002)

SyncPod Released one day after gnuPod 0.1
SyncPod is also written in Perl. It can sync a directory with your iPod and has support for playlists.
SyncPod doesn't seem to parse the old iTunesDB and may not work well if you use your iPod with a different program.



Ipod-on-linux
Another GPL'd project aiming to make use of the iPod possible under Linux.
The whole thing is written in C (..and will be a library?)
Currently you can find an iPod backup tool (?) and a firmware upgrader on this project's site.
Via CVS you can additionaly download tools to write the iTunesDB (which I couldn't compile..)
The project also offers an interesting documentation for the iTunesDB format.
Unfortunately, we had already decrypted 90% of it before finding that site. Nevertheless, the documentaiton helped resolving some uncertainties.





Tex9 ipod-clu
Closed source and only for x86 (so PPC-Linux users don't have iPods, then?)
Also available as plug-in for an 'iTunes-like' application. Costs US$ 10.


Installation

Requirements

To use gnuPod, the follwing is needed:
gnuPod should work on most UNIX-Systems. All you need is an OS with a working Perl and support for FAT32 formatted FW-devices.


Installation of the gnuPod tools

First of all, you should make sure that the required Perl module are installed and usable on the system.
On Debian,
apt-get install libfile-ncopy-perl
apt-get install libmp3-info-perl
apt-get install libxml-parser-perl
apt-get install libunicode-string-perl
should be sufficient. Otherwise, CPANwill help.
Afterwards you should be ready to copy the gnuPod tools to /usr/local/bin:
$ su
Password:
# cd gnupod-tools/
# cp *.pl /usr/local/bin/
.finished!



Testing FireWire

The kernel must support FireWire, of course.
gnuPod was developed on an iBook2 using kernel 2.4.20-pre5, which supports FireWire nicely. It should also work on e.g. 2.4.18, so:
1. Get kernel source and configure
Needed configuration:
. Now you should compile and install the kernel as usual.
After installation, you can test FireWire/talk to the iPod with the following commands:
Do not connect iPod yet!
# modprobe ohci1394
# insmod sbp2
Now connect iPod
The iPod should now be /dev/sda (..if there are no other SCSI devices in the system). You can verify the whole setup using e.g.: cat /dev/sda2 > /dev/null
If the iPod starts making noises, things should be okay. If Linux complains about the device, a rmmod sbp2 && insmod sbp2 should help. FireWire is still 'Experimental' after all - IF the iPod connects successfully, things should work great though. No kernel panics or anything.


Transforming a Mac iPod into a Win iPod

If you own a Windows iPod, OR your OS can write HFS+ (Darwin can, LINUX CAN'T!), you can skip this chapter.


Let's continue:
To use a Mac (HFS+) iPod with Linux, it must be reformatted as FAT32. Not much can go wrong, I was able to resurrect my iPod using the OSX iPod software several times after deleting my entire iPod hard drive.

What we need This will delete everything on your iPod. Backing up would be wise. Ok, backup done? Let's go!
Almost forgot this: should your iPod turn into a decorative brick: That's life. I don't feel responsible for it. YES, something could go wrong and I am NOT responsible for it.
Well, nothing should happen, really. Look above for what I did to my iPod.


A dream of fdisk..
In order to go ahead, we need an FDISK for DOS partitions
If you do this using PPC Linux, your fdisk is probably a mac-fdisk and cannot create DOS partitions. Therefore it's unusable.
If you are working with x86 Linux, your FDISK is okay and you can continue with 'Now we're getting serious'. (You do have Mac partition support in your kernel?)
PPC Linux users can get a DOS fdisk, it's included with the 'util-linux' source, which we retrieved from: ftp://ftp.kernel.org/pub/linux/utils/util-linux/ (or apt-get source util-linux on Debian).

After downloading, we compile it the 'quick 'n dirty' way:
tar -xjvf util-linux-X.XXx.tar.bz2
cd util-linux-X.XXx
./configure
cd fdisk
make
cp fdisk /usr/sbin/pc-fdisk
Do NOT do a 'make install', we only want a PC fdisk and don't care about the rest!

Now we're getting serious
Now this thing is really taking off, but first we update the firmware to version 1.2, which happens in MacOS. (...or have a look at 'Problems and Solutions')
After the iPod is up and running again with 1.2, we plug it back into our Linux box and load the FireWire stuff. Here's the dangerous part ;)

Back up the firmware
# dd if=/dev/sda2 of=/root/firmware
# md5sum /root/firmware
09f2a78b00a17dbedc74397a6da47db0 firmware
If your md5sum matches the one above, everything's okay. Otherwise: Yay?

Repartition the iPod
This is the most critical part, so pay attention while reading!
dd if=/dev/zero of=/dev/sda Kill Mac partitions, you can kill dd using CTRL+C after about 5 seconds
rmmod sbp2 && insmod sbp2 Reload this module. Forces linux to re-read the new partition table
pc-fdisk /dev/sda start fdisk


Command (m for help): n make new partition
Command action
   e extended
   p primary partition (1-4)
p we want primary
Partition number (1-4): 1 number
First cylinder (1-608, default 1): just press enter
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-608, default 608): 5S Look out: 5S .. S as in Ship

Command (m for help): n
Command action
   e extended
   p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (6-608, default 6): 6 is okay, or even needed.. just press enter
Using default value 6
Last cylinder or +size or +sizeM or +sizeK (6-608, default 608): press ENTER
Using default value 608

Command (m for help): t Modify type
Partition number (1-4): 1
Hex code (type L to list codes): 0 we don't care about the warning below
Type 0 means free space to many systems
(but not to Linux). Having partitions of
type 0 is probably unwise. You can delete
a partition using the `d' command.
Changed system type of partition 1 to 0 (Empty)

Command (m for help): t
Partition number (1-4): 2 this is where data will go
Hex code (type L to list codes): b b=FAT32
Changed system type of partition 2 to b (Win95 FAT32)


Command (m for help): w Writing new partition. Can take a while.
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

#dd if=/root/firmware of=/dev/sda1 here we write the firmware we backed up back to /dev/sda1
65536+0 Records in
65536+0 Records out

#mkfs.vfat -F 32 -n "LUNIX" /dev/sda2 formatting the data partition. "LUNIX" is the name of the iPod.
#rmmod sbp2 remove module
.now we unplug the iPod and pray ;)
The iPod should boot normally, have no songs on it and display Format: Windows (scroll).
Congratulations for your FAT32 iPod! :)


iTunes can make use of a FAT32 iPod without any problems. And as I said: the iPod software updater can turn a FAT32 iPod back into an HFS+ one.


Changing to gnuPod

Your ipod is (or was) now writable using your favorite oparting system (which means the iPod is now FAT32 formatted).
Now we prepare our iPod for gnuPod.
First, we mount it to e.g. /mnt/ipod
Load FireWire stuff first, see 'Testing FireWire'
mkdir /mnt/ipod
mount /dev/sda2 /mnt/ipod
/dev/sda2 is only valid if there are no other SCSI devices in the system. 'dmesg' can help locate your iPod device.
If iPod complains about an 'invalid device': As I said: rmmod sbp2 && insmod sbp2 .


My iPod is empty or freshly formatted
If you converted your Mac iPod to a Windows one (or your iPod is simply a freshly made Win iPod) you must execute the follwing command: (In this document, we assume that the iPod is mounted under /mnt/ipod!)
gnupod_INIT.pl -m /mnt/ipod
A warning appears. You can kill the program with CTRL+C, or continue with ENTER (recommended).
This command creates the directory structure that the iPod and gnuPod need on the hard drive of the iPod.

My iPod still contains MP3s that I'd like to keep
No problem!
mkdir /mnt/ipod/iPod_Control/.gnupod
tunes2pod.pl -m /mnt/ipod
This command converts your current iTunesDB into a gnuPod file.
If you use your iPod with other software than gnuPod, you will make more use of this command (of course you only do mkdir the first time round). The gnuPod tools will tell you if it's necessary.


Everyday use of gnuPod

Your iPod is now ready for gnuPod, so let's use it!
In the following example, we will transfer 2 directories of MP3s to the iPod and then delete a few files. Let's go!

1. Mount iPod
First, the iPod will always need to be mounted
Load FireWire stuff
mount /dev/sda2 /mnt/ipod


2. Transfer 2 directories of MP3s to iPod
gnupod_addsong.pl -m /mnt/ipod seiken_densetsu_2/* ico_melody_in_the_mist/*
This command will transfer all MP3s from the directories 'seiken_densetsu_2' and 'ico_melody_in_the_mist' to the iPod, which has to be mounted on '/mnt/ipod'.
gnupod_addsong.pl does not descend into a further subdirectory. If there are any subdirectories in ico_melody_in_the_mist, they will be ignored (You can use '*' and '?' freely, though)
If there are items in the folders that are also already on the iPod, they will be ignored. gnupod_addsong.pl will print a message.

3. Searching for files on the iPod
Eric C. Cooper developed a the 'gnupod-utils'.
They are included in the gnuPod 0.25 distribution, you can find them at contrib/gnupod-utils
Of course it's possible to pipe the output of search.pl to gnupod_delete.pl (-n switch)
gnupod_delete.pl -m /mnt/ipod/ `./search.pl -m /mnt/ipod -a foobar -n | xargs`


4. Deleting songs
Every song on your iPod has a unique ID.
Open the 'GNUtunesDB' file and search for the files wich you want to remove (id="XX"). Do *not* edit the file! Just close it.
gnupod_delete.pl -m /mnt/ipod 688 693

This command deletes the songs with IDs 688 and 693 from the iPod, which is mounted on /mnt/ipod.
You don't have to worry about your Playlist: gnuPod also removes them from every existing Playlist on your iPod.

5. Creating a Playlist
The file doc/gnutunesdb.example holds 2 playlists.
The syntax is very easy.

GnuPod 0.25 has 'extended' Playlist support. With this Feature it's possible to create a Playlist wich automaticly holds ALL albums of Artist X + (for example) every Song with year="XXXX"
You shouldn't use this Feature if you are using your iPod with another program than gnuPod. tunes2pod.pl will replace the extended playlist with id="" Elements.
Your playlist will still work, but new Songs from Artist X won't go automaticly to this Playlist
If you are using only id="" Elements in your Playlist, you shouldn't have a problem using your iPod with another program than gnuPod.


To create playlists, you have to edit the file /ipod/mountpoint/iPod_Control/.gnupod/GNUtunesDB. Don't forget to run mktunes.pl to update your iTunesDB!

6. umount iPod
We are finished with transferring/deleting of files, so let's prepare our iPod for unplugging:
mktunes.pl -m /mnt/ipod
umount /mnt/ipod
rmmod sbp2
The command 'mktunes.pl' is very important. gnuPod hasn't accessed the iTunesDB directly during the last few actions, it always manipulated the gnuPod file instead. The iPod only understands the iTunesDB, so you need to update it every time before unmounting!
If you forget the 'mktunes.pl' command, your MP3s will still be on the iPod, but your iPod won't know anything about their existence.

umount and rmmod are self-explanatory.


iTunes and gnuPod

gnuPod can coexist with iTunes. If that also works with XPlay and others? No idea, but it should.
What you need to know:
After modifying your iPod's contents using iTunes, you need to update the gnuPod file. If you don't, gnuPod will refuse to work.
This is how it works:
mount iPod
tunes2pod.pl -m /mnt/ipod
Now your iPod is ready for gnuPod again!


Problems und solutions

How do i upgrade the iPod Firmware with Linux?
Upgrading the Firmware is easy, the hard part is to get the new Firmware in a suitable format.
Apple provides Firmware-upgrades as .sit (Mac) and .exe (Win32) Files, unuseable for Linux.

..but if you got an Apple running OSX, it's easy to get the Firmware-file
This worked for me (1.2.1 to 1.2.2 (1.2.2 = An Upgrade for Europa (france) - laws)), but if you trash your iPod, it's not my problem ;)

I can't mount my iPod! Error: mount: /dev/sda2 is not a valid block device.
We assume that your (connected!) iPod can really be accessed as /dev/sda, and that the FireWire port is supported on your computer.
As we said earlier in the document, FireWire is still a bit buggy. In such situations, reloading the sbp2 module usually helps:
rmmod sbp2 && insmod sbp2


The gnuPod tools say:
Error: Cant write to your gnuPod-file
did you run 'gnupod_INITpod.pl' ?


I'm getting the message:
Error: your gnuPod-file is older than your iTunesDB! (Last update not done with gnuPod?)...

Your iTunesDB is newer than the gnuPod file. You used something other than gnuPod to modify your iPod's contens, right? ;)
You need to sync your gnuPod file to the iTunesDB:
tunes2pod.pl -m /mnt/ipod
(mountpoint may be different!)

I got a XML Parser error!
Ouch, seems like gnupod_addsong.pl freaked out..
Please mail me your GNUtunesDB file.

I uploaded songs but they don't show up on the iPod!
You did run mktunes.pl before umounting?
Else: Please mail me your GNUtunesDB file.

I hate this -m /mnt/ipod thing!
Set $IPOD_MOUNTPOINT to your iPod mountpoint.

I can't find an answer to my question here
RTFM and then write e-mail


Errors and limitations

gnuPod is still in development, although it's fit for everyday use.

gnuPod does have a few limitations:



Have fun, and we'll just ignore the spelling errors :)
Oh yeah, and if you want to collaborate on gnuPod, fix up this document or translate it, just write pab at blinkenlights.ch