htcpen: HTC Shift Touchscreen Driver for Linux

Here’s my first attempt to make the HTC Shift touchscreen working under Linux :D

Feel free to send me patches and ideas to improve the driver :)

Update: htcpen submitted to review for inclusion into Linux kernel.
Update2: htcpen has been included into the git input tree, it will be merged when 2.6.27 opens up.

Download

htcpen version 1.6 (2008-05-28)
htcpen-1.6.tar.gz
eGalax Xorg driver + TouchKit version 2.03
TouchKit-2.03.172.tar.gz

Install instructions

Download the tarball, extract it to some temporary directory, compile and install it:

# tar zxvf htcpen-1.6.tar.gz
# cd htcpen-1.6
# make
# make install

X.org configuration:

   # tar zxvf TouchKit-2.03.172.tar.gz
   # cd TouchKit
   # cp egalax_drv.so /usr/lib/xorg/modules/input/

Edit /etc/X11/xorg.conf and configure the following:

   Section \"InputDevice\"
         Identifier \"htcpen\"
         Driver \"egalax\"
         Option \"Device\" \"/dev/input/event_htcpen\"
         Option \"Parameters\" \"/var/lib/egalax.cal\"
         Option \"ScreenNo\" \"0\"
   Endsection

Into your “ServerLayout” section, add the following line:

    InputDevice \"htcpen\" \"CorePointer\"

After rebooting your system, udev should load the htcpen module automatically and create a symlink of the input device to /dev/input/event_htcpen.

To finish, run “TouchKit”, click on “Tool” tab and do the 25 point calibration.

Llegeix la resta del post »

Arxivat a: linux | 5 Comentaris » | May 11th, 2008

How to dump and restore the Vista recovery partition on HTC Shift

The HTC Shift HDD is 40 GB, exactly 40000536576 bytes. The Host Protected Area starts at 0×88FE00000 and is exactly 3GiB, from linux dmesg output:

sda: Host Protected Area detected.
        current capacity is 71826615 sectors (36775 MB)
        native  capacity is 78126048 sectors (40000 MB)
sda: Host Protected Area disabled.
sda: 78126048 sectors (40000 MB), CHS=16383/255/63

Here’s the radare dump, showing the end of the Vista partition and the start of the Host Protected Area, where the Shift HDD stores the Vista recovery information.

Here is how gparted sees the HTC Shift partitions, the 3.00 GiB “unallocated” space at the end holds the vista recovery information, you can’t see this space in Vista.

So we can dump it using ‘dd’: 0×88FE00000 == 36773560320 , we will read & write 16384 bytes at a time, to speed up the process, so 36773560320/16384 = 2244480

# dd if=/dev/sda of=/media/disk/shift-vista-recovery.bin bs=16384 skip=2244480

If we keep the bin file in a safe place, we can happily use the unallocated space and gain 3GiB of space in our HDD.

The md5sum of my Spanish Vista is the following:

# md5sum shift-vista-recovery-es.bin
5c3a9ea3ea578419daf3f1f242755122  shift-vista-recovery-es.bin

If later on we need to restore it, to be able to recover vista using the Fn+F3 key combo at boot time, we must place it in the same place so, using ‘dd’ this would be:

dd if=/media/disk/shift-vista-recovery.bin of=/dev/sda bs=16384 seek=2244480

You can always boot from a USB pendrive using Slax, to perform the ‘dd’ operations.
Note: Replace ‘/dev/sda’ for ‘/dev/hda’ if using Slax.

Arxivat a: linux | 7 Comentaris » | April 22nd, 2008

Suspend / resume in HTC Shift

After a dozen of reboots and hangs trying to figure out what was preventing the suspend / resume to work on HTC shift I finally managed to get it working (both, suspend to ram and hibernate are working :D )

The pm-utils offer a nice interface for hooking your own scripts which are called during the suspend/hibernate and wake up events, so just removing the bogus modules and doing a bit of magic with dbus messages to stop and start wifi in NetworkManager the Shift is suspending properly in a matter of seconds and coming back to live even faster than Vista.

Download the suspend scripts for HTC Shift here, tested on Ubuntu 8.04:

To install:

$ sudo tar zxvfp suspend-shift-v1.tgz -C /

Enjoy ;)

Arxivat a: gadgets, linux | 1 Comentari » | April 21st, 2008

Installing Ubuntu without CD and without Network

Previously I used Wubi-installer to install Ubuntu 8.04 on my HTC Shift, but this time I wanted to partition my Hard Drive and use separate partitions for Ubuntu. Here’s what I did…

