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

Diagnosing an Amiga 1200 Data Path Fault

I recently acquired an Amiga 1200 motherboard in a spares/repairs condition for about £100 recently.…

2 days ago

Bare Metal “Hello World” on an STM32MP135F-DK

Whilst I do like working with STM32 development boards, some basic information I need can…

3 days ago

Two special Amiga 4000s: Diagnosing Jops

When I last left this blog series, the first of Stoo Cambridge's A4000s had gone…

6 days ago

Joining wolfSSL

At the beginning of November, I started working for wolfSSL. Now that I'm a week…

1 week ago

Two special Amiga 4000s: Rebuilding Jools

In my previous post, I had the Amiga 4000 known as Jools mostly repaired, there…

4 weeks ago

Two special Amiga 4000s: Repairing Jools

In my last post, I created a list of things I needed to repair on…

4 weeks ago