Sunday, 24 June 2007

Testing Linux4Palm on qemu

Anyone who's done some handheld hacking will know that testing on a physical device is usually a real pain. If the lack of decent input and tiny screen don't get to you then it's the tiring compile, copy-to-sd, put-sd-in-handheld, test, reboot, put-sd-back-in-pc, fix-code cycle. Today I'm going to explain how you can boot an unmodified linux4palm kernel zImage and rootfs inside the emulator qemu. First though a big thanks to Andrzej "balrog-kun" Zaborowski who as part of his work for OpenedHand added support for XScale processors to qemu and helped Marek and I get the Hack&Dev kernel working properly within it.

Installing qemu (with H&D patches)

Windows

It's your lucky day, we're making things easy. Grab these binaries and unzip them somewhere.

Linux and others

Today I committed the OpenMoko qemu tree with the palm machine support patches into H&D SVN. So the first step is to grab a copy of tree:
svn co https://hackndev.svn.sourceforge.net/svnroot/hackndev/qemu/trunk qemu-hnd
cd qemu-hnd
Alternatively get the version I wrote this guide against from the SF release page. Next you'll need to make sure you have gcc 3.x installed (look for /usr/bin/gcc-3.*). Unfortunately qemu will not build with gcc 4. Gentoo users can grab 3.4.6 with:
emerge -av =gcc-3.4.6-r2
Next we configure and make, choosing only to build the arm-softmmu target and using the 3.4.6 compiler:
./configure --disable-system --disable-user --target-list=arm-softmmu --cc=gcc-3.4.6
make -j3
Once the build is complete, you'll find a qemu-system-arm executable in arm-softmmu/.

Booting qemu

You can check which machines qemu supports using this command:
./arm-softmmu/qemu-system-arm -M ?
As of this writing the partially supported palms are palmld, palmt650, palmt680, palmtc, palmz72 and palmtx. Grab and unpack a bootpack for your desired machine. I'm going to use Stepan's Fire and Water 0.0.3 palmld bootpack as an example.

Now simply fire up qemu, telling it to use the kernel and rootfs from the bootpack. I'm omitting the initrd since the palmld bootpack expects to boot off the HDD but it's easier to boot it off the SD card in qemu. The psplash=false option is to disable the OE splash screen so that I can view the startup messages.

./arm-softmmu/qemu-system-arm -M palmld -kernel zImage \
    -sd Angstrom-opie-image-palmld-0.0.3-alpha.rootfs.ext2 \
    -append "root=/dev/mmcblk0 psplash=false"
It may take a while to boot so be patient. Eventually you should see the OPIE touchscreen callibration screen:

Since qemu doesn't currently support the palms' touchscreens press Ctrl+Alt+3 to get to the serial console. You can then login as root. Press Ctrl+Alt+1 if you want to get back to the graphical output.

Edit: More screenshots

3 comments:

Avatar Ng said...

Tried Angstrom GPE on my iPAQ h2200 physical device, its working.

However didn't serve my purpose of running Java development on my device.

Embedded Java(linux arm distribution) doesn't seems to run on it. (however it runs on Familiar GPE distribution)

Angstrom GPE is fast, hence thinking of emulates it on my PC before deploying.

any idea?

Alex said...

You want to adapt Qemu for the h2200? That wouldn't be too hard, look into hw/palm.c or hw/spitz.c in the source, it's pretty straightforward.

If all you want is to debug java (yuck!) then you can just use a different machine's qemu and kernel with your h2200 rootfs. I'd suggest using Zaurus qemu as it has working touchscreen and keypad.

Alex said...

By the way, there's also special Angstrom images for qemu:

http://www.angstrom-distribution.org/unstable/images/qemuarm/
http://www.angstrom-distribution.org/unstable/images/qemux86/

I've never tried them though.