First, resize the Vista partition: You don’t need Partition Magic or gparted to do this, vista itself can do it. Right click on my computer, select Manage, click on Disk Management, Right click on the partition you want to shrink.

Then create 2 (or more) partitions using the Vista Computer Management console, one should be around 1Gb, which we will use to place the Ubuntu ISO image. Later on, when installation is finished you can use it as a swap partition. In the HTC Shift you must create these two partitions using Vista Disk Management tool, if you do it with Linux you can easily damage the Host Protected Area partition which holds the Vista Recovery (Fn + F3 at boot time), so it is safer to do this with Vista.

Now install Slax on a USB Pendrive. When installed, copy the following files to the PenDrive too:

Now boot using the USB stick (on HTC Shift, Fn+F10 at boot time). Once Slax has booted, use cfdisk to setup your Linux partitions, remember you need to leave a ~1Gb ext3 partition for the ISO.

Format the 1Gb partition as Ext3 (change XX to your partition number):

mke2fs -I 128 -j /dev/hdaXX

the ‘-I 128‘ is to set the inode-size to 128 as grub can’t read bigger inode sizes, and Slax formats to 256 by default.

Mount the partition in /boot:

# mount /dev/hdaXX /boot

Install grub package on Slax:

# cd /mnt/sda1
# installpkg grub-0.97-i486-3.tgz

Copy the files needed to boot Ubuntu installer on the 1Gb partition:

# cp ubuntu-8.04-alternate-i386.iso vmlinuz initrd.gz /boot
# cd /boot ; ln -s . boot

Create the ‘menu.lst’ file for grub:

title Install Ubuntu
root (hdX,Y)
kernel /boot/vmlinuz vga=normal ramdisk_size=14972 root=/dev/rd/0 rw --
initrd /boot/initrd.gz

hdX,Y should be changed to the value matching your partition, in my case it was (hd0,2) which refers to the 1st hard drive ‘hd0′ and the 3rd partition ‘2′.

Now Install grub:

# grub-install /dev/hda

Reboot, and ubuntu installation should start. Remember not to screw the 1Gb partition during the installation, you can safely remove it once ubuntu has been installed.

Arxivat a: gadgets, linux | 3 Comentaris » | April 19th, 2008

Linux on HTC Shift

I recently got an UMPC HTC Shift (also known as HTC P9500, HTC Shangrila or HTC Clio).

You can install Ubuntu Hardy 8.04 using Wubi Installer, so you don’t need to partition the Hard Drive. Installation is pretty straight forward, just choose the installation size (I would recommend no less than 7Gb) and click “next”, “next”… If you prefer to install on a separate partition, follow the instructions here.

Once Ubuntu is installed, you get a menu at boot time which lets you choose which operating system to boot, Vista or Ubuntu. Surprisingly most of the hardware is auto-detected by ubuntu, and almost everything works out of the box:

  • Audio is working, mute and volume control works using the Fn keys.
  • SD card reader is working.
  • Adjusting the screen backlight works with the proper Fn keys.
  • Webcam is working (you can test it with gstreamer-properties).
  • CPU frequency scaling works by default too on the Intel Stealy 800Mhz CPU, you can monitor it by enabling the cpufreq gnome pannel.
  • ACPI is working, you can get the CPU temperature using the sensors-applet.
  • Screen resolution works at 800×480. I have not tried higher resolutions yet.
  • Bluetooth is working.

However there are a few things that require some extra work in order to have them working properly. I’ll walk through some of them in this post.

Setting up HTC Shift “The Easy Way”TM

If you are running Ubuntu/Kubuntu/Xubuntu 8.04, I have created a script which will automatically setup the following:

  • TouchScreen
  • Wifi
  • 3G Connectivity
  • suspend/resume
  • Hardware buttons support
  • rotate screen utility
  • Embedded Controller Toolkit (lets you enable/disable wifi and bluetooth)

You can download it from here:
htcshift-easy-setup-v1.2.tar.bz2

Install Instructions:

Put htcshift-easy-setup-v1.2.tar.bz2 in a USB memory stick, insert it in the Shift and Ubuntu will automatically mount it as /media/disk/. Then issue the following commands:

$ sudo tar jxvfp /media/disk/htcshift-easy-setup-v1.2.tar.bz2
$ cd htcshift-easy-setup
  • Run ‘sudo ./install.sh kernel‘ for keeping the default usb-rndis kernel modules: If you choose this option, the provided USB ethernet will work, however you will not be able to use 3G connectivity or to transfer files from WinCE using synce.
  • Run ‘sudo ./install.sh synce‘ for keeping the synce usb-rndis kernel modules: If you choose this option, you will be able to use 3G connectivity and to transfer files from WinCE using synce, however the provided USB ethernet will not work.

