Linux port to the HTC Smartphones

Installing

You'll need a miniSD card and a SD card reader (with miniSD adapter). Put the card in your reader and check the device name under which it appears (usually /dev/sda, mine is /dev/sdc... be extra careful if you already have SCSI drives...). I will refer to this device as /dev/sdx.

There are two options for installing Linux on the miniSD card. The first one is to simply dump the provided miniSD images on a card. However, this will only work on an unlocked phone (see why here). The second option is to build EOL from the source and sign it with your miniSD unique identifier. This is also useful to install EOL on an already formated miniSD and still use it for storing data (make a backup of your data then!).

Note that to retrieve your miniSD unique identifier, you can boot from WinCE and read the identifier in /sys/class/mmc_host/mmc0/mmc0*/cid (see also "Using the Mini-SD image"). Unfortunately it's in reverse order and the first byte should be zeroed, so the following command should give you the CARDID to set in EOL Makefile:

sed 's/\(................\)\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)../00\8\7\6\5\4\3\2\1/' /sys/class/mmc_host/mmc0/mmc0*/cid | sed 's/\(................\)\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)/\1\9\8\7\6\5\4\3\2/'

Using a MiniSD image

Simply copy the image to the card:

# dd if=minisd.img of=/dev/sdx
and skip to the section "Booting".

Building and installing EOL

To compile EOL, you need the ARM toolchain from handhelds.org. You also need Perl, with the installed and working NbfUtils package, for building the encrypted SD card image. Extract the EOL archive:
$ tar xvfz eol-0.5.tar.gz
$ cd eol-0.5
Unless your phone is unlocked, edit the Makefile and replace the CARDID with your miniSD unique identifier, zeroing the first byte. Make sure MODEL matches your phone model as well. Build EOL:
$ make
Install it on the miniSD:
# ./mkbootimg /dev/sdx boot.img
If the above line complains there is not enough room on the miniSD, you will have to repartition it (and thus lose data already present on it).

Installing the OS

To install the Linux kernel, copy arch/arm/boot/Image to the SD card.
# mount /dev/sdx1 /mnt
# cp linux/arch/arm/boot/Image /mnt/IMAGE.BIN
# umount /mnt
The rest of the distribution is not done yet. You can use this initial ramdisk image to have a minimal userland in the meantime. Simpy copy it to the miniSD as well.
# mount /dev/sdx1 /mnt
# cp initrd.bin /mnt/INITRD.BIN
# umount /mnt

Installing the configuration file

EOL reads its configuration from the eol.conf at the root of the filesystem. The syntax is very limited for now and similar to lilo.conf. Simply install it by copying it to the miniSD:
# mount /dev/sdx1 /mnt
# cp eol.conf /mnt/
# umount /mnt

Booting

Turn off your phone, install your miniSD under the battery. Press and hold the camera button (on the right), then press the power button (on the top) for half a second or so, then release the power button, and wait for a white screen to appear. If the splash screen logo appears instead you pressed the power button for too long, wait for the phone to boot then turn it off again and try again. The white screen should read:

SD MFG image
<- Press this key
   Start Download

Download SD image?

You have 5 seconds to press the volume down button (on the left) to start loading the image. If you were not quick enough or something went wrong you will see the tricolor SPL screen. Power down your phone and try again.

Now the EOL bootloader should be loading (black screen written in white) and proceed to the boot menu. Booting back to WinCE or turning off the phone is not supported yet, you have to remove your battery if you want to do so.

Using the Mini-SD image

A MiniSD image should contain a bootloader, a kernel and a basic userland for testing. It boots with framebuffer activated, and you should be able to connect to the phone through USB. On the PC, load the 'usbnet' module and configure the usb0 interface with:
modprobe cdc_ether
modprobe usbnet
ifconfig usb0 up 192.168.9.1
You can then connect to the phone with telnet:
telnet 192.168.9.10
login is 'root' with no password.

If things don't work, check lsusb (should report: Netchip Technology, Inc. Linux-USB Ethernet/RNDIS Gadget). The message 'usb0: full speed config #1: 100mA, Ethernet Gadget, using CDC Ethernet' should appear on the phone screen as you plug the USB cable.