Technology

My experiments with iPod

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.

Google on command line

In my quest for writing webservices in C, I wrote a small command line utility for collecting information from Google.

Released the first (0.1) version of Gcmd this weekend. Project home page is located at http://gcmd.sf.net. Being POSIX compliant as of now, it should work under variety of UNIX like Operating systems and Cygwin.

Following features are currently included:

  • Google command line search for a keyword.
  • Compare search results for two keywords in Google.
  • For a given URL collect the following statistics:
         i. Websites having link to this URL.
         ii. Websites similar to the given URL.
         iii.Website containing this URL in their page.
  • Spelling suggestion for a word or phrase.
  • and I am planning to add few more features.

    So download this utility from here and let me know what you think about it.

    Future of blogging

    According to news.com, a new blog is created every 7.4 seconds. That adds up to 12,000 new blogs a day, 275,000 posts a day and 10,800 updates an hour. Technorati, a search engine that monitors blogs, tracked more than 8 million online diaries as of March 21, 2005, up from 100,000 just two years ago.

    Blogging is really catching up. Indian government is also planning to open doors to Indian bloggers.

    I was wondering on how future of blogging will look like.

    Blog Weblog wrote that Autoblogging will be the wave of future. According to them, some examples of autoblogging could be :
    1. autoblogging by email
    2. autoblogging via mobile phone
    3. autoblogging in a supermarket with a PDA

    A new term Moblog is emerging in blogging these days.
    Recent interest in wireless blogging seems to revolve around SMS. Essentially this is e-mail blogging from a cellular phone using an SMS to E-mail gateway.
    Though, Blogging using PDA is also becoming common. People have started blogging using Camera phones, and there are products to even update a blog using phones.

    People are finding Audio blogging as interesting. I recently noticed a site audioblogger which seems to be an extension of Blogger and provides unlimited audio posts. Another site audblog allows bloggers to post audio to their blogs using any phone.

    Talking about expressing ideas, Video blogs seems to be the next extension to audio blogging. Vidblog contains a collection of video blogs, and the number seemed fairly surprising to me. Search engine giant Google is also looking towards video blogging, they have already started accepting videos.

    There are so many blogs on web that it becomes difficult to keep track of them. RSS, ATOM, RDF, OPML (Outline Processor Markup Language) are few of the popular specifications of syndicating and sharing weblogs. OPML is a file format which can be used to share RSS subscriptions. It can be used in RSS aggregators like Bloglines or Akregator to import an OPML file to subscribe to all the feeds.

    Lot of Companies are encouraging their employees to blog. Google was probably the first one to create a corporate blog, and now there are others including Microsoft, Macromedia, Yahoo search and Ask Jeeves.

    With all these new changes taking place in blogging, it makes me think how it will look like in future. Adding few more points on what Fabrice wrote on this:

  • Blogging and social networking softwares will converge.
  • websites will become more blog like.
  • Corporate blogging will grow. Companies are already finding it as a way for the employees to express their thoughts and concerns.
  • There will be areas other than technology and politics emerging in blogs.
  • Based on blogger's interests, new blogging groups will start emerging.
  • New business models for blogging will emerge. Companies like google, yahoo, msn, bloglines are already working on providing blogging services, and it might take form of something similar to having a premium blogging account with more space and more features with some extra charges.
  • XML feed