What is this iPod
iPod is a brand of portable digital audio player designed by Apple computer. The first three generations of iPod use two ARM 7TDMI-derived CPUs running at 90 MHz, while later models have variable speed chips with a peak of 80 MHz to save battery life.
Is this an article on iPod
This article is intended for iPod users on Linux and also for Linux users on iPod.
Locating your iPod
Before getting started with using iPod on Linux, the first step would be to locate the iPod on Linux. After connecting the iPod with USB port, check the location of iPod:
# cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: Apple Model: iPod Rev: 1.50
Type: Direct-Access ANSI SCSI revision: 02
scsi0 means that iPod is connected to /dev/sda, scsi1 means that iPod is connected to /dev/sdb and so on.
I am assuming that /dev/sda is used throughout this article.
Mounting and unmounting iPod
Now is the time to start exploring iPod. For this we need to mount the iPod on Linux:
# mkdir /mnt/myiPodSongs
# mount -t vfat /dev/sda2 /mnt/myiPodSongs
After mounting iPod, the content of iPod can be browsed as a normal file system.
Once done, iPod can be unmounted as follows:
#umount /dev/sda2
Copying and playing music
Ok, this was neat, but what about playing some music.
On Linux, gtkpod can be used to copy and organize your music into playlists .
After installing gtkpod, mount point of iPod can be specified from "Edit->Edit Preferences".
Once the mount point is added, gtkpod let's you create and modify playlists, add or remove songs and even export your thunderbird or evolution data to the iPod.
Podcasting
Podcasts are radio-style shows for iPod. Unlike streaming audio, which requires you to listen in real time, podcasting lets you control how and when you hear your favorite shows.
Some of the podcasting clients available on Linux are amaroK or BashPodder, a command line utility to download podcasts.
Installing Linux on iPod
Now that we know how to use iPod on Linux, it's time to use Linux on iPod.
But why bother to install Linux on an iPod? because it includes loads of new games, movie player, voice recorder and the freedom to write new applications.
iPodLinux can be used to install Linux on iPod. First, second and third generation of iPods are officially supported by iPodLinux.
After playing with installer a bit I was able to install Linux on my 60GB photo iPod.
The port uses uClinux, a Linux flavor designed for devices that lack a memory management unit (MMU). While the iPod has some MMU-type capabilities, they are not sufficient to support the Linux kernel.
Before installing Linux, it will be a good idea to take backup of iPod boot loader and OS, which can be restored if something goes wrong:
# dd if=/dev/sda of=ipod_boot_sector_backup count=1
# dd if=/dev/sda1 of=ipod_os_partition_backup
After the backup is done, next step would be to create a new partition on iPod to hold root file system for Linux.
Partition can be created using "fdisk /dev/sda", I created following partitions for a 60GB iPod.
Device Boot Start End Blocks Id System
/dev/sda1 * 1 1 8001 0 Empty
/dev/sda2 * 6 7296 58564957+ b W95 FAT32
/dev/sda3 2 5 32130 83 Linux
Once partition is done to hold root filesystem, create the filesystem with an ext3 journal:
# mke2fs -j /dev/sda3
and adjust the maximal mount count between two filesystem checks to never:
# tune2fs -c 0 /dev/sda3
To install Linux kernel and boot loader, download either
Official Boot loader(for 1,2 and 3 generation iPod)
or
Boot loader for 4G photo iPod
Also, download the latest kernel from nightly build.
Extract the kernel and boot loader in a directory. Assuming that name of the kernel is: uclinux-2.4.24-ipod2.bin
Now extract the apple image from the boot loader and create a new image including Linux and Apple OS:
# ./make_fw -3 -o apple_os.bin -e 0 ipod_os_partition_backup
# ./make_fw -3 -o my_sw.bin -i apple_os.bin -l uclinux-2.4.24-ipod2.bin loader.bin
NOTE: -3 is required in make_fw only for 4G iPods.
Once this is done, we can copy the new image and Kernel modules into iPod:
# dd if=my_sw.bin of=/dev/sda1
# mkdir /mnt/ipod
# mount -t ext3 /dev/sda3 /mnt/ipod
# cp -r lib /mnt/ipod
# umount /mnt/ipod
For userland installation, I downloaded the iPodLinux compress FS and performed the following steps to install filesystem:
Mount iPod root partition
# mount -t ext3 /dev/sda3 /mnt/ipod
Extract the filesystem
# mkdir /mnt/linuxos
# mount -o loop \
floydzilla-2005-08-28-ipod+iboy+doom.img /mnt/linuxos
#cp /mnt/linuxos /mnt/ipod
and finally, unmount the iPod partition
#umount /mnt/ipod
#umount /mnt/linuxos
#eject /dev/sda
And we are done. But before you start playing Doom on iPod, it needs to be rebooted.
To reboot disconnect your iPod from the USB port. If the iPod did not automatically reboot hold down the menu and the play buttons for 3 seconds to reboot it.
After reboot keep the back button pressed to boot Linux, otherwise the default interface will load.
Programming your iPod
First thing required to compile hello world on iPod would be ofcourse a compiler.
But why a new compiler? because iPod have ARM processors and a cross compiler is required to compile programs for this architecture. Download the compiler for uclinux from here.
After the cross compiler is installed, next thing to do would be to write a hello iPod program.
Once done, compile the program:
# arm-elf-gcc -o hello hello.c -elf2flt
copy the program into iPod:
# mount -t vfat /dev/sda2 /mnt/myIpodSongs
# mkdir /mnt/myIpodSongs/myprogs
# cp hello /mnt/myIpod/myprogs
and reboot the iPod(After unmounting the partition)
# cd $HOME
# umount /mnt/myIpodSongs
# eject /dev/sda
After booting into floydzilla, goto "File browser->/mnt/myprogs" and click on the "hello" to see output of hello world on iPod.
Click on read more to view some of the images.