Linux DevCenter    
 Published on Linux DevCenter (http://www.linuxdevcenter.com/)
 See this if you're having trouble printing code examples


Linux on an iPAQ

by Chris Halsall
06/01/2001

Using a Compaq 3650 iPAQ can at first be a bit of a mind-blowing experience. You're holding in your hand a 206-MHz StrongArm processor, 32 megabytes of RAM, and a 240-by-320 pixel color LCD screen. Other than the display, this is better than what we had on our desks only a few short years ago!

The physical design of the unit is quite sexy, with a metalized finish and curved side edges. It feels comfortable to hold, if only slightly heavy. In addition to a regular sync port, the iPAQ also has an expansion bus which, with the use of Expansion Pack jackets, allows the use of one or two CompactFlash or PCMCIA cards.

In addition to the display (able to show 4,096 colors), it also includes a built-in speaker and microphone, plus an audio jack for private listening. Four application buttons straddle a five-action joystick, perfect for games -- I mean -- spreadsheet navigation. There's also a fifth application button, "Record", positioned to be immediately accessible by the thumb when held in the left hand.

At the very top of the unit, in addition to the audio jack, is the IR port, and the location where the stylus is held. Once inserted, the stylus will not fall out no matter how much G-force the unit is subjected to. To get the stylus back, you must press a button just to the left, at which point it jumps out part way -- very James Bond.

Now, all this power and capability comes at a rather steep price -- suggested retail for the 3635 model is $599, although you can find them (or the 3630/3650; the same hardware) for around $500 without too much effort. This is twice the price of the Agenda VR3, and three to five times the price of a low-end Palm.


The Compaq iPAQ.
The Compaq iPAQ.

 

Previously in this series:

Linux on Your PDA

The Agenda VR3: Real Linux in a PDA

Comment on this articleHave you tried any of the various Linux distributions available for the iPAQ? If so, tell us what you've discovered.
Post your comments

However, Compaq can't build iPAQs fast enough. Recently there's been a general shortage of units in many retail channels, with most iPAQ customers being on waiting lists with retailers, or ordering directly from Compaq (and still waiting two weeks). Production is being ramped up, so this should be less of an issue soon.

Linux instead of Windows CE: But which Linux?

The iPAQs come pre-installed with Microsoft's Windows for Pocket PC, formerly known as Windows CE, or WinCE (rhymes with "prince"). For those who want to run a more familiar operating system, Linux can replace WinCE in the unit's 16 megabytes of flash ROM. While Compaq won't sell a unit without WinCE, they are contributing considerable resources to making Linux work on the machines.

Compaq hosts and sponsors the www.handhelds.org site, which is a community resource center, primarily for developers, hosting Web, FTP, CVS, and mailing-list services. The site focuses on Linux under StrongArm SA11xx processors, such as the iPAQ and the Yopy, but does not mention work on other processors such as MIPS or 68xxx. At the site are detailed instructions on installing Linux on a iPAQ, which we will cover in more detail below.

Similar to the situation on personal computers, there is more than one choice as to which Linux distribution to run on an iPAQ. Until recently, the reference distribution known as compaq (or hh for handhelds.org) was the most commonly used. The distribution was first released as v0.1 (really v0.01) in May of 2000, and has been steadily improving over the last year, now up to v0.21.

As the name implies, this distribution is a Linux kernel and OS environment produced by Compaq. Being a reference design, others were encouraged to use it as a base to experiment with, which is exactly what happened. While Compaq focused on getting the kernel and critical facilities like X working, other projects built on this work to create new distributions.

One example of this is the Familiar distribution, a lightweight package with Python and XFree86 with anti-aliased fonts, using the Blackbox window manager. Familiar also includes a new packaging system called ipkg, which is like RPM or DEB packages for desktop Linux. Put together by Alexander Guy and Carl Worth, Familiar version 0.4 was just released as a stable version. See familiar.handhelds.org for more information.

In an excellent example of the open-source process resulting in organic evolution of code and projects, Compaq has decided to drop their own distribution and adopt Familiar as the new reference. Familiar 0.4 was so much further along compared to their own v0.21, they asked the participants of the e-mail list what people thought of the idea -- it was greeted with enthusiasm.

Another distribution is known as Intimate, and is an extension of Familiar. Unlike Familiar, which is designed to fit inside an unexpanded iPAQ, Intimate requires at least an extra 340 Mbytes of storage be available, usually by way of a microdrive. Intimate's goal is to provide a "full-blown" distribution for the iPAQ, including things like Doom, Konqueror, and MPEG players. See the Intimate homepage for details and screenshots.

In addition to these three general-purpose distributions, there are also three specialized distributions available. Century Software Embedded Technology has a system that starts with the hh distribution, but replaces the X Window System with Microwindows and the Fast Light ToolKit (FLTK). Also included are several applications, including PIM software and a web browser.

Trolltech has ported its Qt Palmtop Environment (QPE) to the iPAQ, making it available as source or a simple /usr flash image used as a drop-in replacement for the one provided with the hh distribution. Like Microwindows, Qt replaces X with a direct-to-framebuffer interface that makes things a little faster. QPE is available for free for individual users, although commercial developers must pay a license to develop for the platform.

Transvirtual Technology's PocketLinux technology, however, is a bit unique. It, like the others, builds on the work from Handhelds.org, but instead of a Linux environment, its goal is to provide a Java runtime instead! Created by the authors of the Kaffe Java Virtual Machine (JVM) -- a clean-room, open-source implementation of Sun's "write once, debug everywhere" language (that's a joke) -- PocketLinux is intended to run Java applications.

Wow! Six distributions -- all for a handheld! One might think there's been excessive forking going on. In fact, these distributions simply represent the current available technologies, all ported to the platform. QPE and Microwindows are targeted more to PDA application developers, rather than X and Linux geeks. PocketLinux is even more specialized, using Linux more as a substrate upon which to provide a Java runtime.

The choice of which distribution to use really comes down to a simple set of criteria. Want the X Window System? Run Familiar, or Intimate if you've got a microdrive. More interested in lightweight application development? Consider QPE or Century Software's Microwindows. Love the speed (of development) of Java? Then you'll want to develop for PocketLinux.

As the Familiar distribution is now the reference -- there will be no additional releases of hh -- this will be the choice for those wishing to be involved with the latest development activities.

Installing Linux on your iPAQ

The actual installation process is fairly straightforward, although as with all such activities, care must be taken to prevent creating a brick. Compaq has committed to recovering any units which do meet with an unfortunate flash, but they'd really prefer not to have to. Also, it's advisable to make a backup of the current WinCE installation before you overwrite it; you paid for it -- might as well keep an image.

Ironically, the initial installation of Linux on the iPAQ requires the use of a Windows desktop platform. This is because we need to install the osloader program, which bootstraps the process. This can only be transferred to the unit by using Microsoft's ActiveSync tool. Osloader also creates the WinCE backup images, which are also transferred by ActiveSync.

Osloader contains a copy of the bootldr program, which handles how the iPAQ boots. This is similar to the Agenda VR3's PMON, or a PC's BIOS/LILO, and is written to the boot block of the device. As with other devices with a boot block in the flash, this should be write-protected to prevent accidental overwriting.

The remainder of the installation process is done by way of a serial connection using a communications program like Hyperterminal under Windows. As all color iPAQs come with USB cradles, it means a serial cable or cradle must be purchased before the Linux installation can be completed.

Once bootldr is installed and running, a dialog is established through the serial port at 115,200 Kbps. Installing or upgrading Linux simply involves entering "load [blockname]" (when {when "blockname" is replaced with bootldr, kernel or root, or a hex address), and then sending the appropriate file to the device via xmodem.

Earlier versions of bootldr had problems with transfers under Linux because of xmodem timing issues, but this has been improved with later versions, and can be further tuned manually by setting timeout values. For this reason, along with better power management support, I advise you to upgrade bootldr to the latest version -- rather than using the one installed by osloader, which will most likely be much older than what's currently available.

Exactly what files are flashed into which sections depend on the particular distribution being installed. They all share the bootldr, and they all have a kernel image and at least one file image, but these can vary considerably between distributions. Also, some use multiple cramfs format filesystems, while the latest Familiar uses a single JFFS2 format partition.

For specific installation instructions, see the ReadMe doc or other documentation included with each distribution. These documents are all quite complete, and can be followed by anyone with moderate technical ability. The good news also is it is actually rather difficult to incorrectly flash the units to a point of not being able to recover to bootldr. Once bootldr is installed and write-protected, upgrading between the different distributions is fairly easy.

Running Familiar 0.4

Booting the Familiar environment takes less than 20 seconds to go from a reset to having a full Linux and X Window system up and running, with the Blackbox window manager. By default, Familiar launches its full-screen handwriting recognition (HRW) program fscrib, a fork of xscribble, which opens a small window in the upper-left-hand corner of the screen.

Hidden at the very bottom of the screen is a control panel that can be fully displayed by tapping at the very bottom of the screen. This lets you move between the open windows on the current desktop, and switch between one of four desktops. Because this panel is always top-most on the display, you can use this to navigate around even when an application opens a full-screen window.

Applications are launched by tapping anywhere on the background desktop area. The menu is generated from a simple text file, /etc/X11/blackbox/blackbox-menu, which can be modified as desired to add new items. For those who have trouble reading the anti-aliased menu items, this can be a handy file to check out too.

Familiar 0.4 is configured to have the display in "landscape," or rotated mode, giving a 320 x 240 pixel display. "Portrait," or 240 x 320, can also be configured, if desired; a menu-option for this possible, using the xinerama extension of X, although isn't installed by default.

Selecting HWR.
Selecting stylus-as-mouse.
Handwriting recognition is activated by clicking on the keyboard icon on the fscrib window; clicking the mouse icon reverts to regular stylus-as-mouse mode.

 

The xvkbd keyboard.
The xvkbd keyboard.

The HWR program, fscrib, is interesting in that unlike most other handwriting-recognition systems, you draw (and leave a trail) on the entire screen. After each stroke, the trail is quickly removed, and you continue on. The trail drawing and removal is done by fscrib itself, and does not rely on having the applications redraw themselves. The HWR itself is activated by clicking on the keyboard icon on the fscrib window; clicking the mouse icon reverts to regular stylus-as-mouse mode.

While the character recognition is quite good (see HowToUseFscrib at the Wiki site), there are times when a virtual keyboard is needed. For this, the program xvkbd is provided. It is actually possible to have both running at the same time, for quick interchange between them.

While there has been quite a bit of software ported to the iPAQ, Familiar 0.4 does not come packed with very many applications. Instead, it is assumed you'll update and upgrade your iPAQ with desired software using the ipkg facility. Similar to the RPM or DEB facilities under desktop Linux distributions, ipkg is a user-friendly way of handling software packages, and is network enabled.

For console access to the iPAQ, there is the rxvt X terminal provided in the application's menu. Using a regular serial communications program, Familiar also is configured to allow serial console access (the root password is "rootme"). You can use this to ensure you have a good serial connection to the device.

xterm screen shot.\
The rxvt X terminal.

In addition, the serial port is also configured to detect the start of a PPP session. As root on the connected Unix desktop, enter:

/usr/sbin/pppd /dev/ttyS0 115200 192.168.1.100:192.168.1.3 nodetach noauth debug nocrtscts lock user ppp connect '/usr/sbin/chat -v -t3 ogin--ogin: ppp'

... and then wait. Within a few seconds you should get a report of success and should be able to ping the iPAQ. The above assumes your host computer's IP is 192.168.1.100, and the IPAQs is being assigned as 192.168.1.3. Also, adjust /dev/ttyS0 to be appropriate.

By default under Familiar 0.4, the only network service available (other than X at 8000) is ssh. So the next step is to ssh into the machine. Enter ssh root@192.168.1.3, and if everything's working OK you should quickly be greeted with a "request root's password" message. rootme, and you're in.

If ssh fails, but you're able to ping the iPAQ, it means the ssh daemon failed to launch. This is almost always because the ssh_host_key was not created, usually caused by not completing the install instructions. This can be rectified by running /usr/bin/ssh-keygen -f /etc/ssh/ssh_host_key -N '' on the iPAQ, and then sshd. This can be done via rxvt, or by breaking the PPP connection and using the serial console access.

Once you have a PPP session running with ssh access, additional configuration can be done through the comfort of TCP/IP networking. Files can be transferred between the iPAQ and the desktop machine using scp. To enable access to the full Internet by the iPAQ, its IP must be masqueraded. This is done on the host computer, and is detailed at the Handhelds Wiki site, among many others.

Once the iPAQ is able to connect to the full Internet, the last step is to configure either the /etc/resolv.conf file with one or more DNS servers, or at least set up an entry in /etc/hosts for familiar.handhelds.org. This will allow the ipkg system to connect to its server, allowing the ipkg update and ipkg upgrade commands to work correctly.

At this point, you're pretty much working with a standard Linux installation; it just happens to be sitting in your hand or in your pocket -- instead of on your desk or floor. I find it rather amusing that the display size, 320 x 200 pixels, is the resolution that many of us were first able to render to as a "bitmap," using our clunky old Apples and Commodore 64s.

Conclusion

The Compaq iPAQ is a remarkable piece of hardware engineering, with a tiny form-factor considering the power of the device. There is little wonder why the product has been in such high demand lately. Even without all the software of the Palm, an iPAQ running WinCE can be a great asset during those occasional "who's got the best PDA" contests.

Fortunately, and largely thanks to Compaq themselves, there are also several Linux-based options as well, as detailed above. The diversity of the offerings is also interesting, as we watch different groups (both commercial and not) build upon the base Linux kernel and OS to deliver different targeted solutions.

For anyone who's wanting to run a Linux-based iPAQ as a day-to-day PDA, one of the specialized distributions like PocketLinux or QPE would probably be your best option right now. Familiar is also a possibility, as there are a couple of Personal Information Management (PIM) suites available for the platform, including the PIM software for VR3 by Agenda Computing.

But really, where the most excitement seems to center is around making the iPAQ as capable as possible as both a Linux and a X Window system platform. The general option seems to be that, well, sure it can run PIM apps, but it could be a portable network analyzer, or a video-streamer, or the CPU for a wearable platform (PCMCIA video cards and all), or, well, just about anything.

The question as to which windowing system is best -- X, Qt, or Microwindows -- is still being "discussed." Those in the X camp argue that the ability to import and export displays, not to mention the ease of application porting, far outweigh the slight speed advantages of a direct-to-framebuffer option. This can be best measured by the number of apps being ported to the different platforms. Only time will tell for sure, but I suspect that X will end up the most common target.

Emulation is also an area receiving a lot of attention. People are porting emulations for older devices (Gameboys and Commodore 64s, for example) to the iPAQs, and running their old software within the machines. I'll personally bet anyone a pint of beer (at the pub of my choosing) that we'll see the POSE Palm emulator running on the iPAQ within a year. I own a Palm, so using an image of the ROMs in the POSE will be legal and give me access to all the Palm apps. I think this will be a common situation.

The community that has formed around the Handhelds.org site and the Linux iPAQ development project, is large and active. The development e-mail lists receive dozens of posts a day, with the IRC channels regularly attended. Development types will immediately feel right at home.

On the other hand, the Linux iPAQ user community is not nearly as well-represented. This can quite simply be explained by the fact that there aren't many end users using Linux on their iPAQs -- they're sticking with WinCE. And, in the short term, this isn't likely to change.

But for power users who want more, the iPAQ running Linux is a very versatile platform. While Linux isn't likely to cut much out of WinCE's market share, those using Linux are able to enjoy the inexpensive "kit" made possible because of the demand for product (the M$ "tax" non-withstanding).

Anyone interested in mobile, "personal" computing would be well rewarded giving Linux on an iPAQ a try. While not quite ready for end users yet, it is definitely worth experimenting with now -- a full-powered PC in your pocket. Besides, the weight of the iPAQ nicely balances that of your Palm in your other pocket, until the day you don't need it anymore ...

Online resources

There are considerable resources available online for iPAQ developers. Interestingly, there are fewer user-targeted sites, but these will no doubt develop over time.

Handhelds.org
Site run by Compaq to "encourage and facilitate the creation of open-source software for use on handheld and wearable computers". Hosts CVS and FTP servers with distributions, kernels and apps.

HandheldsWiki
User contributed/edited web resource pages.

Familiar homepage
Download and development resource site for PocketLinux.

PocketLinux.org
Download and development resource site for PocketLinux.

Copyright © 2009 O'Reilly Media, Inc.