After installation, the two right side hardware buttons will be mapped to launch hsect2 (enable/disable wifi & bluetooth) and to rotate the screen, and you should have the following new items in Accessories menu:

  • TouchKit (Touch Screen Calibration Utility)
  • HTC Shift Embedded Controller Toolkit
  • Rotate Screen

You can switch from kernel to synce or viceversa at any time, just run the install.sh again.

To use 3G, you need to run USBTool.exe on CE, select “Attach to Vista”, then open the “Internet Sharing” application on CE and click “Connect”. Switch to linux, you should get the network settings over DCHP on rndis0 interface. Ubuntu’s NetworkManager sees it as a wired network.

Now I’ll explain the “long dificult way”TM, for those who don’t want to use my script or have a different kernel version or distribution.

Wi-Fi: Marvell SD8686 Wireless Lan SDIO

The wlan card does not work by default, the driver for it is missing in ubuntu 8.04 beta. I have submitted a bug report, so hopefully it is included in the final 8.04 release, but at the moment you have to compile the driver yourself. Luckily for us, Marvell has published an open source driver plus a proprietary firmware which allows the wifi to work. The sources are available on the linux-ubuntu-modules-2.6.24 package.

To compile it, download the linux-ubuntu-modules package source, untar it and edit the file ubuntu-hardy-lum/debian/config/i386 to add the following:

CONFIG_MMC_SD8686=m
CONFIG_MMC_SD8688=m

Then compile it using ‘dpkg-buildpackage‘, the resulting module will be in ubuntu-hardy-lum/debian/build/build-386/wireless/marvell/8686_wlan/sd8686.ko, copy it to your /lib/modules and run depmod -a.

You also need to place the proprietary Marvell firmware to /lib/firmware/mrvl/ directory, the firmware can be downloaded from Marvell’s website here.

To get the wifi loaded automatically at boot time edit /etc/modules and add ’sd8686′.

3G/HSDPA connectivity

3G connectivity is achieved through the CE / SnapVUE side, the same way you do it in Vista, but using the usb-rndis-lite linux module from SynCE. It just allows you to tether the “embedded” MSM7200 device in the Shift with the x86 side, using the USB connection that links them.

For it to work, you first need to get synce (which will also allow you to sync Ubuntu contacts and appointments with CE, share files between both systems, etc…) and the SVN version of the rndis-lite module:

$ sudo apt-get install synce-dccm synce-multisync-plugin synce-serial libsynce0 libsynce0-dev librra0 librra0-dev librra0-tools subversion build-essential
$ svn co http://synce.svn.sf.net/svnroot/synce/trunk/usb-rndis-lite/
$ cd usb-rndis-lite/
$ make
$ sudo ./clean.sh
$ sudo make install

You can also follow the Synce With Ubuntu instructions on SynCE website.

To enable 3G connectivity, you need to switch to CE, use the USBTool.exe utility to “Attach to Vista” (this will enable the USB connection between the PocketPC side and the PC side) and then enable “Internet Sharing” in WM6. Network settings can be acquired through DHCP on interface rndis0.

Fingerprint Reader: AuthenTec AES1610

Ubuntu 8.04 does not have support for the AuthenTec AES1610, however this reader is supported in Linux using the fprint library. Unfortunately the current version doesn’t seem to work very well (it fails recognizing the fingerprint most of the times), but if you want to try it, there are some precompiled ubuntu packages in launchpad. To install them, add the following line to your /etc/apt/sources.list:

deb http://ppa.launchpad.net/madman2k/ubuntu hardy main restricted universe multiverse

Then install the libpam-fprint + libfprint + fprint-demo packages:

$ sudo apt-get install libpam-fprint libfprint0 fprint-demo

You can test the reader by running gksudo /usr/bin/fprint_demo.

Touchscreen

Finally we have a working touchscreen, read instructions on this post:

htcpen: HTC Shift Touchscreen Driver for Linux

What still doesn’t work

  • touch screen: Touchscreen working with htcpen driver :D The touch screen is not working yet, AFAIK there is no driver for linux (nor for Windows XP). Vista uses a “HTC Touch Screen Driver, V1.0.0.2″ which will need to be disassembled first. Meanwhile you’ll have to use the Synaptics Touchpad, which does its job nicely.
  • suspend: Suspend works, but the device doesn’t resume properly. I’ll have to look what is preventing it to resume, and probably disable the offending device driver before suspending. Will post more details if I get it working. download the suspend / resume scripts for HTC Shift here :D

Screenshots

To finish, a couple of screenshots, click on them to maximize.

