nbimg: HTC splash screen tool

nbimg is a command line tool which allows to convert HTC Splash Screen images from NB to BMP and create NB splash screens from BMP format. Any splash screen size is supported (yes, it works for Diamond or Athena at 640×480 resolution too).

=== nbimg v1.1
=== Convert NB <--> BMP splash screens
=== (c)2008 Pau Oliva - pof @ xda-developers
Usage: nbimg -F file.[nb|bmp]
Mandatory arguments:
   -F <filename>    Filename to convert.
                    If the extension is BMP it will be converted to NB.
                    If the extension is NB it will be converted to BMP.
Optional arguments:
   -w <width>       Image width in pixels. If not specified will be autodetected.
   -h <height>      Image height in pixels. If not specified will be autodetected.
   -t <pattern>     Manually specify the padding pattern (usually 0 or 255).
   -p <size>        Manually specify the padding size.
   -n               Do not add HTC splash signature to NB file.
   -s               Output smartphone format.
NBH arguments:      (only when converting from BMP to NBH)
   -D <model_id>    Generate NBH with specified Model ID (mandatory)
   -S <chunksize>   NBH SignMaxChunkSize (64 or 1024)
   -T <type>        NBH header type, this is typically 0x600 or 0x601

Example to convert a NB to BMP:

$ ./nbimg.exe -F diamond137.nb
=== nbimg v1.1
=== Convert NB <--> BMP splash screens
=== (c)2008 Pau Oliva - pof @ xda-developers
[] File: diamond137.nb
[] Image dimensions: 480x640
[] Encoding: diamond137.nb.bmp
[] Done!

Example to convert a BMP to NB:

$ ./nbimg.exe -F diamond137.bmp
=== nbimg v1.1
=== Convert NB <--> BMP splash screens
=== (c)2008 Pau Oliva - pof @ xda-developers
[] File: diamond137.bmp
[] Encoding: diamond137.bmp.nb
[] Image dimensions: 480x640
[] Done!


version 1.2+

version 1.1

version 1.0

Posted in android, HTC, linux | Tagged , , , , , , , , , | 22 Comments

Ubuntu Netbook Remix on HTC Shift

kornel has requested to post some instructions on installing ubuntu netbook remix on HTC Shift.

First, for those who still don’t know what UNR is, a picture is worth 1000 words:

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

Here are the instructions:

1) Go to System -> Administration -> Software Sources. Click on Third Party software. Click Add…, and add the following:

deb http://ppa.launchpad.net/netbook-remix-team/ubuntu hardy main
deb-src http://ppa.launchpad.net/netbook-remix-team/ubuntu hardy main

Then Click Close and Click Reload.

Advanced users can just add the above lines to their /etc/apt/sources.list (and run sudo apt-get update afterwards).

2) Install all netbook remix packages:

$ sudo apt-get install go-home-applet window-picker-applet maximus human-netbook-theme ume-launcher

3) Once installed, you’ll need to add maximus to autostart for your session. You’ll also need to setup the gnome-panel to look like the screenshots, basically:

  • Delete bottom panel
  • Setup top panel like: GoHomeApplet|WindowPickerApplet|NotificationArea|MixerApplet|Clock

UPDATE: This has been fixed in current ume-launcher version.

You’ll notice that the icons are very small by default, this is because UNR doesn’t support resolutions below 1024×600. I have done a patch to ume-launcher which increases the icon size, available in launchpad bug #237373.

So, if you prefer bigger icons, just download my patched ume-launcher_0.3ubuntu3_i386.deb, and install it.

Posted in linux | 12 Comments

HTCFlasher: Open Source ROM Update Utility (RUU) for HTC devices

I have just released HTCFlasher version 3, get it while it’s hot!! :)

HTCFlasher -formerly known as HERMflasher– is an open source tool which allows you to flash ROMs on most current HTC devices. It has some extra features that the original HTC RUU doesn’t have, like for example it can present a serial prompt to the bootloader (replacing mtty), or it can dump NBH file contents (.nb ROM parts).

Currently most new HTC devices are supported, and the basic set of functions to work with every HTC bootloader has been implemented, so adding support for new bootloader versions or new devices should be quite easy to do, if not working out of the box.

For an incomplete list, see SupportedDevices.

Supported Operating Systems

  • GNU/Linux x86 and x86_64
  • Win32/Cygwin (except Vista)
  • Mac OS X (intel based)


  • Flash NBH files: replaces the Windows Rom Upgrade Utility (RUU)
  • Extract NBH files: replaces windows tools like nbhextract
  • Serial prompt: replaces mtty / minicom
  • Easy to use Gtk GUI


