Porting Linux to the iPodby Howard Wen
Just as the name Linux on iPod suggests, now you can have Linux running on your iPod. With Linux on iPod, you can play (to a limited degree, as of this writing) MP3 and Ogg files under Linux on your iPod. This is possible thanks to the work of just one man, Bernard Leach, a 30 year old software engineer in Wiesbaden, Germany.
Practically speaking, though, why should one even bother with running Linux on an iPod? Its creator hopes that his accomplishment will help extend the functionality of this closed-system gadget by inspiring others to develop Linux-based applications for it.
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. The code is released under the GNU General Public license.
Howard Wen recently interviewed Bernard about the project.
O'Reilly Network: Can you tell us a little bit about yourself and your background?
Bernard Leach: I'm actually from Melbourne, Australia and have only been here [in Germany] for the last two years. I previously worked as a software engineer for a company that develops cryptographic hardware.
ORN: What was your inspiration for porting the uClinux kernel to the iPod?
BL: The inspiration to port Linux was the challenge itself! From what information I could find about the iPod, I could tell that it was more than capable of running Linux. I'd seen what people have managed to do without being able to modify the firmware. And I knew that being able to do so would open up many opportunities to add further functionality.
ORN: Did you develop or use any other tools to help pull off this port?
BL: In terms of software tools, the GNU compiler toolchain was essential to the port, not only for building the software to run on the iPod, but also for examining the existing software. Besides the toolchain, Perl, Vim and bc. On the non-software side, I spent a lot of time on Google looking for information.
ORN: What kind of modifications did you do to the uClinux kernel, if any, to get it onto the iPod?
BL: The kernel modifications to uClinux were quite minimal. To get the kernel to run, you basically need to supply code to manage a timer, some interrupt processing, and start-up code. Since there are quite a few other uClinux ports, this part is all fairly straightforward. Normally, you would also need a bootloader to get started, but I was able to take advantage of the existing loader in the original firmware. On top of that, you need to add drivers for the various I/O devices. Fortunately, Linux comes to the rescue here as well; drivers like the multi-platform EIDE driver just needed some register addresses defined in order to work. Similarly, the keyboard driver and framebuffer simply build on existing drivers.
ORN: What were the technical challenges you faced in developing this port?
BL: The real interesting challenges were really before I started the port. Since there is very little technical information available on the processor in the iPod, the real challenge was to work out how it all fit together. After that, the biggest challenge was always how to debug the code. Normally, you'd have a serial port available, but with the iPod there's nothing really available for debugging.
ORN: Regarding the inner workings of the iPod, what are the unique challenges in porting Linux to the iPod? Did you learn anything interesting about the iPod itself?
BL: With the basic port, there's nothing really anything unique about this particular port.
ORN: Take us through the basic step-by-step process of what you had to go through to figure out how to get this port working.
BL: In order to get the port working, there were a number of milestones I needed to reach: Working out the boot process, and building up a memory map sorting out the protocols for the various devices. Getting there wasn't so much of a step-by-step process. It was more akin to solving a puzzle where all the picture was worked on together. A lot of time was spent analyzing disassembled code, following code paths, noting special addresses, and slowly building up the big picture. Eventually, I had enough information to start testing some of the theories, and—slowly through these short, special-purpose programs—the remaining questions were resolved.
ORN: So, let's be clear: You didn't physically take apart an iPod to do any of this?
BL: No, I didn't take my iPod apart, but a number of other people did, which is how the major components were identified. From those dissections, I had the part numbers to search for the various data manuals for programming them.
ORN: What features do you plan to add to future versions of your port?
BL: At the kernel level, most of the features have been implemented to some extent. Now it's more about getting the drivers to work better or in new ways. I'd also like to get the new HFS+ driver in so Mac iPods can run the port without a reformat.
ORN: Was providing FireWire support difficult? If so, why?
BL: The FireWire was something I intentionally put off because I thought it would be quite hard. Since the initial release of the port, I have managed to add support for FireWire and my suspicions were certainly justified. Getting the FireWire going was one of the hardest parts of the project!
There were a number of reasons: Firstly, I only had a vague understanding of the protocol and how it worked. Secondly, the support in Linux is pretty flaky. I can crash my machine just loading and unloading the sbp2 module. And, finally, the documentation for the Texas Instruments chip on the iPod is pretty vague in certain areas.
Just recently, thanks to the guys at SiK.com, I got the hardware together to test connecting a CompactFlash reader to the iPod. So far, I've only had limited success, but it's getting there. Once I get that working, I plan to write a small application that will let me copy digital images from CompactFlash cards to the iPod.
ORN: What sorts of contributions could your work use from outsiders willing to volunteer their skills?
BL: I'd welcome contributions to any part of the port. Up until now, almost all of what I've done has been a part of my learning process. I've worked with a kernel before, but for this port I needed to create a number of different types of drivers, all of which were new to me.
The FireWire is the last major I/O driver missing, but power management support, accomplished by throttling the CPU speed, is another important area yet to be addressed. So far, I've been quite focused on getting the core kernel services working, but as people look to get "real" applications running, higher-level services need to be developed; most obvious here is a working GUI layer. Porting one of the lightweight GUIs, such as Microwindows or PicoGUI, would be a good start.
ORN: What advice do you have for those who might want to modify the port you created?
Other Linux Interviews
BL: For people looking at modifying the port, I would say, "jump in!" There are certainly many areas which need work. I would suggest to take the time to get to understand the current source. Also, join in on the mailing list to share with others what you are working on.
ORN: Any advice on the kind of applications—which would technically work best under your port—that others should try to develop for the iPod? What should be avoided, at this point?
BL: The iPod is a music device and so, not surprisingly, audio applications are ideal. At the moment, performance is still an issue. High performance audio decoding is one area that really needs work, but the biggest barrier at the moment is a working user interface layer.
ORN: Have you played with the new iPod models that were recently released? Are they any different in terms of hacking?
BL: The new iPods look really nice! I haven't had a proper play with one yet, but I've been looking at the new firmware to see how they might differ. Generally, it looks like some of the hardware has been hooked up a little differently, but it doesn't look like there will be any problems with getting the Linux port running on them.
From the hardware perspective, the recording feature discovered by the guys at ipodding.com looks really interesting. The core chip on the iPod has always supported audio input so it's nice that they have added it. Depending on what software support they add in the standard firmware, there might be a call for extra functionality running under Linux.
ORN: So what have you been listening to lately on your iPod?
BL: Not a lot of new music, unfortunately. The last album I bought was 100th Window by Massive Attack, which is quite cool. Just for the record, "Dumb" by Garbage was the first MP3 to play under Linux on the iPod!
Return to the Linux DevCenter.