Linux

Emulating PPC32 Linux in x86_64 Linux

I’ve recently needed to do some porting work for a PPC32 CPU running Linux. At the time I didn’t have any PPC hardware (I’ve since acquired a PowerMac G5). Of course when we don’t have hardware, we can normally emulate it. Here is how I set up the emulation so I can remember for next time.

There are a couple of things we need to start with. First of all, QEMU, this is a multi platform emulator which can be found in most Linux distributions. On my machine I installed this with the required PPC32 parts by running:

sudo apt install qemu-system-ppc openbios-ppc

Next up we need an OS to install. I needed something a little older than normal, Debian 8.11 PowerPC edition. After this I created a blank 12GB hard disk image using:

qemu-img create -f qcow2 powerpc32.img 12G

Then install the OS using the following, these options are documented at https://wiki.qemu.org/Documentation/Platforms/PowerPC:

qemu-system-ppc -L pc-bios -boot d -M mac99,via=pmu -m 1024 -hda powerpc32.img -cdrom debian-8.11.0-powerpc-DVD-1.iso

The installer will be somewhat familiar if you have ever installed a Linux distro before. I recommend not installing the GUI for Debian 8.11, the emulated CPU is very slow and GNOME wouldn’t work.

After a long wait for the installer to finish I created a file called boot.sh with the following contents:

qemu-system-ppc -L pc-bios -boot c -prom-env "boot-device=hd:,\yaboot" -prom-env "boot-args=conf=hd:,\yaboot.conf" -M mac99,via=pmu -m 2048 -hda powerpc32.img

Now running boot.sh will boot the PowerPC 32bit Linux image and give it 2GB of RAM.

The final piece needed for Debian 8.11 is the APT repositories. The default ones do not work, so in the VM you need to edit /etc/apt/sources.list, remove the cdrom line and add the following:

deb http://archive.debian.org/debian jessie main contrib non-free
deb-src http://archive.debian.org/debian jessie main contrib non-free

We are now good to go! Compile away and find any big endian based bugs!

Featured image by Baz1521, used under CC-BY-SA 3.0 license.

LinuxJedi

View Comments

Share
Published by
LinuxJedi

Recent Posts

Two special Amiga 4000s: Introduction

On Saturday, I was at a Norwich Amiga Group meetup, where I got to meet…

1 hour ago

Working with the AVR Dx family

In recent years, Microchip has launched a new range of AVR chips. They appear to…

5 days ago

My WordPress Slack ban

A couple of days ago, I got banned from the WordPress community Slack. As this…

6 days ago

Issues I found during WordPress.com to .org migration

Whilst migrating from wordpress.com to an installation of the open source WordPress, I hit some…

1 week ago

Why I moved my blog

Unfortunately, there is a war going on within the WordPress community. To stay as far…

1 week ago

Four new Amiga products for September 2024

Since the June Amiga Expo, I have been developing some new Amiga related products. I…

3 weeks ago