linux on HTC Shift 1 linux on HTC Shift 2 ume-launcher on HTC Shift 1 ume-launcher on HTC Shift 2

Arxivat a: gadgets, linux | 84 Comentaris » | April 14th, 2008

Linux en HTC Hermes

Per fi, htc-hermes pot correr linux:

/ # uname -a
Linux hermes 2.6.20-hh6 #66 Sat Apr 7 14:12:59 EDT 2007 armv4tl unknown
/ # cat /proc/cpuinfo
Processor       : ARM920T rev 0 (v4l)
BogoMIPS        : 199.47
Features        : swp half thumb
CPU implementer : 0x41
CPU architecture: 4T
CPU variant     : 0x1
CPU part        : 0x920
CPU revision    : 0
Cache type      : write-back
Cache clean     : cp15 c7 ops
Cache lockdown  : format A
Cache format    : Harvard
I size          : 16384
I assoc         : 64
I line length   : 32
I sets          : 8
D size          : 16384
D assoc         : 64
D line length   : 32
D sets          : 8
	
Hardware        : HTC Hermes
Revision        : 0000
Serial          : 0000000000000000

Passos per crear una imatge del kernel desde zero:

  $ export CVSROOT=:pserver:anoncvs@cvs.handhelds.org:/cvs
  $ cvs login
  $ cvs co linux
  $ emerge crossdev
  $ crossdev -t arm
  $ make htchermes_defconfig

Passos per utilitzar la imatge de kevin2:

haret + zImage + default.txt:


set KERNEL zImage
bootlinux

Més informació:

Gràcies a cr2 i a kevin2!

Enjoy! :D

Arxivat a: gadgets, linux | 7 Comentaris » | April 10th, 2007

SIM-Unlocker per a HTC Hermes

Després d’una nit llaaarga he publicat el primer sim-unlocker gratuït per a HTC Hermes, el que faig flashejar una rom de radio parchejada utilitzant la utilitat de flash de la HTC Magician que checkeja el checksum al final. Les modificacions a la rom de radio el que fan és que el codi d’unlock sigui sempre el mateix, i a més et fan el dispositiu SuperCID i SecLevel=0 que permet flashejar qualsevol rom sense checkejar el CID. Aquestes dues coses es perden quan es reflasheja la rom de radio, pero el teléfon continua sense sim-lock per sempre :)

Podeu descarregar l’unlocker i veure les instruccions per treure el sim-lock aquí: http://pof.eslack.org/hermes-unlocker/

Per fer l’unlocker he fet enginyería inversa del unlocker comercial de imei-check, que val 20 pounds, tot el procés l’he explicat en aques thread de xda-developers.

Arxivat a: Uncategorized | 23 Comentaris » | November 6th, 2006

Coses sobre HTC i xda-developers

HTC Hermes

Fa dos mesos que no feia cap post… he estat mooolt liat aquests dos mesos, a part de feina i estudis, desde que em vaig comprar la HTC Hermes (TyTN) m’he enganxat moltíssim a hackejar-la… de tant en tant rebo algun mail de gent que em pregunta coses sobre la Hermes, donçs totes les respostes les teniu a xda-developers:

Desde el primer moment el meu objectiu era bootar un kernel de Linux, per desgràcia això encara no és possible, pero havia de conèixer al màxim el dispositu per tal d’arribar a fer-ho. El primer pas va ser aprendre com funcionava el nou format NBH dels upgrades de ROM, per poder extreure les diferents parts. Aquest format ha canviat respecte a versions anteriors de PDAs de HTC, pero pel que sembla tots els nous dispositius d’HTC utilitzaràn aquest format a partir d’ara (Treo750, Trinity, Artemis, Excalibur, StarTrk, etc…).

Despres he estat investigant moltissim sobre el bootloader de la Hermes, gràcies a l’ajuda de l’esteve vam descobrir com autenticar-nos al bootloader amb el password correcte que es genera dinàmicament i permet utilitzar totes les comandes.

Gràcies a alguns contactes, he anat aconseguint ROMs en primicia, no només per a la Hermes sinó també per a altres dispositius d’HTC:

També he pogut extreure roms de radio, per actualitzar només la radio stack sense haver de fer hard reset, gràcies a les fotos que ha publicat la gent que ha obert la Hermes (jo encara no m’he atrevit!) hem anat descobrint el hardware que porta dins, molt útil per al port de Linux, he estat ajudant a gent que s’ha carregat la Hermes fent un upgrade, etc, etc… no acabaría mai: ja porto 870 posts als forums de xda-developers :)

