Hack 17. Run Linux on Your Palm
Although it's not the Palm version of Linux that will no doubt blow our socks off when it eventually arrives, uClinux is a good way to play around with an alternative operating system on your Palm.
If you haven't heard already, Palm is switching operating systems, and in the not-so-distant future, Palm-Powered will mean Linux-Powered, but with all the elegance and grace of the current Palm OS. It's going to take a while, though. If you want to give Linux a whirl on a Palm right now, it's quick and easy. You won't get any of the graphical goodness you'll eventually get with the future version of Palm OS, but you will have a chance to play around a bit and run this powerful operating system right on your little handheld.
Unfortunately, Linux doesn't run on a lot of Palms. The good news is that it runs on a lot of older popular models, such as the IIIe, IIIx, V, Vx, and even some of the m series. You can usually find these Palms very cheaply [Hack #50], so you can play around with this on the cheap. In fact, when I bought a used Palm Vx for $30, it included a USB-to-serial adapter, which was worth nearly the price I paid for both items!
2.8.1. Boot Linux on Your Palm
The simplest way to get Linux running on a Palm is to pick a well-supported Palm, such as the Vx, and download a binary release of Linux from http://palm-linux.sourceforge.net/. At the time of this writing, they had versions that worked with the m500 as well as a bunch of older models. What you'll get is a small PRC file (such as uClinuxPalm.prc) that has the Linux distribution and a bootloader. Install the PRC on your Palm, and you're just about ready to launch Linux.
I say just about, because you need a couple of things. First, you need to be prepared to sacrifice everything in your Palm's storage. After you launch Linux, you'll lose all your settings, appointments, contacts, and even installed applications. You can reset your Palm and go back into the Palm OS, but it will be as if you'd performed a hard reset.
Second, you need a way to talk to the Palm. Unfortunately, if you want to interact with the Linux operating system running on your Palm, you need to use a serial connection and a terminal program. So, you won't be taking your Linux-powered Palm on the go with you. Here's what you need to do to get this all working.
220.127.116.11. Setting up the serial connection.
If you've got a recent notebook computer, a Mac, or legacy-free PC, there's a good chance you don't have a classic serial port. However, there are many USB to serial adapters that can do the trick. The PalmConnect USB kit, shown in Figure 2-27, is a small dongle that will work for Windows and Linux users.
Figure 2-27. The PalmConnect USB kit
Although it ships with a CD-ROM, the PalmConnect hardware is of an old enough vintage that you should check http://www.palm.com to see if there are any updates to the driver (Mac OS X users will not be able to use the PalmConnect kit for this, since the Mac OS X drivers do not represent the device as a serial port). Also, Keyspan (http://www.keyspan.com) makes a variety of USB to Serial adapters that work with Windows, Mac OS X, and Linux.
Once you've installed the USB to serial adapter, you need to figure out where it lives. On Linux and Mac OS X, serial ports appear as files in the /dev directory. On Windows, they appear as COM ports. Table 2-2 shows some possible candidates for serial ports for systems with both USB to serial and built-in serial ports.
18.104.22.168. Installing Palm Linux.
Installing Linux on your Palm is as easy as installing the PRC I mentioned earlier. On Windows or Mac OS X, set up Palm Desktop and use Quick Install to install the PRC. The next time you perform a HotSync, Palm Linux will be installed. On Linux or Unix, you can use the pilot-xfer utility to install it:
$ PILOTRATE=115200 pilot-xfer -p /dev/ttyS0 -i uClinuxPalm.prc Listening to port: /dev/ttyS0 Please press the HotSync button now… Connected Installing uClinuxPalm.prc Time elapsed: 0:01:26
Once it's installed, you'll see a Loader icon in the launcher, as shown in Figure 2-28.
Figure 2-28. The Palm Linux loader
22.214.171.124. Booting Linux.
Before you boot Linux, you should start talking to the serial port. If you're on Mac OS X or Windows, you've probably still got HotSync running and listening on the serial port. Since this will prevent you from opening a terminal session with the serial port, be sure to release the serial port before you proceed. You can either launch HotSync and configure it to not use the serial port, or shut it down altogether. If you do tell it to stop using the serial port, you'll need to switch it back before you can perform a HotSync again.
Once you've shut down HotSync, you can open a session with the serial port. On Windows, launch HyperTerminal (open the Start menu, choose Programs Accessories Communications HyperTerminal) and open a session with the serial port your Palm is connected to. You should use a serial port speed of 9600, and leave the rest of the settings at their defaults. On Mac OS X or Linux, you can use the screen program to connect to the serial port, as in screen /dev/ttyS0 (use Ctrl-A, K to end your session). You wont see anything at first, but once you make this connection, you're ready to boot Linux.
To boot Linux, tap the Palm Loader icon. You'll get the warning shown in Figure 2-29. Tap Boot Linux, and your serial port session will fill up with boot messages:
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFRBCK 68EZ328 DragonBallEZ support (C) 1999 Rt-Control, Inc uClinux/MC68EZ328 Flat model support (C) 1998,1999 Kenneth Albanowski, D. Jeff Dionne PalmV support by Lineo Inc. <jeff@uClinux.com> Console driver (without boot console): mono mc68328 40x26, 1 virtual console (max 63) Calibrating delay loop..
Figure 2-29. The Palm Linux warning
There will be a short delay, and then the boot messages will scroll across your screen. As this is all happening, the uClinux logo appears on the Palm, as shown in Figure 2-30. Once Linux is fully booted, your serial session will display a shell prompt:
Congratulations, you've got Linux running on your Palm. When you're ready to go back to the Palm OS, you can type reboot and press return, or simply do a soft reset.
Figure 2-30. Palm Linux is up and running
2.8.2. Roll Your Own Palm Linux Distribution
uClinux makes it possible to put together your own Linux distribution for your Palm, but it takes a bit of work to get all the pieces together. The good news is, once you've got the necessary tools, it's pretty easy to build a bootable Linux image for your Palm. In theory, you just need a cross-compiler, Palm's PRC tools, and the uClinux source. The bad news is that I could not successfully compile a kernel for my Palm Vx using the latest releases of these packages. The good news is that there is a well-documented combination of versions that works like a charm. For more information on this combination, see http://www.ucdot.org/article.pl?sid=03/02/07/1329233. Here's what I grabbed to get it all working:
Here's how I built Linux for my Palm Vx:
When it's done compiling, you should have a file called uClinuxPalm.prc in the images/ subdirectory. If something goes wrong, check out http://www.ucdot.org/article.pl?sid=03/02/07/1329233, which goes into this process in more detail. Once you've got it compiled, you can install the PRC file as described earlier in this hack.
You might get bored with the limits of running Linux on your Palm in the way described in this hack. Fortunately, you can go a bit further with some other gadgets. uClinux is used for both Nintendo DS Linux (http://www.dslinux.org/) and iPod Linux (http://www.ipodlinux.org).
Also, there are many inexpensive embedded systems and single board computers that are capable of running uClinux. Figure 2-31 shows my Nintendo DS running uClinux with the boot messages at the top and the virtual keyboard on the bottom touchscreen.
Figure 2-31. uClinux running on the Nintendo DS