Main Window
HTCFlasher main window

Flash NBH file
HTCFlasher flash NBH file

For more information:

Posted in linux | 5 Comments

shiftbuttons: HTC Shift Hardware Buttons control

shiftbuttons is a program that monitors the two right side hardware buttons on HTC shift, and launches any desired program when a button is pressed.

Typical usage is to start it as daemon (-d option) when you start your X session, and map each button to the desired function. For example, you can go into Gnome menu System -> Settings -> Sessions. There you find a tab named ‘Startup Programs’, and add the following:

    shiftbuttons -d -c \"gksudo /usr/bin/hsect2\" -r htcshift-rotate

This will launch hsect2 when you press the CommManager button, and will rotate the screen when you press the switch resolution button.

System wide configuration can be changed at /etc/xdg/autostart/shiftbuttons.desktop.

htcshift-rotate is also included in the tarball and the debian package.


Source code: shiftbuttons-1.0.tar.gz
Ubuntu / Debian package: shiftbuttons_1.0-1_i386.deb

Posted in linux | 9 Comments

gsensor-joy: HTC Shift G-Sensor Joystick Linux kernel module

I have found some free time (long night) to implement a kernel module which converts the axis reported by the HTC Shift G-Sensor accelerometer (see previous post!) into a Joystick input event device.



Install Instructions

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

   # make
   # make install

Load the needed modules:

   #modprobe i2c_i801
   #modprobe i2c_dev
   #modprobe gsensor-joy
   #modprobe joydev

If you want that automatically loaded every boot, you can also add them to /etc/modules.

For X.org configuration see the README file included in the tarball.

Here’s a demo video playing TuxRacer…

Continue reading

Posted in linux | 7 Comments

i2c-gsensor: LIS3LV02DL accelerometer on HTC Shift G-Sensor

The “feature” commercially advertised as G-Sensor in HTC Shift turned out to be a STMicroelectronics LIS3LV02DL 3-axis inertial sensor [datasheet], which of course can be accessed through linux i2c/SMBus interface :)

Actually there’s a Linux kernel module for the HP Mobile Data Protection System 3D (mdps) by Yan Burman, which is the same accelerometer used in some HP laptops, however those laptops have the accelerometer connected through an SPI interface instead of i2c, so the driver is not suitable for the HTC Shift as it is, but maybe in the future… πŸ˜‰

As a proof of concept, here’s an small userland tool that will show the output of X,Y,Z axis when moving the HTC Shift, just as if it was the Wii Remote :) To use it you need to modprobe i2c_i801 and i2c_dev modules first.

Download: i2c-gsensor.tar.gz.

Update (05/06/2008): gsensor-joy: HTC Shift G-Sensor Joystick Linux kernel module

Posted in linux | Leave a comment

hsect: HTC Shift Embedded Controller Toolkit

HTC Shift Embedded Controller Toolkit
I am proud to release hsect, the HTC Shift Embedded Controller Toolkit πŸ˜€


  • Turn on and off WLAN
  • Turn on and off Bluetooth
  • Enter and exit CE (ARM) Bootloader mode (SPL)
  • Enter Radio Bootloader / OEMSBL*
  • Reboot Windows CE
  • Switch To CE / SnapVUE
  • Change the LEDs*

* features only available via command line

This means you don’t need to boot Vista anymore to enable Wifi or Bluetooth after removing the battery, now you can do it on Linux or WinXP :)

Download binary package

Ubuntu / debian package: hsect_2.1-1_i386.deb
Windows cygwin executable (no GTK support): hsect-2.1win32.zip

Download source


Many thanks to Esteve EspuΓ±a who helped me with Syser, the Vista kernel debugger we used to understand how the EC Controller driver (ecdrv.sys) works, and to cmonex who told me the DeviceIoControl she uses in her windows program to enter and leave bootloader mode and reboot CE, which translate directly to the EC commands used in this tool.

Posted in linux, wireless | Leave a comment

htcpen: HTC Shift Touchscreen Driver for Linux

Here’s my first attempt to make the HTC Shift touchscreen working under Linux πŸ˜€

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.


htcpen version 1.6 (2008-05-28)
eGalax Xorg driver + TouchKit version 2.03

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\"

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.

Continue reading

Posted in linux | 5 Comments

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 0x88FE00000 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': 0x88FE00000 == 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.

Posted in linux | 10 Comments

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 πŸ˜‰

Posted in gadgets, linux | 1 Comment