I wanted big-endian emulation on my little-endian Intel machine to test a program for byte order related issues. QEMU PowerPC emulator seemed like a good solution. I have documented the steps to set it up in this note.

  1. Installed QEMU.
    nifty:~# aptitude update &&
    aptitude install qemu
  2. Downloaded Mac-on-Linux from http://sourceforge.net/projects/mac-on-linux/files/ and copied the 'video.x' file in the download to '/usr/share/qemu'. This was necessary to prevent qemu-system-ppc from complaining about it.
    nifty:~# tar -xjf
    nifty:~# cp mol-
  3. Downloaded Debian for PowerPC and installed it on a QEMU hard disk image.
    susam@nifty:~/qemu\$ wget
    2010-06-19 02:55:06
    -> "debian-504-powerpc-CD-1.iso" [1]
    susam@nifty:~/qemu\$ qemu-img create powerpc.img
    Formatting 'powerpc.img', fmt=raw size=2147483648
    susam@nifty:~/qemu\$ qemu-system-ppc -hda
    powerpc.img -cdrom debian-504-powerpc-CD-1.iso -boot d -m 512
  4. Booted the QEMU PowerPC emulator with the hard disk image.
    susam@nifty:~/qemu\$ qemu-system-ppc -hda powerpc.img -m 512
  5. Verified that I was really on a big endian system by writing a simple C program.
    susam@lilliput:~\$ cat
    #include <stdio.h>

    int main() { int n = 0x1; printf(*((char *) &n) ? "little-endian\n" : "big-endian\n"); return 0; } susam@lilliput:~\$ gcc endian.c && ./a.out big-endian susam@lilliput:~\$

In case you missed the pun, Lilliputians were originally big-endians.

No comments

Post a comment