Thursday, July 9, 2009

Zipit Z2 bootloader hacking

Some time ago, I got quite nice device called Aeronix Zipit Z2 from Martin 'Magon' Kupec. The configuration is pretty normal - 32MB of RAM, 8MB of Flash, 312MHz PXA270C5. Moreover, the device is Linux-based, but running some proprietary userspace application.

Actually, the maker of the Z2 was kind enough and provided some patches and some hardware information (can be found here). I'm a little suspicious whether the patches and what's in the device correspond, but whatever. Unlike Palm Inc. (whose behavior towards Linux community is very disgusting and rude), the Z2 maker is very open to cooperation with Linux community and very supportive.

Anyway, just recently, I started hacking on a new bootloader for Z2 as the one the device is shipping with is total crap (details left out for the sake of mentally weaker readers). The bootloader of choice was u-boot again. In it's current state, the only problem with replacing BLOB (the original bootloader) with u-boot is that with u-boot, the LCD doesn't work even later in Linux, it just stays blank white. The rest of the hardware works (you can even boot kernel from MMC card, serial console is OK, Flash memory is supported etc.). I suspect the problem with LCD is some GPIO setup problem or PMIC setup problem and will need further investigation. Here's a simple howto to get an u-boot binary for your Z2:
  • Clone U-Boot-ARM sources: git clone git://git.denx.de/u-boot-arm.git
  • Download patch here and apply it to the sources
  • Run the following commands to compile U-Boot for Z2:
    • make CROSS_COMPILE=arm-linux-gnueabi- clean
    • make CROSS_COMPILE=arm-linux-gnueabi- zipitz2_config
    • make CROSS_COMPILE=arm-linux-gnueabi-
The above procedure will produce file called u-boot.bin. You'll need a serial port attached to Z2 to replace the BLOB bootloader. In case you happen to fail the process of replacing the bootloader, you'll have to attach JTAG adapter to the Z2 and reflash using JTAG.

BEWARE: THIS PROCEDURE IS DANGEROUS AND MAY PUT YOUR DEVICE TO UNUSABLE STATE (BRICK IT)! THE AUTHOR IS NOT LIABLE FOR ANY DAMAGE CAUSED BY APPLYING THE FOLLOWING PROCEDURE!

Ok, so if you are still brave enough, here's the procedure.
  • Run minicom terminal emulator on your PC, set serial port configuration to 115200Bd 8N1 (^A-o).
  • Power up Z2, press Enter repeatedly to interrupt autoboot ... you will get bootloader prompt (blob>).
  • On your PC, prepare two files from u-boot.bin by issuing the following commands:
    • dd if=u-boot.bin of=u-boot.bin.1 bs=64k count=1
    • dd if=u-boot.bin of=u-boot.bin.2 bs=64k skip=1
    The first file should be exactly 65536 bytes long, the second one should be a little shorter.
  • Now you have to send the files to the device. In the BLOB command prompt type "xdownload blob" without quotes and press ^A-s, select xmodem and navigate to the u-boot.bin.1 file. Send that one.
  • Once the above procedure succeeded, continue to sending second part of u-boot. In the BLOB prompt, type "xdownload kernel", do the same sequence as before, that is ^A-s, select xmodem, but this time send u-boot.bin.2 file.
  • Now finally you can flash the u-boot into the device. That is done by issuing the following two commands in BLOB prompt (this is the unsafe part, anything to this point was safe): "flash kernel" "flash blob". Once those complete, type "reboot" and you should get an u-boot prompt.
If the above worked, congratulations to your new Z2 with u-boot.

Just a final note to this patch, it needs cleaning up and fixing the LCD problem.

1 comment:

Unknown said...

Just wanted to thank you for this post, it helped me get the latest source working(u-boot 2008, Dec ). I had to manually merge the patch, but everything worked great.

In order to write it, I just did flash write_image u-boot.bin 0x00000000

I had to clear the protection bits first.

Thanks again!