<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V3.1//EN"[]>

<article id="Intimate-install">
 <title>Installing Intimate Linux on a Compaq iPAQ 36xx/38xx</title>
 <artheader>
   <authorgroup>
     <author>
       <firstname>Chris</firstname>
       <surname>Jones</surname>
       <affiliation>
         <address>
           <email>chris@black-sun.co.uk</email>
         </address>
       </affiliation>
     </author>
   </authorgroup>

   <copyright>
     <year>2002, 2003</year>
     <holder>Chris Jones</holder>
   </copyright>

   <legalnotice>
     <para>
       Permission is granted to copy, distribute and/or modify this document
       under the terms of the GNU Free Documentation License, Version 1.1
       or any later version published by the Free Software Foundation;
       with no invariant sections, with no Front-Cover Texts or Back-Cover Texts.
     </para>
     <para>
       A copy of the license is included in the section entitled "GNU
       Free Documentation License".
     </para>
                                                                                             
   </legalnotice>
 </artheader>

 <sect1 id="intro">
   <title>Introduction</title>
   <abstract id="intro-abstract">
     <para>
       Version: 0.6
     </para>
     <para>
       $Header: /cvs/intimate/docs/install-howto.sgml,v 1.6 2003/06/24 11:58:35 cmsj Exp $
     </para>
     <para>
       Installation and configuration of Intimate Linux on a Compaq iPAQ handheld PC.
     </para>
     <para>
     <note><title>WARNING</title>
     <para>
     This is a very new install process and has not seen a great deal of testing yet. We would welcome any feedback you have, but please don't be too disappointed if it doesn't work, there are probably some bugs still to iron out!
     </para>
     </note>
     </para>
   </abstract>

  <sect2 id="background">
    <title>Background</title>
    <para>
      The Compaq iPAQ is a highly versatile handheld PC that features a 240x320 colour LCD screen and a vast array of peripherals, thanks to Compact Flash and PCMCIA expansion jackets.
    </para>
    <para>
      This guide attempts to simplify the process of installing Intimate onto an iPAQ, however, further work needs to be done to automate the process, probably through use of scripting.
    </para>
    <para>
      Since the original Intimate installer was written, significant development has taken place on <application>bootldr</application>, the program used to boot Linux on the iPAQ. These developments include recognising some of the iPAQ expansion sleeves (e.g. the Compact Flash and PCMCIA sleeves), reading from IDE devices and the ability to read MS-DOS formatted partitions. It is also now capable of booting PocketPC, making it entirely possible to have a dual-boot system, with either PocketPC or Familiar Linux in flash memory, and an OS such as Intimate Linux on an external storage device. It is this dual-boot ability that we will be taking advantage of. 
    </para>
    <para>
      The boot process for Intimate loads a kernel image and an 'initial ram disk' (or 'initrd') from an MS-DOS formatted partition and then executes the kernel. The initrd (a gzipped cramfs image) is then mounted and provides a small selection of programs required to mount the main Intimate disk partition and start it booting.
    </para>
    <para>
      While this is not necessarily the cleanest way to boot an operating system, it does mean that none of the precious flash is used, so you can install another OS there, be it Familiar Linux or PocketPC.
    </para>
  </sect2>

  <sect2 id="assumption">
    <title>Assumptions</title>
    <para>
      To limit the size of this document, several assumptions are made - you MUST meet these before beginning any of the tasks described here. Failure to do so is very unlikely to cause any damage, but it might lead to data loss as it involves formatting certain devices.
    </para>
    <orderedlist>
      <listitem>
        <para>
          You have a Compaq iPAQ. Currently the 36xx models are best supported, and 38xx models should now be supported.
        </para>
      </listitem>
      <listitem>
        <para>
          You have installed <application>bootldr</application> 2.18.54. If you have a previous version of <application>bootldr</application> installed, upgrade instructions can be found <ulink type="http" url="http://familiar.handhelds.org/familiar/releases/v0.5.2/install/H3600/install.html">here</ulink> (only the "Installing the Bootldr" section). If you have not yet installed any version of <application>bootldr</application>, installation instructions can be found <ulink type="http" url="ftp://ftp.handhelds.org/pub/linux/dists/compaq/ipaq/stable/install.html">here</ulink>.
        </para>
        <para>
          We have found that newer versions of <application>bootldr</application> (e.g. 2.19.x and 2.20.x) have some issues booting our initrd's. Investigations are ongoing.
        </para>
      </listitem>
      <listitem>
        <para>
          You have some kind of storage device on which to install Intimate. 
        </para>
        <note><title>Can't I use the built-in flash memory?</title>
          <para>Intimate <emphasis>will not</emphasis> fit in the 16MB/32MB Flash ROM in a typical iPAQ, you will need an external storage device of some kind. This could either be a large Compact Flash device, such as an IBM Microdrive, or a PCMCIA IDE hard disk. These devices are typically available in anything up to 5GB sizes.</para>
        </note>
      </listitem>
      <listitem>
        <para>
          Your storage device is partitioned as follows:
          <orderedlist>
            <listitem>
              <para>Primary Partition 1: 10MB FAT16</para>
            </listitem>
            <listitem>
              <para>Primary Partition 2: ext3</para>
            </listitem>
          </orderedlist>
          (the ext3 partition should fill whatever space is left after addition of the FAT16 partition. A typical Intimate install will need this partition to be around 300MB)
        </para>
        <para>
          Both partitions should be pre-formatted. You can do this either with another machine (e.g. a laptop or other machine with pcmcia slots) or from the iPAQ itself if you have <ulink type="http" url="http://familiar.handhelds.org">Familiar Linux</ulink> installed. Whatever system you are using, once you have partitioned the device (using <application>fdisk</application>, <application>parted</application>, etc.), you can use the command <command>mkdosfs /dev/discs/discX/part1</command> to make the FAT16 partition and <command>mkfs.ext3 -j /dev/discs/discX/part2</command> for the ext3 partition (you should replace the block device '/dev/discs/discX/' with the correct path to the block device that represents your storage device). If you are performing these tasks from within Familiar, you will need to install the mkfs commands, which are in the <application>e2fsprogs</application> ipk (e.g. <command>ipkg install e2fsprogs</command>).
          <note><title>Does it have to be ext3?</title>
          <para>For now, yes. ext3is more widely accessible than reiserfs, which in our view makes it more useful for a device like an iPAQ.</para>
          <para>It is also very important that you create ext3's journal inodes on the partition. Passing "-j" to <command>mkfs.ext3</command> (as above) will do this automatically, or, if you want to do it seperately, <command>tune2fs -j /dev/discs/discX/part2</command> will do the trick</para>
          </note>
        </para>
      </listitem>
    </orderedlist>
  </sect2>

  <sect2 id="caveat">
   <title>Caveat</title>
   <para>
     As of time of writing, some of the Intimate packages are out of date. Efforts are being made to update these. Contributions are very welcome!
   </para>
  </sect2>
 </sect1>

 <sect1 id="prepare">
   <title>Preparation</title>
   <para>
     Before installation can take place, you will need to perform a few tasks on your freshly formatted storage partitions.
   </para>
   <orderedlist>
    <listitem>
      <para>
        Either from Familiar, or a laptop, mount the MS-DOS partition (e.g. <command>mount /dev/discs/disc0/part1 /mnt/vfat -tmsdos</command>) and change directory to the mounted partition (e.g. <command>cd /mnt/vfat</command>).
      </para>
    </listitem>
    <listitem>
      <para>
        Create a directory called 'boot' and change directory to it. It is this directory that <application>bootldr</application> will examine to find the kernel image and initrd.
      </para>
    </listitem>
    <listitem>
      <para>
        Download the following files into the 'boot' directory:
         <orderedlist>
           <listitem>
             <para>The kernel image, <ulink type="http" url="http://intimate.handhelds.org/install/zimage">zimage</ulink></para>
             <note><title>Shouldn't that be a capital i?</title>
               <para>On a typical Linux system, the kernel file would be called 'zImage', however, <application>bootldr</application> does not currently understand uppercase letters, so the Intimate kernel file is called 'zimage'.</para>
             </note>
           </listitem>
           <listitem>
             <para>The initrd image, <ulink type="http" url="http://intimate.handhelds.org/install/initrd">initrd</ulink></para>
           </listitem>
           <listitem>
             <para>A <application>bootldr</application> configuration file, <ulink type="http" url="http://intimate.handhelds.org/install/params">params</ulink>. This file tells <application>bootldr</application> to use the zimage and initrd listed above.</para>
           </listitem>
         </orderedlist>
       </para>
     </listitem>
     <listitem>
       <para>
         Unmount the DOS partition.
       </para>
     </listitem>
     <listitem>
       <para>
       Reboot your iPAQ, insert the storage device and from the <application>bootldr</application> screen, choose the "Boot VFAT HDD/CF" option (normally mapped to the 'Q' button). If you have a serial console connected to the iPAQ you should now see a series of messages scrolling past that indicate the kernel is booting. During the boot sequence of the initrd, it checks for the intimate partition and if it finds that it is empty, it will load a minimal XFree86 based environment, giving you a shell and an on-screen keyboard (see Figure 1).
       </para>
       <note><title>Why can't I change any of the files?</title>
         <para>The initrd image is mounted read-only on boot, so you will not be able to make any changes to the system once it has booted. To do this you will need to create a new initrd, but fortunately that process is very simple and is documented in Appendix A.</para>
       </note>
     </listitem>
   </orderedlist>
 </sect1>

 <sect1 id="install">
   <title>Installation</title>
   <para>
   At this point you will need to connect your iPAQ to some kind of network, be it Ethernet, Wireless or USBnet - the installation process needs to download packages from the Internet. If you are using a PCMCIA card for network access, it should ideally be a card that is supported by the standard PCMCIA drivers as they are included in the initrd. However, <application>cardmgr</application> is not running as a daemon after the initrd boots, so you will need to insert the card before booting the initrd, or if you insert it after booting, you will need to run <application>cardmgr</application> manually (the command <command>cardmgr -o</command> will do this). Once the card's driver is loaded, you can use standard tools such as <application>ifconfig</application> to configure the interface, although ideally you should install a DHCP server on a seperate machine to configure the iPAQ's network connection automatically.
   </para>
   <para>
   If your chosen method of connecting it to the internet isn't supported by the initrd (ie it doesn't work), let us know, we will try to help get it working.
   </para>
   <para>
   While is is entirely possible to run the following commands/files via the terminal/keyboard onscreen, it is considerably easier to use a serial cable if you have one (the serial console is set to run as 115200 8N1 with no flow control).
   </para>
   <orderedlist>
     <listitem>
       <para>
       Run the command <command>intimate-install</command> - the script will mount your Intimate partition and begin downloading the base packages. It will then attempt to perform some minor configuration tasks on the partition and then go into a second stage install which downloads useful packages like an X server from the Intimate feed.
       </para>
     </listitem>
     <listitem>
       <para>
       When the install has completed, reboot your iPAQ, again selecting the HDD <application>bootldr</application> option. This time, instead of booting to the X/terminal/keyboard setup you saw previously, Intimate should boot to an X server and run a window manager and terminal.
   </para>
     </listitem>
    </orderedlist>
   <para>You should now have Intimate completely installed and, as far as this document is concerned, you are on your own. At this point, you can install applications, tools, etc. as you would on any Debian machine - usually with <application>apt-get</application>. The Intimate mailing list (see <ulink type="http" url="http://intimate.handhelds.org">http://intimate.handhelds.org</ulink>) and/or IRC channel can help you progress from here.
   </para>
 </sect1>
 <sect1 id="AppendixA"><title>Appendix A: Creating your own initrd</title>
 <para>
 The initrd image is incredibly easy to make - simply download the existing initrd image (see Section 2) and rename it to <filename>initrd.cramfs.gz</filename>. Unzip it (<command>gunzip initrd.cramfs.gz</command>) and then mount it using the loopback device (e.g. <command>mount -t cramfs -o loop initrd.cramfs /mnt/initrd</command>). Since the cramfs image is read-only, you will need to copy out all of the files before changing/adding any (e.g. <command>cp -av /mnt/initrd/* /tmp/initrd/</command>). Now make any changes you want and run the following commands to remake the image:
 <orderedlist>
   <listitem>
     <para>
     <command>chmod -R root.root /tmp/initrd</command> - files must be owned by root.root in the initrd
     </para>
   </listitem>
   <listitem>
     <para>
     <command>mkcramfs /tmp/initrd/ /tmp/initrd.cramfs</command> - this makes a new cramfs image from the working directory (you may need to install <application>mkcramfs</application> for this to work)
     </para>
   </listitem>
   <listitem>
     <para>
     <command>gzip /tmp/initrd.cramfs</command> - zip the cramfs image to reduce its size
     </para>
   </listitem>
  </orderedlist>
  You can now rename the new image to <filename>initrd</filename>, remove the existing initrd from the vfat partitions <filename class="directory">/boot</filename> directory and put the new one in its place.
  </para>
  <note><title>What about upgrading the kernel?</title>
  <para>This is not yet a simple process - you will need to put new kernel modules into the initrd, put a new <filename>zimage</filename> for your kernel into the vfat partition and put the new kernel modules into <filename class="directory">/lib/modules</filename> on your ext3 Intimate partition.
  </para>
  <para>We are working on automating this process</para>
  </note>
 </sect1>
 <sect1 id="credits"><title>Credits</title>
 <para>
 This document was written by Chris Jones (Ng), with help from Jim Conner (Tangent). Originally based on a textfile by Ron Wolfe
 The Intimate install script was written by Chris Jones, with help from Paul Hedderly (prh).
 </para>
 </sect1>
</article>