Ara mateix estic intentant fer enginyeria inversa sobre el unlocker de imei-check per treure-li el simlock a la Hermes i oferir un unlocker gratuït, simplement per apendre com funciona la “security area” i la rom de radio :)

Ah! i se m’oblidava: em vaig comprar una segona HTC Hermes per ebay ($400), un model de preproducció amb security level 0 i SuperCID, molt útil per apendre com funciona la Hermes realment ;)

Ja us contaré més coses, ara vaig a preparar-me la maleta que demà me’n vaig cap a Alemania una setmaneta de vacances…

Arxivat a: gadgets, linux, personal, trips | 6 Comentaris » | October 25th, 2006

Com comparar dos fitxers de registre de windows

Últimament estic flashejant una ROM nova a la PDA cada molt poc temps, i m’he cansat de anar customitzant el WM5 després de reinstalar cada cop, aixi que he exportat tot el registre després d’arrancar per primer cop i després he customitzat tot el que volia i he tornat a exportar el registre. El problema és que WM5 guarda el registre en format UTF16 i el diff només em deia que els fitxers eren diferents, però no me’ls comparava. He trobat una utilitat per comparar el registre que es diu regdelta, però és la versió 0.1 només funciona amb fitxers exportats per ell mateix, per tant no m’ha ajudat molt. Finalment he aconseguit fer el diff d’aquesta manera:

$ iconv -f utf16 -t iso-8859-15 full-reg1.reg > full1.reg
$ iconv -f utf16 -t iso-8859-15 full-reg2.reg > full2.reg
$ diff full1.reg full2.reg

Després he editat manualment el resultat del diff per deixar-lo correcte i m’he fet un .cab per instal·lar directament a la PocketPC amb WinCE CAB Manager.

Arxivat a: Uncategorized | 6 Comentaris » | August 25th, 2006

Aplicacions per a WM5

He fet una llista de les aplicacions que tinc instalades fins ara a la HTC TyTN, per recordar tot el que he d’instal·lar després d’un upgrade de ROM o d’un hard reset, es bastant semblant a la llista de la PDA2k que vaig fer fa temps, però he canviat algunes aplicacions per compatibilitat amb WM5 o per que n’he trobat de millors:

  • mToken: El millor client de ssh, també té telnet, traceroute…(comercial)
  • pocketPutty: Client de ssh gratuït
  • openvpn: Client de VPN.
  • MyIpConfig: Per veure la configuració de xarxa, al estil winipcfg.
  • vxUtil: ping, nslookup, traceroute, portscan i més utilitats de xarxa…
  • GPRS Traffic Monitor: Per portar un control del tràfic GPRS/3G (comercial)
  • PocketSNES: Emulador de SuperNES, per jugar al street fighter 2.
  • MameCE: port del mame per a pocketPC, per jugar al Pang.
  • SJPhone: Softphone SIP
  • x-lite ce: Un altre softphone SIP (comercial).
  • Skype: client de IM amb VoIP propietària.
  • WM5NewMenu: Afegeix un menú personalitzable al softbutton de la today screen.
  • SMSDRFix: Per veure el nom del contacte al costat del telèfon en un SMS.
  • Batti: Indicador de batería
  • Birthdays: Recorda els aniversaris a la today screen.
  • PIEPlus: Afegeix tabs i altres funcions al Pocket Internet Explorer (comercial).
  • PPC Task Manager: Task manager molt complet.
  • wififofum: Scanner de xarxes wifi amb soport de GPS.
  • hitchhiker: Scanner de xarxes wifi, intenta connectar automàticament a les xarxes obertes i detecta hotspots.
  • btCrawler: Scanner de Bluetooth.
  • Metro: Calcula la ruta més curta del metro, soporta metros de moltes ciutats.
  • Resco Explorer: Navegador de fitxers molt complert, client de ftp, browser de netbios i editor de registre (comercial).
  • TCPMP: Reproductor de video, per veure divx.
  • flash player: Plugin de flash.
  • Launcher: Per afegir accesos directes a les aplicacions que més utilitzem a la today screen.
  • AgileMessenger: Client de IM multiprotocol (jabber, gtalk, msn…).
  • PocketRAR: compresor/descompresor de rar i zip.
  • mbutton2: Task switcher que s’integra en la barra superior, imprescindible en qualsevol pocketpc
  • MortPlayer: El millor reproductor de mp3
  • Remote Display Control: Accedir a la pocketpc desde el PC, útil per fer screenshots.

Aplicacions específiques per a HTC TyTN:

…i crec que això és tot, però segur que me’n deixo alguna!

Arxivat a: gadgets | 5 Comentaris » | August 20th, 2006