Tuesday, February 15, 2011

qemu with Z2 support

I spent some days getting qemu to emulate some Z2 hardware, and got some results :)
Almost all hw is emulated, it lacks only voltage regulator and WiFi, but it's not easy to implement Marvell's WiFi chip, because there's no datasheet, and anyway it makes no sense. Also screen rotation is not supported (yet).

Stock bootloader - blob - (with slight modification) and stock kernel works. Blob puts Z2 into deepsleep on reset, so I hacked it not to do this.

How to compile qemu:

So, how to hack blob:
  • put your blob image (first 64kb of NOR) somewhere
  • convert it to hex representation with xxd: xxd mtdblock1.bin >mtdblock1.hex
  • apply patch onto mtdblock1.hex
  • convert hex back to bin: mv mtdblock1.bin mtdblock1.bin.bak; xxd -r mtdblock1.hex >mtdblock1.bin
I don't put modified nor original blob binary anywhere, as I doubt it's legal.

How to run stock sw:
  • cd qemu-z2; mkdir z2; wget http://downloads.tuxfamily.org/linuxrx1950/tmp/z2_start.sh
  • Combine mtdblocks into one flash image: cat mtdblock1.bin >z2_flash; cat mtdblock2.bin >>z2_flash; cat mtdblock3.bin >>z2_flash
  • So, z2 directory contains following files: z2_start.sh, z2_flash
  • Now just start z2_start.sh script
How to run latest kernel:
  • Use same z2_flash and z2_start.sh files from z2 directory
  • You'll also need kernel image - zImage (not uImage!)
  • Start z2_start.sh as follows: ./z2_start.sh -kernel zImage -append console=tty0
You can also use SD card image, just specify -sd image.filename as argument to z2_start.sh script

Update (2013-Nov-27): link to blob patch is updated!

Saturday, February 5, 2011

pxa270 powersaving

Some days ago I made a driver (named pxa270-voltage) to set cpu core voltage according to its frequency, it should improve battery life (but I did not perform testing). freq-voltage table was taken from cpufreq-2xx driver. If anyone can test and report if it really improves battery life - it would be nice.

Here's new patchset, precompiled binaries can be taken here, patches still should be applied ontop of Marex's tree

Also new patchset fixes race condition in pxa2xx-spi suspend handler.

P.S. This driver is just temporary solution until someone fix cpufreq on pxa270.

Thursday, February 3, 2011

Zipit Z2 kernel

Recently I did some stuff for Z2 kernel:
  • fixed bug in libertas (already submitted patches upstream)
  • added proper suspend/resume support for libertas
  • fixed wrong coefficient to convert adc value to battery voltage
  • fixed bug in Z2 ASoC driver (with detecting Z2 soundcard)
  • make Z2 resume only on power button and AC plug
Patches agains Marex's tree you can find here. cpufreq and cpu voltage regulator do not work, so don't enable them in kernel config.

PXA27x overlay in mplayer

Last week I was busy getting PXA27x overlay working, as it was pretty broken in mainline kernel. There were two problems: overlay driver somehow corrupted memory on second access to it, and actually it does not work. So I got following messages on dmesg, and of course no visible overlay plane:

[ 93.679574] overlay1fb_disable: timeout disabling overlay1
[ 95.601537] BUG: Bad page state in process sh pfn:a1b60
[ 95.601645] page:c0456c00 count:0 mapcount:0 mapping: (null) index:0x0
[ 95.601698] page flags: 0x200(arch_1)

First bug was successfully fixed by Russel King, here you can find his patch. It fixed memory corruption, but overlay still did not work.

Problem was in selecting planes Z-ordering in wrong time, so overlay was under main plane, and main plane has no transparency bit (rgb565 colorspace), so there was no way to make it visible. I fixed this issue, added some cosmetical fixes, and produced patch.

To use 2nd overlay (one with yuv colospace available) I created mplayer vo driver, here you can find patch for mplayer-1.0rc2, however it's easy to port it to newer mplayer versions (but I was not able to crosscompile mplayer-1.0rc3 nor mplayer-1.0rc4, did not investigate issues yet)

As result Zipit Z2@208mhz is now able to play mpeg4 video with qvga resolution without problems :) Of course, without scaler (so you can't down/up scale your video) - scaler from mplayer is _really_ slow.

Next point is getting some powersaving stuff working on Z2.