Do you remember that nice small gadget called the Palm Pilot that everybody wanted desperately and made you look so cool just a few bunch of years ago? I bet you even have one in your drawer but are just too embarrassed to take it out and show it alongside your friend’s shinny new smartphones.
But I’m diverting. Have you considered the fact that those once cool little machines may be capable of running something else than the now dreadful PalmOS? Why on earth would you want Linux on that thing anyway? Well, why not?
As it turned out to be, I found that from a learning perspective, trying to fit a standard Linux Kernel into a Palm is just what the Geek Doctor prescribed, not to mention that by doing it you do are entitled to show off your Palm and brag about it with your smartphone friends, how about that for a spin?
So I figured out that having nothing better to do on a Saturday night I might just as well write about my little Linux and Palm – Frankenstein project. What do you know, I can even put a few words the Android topic as well if it suits.
What do you need to put Linux in your Palm?
Fortunately, it has been done before by a couple of ex PalmOS developers in search of redemption from working so many years with such a hideous thing (PalmOS, that is). So you may want to check a site called Hack&Dev. There’s a nice working version of it for the Palm TX, but of course if we stop there that wouldn’t be fun and we will spoil Christmas too soon.
So where to start? Well we need to follow some sort of steps like the following:
- Get a Palm. Seriously. Using Palm simulators is cheating on yourself. I have a Palm TX so I got started with that, not that I need another one though.
- Decide how you want to boot the Linux image once you have it. Basically, PCs have Master Boot Records, and embedded devices have Bootloaders. Palms come with a ROM image with everything in it, including a Bootloader. So if you want to override what’s in the Palm, you’ll need a way to rewrite the ROM and of course you need to backup your current one if you ever want to get your old PalmOS back (say when you bragged enough). There’s a nice alternative though, most of the latest Palm devices (latest I mean from 2003 up) have external memory card support (SD, Memory Stick, etc). I found we can use a PalmOS program that will act as a Bootloader using an image that could be stored in your SD card. Pretty convenient huh? Now we can keep the PalmOS ROM and test out our awesome Linux images using only our external card. If we screw up, just reboot and Palm OS will rise form the dead again. The best PalmOS Bootloader program I’ve seen is called Cocoboot, so google it.
- Now that we have a safe way to test stuff, we need to build the stuff. This is where I guess 90% of the readers will close the webpage, not because you can’t do it, but because it is way too tedious. Here’s where the research efforts are spent. You’ll need to:
- Learn how the Linux system boots. There are lots of internet articles on this topic, but in short, learn that the Bootloader loads the Kernel, the Kernel mounts the root filesystem, the Kernel then calls the init() function to perform (amongst other things) hardware specific setup, then the devices mount, Kernel space ends and User space takes over to initialize any juicy stuff you want to put in there like GUI systems, services, etc.
- Learn where to get the code you need. Believe or not, there are specific Embedded Linux Distributions for a lot of popular hardware architectures besides the x86 family. So the job is pretty much done in terms of drivers, Memory Management and Core/Cache logic, etc. Specifically, there’s one distribution targeted at the ARM processor used by our beloved Palms. So the basic chipset is already coded for Linux when it comes to hardware. The tough part would be to plug in specific drivers for WiFi and other stuff that are not contemplated by the core distribution archives.
- Setup a Tool-Chain. A Tool-chain is the whole set of tools (libraries, compilers, linkers, assemblers, debuggers, profilers and even development environments) that enables you to start with your Linux code and eventually get your binary images that run in the target device (the Palm in our case). Keep in mind that you will need to compile/link/package binary code that doesn’t run in the machine that you compile it (unless you dare to install the Tool-Chain in the Palm itself, in which case please write a Blog about it). I recommend using Linux as the host machine where you will setup your Tool-Chain, being my personal taste Ubuntu, though Fedora works too (how cool is that, Linux to build Linux …). Unless you are a real Linux evangelist, try using the GUI/Desktop versions of Linux and avoid the command line as much as you can. You will have to face it eventually so why make yourself miserable form the beginning. Also, I have good news for you, Eclipse has already developed a nice way to work with Tool-chains and it should be very easy for almost everyone to setup one using Eclipse.
- Dig in for drivers. You eventually will want to use your Palm’s Bluetooth, audio, etc. Most of them require drivers that are available already over the internet (except WiFi, darn!!). So search for those and hook them up to your project if needed. They will be regular Lunix MODs so it is not hard to plug them in if they are already compiled for the ARM architecture. I know, I know, this is the toughest part, so you migh just as well skip it. After all, showing off a command line driven Linux in your Palm is also going to be cool. But at least, get the driver for a virtual keyboard, unless your Palm has a physical one already, you will not get pass by the login screen (no it will not be cool to stop here, I can code a fake login screen in PalmOS, so no cheating).
- Compile/Link and package the Kernel. This step is as simple as that. You will get one nice image file. The good thing about the Cocoboot Bootloader, is that it knows how to read compressed image files so you may also create a compressed binary Kernel image file, though it doesn’t really matter from a non Geek perspective.
- Package the filesystems with libraries and tools. Once you package the Kernel, you get to decide if you will include additional libraries and stuff. Well all this extra stuff needs an extra filesystem (virtual hard drive if you may). So you just package the compiled versions of your libraries, shells, games, etc, in this image that the Kernel should be able to mount as an additional filesystem within the already mounted root filesystem, in the good’ol Linux way.
- Test it. Now it’s the time to copy your stuff into your SD card and test it (if you didn’t wipe the Palm’s ROM, in which case you’ll need to flash the ROM with your Bootloader, Kernel and additional filesystems, probably as a single flashimage as most manufacturer’s do.). You will probably hang the Palm the first time (or 100 times). Just be sure to include all the nice Linux logs stdout to the terminal screen so that you may see what needs to be fixed. In my case the drivers I got and all the code was so nicely developed in the ARM Embedded distribution that the only place I got stuck was at the login screen (remember the virtual keyboard I talked about?). Later I used a nice Linux library from the OPI distribution so my Linux got graphical!.
Are you an expert already? Well I guess this is not the 48 hour development endeavor one of my colleagues was blogging about the other day (probably more like a 48 day thing), but I hope at least I gave you the very high level picture of what it takes to totally waste your valuable free time in the name of pure techie style -sugar highs.
Next step: Android (but that my friends, is another story …)
If you are at least a bit intrigued after reading this blog (assuming you really did read it), my mission is accomplished an I can happily say my weekend had a purpose.
May the fork() be with you.