Recently I have been playing around to get Windows XP to run on my Android ARM phone. After a decent amount of research and work done (found out later that most of it was unnecessary) I managed to get proof of concept Windows XP to boot with usable resolution, network, and no sound ;) Like my colleague said: Just because I can ;)
Photos for the curious
The host (Samsung Galaxy S2, a tablet, etc)
First of all you need to face the obvious – your device is ARM-based, and Windows XP runs on x86 architecture. So what you need is an x86 emulator, and it means that it will not be that fast. QEMU is a popular and efficient choice nowadays when you need different architectures for your guest systems. Years ago I used it to run a proof of concept PPC Mac OS X on an Intel box, it was terribly slow on an Athlon 900 but it worked.
Fortunately on my Android I had already prepared a playground for myself to run various things – see my post about Gentoo on Android (it is not a must, but the article assumes you do have Gentoo – otherwise you are on your own to get qemu for your device). Aside from allowing you to run a ssh server, cron and maybe a web server – Gentoo provides you the power to compile a lot of software natively (build=host=target) to ARM as your CHOST in /etc/make.conf states.
To save your time I will tell you ahead, that none of currently available (in portage) versions of qemu worked for this setup. I did not take precise notes, but it is ok to assume that versions 0.11.1* will cause your Windows XP to bluescreen and reboot before the boot logo appears and will drop you to “last good configuration” boot menu. The 1.0* will just say “Aborted” on the command line. Version 0.9 and before should theoretically work (these have a different approach to TCG/TCI), but require either working gcc-3 to build or heavy patching for gcc-4.
I have tried both approaches. The gcc-3 (for qemu-0.9) does not support armv7a. Cross building for amrv6j with gcc-4 was a horror and it failed anyway, triggering even unmasking newer binutils as the linker had emulation mode / ABI issues. Trust me, this is not a good way to go. To build with gcc-4 – there are no high quality qemu patches (tried many various combinations) to successfully build specifically on an ARM host for x86 target. These just failed, and actually even if it built successfully I would not trust the emulation to work reliably anyway.
So the quick answer is: go with qemu-0.15.1. It is not included in the portage tree (not even as masked), but you can add it to your local overlay using qemu-0.11.1-r1.ebuild as a base ebuild (the -r1 includes a security patch). You will need to disable the code handling –disable-kqemu configure option, get the usual files directory and digest the ebuild. Here is mine qemu-0.15.1.ebuild file.
Edit your /etc/make.conf to include:
QEMU_SOFTMMU_TARGETS="arm i386" QEMU_USER_TARGETS="arm i386"
I put the ARM target just for any future use. Then issue:
# emerge -va qemu
And have it compiled and ready for use. But wait, there’s more.
To access your Windows XP you will need a VNC client. This simplifies the overall GUI situation greatly. Get androidVNC from the market and set Input Method to Touchpad, as it seems to work reasonably well (scrolls the display following the cursor, single tap – single click, double tap – right click, slow double tap – double click). You might also want to get Hackers Keyboard to be able to type in a more comfortable way if you don’t have it yet. In androidVNC – tap and hold, and then tap the small keypad icon on the bottom to get to the keyboard.
And last but not least – have at minimum 2GB free storage on your device for disk image file.
Now when your Android is ready you should set-up the system image (actually a disk image is enough). I used qemu-0.11.1 on my main workstation. This version exposes a different network card to the guest than qemu-0.15 by default, but we will handle that later on, when running it on the destination device (model=ne2k_pci).
Create an x86 machine, with 128 (works) or 256 (better) MB of memory and a 2G (at least) disk image. Get a GUI (qemulator?) or in short:
# dd if=/dev/zero of=./qemu-winxp2g.bin bs=1M count=2048 # qemu -M pc -m 256 -net nic,vlan=0 -net user,vlan=0,hostname=emu \ -hda ./qemu-winxp2g.bin -cdrom ./windows-xp-install.iso \ -boot d -usbdevice tablet -localtime
Now do the usual installation (skip time zone auto adjustment for daylight saving) and remember to install all the updates. Additional things you might want to change then:
- set-up a classic start menu to easily fit it on screen (or leave the fancy one for easy tapping)
- disable grouping on the task bar (well, maybe this one is just my personal)
- disable system restore
- disable automatic updates (with all the consequences…)
- tweak screen resolution to 800×480 (for Galaxy S2 at least) – there are many ways to do that, including using emulated vmware vga driver (man qemu) or using Powerstrip – however I did not do this, as I can live with scrolling up and down, and some settings windows just fit
When done, shut down your Windows XP properly and transfer the disk image to the phone location of your choice, say:
# adb shell mkdir /mnt/sdcard/external_sd/VM # adb push ./qemu-winxp2g.bin /mnt/sdcard/external_sd/VM/
And yes, your SD card will get traffic like a real hard disk with all the swapping included, so bear it in mind if one day it dies unexpectedly.
Get a root shell on the phone. In the Gentoo chroot in this example you might just ssh to your phone – and issue:
# qemu -M pc -m 256 -net nic,vlan=0,model=ne2k_pci \ -net user,vlan=0,hostname=emu -vnc 127.0.0.1:2 -localtime \ -hda /android/mnt/sdcard/external_sd/VM/qemu-winxp2g.bin \ -boot c -usbdevice tablet
Then run androidVNC and connect to 127.0.0.1:5902. You might get disconnected while the system changes resolutions during the boot process. Just reconnect.
After ~10 minutes your Windows XP on Android should be booted and ready for use.
– Tasker / Tasks / New Task / “WinXP”:
– add: Secure Settings / Configuration – Edit / Run Command with (or equivalent):
/data/gentoo/do-cmd qemu -M pc -m 256 -net nic,vlan=0,model=ne2k_pci \ -net user,vlan=0,hostname=emu -vnc 127.0.0.1:2 -localtime \ -hda /android/mnt/sdcard/external_sd/VM/qemu-winxp2g.bin \ -boot c -usbdevice tablet
– add: Load App / androidVNC
Save, and then add a Tasker Task widget to the home screen, select this task and an icon, and you’re done.
And that’s about it. I did not configure sound, since my Gentoo has some issues with the phone’s alsa device – sound is pretty much stuck and heard just after a volume change – probably device access is conflicting with Android’s processes (well, fuser says nothing), so I left it as is for now. I hope you have a dual-core device to handle qemu load. I haven’t tried with qemu -smp 2, but YMMV.
One more photo if you have reached that far ;)
- Gentoo on Samsung Galaxy S2 (rootprompt.apatsch.net)